Commit 2fd1cd72 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: bug with network with no info (#4489)

* fix bug with network with no info

* remove unneeded check

* add null checks

* check info for supported case
Co-authored-by: default avatarCharlie <charlie@uniswap.org>
parent 3a2276dc
......@@ -12,7 +12,6 @@ import { subhead } from 'nft/css/common.css'
import { themeVars, vars } from 'nft/css/sprinkles.css'
import { useIsMobile } from 'nft/hooks'
import { ReactNode, useReducer, useRef } from 'react'
import { isChainAllowed } from 'utils/switchChain'
import * as styles from './ChainSwitcher.css'
import { NavDropdown } from './NavDropdown'
......@@ -73,17 +72,16 @@ export const ChainSwitcher = ({ leftAlign }: ChainSwitcherProps) => {
const selectChain = useSelectChain()
useSyncChainQuery()
if (!chainId || !info) {
if (!chainId) {
return null
}
const isSupported = isChainAllowed(chainId)
const isSupported = !!info
const dropdown = (
<NavDropdown top={54} leftAligned={leftAlign} paddingBottom={8} paddingTop={8}>
<Column marginX="8">
{NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) =>
isSupported ? (
{NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) => (
<ChainRow
onSelectChain={async (targetChainId: SupportedChainId) => {
await selectChain(targetChainId)
......@@ -92,8 +90,7 @@ export const ChainSwitcher = ({ leftAlign }: ChainSwitcherProps) => {
targetChain={chainId}
key={chainId}
/>
) : null
)}
))}
</Column>
</NavDropdown>
)
......@@ -111,7 +108,7 @@ export const ChainSwitcher = ({ leftAlign }: ChainSwitcherProps) => {
<>
<TokenWarningRedIcon fill={themeVars.colors.darkGray} width={24} height={24} />
<Box as="span" className={subhead} display={{ sm: 'none', xl: 'flex' }} style={{ lineHeight: '20px' }}>
{info?.label ?? 'Unsupported'}
Unsupported
</Box>
</>
) : (
......
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