Skip to content

Commit fb3f63f

Browse files
authored
Remove lazy invokation of segments (#20656)
This is a remainder from Blocks when these were separate query functions.
1 parent 6d94017 commit fb3f63f

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎packages/react-server/src/ReactFlightServer.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type ReactModelObject = {+[key: string]: ReactModel};
6767

6868
typeSegment={
6969
id: number,
70-
query: ()=>ReactModel,
70+
model:ReactModel,
7171
ping: ()=>void,
7272
};
7373

@@ -113,7 +113,7 @@ export function createRequest(
113113
},
114114
};
115115
request.pendingChunks++;
116-
constrootSegment=createSegment(request,()=>model);
116+
constrootSegment=createSegment(request,model);
117117
pingedSegments.push(rootSegment);
118118
returnrequest;
119119
}
@@ -180,11 +180,11 @@ function pingSegment(request: Request, segment: Segment): void {
180180
}
181181
}
182182

183-
functioncreateSegment(request: Request,query: ()=>ReactModel): Segment{
183+
functioncreateSegment(request: Request,model:ReactModel): Segment{
184184
constid=request.nextChunkId++;
185185
constsegment={
186186
id,
187-
query,
187+
model,
188188
ping: ()=>pingSegment(request,segment),
189189
};
190190
returnsegment;
@@ -408,7 +408,7 @@ export function resolveModelToJSON(
408408
if(typeofx==='object'&&x!==null&&typeofx.then==='function'){
409409
// Something suspended, we'll need to create a new segment and resolve it later.
410410
request.pendingChunks++;
411-
constnewSegment=createSegment(request,()=>value);
411+
constnewSegment=createSegment(request,value);
412412
constping=newSegment.ping;
413413
x.then(ping,ping);
414414
returnserializeByRefID(newSegment.id);
@@ -625,10 +625,8 @@ function emitSymbolChunk(request: Request, id: number, name: string): void {
625625
}
626626

627627
function retrySegment(request: Request, segment: Segment): void {
628-
constquery=segment.query;
629-
letvalue;
630628
try{
631-
value=query();
629+
letvalue =segment.model;
632630
while(
633631
typeofvalue==='object'&&
634632
value!==null&&
@@ -639,7 +637,7 @@ function retrySegment(request: Request, segment: Segment): void {
639637
// Attempt to render the server component.
640638
// Doing this here lets us reuse this same segment if the next component
641639
// also suspends.
642-
segment.query=()=>value;
640+
segment.model=value;
643641
value=attemptResolveElement(
644642
element.type,
645643
element.key,

0 commit comments

Comments
 (0)