Skip to content

Instantly share code, notes, and snippets.

@NoamELB
Last active December 22, 2018 14:00
Show Gist options
  • Save NoamELB/43b9b3b6c6771da5dc21088b1e0d1b70 to your computer and use it in GitHub Desktop.
Save NoamELB/43b9b3b6c6771da5dc21088b1e0d1b70 to your computer and use it in GitHub Desktop.
static getDerivedStateFromProps(props, state) {
let newState = null;
if (props.value !== state.prevValue) {
newState = { prevValue: props.value };
if (props.value !== state.value) {
newState.value = props.value;
}
}
return newState;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment