tezvyn:

useFormState (now useActionState): State for Actions

Source: react.devadvanced

useActionState (formerly useFormState) lets you update state from an async Action. It returns the action's result, a dispatch function, and a pending status. Use it to manage form UI for loading states and validation messages from Server Actions.

useActionState (formerly useFormState) is a hook for managing state tied to an async operation, or Action. It takes a reducer and initial state, returning the current state, a dispatch function, and an `isPending` boolean. This is ideal for forms, where you can show loading states and display success or error messages returned from a Server Action without complex `useEffect` chains. The key footgun is realizing it's for state *derived from* an action's result, not just any state.

Read the original → react.dev

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

useFormState (now useActionState): State for Actions · Tezvyn