import { ReactNode, ComponentType } from "react" import { ErrorBoundary } from "react-error-boundary"; export interface ErrorFallbackComponentProps { error: any; resetErrorBoundary: (...args: any[]) => void; } export type ErrorBoundaryProps = { children: ReactNode; fallback: ComponentType; }; export function VertesiaErrorBoundary({ children, fallback }: ErrorBoundaryProps) { if (ErrorBoundaryInstance) { // custom error boundary? return {children} } else { return {children} } } let ErrorBoundaryInstance: ComponentType<{ fallback: ComponentType; children: ReactNode; }> | null = null; export function setErrorBoundaryComponent(ErrorBoundaryComponent: ComponentType) { ErrorBoundaryInstance = ErrorBoundaryComponent; }