From 51a864d858beac175a769abb046a05240c220042 Mon Sep 17 00:00:00 2001 From: Nathan Quarles Date: Fri, 30 Mar 2018 11:44:46 -0400 Subject: [PATCH] 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`. --- .../updating-external-data-when-props-change-after.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/update-on-async-rendering/updating-external-data-when-props-change-after.js b/examples/update-on-async-rendering/updating-external-data-when-props-change-after.js index 2426bc9a9d6..78d59599399 100644 --- a/examples/update-on-async-rendering/updating-external-data-when-props-change-after.js +++ b/examples/update-on-async-rendering/updating-external-data-when-props-change-after.js @@ -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); } }