packages/gazzodown/src/elements/Timestamp/ErrorBoundary.tsx
import { Component, ReactNode } from 'react';
interface ErrorBoundaryProps {
fallback: ReactNode;
children: ReactNode;
}
export class ErrorBoundary extends Component<ErrorBoundaryProps, { hasError: boolean }> {
constructor(props: ErrorBoundaryProps) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(): { hasError: boolean } {
return { hasError: true };
}
render(): ReactNode {
if (this.state.hasError) {
// You can render any custom fallback UI
return this.props.fallback;
}
return this.props.children;
}
}