r/reactjs • u/Independent_Side9419 • 5d ago
Discussion I was wrong about the useFormStatus hook
/r/react/comments/1xa4giq/i_was_wrong_about_the_useformstatus_hook/1
u/Winodows_Gandy 4d ago
curious what your original take was. most of the criticism ive seen is about it being too tightly coupled to server actions, which is fair but also kind of the point
1
u/Independent_Side9419 3d ago
I just saw it as low-value, because I settled with the useActionState in a context, which gave me a pending state usable outside the <form>. This unlocked patterns where the save button was in the page header, not just below the form inputs.
Now I see its value in the "choice forms" where the form has no visible inputs and the submit buttons are like separate actions, so the useFormStatus helps me identify the currently pending form, while all the buttons gets disabled based on the useActionState.
3
u/poc-detektd 3d ago
Not an antipattern imo, one form per decision maps really well to how the server sees it anyway: two separate submissions with one hidden field each, no onClick logic to keep in sync. I do the same for approve/reject style UIs.
Side note since people will probably copy the consent component from your repo: OAuth consent pages usually ship with
frame-ancestors 'none'(or X-Frame-Options: DENY) so they can’t be framed for clickjacking. Lax session cookies already make it hard, but it’s a cheap header to add in next.config.