diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-04-22 03:05:35 +0900 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-21 20:05:35 +0200 |
commit | 1948f9e767c5c8f7cb52337ce777a61b5ad1a599 (patch) | |
tree | 4d5f3549f6e5fd88340bb3543e1eb2eafc47952c /app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx | |
parent | 27ea2a88c12835b491ea5537f934983470faf781 (diff) |
Remove deprecated features at React v15.5 (#1905)
* Remove deprecated features at React v15.5 - [x] React.PropTypes - [x] react-addons-pure-render-mixin - [x] react-addons-test-utils * Uncommented out & Add browserify_rails options * re-add react-addons-shallow * Fix syntax error from resolve conflicts * follow up 59a77923b368d48c590cd9f4a0c6b73ce972d33f
Diffstat (limited to 'app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx')
-rw-r--r-- | app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx b/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx index de8942d4d..6a80cf7a2 100644 --- a/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx +++ b/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx @@ -1,4 +1,4 @@ -import PureRenderMixin from 'react-addons-pure-render-mixin'; +import PropTypes from 'prop-types'; import { injectIntl, defineMessages } from 'react-intl'; import IconButton from '../../../components/icon_button'; @@ -19,51 +19,48 @@ const iconStyle = { height: null }; -const PrivacyDropdown = React.createClass({ +class PrivacyDropdown extends React.PureComponent { - propTypes: { - value: React.PropTypes.string.isRequired, - onChange: React.PropTypes.func.isRequired, - intl: React.PropTypes.object.isRequired - }, - - getInitialState () { - return { + constructor (props, context) { + super(props, context); + this.state = { open: false }; - }, - - mixins: [PureRenderMixin], + this.handleToggle = this.handleToggle.bind(this); + this.handleClick = this.handleClick.bind(this); + this.onGlobalClick = this.onGlobalClick.bind(this); + this.setRef = this.setRef.bind(this); + } handleToggle () { this.setState({ open: !this.state.open }); - }, + } handleClick (value, e) { e.preventDefault(); this.setState({ open: false }); this.props.onChange(value); - }, + } onGlobalClick (e) { if (e.target !== this.node && !this.node.contains(e.target) && this.state.open) { this.setState({ open: false }); } - }, + } componentDidMount () { window.addEventListener('click', this.onGlobalClick); window.addEventListener('touchstart', this.onGlobalClick); - }, + } componentWillUnmount () { window.removeEventListener('click', this.onGlobalClick); window.removeEventListener('touchstart', this.onGlobalClick); - }, + } setRef (c) { this.node = c; - }, + } render () { const { value, onChange, intl } = this.props; @@ -96,6 +93,12 @@ const PrivacyDropdown = React.createClass({ ); } -}); +} + +PrivacyDropdown.propTypes = { + value: PropTypes.string.isRequired, + onChange: PropTypes.func.isRequired, + intl: PropTypes.object.isRequired +}; export default injectIntl(PrivacyDropdown); |