Commit 779625a0 authored by Tina's avatar Tina Committed by GitHub

fix: chain parameter should be able to switch chains on initial load (#3180)

* fix switch network on load

* dont run useeffect when chainId isnt defined yet

* remove newline
parent d1e08126
...@@ -282,8 +282,10 @@ export default function NetworkSelector() { ...@@ -282,8 +282,10 @@ export default function NetworkSelector() {
) )
useEffect(() => { useEffect(() => {
if (!chainId || !prevChainId) return
// when network change originates from wallet or dropdown selector, just update URL // when network change originates from wallet or dropdown selector, just update URL
if (chainId && chainId !== prevChainId) { if (chainId !== prevChainId) {
history.replace({ search: replaceURLParam(history.location.search, 'chain', getChainNameFromId(chainId)) }) history.replace({ search: replaceURLParam(history.location.search, 'chain', getChainNameFromId(chainId)) })
// otherwise assume network change originates from URL // otherwise assume network change originates from URL
} else if (urlChainId && urlChainId !== chainId) { } else if (urlChainId && urlChainId !== chainId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment