Skip to content

Instantly share code, notes, and snippets.

@alexeisavca
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeisavca/997d1e3b4078b1d72247 to your computer and use it in GitHub Desktop.
Save alexeisavca/997d1e3b4078b1d72247 to your computer and use it in GitHub Desktop.
Pure render component superclass(look, ma, no mixins!)
var React = require('react');
var shallowDiff = (a,b) => Object.keys(a).some(key => a[key] != b[key]);
module.exports = class extends React.Component {
shouldComponentUpdate (nextProps, nextState){
return shallowDiff(this.props, nextProps) || shallowDiff(this.state, nextState);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment