返回 DeepSeek-Reasonix
ErrorBoundary.tsx
根目录 / desktop / frontend / src / components / ErrorBoundary.tsx
1 import { Component, type ReactNode } from "react";
2 import { reportCrash } from "../lib/crash";
3
4 export class ErrorBoundary extends Component<{ children: ReactNode }, { crashed: boolean }> {
5 state = { crashed: false };
6
7 static getDerivedStateFromError() {
8 return { crashed: true };
9 }
10
11 componentDidCatch(error: unknown, info: { componentStack?: string | null }) {
12 reportCrash("react", error, info.componentStack ?? undefined);
13 }
14
15 render() {
16 return this.state.crashed ? null : this.props.children;
17 }
18 }
19
19 lines Plain Text