Created
June 16, 2022 04:00
-
-
Save Salman18/1ca9056b35affa14ad921384c5e43402 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, Routes, Route } from "react-router-dom"; | |
//Pages | |
import Login from "../pages/login/Login"; | |
import Onboarding from "../onboarding/Onboarding"; | |
import Error from "./Error"; | |
import PrivateRoute from "./Private_Route"; | |
import Dashboard from "../pages/Dashboard"; | |
import { useState } from "react"; | |
//Routing | |
const Routing = () => { | |
const [isLogged, setIsLogged] = useState(false); | |
const fakeAsyncLogin = () => { | |
console.log('called fakeAsyncLogin'); | |
setIsLogged(true) | |
}; | |
return ( | |
<BrowserRouter> | |
<Routes> | |
<Route path="/login" element={<Login isLogged={isLogged} cb={fakeAsyncLogin} />} /> | |
<Route element={<PrivateRoute isLogged={isLogged} />}> | |
<Route path="/dashboard" element={<Dashboard />} /> | |
</Route> | |
<Route path="/*" element={<Error />} /> | |
<Route exact path="/" element={<Onboarding />} /> | |
</Routes> | |
</BrowserRouter> | |
); | |
}; | |
export default Routing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment