-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathCrashPage.tsx
More file actions
56 lines (50 loc) · 1.35 KB
/
CrashPage.tsx
File metadata and controls
56 lines (50 loc) · 1.35 KB
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
50
51
52
53
54
55
56
import * as React from 'react';
import { Resource } from '@tomic/react';
import { ContainerWide } from '../components/Containers';
import { ErrorBlock } from '../components/ErrorLook';
import { Button } from '../components/Button';
import { Column, Row } from '../components/Row';
import type { JSX } from 'react';
import { styled } from 'styled-components';
type ErrorPageProps = {
resource?: Resource;
children?: React.ReactNode;
error: Error;
info: React.ErrorInfo;
clearError: () => void;
};
/** If the entire app crashes, show this page */
function CrashPage({
resource,
children,
error,
clearError,
}: ErrorPageProps): JSX.Element {
return (
<StyledMain>
<ContainerWide resource={resource?.subject}>
<Column>
{children ? children : <ErrorBlock error={error} showTrace={true} />}
<Row>
{clearError && <Button onClick={clearError}>Clear error</Button>}
<Button
onClick={() =>
window.setTimeout(
window.location.reload.bind(window.location),
200,
)
}
>
Try Again
</Button>
</Row>
</Column>
</ContainerWide>
</StyledMain>
);
}
export default CrashPage;
const StyledMain = styled.main`
height: 100dvh;
overflow: auto;
`;