import React from 'react'; interface ErrorBoundaryState { hasError: boolean; error: Error | null; } interface ErrorBoundaryProps { children: React.ReactNode; fallback?: React.ComponentType<{ error: Error | null; retry: () => void }>; } class ErrorBoundary extends React.Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): ErrorBoundaryState { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error('ErrorBoundary caught an error:', error, errorInfo); } retry = () => { this.setState({ hasError: false, error: null }); }; render() { if (this.state.hasError) { if (this.props.fallback) { const FallbackComponent = this.props.fallback; return ; } return (
⚠️

Une erreur s'est produite

L'application a rencontré un problème inattendu.

{this.state.error && (
Détails de l'erreur
                  {this.state.error.toString()}
                
)}
); } return this.props.children; } } export default ErrorBoundary;