Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7969

Account change listener is not working for phantom wallet

$
0
0

I am using this code given below in my react application to listen an account change event but facing issue as no response or error i am getting on changing account form phantom wallet .i have followed the documentation and tried the method using public key as well but still i didn't get any solution the code for the account change listener is given below .

useEffect(() => {const provider = (window as any)?.phantom?.solana;

if (provider !== undefined) {  provider.on("accountChanged", async () => {    try {      dispatch(setOverlapLoader(true));      await wallet.disconnect();      dispatch(logoutUser());    } catch (error) {      console.log("error", error);    } finally {      dispatch(setOverlapLoader(false));    }  });}

}, [dispatch, wallet]);


Viewing all articles
Browse latest Browse all 7969

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>