NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #2947 most downloaded on npm
Simple reusable React error boundary component
Last release 14 days ago
20 Sep 2026
Release timing varies
gaps range from 1 weeks to 8 months
Most releases are documented
notes for 47 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
62 releases · first in 2017
Memoize context values to avoid unnecessary consumer renders when boundary state is unchanged.
Minor bug fixes:
withErrorBoundary types.undefined fallback but log an error in development.249 : Infer the wrapped component's ref type in withErrorBoundary
withErrorBoundaryOne column per quarter.
247 : Edge case: Handle null as thrown value
null as thrown value245 - Add @types/react as an optional peer dependency
245- Add @types/react as an optional peer dependency
README and doc comment updates
README and doc comment updates
Fixed a problem with project logo not displaying correctly in the README for the Firefox browser.
Export getErrorMessage helper method
Error -> unknown)getErrorMessage helper methodRemoved react-dom from peer dependencies list; it was accidentally added during a previous internal refactor
react-dom from peer dependencies list; it was accidentally added during a previous internal refactorUpdated README and generated TS docs
Updated README and generated TS docs
Updated README and generated docs
Updated README and generated docs
Module is ESM-only in order to better work with modern tooling.
Module is ESM-only in order to better work with modern tooling.
Update withErrorBoundary types to be compatible with the latest forwardRef types
withErrorBoundary types to be compatible with the latest forwardRef typesFor more background see PR #211
Remove engines field from Package JSON entirely
engines field from Package JSON entirelyRemove node constraint from engines
Relax fallback prop to support broader ReactNode type
Removed references to ESLint config kcd-scripts from package.json
Removed references to ESLint config kcd-scripts from package.json
* Support null fallback prop
Re-throw original error in the event that no fallback is specified
Target Safari 12+ compatibility (by removing optional chaining operator and default parameters)
145: Removed explicit ErrorBoundary.render return type to avoid TypeScript error:
ErrorBoundary.render return type to avoid TypeScript error:'ErrorBoundary' cannot be used as a JSX component.
144: Build release bundle with Preconstruct
*Replaced post-processing "use client" insertion step with a custom Parcel plug-in. This should hopefully produce better source maps.
*Replaced post-processing "use client" insertion step with a custom Parcel plug-in. This should hopefully produce better source maps.
Removed arrow function syntax to support older versions of Safari
Move "use client" directive to top of the bundled file.
Move "use client" directive to top of the bundled file.
Nothing published for this version
withErrorBoundary forwards refs
withErrorBoundary forwards refs"use client" directiveFix broken TypeScript definitions file (#133, https://github.com/parcel-bundler/parcel/issues/8908)
Fix broken TypeScript definitions file (#133, https://github.com/parcel-bundler/parcel/issues/8908)
Render ErrorBoundaryContext around fallback UI as well, so the useErrorBoundary hook could be used within the fallback component to reset the boundary
ErrorBoundaryContext around fallback UI as well, so the useErrorBoundary hook could be used within the fallback component to reset the boundary.For example:
import { useErrorBoundary } from "react-error-boundary";
function ErrorFallback({ error }) {
const { resetBoundary } = useErrorBoundary();
return (
<div role="alert">
<p>Something went wrong:</p>
<pre style={{ color: "red" }}>{error.message}</pre>
<button onClick={resetBoundary}>Try again</button>
</div>
);
}
See this demo: https://codesandbox.io/s/nostalgic-browser-e9lpmf
Replace useErrorHandler hook with useErrorBoundary; can be used to trigger an error boundary or dismiss one
useErrorHandler hook with useErrorBoundary; can be used to trigger an error boundary or dismiss oneonReset and onResetKeys props; pass "details" object explaining the cause of the resetuseErrorHandler hook change?The old hook had two design flaws, both related to the givenError parameter:
throw this value. This seemed unnecessary, because if a component already has a reference to an error during render, it can just throw the value itself.null or undefined values. (Although an edge case, JavaScript enables throwing any values/types.)If you were using the givenError functionality– you can now just throw the value directly instead.
// Before
function Greeting() {
const [name, setName] = React.useState('')
const {greeting, error} = useGreeting(name)
useErrorHandler(error)
// After
function Greeting() {
const [name, setName] = React.useState('')
const {greeting, error} = useGreeting(name)
if (error) {
throw error;
}
useErrorHandler hook?React only handles errors thrown during render or during component lifecycle methods (e.g. effects and did-mount/did-update). Errors thrown in event handlers, or after async code has run, will not be caught.
This hook can be used to pass those errors to the nearest error boundary:
import { useErrorBoundary } from "react-error-boundary";
function Example() {
const { showBoundary } = useErrorBoundary();
useEffect(() => {
fetchGreeting(name).then(
response => {
// Set data in state and re-render
},
error => {
// Show error boundary
showBoundary(error);
}
);
});
// Render ...
}
A fallback component can use this hook to request the nearest error boundary retry the render that original failed.
import { useErrorBoundary } from "react-error-boundary";
function ErrorFallback({ error }) {
const { resetBoundary } = useErrorBoundary();
return (
<div role="alert">
<p>Something went wrong:</p>
<pre style={{ color: "red" }}>{error.message}</pre>
<button onClick={resetBoundary}>Try again</button>
</div>
);
}
## 3.1.4 (2021-10-29) ### Bug Fixes * remove class instance property
useErrorHandler: use unknown instead of Error (#89) (ec81d61), closes #83
TS: help typescript to find his way for the ErrorBoundaryProps union
# 3.1.0 (2020-11-30) ### Features * TS: migrate to TypeScript
TS: TypeScript types for onError
TS: types for v3 breaking change
This removes the componentStack in the props given to the FallbackComponent and fallbackRender
switch to getDerivedStateFromError to avoid unnecessary rerender (#67) (463c62e), closes #66
FallbackComponent type (#62) (f75eda0), closes #61
useErrorHandler: add new hook for handling errors
TS: point package.json types property to including type declarations
compare length of resetKeys when checking if resetKeys has changed
## 2.2.1 (2020-05-01) ### Bug Fixes * Publish types
reset: add onReset and resetKeys props
fix TS typings as they are now exported as named exports
ensure the fallback props are the correct type
support resetting the error state (#46) (c38c84b), closes #26 #15 #34
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →