render-to-stream.js — react Source File
Architecture documentation for render-to-stream.js, a javascript file in the react codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d469dba5_b6ac_21d6_fd11_39f7311bf17b["render-to-stream.js"] 80a4d9b0_ea35_ec8f_4f21_8a2085be082e["App.js"] d469dba5_b6ac_21d6_fd11_39f7311bf17b --> 80a4d9b0_ea35_ec8f_4f21_8a2085be082e 0ed5d49a_8ea3_0b80_de56_5d5e1cbc4e72["App"] d469dba5_b6ac_21d6_fd11_39f7311bf17b --> 0ed5d49a_8ea3_0b80_de56_5d5e1cbc4e72 ea6c61ad_b555_8796_c3e4_a78a8f5c0ffc["delays.js"] d469dba5_b6ac_21d6_fd11_39f7311bf17b --> ea6c61ad_b555_8796_c3e4_a78a8f5c0ffc ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] d469dba5_b6ac_21d6_fd11_39f7311bf17b --> ac587885_e294_a1e9_b13f_5e7b920fdb42 860fcd5f_4dd1_15af_0c6d_0894e4c5dffb["server"] d469dba5_b6ac_21d6_fd11_39f7311bf17b --> 860fcd5f_4dd1_15af_0c6d_0894e4c5dffb style d469dba5_b6ac_21d6_fd11_39f7311bf17b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import * as React from 'react';
import {renderToPipeableStream} from 'react-dom/server';
import App from '../src/App';
import {ABORT_DELAY} from './delays';
// In a real setup, you'd read it from webpack build stats.
let assets = {
'main.js': '/main.js',
'main.css': '/main.css',
};
module.exports = function render(url, res) {
// The new wiring is a bit more involved.
res.socket.on('error', error => {
console.error('Fatal', error);
});
let didError = false;
let didFinish = false;
const {pipe, abort} = renderToPipeableStream(<App assets={assets} />, {
bootstrapScripts: [assets['main.js']],
onAllReady() {
// Full completion.
// You can use this for SSG or crawlers.
didFinish = true;
},
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');
setImmediate(() => 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 if enough time passes.
// Try lowering this to see the client recover.
setTimeout(() => {
if (!didFinish) {
abort();
}
}, ABORT_DELAY);
};
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does render-to-stream.js do?
render-to-stream.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in render-to-stream.js?
render-to-stream.js defines 1 function(s): module.
What does render-to-stream.js depend on?
render-to-stream.js imports 5 module(s): App, App.js, delays.js, react, server.
Where is render-to-stream.js in the architecture?
render-to-stream.js is located at fixtures/fizz/server/render-to-stream.js (domain: BabelCompiler, subdomain: Entrypoint, directory: fixtures/fizz/server).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free