Files
AetherForge/server/web/src/components/ErrorBoundary.tsx
drjones e11fb30350 Fix dashboard black screen, add login gate, and expand README.
Pin React Three Fiber to React 18, remove PWA caching, add SessionGate and error boundaries, and document movie fusion, auth, outputs, and troubleshooting.
2026-05-29 08:50:48 -07:00

40 lines
965 B
TypeScript

import { Component, type ErrorInfo, type ReactNode } from 'react';
interface Props {
children: ReactNode;
fallback?: ReactNode;
}
interface State {
error: Error | null;
}
export default class ErrorBoundary extends Component<Props, State> {
state: State = { error: null };
static getDerivedStateFromError(error: Error): State {
return { error };
}
componentDidCatch(error: Error, info: ErrorInfo) {
console.error('UI error:', error, info);
}
render() {
if (this.state.error) {
return (
this.props.fallback ?? (
<div className="error-boundary-fallback card">
<h3>Something failed to render</h3>
<p className="form-hint">{this.state.error.message}</p>
<button type="button" className="btn btn-primary" onClick={() => this.setState({ error: null })}>
Retry
</button>
</div>
)
);
}
return this.props.children;
}
}