BlockHeaders.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2017-2020 @polkadot/app-explorer authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import React, { useMemo } from 'react';
  5. import { HeaderExtended } from '@polkadot/api-derive';
  6. import { Table } from '@polkadot/react-components';
  7. import BlockHeader from './BlockHeader';
  8. import { useTranslation } from './translate';
  9. interface Props {
  10. headers: HeaderExtended[];
  11. }
  12. function BlockHeaders ({ headers }: Props): React.ReactElement<Props> {
  13. const { t } = useTranslation();
  14. const header = useMemo(() => [
  15. [t('recent blocks'), 'start', 3]
  16. ], [t]);
  17. return (
  18. <Table
  19. empty={t<string>('No blocks available')}
  20. header={header}
  21. >
  22. {headers
  23. .filter((header) => !!header)
  24. .map((header): React.ReactNode => (
  25. <BlockHeader
  26. key={header.number.toString()}
  27. value={header}
  28. />
  29. ))}
  30. </Table>
  31. );
  32. }
  33. export default React.memo(BlockHeaders);