MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / withErrorBoundary

Function withErrorBoundary

packages/react/src/errorboundary.tsx:221–239  ·  view source on GitHub ↗
(
  WrappedComponent: React.ComponentType<P>,
  errorBoundaryOptions: ErrorBoundaryProps,
)

Source from the content-addressed store, hash-verified

219
220// eslint-disable-next-line @typescript-eslint/no-explicit-any
221function withErrorBoundary<P extends Record<string, any>>(
222 WrappedComponent: React.ComponentType<P>,
223 errorBoundaryOptions: ErrorBoundaryProps,
224): React.FC<P> {
225 const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
226
227 const Wrapped = React.memo((props: P) => (
228 <ErrorBoundary {...errorBoundaryOptions}>
229 <WrappedComponent {...props} />
230 </ErrorBoundary>
231 )) as unknown as React.FC<P>;
232
233 Wrapped.displayName = `errorBoundary(${componentDisplayName})`;
234
235 // Copy over static methods from Wrapped component to Profiler HOC
236 // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
237 hoistNonReactStatics(Wrapped, WrappedComponent);
238 return Wrapped;
239}
240
241export { ErrorBoundary, withErrorBoundary };

Callers 2

Calls 1

hoistNonReactStaticsFunction · 0.90

Tested by

no test coverage detected