Last active
August 29, 2015 14:23
-
-
Save alexeisavca/997d1e3b4078b1d72247 to your computer and use it in GitHub Desktop.
Pure render component superclass(look, ma, no mixins!)
This file contains 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
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