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
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/server/renderToNodeStream.md
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ title: renderToNodeStream
4
4
5
5
<Deprecated>
6
6
7
-
This API will be removed in a future major version of React. Use[`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) instead.
7
+
此 API 将在未来的 React 主要版本中被移除,请使用[`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream)。
8
8
9
9
</Deprecated>
10
10
11
11
<Intro>
12
12
13
-
`renderToNodeStream`renders a React tree to a [Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams)
On the server, call `renderToNodeStream`to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) which you can pipe into the response.
*As of React 18, this method buffers all of its output, so it doesn't actually provide any streaming benefits. This is why it's recommended that you migrate to [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) instead.
*The returned stream is a byte stream encoded in utf-8. If you need a stream in another encoding, take a look at a project like [iconv-lite](https://www.npmjs.com/package/iconv-lite), which provides transform streams for transcoding text.
### Rendering a React tree as HTML to a Node.js Readable Stream {/*rendering-a-react-tree-as-html-to-a-nodejs-readable-stream*/}
62
+
### 为 Node.js 只读流将 React 树渲染为 HTML {/*rendering-a-react-tree-as-html-to-a-nodejs-readable-stream*/}
63
63
64
-
Call`renderToNodeStream`to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) which you can pipe to your server response:
//The route handler syntax depends on your backend framework
69
+
//路由处理程序的语法取决于使用的后端框架。
70
70
app.use('/', (request, response) => {
71
71
conststream=renderToNodeStream(<App />);
72
72
stream.pipe(response);
73
73
});
74
74
```
75
75
76
-
The stream will produce the initial non-interactive HTML output of your React components. On the client, you will need to call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot)to *hydrate* that server-generated HTML and make it interactive.
76
+
这里的流会将 React 组件初始输出为非交互式 HTML。在客户端上,你需要调用 [`hydrateRoot`](/reference/react-dom/client/hydrateRoot)方法来 hydrate 服务器生成的 HTML 并使其具有交互功能。
0 commit comments