Moralis-react logout not working

if (isAuthenticated) {
    console.log('isAuthenticated' , isAuthenticated)
    logout().then(() => console.log(`then is isAuthenticated :::` , isAuthenticated))
}
const {logout : moralisLogOut , isInitialized , isAuthenticated , deactivateWeb3 , hasAuthError , isAuthUndefined} = useMoralis();

useEffect(() => {
        (async() => {
            console.log(`isAuthenticated :: ` , isAuthenticated)
            if (isInitialized && isAuthenticated) {
                await moralisLogOut()
                    .then(() => {
                        console.log(`Callback isAuthenticated :: ` , isAuthenticated)
                    })
                    .catch(e => {
                        console.log(`Catch the Error ::` , e.message)
                    })
            }

        })()
    },[isInitialized])

Hello, I am using react moralis web3auth (SNS Login) I want to make sure that I always log in again when I leave the page and come back in So, even though I used the logout function like the code above, I don’t log in again, but I log in with the account I logged in with. The isAuthenticated recorded with Callback is still true.

Hi @seung-gumon

Your above code seems ok, and it should run the logout function as expected.
Since isAuthenticated is a state variable there will be a small delay before the state changes. That could be the reason why you still see it as true while logging from the callback.

Try using useEffect to log the isAuthenticated like this.

useEffect(() => {
    console.log(isAuthenticated)
  },[isAuthenticated])