Skip to content

Commit

Permalink
[Flight] Unwrap lazy before reading the value (#30938)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage authored Sep 10, 2024
1 parent a5a7f10 commit bac33d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,7 @@ function getOutlinedModel<T>(
case INITIALIZED:
let value = chunk.value;
for (let i = 1; i < path.length; i++) {
value = value[path[i]];
if (value.$$typeof === REACT_LAZY_TYPE) {
while (value.$$typeof === REACT_LAZY_TYPE) {
const referencedChunk: SomeChunk<any> = value._payload;
if (referencedChunk.status === INITIALIZED) {
value = referencedChunk.value;
Expand All @@ -1069,10 +1068,11 @@ function getOutlinedModel<T>(
key,
response,
map,
path.slice(i),
path.slice(i - 1),
);
}
}
value = value[path[i]];
}
const chunkValue = map(response, value);
if (__DEV__ && chunk._debugInfo) {
Expand Down

0 comments on commit bac33d1

Please sign in to comment.