From 50e901d4706d12f343fb468e4e8c407110f45885 Mon Sep 17 00:00:00 2001 From: michalsmiarowski Date: Mon, 21 Aug 2023 10:51:03 +0200 Subject: [PATCH 1/2] Fix WalletConnection alert There was a bug - the walletconnection alert did not show up second time if the error message stays the same. This commit fixes that. --- src/components/Navbar/WalletConnectionAlert.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Navbar/WalletConnectionAlert.tsx b/src/components/Navbar/WalletConnectionAlert.tsx index 24d986e89..490da70e7 100644 --- a/src/components/Navbar/WalletConnectionAlert.tsx +++ b/src/components/Navbar/WalletConnectionAlert.tsx @@ -46,6 +46,7 @@ const WalletConnectionAlert: FC<{ const resetAlert = () => { setHideAlert(true) setAlertDescription("") + if (error) error.message = "" } if (hideAlert) { From 779f5ae0daa5fb4548469288df986558db7524a8 Mon Sep 17 00:00:00 2001 From: michalsmiarowski Date: Wed, 6 Sep 2023 15:00:13 +0200 Subject: [PATCH 2/2] Use `deactivate` function to reset alert We should never change or update the state directly and `error` is a state variable. Instead we call `deactivate` function from `useWeb3React` to clear the state. --- src/components/Navbar/WalletConnectionAlert.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Navbar/WalletConnectionAlert.tsx b/src/components/Navbar/WalletConnectionAlert.tsx index 490da70e7..8ed424dcb 100644 --- a/src/components/Navbar/WalletConnectionAlert.tsx +++ b/src/components/Navbar/WalletConnectionAlert.tsx @@ -15,7 +15,7 @@ const WalletConnectionAlert: FC<{ chainId?: number }> = ({ account, chainId }) => { const [hideAlert, setHideAlert] = useState(false) - const { error } = useWeb3React() + const { error, deactivate } = useWeb3React() const [alertDescription, setAlertDescription] = useState("") const errorMessage = error?.message @@ -46,7 +46,7 @@ const WalletConnectionAlert: FC<{ const resetAlert = () => { setHideAlert(true) setAlertDescription("") - if (error) error.message = "" + deactivate() } if (hideAlert) {