-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsx
More file actions
69 lines (64 loc) · 1.9 KB
/
index.jsx
File metadata and controls
69 lines (64 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
import * as React from 'react'
import * as ReactDOM from 'react-dom/client'
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import './index.css'
import ErrorPage from './error-page'
import Root, { loader as rootLoader, action as rootAction } from './routes/root'
import Contact, {
loader as contactLoader,
action as contactAction,
} from './routes/contact'
import EditContact, { action as editAction } from './routes/edit'
import { action as destroyAction } from './routes/destroy'
import Index from './routes/index'
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 10,
},
},
})
const router = createBrowserRouter([
{
path: '/',
element: <Root />,
errorElement: <ErrorPage />,
loader: rootLoader(queryClient),
action: rootAction(queryClient),
children: [
{
index: true,
element: <Index />,
},
{
path: 'contacts/:contactId',
element: <Contact />,
loader: contactLoader(queryClient),
action: contactAction(queryClient),
},
{
path: 'contacts/:contactId/edit',
element: <EditContact />,
loader: contactLoader(queryClient),
action: editAction(queryClient),
},
{
path: 'contacts/:contactId/destroy',
element: <EditContact />,
action: destroyAction(queryClient),
errorElement: <div>Oops! There was an error.</div>,
},
],
},
])
const rootElement = document.getElementById('root')
ReactDOM.createRoot(rootElement).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
<ReactQueryDevtools position="bottom-right" />
</QueryClientProvider>
</React.StrictMode>,
)