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
Hi there. Does someone have a good abstraction hook to deal with forms? I was looking for some abstraction with zod, rhf and maybe error messages.
The best one I came across was this one, and I was looking for improvements or suggestions:
// component.tsxconstchangeAddressFormSchema=z.object({// schema...})constchangeAddressFormErrorMessages: {[key: string]: string}={STREET_IS_INVALID: "Error message here",}consthandleChangeAddress=async(formData: z.infer<typeofchangeAddressFormSchema>)=>{// action function...// in my case, this also displays a toast with success or error when the modal is closed // (different toast from the one used in useFormValidation, which only displays the error and when it is open)}const{ inputs, onSubmit, isSubmitting }=useFormValidation<z.infer<typeofchangeAddressFormSchema>>(changeAddressFormSchema,changeAddressFormErrorMessages,handleChangeAddress)<formonSubmit={onSubmit}><Input{...inputs("street")}label="Street"defaultValue={address?.street}placeholder="Street One"/></form>
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there. Does someone have a good abstraction hook to deal with forms? I was looking for some abstraction with zod, rhf and maybe error messages.
The best one I came across was this one, and I was looking for improvements or suggestions:
Beta Was this translation helpful? Give feedback.
All reactions