diff --git a/docs/docs/reference-react-component.md b/docs/docs/reference-react-component.md index 2c1b0770cb871..10605f88828ab 100644 --- a/docs/docs/reference-react-component.md +++ b/docs/docs/reference-react-component.md @@ -249,8 +249,8 @@ The first argument is an `updater` function with the signature: `prevState` is a reference to the previous state. It should not be directly mutated. Instead, changes should be represented by building a new state object based on the input from `prevState` and `props`. For instance, suppose we wanted to increment a value in state by `props.step`: ```javascript -this.setState((prevState, props) => { - return {counter: prevState.counter + props.step}; +this.setState(function(prevState, props) { + return { counter: prevState.counter + props.step } }); ``` @@ -284,8 +284,8 @@ Object.assign( Subsequent calls will override values from previous calls in the same cycle, so the quantity will only be incremented once. If the next state depends on the previous state, we recommend using the updater function form, instead: ```js -this.setState((prevState) => { - return {counter: prevState.quantity + 1}; +this.setState(function(prevState) { + return { counter: prevState.quantity + 1 } }); ```