question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`useFormContext` should be available through children

See original GitHub issue

Since we are using react-hook-form. It would be nice to have access to stuff like isSubmitting from the form children without having to pass it down the three.

Right now, the form is controlling the label of the button to indicate the form is submiting but if you are working with UI libs like Chakra, you might want to use somethnig like <Button isLoading />

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
danielweinmanncommented, Dec 7, 2022

It took me some time, but I finally understood this issue 😅

If we always render a FormProvider inside our forms, it will enable the users to useFormContext anywhere inside any form. The solution is simple and looks harmless. I’ll reopen the issue until we implement it.

0reactions
danielweinmanncommented, Dec 12, 2022

Released on v1.3.0. Thanks for the PR, @bvangraafeiland 💪🏼 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

useFormContext - Simple React forms validation
Performant, flexible and extensible forms with easy-to-use validation.
Read more >
React Hook Form with Children in React Native - Stack Overflow
In your child component, define useFormContext() and de-structure your props; Get access to the field methods like onChange, onBlur, value by ...
Read more >
useFormContext returns null · Discussion #3894 · react-hook ...
Hi. i have some internal library where i created few components based on react-hook-form@5.7.2. everything was ok when i build library in ...
Read more >
Advanced Usage - Simple React forms validation
React Hook Form will validate your input data against the schema and return with either errors or a valid result. Step 1: Install...
Read more >
Using React Hook Form in component tests | by Adam J. Arling
Recently we transitioned our React Hook Form implementations and child components to use useFormContext. Since we're gravitating towards using our own ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found