Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

How to Report React Error Boundary Failures to a Backend

A React Error Boundary can render fallback UI and report caught errors separately. Learn what to send, how to make production component stacks readable, and which failures need other handling.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use static getDerivedStateFromError(error) to switch the interface to fallback UI, and componentDidCatch(error, info) to report the failure. The second method receives info.componentStack, which identifies the failing component and its ancestors. Send the error and stack to your backend or monitoring service without making the reporting request part of the fallback-rendering path.

Use the boundary’s reporting lifecycle method

React separates the boundary’s UI response from its side effects: getDerivedStateFromError updates state so the boundary can render a fallback, while componentDidCatch is where React documents logging to an error-reporting service. The React Component reference describes info.componentStack as the trace of the component tree where the error occurred.

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

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

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

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

This is an illustrative pattern; adapt the reporting function and payload to your application. Keep the state update synchronous and focused on fallback rendering. Treat reporting as a separate side effect, so a failed request does not block the fallback from appearing.

Build a useful, safe report payload

At minimum, include the thrown value and component stack. If your application already tracks deployment context, you may also include fields such as release and environment to help correlate a report with a build. There is no universally safe payload or retention policy established here: choose fields and handling rules that fit your backend and data practices.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Normalize unknown thrown values. JavaScript permits throwing values such as strings or null, not just Error objects. Avoid assuming error.message exists; convert values into a serializable representation before sending them.
  • Preserve the component stack. Forward info.componentStack as a separate field so it is not confused with a JavaScript stack trace.
  • Handle transport failures independently. A network outage or rejected reporting request should not replace or prevent the boundary’s fallback UI.

Make production component stacks readable

React notes that component names are minified in production. Source maps can decode the component stack in the same way they decode ordinary JavaScript error stacks. Make the relevant maps available to your backend or monitoring service’s symbolication workflow. The right upload and access arrangement depends on your build and service setup; avoid exposing source maps publicly by accident.

Know what Error Boundaries do not catch

An Error Boundary is not a global exception handler. React’s reference excludes failures in event handlers, server-side rendering, the boundary itself, and most asynchronous callbacks. Those paths need their own error handling and reporting. React identifies errors thrown inside the transition function passed to startTransition from useTransition as an exception to the general asynchronous limitation. See the React documentation for the current behavior.

Choose where reports go

A custom endpoint gives your team direct control over ingestion and storage, while a hosted monitoring service may provide an existing workflow for grouping and triaging issues. Consider who owns storage and access, the setup and maintenance involved, source-map handling, data controls, and alerting needs. Those are decision criteria, not a universal ranking of services.

Sentry is one example of a service with a React SDK. Its React guide describes its React integration, including an ErrorBoundary. For React 19, the guide also discusses onCaughtError and onUncaughtError; consult the current SDK documentation before using vendor-specific setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Function-component boundaries

React’s current reference says there is no direct componentDidCatch equivalent for function components and that Error Boundaries cannot currently be written as function components. Use a reusable class boundary or a package such as react-error-boundary when you want to consume boundary behavior from a function-component application.

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 *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.