Skip to content

@wagmi/core V2: How to use watchAccount to update my data. #3414

Answered by Rubanrubi
Nilbristi asked this question in Q&A
Discussion options

You must be logged in to vote

@Nilbristi

this.unwatch = watchAccount(wagmiConfig, {
onChange: (data) => {
console.log('Account changed!', data);
if (data.address != undefined) {
this.getUser(data.address);
}
const chains = wagmiConfig.chains
const chain = chains.find(chain => chain.id === data.chainId)

  },
})

you can change OnChange function to arrow function it works 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Rubanrubi
Comment options

Answer selected by Nilbristi
@Nilbristi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants