Created
May 19, 2022 19:11
-
-
Save sourabhbagrecha/210406b77004ce25cb247db72cbbd972 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserRouter, Route, Routes } from "react-router-dom"; | |
import { UserProvider } from "./contexts/user.context"; | |
import Home from "./pages/Home.page"; | |
import Login from "./pages/Login.page"; | |
import PrivateRoute from "./pages/PrivateRoute.page"; | |
import Signup from "./pages/Signup.page"; | |
function App() { | |
return ( | |
<BrowserRouter> | |
{/* We are wrapping our whole app with UserProvider so that */} | |
{/* our user is accessible through out the app from any page*/} | |
<UserProvider> | |
<Routes> | |
<Route exact path="/login" element={<Login />} /> | |
<Route exact path="/signup" element={<Signup />} /> | |
{/* We are protecting our Home Page from unauthenticated */} | |
{/* users by wrapping it with PrivateRoute here. */} | |
<Route element={<PrivateRoute />}> | |
<Route exact path="/" element={<Home />} /> | |
</Route> | |
</Routes> | |
</UserProvider> | |
</BrowserRouter> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment