Skip to content

Instantly share code, notes, and snippets.

@borm
Forked from acdlite/pureRenderMixin.js
Created March 16, 2016 12:54
Show Gist options
  • Select an option

  • Save borm/78c14e8f94f3fbb1fb3b to your computer and use it in GitHub Desktop.

Select an option

Save borm/78c14e8f94f3fbb1fb3b 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