Question
I'm using TypeScript with React Hook Form. What's the correct type definition for `setError`?
Asked by: USER6315
93 Viewed
93 Answers
Responsive Ad After Question
Answer (93)
In TypeScript, the `setError` function is typically typed as `(name: string, error: FieldError | undefined) => void`. `FieldError` is an interface defined by React Hook Form that specifies the `type` and `message` properties for an error. Ensure you're importing `FieldError` from 'react-hook-form' to get proper type checking.