Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Last active January 16, 2020 15:03
Show Gist options
  • Save ernestofreyreg/1ea59768029635c6f1a1ab79583b510e to your computer and use it in GitHub Desktop.
Save ernestofreyreg/1ea59768029635c6f1a1ab79583b510e to your computer and use it in GitHub Desktop.
import React from 'react'
import { useAuth0 } from '../lib/auth0-spa'
interface Props {}
const NavigationBar: React.FunctionComponent<Props> = () => {
const { isAuthenticated, loginWithRedirect, logout, loading } = useAuth0()
return (
<div>
{!loading && !isAuthenticated && (
<button onClick={() => loginWithRedirect({})}>Log in</button>
)}
{!loading && isAuthenticated && (
<button onClick={() => logout()}>Log out</button>
)}
</div>
)
}
export default NavigationBar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment