Skip to content

Commit 553f7fd

Browse files
authored
[react] Remove unnecessary ConnectModal opening (#2375)
1 parent bc198e2 commit 553f7fd

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

.changeset/silly-moles-punch.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@thirdweb-dev/react": patch
3+
---
4+
5+
Remove unnecessary ConnectModal auto opening.
6+
7+
This also fixes the issue where Connect Modal opens on page load when `ThirdwebProvider` is dynamically imported and rendered in the app.

packages/react/src/wallet/ConnectWallet/Modal/ConnectModal.tsx

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
useDisconnect,
1010
useThirdwebAuthContext,
1111
useUser,
12-
useWallet,
1312
useWalletContext,
1413
useWallets,
1514
} from "@thirdweb-dev/react-core";
@@ -241,41 +240,8 @@ export const ConnectModal = () => {
241240
});
242241
}, [initialScreen, setIsWalletModalOpen, setScreen]);
243242

244-
const [prevConnectionStatus, setPrevConnectionStatus] =
245-
useState(connectionStatus);
246-
247-
useEffect(() => {
248-
setPrevConnectionStatus(connectionStatus);
249-
}, [connectionStatus]);
250-
251243
const disconnect = useDisconnect();
252244

253-
const wallet = useWallet();
254-
const isWrapperConnected = !!wallet?.getPersonalWallet();
255-
256-
const isWrapperScreen =
257-
typeof screen !== "string" && !!screen.personalWallets;
258-
259-
// reopen the screen to complete wrapper wallet's next step after connecting a personal wallet
260-
useEffect(() => {
261-
if (
262-
!isWrapperConnected &&
263-
isWrapperScreen &&
264-
!isWalletModalOpen &&
265-
connectionStatus === "connected" &&
266-
prevConnectionStatus === "connecting"
267-
) {
268-
setIsWalletModalOpen(true);
269-
}
270-
}, [
271-
isWalletModalOpen,
272-
connectionStatus,
273-
setIsWalletModalOpen,
274-
isWrapperScreen,
275-
isWrapperConnected,
276-
prevConnectionStatus,
277-
]);
278-
279245
useEffect(() => {
280246
if (!isWalletModalOpen) {
281247
onModalUnmount(() => {

0 commit comments

Comments
 (0)