useActionState and useFormStatus

useActionState connects a form action to a state: it returns the current state, the action to pass to the form and a pending indicator. useFormStatus, read in a child component of the form, gives the submission status (pending), useful for disabling the button.

Example

const [erreur, action, enCours] = useActionState(envoyer, null);

Related concepts

The whole glossary