Table.tsx 681 B

123456789101112131415161718192021222324
  1. import React, { PureComponent } from 'react';
  2. // import TableModel from 'app/core/table_model';
  3. const EMPTY_TABLE = {
  4. columns: [],
  5. rows: [],
  6. };
  7. export default class Table extends PureComponent<any, any> {
  8. render() {
  9. const { className = '', data } = this.props;
  10. const tableModel = data || EMPTY_TABLE;
  11. return (
  12. <table className={`${className} filter-table`}>
  13. <thead>
  14. <tr>{tableModel.columns.map(col => <th key={col.text}>{col.text}</th>)}</tr>
  15. </thead>
  16. <tbody>
  17. {tableModel.rows.map((row, i) => <tr key={i}>{row.map((content, j) => <td key={j}>{content}</td>)}</tr>)}
  18. </tbody>
  19. </table>
  20. );
  21. }
  22. }