-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
index.tsx
48 lines (44 loc) · 1.28 KB
/
index.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
/* SPDX-FileCopyrightText: 2014-present Kriasoft */
/* SPDX-License-Identifier: MIT */
import { createElement } from "react";
import {
createBrowserRouter,
Navigate,
RouterProvider,
} from "react-router-dom";
import { BaseLayout, MainLayout, RootError } from "../components";
/**
* Application routes
* https://reactrouter.com/en/main/routers/create-browser-router
*/
export const router = createBrowserRouter([
{
path: "",
element: <BaseLayout />,
errorElement: <RootError />,
children: [
{ path: "login", lazy: () => import("./login") },
{ path: "privacy", lazy: () => import("./privacy") },
{ path: "terms", lazy: () => import("./terms") },
],
},
{
path: "",
element: <MainLayout />,
errorElement: <RootError />,
children: [
{ index: true, element: <Navigate to="/dashboard" replace /> },
{ path: "dashboard", lazy: () => import("./dashboard") },
{ path: "tasks", lazy: () => import("./tasks") },
{ path: "messages", lazy: () => import("./messages") },
],
},
]);
export function Router(): JSX.Element {
return createElement(RouterProvider, { router });
}
// Clean up on module reload (HMR)
// https://vitejs.dev/guide/api-hmr
if (import.meta.hot) {
import.meta.hot.dispose(() => router.dispose());
}