Skip to content

Commit

Permalink
remove unneeded sCU
Browse files Browse the repository at this point in the history
  • Loading branch information
mfix22 committed Nov 20, 2018
1 parent 17c8036 commit 9b5b96c
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions components/ExportMenu.js
@@ -1,13 +1,14 @@
import React from 'react'
import enhanceWithClickOutside from 'react-click-outside'
import shallowCompare from 'react-addons-shallow-compare'
import { withRouter } from 'next/router'

import { COLORS, EXPORT_SIZES } from '../lib/constants'
import Button from './Button'
import CopyButton from './CopyButton'
import WindowPointer from './WindowPointer'

import { toggle } from '../lib/util'

const toIFrame = url =>
`<iframe
src="https://carbon.now.sh/embed${url}"
Expand All @@ -16,37 +17,20 @@ const toIFrame = url =>
</iframe>
`

class ExportMenu extends React.Component {
class ExportMenu extends React.PureComponent {
state = {
isVisible: false
}

shouldComponentUpdate(prevProps, prevState) {
return (
prevState.isVisible !== this.state.isVisible ||
(prevState.isVisible && shallowCompare(this, prevProps, prevState))
)
}

toggle = () => {
this.setState({ isVisible: !this.state.isVisible })
}
toggle = () => this.setState(toggle('isVisible'))

handleClickOutside = () => {
this.setState({ isVisible: false })
}
handleClickOutside = () => this.setState({ isVisible: false })

handleInputChange = e => {
this.props.onChange(e.target.name, e.target.value)
}
handleInputChange = e => this.props.onChange(e.target.name, e.target.value)

handleExportSizeChange = selectedSize => () => {
this.props.onChange('exportSize', selectedSize)
}
handleExportSizeChange = selectedSize => () => this.props.onChange('exportSize', selectedSize)

handleExport = format => () => {
this.props.export(format)
}
handleExport = format => () => this.props.export(format)

render() {
const { exportSize, filename, router } = this.props
Expand Down

0 comments on commit 9b5b96c

Please sign in to comment.