@@ -31,7 +31,7 @@ const {prelude} = await prerenderToNodeStream(reactNode, options?)
3131` ` ` js
3232import { prerenderToNodeStream } from ' react-dom/static' ;
3333
34- // The route handler syntax depends on your backend framework
34+ // 路由处理的语法取决于后端框架
3535app .use (' /' , async (request , response ) => {
3636 const { prelude } = await prerenderToNodeStream (< App / > , {
3737 bootstrapScripts: [' /main.js' ],
@@ -90,7 +90,7 @@ app.use('/', async (request, response) => {
9090` ` ` js [[1 , 5 , " <App />" ], [2 , 6 , " ['/main.js']" ]]
9191import { prerenderToNodeStream } from ' react-dom/static' ;
9292
93- // The route handler syntax depends on your backend framework
93+ // 路由处理的语法取决于后端框架
9494app .use (' /' , async (request , response ) => {
9595 const { prelude } = await prerenderToNodeStream (< App / > , {
9696 bootstrapScripts: [' /main.js' ],
@@ -128,7 +128,7 @@ React 会将 [doctype](https://developer.mozilla.org/en-US/docs/Glossary/Doctype
128128` ` ` html [[2 , 5 , " /main.js" ]]
129129< ! DOCTYPE html>
130130< html>
131- <!-- ... HTML from your components ... -->
131+ <!-- ... 组件中的 HTML ... -->
132132< / html>
133133< script src= " /main.js" async = " " >< / script>
134134` ` `
@@ -169,7 +169,7 @@ export default function App({ assetMap }) {
169169在服务器端,渲染 ` < App assetMap= {assetMap} / > ` 并传入 ` assetMap` :
170170
171171` ` ` js {1 - 5 ,8 ,9 }
172- // You'd need to get this JSON from your build tooling, e.g. read it from the build output.
172+ // 您需要从构建工具中获取 JSON。例如,从构建输出中阅读。
173173const assetMap = {
174174 ' styles.css' : ' /styles.123456.css' ,
175175 ' main.js' : ' /main.123456.js'
@@ -188,7 +188,7 @@ app.use('/', async (request, response) => {
188188因为现在服务器端是用 ` assetMap` 渲染 ` < App assetMap= {assetMap} / > ` ,客户端也需要以相同方式渲染以避免 hydration 错误。你可以像下面这样将 ` assetMap` 序列化并传给客户端:
189189
190190` ` ` js {9 - 10 }
191- // You'd need to get this JSON from your build tooling.
191+ // 您需要从构建工具中获取 JSON。
192192const assetMap = {
193193 ' styles.css' : ' /styles.123456.css' ,
194194 ' main.js' : ' /main.123456.js'
@@ -301,8 +301,8 @@ async function renderToString() {
301301 }, 10000 );
302302
303303 try {
304- // the prelude will contain all the HTML that was prerendered
305- // before the controller aborted.
304+ // prelude 将包含预渲染的所有 HTML 代码
305+ // 在控制器终止之前。
306306 const {prelude } = await prerenderToNodeStream (< App / > , {
307307 signal: controller .signal ,
308308 });
0 commit comments