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
Updates the API docs for `useDeferredValue` to include the
`initialValue` option, added in
facebook/react#27500.
This feature is slated for release in React 19.
Call `useDeferredValue` at the top level of your component to get a deferred version of that value.
24
24
@@ -37,10 +37,19 @@ function SearchPage() {
37
37
#### Parameters {/*parameters*/}
38
38
39
39
*`value`: The value you want to defer. It can have any type.
40
+
***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.
41
+
40
42
41
43
#### Returns {/*returns*/}
42
44
43
-
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).
45
+
Returns either `value`, the old `value` that was previously rendered to the screen, or `initialValue`, depending on the scenario:
46
+
47
+
- During the initial render...
48
+
- If `initialValue`_is_ provided, it first returns `initialValue`, then spawns a deferred render to switch to `value`.
49
+
- If `initialValue`_is not_ provided, it returns `value`, and does not spawn a deferred render.
50
+
- During an update...
51
+
- If the update _is_ the result of a Transition, it returns the new `value`, and does not spawn a deferred render.
52
+
- If the update _is not_ the result of a Transition, it first returns the old `value`, then spawns a deferred render to switch to the new `value`.
0 commit comments