Last active
December 1, 2016 21:30
-
-
Save yagamicoder/6180617f6420f4f630268e029d14eadb to your computer and use it in GitHub Desktop.
Checking for props change in a React app
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
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