"use client"; import { Component, ReactNode } from "react"; type Props = { fallback?: ReactNode; children: ReactNode; }; type State = { hasError: boolean; error: Error | null; }; export class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } render() { if (this.state.hasError) { return ( this.props.fallback ?? (

Something went wrong

Please refresh the page or try again later

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