Skip to content

Instantly share code, notes, and snippets.

@kevgathuku
Created April 25, 2019 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevgathuku/3aca5b00cb3f805d46ae2e8d926b5baa to your computer and use it in GitHub Desktop.
Save kevgathuku/3aca5b00cb3f805d46ae2e8d926b5baa 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`)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment