Wallet adapter refresh will lead to couple ms loading where wallet info's not loaded yet
jillxuu opened this issue · 3 comments
When refreshing the page, wallet adapter will be refreshed as well and the wallet info takes milliseconds to get loaded. During that period, we see wallet button content change from wallet address to "Connect Wallet" as if wallets were not connected.
Would suggest to have a more graceful way to handle the wallet adapter reloading.
wallet adapter nextjs example:
Screen.Recording.2023-02-21.at.3.10.47.PM.mov
ANS:
Screen.Recording.2023-02-21.at.3.11.11.PM.mov
Explorer:
Screen.Recording.2023-02-21.at.3.11.21.PM.mov
When I refresh the page, I try to use the isLoading
variable but as you can see in the photo, it is not sync with address data received. isLoading
is false when address
is null
.
try {
setIsLoading(true);
walletCore.connect(walletName);
} catch (e) {
console.log("connect error", e);
} finally {
setIsLoading(false);
}
As I see in the source code, isLoading
variable set to false before the function walletCore.connect(walletName);
finish right? @0xmaayan
@theodao interesting, it might be because we need to await
here https://github.com/aptos-labs/aptos-wallet-adapter/blob/main/packages/wallet-adapter-react/src/WalletProvider.tsx#L56