import React from 'react'; import { logError } from '../utils/errorLogger'; 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) { const componentInfo = { component: errorInfo?.componentStack || null, props: this.props, }; logError(error, componentInfo); } handleRetry = () => { this.setState({ hasError: false, error: null }); }; handleReload = () => { window.location.reload(); }; renderDefaultFallback() { const { compact } = this.props; if (compact) { return (
Что-то пошло не так
Произошла непредвиденная ошибка. Попробуйте обновить страницу или вернуться позже.
{this.state.error && process.env.NODE_ENV === 'development' && (
{this.state.error.message}
)}