Replies: 1 comment 8 replies
-
i think this is you after? |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I can see in the docs that the resolver should be cached on first render ("This function will be cached inside the custom hook, while context is a mutable object which can be changed on each re-render."). This means if I do this:
... and then "validationSchema" changes from undefined to a yup validator object will it change so validation start working?
The reason I'm asking is that I have a form that I use a jsonSchema to generate, and then I have some functions createYupSchemaFromJsonSchema(schema) and generateDefaultValueFromJsonSchema(schema). The schema is set depending on user interaction meaning that it's not there on the initial render. So... I ran into a problem with the defaultValues not being set and did some digging and found out that I had to use reset like this:
That fixed the defaultValue problem ... but what confuses me is that the validation works fine. Seems to me like changing the validationSchema (or actually setting it) changes the resolver. I mean... it works, but I don't understand why ... and I don't like things that work without understanding it, they tend to fail eventually :) Can anyone explain why this works?
Beta Was this translation helpful? Give feedback.
All reactions