Skip to content

Commit

Permalink
Simplify wallet connection aler useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsmiarowski committed Jul 24, 2023
1 parent aaacbe7 commit ab114c9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/Navbar/WalletConnectionAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -39,7 +41,7 @@ const WalletConnectionAlert: FC<{
setHideAlert(false)
return
}
}, [account, chainId, error?.message])
}, [account, chainId, errorMessage])

const resetAlert = () => {
setHideAlert(true)
Expand Down

0 comments on commit ab114c9

Please sign in to comment.