import React from 'react'; import { Icon } from './icons'; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error) { return { hasError: true, error }; } componentDidCatch(error, errorInfo) { console.error('ErrorBoundary caught error:', error, errorInfo); } handleReload = () => { window.location.reload(); }; handleGoHome = () => { window.location.href = '/'; }; render() { if (this.state.hasError) { return (
抱歉,应用遇到了问题。
{process.env.NODE_ENV === 'development' && (
{this.state.error?.toString()}
)}