feat(auth0) add Loading component

This commit is contained in:
dancingCycle 2022-07-20 19:32:52 +02:00
parent 694fd2cf78
commit 9e55024b00
4 changed files with 18 additions and 3 deletions

View File

@ -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>

View File

@ -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;

View File

@ -5,7 +5,6 @@ const LoginButton = () => {
const { loginWithRedirect } = useAuth0();
return (
<button
className="btn btn-primary btn-block"
onClick={() => loginWithRedirect()}
>
Log In

View File

@ -5,7 +5,6 @@ const LogoutButton = () => {
const { logout } = useAuth0();
return (
<button
className="btn btn-danger btn-block"
onClick={() =>
logout({
returnTo: window.location.origin,