isValid is sometimes false despite no errors
See original GitHub issueDescribe the bug
I sometimes get isValid = false
despite having no visible errors and errors
object being an empty object ({}
)
To Reproduce I do not yet have a reproducable sandbox, but I already found a code piece that might be the problem. Please see additional context
Expected behavior
isValid should always reflect what the errors
object contains (e.g. isValid = Object.keys(errors).length === 0
)
Desktop (please complete the following information):
- OS: Windows 10 202001
- Browser: Microsoft Edge
- Version: 86.0.621.0 (Official build) canary (64-bit)
Additional context
The problematic line could be this code piece here: https://github.com/react-hook-form/react-hook-form/blob/03216edb0b29bae631fb752e6ec612111d82798d/src/useForm.ts#L341 which triggers revalidation but without providing an isValid
parameter as the 4th parameter. Hence this line https://github.com/react-hook-form/react-hook-form/blob/03216edb0b29bae631fb752e6ec612111d82798d/src/useForm.ts#L218 will resolve in !!isValid
which essentially means !!undefined === false
.
AFAIK the problem only appears on async filled inputs (inputs that get their value via an api request).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:55 (38 by maintainers)
Top GitHub Comments
https://react-hook-form.com/api/useform/formstate
Why is this closed when the issue still exists?