Skip to content

Commit

Permalink
Use deactivate function to reset alert
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michalsmiarowski committed Sep 6, 2023
1 parent 50e901d commit 779f5ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Navbar/WalletConnectionAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +46,7 @@ const WalletConnectionAlert: FC<{
const resetAlert = () => {
setHideAlert(true)
setAlertDescription("")
if (error) error.message = ""
deactivate()
}

if (hideAlert) {
Expand Down

0 comments on commit 779f5ae

Please sign in to comment.