Last active
December 5, 2018 17:55
-
-
Save Jahans3/f346b09af7ebdf2de369e7550844156c to your computer and use it in GitHub Desktop.
Shallow compare
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
function shallowCompare (state, nextState) { | |
if ((typeof state !== 'object' || state === null || typeof nextState !== 'object' || nextState === null)) return false; | |
return Object.entries(nextState).reduce((shouldUpdate, [key, value]) => state[key] !== value ? true : shouldUpdate, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment