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:
committed by
Eugen Rochko
parent
44a3584e2d
commit
2991a7cfe6
@ -22,25 +22,25 @@ const mapStateToProps = (state, props) => ({
|
||||
|
||||
class Following extends ImmutablePureComponent {
|
||||
|
||||
constructor (props, context) {
|
||||
super(props, context);
|
||||
this.handleScroll = this.handleScroll.bind(this);
|
||||
this.handleLoadMore = this.handleLoadMore.bind(this);
|
||||
}
|
||||
static propTypes = {
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.list
|
||||
};
|
||||
|
||||
componentWillMount () {
|
||||
this.props.dispatch(fetchAccount(Number(this.props.params.accountId)));
|
||||
this.props.dispatch(fetchFollowing(Number(this.props.params.accountId)));
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
componentWillReceiveProps (nextProps) {
|
||||
if (nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) {
|
||||
this.props.dispatch(fetchAccount(Number(nextProps.params.accountId)));
|
||||
this.props.dispatch(fetchFollowing(Number(nextProps.params.accountId)));
|
||||
}
|
||||
}
|
||||
|
||||
handleScroll (e) {
|
||||
handleScroll = (e) => {
|
||||
const { scrollTop, scrollHeight, clientHeight } = e.target;
|
||||
|
||||
if (scrollTop === scrollHeight - clientHeight) {
|
||||
@ -48,7 +48,7 @@ class Following extends ImmutablePureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
handleLoadMore (e) {
|
||||
handleLoadMore = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.dispatch(expandFollowing(Number(this.props.params.accountId)));
|
||||
}
|
||||
@ -83,10 +83,4 @@ class Following extends ImmutablePureComponent {
|
||||
|
||||
}
|
||||
|
||||
Following.propTypes = {
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.list
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Following);
|
||||
|
Reference in New Issue
Block a user