Next.js Discord

Discord Forum

Help with React-Hook-Form and Zod

Unanswered
Snowshoe posted this in #help-forum
Open in Discord
SnowshoeOP
Is there someone is familiar with react hook form and zod? I realy need help I try everything in these 4 days, I use nextjs react hook form and zod it works fine in register and login but when I tried to make profile settings switch between user register (hasPassword) and user oauth (!hasPassword) react hook form submit doesn't work again without give me any errors
https://stackoverflow.com/questions/77518154/nextjs-react-hook-form-submit-not-working

if you can't help just vote to my question so it can shows for other developers and thansk for your help.

3 Replies

Yellow croaker
Probably error with The zod checks. If there is something wrong with The inputs you give, The zod doensnt allow you to submit The form.
U can check formstatus from RHF and see what The error says. Probably it complains about The invalid Field. So basically something like this
Console.log("Form", form.formstatus)
Brown bear
If the form isn't submitting then
- Remove all validations & check the form submits

Then add your validation in one by one until it stops submitting.
- When it stops submitting it means your logic is wrong

To debug console.log() out your errors object to identify where it's getting stuck

Hopefully you can solve it form there
If that doesn't work check out YUP as its a great alternative.
I'm new to Zod & have never had any issues with YUP.
I work full time with react hook form to build complex forms so I'm confident in YUP I just can't comment on Zod yet