Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shallow compare
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