Checking for if the user on navigation to a new page is authenticated or not using the following two options.
- import { withAuthenticationRequired } from “@auth0/auth0-react”; then const { isAuthenticated } = useAuth0();
vs
- import { useAuth0 } from “@auth0/auth0-react”; and then const { isAuthenticated } = useAuth0();
I get two different answers for if the user is authenticated from the two options above.
I start off by after user signs in having the user brought to a page with withAuthenticationRequired and they are logged in.
I then can go to a page where I am using const { isAuthenticated } = useAuth0(); with just the userAuth0 import and when I console log out the isAuthenticated i get “false”
From here where it says isAuthenticated = false I can go back to the page that uses withAuthenticationRequired and console log out isAuthenticated from there and get true.
I can do this over and over again and always get the same answer.
What am I doing wrong? I want to be able to tell if the user is logged in on every page.
Thanks in advance this is my first time using auth0 and really liking it so far. Happy to answer any questions on above. Really appreciate any help you might have on this issue.