aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-11 01:00:05 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-13 01:19:31 +0800
commit8e071db074d3ad88a37d2cfc85780c995bc2cd17 (patch)
treeb8620d8858c2d342affc00532bf8ff77456166cd /packages
parent93422eab55f674ed33168a4731884e54d5a9ca78 (diff)
downloaddexon-sol-tools-8e071db074d3ad88a37d2cfc85780c995bc2cd17.tar
dexon-sol-tools-8e071db074d3ad88a37d2cfc85780c995bc2cd17.tar.gz
dexon-sol-tools-8e071db074d3ad88a37d2cfc85780c995bc2cd17.tar.bz2
dexon-sol-tools-8e071db074d3ad88a37d2cfc85780c995bc2cd17.tar.lz
dexon-sol-tools-8e071db074d3ad88a37d2cfc85780c995bc2cd17.tar.xz
dexon-sol-tools-8e071db074d3ad88a37d2cfc85780c995bc2cd17.tar.zst
dexon-sol-tools-8e071db074d3ad88a37d2cfc85780c995bc2cd17.zip
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.tsx13
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} />;