diff options
author | Steve Klebanoff <steve@0xproject.com> | 2018-12-11 01:55:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-11 01:55:44 +0800 |
commit | 8d93413a5d49bcafe4b5d0dee359cc09afce7222 (patch) | |
tree | 38e94195c4ad669d8f91f958eae053780632e27c /packages | |
parent | a39e0f13be4d47ee79dd971d49835f6929fa71e7 (diff) | |
parent | 9d8ab43f916ba70ee979f80a94317541af547b8b (diff) | |
download | dexon-sol-tools-8d93413a5d49bcafe4b5d0dee359cc09afce7222.tar dexon-sol-tools-8d93413a5d49bcafe4b5d0dee359cc09afce7222.tar.gz dexon-sol-tools-8d93413a5d49bcafe4b5d0dee359cc09afce7222.tar.bz2 dexon-sol-tools-8d93413a5d49bcafe4b5d0dee359cc09afce7222.tar.lz dexon-sol-tools-8d93413a5d49bcafe4b5d0dee359cc09afce7222.tar.xz dexon-sol-tools-8d93413a5d49bcafe4b5d0dee359cc09afce7222.tar.zst dexon-sol-tools-8d93413a5d49bcafe4b5d0dee359cc09afce7222.zip |
Merge pull request #1409 from 0xProject/fix/instant/custom-erc20
[instant] Don't throw error if can't find icon for token
Diffstat (limited to 'packages')
-rw-r--r-- | packages/instant/src/components/erc20_token_selector.tsx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/packages/instant/src/components/erc20_token_selector.tsx b/packages/instant/src/components/erc20_token_selector.tsx index f7d5a4fe4..cb8a8c797 100644 --- a/packages/instant/src/components/erc20_token_selector.tsx +++ b/packages/instant/src/components/erc20_token_selector.tsx @@ -7,7 +7,6 @@ import { analytics } from '../util/analytics'; import { assetUtils } from '../util/asset'; import { SearchInput } from './search_input'; - import { Circle } from './ui/circle'; import { Container } from './ui/container'; import { Flex } from './ui/flex'; @@ -123,10 +122,20 @@ interface TokenSelectorRowIconProps { token: ERC20Asset; } +const getTokenIcon = (symbol: string): React.StatelessComponent | undefined => { + try { + return require(`../assets/icons/${symbol}.svg`) as React.StatelessComponent; + } catch (e) { + // Can't find icon + return undefined; + } +}; + const TokenSelectorRowIcon: React.StatelessComponent<TokenSelectorRowIconProps> = props => { const { token } = props; const iconUrlIfExists = token.metaData.iconUrl; - const TokenIcon = require(`../assets/icons/${token.metaData.symbol}.svg`); + + const TokenIcon = getTokenIcon(token.metaData.symbol); const displaySymbol = assetUtils.bestNameForAsset(token); if (!_.isUndefined(iconUrlIfExists)) { return <img src={iconUrlIfExists} />; |