Skip to content

Instantly share code, notes, and snippets.

@joshwcomeau
Last active March 11, 2016 13:02
Show Gist options
  • Save joshwcomeau/6d6e590f8269905d1b50 to your computer and use it in GitHub Desktop.
Save joshwcomeau/6d6e590f8269905d1b50 to your computer and use it in GitHub Desktop.
Immutable props decorator - function
const immutableProps = propsToCheck => ComposedComponent => {
return class immutablePropChecker extends Component {
shouldComponentUpdate(nextProps) {
return propsToCheck.some( p => this.props[p] !== nextProps[p] );
}
render() {
return <ComposedComponent {...this.props} />;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment