Home / Function/ render() — react Function Reference

render() — react Function Reference

Architecture documentation for the render() function in render.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  448ae305_84ec_828d_e2c0_b7ae9ccc9dd1["render()"]
  2d6263d7_eed7_782a_80f5_608e8f93d047["render.js"]
  448ae305_84ec_828d_e2c0_b7ae9ccc9dd1 -->|defined in| 2d6263d7_eed7_782a_80f5_608e8f93d047
  style 448ae305_84ec_828d_e2c0_b7ae9ccc9dd1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fixtures/view-transition/server/render.js lines 17–47

export default function render(url, res) {
  res.socket.on('error', error => {
    // Log fatal errors
    console.error('Fatal', error);
  });
  let didError = false;
  const {pipe, abort} = renderToPipeableStream(
    <App assets={assets} initialURL={url} />,
    {
      bootstrapScripts: [assets['main.js']],
      onShellReady() {
        // If something errored before we started streaming, we set the error code appropriately.
        res.statusCode = didError ? 500 : 200;
        res.setHeader('Content-type', 'text/html');
        pipe(res);
      },
      onShellError(x) {
        // Something errored before we could complete the shell so we emit an alternative shell.
        res.statusCode = 500;
        res.send('<!doctype><p>Error</p>');
      },
      onError(x) {
        didError = true;
        console.error(x);
      },
    }
  );
  // Abandon and switch to client rendering after 5 seconds.
  // Try lowering this to see the client recover.
  setTimeout(abort, 5000);
}

Domain

Subdomains

Frequently Asked Questions

What does render() do?
render() is a function in the react codebase, defined in fixtures/view-transition/server/render.js.
Where is render() defined?
render() is defined in fixtures/view-transition/server/render.js at line 17.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free