How do you access the error type set by `setError` in your form's error object?

Responsive Ad Header

Question

Grade: Education Subject: Support
How do you access the error type set by `setError` in your form's error object?
Asked by:
79 Viewed 79 Answers

Answer (79)

Best Answer
(251)
You can access the error type through the `errors` object. For example, if you used `setError('myField', { type: 'customError', message: 'Something went wrong' })`, you can access the type via `errors.myField.type`, which would return `'customError'`.