So there is a bug because isWeb3Enabled is always false
try something like that, worked for me:
const { isInitialized, account} = useMoralis();
useEffect(() => {
if (isInitialized && account) {
**YOUR CODE HERE**
}
}, [isInitialized, account]);
2 Likes
Iโm having this same issue with react and useMoralis. Every time I refresh the page, the user object is still valid but the account and chainId go back to null. I can get the account by digging into the user object like user.attributes.ethAddress, but the fact that โaccountโ disappears on refresh seems like an important bug and it messes up a lot of logic in my app. Any solutions yet?
By the way, it does work to refresh the useMoralis account object by putting Moralis.enableWeb3() in useEffect, but that also throws another error:
Cannot execute Moralis.enableWeb3(), as Moralis Moralis.enableWeb3() already has been called, but is not finished yet
Please keep to/see other thread.