import React from 'react'; import { Empty, Button } from '@douyinfe/semi-ui'; import { IllustrationFailure, IllustrationFailureDark, } from '@douyinfe/semi-illustrations'; import { withTranslation } from 'react-i18next'; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError() { return { hasError: true }; } componentDidCatch(error, errorInfo) { console.error('[ErrorBoundary]', error, errorInfo); } render() { if (this.state.hasError) { const { t } = this.props; return (
} darkModeImage={ } description={t('页面渲染出错,请刷新页面重试')} />
); } return this.props.children; } } export default withTranslation()(ErrorBoundary);