Created
April 8, 2016 12:59
-
-
Save fab1an/b79e92bc691726c59368f929816706e0 to your computer and use it in GitHub Desktop.
simple 'shouldComponentUpdate'
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
class ReactBase extends React.Component { | |
shouldComponentUpdate(nextProps) { | |
/* function from lodash */ | |
return !_.isEqual(this.props, nextProps); | |
/* if we use immutableJS we could also just do an equality check */ | |
// return this.props !== nextProps; | |
} | |
} | |
class App extends ReactBase { | |
render() { | |
return ( | |
//... | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment