TokensList.js 1.05 KiB
Newer Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
Amaury Martiny's avatar
Amaury Martiny committed
// SPDX-License-Identifier: BSD-3-Clause
Axel Chalon's avatar
Axel Chalon committed
import React, { Component } from "react";
Axel Chalon's avatar
Axel Chalon committed
import TokenBalance from "./TokenBalance";
Axel Chalon's avatar
Axel Chalon committed
import { consumeTokens, provideTokens } from "../../contexts/TokensContext.js";
Axel Chalon's avatar
Axel Chalon committed

@provideTokens
@consumeTokens
class Tokens extends Component {
Axel Chalon's avatar
Axel Chalon committed
  render() {
    const { tokensArray, address } = this.props;
    // Show empty token placeholder if tokens have not been loaded yet
    const shownArray = tokensArray.length ? tokensArray : [{}];
    return (
Axel Chalon's avatar
Axel Chalon committed
      <div className="window_content">
        <div className="box -scroller">
          <ul className="list -padded">
Amaury Martiny's avatar
Amaury Martiny committed
            {shownArray.map((
              token,
              index // With empty tokens, the token.address is not defined, so we prefix with index
            ) => (
              <li key={`${index}-${token.address}`}>
                <TokenBalance token={token} />
              </li>
          </ul>
        </div>
      </div>
    );
  }
}

export default Tokens;