Created
October 19, 2018 06:34
-
-
Save haldarmahesh/9a794416aae77e8416aa2037b913db2f to your computer and use it in GitHub Desktop.
react lifecycle 16.4 blog
This file contains hidden or 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(props, state) { | |
if (state.value !== props.value) { | |
return { | |
derivedValue: deriveValueFromProps(props), | |
mirroredProp: props.value | |
} | |
} | |
// when null is returned no update is made to the state | |
return null; | |
} | |
// after getDerivedStateFromProps the state looks like as follows: | |
// { | |
// derivedValue: someValue, | |
// mirrordValue: newPropValue | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment