-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorBoundary.tsx
More file actions
42 lines (38 loc) · 988 Bytes
/
ErrorBoundary.tsx
File metadata and controls
42 lines (38 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Component, ReactNode } from 'react';
export class ErrorBoundary extends Component<
{ children: ReactNode },
{ hasError: boolean }
> {
constructor(props: { children: ReactNode }) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error: Error) {
console.error('ParentErrorBoundary caught error:', error);
}
render() {
if (this.state.hasError) {
return (
<div
style={{
padding: '20px',
backgroundColor: '#fef2f2',
border: '1px solid #fecaca',
borderRadius: '6px',
color: '#7f1d1d',
}}
>
<h2 style={{ marginTop: 0 }}>Something went wrong</h2>
<p>
An error occurred in the RemoteFlows component. Please try
refreshing the page.
</p>
</div>
);
}
return this.props.children;
}
}