You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We love this project, and even built a full idiomatic wrapper over this in clojure(script).
My question: *How can I read the "mode" args given to useForm, in a distant child component via the form's context or other hooks? These args don't appear anywhere in useFormContext and useFormState docs.
My use case:
I'm trying to build accessible, standardized, reusable components so the fullstack/backend devs on my team can use standard styling and behavior easily. Eg like a SubmitButton component. These are designed to be used anywhere that has a form context (via FormProvider), so they cannot see any initial args given to useForm, like mode etc.
For example, I want my standardized SubmitButton to be disabled when isSubmitted && !isValid is true, but only when {mode: "onSubmit", reValidateMode: "onChange"} is passed to useForm. But when both mode and reValidateMode are "onChange", then I want to disable my button simply when !isValid is true.
Is there any way to read those values outside of the original useForm-using component?
I am currently just reading control._options directly, tho I know that updates might break that. And I know I could possibly create my own context etc, but was hoping to keep all form information within the single r-h-c context.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
We love this project, and even built a full idiomatic wrapper over this in clojure(script).
My question: *How can I read the "mode" args given to
useForm
, in a distant child component via the form's context or other hooks? These args don't appear anywhere inuseFormContext
anduseFormState
docs.My use case:
I'm trying to build accessible, standardized, reusable components so the fullstack/backend devs on my team can use standard styling and behavior easily. Eg like a
SubmitButton
component. These are designed to be used anywhere that has a form context (via FormProvider), so they cannot see any initial args given touseForm
, likemode
etc.For example, I want my standardized
SubmitButton
to be disabled whenisSubmitted && !isValid
is true, but only when{mode: "onSubmit", reValidateMode: "onChange"}
is passed touseForm
. But when bothmode
andreValidateMode
are"onChange"
, then I want to disable my button simply when!isValid
is true.Is there any way to read those values outside of the original
useForm
-using component?I am currently just reading
control._options
directly, tho I know that updates might break that. And I know I could possibly create my own context etc, but was hoping to keep all form information within the single r-h-c context.Thanks again for this incredible project.
Beta Was this translation helpful? Give feedback.
All reactions