title: Login via Tron Link in React SPA
body: <p>I am making a react app and I need to make it so that the user can log in through the Tron Link browser extension. Now it turned out only to connect the application to the wallet, but now I need to install a new state after the connection. But after the execution of the extension call function, the state changes immediately, without waiting for the connection in the extension to complete.</p>
  <p>How can I track if the connection is completed in the extension, and if completed, then change the state?</p>
  <pre><code>const getAccount = async () =&gt; {
      if (window.tronWeb !== undefined) {
        if (window.tronWeb.defaultAddress.base58) {
          try {
            setInstallFlag(true);
            setlogInFlag(true);
            setAddress(window.tronWeb.defaultAddress.base58); //TR9o7SXc9KqPrAxuBVb1gHMCykybxTK3GR
            let instance = await window.tronWeb
              .contract()
              .at(&quot;TAx8Jq65YhvXc5saxFsqfLzKEwbQ1EdK64&quot;);
            setContract(instance);
            const account = await window.tronWeb.trx.getAccount(
              window.tronWeb.defaultAddress.base58
            );
  
            if (account.assetV2) {
              const temBal = account.assetV2.find(
                (asset) =&gt; asset.key === &quot;1002357&quot;
              );
              if (temBal) {
                setAccountBal(temBal.value / 100);
              } else {
                setAccountBal(0);
              }
            } else {
              setAccountBal(0);
            }
  
            let bal = await instance
              .balanceOf(window.tronWeb.defaultAddress.base58)
              .call();
            setBalance(bal.toNumber() / 100);
            let prof = await instance
              .rewardscheck(window.tronWeb.defaultAddress.base58)
              .call();
            setProfit(prof.toNumber() / 100);
            let clamt = await instance.checkClaim().call();
            setClaim(clamt.toNumber() / 100);
          } catch (error) {
            const msg = error.message ? error.message : error;
          }
        } else {
          setInstallFlag(true);
          setlogInFlag(false);
        }
      } else {
        setInstallFlag(false);
        setlogInFlag(false);
      }
    };
  
  const login = () =&gt; {
    getAccount();
    setState('logged');
  }
  </code></pre>