Skip to content

Instantly share code, notes, and snippets.

@amanshu-kataria
Created May 14, 2018 09:03
Show Gist options
  • Save amanshu-kataria/92fe6bb6962962a0a45abaee4cb4dfa0 to your computer and use it in GitHub Desktop.
Save amanshu-kataria/92fe6bb6962962a0a45abaee4cb4dfa0 to your computer and use it in GitHub Desktop.
static getDerivedStateFromProps(nextProps, prevState){
if(nextProps.someValue!==prevState.someValue){
return { someState: nextProps.someValue};
}
else return null;
}
componentDidUpdate(prevProps, prevState) {
if(prevProps.someValue!==this.props.someValue){
//Perform some operation here
this.setState({someState: someValue});
this.classMethod();
}
}
@amanshu-kataria
Copy link
Author

@ragabmoh anything is fine. It's just for purpose of example.

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