Files
nanobot/webui/src/components/SurfaceErrorBoundary.tsx
T

17 lines
374 B
TypeScript

import { Component, type ReactNode } from "react";
export class SurfaceErrorBoundary extends Component<
{ children: ReactNode; fallback: ReactNode },
{ failed: boolean }
> {
state = { failed: false };
static getDerivedStateFromError() {
return { failed: true };
}
render() {
return this.state.failed ? this.props.fallback : this.props.children;
}
}