Skip to content

Commit 51a864d

Browse files
authored
Fix cDU to correctly make async request
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`.
1 parent 62638c8 commit 51a864d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

examples/update-on-async-rendering/updating-external-data-when-props-change-after.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ExampleComponent extends React.Component {
2525

2626
// highlight-range{1-5}
2727
componentDidUpdate(prevProps, prevState) {
28-
if (prevState.externalData === null) {
28+
if (this.state.externalData === null) {
2929
this._loadAsyncData(this.props.id);
3030
}
3131
}

0 commit comments

Comments
 (0)