mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 09:23:33 -05:00
9daa8f5d98
[web] rename all the JSX files to .jsx/.tsx GitOrigin-RevId: 82056ae47e017523722cf258dcc83c8a925a28f7
37 lines
943 B
JavaScript
37 lines
943 B
JavaScript
import { captureException } from './error-reporter'
|
|
import { ErrorBoundary } from 'react-error-boundary'
|
|
|
|
function errorHandler(error, componentStack) {
|
|
captureException(error, {
|
|
extra: {
|
|
componentStack,
|
|
},
|
|
tags: {
|
|
handler: 'react-error-boundary',
|
|
},
|
|
})
|
|
}
|
|
|
|
function DefaultFallbackComponent() {
|
|
return <></>
|
|
}
|
|
|
|
function withErrorBoundary(WrappedComponent, FallbackComponent) {
|
|
function ErrorBoundaryWrapper(props) {
|
|
return (
|
|
<ErrorBoundary
|
|
FallbackComponent={FallbackComponent || DefaultFallbackComponent}
|
|
onError={errorHandler}
|
|
>
|
|
<WrappedComponent {...props} />
|
|
</ErrorBoundary>
|
|
)
|
|
}
|
|
ErrorBoundaryWrapper.propTypes = WrappedComponent.propTypes
|
|
ErrorBoundaryWrapper.displayName = `WithErrorBoundaryWrapper${
|
|
WrappedComponent.displayName || WrappedComponent.name || 'Component'
|
|
}`
|
|
return ErrorBoundaryWrapper
|
|
}
|
|
|
|
export default withErrorBoundary
|