import { Component, type ErrorInfo, type ReactNode } from "react"; interface State { error: Error | null } // неожиданная ошибка отрисовки страницы: сообщение и перезагрузка вместо пустого экрана; панель разделов остаётся export class ErrorBoundary extends Component<{ children: ReactNode }, State> { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } componentDidCatch(error: Error, info: ErrorInfo) { console.error("ошибка страницы", error, info.componentStack); } render() { if (!this.state.error) return this.props.children; return (
{this.state.error.message}