Skip to content

Commit

Permalink
Fix cDU to correctly make async request
Browse files Browse the repository at this point in the history
When a new `id` prop is passed in, `getDerivedStateFromProps` sets `this.state.externalData` to `null`. If I understand the new API correctly the return value of gDSFP() either becomes the new state or is merged into the new state? If so, then `componentDidUpdate` should examine the new state (`this.state.externalData`), not `prevState.externalData`.
  • Loading branch information
nateq314 authored Mar 30, 2018
1 parent 62638c8 commit 51a864d
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ExampleComponent extends React.Component {

// highlight-range{1-5}
componentDidUpdate(prevProps, prevState) {
if (prevState.externalData === null) {
if (this.state.externalData === null) {
this._loadAsyncData(this.props.id);
}
}
Expand Down

0 comments on commit 51a864d

Please sign in to comment.