You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arguments of onSubmit fn argument of useForm are not documented. For people who don't use React actions (use client-only forms) onSubmit becomes a crucial piece.
From my quick experiments:
useForm({
...
onSubmit(event: ...,context: Context){
...
}})typeContext={action: stringencType: string// enumformData: FormDatamethod: string// enumsubmission?: {//status: 'success'payload: {…},// -- I assume it's the string-only original form datavalue: {…}// -- looks like parsed zod result of `Schema` type. Requires status == "success" condition 🤔reply: ƒ// -- not sure what it is}|{status: "error", ...}}
^ A pretty complex object, we shouldn't guess it's structure. Here's what I ended-up with:
onSubmit(event,{submission}){event.preventDefault()if(submission?.status=="success"){// unfortunately, here we have to add a check which will never fail if `onValidate` is providedconsole.log("value:",submission.value)}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Arguments of
onSubmit
fn argument ofuseForm
are not documented. For people who don't use React actions (use client-only forms)onSubmit
becomes a crucial piece.From my quick experiments:
^ A pretty complex object, we shouldn't guess it's structure. Here's what I ended-up with:
Beta Was this translation helpful? Give feedback.
All reactions