-
-
Save amanshu-kataria/92fe6bb6962962a0a45abaee4cb4dfa0 to your computer and use it in GitHub Desktop.
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
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ragabmoh anything is fine. It's just for purpose of example.