Created
March 1, 2021 21:47
-
-
Save nafeu/45a38d3a71359489b7bdc94d1a47f493 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TableLayout = ({ | |
getTableProps, | |
getTableBodyProps, | |
headerGroups, | |
rows, | |
prepareRow, | |
state: { globalFilter }, | |
visibleColumns, | |
preGlobalFilteredRows, | |
setGlobalFilter | |
}) => { | |
return ( | |
<table {...getTableProps()}> | |
<thead> | |
<tr> | |
<th | |
colSpan={visibleColumns.length} | |
> | |
<GlobalFilter | |
preGlobalFilteredRows={preGlobalFilteredRows} | |
globalFilter={globalFilter} | |
setGlobalFilter={setGlobalFilter} | |
/> | |
</th> | |
</tr> | |
{headerGroups.map(headerGroup => ( | |
<tr {...headerGroup.getHeaderGroupProps()}> | |
{headerGroup.headers.map(column => ( | |
<th {...column.getHeaderProps(column.getSortByToggleProps())}> | |
{column.render('Header')} | |
<span> | |
{column.isSorted | |
? column.isSortedDesc | |
? ' ⬇️' | |
: ' ⬆️' | |
: ' ↕️'} | |
</span> | |
</th> | |
))} | |
</tr> | |
))} | |
</thead> | |
<tbody {...getTableBodyProps()}> | |
{rows.map((row, i) => { | |
prepareRow(row) | |
return ( | |
<tr {...row.getRowProps()}> | |
{row.cells.map(cell => { | |
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td> | |
})} | |
</tr> | |
) | |
})} | |
</tbody> | |
</table> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment