Skip to content

Instantly share code, notes, and snippets.

@rmbrntt
Created March 29, 2019 14:50
Show Gist options
  • Save rmbrntt/c81d9732c9032d94ee500832e101e1b9 to your computer and use it in GitHub Desktop.
Save rmbrntt/c81d9732c9032d94ee500832e101e1b9 to your computer and use it in GitHub Desktop.
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`)
);
}
@rmbrntt
Copy link
Author

rmbrntt commented Mar 29, 2019

just a quick piece of code to pop in and double check if unnecessary re-renders are happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment