Add Error Boundaries Around Unreliable UI Sections
Impact: MEDIUM (prevents full-app crashes from isolated component errors)
When a React component throws during rendering, React unmounts the entire component tree by default — the user sees a blank white screen. Error boundaries catch rendering errors in their child tree and display a fallback UI instead, keeping the rest of the application functional. Without them, a bug in a single widget, chart, or third-party embed takes down the entire page.
Incorrect (no error boundaries — one crash kills the whole app):
Error boundaries only catch errors during rendering, lifecycle methods, and constructors of child components. They do not catch errors in event handlers, async code, or the error boundary itself. Use try/catch for those.
Place error boundaries at strategic points: around each independent feature section, around third-party components, and at the app root as a last resort.
Always log caught errors to an error reporting service (Sentry, Datadog, etc.) in componentDidCatch or onError.
The react-error-boundary package provides useErrorBoundary() hook for triggering error boundaries from event handlers and async code.
Detection hints:
# Check if any error boundaries exist in the projectgrep -rn "componentDidCatch\|ErrorBoundary\|getDerivedStateFromError" src/ --include="*.tsx" --include="*.ts"