One FormProvider, many forms #7206
-
Hello everyone I have a StepWizard with some steps in a modal. In every step I have a form. I would like get context of forms in Modal for disable or enable next button. So this is my code: <Modal {...modalProps}>
<FormProvider {...methods}>
<StepWizard>
<FirstForm />
<SecondForm />
<ThirdForm />
{...}
</<StepWizard>
</FormProvider>
</Modal> So, FirstForm, SecondForm, ThirdForm have every one.In the modal I get the context: // modal.js
const { control } = useFormContext();
const { isDirty, isSubmitting } = useFormState({ control });
const disabledNextButton = !isDirty || isSubmitting;
return (
<Button
disabled={disabledNextButton}
>
) This is correct? Or, Should I have one in every form. Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
bluebill1049
Dec 2, 2021
Replies: 1 comment
-
Should be per form per context. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sebaveg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be per form per context.