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
`useActionState` accepts a function (the "Action"), and returns a new Action to call. This works because Actions compose. When the new Action is called, `useActionState` will return the last result of the Action as `data`, and the pending state of the Action as `pending`.
113
113
114
+
<Note>
115
+
116
+
`React.useActionState` was previously called `ReactDOM.useFormState` in the Canary releases, but we've renamed it and deprecated `useFormState`.
117
+
118
+
See [#28491](https://github.com/facebook/react/pull/28491) for more info.
119
+
120
+
</Note>
121
+
114
122
For more information, see the docs for [`useActionState`](/reference/react/useActionState).
115
123
116
124
### Form Actions {/*form-actions*/}
@@ -148,7 +156,7 @@ function NameInput() {
148
156
}
149
157
```
150
158
151
-
`useFormStatus` works like Context for the nearest `<form>` element, returning it's`pending` state, the last submitted form `data`, and the `action`.
159
+
`useFormStatus` works like Context for the nearest `<form>` element, returning its`pending` state, the last submitted form `data`, and the `action`.
152
160
153
161
For more information, see the docs for [`useFormStatus`](/reference/react-dom/hooks/useFormStatus).
154
162
@@ -180,7 +188,7 @@ return (
180
188
</form>
181
189
);
182
190
```
183
-
The `useOptimisitc` hook will immediately render the `optimisticName` while the `updateName` request is in progress. When the update finishes, React will automatically switch back to the original `name` value.
191
+
The `useOptimistic` hook will immediately render the `optimisticName` while the `updateName` request is in progress. When the update finishes or errors, React will automatically switch back to the original `name` value.
184
192
185
193
For more information, see the docs for [`useOptimistic`](/reference/react/useOptimistic).
186
194
@@ -205,7 +213,7 @@ Or you can read context with `use`:
@@ -503,11 +515,11 @@ This works by first rendering `Notes` as a Server Component, and then instructin
503
515
504
516
Server Components introduce a new way to write Components using async/await. When you `await` in an async component, React will suspend and wait for the promise to resolve before resuming rendering. This works across server/client boundaries with streaming support for Suspense.
505
517
506
-
You can even start a promise on the server, and resume it on the client:
518
+
You can even create a promise on the server, and await it on the client:
507
519
508
520
```js
509
521
// Server Component
510
-
importdbfrom'db';
522
+
importdbfrom'./database';
511
523
512
524
asyncfunctionPage({id}) {
513
525
// Will suspend the Server Component.
@@ -565,7 +577,7 @@ Server Components can define Server Actions with the `"use server"` directive:
@@ -826,7 +838,9 @@ When the component unmounts, React will call the cleanup function returned from
826
838
827
839
<Note>
828
840
829
-
When the cleanup function is provided, React will not call the ref with `null`. In future versions, we will deprecate calling the ref with `null` as a way to reset the `ref`.
841
+
Previously, React would call ref functions with `null` when unmounting the component. If your ref returns a cleanup function, React will skip this step.
842
+
843
+
In future versions, we will deprecate calling the ref with `null` when unmounting components.
830
844
831
845
</Note>
832
846
@@ -961,7 +975,7 @@ React will try to recreate this component tree from scratch using the error boun
961
975
962
976
</ConsoleBlockMulti>
963
977
964
-
Additionally, we've added two newroot options to compliment`onRecoverableError`:
978
+
Additionally, we've added two newroot options to complement`onRecoverableError`:
965
979
966
980
-`onCaughtError`: called when React catches an error in an Error Boundary.
967
981
-`onUncaughtError`: called when an error is thrown and not caught by an Error Boundary.
@@ -971,7 +985,7 @@ For more info and examples, see the docs for [`createRoot`](/reference/react-dom
971
985
972
986
### Diffs for Hydration Errors {/*diffs-for-hydration-errors*/}
973
987
974
-
We also improved error reporting for hydration errors. For example, instead of logging multiple errors inDEV without any information about what mismatched:
988
+
We also improved error reporting for hydration errors. For example, instead of logging multiple errors inDEV without any information about the mismatch:
0 commit comments