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

Something went wrong

{this.state.error?.message || 'An unexpected error occurred.'}

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