diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-05-12 21:44:10 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-12 14:44:10 +0200 |
commit | 2991a7cfe685ca9b42230b7030b9e7d0ece94c88 (patch) | |
tree | 72da0f02bc6279aeab1e641fb7d51527efcb9066 /app/javascript/mastodon/features/compose/components/search.js | |
parent | 44a3584e2d54488393e6f50e482ed61d2765e312 (diff) |
Use ES Class Fields & Static Properties (#3008)
Use ES Class Fields & Static Properties (currently stage 2) for improve class outlook. Added babel-plugin-transform-class-properties as a Babel plugin.
Diffstat (limited to 'app/javascript/mastodon/features/compose/components/search.js')
-rw-r--r-- | app/javascript/mastodon/features/compose/components/search.js | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/app/javascript/mastodon/features/compose/components/search.js b/app/javascript/mastodon/features/compose/components/search.js index 61ae9ce23..341d76920 100644 --- a/app/javascript/mastodon/features/compose/components/search.js +++ b/app/javascript/mastodon/features/compose/components/search.js @@ -8,19 +8,21 @@ const messages = defineMessages({ class Search extends React.PureComponent { - constructor (props, context) { - super(props, context); - this.handleChange = this.handleChange.bind(this); - this.handleKeyDown = this.handleKeyDown.bind(this); - this.handleFocus = this.handleFocus.bind(this); - this.handleClear = this.handleClear.bind(this); - } - - handleChange (e) { + static propTypes = { + value: PropTypes.string.isRequired, + submitted: PropTypes.bool, + onChange: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onClear: PropTypes.func.isRequired, + onShow: PropTypes.func.isRequired, + intl: PropTypes.object.isRequired + }; + + handleChange = (e) => { this.props.onChange(e.target.value); } - handleClear (e) { + handleClear = (e) => { e.preventDefault(); if (this.props.value.length > 0 || this.props.submitted) { @@ -28,7 +30,7 @@ class Search extends React.PureComponent { } } - handleKeyDown (e) { + handleKeyDown = (e) => { if (e.key === 'Enter') { e.preventDefault(); this.props.onSubmit(); @@ -39,7 +41,7 @@ class Search extends React.PureComponent { } - handleFocus () { + handleFocus = () => { this.props.onShow(); } @@ -69,14 +71,4 @@ class Search extends React.PureComponent { } -Search.propTypes = { - value: PropTypes.string.isRequired, - submitted: PropTypes.bool, - onChange: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onClear: PropTypes.func.isRequired, - onShow: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired -}; - export default injectIntl(Search); |