GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove lazy invokation of segments (#20656) · react/react@fb3f63f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-server/src
    • ReactFlightServer.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-server/src/ReactFlightServer.js
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type ReactModelObject = {+[key: string]: ReactModel};
6767

6868
type Segment = {
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-
const rootSegment = createSegment(request, () => model);
116+
const rootSegment = createSegment(request, model);
117117
pingedSegments.push(rootSegment);
118118
return request;
119119
}
@@ -180,11 +180,11 @@ function pingSegment(request: Request, segment: Segment): void {
180180
}
181181
}
182182

183-
function createSegment(request: Request, query: () => ReactModel): Segment {
183+
function createSegment(request: Request, model: ReactModel): Segment {
184184
const id = request.nextChunkId++;
185185
const segment = {
186186
id,
187-
query,
187+
model,
188188
ping: () => pingSegment(request, segment),
189189
};
190190
return segment;
@@ -408,7 +408,7 @@ export function resolveModelToJSON(
408408
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
409409
// Something suspended, we'll need to create a new segment and resolve it later.
410410
request.pendingChunks++;
411-
const newSegment = createSegment(request, () => value);
411+
const newSegment = createSegment(request, value);
412412
const ping = newSegment.ping;
413413
x.then(ping, ping);
414414
return serializeByRefID(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-
const query = segment.query;
629-
let value;
630628
try {
631-
value = query();
629+
let value = segment.model;
632630
while (
633631
typeof value === '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 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.