overleaf/services/web/frontend/js/shared/components/error-boundary-fallback.tsx
Alf Eaton d905863002 Merge pull request #8747 from overleaf/ae-error-boundary-fallback
Create a generic ErrorBoundaryFallback component

GitOrigin-RevId: 0c9200ddef2be3b90030a32eb8c36a59047cf2b4
2022-08-10 08:03:51 +00:00

21 lines
527 B
TypeScript

import { FC, ReactNode } from 'react'
import { Alert } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
export const ErrorBoundaryFallback: FC<{ modal?: ReactNode }> = ({
children,
modal,
}) => {
return (
<div className="error-boundary-alert">
<Alert bsStyle="danger">{children || <DefaultContent />}</Alert>
{modal}
</div>
)
}
const DefaultContent = () => {
const { t } = useTranslation()
return <p>{`${t('generic_something_went_wrong')}. ${t('please_refresh')}`}</p>
}