-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
80 lines (77 loc) · 2.2 KB
/
index.js
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
70
71
72
73
74
75
76
77
78
79
80
import React, { lazy, Suspense, useEffect, useState } from "react";
import ReactDOM from "react-dom/client";
import Body from "./src/components/Body";
import Header from "./src/components/Header";
import Footer from "./src/components/Footer";
import {
createBrowserRouter,
RouterProvider,
Outlet,
Route,
} from "react-router-dom";
import Error from "./src/components/Error";
import RestaurantMenu from "./src/components/RestaurantMenu";
import About from "./src/components/About";
import UserContext from "./src/utils/UserContext";
import { Provider } from "react-redux";
import { persistedStore, appStore } from "./src/redux/appStore";
import { PersistGate } from "redux-persist/integration/react";
import Cart from "./src/components/Cart";
const ToDoApp = lazy(() => import("./src/components/TodoApp"));
const AppComponent = () => {
const [userName, setUserName] = useState();
useEffect(() => {
setUserName("savitha");
}, []);
console.log(<Body />);
return (
<Provider store={appStore}>
{/* <PersistGate loading={null} persistor={persistedStore}> */}
<UserContext.Provider value={{ userName, setUserName }}>
<Header />
<main
className="relative w-10/12 mx-auto z-10"
style={{ marginTop: "84px", position: "relative" }}
>
<Outlet />
</main>
</UserContext.Provider>
{/* </PersistGate> */}
</Provider>
);
};
const appRouter = createBrowserRouter([
{
path: "/",
element: <AppComponent />,
children: [
{
path: "/",
element: <Body />,
},
{
path: "/restaurant/:restId",
element: <RestaurantMenu />,
},
{
path: "/about",
element: <About />,
},
{
path: "/cart",
element: <Cart />,
},
{
path: "/todoApp",
element: (
<Suspense fallback={<h1>Loading Grocery page</h1>}>
<ToDoApp />
</Suspense>
),
},
],
errorElement: <Error />,
},
]);
const root = document.getElementById("root");
ReactDOM.createRoot(root).render(<RouterProvider router={appRouter} />);