October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Why React Error Boundaries Don’t Catch Event Handler and Async Errors

React Error Boundaries handle descendant render failures, not every callback beneath them. Here’s where event, timer, and Promise errors belong—and the important exceptions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

React Error Boundaries catch errors that occur while React renders a descendant component. They do not generally catch exceptions from event handlers, timers, or other asynchronous callbacks, because those failures happen outside the render work the boundary handles. Catch interaction and request failures where they occur; use a boundary for render failures. React documents narrow exceptions, including rejected Promises read with use and errors thrown inside the startTransition function returned by useTransition.

What an Error Boundary catches

An Error Boundary protects a region of the rendered component tree. When a descendant throws while React is rendering it, the boundary can render fallback UI in place of the failed region. A class boundary uses static getDerivedStateFromError to update state for that fallback; componentDidCatch can report the error and component stack to an error-reporting service. React recommends choosing boundaries around UI regions that should fail together, rather than adding one around every component. See React’s Component reference.

class ErrorBoundary extends React.Component {
  state = { hasError: false };

  static getDerivedStateFromError(error) {
    return { hasError: true };
  }

  componentDidCatch(error, info) {
    reportError(error, info.componentStack);
  }

  render() {
    if (this.state.hasError) return this.props.fallback;
    return this.props.children;
  }
}

React’s reference describes this class-based pattern. It does not currently provide a direct function-component equivalent for componentDidCatch; use a reusable boundary component or a package that implements one if your application is otherwise built from function components.

Where different failures are handled

The key distinction is where the failure occurs, not merely whether the code belongs to a component beneath a boundary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Failure location or mechanism What handles it Practical response
Descendant render Error Boundary Show fallback UI; optionally log through componentDidCatch.
Event handler The handler’s own logic Catch expected exceptions or Promise rejections and update UI state.
Timer or animation callback The callback’s own logic Catch at the callback or route the failure into explicit application state.
Promise read with use Suspense while pending; Error Boundary if rejected Reuse a cached Promise instance and use a boundary reset or retry pattern when needed.
Data fetched in an Effect or event handler Not detected by Suspense Handle loading and failure through the fetch flow and application state.
Error inside useTransition’s startTransition callback Error Boundary, as a documented exception Treat this as a specific exception, not a general rule for async callbacks.

Why event-handler errors bypass the boundary

An event handler runs in response to an interaction, not as part of rendering the descendant tree. Declaring the handler in a component beneath a boundary does not bring its later exceptions within the boundary’s render-error handling. Catch expected failures in the handler and represent the result in application state or local feedback.

async function handleSave() {
  try {
    await saveRecord();
    setStatus('saved');
  } catch (error) {
    setStatus('failed');
  }
}

This is also the right place to handle a rejected request Promise initiated by the interaction. Keep the boundary for failures that occur as React renders UI.

Why timers and ordinary async callbacks bypass it

A setTimeout or requestAnimationFrame callback runs later, outside the render phase observed by the boundary. Handle the failure where that callback or its Promise runs. If the desired outcome is boundary fallback UI, deliberately translate the failure into application state that causes a render to fail within the protected region; do not assume the original callback exception will be forwarded automatically.

Suspense does not detect data fetched in an Effect or event handler. Those flows need their own loading and failure handling, rather than relying on a Suspense fallback or Error Boundary to catch a fetch rejection. See React’s Suspense reference.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Promise-with-use exception

React’s use API integrates a Promise read into rendering. While that Promise is pending, the component suspends and the nearest Suspense boundary supplies the loading fallback. If the Promise rejects, the nearest Error Boundary handles the rejection. The Promise passed to use must be cached so the same instance is reused across rerenders. React describes retrying with a replacement Promise and resetting the boundary, including through reset keys or a transition, in its use reference.

Do not wrap use in try/catch. React uses suspension to interrupt rendering; catching that internal control flow can lead to incorrect behavior. Use Suspense for the pending state and an Error Boundary for rejection.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why try/catch around JSX does not catch a child render error

This parent does not catch an exception that occurs later while React renders Child:

function Parent() {
  try {
    return <Child />;
  } catch (error) {
    return <p>Could not render child</p>;
  }
}

The JSX expression creates an element; it does not synchronously render the child inside the surrounding JavaScript try block. React’s error-boundaries lint documentation explains that render errors bubble through the component tree and should be handled with an Error Boundary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The documented startTransition exception

React lists event handlers and asynchronous code such as timer and animation callbacks among the contexts Error Boundaries do not catch, but documents an exception: errors thrown inside the function passed to startTransition from useTransition are caught. This exception is specific to that API; it does not make a boundary a general-purpose handler for every event or async failure. See the Component reference.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.