import React, { Component, ErrorInfo, ReactNode } from 'react'; interface Props { children: ReactNode; fallback?: ReactNode; } interface State { hasError: boolean; error: Error | null; } class ErrorBoundary extends Component { declare state: State; declare props: Props; declare setState: (state: Partial | ((prevState: State) => Partial)) => void; constructor(props: Props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: ErrorInfo): void { console.error('ErrorBoundary caught an error:', error, errorInfo); } handleReset = (): void => { this.setState({ hasError: false, error: null }); }; render(): ReactNode { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback; } return (

Something went wrong

The application encountered an unexpected error. Please try refreshing the page or resetting the app.

{this.state.error && (

{this.state.error.message}

)}
); } return this.props.children; } } export default ErrorBoundary;