Zum Hauptinhalt springen

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​

Default in Storybook öffnen

Custom Title​

Custom Title in Storybook öffnen

No Error​

No Error in Storybook öffnen

Custom Fallback​

Custom Fallback in Storybook öffnen

See Also​

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