Skip to content

Commit

Permalink
Checking if window object exists [ Next.JS fix ]
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Nov 30, 2022
1 parent ea2ecd2 commit 795fcf2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/helpers/provider/use-metamask.ts
Expand Up @@ -22,7 +22,7 @@ export const useMetamask = () => {

const connect = useCallback(async () => {
//@ts-ignore
if (window.ethereum) {
if (typeof window !== "undefined" && window?.ethereum) {
await provider.send('eth_requestAccounts', []);

await accountChangedHandler(provider.getSigner(0));
Expand All @@ -31,7 +31,7 @@ export const useMetamask = () => {
onConnect();
}
}
}, [accountChangedHandler, setProvider]);
}, [accountChangedHandler, setProvider, window]);

useEffect(() => {
const connectWalletOnPageLoad = async () => {
Expand Down

0 comments on commit 795fcf2

Please sign in to comment.