-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathApp.js
More file actions
38 lines (34 loc) · 1.1 KB
/
App.js
File metadata and controls
38 lines (34 loc) · 1.1 KB
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
import "./App.css";
import Home from "./components/pages/Home";
import PokeDex from "./components/pages/PokeDex";
import AuthForm from "./components/auth/AuhtForm";
import Layout from "./components/layout/Layout";
import AuthContext from "./store/auth-context";
import { useContext } from "react";
import { HashRouter, Route, Redirect } from "react-router-dom";
import ProfilePage from "./components/pages/ProfilePage";
function App() {
const authCtx = useContext(AuthContext);
return (
<Layout>
<HashRouter>
<div>
<Route exact path="/" component={Home} />
<Route path="/auth" component={AuthForm} />
<Route path="/pokedex">
{authCtx.isLoggedIn && <PokeDex />}
{!authCtx.isLoggedIn && <Redirect to="/" />}
</Route>
{/*<Route path='/profile'>
{authCtx.isLoggedIn && <ProfilePage />}
{!authCtx.isLoggedIn && <Redirect to='/' />}
</Route>*/}
<Route path="*">
<Redirect to="/" />
</Route>
</div>
</HashRouter>
</Layout>
);
}
export default App;