'use client'; import { Component, ReactNode } from 'react'; interface ErrorBoundaryProps { children: ReactNode; fallback?: ReactNode; } 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) { return this.props.fallback || (

Something went wrong:

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