feat(auth0) add Loading component
This commit is contained in:
parent
694fd2cf78
commit
9e55024b00
|
@ -1,10 +1,16 @@
|
|||
import React from 'react';
|
||||
import { useAuth0 } from '@auth0/auth0-react';
|
||||
|
||||
import NavBar from "./components/nav-bar";
|
||||
import Loading from "./components/loading";
|
||||
import Home from './pages/home';
|
||||
export default function App() {
|
||||
const { isLoading } = useAuth0();
|
||||
if (isLoading) {
|
||||
return <Loading />;
|
||||
}
|
||||
return (
|
||||
<div id="app" className="d-flex flex-column h-100">
|
||||
<div>
|
||||
<NavBar />
|
||||
<div>
|
||||
<h1>Auth0 with React.js</h1>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import React from "react";
|
||||
const loadingImg =
|
||||
"https://cdn.auth0.com/blog/auth0-react-sample/assets/loading.svg";
|
||||
|
||||
const Loading = () => (
|
||||
<div className="spinner">
|
||||
<img src={loadingImg} alt="Loading..." />
|
||||
</div>
|
||||
);
|
||||
|
||||
export default Loading;
|
|
@ -5,7 +5,6 @@ const LoginButton = () => {
|
|||
const { loginWithRedirect } = useAuth0();
|
||||
return (
|
||||
<button
|
||||
className="btn btn-primary btn-block"
|
||||
onClick={() => loginWithRedirect()}
|
||||
>
|
||||
Log In
|
||||
|
|
|
@ -5,7 +5,6 @@ const LogoutButton = () => {
|
|||
const { logout } = useAuth0();
|
||||
return (
|
||||
<button
|
||||
className="btn btn-danger btn-block"
|
||||
onClick={() =>
|
||||
logout({
|
||||
returnTo: window.location.origin,
|
||||
|
|
Loading…
Reference in New Issue