diff options
| author | Haishan <[email protected]> | 2019-12-21 22:47:04 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2019-12-21 22:47:04 +0800 |
| commit | 1ab5ac02e6cb027d7c6071f9fda4859c92d50f04 (patch) | |
| tree | 9352ca6649f2e0306d693404acbe93e176f66298 /src/components/ConnectionTable.js | |
| parent | 5f032aa0a8a8986a12b1465f3e8fe438bf4d8ea0 (diff) | |
fix: connections table header data miss alignment
Diffstat (limited to 'src/components/ConnectionTable.js')
| -rw-r--r-- | src/components/ConnectionTable.js | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/src/components/ConnectionTable.js b/src/components/ConnectionTable.js index 722ef8b..8438b23 100644 --- a/src/components/ConnectionTable.js +++ b/src/components/ConnectionTable.js @@ -8,7 +8,7 @@ import { useTable, useSortBy } from 'react-table'; import s from './ConnectionTable.module.css'; const columns = [ - { accessor: 'id', show: false }, + // { accessor: 'id', show: false }, { Header: 'Host', accessor: 'host' }, { Header: 'Download', accessor: 'download' }, { Header: 'Upload', accessor: 'upload' }, @@ -34,43 +34,38 @@ function renderCell(cell, now) { } } -const sortById = { id: 'id', desc: true }; +// const sortById = { id: 'id', desc: true }; // const sortByStart = { id: 'start', desc: true }; -const tableState = { - sortBy: [ - // maintain a more stable order - sortById - ] -}; +// const tableState = { +// sortBy: [ +// // maintain a more stable order +// sortById +// ], +// hiddenColumns: ['id'] +// }; -function tableReducer(newState, action, _prevState) { - const { type } = action; - if (type === 'toggleSortBy') { - const { sortBy = [] } = newState; - if (sortBy.length === 0) { - return { - ...newState, - sortBy: [sortById] - }; - } - } - return newState; -} +// function tableReducer(newState, action, _prevState) { +// const { type } = action; +// if (type === 'toggleSortBy') { +// const { sortBy = [] } = newState; +// if (sortBy.length === 0) { +// return { +// ...newState, +// sortBy: [sortById] +// }; +// } +// } +// return newState; +// } function Table({ data }) { const now = new Date(); - const { - getTableProps, - // getTableBodyProps, - headerGroups, - rows, - prepareRow - } = useTable( + const { getTableProps, headerGroups, rows, prepareRow } = useTable( { columns, - data, - initialState: tableState, - reducer: tableReducer + data + // initialState: tableState, + // reducer: tableReducer }, useSortBy ); |
