Created
October 9, 2020 00:33
-
-
Save mbrown3321/997199ddf779b520097ebccf2c51a2f7 to your computer and use it in GitHub Desktop.
App.js - with logout
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 { Navbar, Nav, Button } from "react-bootstrap" | |
import { useAuth0 } from "@auth0/auth0-react"; | |
import 'bootstrap/dist/css/bootstrap.min.css'; | |
const App = () => { | |
const { loginWithRedirect, isAuthenticated, logout } = useAuth0(); | |
return ( | |
<div> | |
<Navbar bg="dark" variant="dark"> | |
<Navbar.Brand href="#home">Auth0</Navbar.Brand> | |
<Nav className="ml-auto"> | |
{ | |
isAuthenticated | |
? ( | |
<Button onClick={() => logout()}>Logout</Button> | |
) : ( | |
<Button onClick={() => loginWithRedirect()}>Login</Button> | |
) | |
} | |
</Nav> | |
</Navbar> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment