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