Table = {
return function Table({ columns, data }) {
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
} = ReactTable.useTable({
columns,
data,
})
return htm`
<table ...${getTableProps()}>
<thead>
${headerGroups.map(headerGroup => (
htm`<tr ...${headerGroup.getHeaderGroupProps()}>
${headerGroup.headers.map(column => (
htm`<th ...${column.getHeaderProps()}>${column.render('Header')}</th>`
))}
</tr>`
))}
</thead>
<tbody ...${getTableBodyProps()}>
${rows.map((row, i) => {
prepareRow(row)
return htm`
<tr ...${row.getRowProps()}>
${row.cells.map(cell => {
return htm`<td ...${cell.getCellProps()}>${cell.render('Cell')}</td>`
})}
</tr>
`
})}
</tbody>
</table>
`
}
}