Skip to content

Commit

Permalink
fix: Is wrong network modal persists when going back
Browse files Browse the repository at this point in the history
  • Loading branch information
memoyil committed Jan 3, 2025
1 parent cc102fe commit 24d0016
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions apps/web/src/hooks/useActiveChainId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ queryChainIdAtom.onMount = (set) => {

export function useLocalNetworkChain() {
const [queryChainId, setQueryChainId] = useAtom(queryChainIdAtom)
const { query } = useRouter()
const chainId = +(getChainId(query.chain as string) || queryChainId)
const { query, isReady } = useRouter()
const chainId = getChainId(query.chain as string)

useEffect(() => {
if (chainId) {
setQueryChainId(chainId)
if (isReady) {
if (chainId) {
if (queryChainId !== chainId) {
setQueryChainId(chainId)
}
} else if (queryChainId > 0) {
setQueryChainId(-1)
}
}
}, [chainId, setQueryChainId])
}, [chainId, isReady, queryChainId, setQueryChainId])

if (isChainSupported(chainId)) {
if (chainId && isChainSupported(chainId)) {
return chainId
}

Expand Down

0 comments on commit 24d0016

Please sign in to comment.