Created
November 6, 2021 13:24
-
-
Save dayhaysoos/2fa146d61435da09d81e1ff5e560e2da 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
| // column | |
| const columns = React.useMemo( | |
| () => [ | |
| { | |
| id: 'expander', | |
| accessor: '', | |
| Header: ({ getToggleAllRowsExpandedProps, isAllRowsExpanded }) => ( | |
| <span {...getToggleAllRowsExpandedProps()}> | |
| {isAllRowsExpanded ? 'π' : 'π'} | |
| </span> | |
| ), | |
| Cell: ({ row }) => { | |
| return ( | |
| // Use the row.canExpand and row.getToggleRowExpandedProps prop getter | |
| // to build the toggle for expanding a row | |
| row.canExpand ? ( | |
| <span | |
| {...row.getToggleRowExpandedProps({ | |
| style: { | |
| // We can even use the row.depth property | |
| // and paddingLeft to indicate the depth | |
| // of the row | |
| paddingLeft: `${row.depth * 2}rem` | |
| } | |
| })} | |
| > | |
| {row.isExpanded ? 'π' : 'π'} | |
| </span> | |
| ) : null | |
| ) | |
| } | |
| }, | |
| { | |
| Header: 'UID', | |
| accessor: 'id', | |
| disableFilters: true, | |
| Cell: function UID(props) { | |
| return props.value.split('-')[0] | |
| } | |
| }, | |
| { | |
| Header: 'Country', | |
| accessor: 'country' | |
| }, | |
| { | |
| Header: 'Education', | |
| accessor: 'education' | |
| }, | |
| { | |
| Header: 'Experience', | |
| accessor: 'years_of_exp' | |
| }, | |
| { | |
| Header: 'Skills', | |
| accessor: 'skills', | |
| Filter: TagFilter, | |
| Cell: function Skill(props) { | |
| return <Skills skills={props.value} /> | |
| } | |
| } | |
| ], | |
| [] | |
| ) | |
| // usetable hook | |
| const { | |
| getTableProps, | |
| getTableBodyProps, | |
| headerGroups, | |
| rows, | |
| prepareRow, | |
| state, | |
| state: { expanded }, | |
| visibleColumns, | |
| preGlobalFilteredRows, | |
| setGlobalFilter | |
| } = useTable( | |
| { | |
| columns, | |
| data, | |
| defaultColumn, | |
| filterTypes, | |
| useState | |
| }, | |
| useGlobalFilter, // useGlobalFilter! | |
| useFilters, | |
| useExpanded | |
| ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
π Aight I'll hit you up tomorrow on twitter!