Closed lidachao111222 closed 3 years ago
I haven't tested the minimal example with network switch but I can imagine two things:
import cache from 'swr'
cache.clear()
Thanks for your reply.
The first idea that I tried before. It doesn't work.
I use the second idea like this:
useEffect(() => { if (library !== undefined) { cache.clear() } }, [chainId]);
It also doesn't work.
Finally, I used another way to get balance and it works! lol
Here is the code:
```const { data: balance, mutate, error } = useEtherSWR(...``` // change different network
if (error) { window.location.reload(); }
The page will reload if I change the network. Although I need to connect the wallet again.
Have a look at how it works https://github.com/NoahZinsmeister/web3-react. The problem you are facing seems more related to the web3 provider than ether-swr itself.
Hi, Lorenzo. Sorry for disturbing you.
I have one question about the Interact with Ethereum methods when I use the getBalance function with ether-swr. When I tried the minimal example. I saw that the ethereum amount won't change if I switch to another network(ex: from Ropsten to Rinkeby).
Would you like to give me some ideas please? Thank you.