Created
February 28, 2020 10:50
-
-
Save jenshandersson/892680feb68187c676cf34e61f6edaf7 to your computer and use it in GitHub Desktop.
React componentDidUpdate diff
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
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