can I know what should I do to utilize the function of onChainChange
const xx = Moralis.onChainChanged()
I want the NativeBalance show correct value, corresponding to the MetaMask account change.
I have tried below method.
But when account change, the callback function did not trigger.
And I got below warning.
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 accountChanged listeners added. Use emitter.setMaxListeners() to increase limit
summary:
solved.
just pass the account and user, from parent component to child component, and place the account into the useEffect, dependencies.