'use client'; import { Component, ReactNode } from 'react'; interface ErrorBoundaryProps { children: ReactNode; fallback?: ReactNode; onReset?: () => void; } interface ErrorBoundaryState { hasError: boolean; error?: Error; } export class ErrorBoundary extends Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): ErrorBoundaryState { return { hasError: true, error }; } render() { if (this.state.hasError) { if (this.props.fallback) return this.props.fallback; return (

Something went wrong:

{this.state.error?.message}
{this.state.error?.stack}
{this.props.onReset && ( )}
); } return this.props.children; } }