Skip to content

Two nested 'FormProvider', where the child wants to access the parent instance #3675

Discussion options

You must be logged in to vote

    <>
      <FormProvider {...methods}>
        <form onSubmit={handleSubmit((data) => console.log(data))}>
          <label>Main Screen Input</label>
          <input name="test" ref={register({ required: true })} />
          <label>Main Screen Child Input</label>
          <Test />

          <button onClick={() => setIsOpen(true)}>Dialog Open</button>
          <input type="submit" />
        </form>
      </FormProvider>
      <Dialog open={isOpen} setIsOpen={setIsOpen} />
    </>

is this a possible solution? instead burry two useForm inside of each others?

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
3 replies
@bluebill1049
Comment options

@yamakeeeeeeeeen
Comment options

@bluebill1049
Comment options

Answer selected by bluebill1049
Comment options

You must be logged in to vote
8 replies
@david-morris
Comment options

@belaszalontai
Comment options

@caweidmann
Comment options

@sKopheK
Comment options

@yhc-readonly
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants