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
The stream will produce non-interactive HTML output of your React components.
35
35
36
-
#### 参数 {/*parameters*/}
36
+
#### Parameters {/*parameters*/}
37
37
38
-
*`reactNode`:想要渲染为 HTML 的 React 节点。比如像 `<Page />` 一样的 JSX 元素。
38
+
*`reactNode`: A React node you want to render to HTML. For example, a JSX element like `<Page />`.
39
39
40
-
#### 返回值 {/*returns*/}
40
+
#### Returns {/*returns*/}
41
41
42
-
输出 HTML 字符串的 [Node.js 只读流](https://nodejs.org/api/stream.html#readable-streams),以此法输出的 HTML 不能被客户端 hydrate。
42
+
A [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) that outputs an HTML string. The resulting HTML can't be hydrated on the client.
43
43
44
-
#### 注意 {/*caveats*/}
44
+
#### Caveats {/*caveats*/}
45
45
46
-
*`renderToStaticNodeStream`的输出不能被 hydrate。
46
+
*`renderToStaticNodeStream`output cannot be hydrated.
*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.
53
53
54
54
---
55
55
56
-
## 用法 {/*usage*/}
56
+
## Usage {/*usage*/}
57
57
58
-
### 为 Node.js 只读流将 React 树渲染为静态 HTML {/*rendering-a-react-tree-as-static-html-to-a-nodejs-readable-stream*/}
58
+
### Rendering a React tree as static HTML to a Node.js Readable Stream {/*rendering-a-react-tree-as-static-html-to-a-nodejs-readable-stream*/}
Call`renderToStaticNodeStream`to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) which you can pipe to your server response:
This method renders **non-interactive HTML that cannot be hydrated.** This is useful if you want to use React as a simple static page generator, or if you're rendering completely static content like emails.
Interactive apps should use [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream)on the server and [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) on the client.
0 commit comments