@@ -67,7 +67,7 @@ type ReactModelObject = {+[key: string]: ReactModel}; |
67 | 67 |
|
68 | 68 | type Segment = { |
69 | 69 | id: number, |
70 | | - query: () => ReactModel, |
| 70 | + model: ReactModel, |
71 | 71 | ping: () => void, |
72 | 72 | }; |
73 | 73 |
|
@@ -113,7 +113,7 @@ export function createRequest( |
113 | 113 | }, |
114 | 114 | }; |
115 | 115 | request.pendingChunks++; |
116 | | - const rootSegment = createSegment(request, () => model); |
| 116 | + const rootSegment = createSegment(request, model); |
117 | 117 | pingedSegments.push(rootSegment); |
118 | 118 | return request; |
119 | 119 | } |
@@ -180,11 +180,11 @@ function pingSegment(request: Request, segment: Segment): void { |
180 | 180 | } |
181 | 181 | } |
182 | 182 |
|
183 | | -function createSegment(request: Request, query: () => ReactModel): Segment { |
| 183 | +function createSegment(request: Request, model: ReactModel): Segment { |
184 | 184 | const id = request.nextChunkId++; |
185 | 185 | const segment = { |
186 | 186 | id, |
187 | | - query, |
| 187 | + model, |
188 | 188 | ping: () => pingSegment(request, segment), |
189 | 189 | }; |
190 | 190 | return segment; |
@@ -408,7 +408,7 @@ export function resolveModelToJSON( |
408 | 408 | if (typeof x === 'object' && x !== null && typeof x.then === 'function') { |
409 | 409 | // Something suspended, we'll need to create a new segment and resolve it later. |
410 | 410 | request.pendingChunks++; |
411 | | - const newSegment = createSegment(request, () => value); |
| 411 | + const newSegment = createSegment(request, value); |
412 | 412 | const ping = newSegment.ping; |
413 | 413 | x.then(ping, ping); |
414 | 414 | return serializeByRefID(newSegment.id); |
@@ -625,10 +625,8 @@ function emitSymbolChunk(request: Request, id: number, name: string): void { |
625 | 625 | } |
626 | 626 |
|
627 | 627 | function retrySegment(request: Request, segment: Segment): void { |
628 | | - const query = segment.query; |
629 | | - let value; |
630 | 628 | try { |
631 | | - value = query(); |
| 629 | + let value = segment.model; |
632 | 630 | while ( |
633 | 631 | typeof value === 'object' && |
634 | 632 | value !== null && |
@@ -639,7 +637,7 @@ function retrySegment(request: Request, segment: Segment): void { |
639 | 637 | // Attempt to render the server component. |
640 | 638 | // Doing this here lets us reuse this same segment if the next component |
641 | 639 | // also suspends. |
642 | | - segment.query = () => value; |
| 640 | + segment.model = value; |
643 | 641 | value = attemptResolveElement( |
644 | 642 | element.type, |
645 | 643 | element.key, |
|