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:
parent
44a3584e2d
commit
2991a7cfe6
79 changed files with 838 additions and 1128 deletions
|
@ -8,33 +8,38 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||
|
||||
class Header extends ImmutablePureComponent {
|
||||
|
||||
constructor (props, context) {
|
||||
super(props, context);
|
||||
this.handleFollow = this.handleFollow.bind(this);
|
||||
this.handleBlock = this.handleBlock.bind(this);
|
||||
this.handleMention = this.handleMention.bind(this);
|
||||
this.handleReport = this.handleReport.bind(this);
|
||||
this.handleMute = this.handleMute.bind(this);
|
||||
}
|
||||
static propTypes = {
|
||||
account: ImmutablePropTypes.map,
|
||||
me: PropTypes.number.isRequired,
|
||||
onFollow: PropTypes.func.isRequired,
|
||||
onBlock: PropTypes.func.isRequired,
|
||||
onMention: PropTypes.func.isRequired,
|
||||
onReport: PropTypes.func.isRequired,
|
||||
onMute: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
handleFollow () {
|
||||
static contextTypes = {
|
||||
router: PropTypes.object
|
||||
};
|
||||
|
||||
handleFollow = () => {
|
||||
this.props.onFollow(this.props.account);
|
||||
}
|
||||
|
||||
handleBlock () {
|
||||
handleBlock = () => {
|
||||
this.props.onBlock(this.props.account);
|
||||
}
|
||||
|
||||
handleMention () {
|
||||
handleMention = () => {
|
||||
this.props.onMention(this.props.account, this.context.router);
|
||||
}
|
||||
|
||||
handleReport () {
|
||||
handleReport = () => {
|
||||
this.props.onReport(this.props.account);
|
||||
this.context.router.push('/report');
|
||||
}
|
||||
|
||||
handleMute() {
|
||||
handleMute = () => {
|
||||
this.props.onMute(this.props.account);
|
||||
}
|
||||
|
||||
|
@ -64,20 +69,7 @@ class Header extends ImmutablePureComponent {
|
|||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Header.propTypes = {
|
||||
account: ImmutablePropTypes.map,
|
||||
me: PropTypes.number.isRequired,
|
||||
onFollow: PropTypes.func.isRequired,
|
||||
onBlock: PropTypes.func.isRequired,
|
||||
onMention: PropTypes.func.isRequired,
|
||||
onReport: PropTypes.func.isRequired,
|
||||
onMute: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
Header.contextTypes = {
|
||||
router: PropTypes.object
|
||||
};
|
||||
|
||||
export default Header;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue