-
-
Notifications
You must be signed in to change notification settings - Fork 335
Expand file tree
/
Copy pathDefaultCatchBoundary.tsx
More file actions
75 lines (70 loc) · 1.9 KB
/
DefaultCatchBoundary.tsx
File metadata and controls
75 lines (70 loc) · 1.9 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {
ErrorComponent,
ErrorComponentProps,
Link,
rootRouteId,
useMatch,
useRouter,
} from '@tanstack/react-router'
import * as Sentry from '@sentry/tanstackstart-react'
import { Button } from './Button'
import { useEffect } from 'react'
// type DefaultCatchBoundaryType = {
// status: number
// statusText: string
// data: string
// isRoot?: boolean
// }
export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
const router = useRouter()
useEffect(() => {
Sentry.captureException(error)
}, [error])
const isRoot = useMatch({
strict: false,
select: (state) => state.id === rootRouteId,
})
console.error(error)
return (
<div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
<h1 className="opacity-10 flex flex-col text-center font-black">
{/* <div className="text-7xl leading-none">{status}</div>
{statusText ? (
<div className="text-3xl leading-none">{statusText}</div>
) : null} */}
</h1>
<ErrorComponent error={error} />
<div className="flex gap-2 items-center flex-wrap">
<Button
onClick={() => {
router.invalidate()
}}
className="bg-gray-600 border-gray-600 hover:bg-gray-700 text-white"
>
Try Again
</Button>
{isRoot ? (
<Button
as={Link}
to="/"
className="bg-gray-600 border-gray-600 hover:bg-gray-700 text-white"
>
TanStack Home
</Button>
) : (
<Button
as={Link}
to="/"
className="bg-gray-600 border-gray-600 hover:bg-gray-700 text-white"
onClick={(e: React.MouseEvent) => {
e.preventDefault()
window.history.back()
}}
>
Go Back
</Button>
)}
</div>
</div>
)
}