-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.jsx
57 lines (54 loc) · 1.45 KB
/
main.jsx
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
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import {
createRoutesFromElements,
createBrowserRouter,
RouterProvider,
Route,
} from 'react-router-dom';
import './index.css';
import Root, {
loader as rootLoader,
action as rootAction,
} from './routes/root';
import ErrorPage from './error-page';
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 router = createBrowserRouter(
createRoutesFromElements(
<Route
path="/"
element={<Root />}
loader={rootLoader}
action={rootAction}
errorElement={<ErrorPage />}
>
<Route errorElement={<ErrorPage />}>
<Route index element={<Index />} />
<Route
path="contacts/:contactId"
element={<Contact />}
loader={contactLoader}
action={contactAction}
/>
<Route
path="contacts/:contactId/edit"
element={<EditContact />}
loader={contactLoader}
action={editAction}
/>
<Route path="contacts/:contactId/destroy" action={destroyAction} />
</Route>
</Route>
)
);
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>
);