Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Commit

Permalink
Add routes and update NavBar
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarprudnikov committed Jan 2, 2020
1 parent e17d175 commit f2fe93e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React from 'react';
import React from "react";
import NavBar from "./components/NavBar";
import { useAuth0 } from "./react-auth0-spa";
import { Router, Route, Switch } from "react-router-dom";
import Profile from "./components/Profile";
import history from "./utils/history";

function App() {

const { loading } = useAuth0();

if (loading) {
return <div>Loading...</div>;
}

return (
<div className="App">
<header>
<NavBar />
</header>
<Router history={history}>
<header>
<NavBar />
</header>
<Switch>
<Route path="/" exact />
<Route path="/profile" component={Profile} />
</Switch>
</Router>
</div>
);
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { useAuth0 } from "../react-auth0-spa";
import { Link } from "react-router-dom";

const NavBar = () => {
const { isAuthenticated, loginWithRedirect, logout } = useAuth0();
Expand All @@ -11,6 +12,13 @@ const NavBar = () => {
)}

{isAuthenticated && <button onClick={() => logout()}>Log out</button>}

{isAuthenticated && (
<span>
<Link to="/">Home</Link>&nbsp;
<Link to="/profile">Profile</Link>
</span>
)}
</div>
);
};
Expand Down

0 comments on commit f2fe93e

Please sign in to comment.