web3-react
web3-react copied to clipboard
RPC Error
Not sure how to handle errors with the library itself.
<Button
type="primary"
disabled={connecting}
onClick={() => {
setConnecting(true);
activate(injected, undefined, true).then(
() => {
setConnecting(true)
}
).catch((error) => {
// ignore the error if it's a user rejected request
if (error instanceof UserRejectedRequestError) {
setConnecting(false);
} else if (error instanceof UnsupportedChainIdError) {
setConnecting(false);
} else if (error instanceof RpcError) { // was trying to find if this error was typed already.
setConnecting(false);
} else {
setError(error);
}
});
}}
>
{isMetaMaskInstalled ? t('connect_metamask') : t('connect_wallet')}
</Button>
inpage.js:1 MetaMask - RPC Error: Already processing eth_requestAccounts. Please wait. {code: -32002, message: 'Already processing eth_requestAccounts. Please wait.'}
this error usually appears when you connect to a wallet but user hasn't unlocked it yet. The easiest way is checking by error.code imo