Files
BrainWind/app/src/components/WebglErrorBoundary.tsx
T

33 lines
685 B
TypeScript

import { Component, type ReactNode } from 'react';
interface Props {
children: ReactNode;
fallback: ReactNode;
}
interface State {
hasError: boolean;
}
export default class WebglErrorBoundary extends Component<Props, State> {
declare state: State;
constructor(props: Props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(): State {
return { hasError: true };
}
override componentDidCatch(error: Error) {
console.warn('[WindApp] Canvas render failed, showing fallback:', error.message);
}
override render() {
if (this.state.hasError) return this.props.fallback;
return this.props.children;
}
}