Created
June 28, 2019 14:26
-
-
Save dorklord23/78af07a2c02d27480d57f5e9469a91ea to your computer and use it in GitHub Desktop.
Ultimate debugging function to find out why a component seemingly re-renders itself in React
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
function compare(currentProps, prevProps) { | |
Object.keys(currentProps).forEach(key => { | |
if (currentProps[key] !== prevProps[key]) { | |
console.log(key, "changed from", prevProps[key], "to", currentProps[key]); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment