Skip to content

Instantly share code, notes, and snippets.

Last active July 17, 2019 09:29
What would you like to do?
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 {}
export default MyComponent;
Copy link

acdlite commented Mar 30, 2015

Good idea? Terrible idea? Is an HoC overkill in this case, since it's just one method? ¯_(ツ)_/¯

Copy link

Decorators will probably be a better fit, but i think this will probably be better that something like this for now

Copy link

angus-c commented May 7, 2015

I wrote a universal react mixin util that accepts traditional react mixins and ES6 class mixins

import mixin from 'es6-react-mixins'
class MyComponent extends mixin(ReactAddOns.addons.PureRenderMixin) {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment