import type { ComponentType, ReactNode, ComponentProps } from 'react'; import { ErrorBoundary } from 'react-error-boundary'; function withErrorBoundary(Component: ComponentType, fallback: ReactNode = null) { const WrappedComponent = function (props: ComponentProps) { return ( {fallback}}> ); }; WrappedComponent.displayName = `withErrorBoundary(${Component.displayName ?? Component.name ?? 'Component'})`; return WrappedComponent; } export { withErrorBoundary };