"use client"; import { Component, type ReactNode } from "react"; import Link from "next/link"; interface Props { children: ReactNode; fallback?: ReactNode; } interface State { hasError: boolean; error?: Error; } export default class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, info: { componentStack: string }) { console.error("[ErrorBoundary]", error, info.componentStack); } render() { if (this.state.hasError) { if (this.props.fallback) return this.props.fallback; return (

Une erreur inattendue s'est produite.

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