Skip to content

Commit

Permalink
Fix onConnect called twice with inApp social login in ConnectButton (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MananTank committed May 20, 2024
1 parent c494af8 commit a22eb5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-lemons-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix `onConnect` prop called twice when connecting inApp wallet using Social login
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type InAppWalletFormUIProps = {
export const InAppWalletFormUI = (props: InAppWalletFormUIProps) => {
const locale = props.locale;
const { chain, client, connectModal } = useConnectUI();
const { done, wallet } = props;
const { wallet } = props;
const setData = useSetSelectionData() as (
value: InAppWalletSelectUIState,
) => void;
Expand Down Expand Up @@ -134,10 +134,11 @@ export const InAppWalletFormUI = (props: InAppWalletFormUIProps) => {
connectionPromise: connectPromise,
},
});
props.select();

await connectPromise;
done();
props.select(); // show Connect UI

// Note: do not call done() here, it will be called InAppWalletSocialLogin component
// we simply trigger the connect and save promise here - its resolution is handled in InAppWalletSocialLogin
} catch (e) {
console.error(`Error sign in with ${strategy}`, e);
}
Expand Down

0 comments on commit a22eb5c

Please sign in to comment.