ErrorBoundary
Generic error boundary that prevents a crashing subtree from taking down the
rest of the page. Reporting is delegated to onError (no hardcoded logging),
and recovery is available through reset on a render-prop fallback.
Usage
import { ErrorBoundary, ErrorBoundaryFallbackProps, ErrorBoundaryProps } from "@desk/ui/components/error-boundary";Best practices
ErrorBoundarycatches render crashes in a subtree — pair it with anErrorStateinfallbackto show the failure; it renders nothing by default.It logs nothing itself — wire telemetry through
onError, and offer recovery via the render-propfallback'sresetcallback.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | ||
| fallback | ReactNode | ((props: ErrorBoundaryFallbackProps) => ReactNode) | Rendered when the subtree throws. Either a static node or a render prop
receiving the captured error and a | |
| onError | (error: Error, info: ErrorInfo) => void | Called when the subtree throws. Receives the error and React's component stack. Use this to report to logging/telemetry — the boundary itself does not log. | |
| onReset | () => void | Called when the boundary is reset, before the subtree re-renders. |
Also exports
- interface
ErrorBoundaryFallbackProps - interface
ErrorBoundaryProps