mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-22 20:01:57 +00:00
Fix controlled state example
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user