import React from 'react' export class ErrorBoundary extends React.Component<{ children: React.ReactNode },{ hasError: boolean error?: Error } > { constructor(props: { children: React.ReactNode }) { super(props) this.state = { hasError: false } } static getDerivedStateFromError(error: Error): { hasError: boolean error?: Error } { return { hasError: true, error } } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error('Error caught by boundary:', error, errorInfo) } render() { if (this.state.hasError) { return (
Error: {this.state.error?.message}
{this.state.error?.stack}