Created
March 15, 2017 20:59
-
-
Save geetotes/c63e9f00f02fd42080561b07803b587b 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 NeatoComponent extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
foo: this.props.foo, | |
bar: this.props.bar | |
}; | |
} | |
componentWillReceiveProps(nextProps) { | |
if (this.props !== nextProps) { // This is crappy comparison just for the purposes of this example | |
this.setState({ | |
foo: nextProps.foo, | |
bar: nextProps.bar | |
}); | |
} | |
} | |
render() { | |
return (<p> Foo bar: {this.state.foo} {this.state.bar}</p>); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment