metamask event disconnect code example
Example: metamask event disconnect
web3.ethereum.on("accountsChanged", accounts => {
if (accounts.length > 0)
console.log(`Account connected: ${accounts[0]}`);
else
console.log("Account disconnected");
});