MCPcopy Index your code
hub / github.com/react/react / resumeAndPrerender

Function resumeAndPrerender

packages/react-dom/src/server/ReactDOMFizzStaticNode.js:343–407  ·  view source on GitHub ↗
(
  children: ReactNodeList,
  postponedState: PostponedState,
  options?: Omit<ResumeOptions, 'nonce'>,
)

Source from the content-addressed store, hash-verified

341}
342
343function resumeAndPrerender(
344 children: ReactNodeList,
345 postponedState: PostponedState,
346 options?: Omit<ResumeOptions, 'nonce'>,
347): Promise<{
348 postponed: null | PostponedState,
349 prelude: ReadableStream,
350}> {
351 return new Promise((resolve, reject) => {
352 const onFatalError = reject;
353
354 function onAllReady() {
355 let writable: Writable;
356 const stream = new ReadableStream(
357 {
358 type: 'bytes',
359 start: (controller): ?Promise<void> => {
360 writable =
361 createFakeWritableFromReadableStreamController(controller);
362 },
363 pull: (controller): ?Promise<void> => {
364 startFlowing(request, writable);
365 },
366 cancel: (reason): ?Promise<void> => {
367 stopFlowing(request);
368 abort(request, reason);
369 },
370 },
371 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
372 {highWaterMark: 0},
373 );
374
375 const result = {
376 postponed: getPostponedState(request),
377 prelude: stream,
378 };
379 resolve(result);
380 }
381
382 const request = resumeAndPrerenderRequest(
383 children,
384 postponedState,
385 resumeRenderState(postponedState.resumableState, undefined),
386 options ? options.onError : undefined,
387 onAllReady,
388 undefined,
389 undefined,
390 onFatalError,
391 options ? options.onPostpone : undefined,
392 );
393 if (options && options.signal) {
394 const signal = options.signal;
395 if (signal.aborted) {
396 abort(request, (signal: any).reason);
397 } else {
398 const listener = () => {
399 abort(request, (signal: any).reason);
400 signal.removeEventListener('abort', listener);

Callers

nothing calls this directly

Calls 4

resumeRenderStateFunction · 0.90
abortFunction · 0.90
startWorkFunction · 0.90

Tested by

no test coverage detected