import { Component } from "react"; import type { ReactNode } from "react"; import { AlertCircle } from "lucide-react"; import { Button } from "@/client/components/ui/button"; interface Props { fallback?: ReactNode; children: ReactNode; } interface State { hasError: boolean; } export class ErrorBoundary extends Component { state: State = { hasError: false }; static getDerivedStateFromError(): State { return { hasError: true }; } render() { if (this.state.hasError) { if (this.props.fallback) return this.props.fallback; return (

Something went wrong.

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