Skip to content

Instantly share code, notes, and snippets.

@vidaaudrey
Forked from acdlite/pureRenderMixin.js
Created January 12, 2016 17:42
Show Gist options
  • Save vidaaudrey/889d14369846997121cd to your computer and use it in GitHub Desktop.
Save vidaaudrey/889d14369846997121cd to your computer and use it in GitHub Desktop.
Pure Render Mixin in ES6
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