MCPcopy
hub / github.com/bvaughn/react-error-boundary / withErrorBoundary

Function withErrorBoundary

lib/utils/withErrorBoundary.ts:10–27  ·  view source on GitHub ↗
(Component: ComponentType<Props>, errorBoundaryProps: ErrorBoundaryProps)

Source from the content-addressed store, hash-verified

8import type { ErrorBoundaryProps } from "../types";
9
10export function withErrorBoundary<
11 Type extends ComponentClass<unknown>,
12 Props extends object,
13>(Component: ComponentType<Props>, errorBoundaryProps: ErrorBoundaryProps) {
14 const Wrapped = forwardRef<InstanceType<Type>, Props>((props, ref) =>
15 createElement(
16 ErrorBoundary,
17 errorBoundaryProps,
18 createElement(Component, { ...props, ref } as Props),
19 ),
20 );
21
22 // Format for display in DevTools
23 const name = Component.displayName || Component.name || "Unknown";
24 Wrapped.displayName = `withErrorBoundary(${name})`;
25
26 return Wrapped;
27}

Callers 3

renderFunction · 0.90

Calls

no outgoing calls

Tested by 1

renderFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…