A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/reactwg/react-18/discussions/127 below:

Renaming SSR Callbacks · reactwg/react-18 · Discussion #127 · GitHub

Heads up in the latest RC, we renamed some of the callbacks in the Node.js streaming API as well as the Web Streams API.

They're no longer called "Complete" but instead "Ready". That indicates that they're ready to be written but hasn't necessarily been written.

The Web Streams API have moved the onCompleteAll callback to a stream.allReady promise.

To wait for all Suspense boundaries to resolve before flushing:

let controller = new AbortController();
try {
  let stream = await renderToReadableStream(
    <html>
      <body>Success</body>
    </html>,
    {
      signal: controller.signal,
    }
  );
  await stream.allReady;
  return new Response(stream, {
    headers: {'Content-Type': 'text/html'},
  });
} catch (error) {
  return new Response(
    '<!doctype html><p>Loading...</p><script src="clientrender.js"></script>',
    {
      status: 500,
      headers: {'Content-Type': 'text/html'},
    }
  );
}

The Node.js API has onShellReady, onShellError or onAllReady callbacks.

const {pipe, abort} = renderToPipeableStream(
  <App />,
  {
    onAllReady() {
      res.statusCode = 200;
      res.setHeader('Content-type', 'text/html');
      pipe(res);
    },
    onShellError(x) {
      res.statusCode = 500;
      res.send(
        '<!doctype html><p>Loading...</p><script src="clientrender.js"></script>'
      );
    }
  }
);

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4