[SOLVED] isAuthenticated getting false in React

Good day!

I experienced a weird result. When I refresh the site, it will return false, true, false.

useEffect(() => {

      console.log(isAuthenticated)

  }, [isAuthenticated]);

image

strange, can you also add a timestamp?

you can add more dependencies to that useEffect, like isInitialized

I added isInitialized and isWeb3Enabled it’s still the same.
Then for the timestamp, there’s 150ms interval

Did you try by building for dev or for production? It may be different names

Both, same output. What else can I do with this?

What for you are going to use that isAuthenticated flag?

For the connect wallet button, because after I signed in, if I refresh the page I can’t retrieve user’s info again.

on what user info you are referring?

authentication is different than enabling web3

I mean, after the user used authentication() we are able to fetch the user’s info. However, if we refresh the page, it’s giving me a false in the isAuthenticated. I was using it to change the “Connect Wallet” to “0x…12” button.

I would expect it to work after you refresh the page
if you use vanilla js syntax then it works? Moralis.isAuthenticated()

Yes, same here. I have recycled the code and it works on my previous project. But for the new one, it’s acting really strange. And the session is also available in the local storage. But if I use isAuthenticated, it’s giving me false, true, false.

what is the difference between the old project and the new one?
maybe difference versions for some libraries?

Nothing much, I used the same versions.

Maybe try to build again in a new empty folder?

1 Like

Ohhhhh okay, maybe it was a cache issue. I deleted the build folder, reset the data of the site then it works!

1 Like