import React from 'react'; interface ErrorBoundaryProps { children: React.ReactNode; } interface ErrorBoundaryState { error: Error | null; } export default class ErrorBoundary extends React.Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { error: null }; } static getDerivedStateFromError(error: Error) { return { error }; } componentDidCatch(error: Error, info: React.ErrorInfo) { console.error('ErrorBoundary caught:', error, info); } render() { if (this.state.error) { return (
Something went wrong

{this.state.error.message}

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