diff --git a/content/docs/reference-react.md b/content/docs/reference-react.md index d506a1ad31..0ee52dbb4d 100644 --- a/content/docs/reference-react.md +++ b/content/docs/reference-react.md @@ -1,6 +1,6 @@ --- id: react-api -title: React Top-Level API +title: React 顶层 API layout: docs category: Reference permalink: docs/react-api.html @@ -13,35 +13,35 @@ redirect_from: - "docs/top-level-api-zh-CN.html" --- -`React` is the entry point to the React library. If you load React from a `<script>` tag, these top-level APIs are available on the `React` global. If you use ES6 with npm, you can write `import React from 'react'`. If you use ES5 with npm, you can write `var React = require('react')`. +`React` 是 React 库的入口。如果你通过使用 `<script>` 标签的方式来加载 React,则可以通过 `React` 全局变量对象来获得 React 的顶层 API。当你使用 ES6 与 npm 时,可以通过编写 `import React from 'react'` 来引入它们。当你使用 ES5 与 npm 时,则可以通过编写 `var React = require('react')` 来引入它们。 -## Overview {#overview} +## 概览 {#overview} -### Components {#components} +### 组件 {#components} -React components let you split the UI into independent, reusable pieces, and think about each piece in isolation. React components can be defined by subclassing `React.Component` or `React.PureComponent`. +使用 React 组件可以将 UI 拆分为独立且复用的代码片段,每部分都可独立维护。你可以通过子类 `React.Component` 或 `React.PureComponent` 来定义 React 组件。 - [`React.Component`](#reactcomponent) - [`React.PureComponent`](#reactpurecomponent) -If you don't use ES6 classes, you may use the `create-react-class` module instead. See [Using React without ES6](/docs/react-without-es6.html) for more information. +如果你不使用 ES6 的 class,则可以使用 `create-react-class` 模块来替代。请参阅[不使用 ES6](/docs/react-without-es6.html) 以获取更多详细信息。 -React components can also be defined as functions which can be wrapped: +React 组件也可以被定义为可被包装的函数: - [`React.memo`](#reactmemo) -### Creating React Elements {#creating-react-elements} +### 创建 React 元素 {#creating-react-elements} -We recommend [using JSX](/docs/introducing-jsx.html) to describe what your UI should look like. Each JSX element is just syntactic sugar for calling [`React.createElement()`](#createelement). You will not typically invoke the following methods directly if you are using JSX. +我们建议[使用 JSX](/docs/introducing-jsx.html) 来编写你的 UI 组件。每个 JSX 元素都是调用 [`React.createElement()`](#createelement) 的语法糖。一般来说,如果你使用了 JSX,就不再需要调用以下方法。 - [`createElement()`](#createelement) - [`createFactory()`](#createfactory) -See [Using React without JSX](/docs/react-without-jsx.html) for more information. +请参阅[不使用 JSX](/docs/react-without-jsx.html) 以获取更多详细信息。 -### Transforming Elements {#transforming-elements} +### 转换元素 {#transforming-elements} -`React` provides several APIs for manipulating elements: +`React` 提供了几个用于操作元素的 API: - [`cloneElement()`](#cloneelement) - [`isValidElement()`](#isvalidelement) @@ -49,7 +49,7 @@ See [Using React without JSX](/docs/react-without-jsx.html) for more information ### Fragments {#fragments} -`React` also provides a component for rendering multiple elements without a wrapper. +`React` 还提供了用于减少不必要嵌套的组件。 - [`React.Fragment`](#reactfragment) @@ -60,20 +60,20 @@ See [Using React without JSX](/docs/react-without-jsx.html) for more information ### Suspense {#suspense} -Suspense lets components "wait" for something before rendering. Today, Suspense only supports one use case: [loading components dynamically with `React.lazy`](/docs/code-splitting.html#reactlazy). In the future, it will support other use cases like data fetching. +Suspense 使得组件可以“等待”某些操作结束后,再进行渲染。目前,Suspense 仅支持的使用场景是:[通过 `React.lazy` 动态加载组件](/docs/code-splitting.html#reactlazy)。它将在未来支持其它使用场景,如数据获取等。 - [`React.lazy`](#reactlazy) - [`React.Suspense`](#reactsuspense) ### Hooks {#hooks} -*Hooks* are a new addition in React 16.8. They let you use state and other React features without writing a class. Hooks have a [dedicated docs section](/docs/hooks-intro.html) and a separate API reference: +*Hooks* 是在 React 16.8 中引入的新概念。Hooks 允许你在不使用 class 组件的情况下使用 state 及其他 React 功能。Hooks 拥有[专属文档章节](/docs/hooks-intro.html)和单独的 API 参考文档: -- [Basic Hooks](/docs/hooks-reference.html#basic-hooks) +- [基础 Hooks](/docs/hooks-reference.html#basic-hooks) - [`useState`](/docs/hooks-reference.html#usestate) - [`useEffect`](/docs/hooks-reference.html#useeffect) - [`useContext`](/docs/hooks-reference.html#usecontext) -- [Additional Hooks](/docs/hooks-reference.html#additional-hooks) +- [额外的 Hooks](/docs/hooks-reference.html#additional-hooks) - [`useReducer`](/docs/hooks-reference.html#usereducer) - [`useCallback`](/docs/hooks-reference.html#usecallback) - [`useMemo`](/docs/hooks-reference.html#usememo) @@ -84,11 +84,11 @@ Suspense lets components "wait" for something before rendering. Today, Suspense * * * -## Reference {#reference} +## 参考 {#reference} ### `React.Component` {#reactcomponent} -`React.Component` is the base class for React components when they are defined using [ES6 classes](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes): +`React.Component` 是使用 [ES6 classes](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) 方式定义 React 组件的基类: ```javascript class Greeting extends React.Component { @@ -98,21 +98,21 @@ class Greeting extends React.Component { } ``` -See the [React.Component API Reference](/docs/react-component.html) for a list of methods and properties related to the base `React.Component` class. +请参阅 [React.Component API 参考](/docs/react-component.html),获取与基类 `React.Component` 相关方法和属性的详细列表。 * * * ### `React.PureComponent` {#reactpurecomponent} -`React.PureComponent` is similar to [`React.Component`](#reactcomponent). The difference between them is that [`React.Component`](#reactcomponent) doesn't implement [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate), but `React.PureComponent` implements it with a shallow prop and state comparison. +`React.PureComponent` 与 [`React.Component`](#reactcomponent) 很相似。两者的区别在于 [`React.Component`](#reactcomponent) 并未实现 [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate),而 `React.PureComponent` 中以浅层对比 prop 和 state 的方式来实现了该函数。 -If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases. +如果赋予 React 组件相同的 props 和 state,`render()` 函数会渲染相同的内容,那么在某些情况下使用 `React.PureComponent` 可提高性能。 -> Note +> 注意 > -> `React.PureComponent`'s `shouldComponentUpdate()` only shallowly compares the objects. If these contain complex data structures, it may produce false-negatives for deeper differences. Only extend `PureComponent` when you expect to have simple props and state, or use [`forceUpdate()`](/docs/react-component.html#forceupdate) when you know deep data structures have changed. Or, consider using [immutable objects](https://facebook.github.io/immutable-js/) to facilitate fast comparisons of nested data. +> `React.PureComponent` 中的 `shouldComponentUpdate()` 仅作对象的浅层比较。如果对象中包含复杂的数据结构,则有可能因为无法检查深层的差别,产生错误的比对结果。仅在你的 props 和 state 较为简单时,才使用 `React.PureComponent`,或者在深层数据结构发生变化时调用 [`forceUpdate()`](/docs/react-component.html#forceupdate) 来确保组件被正确地更新。你也可以考虑使用 [immutable 对象](https://facebook.github.io/immutable-js/)加速嵌套数据的比较。 > -> Furthermore, `React.PureComponent`'s `shouldComponentUpdate()` skips prop updates for the whole component subtree. Make sure all the children components are also "pure". +> 此外,`React.PureComponent` 中的 `shouldComponentUpdate()` 将跳过所有子组件树的 prop 更新。因此,请确保所有子组件也都是“纯”的组件。 * * * @@ -120,35 +120,35 @@ If your React component's `render()` function renders the same result given the ```javascript const MyComponent = React.memo(function MyComponent(props) { - /* render using props */ + /* 使用 props 渲染 */ }); ``` -`React.memo` is a [higher order component](/docs/higher-order-components.html). It's similar to [`React.PureComponent`](#reactpurecomponent) but for function components instead of classes. +`React.memo` 为[高阶组件](/docs/higher-order-components.html)。它与 [`React.PureComponent`](#reactpurecomponent) 非常相似,但它适用于函数组件,但不适用于 class 组件。 -If your function component renders the same result given the same props, you can wrap it in a call to `React.memo` for a performance boost in some cases by memoizing the result. This means that React will skip rendering the component, and reuse the last rendered result. +如果你的函数组件在给定相同 props 的情况下渲染相同的结果,那么你可以通过将其包装在 `React.memo` 中调用,以此通过记忆组件渲染结果的方式来提高组件的性能表现。这意味着在这种情况下,React 将跳过渲染组件的操作并直接复用最近一次渲染的结果。 -By default it will only shallowly compare complex objects in the props object. If you want control over the comparison, you can also provide a custom comparison function as the second argument. +默认情况下其只会对复杂对象做浅层对比,如果你想要控制对比过程,那么请将自定义的比较函数通过第二个参数传入来实现。 ```javascript function MyComponent(props) { - /* render using props */ + /* 使用 props 渲染 */ } function areEqual(prevProps, nextProps) { /* - return true if passing nextProps to render would return - the same result as passing prevProps to render, - otherwise return false + 如果把 nextProps 传入 render 方法的返回结果与 + 将 prevProps 传入 render 方法的返回结果一致则返回 true, + 否则返回 false */ } export default React.memo(MyComponent, areEqual); ``` -This method only exists as a **[performance optimization](/docs/optimizing-performance.html).** Do not rely on it to "prevent" a render, as this can lead to bugs. +此方法仅作为**[性能优化](/docs/optimizing-performance.html)**的方式而存在。但请不要依赖它来“阻止”渲染,因为这会产生 bug。 -> Note +> 注意 > -> Unlike the [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate) method on class components, the `areEqual` function returns `true` if the props are equal and `false` if the props are not equal. This is the inverse from `shouldComponentUpdate`. +> 与 class 组件中 [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate) 方法不同的是,如果 props 相等,`areEqual` 会返回 `true`;如果 props 不相等,则返回 `false`。这与 `shouldComponentUpdate` 方法的返回值相反。 * * * @@ -162,9 +162,9 @@ React.createElement( ) ``` -Create and return a new [React element](/docs/rendering-elements.html) of the given type. The type argument can be either a tag name string (such as `'div'` or `'span'`), a [React component](/docs/components-and-props.html) type (a class or a function), or a [React fragment](#reactfragment) type. +创建并返回指定类型的新 [React 元素](/docs/rendering-elements.html)。其中的类型参数既可以是标签名字符串(如 `'div'` 或 `'span'`),也可以是 [React 组件](/docs/components-and-props.html) 类型 (class 组件或函数组件),或是 [React fragment](#reactfragment) 类型。 -Code written with [JSX](/docs/introducing-jsx.html) will be converted to use `React.createElement()`. You will not typically invoke `React.createElement()` directly if you are using JSX. See [React Without JSX](/docs/react-without-jsx.html) to learn more. +使用 [JSX](/docs/introducing-jsx.html) 编写的代码将会被转换成使用 `React.createElement()` 的形式。如果使用了 JSX 方式,那么一般来说就不需要直接调用 `React.createElement()`。请查阅[不使用 JSX](/docs/react-without-jsx.html) 章节获得更多信息。 * * * @@ -178,17 +178,17 @@ React.cloneElement( ) ``` -Clone and return a new React element using `element` as the starting point. The resulting element will have the original element's props with the new props merged in shallowly. New children will replace existing children. `key` and `ref` from the original element will be preserved. +以 `element` 元素为样板克隆并返回新的 React 元素。返回元素的 props 是将新的 props 与原始元素的 props 浅层合并后的结果。新的子元素将取代现有的子元素,而来自原始元素的 `key` 和 `ref` 将被保留。 -`React.cloneElement()` is almost equivalent to: +`React.cloneElement()` 几乎等同于: ```js <element.type {...element.props} {...props}>{children}</element.type> ``` -However, it also preserves `ref`s. This means that if you get a child with a `ref` on it, you won't accidentally steal it from your ancestor. You will get the same `ref` attached to your new element. +但是,这也保留了组件的 `ref`。这意味着当通过 `ref` 获取子节点时,你将不会意外地从你祖先节点上窃取它。相同的 `ref` 将添加到克隆后的新元素中。 -This API was introduced as a replacement of the deprecated `React.addons.cloneWithProps()`. +引入此 API 是为了替换已弃用的 `React.addons.cloneWithProps()`。 * * * @@ -198,11 +198,11 @@ This API was introduced as a replacement of the deprecated `React.addons.cloneWi React.createFactory(type) ``` -Return a function that produces React elements of a given type. Like [`React.createElement()`](#createElement), the type argument can be either a tag name string (such as `'div'` or `'span'`), a [React component](/docs/components-and-props.html) type (a class or a function), or a [React fragment](#reactfragment) type. +返回用于生成指定类型 React 元素的函数。与 [`React.createElement()`](#createElement) 相似的是,类型参数既可以是标签名字符串(像是 `'div'` 或 `'span'`),也可以是 [React 组件](/docs/components-and-props.html) 类型 (class 组件或函数组件),或是 [React fragment](#reactfragment) 类型。 -This helper is considered legacy, and we encourage you to either use JSX or use `React.createElement()` directly instead. +此辅助函数已废弃,建议使用 JSX 或直接调用 `React.createElement()` 来替代它。 -You will not typically invoke `React.createFactory()` directly if you are using JSX. See [React Without JSX](/docs/react-without-jsx.html) to learn more. +如果你使用 JSX,通常不会直接调用 `React.createFactory()`。请参阅[不使用 JSX](/docs/react-without-jsx.html) 以获得更多信息。 * * * @@ -212,13 +212,13 @@ You will not typically invoke `React.createFactory()` directly if you are using React.isValidElement(object) ``` -Verifies the object is a React element. Returns `true` or `false`. +验证对象是否为 React 元素,返回值为 `true` 或 `false`。 * * * ### `React.Children` {#reactchildren} -`React.Children` provides utilities for dealing with the `this.props.children` opaque data structure. +`React.Children` 提供了用于处理 `this.props.children` 不透明数据结构的实用方法。 #### `React.Children.map` {#reactchildrenmap} @@ -226,11 +226,11 @@ Verifies the object is a React element. Returns `true` or `false`. React.Children.map(children, function[(thisArg)]) ``` -Invokes a function on every immediate child contained within `children` with `this` set to `thisArg`. If `children` is an array it will be traversed and the function will be called for each child in the array. If children is `null` or `undefined`, this method will return `null` or `undefined` rather than an array. +在 `children` 里的每个直接子节点上调用一个函数,并将 `this` 设置为 `thisArg`。如果 `children` 是一个数组,它将被遍历并为数组中的每个子节点调用该函数。如果子节点为 `null` 或是 `undefined`,则此方法将返回 `null` 或是 `undefined`,而不会返回数组。 -> Note +> 注意 > -> If `children` is a `Fragment` it will be treated as a single child and not traversed. +> 如果 `children` 是一个 `Fragment` 对象,它将被视为单一子节点的情况处理,而不会被遍历。 #### `React.Children.forEach` {#reactchildrenforeach} @@ -238,7 +238,7 @@ Invokes a function on every immediate child contained within `children` with `th React.Children.forEach(children, function[(thisArg)]) ``` -Like [`React.Children.map()`](#reactchildrenmap) but does not return an array. +与 [`React.Children.map()`](#reactchildrenmap) 类似,但它不会返回一个数组。 #### `React.Children.count` {#reactchildrencount} @@ -246,7 +246,7 @@ Like [`React.Children.map()`](#reactchildrenmap) but does not return an array. React.Children.count(children) ``` -Returns the total number of components in `children`, equal to the number of times that a callback passed to `map` or `forEach` would be invoked. +返回 `children` 中的组件总数量,等同于通过 `map` 或 `forEach` 调用回调函数的次数。 #### `React.Children.only` {#reactchildrenonly} @@ -254,11 +254,11 @@ Returns the total number of components in `children`, equal to the number of tim React.Children.only(children) ``` -Verifies that `children` has only one child (a React element) and returns it. Otherwise this method throws an error. +验证 `children` 是否只有一个子节点(一个 React 元素),如果有则返回它,否则此方法会抛出错误。 -> Note: +> 注意: > ->`React.Children.only()` does not accept the return value of [`React.Children.map()`](#reactchildrenmap) because it is an array rather than a React element. +>`React.Children.only()` 不接受 [`React.Children.map()`](#reactchildrenmap) 的返回值,因为它是一个数组而并不是 React 元素。 #### `React.Children.toArray` {#reactchildrentoarray} @@ -266,17 +266,17 @@ Verifies that `children` has only one child (a React element) and returns it. Ot React.Children.toArray(children) ``` -Returns the `children` opaque data structure as a flat array with keys assigned to each child. Useful if you want to manipulate collections of children in your render methods, especially if you want to reorder or slice `this.props.children` before passing it down. +将 `children` 这个复杂的数据结构以数组的方式扁平展开并返回,并为每个子节点分配一个 key。当你想要在渲染函数中操作子节点的集合时,它会非常实用,特别是当你想要在向下传递 `this.props.children` 之前对内容重新排序或获取子集时。 -> Note: +> 注意: > -> `React.Children.toArray()` changes keys to preserve the semantics of nested arrays when flattening lists of children. That is, `toArray` prefixes each key in the returned array so that each element's key is scoped to the input array containing it. +> `React.Children.toArray()` 在拉平展开子节点列表时,更改 key 值以保留嵌套数组的语义。也就是说,`toArray` 会为返回数组中的每个 key 添加前缀,以使得每个元素 key 的范围都限定在此函数入参数组的对象内。 * * * ### `React.Fragment` {#reactfragment} -The `React.Fragment` component lets you return multiple elements in a `render()` method without creating an additional DOM element: +`React.Fragment` 组件能够在不额外创建 DOM 元素的情况下,让 `render()` 方法中返回多个元素。 ```javascript render() { @@ -289,59 +289,59 @@ render() { } ``` -You can also use it with the shorthand `<></>` syntax. For more information, see [React v16.2.0: Improved Support for Fragments](/blog/2017/11/28/react-v16.2.0-fragment-support.html). +你也可以使用其简写语法 `<></>`。欲了解更多相关信息,请参阅 [React v16.2.0: Fragments 支持改进](/blog/2017/11/28/react-v16.2.0-fragment-support.html)。 ### `React.createRef` {#reactcreateref} -`React.createRef` creates a [ref](/docs/refs-and-the-dom.html) that can be attached to React elements via the ref attribute. +`React.createRef` 创建一个能够通过 ref 属性附加到 React 元素的 [ref](/docs/refs-and-the-dom.html)。 `embed:16-3-release-blog-post/create-ref-example.js` ### `React.forwardRef` {#reactforwardref} -`React.forwardRef` creates a React component that forwards the [ref](/docs/refs-and-the-dom.html) attribute it receives to another component below in the tree. This technique is not very common but is particularly useful in two scenarios: +`React.forwardRef` 会创建一个React组件,这个组件能够将其接受的 [ref](/docs/refs-and-the-dom.html) 属性转发到其组件树下的另一个组件中。这种技术并不常见,但在以下两种场景中特别有用: -* [Forwarding refs to DOM components](/docs/forwarding-refs.html#forwarding-refs-to-dom-components) -* [Forwarding refs in higher-order-components](/docs/forwarding-refs.html#forwarding-refs-in-higher-order-components) +* [转发 refs 到 DOM 组件](/docs/forwarding-refs.html#forwarding-refs-to-dom-components) +* [在高阶组件中转发 refs](/docs/forwarding-refs.html#forwarding-refs-in-higher-order-components) -`React.forwardRef` accepts a rendering function as an argument. React will call this function with `props` and `ref` as two arguments. This function should return a React node. +`React.forwardRef` 接受渲染函数作为参数。React 将使用 `props` 和 `ref` 作为参数来调用此函数。此函数应返回 React 节点。 `embed:reference-react-forward-ref.js` -In the above example, React passes a `ref` given to `<FancyButton ref={ref}>` element as a second argument to the rendering function inside the `React.forwardRef` call. This rendering function passes the `ref` to the `<button ref={ref}>` element. +在上述的示例中,React 会将 `<FancyButton ref={ref}>` 元素的 `ref` 作为第二个参数传递给 `React.forwardRef` 函数中的渲染函数。该渲染函数会将 `ref` 传递给 `<button ref={ref}>` 元素。 -As a result, after React attaches the ref, `ref.current` will point directly to the `<button>` DOM element instance. +因此,当 React 附加了 ref 属性之后,`ref.current` 将直接指向 `<button>` DOM 元素实例。 -For more information, see [forwarding refs](/docs/forwarding-refs.html). +欲了解更多相关信息,请参阅 [refs 转发](/docs/forwarding-refs.html)。 ### `React.lazy` {#reactlazy} -`React.lazy()` lets you define a component that is loaded dynamically. This helps reduce the bundle size to delay loading components that aren't used during the initial render. +`React.lazy()` 允许你定义一个动态加载的组件。这有助于缩减 bundle 的体积,并延迟加载在初次渲染时未用到的组件。 -You can learn how to use it from our [code splitting documentation](/docs/code-splitting.html#reactlazy). You might also want to check out [this article](https://medium.com/@pomber/lazy-loading-and-preloading-components-in-react-16-6-804de091c82d) explaining how to use it in more detail. +你可以在[代码分割文档](/docs/code-splitting.html#reactlazy)中学习如何使用它。查阅[此文章](https://medium.com/@pomber/lazy-loading-and-preloading-components-in-react-16-6-804de091c82d)可以了解更多用法细节。 ```js -// This component is loaded dynamically +// 这个组件是动态加载的 const SomeComponent = React.lazy(() => import('./SomeComponent')); ``` -Note that rendering `lazy` components requires that there's a `<React.Suspense>` component higher in the rendering tree. This is how you specify a loading indicator. +请注意,渲染 `lazy` 组件依赖该组件渲染树上层的 `<React.Suspense>` 组件。这是指定加载指示器(loading indicator)的方式。 -> **Note** +> **注意** > -> Using `React.lazy`with dynamic import requires Promises to be available in the JS environment. This requires a polyfill on IE11 and below. +> 使用 `React.lazy` 的动态引入特性需要 JS 环境支持 Promise。在 IE11 及以下版本的浏览器中需要通过引入 polyfill 来使用该特性。 ### `React.Suspense` {#reactsuspense} -`React.Suspense` let you specify the loading indicator in case some components in the tree below it are not yet ready to render. Today, lazy loading components is the **only** use case supported by `<React.Suspense>`: +`React.Suspense` 可以指定加载指示器(loading indicator),以防其组件树中的某些子组件尚未具备渲染条件。目前,懒加载组件是 `<React.Suspense>` 支持的**唯一**用例: ```js -// This component is loaded dynamically +// 该组件是动态加载的 const OtherComponent = React.lazy(() => import('./OtherComponent')); function MyComponent() { return ( - // Displays <Spinner> until OtherComponent loads + // 显示 <Spinner> 组件直至 OtherComponent 加载完成 <React.Suspense fallback={<Spinner />}> <div> <OtherComponent /> @@ -351,10 +351,10 @@ function MyComponent() { } ``` -It is documented in our [code splitting guide](/docs/code-splitting.html#reactlazy). Note that `lazy` components can be deep inside the `Suspense` tree -- it doesn't have to wrap every one of them. The best practice is to place `<Suspense>` where you want to see a loading indicator, but to use `lazy()` wherever you want to do code splitting. +它已被收录在了我们的[代码分割指南](/docs/code-splitting.html#reactlazy)中。请注意,`lazy` 组件可以位于 `Suspense` 组件树的深处——它不必包装树中的每一个延迟加载组件。最佳实践是将 `<Suspense>` 置于你想展示加载指示器(loading indicator)的位置,而 `lazy()` 则可被放置于任何你想要做代码分割的地方。 -While this is not supported today, in the future we plan to let `Suspense` handle more scenarios such as data fetching. You can read about this in [our roadmap](/blog/2018/11/27/react-16-roadmap.html). +虽然目前尚未支持其它特性,但未来我们计划让 `Suspense` 支持包括数据获取在内的更多场景。你可以在 [roadmap](/blog/2018/11/27/react-16-roadmap.html) 中了解相关信息。 ->Note: +>注意: > ->`React.lazy()` and `<React.Suspense>` are not yet supported by `ReactDOMServer`. This is a known limitation that will be resolved in the future. +>`React.lazy()` 和 `<React.Suspense>` 尚未在 `ReactDOMServer` 中支持。这是已知问题,将会在未来解决。