Skip to content

Instantly share code, notes, and snippets.

@fab1an
Created April 8, 2016 12:59
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 fab1an/b79e92bc691726c59368f929816706e0 to your computer and use it in GitHub Desktop.
Save fab1an/b79e92bc691726c59368f929816706e0 to your computer and use it in GitHub Desktop.
simple 'shouldComponentUpdate'
class ReactBase extends React.Component {
shouldComponentUpdate(nextProps) {
/* function from lodash */
return !_.isEqual(this.props, nextProps);
/* if we use immutableJS we could also just do an equality check */
// return this.props !== nextProps;
}
}
class App extends ReactBase {
render() {
return (
//...
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment