From fc16281f3d0cae4b19be7435a339c788c2295969 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Thu, 25 May 2023 11:07:48 +0700 Subject: [PATCH] fix: faucet --- src/lib/app-provider/hooks/useNetworkChange.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/app-provider/hooks/useNetworkChange.ts b/src/lib/app-provider/hooks/useNetworkChange.ts index edaad7058..76c512961 100644 --- a/src/lib/app-provider/hooks/useNetworkChange.ts +++ b/src/lib/app-provider/hooks/useNetworkChange.ts @@ -15,13 +15,15 @@ export const useNetworkChange = ( ? getFirstQueryParam(router.query.network, DEFAULT_SUPPORTED_CHAIN_ID) : router.asPath.split("/")[1]; - // Redirect to default chain if the chain is not supported by the app - if (!SUPPORTED_CHAIN_IDS.includes(networkRoute)) - networkRoute = DEFAULT_SUPPORTED_CHAIN_ID; + if (router.isReady || router.pathname === "/404") { + // Redirect to default chain if the chain is not supported by the app + if (!SUPPORTED_CHAIN_IDS.includes(networkRoute)) + networkRoute = DEFAULT_SUPPORTED_CHAIN_ID; - if (networkRoute !== networkRef.current) { - networkRef.current = networkRoute; - handleOnChainIdChange(networkRoute); + if (networkRoute !== networkRef.current) { + networkRef.current = networkRoute; + handleOnChainIdChange(networkRoute); + } } }, [ handleOnChainIdChange,