import React from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { isEqual } from 'lodash'; import { getShouldHideZeroBalanceTokens } from '../../../selectors'; import { useTokenTracker } from '../../../hooks/useTokenTracker'; import Identicon from '../../ui/identicon'; import TokenBalance from '../../ui/token-balance'; import { useI18nContext } from '../../../hooks/useI18nContext'; import { getTokens } from '../../../ducks/metamask/metamask'; export default function TokenListDisplay({ clickHandler }) { const t = useI18nContext(); const shouldHideZeroBalanceTokens = useSelector( getShouldHideZeroBalanceTokens, ); const tokens = useSelector(getTokens, isEqual); const { loading, tokensWithBalances } = useTokenTracker( tokens, true, shouldHideZeroBalanceTokens, ); if (loading) { return
{t('loadingTokens')}
; } const sendableTokens = tokensWithBalances.filter((token) => !token.isERC721); return ( <> {sendableTokens.map((tokenData) => { const { address, symbol, image } = tokenData; return (
clickHandler(tokenData)} >
{symbol}
{`${t('balance')}:`}
); })} ); } TokenListDisplay.propTypes = { clickHandler: PropTypes.func, };