mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 04:33:10 +00:00
Update 2018-05-23-react-v-16-4.md example fix (#1423)
Minor "fix" to the suggested fix in the blog post to default back to empty object if `state.prevProps` isn't yet set. This will help anyone copying the example as-is who has stumbled across this blog post.
This commit is contained in:
committed by
Dan Abramov
parent
cd5d2ce10b
commit
488e717e5b
@@ -62,7 +62,7 @@ One possible way to fix this is to compare the incoming value to the previous va
|
||||
|
||||
```js
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
const prevProps = state.prevProps;
|
||||
const prevProps = state.prevProps || {};
|
||||
// Compare the incoming prop to previous prop
|
||||
const controlledValue =
|
||||
prevProps.value !== props.value
|
||||
|
||||
Reference in New Issue
Block a user