Pending States (useFormStatus)
Context-aware pending states for nested form components.
Implicit Form Context
useFormStatus is a React Hook that gives you access to the status of a form submission.
Under the hood, native <form> elements in modern React act like Context Providers. Any child component inside the form can use this hook to instantly know if the form is currently submitting.
Reusable Submit Buttons
Historically, to disable a submit button while loading, you had to manage an isSubmitting state at the top of your component and pass it down as a prop: <SubmitButton disabled={isSubmitting} />.
With useFormStatus, the button manages itself. You can build a generic <SubmitButton> that automatically disables itself and shows a spinner whenever the parent form is pending.
The Pending Flag
Inside your child component, call the hook: const { pending } = useFormStatus();.
Use that boolean to conditionally style the button or disable it to prevent double-submissions: <button disabled={pending}>.
The Component Boundary
Submit the form below. Notice how the nested <SubmitButton> automatically detects the pending state and shows a spinner. The visual highlights the strict component boundary required to make the hook work.
Component Tree
Newsletter Signup
Code Wiring
<form action={myAction}>
// Must be a separate component!
<SubmitButton />
export function SubmitButton() {
return (
disabled={false}
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
useFormStatusreads pending state implicitly from a parent<form>.- It is primarily used for creating reusable
<SubmitButton>components. - You MUST call it from a child component inside the form.
- Calling it in the same component that renders the form will result in
pendingalways being false. - It only works with form submissions, not manual
onClickRPC mutations.
Done with this concept?
Mark it complete to track your progress. No login needed.