From ab114c9d6dc19abb851a8c6d6dfa2864025ccdc4 Mon Sep 17 00:00:00 2001 From: michalsmiarowski Date: Mon, 24 Jul 2023 11:17:38 +0200 Subject: [PATCH] Simplify wallet connection aler useEffect --- src/components/Navbar/WalletConnectionAlert.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)