-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathroot-component.tsx
More file actions
69 lines (64 loc) · 1.71 KB
/
root-component.tsx
File metadata and controls
69 lines (64 loc) · 1.71 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
import { Outlet } from '@tanstack/react-router';
import { lazy, Suspense, useEffect } from 'react';
import { toast } from 'sonner';
const TanStackDevtools = import.meta.env.DEV
? lazy(() =>
import('@tanstack/react-devtools').then((mod) => ({
default: mod.TanStackDevtools,
}))
)
: () => null;
const ReactQueryDevtoolsPanel = import.meta.env.DEV
? lazy(() =>
import('@tanstack/react-query-devtools').then((mod) => ({
default: mod.ReactQueryDevtoolsPanel,
}))
)
: () => null;
const TanStackRouterDevtoolsPanel = import.meta.env.DEV
? lazy(() =>
import('@tanstack/react-router-devtools').then((mod) => ({
default: mod.TanStackRouterDevtoolsPanel,
}))
)
: () => null;
export const RootComponent = () => {
useEffect(() => {
toast.success('This is a test toast for preview 2', {
position: 'bottom-center',
duration: 5000,
closeButton: true,
});
}, []);
return (
<>
<Outlet />
{import.meta.env.DEV && (
<Suspense fallback={null}>
<TanStackDevtools
plugins={[
{
name: 'TanStack Query',
render: (
<Suspense fallback={null}>
<ReactQueryDevtoolsPanel />
</Suspense>
),
defaultOpen: true,
},
{
name: 'TanStack Router',
render: (
<Suspense fallback={null}>
<TanStackRouterDevtoolsPanel />
</Suspense>
),
defaultOpen: false,
},
]}
/>
</Suspense>
)}
</>
);
};