Skip to content

Commit

Permalink
Merge pull request #2 from tian000/noah
Browse files Browse the repository at this point in the history
Only update state and rely on react to fire off reconnect
  • Loading branch information
nheingit committed Feb 8, 2023
2 parents ae948e4 + 17392f8 commit 19cb84f
Showing 1 changed file with 4 additions and 8 deletions.
Expand Up @@ -181,19 +181,15 @@ export function ConnectDetail({
downloadUrls?.qrCode && downloadUrls?.browserExtension;
const hasQrCode = qrCode && qrCodeUri;

const [isReady, setIsReady] = useState<boolean>(false);

const [isReady, setIsReady] = useState<boolean | undefined>(undefined);
// Check on component mount if the wallet is ready.
useEffect(() => {
wallet.connector.getProvider().then(provider => {
const isReady = provider;
if (!wasReady && isReady) {
// If the wallet was not ready, but now is ready attempt to connect
reconnect(wallet);
if (!wasReady && provider && isReady === undefined) {
setIsReady(!!provider);
}
setIsReady(isReady);
});
}, [wallet.connector, reconnect, wallet, wasReady]);
}, [wallet.connector, wallet, wasReady, isReady]);

const ready = wasReady || isReady;

Expand Down

0 comments on commit 19cb84f

Please sign in to comment.