[BUG]: React Hook Form doesn't submit when using drizzle-zod to create schemes to use in zodResolver

When using drizzle-zod to generate schemas from database schemas and using them in the useForm resolvers the onSubmit won't fire at all for some reason, So for example:
export const userSchema = createInsertSchema(users);
export const userSchema = createInsertSchema(users);
and then using it in the useForm
const { handleSubmit, register, control, getValues } = useForm<User>({
resolver: zodResolver(userSchema),
defaultValues: async () => {
const res = await fetch(`/api/users/`)
const user = (await res.json()) as User;
return user;
},
});

const onSubmit: SubmitHandler<User> = async (data) => {
console.log(data)

await fetch('/api/users/updateUser', {
method: "PUT",
body: body: JSON.stringify(data),
})
};
const { handleSubmit, register, control, getValues } = useForm<User>({
resolver: zodResolver(userSchema),
defaultValues: async () => {
const res = await fetch(`/api/users/`)
const user = (await res.json()) as User;
return user;
},
});

const onSubmit: SubmitHandler<User> = async (data) => {
console.log(data)

await fetch('/api/users/updateUser', {
method: "PUT",
body: body: JSON.stringify(data),
})
};
in this example when you click the Submit from the form it doesn't work at all. however if you build your own schema using zod it works fine. For reference this was working about a about a week ago. No errors show in the browser console or terminal, so i don't know what is up there I have posted issues on react-hook-form and drizzle-orm however I'm not sure which team is that the problem is coming from https://github.com/react-hook-form/resolvers/issues/642 https://github.com/drizzle-team/drizzle-orm/issues/1448 To Reproduce Steps to reproduce the behavior: 1. create a schema using zod 2. create a zod schema using drizzle-zod and createInsertSchema 3. import that schema into a useForm resolver 4. try submitting the form (should not work) Codesandbox link very simple application that doesn't seem to submit: https://codesandbox.io/p/sandbox/react-hook-form-zod-resolver-not-working-9c7qn9 Environment & setup Operating systems that is is occuring in: - Mac ventura 13.5.2, - Windows 10 - Windows 11 - Codesandbox Browsers: - Chrome Versions of packages: - react-hook-form: 7.47.0 - @hookform/resolvers: 3.3.2 - drizzle-orm: 0.28.6 - drizzle-zod: 0.5.1 - drizzle-kit: 0.19.13
GitHub
Form not submitting when using drizzle-zod to create schemes to use...
Describe the bug When using drizzle-zod to generate schemas from database schemas and using them in the useForm resolvers the onSubmit won't fire at all for some reason, So for example: export ...
GitHub
[BUG]: React Hook Form doesn't submit when using drizzle-zod to cre...
What version of drizzle-orm are you using? 0.28.6 What version of drizzle-kit are you using? 0.19.13 Describe the Bug When using drizzle-zod to generate schemas from database schemas and using them...
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server