
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
react-error-boundary
Advanced tools
react-error-boundary: Reusable React error boundary component. Supports all React renderers (including React DOM and React Native).
# npm
npm install react-error-boundary
# pnpm
pnpm add react-error-boundary
# yarn
yarn add react-error-boundary
Frequently asked questions can be found here.
A reusable React error boundary component. Wrap this component around other React components to "catch" errors and render a fallback UI.
This package is built on top of React error boundaries, so it has all of the advantages and constraints of that API. This means that it can't catch errors during:
ℹ️ The component provides several ways to render a fallback: fallback, fallbackRender, and FallbackComponent.
Refer to the documentation to determine which is best for your application.
ℹ️ This is a client component. You can only pass props to it that are serializeable or use it in files that have a "use client"; directive.
None
| Name | Description |
|---|---|
| onError | Optional callback to enable e.g. logging error information to a server. @param error Error that was thrown @param info React "component stack" identifying where the error was thrown |
| onReset | Optional callback to to be notified when an error boundary is "reset" so React can retry the failed render. |
| resetKeys | When changed, these keys will reset a triggered error boundary. This can be useful when an error condition may be tied to some specific state (that can be uniquely identified by key). See the the documentation for examples of how to use this prop. |
| fallback | Static content to render in place of an error if one is thrown.
|
| FallbackComponent | React component responsible for returning a fallback UI based on a thrown value.
|
| fallbackRender | Render prop function responsible for returning a fallback UI based on a thrown value.
|
ErrorBoundary cannot be used as a JSX componentThis error can be caused by a version mismatch between react and @types/react. To fix this, ensure that both match exactly, e.g.:
If using NPM:
{
...
"overrides": {
"@types/react": "17.0.60"
},
...
}
If using Yarn:
{
...
"resolutions": {
"@types/react": "17.0.60"
},
...
}
This blog post shows more examples of how this package can be used, although it was written for the version 3 API.
This package provides an overlay for displaying runtime errors in React applications. It is similar to react-error-boundary in that it helps developers handle errors, but it focuses on providing a development-time overlay that displays errors rather than a production-ready error boundary component.
React-error-guard is a package that provides error boundary functionality with a focus on simplicity and minimalism. It is similar to react-error-boundary but may have fewer features and a simpler API, which could be beneficial for smaller projects or for developers who prefer a more straightforward approach.
FAQs
Simple reusable React error boundary component
The npm package react-error-boundary receives a total of 6,597,444 weekly downloads. As such, react-error-boundary popularity was classified as popular.
We found that react-error-boundary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.