Loading...
function Form() {
const { pending } = useFormStatus();
return (
<form action={save}>
<button disabled={pending}>Save</button>
</form>
);
}function SubmitButton() {
const { pending } = useFormStatus();
return <button disabled={pending}>Save</button>;
}
function Form() {
return <form action={save}><SubmitButton /></form>;
}useFormStatus reads the status of the parent <form>, so it must be called in a component rendered inside it.
<form>, so pending is always false.useFormStatus is imported from 'react-dom', not 'react'.<form>, not in the component that renders the form.action prop, since onSubmit handlers do not update the status.Yes. Besides pending it returns data (the FormData), method and action of the parent form while it submits.
useActionState holds the result of an action. useFormStatus only tells a child component that its parent form is submitting.