Error Boundaries & Failure Isolation

An error boundary catches rendering errors in its descendant tree and displays fallback UI instead of allowing the entire application subtree to fail.

Error boundaries do not catch every kind of error. Event handler errors, asynchronous callbacks, server errors, and errors thrown outside the boundary's supported rendering lifecycle require other handling strategies.

Place boundaries around meaningful failure domains: a dashboard widget, route, editor, or application shell. A user should ideally be able to continue using unaffected parts of the application.

Failure isolation

Treat errors as part of the UI design. Decide what can fail independently and give users a recovery path.

Key Takeaways
  • Error boundaries isolate rendering failures.
  • Different error sources require different handling mechanisms.
  • Provide recovery rather than only displaying a stack trace.