Browse Source

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.
main
Michael Steward 6 years ago
committed by Dan Abramov
parent
commit
488e717e5b
  1. 2
      content/blog/2018-05-23-react-v-16-4.md

2
content/blog/2018-05-23-react-v-16-4.md

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

Loading…
Cancel
Save