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

Commit

Permalink
Create NavBar that uses custom Auth0 hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarprudnikov committed Jan 2, 2020
1 parent 4b0413d commit 07a26fe
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/NavBar.js
@@ -0,0 +1,18 @@
import React from "react";
import { useAuth0 } from "../react-auth0-spa";

const NavBar = () => {
const { isAuthenticated, loginWithRedirect, logout } = useAuth0();

return (
<div>
{!isAuthenticated && (
<button onClick={() => loginWithRedirect({})}>Log in</button>
)}

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

export default NavBar;

0 comments on commit 07a26fe

Please sign in to comment.