Custom errors Typing - TypeScript #11257
Unanswered
RemyMachado
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using a
FormProvider
and I wanted to handle custom errors (coming from API response) in the same place as the inputs errors.In my use case, the custom error is an internal server error 5xx.
I extended the error type like this:
In order to do the following anywhere:
But I'm struggling to make it type safe, I don't know where to use this
CustomFormErrorsType
type. The documentation example doesn't look typesafe : https://react-hook-form.com/docs/useform/seterrorAny help would be appreciated.
PS: I found this existing discussion: https://github.com/orgs/react-hook-form/discussions/9691, but it's not resolved yet.
Beta Was this translation helpful? Give feedback.
All reactions