shadcn/ui page reloads on form submit
I have this code to submit on enter on the form but the page reloads on the submit:
4 Replies
Hi I'll help you but I have a few questions. Why are you using doubled form? I guess that the custom
Form
component already uses native form under the hood, so you probably don't need the second one. Secondly you should prevent default form behavior not input event.
@FleetAdmiralJakob 🗕 🗗 🗙Thats the recommendation: https://ui.shadcn.com/docs/components/form
React Hook Form
Building forms with React Hook Form and Zod.
If you preventDefault and then void the function call everything works great. I have it as this:
assuming this is react hook form the default should already be prevented no?
altho maybe the ref is somehow messing with that?