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
This commit is contained in:
parent
d1e0812684
commit
779625a04e
@ -282,8 +282,10 @@ export default function NetworkSelector() {
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!chainId || !prevChainId) return
|
||||
|
||||
// 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)) })
|
||||
// otherwise assume network change originates from URL
|
||||
} else if (urlChainId && urlChainId !== chainId) {
|
||||
|
Loading…
Reference in New Issue
Block a user