diff options
| author | Haishan <[email protected]> | 2020-01-04 17:16:58 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2020-01-07 22:10:50 +0800 |
| commit | dfbdee474979b21249461f270edfa0225994f298 (patch) | |
| tree | 15368a9ef8f89753274edcadd0c1d52fc9fde45e /src/components/ConnectionTable.js | |
| parent | f7d5a770fff4d8c2ebd2f1d7569e2626205818df (diff) | |
chore: initially sort connections by id
Diffstat (limited to 'src/components/ConnectionTable.js')
| -rw-r--r-- | src/components/ConnectionTable.js | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/components/ConnectionTable.js b/src/components/ConnectionTable.js index 3fc0219..d2afd22 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,38 +34,23 @@ function renderCell(cell, now) { } } -// const sortById = { id: 'id', desc: true }; -// const sortByStart = { id: 'start', desc: true }; -// 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; -// } +const sortById = { id: 'id', desc: true }; +const tableState = { + sortBy: [ + // maintain a more stable order + sortById + ], + hiddenColumns: ['id'] +}; function Table({ data }) { const now = new Date(); const { getTableProps, headerGroups, rows, prepareRow } = useTable( { columns, - data - // initialState: tableState, - // reducer: tableReducer + data, + initialState: tableState, + autoResetSortBy: false }, useSortBy ); |
