-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.route.tsx
64 lines (59 loc) · 2.01 KB
/
core.route.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as Sentry from '@sentry/react'
import { useQueryErrorResetBoundary } from '@tanstack/react-query'
import { Outlet, ScrollRestoration, useRouterState } from '@tanstack/react-router'
import { lazy } from 'react'
import { Button } from '@/components/button'
import { Meta } from '@/components/meta'
import { useThemeManager } from '@/hooks/use-theme-manager.hook'
const TanStackRouterDevtools = import.meta.env.PROD
? () => null
: lazy(() =>
import('@tanstack/router-devtools').then((mod) => ({
default: () => <mod.TanStackRouterDevtools initialIsOpen={false} position="bottom-left" />,
})),
)
const TanStackQueryDevtools = import.meta.env.PROD
? () => null
: lazy(() =>
import('@tanstack/react-query-devtools').then((mod) => ({
default: () => <mod.ReactQueryDevtools initialIsOpen={false} />,
})),
)
const NavigationLoader = () => {
const isLoading = useRouterState({ select: (state) => state.status === 'pending' })
return isLoading && <span className="loader" />
}
export const Core = () => {
const { reset } = useQueryErrorResetBoundary()
useThemeManager()
return (
<Sentry.ErrorBoundary
onReset={reset}
fallback={({ resetError, error }) => (
<div className="flex min-h-screen flex-col items-center justify-center">
<div className="flex w-full flex-col items-center gap-4 p-3">
<div className="font-mono text-xl font-bold tracking-tighter text-rose-500">{error.message}</div>
<Button
intent="primary"
className="w-full max-w-xs"
onClick={() => {
resetError()
}}
>
Try again
</Button>
</div>
</div>
)}
>
<ScrollRestoration />
<Meta titleTemplate="%s • Wayfarer" />
<div className="min-h-screen">
<NavigationLoader />
<Outlet />
<TanStackRouterDevtools />
<TanStackQueryDevtools />
</div>
</Sentry.ErrorBoundary>
)
}