Web3 Enable losing when I refresh page

When I authenticate and check isWeb3Enable, it returns an answer that is true. And when I refresh the page it returns a false.

You can run enableWeb3() if isWeb3Enabled is false e.g. in a useEffect.

2 Likes

Thanks, I have already solved this problem.

useEffect(() => {
if (!isWeb3Enabled && isAuthenticated) {
if (typeof screen.orientation === ‘undefined’) {
enableWeb3({
provider: ‘walletconnect’,
chainId: 4,
})
} else {
enableWeb3({
provider: ‘metamask’,
chainId: 4,
})
}
}

}, [isWeb3Enabled, isAuthenticated, enableWeb3])

but I have a new problem, walletConnect not working.
No mobileLinks are visible when logging in from the smartphone. For example “Metamask”. and error is "TypeError: Cannot read properties of undefined {reading ‘importKey’}

1 Like