import React, { Component, ErrorInfo, ReactNode } from 'react'; interface Props { children: ReactNode; } interface State { hasError: boolean; error: Error | null; } class ErrorBoundary extends Component { public state: State = { hasError: false, error: null }; public static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } public componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error('Error caught by boundary:', error, errorInfo); } public render() { if (this.state.hasError) { return (

Something went wrong

The application encountered an unexpected error. Please refresh the page and try again.

{process.env.NODE_ENV === 'development' && this.state.error && (
Error Details (Development)
                    {this.state.error.stack}
                  
)}
); } return this.props.children; } } export default ErrorBoundary;