-
-
Save vidaaudrey/889d14369846997121cd 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