YuhuanStudioYunUIDocs
Patterns

Error Boundary

React error boundary with a friendly retry fallback.

A React error boundary that catches render errors in its subtree and shows a friendly fallback — an icon, message, and a "Try again" button that resets the boundary. Override the copy with labels, supply a fully custom fallback, or hook into onError for logging.

Import

tsx
1import { ErrorBoundary } from "@yuhuanowo/yunui/patterns";

Basic

Wrap any subtree. While no error is thrown, it renders its children transparently.

ErrorBoundary

This content is protected by an error boundary.

Custom labels

Pass labels to localize the fallback's title, message, and retry button.

tsx
1<ErrorBoundary
2 labels={{ title: "Something broke", message: "Please try again.", retry: "Reload" }}
3 onError={(error, info) => logToService(error, info)}
4>
5 <Dashboard />
6</ErrorBoundary>

Props

PropTypeDefaultDescription
fallbackReactNode
labelsErrorBoundaryLabelsOverride the default English copy.
onError((error: Error, info: ErrorInfo) => void)Notified when an error is caught (e.g. for logging).

On this page