MCPcopy
hub / github.com/facebook/react / renderSuspenseBoundary

Function renderSuspenseBoundary

packages/react-server/src/ReactFizzServer.js:1272–1619  ·  view source on GitHub ↗
(
  request: Request,
  someTask: Task,
  keyPath: KeyNode,
  props: SuspenseProps,
)

Source from the content-addressed store, hash-verified

1270}
1271
1272function renderSuspenseBoundary(
1273 request: Request,
1274 someTask: Task,
1275 keyPath: KeyNode,
1276 props: SuspenseProps,
1277): void {
1278 if (someTask.replay !== null) {
1279 // If we're replaying through this pass, it means we're replaying through
1280 // an already completed Suspense boundary. It's too late to do anything about it
1281 // so we can just render through it.
1282 const prevKeyPath = someTask.keyPath;
1283 const prevContext = someTask.formatContext;
1284 const prevRow = someTask.row;
1285 someTask.keyPath = keyPath;
1286 someTask.formatContext = getSuspenseContentFormatContext(
1287 request.resumableState,
1288 prevContext,
1289 );
1290 someTask.row = null;
1291 const content: ReactNodeList = props.children;
1292 try {
1293 renderNode(request, someTask, content, -1);
1294 } finally {
1295 someTask.keyPath = prevKeyPath;
1296 someTask.formatContext = prevContext;
1297 someTask.row = prevRow;
1298 }
1299 return;
1300 }
1301 // $FlowFixMe: Refined.
1302 const task: RenderTask = someTask;
1303
1304 const prevKeyPath = task.keyPath;
1305 const prevContext = task.formatContext;
1306 const prevRow = task.row;
1307 const parentBoundary = task.blockedBoundary;
1308 const parentPreamble = task.blockedPreamble;
1309 const parentHoistableState = task.hoistableState;
1310 const parentSegment = task.blockedSegment;
1311
1312 // Each time we enter a suspense boundary, we split out into a new segment for
1313 // the fallback so that we can later replace that segment with the content.
1314 // This also lets us split out the main content even if it doesn't suspend,
1315 // in case it ends up generating a large subtree of content.
1316 const fallback: ReactNodeList = props.fallback;
1317 const content: ReactNodeList = props.children;
1318
1319 const fallbackAbortSet: Set<Task> = new Set();
1320 let newBoundary: SuspenseBoundary;
1321 if (canHavePreamble(task.formatContext)) {
1322 newBoundary = createSuspenseBoundary(
1323 request,
1324 task.row,
1325 fallbackAbortSet,
1326 createPreambleState(),
1327 createPreambleState(),
1328 );
1329 } else {

Callers 1

renderElementFunction · 0.85

Calls 15

canHavePreambleFunction · 0.90
createPreambleStateFunction · 0.90
pushSegmentFinaleFunction · 0.90
renderNodeFunction · 0.85
createSuspenseBoundaryFunction · 0.85
createPendingSegmentFunction · 0.85
finishedSegmentFunction · 0.85
createRenderTaskFunction · 0.85
pushComponentStackFunction · 0.85

Tested by

no test coverage detected