Skip to content

Commit

Permalink
add on and off functions
Browse files Browse the repository at this point in the history
  • Loading branch information
theparthway committed Oct 18, 2024
1 parent fbac52e commit c55b91a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
26 changes: 12 additions & 14 deletions packages/walletConnectors/src/bitcoin/btcWalletsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,18 @@ export const BTCWalletProvider = ({ children }: { children: ReactNode }) => {
}
}, []);

// currently don't require these functions
// useEffect(() => {
// if (!provider) return;
// provider.on('accountsChanged', (obj) => {
// console.log('obj :', obj);
// console.log('accounts changed');
// });

// return () => {
// provider.off('accountsChanged', () => {
// console.log('accounts changed');
// });
// };
// }, [provider]);
useEffect(() => {
if (!provider) return;
provider.on('accountsChanged', (obj) => {
setAccount(obj.val);
});

return () => {
provider.off('accountsChanged', (obj) => {
setAccount(obj.val);
});
};
}, [provider]);

return (
<BTCWalletProviderContext.Provider
Expand Down
1 change: 0 additions & 1 deletion packages/walletConnectors/test/src/components/Hello.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const Hello = () => {
<div>Network: {network}</div>
<div>
<div
onClick={updateInfo}
style={{ cursor: 'pointer' }}
>
total balance: {balance.total}
Expand Down

0 comments on commit c55b91a

Please sign in to comment.