Skip to main content

ErrorBoundary

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

Catches render errors thrown by its children and shows an error-variant Callout in their place, so one broken widget doesn't take the whole frame down with it.

Import​

import { ErrorBoundary } from "~lib/feedback/error-boundary";

Props​

NameTypeRequiredDefaultDescription
childrenReactNodeYesN/AContent to render and monitor for errors
titlestringNo"Something went wrong"Heading shown by the default fallback Callout
fallback(props: FallbackProps) => ReactNodeNoN/ARenders in place of the default Callout when an error is caught
onError(error: unknown, info: ErrorInfo) => voidNoN/ACalled when a child throws
onReset() => voidNoN/ACalled when the boundary resets, either via resetKeys or a fallback's resetErrorBoundary()
resetKeysunknown[]NoN/AWhen any value changes, the boundary clears the error and re-renders children

Examples​

Default​

Open Default in Storybook

Custom Title​

Open Custom Title in Storybook

No Error​

Open No Error in Storybook

Custom Fallback​

Open Custom Fallback in Storybook

See Also​

  • Callout - Message boxes, including the error variant used by the default fallback
  • EmptyState - No-data placeholder