import React, { ReactNode } from 'react' import { Text, MessageBox } from '@adminjs/design-system' import { useTranslation } from '../../hooks/index.js' type State = { error: any; } const ErrorMessage: React.FC = ({ error }) => { const { translateMessage } = useTranslation() return ( {error.toString()} {translateMessage('seeConsoleForMore')} ) } export class ErrorBoundary extends React.Component { constructor(props) { super(props) this.state = { error: null, } } componentDidCatch(error): void { this.setState({ error }) } render(): ReactNode { const { children } = this.props const { error } = this.state if (error !== null) { return () } return children || null } } export default ErrorBoundary