Fix controlled state example

This commit is contained in:
Andrew Clark
2018-05-23 12:58:58 -07:00
parent a3cff20422
commit 6a453171a6

View File

@@ -52,8 +52,8 @@ static getDerivedStateFromProps(props, state) {
const prevProps = state.prevProps;
// Compare incoming props to previous props
const controlledValue =
prevProps.value !== state.controlledValue
? prevProps.value
prevProps.value !== props.value
? props.value
: state.controlledValue;
return {
// Store the previous props in state