Skip to content

Instantly share code, notes, and snippets.

@yagamicoder
Last active December 1, 2016 21:30
Show Gist options
  • Save yagamicoder/6180617f6420f4f630268e029d14eadb to your computer and use it in GitHub Desktop.
Save yagamicoder/6180617f6420f4f630268e029d14eadb to your computer and use it in GitHub Desktop.
Checking for props change in a React app
componentWillReceiveProps (newProps) {
/*
If the new prop (nextProps) is not equal to
the current prop, call a function that sets the state
*/
const { id } = this.props;
if (newProps.id !== id) {
//Call some function
deleteItem(id);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment