Last active
April 8, 2018 21:03
-
-
Save kenwheeler/f877eaa98bd5cf0c50cf725680950b53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Whatever extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
a: 5 + props.b; | |
}; | |
this.offset = 0; | |
this.someEvent = this.someEvent.bind(this); | |
} | |
componentWillReceiveProps(nextProps) { | |
this.setState({ | |
a: this.state.a + this.props.b + this.offset | |
}); | |
} | |
someEvent(evt) { | |
this.offset += evt.clientX; | |
} | |
render() { | |
return <DoesntMatter/> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suggest something more like: