-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4057863
commit 68c62cf
Showing
4 changed files
with
162 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useEffect, useRef } from 'react' | ||
import { useAccount, useNetwork } from 'wagmi' | ||
|
||
export default function NetworkListener() { | ||
const { chain } = useNetwork() | ||
const currentChain = useRef(chain?.id) | ||
|
||
useEffect(() => { | ||
if (chain?.id && currentChain.current && chain.id !== currentChain.current) { | ||
window.location.reload() | ||
} | ||
}, [chain]) | ||
|
||
return <></> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import type { AppProps } from "next/app"; | ||
import AppConfig from "../components/AppConfig"; | ||
import Layout from "../components/Layout"; | ||
import "../styles/globals.css"; | ||
import NetworkListener from 'components/NetworkListener' | ||
import type { AppProps } from 'next/app' | ||
import AppConfig from '../components/AppConfig' | ||
import Layout from '../components/Layout' | ||
import '../styles/globals.css' | ||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
return ( | ||
<> | ||
<AppConfig> | ||
<NetworkListener /> | ||
<Layout> | ||
<Component {...pageProps} /> | ||
</Layout> | ||
</AppConfig> | ||
</> | ||
); | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters