-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrorWrapper.tsx
49 lines (42 loc) · 1.59 KB
/
ErrorWrapper.tsx
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
43
44
45
46
47
48
49
import dynamic from 'next/dynamic';
import styles from '../styles/Index.module.css';
import React from 'react';
// Icons
import { IconType } from 'react-icons-ng/lib/esm/index';
const FaHeartBroken = dynamic<React.ComponentProps<IconType>>(() => import('react-icons-ng/fa/index.js').then(mod => mod.FaHeartBroken), { ssr: false })
export default class ErrorBoundary extends React.Component {
declare state: Readonly<{ hasError: boolean }>;
constructor(props: any) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error: any) {
return { hasError: true };
}
componentDidCatch(error: any, errorInfo: any) {
console.warn({ error, errorInfo });
}
render() {
if (this.state.hasError) {
<div
style={{ zIndex: '2000' }}
className={[styles.dropzone, styles.backdrop, 'droppy'].join(' ')}>
<div
className={['details', 'error', 'droppy'].join(' ')}
style={{ maxWidth: '400px', justifyContent: 'center' }}>
<FaHeartBroken style={{ color: 'var(--red)', fontSize: '64px' }} />
<h1 style={{ margin: '6px', textAlign: 'center' }}>
ClientSideError
</h1>
<p className="error-text" style={{ fontSize: '18px' }}>
This error didnt occur from cloud, server nor our database. Rather
its from the Client {'(your browser)'} side. Please contact the
owner.
</p>
</div>
</div>;
}
//@ts-ignore
return this.props.children;
}
}