issue: the formState.errors
default type is incorrect
#11841
Labels
status: under investigation
aware of this issue and pending for investigation
formState.errors
default type is incorrect
#11841
Version Number
7.51.3 (latest)
Codesandbox/Expo snack
CodeSandbox link
Steps to reproduce
Check the source code of the CodeSandbox.
But summarized: When you use
useFormContext()
without passing it a generic, then the RHF types don't know what fields the form has.When you extract
formState.errors
from the context, and try to access the errors for a field that is an array, you won't be able to index the error. So doing this gives you a type error:So
e
can be an array, as you can see in the log, but the default types don't think it can be.Expected behaviour
I expect the default error types to expect the error to be an array (with inside it an object with a
message
property), as well as just an object with amessage
property.What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: