mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 11:24:13 -05:00
d905863002
Create a generic ErrorBoundaryFallback component GitOrigin-RevId: 0c9200ddef2be3b90030a32eb8c36a59047cf2b4
21 lines
527 B
TypeScript
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>
|
|
}
|