-
-
Save evenstensberg/6ad55d23c5676dcd6d8a63bfbb0ef68f to your computer and use it in GitHub Desktop.
Pure Render Mixin in ES6
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
function pureRenderMixin(Component) { | |
Component.prototype.shouldComponentUpdate(nextProps, nextState) { | |
return !shallowEqual(this.props, nextProps) || | |
!shallowEqual(this.state, nextState); | |
} | |
return Component; | |
} | |
class MyComponent extends React.Component {} | |
pureRenderMixin(MyComponent); | |
export default MyComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment