Created
July 21, 2021 01:43
-
-
Save amadeus/6230b5b3a3971d7e035f4a4d3b7fb05f 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
export function logChanges(newProps: any, prevProps: any) { | |
if (process.env.NODE_ENV === 'development') { | |
const changes = Object.create(null); | |
Object.keys(newProps).forEach((key) => { | |
const newValue: any = newProps[key]; | |
const oldValue: any = prevProps[key]; | |
if (newValue !== oldValue) { | |
changes[key] = [oldValue, newValue]; | |
} | |
}); | |
if (Object.keys(changes).length > 0) { | |
// eslint-disable-next-line no-console | |
console.log('ZZZZZ - account changes', changes); | |
} else { | |
// eslint-disable-next-line no-console | |
console.log('ZZZZZ - account did not change'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment