Closed alienzhangyw closed 1 year ago
Sorry for any inconvenience.
autoConnect
is designed to work when selected wallet changes.
If there is a selected wallet and it is the wallet that the user want to connect, we can call connect()
.
If the selected wallet is not the wallet that the user want to connect, we can call select()
and it will automatically connect.
Before call select
method , we can judge that if the current selected wallet is we want to connect. If so just call connect()
.
Sorry for any inconvenience.
autoConnect
is designed to work when selected wallet changes. If there is a selected wallet and it is the wallet that the user want to connect, we can callconnect()
. If the selected wallet is not the wallet that the user want to connect, we can callselect()
and it will automatically connect.Before call
select
method , we can judge that if the current selected wallet is we want to connect. If so just callconnect()
.
Yeah, I've already handled this before. Just manually connect when selecting while adapter.name is the same
const handleSelect = useCallback((w: Wallet) => {
if (w.adapter.name === wallet?.adapter.name) {
connect();
} else {
select(w.adapter.name);
}
onClose();
}, [connect, onClose, select, wallet?.adapter.name]);
To reproduce:
Maybe you can uncomment this line to fix it. https://github.com/tronprotocol/tronwallet-adapter/blob/eaaac80af7de46efe05620ee9b2cc173a804ca4c/packages/react/react-hooks/src/WalletProvider.tsx#L241C38-L241C38
Manully connecting the wallet with
connect
fromuseWallet
also works badly. If I useconnect
just afterselect
, it will always connect to the last selected adapter.