Last active
March 11, 2016 13:02
-
-
Save joshwcomeau/6d6e590f8269905d1b50 to your computer and use it in GitHub Desktop.
Immutable props decorator - function
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
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