Last active
November 13, 2018 10:58
-
-
Save wklsh/869020a94814d51e403394a7929b6d9c to your computer and use it in GitHub Desktop.
Check for updated props / states within ComponentDidUpdate lifecycle
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
componentDidUpdate(prevProps, prevState) { | |
// Get updated props | |
for (const index in prevProps) { | |
if (prevProps[index] !== this.props[index]) { | |
console.log(index, prevProps[index], "-->", this.props[index]); | |
} | |
} | |
// Get updated states | |
for (const index in prevState) { | |
if (prevState[index] !== this.state[index]) { | |
console.log(index, prevState[index], "-->", this.state[index]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment