import { Component, type ReactNode, type ErrorInfo } from "react"; interface Props { children: ReactNode; } interface State { hasError: boolean; error: Error | null; } export default class ErrorBoundary extends Component { state: State = { hasError: false, error: null }; static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, info: ErrorInfo) { console.error("ErrorBoundary caught:", error, info); } render() { if (this.state.hasError) { return (

Něco se pokazilo

{this.state.error?.message}

); } return this.props.children; } }