Last active
July 18, 2016 12:19
-
-
Save developit/569fe404e18b936ea42b3aa245b4d94a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function shallowEqual(a, b) { | |
| if (a!==b) { | |
| for (let i in a) if (a[i]!==b[i]) return false; | |
| for (let i in b) if (!(i in a)) return false; | |
| } | |
| return true; | |
| } | |
| export function shouldComponentUpdate(props, state) { | |
| return !shallowEqual(props, this.props) || !shallowEqual(state, this.state); | |
| } | |
| export default { shouldComponentUpdate }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment