Without error boundaries, a single component crash takes down your entire app. Error boundaries prevent cascading failures.
What Are Error Boundaries?
Error boundaries are React components that catch JavaScript errors in their child component tree, log them, and display a fallback UI.
Usage Patterns
Page-Level Boundary
Feature-Level Boundary
Retry Pattern
What Error Boundaries DON'T Catch
- Event handlers (use try/catch inside handlers)
- Async code (promises, setTimeout)
- Server-side rendering
- Errors in the error boundary itself
Production Strategy
- App-level boundary: catches everything, shows "refresh" page
- Route-level boundary: isolates page crashes
- Feature-level boundary: isolates widget crashes
- Always log errors to a monitoring service (Sentry, DataDog)