We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { useEffect, useState } from 'react'; import { useConnection } from '@solana/wallet-adapter-react'; import { PublicKey } from '@solana/web3.js'; const useWalletMonitor = (walletAddress) => { const { connection } = useConnection(); const [accountInfo, setAccountInfo] = useState(null); useEffect(() => { if (!walletAddress) return; const publicKey = new PublicKey(walletAddress); // Function to handle account changes const handleAccountChange = (accountInfo) => { console.log('Account updated:', accountInfo); setAccountInfo(accountInfo); }; // Subscribe to account changes const subscriptionId = connection.onAccountChange(publicKey, handleAccountChange); // Cleanup subscription on unmount return () => { connection.removeAccountChangeListener(subscriptionId); }; }, [connection, walletAddress]); return accountInfo; }; export default useWalletMonitor;
the connection.onAccountChange doesn't trigger when my phantom wallet account got changed, but if using the suggested way mentioned in phantom's official here https://docs.phantom.app/solana/establishing-a-connection#changing-accounts it works
The text was updated successfully, but these errors were encountered:
Are you using Next.js? If so, take a look at this thread: #883
Sorry, something went wrong.
No branches or pull requests
the connection.onAccountChange doesn't trigger when my phantom wallet account got changed, but if using the suggested way mentioned in phantom's official here https://docs.phantom.app/solana/establishing-a-connection#changing-accounts
it works
The text was updated successfully, but these errors were encountered: