Skip to content

Instantly share code, notes, and snippets.

@tidusx18
Created January 10, 2019 18:09
Show Gist options
  • Save tidusx18/bac4471a9526faed4f72677b0a5cac60 to your computer and use it in GitHub Desktop.
Save tidusx18/bac4471a9526faed4f72677b0a5cac60 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