diff --git a/src/layouts/NetworkLayout/NetworkLayout.tsx b/src/layouts/NetworkLayout/NetworkLayout.tsx index 0ce529b..85ffb58 100644 --- a/src/layouts/NetworkLayout/NetworkLayout.tsx +++ b/src/layouts/NetworkLayout/NetworkLayout.tsx @@ -14,7 +14,7 @@ import { import { alpha } from '@mui/system/colorManipulator'; import classnames from 'classnames'; import { Outlet } from 'react-router-dom'; -import { useDisconnect, useNetwork, useWalletClient } from 'wagmi'; +import { useDisconnect, useNetwork, useSwitchNetwork, useWalletClient } from 'wagmi'; import { Logo } from '@components/Logo'; import { NetworkSwitcher } from '@components/NetworkSwitcher'; @@ -261,9 +261,10 @@ export const NetworkLayout = ({ const { chain } = useNetwork(); const { disconnect } = useDisconnect(); const { network, switchAndReset } = useSubsquidNetwork(); + const { pendingChainId } = useSwitchNetwork(); useEffect(() => { - if (!isConnected || isLoading) return; + if (!isConnected || isLoading || pendingChainId) return; if (chain?.id === getChainId(network)) return; @@ -273,7 +274,7 @@ export const NetworkLayout = ({ } disconnect(); - }, [chain, disconnect, isConnected, network, isLoading, switchAndReset]); + }, [chain, disconnect, isConnected, network, isLoading, switchAndReset, pendingChainId]); const theme = useTheme(); const narrowLg = useMediaQuery(theme.breakpoints.down('lg'));