客户端 React DOM API

react-dom/client API 让你可以在客户端(浏览器中)渲染 React 组件。这些 API 通常在应用的顶层使用,以初始化你的 React 树。框架 可能会为你调用它们。你大部分的组件不需要导入或使用它们。

🌐 The react-dom/client APIs let you render React components on the client (in the browser). These APIs are typically used at the top level of your app to initialize your React tree. A framework may call them for you. Most of your components don’t need to import or use them.


客户端 API

🌐 Client APIs

  • createRoot 让你创建一个根,用于在浏览器 DOM 节点中显示 React 组件。
  • hydrateRoot 允许你在其 HTML 内容之前由 react-dom/server 生成的浏览器 DOM 节点中显示 React 组件。

浏览器支持

🌐 Browser support

React 支持所有流行的浏览器,包括 Internet Explorer 9 及以上版本。较旧的浏览器(如 IE 9 和 IE 10)需要一些 polyfill。

🌐 React supports all popular browsers, including Internet Explorer 9 and above. Some polyfills are required for older browsers such as IE 9 and IE 10.