Skip to content

Instantly share code, notes, and snippets.

@kocisov
Created July 17, 2018 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kocisov/3fac0401417bd927558bd4de5df3ddeb to your computer and use it in GitHub Desktop.
Save kocisov/3fac0401417bd927558bd4de5df3ddeb to your computer and use it in GitHub Desktop.
Sup #2
class App extends Component {
// return false = COMPONENT_SHOULD_NOT_UPDATE!
// return true = COMPONENT_SHOULD_UPDATE!
shouldComponentUpdate(nextProps, nextState) {
// PureComponent do this for you, not for everything tho
return this.props.value != nextProps.value;
}
render() {
return (
<div>
<h2>{this.props.value}</h2>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment