Skip to content

Commit bac33d1

Browse files
authored
[Flight] Unwrap lazy before reading the value (#30938)
This is important if the lazy is at the root of the chunk. I don't have a unit test for it but @gnoff has a repro. It also shouldn't unwrap the last value since that's the one we're referencing. This was already done correctly by @unstubbable in waitForReference so this just aligns with that.
1 parent a5a7f10 commit bac33d1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/react-client/src/ReactFlightClient.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,7 @@ function getOutlinedModel<T>(
10571057
case INITIALIZED:
10581058
let value = chunk.value;
10591059
for (let i = 1; i < path.length; i++) {
1060-
value = value[path[i]];
1061-
if (value.$$typeof === REACT_LAZY_TYPE) {
1060+
while (value.$$typeof === REACT_LAZY_TYPE) {
10621061
const referencedChunk: SomeChunk<any> = value._payload;
10631062
if (referencedChunk.status === INITIALIZED) {
10641063
value = referencedChunk.value;
@@ -1069,10 +1068,11 @@ function getOutlinedModel<T>(
10691068
key,
10701069
response,
10711070
map,
1072-
path.slice(i),
1071+
path.slice(i - 1),
10731072
);
10741073
}
10751074
}
1075+
value = value[path[i]];
10761076
}
10771077
const chunkValue = map(response, value);
10781078
if (__DEV__ && chunk._debugInfo) {

0 commit comments

Comments
 (0)