react-dom/server
API 可让你在服务器端将 React 组件渲染为 HTML。这些 API 仅在应用顶层的服务器上使用,以生成初始 HTML。框架 可能会为你调用它们。你的大部分组件不需要导入或使用它们。
¥The react-dom/server
APIs let you server-side render React components to HTML. These APIs are only used on the server at the top level of your app to generate the initial HTML. A framework may call them for you. Most of your components don’t need to import or use them.
Node.js 流的服务器 API
¥Server APIs for Node.js Streams
这些方法只适用于使用 Node.js 流 的环境:
¥These methods are only available in the environments with Node.js Streams:
-
renderToPipeableStream
将 React 树渲染为可管道 Node.js 流。¥
renderToPipeableStream
renders a React tree to a pipeable Node.js Stream.
Web 流的服务器 API
¥Server APIs for Web Streams
这些方法仅在具有 网络流 的环境中可用,其中包括浏览器、Deno 和一些现代 Edge 运行时:
¥These methods are only available in the environments with Web Streams, which includes browsers, Deno, and some modern edge runtimes:
-
renderToReadableStream
将 React 树渲染到 可读网络流。¥
renderToReadableStream
renders a React tree to a Readable Web Stream.
非流式环境的旧服务器 API
¥Legacy Server APIs for non-streaming environments
这些方法可以在不支持流的环境中使用:
¥These methods can be used in the environments that don’t support streams:
-
renderToString
将 React 树渲染为字符串。¥
renderToString
renders a React tree to a string. -
renderToStaticMarkup
将非交互式 React 树渲染为字符串。¥
renderToStaticMarkup
renders a non-interactive React tree to a string.
与流式 API 相比,它们的功能有限。
¥They have limited functionality compared to the streaming APIs.