react-hook-form: issue: isValid not consistent with errors while validation

Version Number

7.39.6

Codesandbox/Expo snack

https://codesandbox.io/s/empty-morning-j0yr37?file=/src/App.tsx

Steps to reproduce

  1. input ‘aaaa’, you can see there is an error message but the button is still enabled due to isValid is true

Expected behaviour

  1. If there is an error message, the button should be disabled

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 22 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@bluebill1049 This works for me, thanks for you work!

@blingblingredstar let me know if you want to verify the fix before I close this issue with PR.

Hey, I ran into the same issue in my app. I’m using an async function for the validation. The isValid field is true but the errors field has errors. Screen Shot 2022-11-28 at 11.51.01.png

This is a regression introduced in the last patch, i am looking for a better solution before roll it back.

I was about to redo all of my forms using Context Provider. Thanks, guys 💙

sorry about the context api regression…

This issue won’t give an immediate fix, as promise-based race conditions will need to be planned and considered carefully.

Something changed in 7.39.6 the errors get from formState.errors always is empty

const {formState} = useFormContext()