-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue: isValid reports incorrect value #8601
Comments
Continuation of #8497 |
Thanks for the detailed issue report. |
Thanks for being so responsive and maintaining this library! <3 |
you are missing the mode attribute :) https://react-hook-form.com/api/useform/formstate
|
That behavior is surprising to me. Has the potential to confuse developers (like me!) who miss the fine print. Erroneously being If this is intended, we can close the issue. Is there any way to have |
If you subscribe to Hope the above makes a bit more sense. |
My reasoning for expecting
I figured after submit, My use case is that I do not want to show any errors until submit is clicked. If the form is invalid, I then want to disable submit button until all fields are valid. It's additionally inconsistent behavior with |
|
If it should always represent entire-form validity, then it is not correct after the submit button is clicked, even though Hopefully my tone doesn't sound argumentative. Just trying to share my viewpoint! Thanks again for discussing. |
No, you are not. :) Yes, but if you are not subscribed to |
@bluebill1049 I totally understand the purpose of of Take the example of a form using the There is no way for us to let a user know that they have fixed all validation errors simply using |
It is still my opinion that this is an area that could use improvement. There are workarounds, but it is not intuitive, and leads to a "pit of failure" for naïve developers. |
I also fell into this pitfall. My form uses |
I just spent 4 hours debugging why isValid kept returning false until I found this discussion. If mode is required for validation to work, shouldn't mode default to 'onSubmit'? Also, none of the basic usage examples in the docs actually passed 'mode'. My form uses third party UI components and I wrap those in higher order components, so I spent a lot of time trying to figure out if my props and refs were not being passed correctly. Setting mode in useForm fixed the issue. |
Version Number
7.32.1
Codesandbox/Expo snack
https://codesandbox.io/s/react-hook-form-isvalid-falg-issue-forked-s24jmj?file=/src/App.tsx
Steps to reproduce
Demo:
Expected behaviour
isValid: false
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: