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
Copy file name to clipboardexpand all lines: docs/02-app/01-building-your-application/02-data-fetching/02-server-actions-and-mutations.mdx
+10-10
Original file line number
Diff line number
Diff line change
@@ -358,10 +358,10 @@ export default async function createsUser(formData) {
358
358
}
359
359
```
360
360
361
-
Once the fields have been validated on the server, you can return a serializable object in your action and use the React [`useFormState`](https://react.dev/reference/react-dom/hooks/useFormState) hook to show a message to the user.
361
+
Once the fields have been validated on the server, you can return a serializable object in your action and use the React [`useActionState`](https://react.dev/reference/react-dom/hooks/useActionState) hook to show a message to the user.
362
362
363
-
- By passing the action to `useFormState`, the action's function signature changes to receive a new `prevState` or `initialState` parameter as its first argument.
364
-
-`useFormState` is a React hook and therefore must be used in a Client Component.
363
+
- By passing the action to `useActionState`, the action's function signature changes to receive a new `prevState` or `initialState` parameter as its first argument.
364
+
-`useActionState` is a React hook and therefore must be used in a Client Component.
365
365
366
366
```tsx filename="app/actions.ts" switcher
367
367
'use server'
@@ -385,20 +385,20 @@ export async function createUser(prevState, formData) {
385
385
}
386
386
```
387
387
388
-
Then, you can pass your action to the `useFormState` hook and use the returned `state` to display an error message.
388
+
Then, you can pass your action to the `useActionState` hook and use the returned `state` to display an error message.
@@ -739,7 +739,7 @@ export async function createTodo(prevState, formData) {
739
739
740
740
> **Good to know:**
741
741
>
742
-
> - Aside from throwing the error, you can also return an object to be handled by `useFormState`. See [Server-side validation and error handling](#server-side-validation-and-error-handling).
742
+
> - Aside from throwing the error, you can also return an object to be handled by `useActionState`. See [Server-side validation and error handling](#server-side-validation-and-error-handling).
743
743
744
744
### Revalidating data
745
745
@@ -1002,5 +1002,5 @@ For more information on Server Actions, check out the following React docs:
Copy file name to clipboardexpand all lines: docs/02-app/01-building-your-application/09-authentication/index.mdx
+10-8
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ The examples on this page walk through basic username and password auth for educ
29
29
30
30
### Sign-up and login functionality
31
31
32
-
You can use the [`<form>`](https://react.dev/reference/react-dom/components/form) element with React's [Server Actions](/docs/app/building-your-application/rendering/server-components), [`useFormStatus()`](https://react.dev/reference/react-dom/hooks/useFormStatus), and [`useFormState()`](https://react.dev/reference/react-dom/hooks/useFormState) to capture user credentials, validate form fields, and call your Authentication Provider's API or database.
32
+
You can use the [`<form>`](https://react.dev/reference/react-dom/components/form) element with React's [Server Actions](/docs/app/building-your-application/rendering/server-components), [`useFormStatus()`](https://react.dev/reference/react-dom/hooks/useFormStatus), and [`useActionState()`](https://react.dev/reference/react/useActionState) to capture user credentials, validate form fields, and call your Authentication Provider's API or database.
33
33
34
34
Since Server Actions always execute on the server, they provide a secure environment for handling authentication logic.
35
35
@@ -200,16 +200,16 @@ export async function signup(state, formData) {
200
200
}
201
201
```
202
202
203
-
Back in your `<SignupForm />`, you can use React's `useFormState()` hook to display validation errors to the user:
203
+
Back in your `<SignupForm />`, you can use React's `useActionState()` hook to display validation errors to the user:
Copy file name to clipboardexpand all lines: packages/next-swc/crates/next-custom-transforms/tests/errors/react-server-components/server-graph/react-dom-api/input.js
Copy file name to clipboardexpand all lines: packages/next-swc/crates/next-custom-transforms/tests/errors/react-server-components/server-graph/react-dom-api/output.js
0 commit comments