fix: model be cleared when apply config to all in compare

This commit is contained in:
jialin
2024-11-22 18:25:07 +08:00
parent c8c22b3f22
commit a6f0f554f0
14 changed files with 124 additions and 102 deletions
+39
View File
@@ -0,0 +1,39 @@
import { Component } from 'react';
interface ErrorBoundaryState {
hasError: boolean;
}
class ErrorBoundary extends Component<
{ children?: React.ReactNode },
ErrorBoundaryState
> {
constructor(props: any) {
super(props);
this.state = {
hasError: false
};
}
// 捕获错误并更新状态
static getDerivedStateFromError(error: any) {
console.error('Error caught by Error Boundary:', error);
return { hasError: true };
}
// 记录错误信息(可选)
componentDidCatch(error: any, info: any) {
console.error('Error caught by Error Boundary:', error);
console.error(info);
}
render() {
if (this.state.hasError) {
return <h1>Something went wrong.</h1>;
}
return this.props.children;
}
}
export default ErrorBoundary;