Skip to content

Instantly share code, notes, and snippets.

@jenshandersson
Created February 28, 2020 10:50
Show Gist options
  • Save jenshandersson/892680feb68187c676cf34e61f6edaf7 to your computer and use it in GitHub Desktop.
Save jenshandersson/892680feb68187c676cf34e61f6edaf7 to your computer and use it in GitHub Desktop.
React componentDidUpdate diff
console.log('Rrow update diff:');
console.log('++++++++++++++++++++');
console.log('++++++++++++++++++++');
const now = Object.entries(this.props);
const added = now.filter(([key, val]) => {
if (prevProps[key] === undefined && val !== undefined) return true;
if (!isEqual(prevProps[key], val)) {
console.log(`${key}
- ${JSON.stringify(prevProps[key])}
+ ${JSON.stringify(val)}`);
}
return false;
});
added.forEach(([key, val]) =>
console.log(`${key}
+ ${JSON.stringify(val)}`),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment