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:
Michael Steward
2018-11-28 11:51:22 -08:00
committed by Dan Abramov
parent cd5d2ce10b
commit 488e717e5b

View File

@@ -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