Hi, I have my a ReactJs App based in the QuickStart that Auth0 recommends here(https://auth0.com/docs/quickstart/spa/react), the problem that I have been facing is that in my react component I have something like this:
import React from "react";
import { useAuth0 } from "../react-auth0-spa";
import authProvider from '../authProvider'
import LoginForm from '../components/LoginForm'
const LoginPage = () => {
const { isAuthenticated, loginWithRedirect } = useAuth0();
return (
<div>
{!isAuthenticated && (
<LoginForm/>
)}
{isAuthenticated &&
<div> you are logged in</div>
}
</div>
);
};
export default LoginPage;
so where is the problem?
when I refresh the page it log me out automatically, and I’ve been reading a lot of forums trying to get an answer, I read that using getTokenSilently function will works to solve this problem, the thing is that when I call that function I get an error, saying:
“TypeError: Cannot read property ‘getTokenSilently’ of undefined”
and I don’t know, how can the app knows that I’ve logged in so when I refresh the page it stills having me inside my app.
In advance thank you for your help.