From 789700cf60ac40d4cc2742c8aa735a225089c522 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 1 Nov 2023 15:56:00 -0700 Subject: [PATCH] [React] Fix sign in button display logic (#1888) --- .changeset/fresh-toys-remember.md | 5 +++++ .../react/src/wallet/ConnectWallet/ConnectWallet.tsx | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/fresh-toys-remember.md diff --git a/.changeset/fresh-toys-remember.md b/.changeset/fresh-toys-remember.md new file mode 100644 index 00000000000..f7412042c95 --- /dev/null +++ b/.changeset/fresh-toys-remember.md @@ -0,0 +1,5 @@ +--- +"@thirdweb-dev/react": patch +--- + +Fix sign in connect button display logic diff --git a/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx b/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx index 5a13e7cccdb..cd69822b052 100644 --- a/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx +++ b/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx @@ -169,12 +169,14 @@ export const ConnectWallet: React.FC = (props) => { const { user } = useUser(); const disconnect = useDisconnect(); - const shouldSignIn = !!authConfig?.authUrl && !!address && !user?.address; - const addressAndUserAddressMismatched = address !== user?.address; + const connectedButNotSignedIn = + !!authConfig?.authUrl && + !!address && + (!user?.address || address !== user?.address); const requiresSignIn = props.auth?.loginOptional ? false - : shouldSignIn || addressAndUserAddressMismatched; + : connectedButNotSignedIn; const supportedTokens = useMemo(() => { if (!props.supportedTokens) { @@ -195,10 +197,10 @@ export const ConnectWallet: React.FC = (props) => { // if wallet gets disconnected, close the signature modal useEffect(() => { - if (!activeWallet && !addressAndUserAddressMismatched) { + if (!activeWallet) { setShowSignatureModal(false); } - }, [activeWallet, addressAndUserAddressMismatched]); + }, [activeWallet]); return (