Yup resolver is not working #11342
-
I'm using the React Hook Form. I used custom components for form and form input. I also configured the Yup resolver for validation errors. But it's not working. However, the resolver is preventing the form from being submitted but it shows nothing in the errors object destructed from the
Additionally, the
What's the issue with my code? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
Finally got it to work: useForm({
// ...
resolver: yupResolver(schema),
})
// ...
await trigger()
// Important Note: given time/ticks to make formState.errors working with yup schema
await sleep(0);
formState.errors // is ok with yup schema
// with util
export const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); |
Beta Was this translation helpful? Give feedback.
Finally got it to work: