Skip to content

Commit 9f4c8ef

Browse files
add conditional off for events
1 parent 1de748e commit 9f4c8ef

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/modal/src/react/context/Web3AuthInnerContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ export function Web3AuthInnerProvider(params: PropsWithChildren<Web3AuthProvider
7878
if (provider) {
7979
provider.on("chainChanged", handleChainChange);
8080
return () => {
81-
provider.off("chainChanged", handleChainChange);
81+
if (provider) {
82+
provider.off("chainChanged", handleChainChange);
83+
}
8284
};
8385
}
8486
}, [web3Auth, provider]);

packages/no-modal/src/react/context/Web3AuthInnerContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ export function Web3AuthInnerProvider(params: PropsWithChildren<Web3AuthProvider
7979
if (provider) {
8080
provider.on("chainChanged", handleChainChange);
8181
return () => {
82-
provider.off("chainChanged", handleChainChange);
82+
if (provider) {
83+
provider.off("chainChanged", handleChainChange);
84+
}
8385
};
8486
}
8587
}, [web3Auth, provider]);

0 commit comments

Comments
 (0)