diff options
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 ); |
