diff --git a/src/components/Navbar/WalletConnectionAlert.tsx b/src/components/Navbar/WalletConnectionAlert.tsx index 51fc2dfb4..24d986e89 100644 --- a/src/components/Navbar/WalletConnectionAlert.tsx +++ b/src/components/Navbar/WalletConnectionAlert.tsx @@ -18,9 +18,11 @@ const WalletConnectionAlert: FC<{ const { error } = useWeb3React() const [alertDescription, setAlertDescription] = useState("") + const errorMessage = error?.message + useEffect(() => { - if (error) { - setAlertDescription(error.message) + if (errorMessage) { + setAlertDescription(errorMessage) setHideAlert(false) return } @@ -39,7 +41,7 @@ const WalletConnectionAlert: FC<{ setHideAlert(false) return } - }, [account, chainId, error?.message]) + }, [account, chainId, errorMessage]) const resetAlert = () => { setHideAlert(true)