Created
July 13, 2020 10:47
-
-
Save mtreacy002/016ff08ccaa59985cdec2835522003d7 to your computer and use it in GitHub Desktop.
Protected page with Reactjs
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 React from "react"; | |
import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; | |
import Home from "./Home"; | |
import Login from "./Login"; | |
import MySpace from "./MySpace"; | |
import ProtectedRoute from "./ProtectedRoute"; | |
import Navigation from "./Navigation"; | |
import AuthProvider from "./AuthContext"; | |
export default function Routes() { | |
return ( | |
<Router> | |
<AuthProvider> | |
<Navigation /> | |
<Switch> | |
<Route exact path="/"> | |
<Home /> | |
</Route> | |
<Route path="/login"> | |
<Login /> | |
</Route> | |
<ProtectedRoute exact path="/my-space"> | |
<MySpace /> | |
</ProtectedRoute> | |
</Switch> | |
</AuthProvider> | |
</Router> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment