Skip to content

Commit f688610

Browse files
authored
docs(cn): update useDeferredValue translation (#1626)
2 parents 5b95c4b + 7d86e81 commit f688610

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/content/reference/react/useDeferredValue.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ function SearchPage() {
3737
#### 参数 {/*parameters*/}
3838

3939
* `value`: 你想延迟的值,可以是任何类型。
40-
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `initialValue`: A value to use during the initial render of a component. If this option is omitted, `useDeferredValue` will not defer during the initial render, because there's no previous version of `value` that it can render instead.
40+
* <CanaryBadge title="这个功能只在 Canary 渠道中可用" /> **可选的** `initialValue`: 组件初始渲染时使用的值。如果省略此选项,`useDeferredValue` 在初始渲染期间不会延迟,因为没有以前的版本可以渲染。
4141

4242
#### 返回值 {/*returns*/}
4343

44-
- `currentValue`: During the initial render, the returned deferred value will be the same as the value you provided. During updates, React will first attempt a re-render with the old value (so it will return the old value), and then try another re-render in the background with the new value (so it will return the updated value).
44+
- `currentValue`: 在初始渲染期间,返回的延迟值将与你提供的值相同。在更新期间,React 首先尝试使用旧值重新渲染(因此返回旧值),然后在后台尝试使用新值重新渲染(因此返回更新后的值)。
4545

4646
<Canary>
4747

48-
In the latest React Canary versions, `useDeferredValue` returns the `initialValue` on initial render, and schedules a re-render in the background with the `value` returned.
48+
在最新的 React Canary 版本中,`useDeferredValue` 在初始渲染期间返回 `initialValue`,并在后台使用返回的 `value` 重新调度渲染。
4949

5050
</Canary>
5151

5252
#### 注意事项 {/*caveats*/}
5353

54-
- When an update is inside a Transition, `useDeferredValue` always returns the new `value` and does not spawn a deferred render, since the update is already deferred.
54+
- 当更新发生在 Transition 内部时,`useDeferredValue` 总是返回新的 `value` 并且不会产生延迟渲染,因为该更新已经被延迟了。
5555

56-
- The values you pass to `useDeferredValue` should either be primitive values (like strings and numbers) or objects created outside of rendering. If you create a new object during rendering and immediately pass it to `useDeferredValue`, it will be different on every render, causing unnecessary background re-renders.
56+
- 传递给 `useDeferredValue` 的值应该是原始值(如字符串和数字)或是在渲染之外创建的对象。如果你在渲染期间创建一个新对象并立即将其传递给 `useDeferredValue`,它在每次渲染时都会不同,从而导致不必要的后台重新渲染。
5757

5858
-`useDeferredValue` 接收到与之前不同的值(使用 [`Object.is`](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/is) 进行比较)时,除了当前渲染(此时它仍然使用旧值),它还会安排一个后台重新渲染。这个后台重新渲染是可以被中断的,如果 `value` 有新的更新,React 会从头开始重新启动后台渲染。举个例子,如果用户在输入框中的输入速度比接收延迟值的图表重新渲染的速度快,那么图表只会在用户停止输入后重新渲染。
5959

0 commit comments

Comments
 (0)