State Management · Senior · Question 45 of 75
How should validation errors from a React Router action reach the form?
- ✓Correct answer: Return them as data from the action and read them with
useActionData/fetcher.data - 2Throw them so the route's error boundary shows the form errors
- 3Store them in a global store
Explanation
Expected errors (an invalid email) are data: return { errors } (often with a 400 status). Thrown errors go to the ErrorBoundary and replace the route UI - that's for unexpected failures.