web3-react icon indicating copy to clipboard operation
web3-react copied to clipboard

How to catch web3react context updates?

Open redrossa opened this issue 2 years ago • 1 comments

I need to be able to detect if the user switches account or network. I notice that the activate function is not called when those changes happen by the user. However, I see that an Event is emitted when those changes occur. Is there a way for me to handle those events? Or, is there a way for me to set callback functions for those events?

redrossa avatar Apr 13 '22 16:04 redrossa

If you grab the account or chainId from the useWeb3React hook in a component that is a child of the Web3ReactProvider, your components will get those updates.

mattparrilla avatar Apr 18 '22 18:04 mattparrilla