import { Component, ReactNode } from 'react'; interface Props { children: ReactNode; } interface State { hasError: boolean; error: Error | null; } export class ChartErrorBoundary extends 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('Chart error:', error, errorInfo); } render() { if (this.state.hasError) { return (
⚠️

Chart Loading Error

{this.state.error?.message || 'Unable to load the chart'}

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