import * as React from 'react' ; import ErrorBoundary from '../ErrorBoundary' ; const withErrorBoundary = < TOrigProps extends Record < string , unknown > > ( Component , onError , FallbackComponent ? ) => { const name = Component . displayName ? Component . displayName : 'Unnamed Component' ; const ErrorBoundaryWrapper = ( props ) => ( < ErrorBoundary onError = { onError } name = { name } FallbackComponent = { FallbackComponent } > < Component { ... props } / > < /ErrorBoundary>); ErrorBoundaryWrapper . displayName = `WithErrorBoundary(${ name })` ; return ErrorBoundaryWrapper ; } ; export default withErrorBoundary ;