0
Challenge · 26Mutations & Auth
Forms: useActionState & useFormStatus
Mutationsused in ~90% of apps
Almost every form tutorial blurs these two hooks into one fuzzy idea: 'they handle the loading spinner.' They do not do the same job, they do not live in the same component, and interviewers love watching a candidate put useFormStatus in the wrong place and stare at a pending value that never flips.
Core idea. `useActionState(action, initial)` wires a Server Action to a `<form>` and gives you back the returned state (your errors / result) plus a pending flag — it lives in the component that owns the form. `useFormStatus()` reads the status of the nearest *parent* `<form>`, so it only works inside a child you render *inside* that form (typically the submit button).
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
Same form, two engines — watch the render counters
Type a few characters into each form, then blur or submit. The counters tell the story.
0
useState renders
0
RHF renders
The register-ed inputs are uncontrolled — React Hook Form holds values in the DOM via a ref and only re-renders when validation state actually changes. The useState form re-renders on every single keystroke.
↑ play a little first, then dig in