Skip to content

Instantly share code, notes, and snippets.

@dorklord23
Created June 28, 2019 14:26
Show Gist options
  • Save dorklord23/78af07a2c02d27480d57f5e9469a91ea to your computer and use it in GitHub Desktop.
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
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