// Check if wallet is stored in localStorage
// it helps to handle the case when user refreshes the page
// and we don't know if wallet is connected or not
// while tonconnect is restoring wallet info
const isWalletStored = !!window?.localStorage.getItem(
'ton-connect-ui_wallet-info'
);
const wallet = useTonConnect();
console.log(wallet.connected, isWalletStored)
// false, true
// here I just example that in few seconds wallet
setTimeout(() => {
console.log(wallet.connected, isWalletStored)
// true, true
}, 10)
В react с @tonconnect есть проблема с проверкой подключен ли кошелек у пользователя или нет. Решение с isWalletStored, это то что я использую, дабы избежать разных лагов с авторизацией пользователя.
возможно у вас есть лучше способ узнать подключен ли кошелек пока tonconnect соединяется с ним, буду рад узнать 🍷