"use client" import { Component, type ReactNode } from "react" interface ErrorBoundaryProperties { fallback?: ReactNode children: ReactNode } interface ErrorBoundaryState { hasError: boolean error: Error | null } export class ErrorBoundary extends Component< ErrorBoundaryProperties, ErrorBoundaryState > { constructor(properties: ErrorBoundaryProperties) { super(properties) this.state = { hasError: false, error: null } } 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 ?? "an unexpected error occurred"}