Skip to content

Instantly share code, notes, and snippets.

@amadeus
Created July 21, 2021 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amadeus/6230b5b3a3971d7e035f4a4d3b7fb05f to your computer and use it in GitHub Desktop.
Save amadeus/6230b5b3a3971d7e035f4a4d3b7fb05f to your computer and use it in GitHub Desktop.
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