Question presented to candidate:
"React 19 lets you pass a function to a form's action prop. What does that actually buy you over an onSubmit handler?"
What a strong answer should cover:
- An Action is a function React runs on your behalf — passed to
<form action>, or tostartTransition— for which React manages the pending state, errors, and optimistic updates itself. - Passing a function to
actiongives you the FormData directly. NopreventDefault, no reading refs, no state per field. - React resets an uncontrolled form after the action resolves successfully, which is the behaviour you would otherwise write by hand.
- The submission runs inside a transition, so the UI stays responsive and
isPendingis something React knows rather than something you track. - The practical consequence: uncontrolled forms are the default again. Most fields need no
useStateat all. - The surrounding hooks complete the picture:
useActionStatefor the result and pending flag,useFormStatusfor a nested submit button,useOptimisticfor instant feedback. - With a framework, an action can be a Server Action and the form works before JavaScript loads — genuine progressive enhancement.
Clarifying questions expected:
- "Is this a plain client app or a framework with Server Actions?" — progressive enhancement only applies to the second.
- "Do any fields need per-keystroke validation?" — those still want controlled inputs.
Code / implementation expected: Optional. Contrasting a <form action={fn}> against the onSubmit version it replaces is the clearest form.