Created
March 29, 2019 14:50
-
-
Save rmbrntt/c81d9732c9032d94ee500832e101e1b9 to your computer and use it in GitHub Desktop.
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) { | |
Object.entries(this.props).forEach(([key, val]) => | |
prevProps[key] !== val && console.log(`Prop '${key}' changed`) | |
); | |
Object.entries(this.state).forEach(([key, val]) => | |
prevState[key] !== val && console.log(`State '${key}' changed`) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just a quick piece of code to pop in and double check if unnecessary re-renders are happening.