You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current example, the performance impact is minor but with a large number of components, doing this treatment for each server request can have bigger impact.
A quick optimization below:
let moduleMap;
async function renderReactTree(res, props) {
if (!moduleMap) {
await waitForWebpack()
const manifest = readFileSync(
path.resolve(__dirname, '../build/react-client-manifest.json'),
'utf8'
);
moduleMap = JSON.parse(manifest);
}
pipeToNodeWritable(React.createElement(ReactApp, props), res, moduleMap);
}
In
renderReactTree
the following block of code is only required once at runtime:In the current example, the performance impact is minor but with a large number of components, doing this treatment for each server request can have bigger impact.
A quick optimization below:
The NextJS demo is optimized:
https://github.com/vercel/next-server-components/blob/master/libs/send-res.js
The text was updated successfully, but these errors were encountered: