formState.isValid is not being updated when fields are registered in useEffect

See original GitHub issue

Describe the bug The formState.isValid property doesn’t update when using useEffect to register the fields.

To Reproduce The codesandbox below shows the behaviour. https://codesandbox.io/embed/bug-react-hook-form-formstateisvalid-wont-change-if-fields-are-registered-on-useeffect-segvo

Expected behavior The formState.isValid should change accordingly.

Additional context I just started using this library, so I hopefully I didn’t miss anything. But I am trying for more than 1 hour and I can’t find any issues with the example code. It suppose to work according to the docs.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
lnmunhozcommented, Sep 9, 2019

Oh all right! I didn’t see that. Makes sense.

In my opinion this validate should be true by default, being false is so counterintuitive. I will give it a try. Thank you!

0reactions
bluebill1049commented, Oct 18, 2019

However it need to be default to false. Because you aren’t certain it’s valid just yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - 'isValid' is always false
I am using custom register in react-hook-form , and I am unable to get formState.isValid to be true when I enter text into...
Read more >
Bug (react-hook-form): formState.isValid won't change if ...
Bug (react-hook-form): formState.isValid won't change if fields are registered on useEffect by lnmunhoz using react, react-dom, react-hook-form, ...
Read more >
useForm - FormState
Set to true if the form doesn't have any errors. setError has no effect on isValid formState, isValid will always derived via the...
Read more >
react hook form onblur not working
So when all of your fields become valid, it does not trigger validation. ... will have to register during useEffect , and update...
Read more >
API Documentation
Note: defaultValues doesn't auto populate with the manually registered input (eg: register({ name: 'test' }) ) because the manual register field does not...
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