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.
This commit is contained in:
Yamagishi Kazutoshi 2017-05-12 21:44:10 +09:00 committed by Eugen Rochko
parent 44a3584e2d
commit 2991a7cfe6
79 changed files with 838 additions and 1128 deletions

View file

@ -22,28 +22,27 @@ const iconStyle = {
class PrivacyDropdown extends React.PureComponent {
constructor (props, context) {
super(props, context);
this.state = {
open: false
};
this.handleToggle = this.handleToggle.bind(this);
this.handleClick = this.handleClick.bind(this);
this.onGlobalClick = this.onGlobalClick.bind(this);
this.setRef = this.setRef.bind(this);
}
static propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired
};
handleToggle () {
state = {
open: false
};
handleToggle = () => {
this.setState({ open: !this.state.open });
}
handleClick (value, e) {
handleClick = (value, e) => {
e.preventDefault();
this.setState({ open: false });
this.props.onChange(value);
}
onGlobalClick (e) {
onGlobalClick = (e) => {
if (e.target !== this.node && !this.node.contains(e.target) && this.state.open) {
this.setState({ open: false });
}
@ -59,7 +58,7 @@ class PrivacyDropdown extends React.PureComponent {
window.removeEventListener('touchstart', this.onGlobalClick);
}
setRef (c) {
setRef = (c) => {
this.node = c;
}
@ -96,10 +95,4 @@ class PrivacyDropdown extends React.PureComponent {
}
PrivacyDropdown.propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired
};
export default injectIntl(PrivacyDropdown);