Course contentsShow
← React
Lesson 1292 of 2,39633. Error BoundariesFree lesson

What Error Boundaries DON'T Catch: Their Own Errors

An error boundary cannot catch errors thrown within itself; you need a parent error boundary for that.

What Error Boundaries DON'T Catch: Their Own Errors

You'll learn why error boundaries can't catch errors that occur within their own code.

The Self-Rescue Problem

Imagine a lifeguard who falls into the water—they can't save themselves. Error boundaries face the same limitation: an error boundary cannot catch errors thrown from its own component logic. If the error boundary itself breaks, it can't handle its own failure.

This makes sense when you think about React's error handling flow. When a component throws an error, React looks up the component tree for the nearest error boundary. But if the error boundary is the source of the error, there's nowhere to look—it can't be its own parent.

Where This Happens

Errors in an error boundary's own code won't be caught by itself:

  • Errors in the error boundary's render() method
  • Errors in componentDidCatch() itself
  • Errors in getDerivedStateFromError()
  • Errors in the error boundary's own event handlers
  • Errors in the error boundary's own hooks

The Solution: Parent Error Boundaries

To catch errors from an error boundary, you need another error boundary wrapping it. Think of it as layers of protection: if the inner boundary fails, the outer one catches it.

This is why production apps often have:

  • A root-level error boundary for catastrophic failures
  • Feature-level error boundaries for specific sections
  • Component-level error boundaries for isolated widgets

Each layer protects the one below it.

Key Takeaway: An error boundary cannot catch its own errors—you need a parent error boundary higher in the tree to handle failures within an error boundary component itself.