Sorting bug with the HTML <i> element
Describe the bug (required)
I'm trying to use an html <i> element with a custom icon. It will sort on the first two clicks and then it will blow up with an error similar to this SO question: https://stackoverflow.com/questions/54880669/react-domexception-failed-to-execute-removechild-on-node-the-node-to-be-re
My table head looks like this:
<th {...column.getHeaderProps(column.getSortByToggleProps())} className='text-center'>
{column.render('Header')}
<span >
{column.isSorted ? (column.isSortedDesc ? <i className="fas fa-sort-down ml-1 text-secondary"></i> : <i className="fas fa-sort-up ml-1 text-secondary"></i> ) : ''}
</span>
</th>
My table config looks like this:
const data = React.useMemo(
() => rows.map((project) => {
return project
}), [rows])
const columns = React.useMemo(
() => [
{
Header: () => null,
disableSortBy: true
},
{
Header: 'Name',
accessor: 'name',
sortType: 'basic'
},
{
Header: 'Description',
accessor: 'projectDescription',
},
},
], []
)
const {
getTableProps,
getTableBodyProps,
headerGroups,
prepareRow,
page,
canPreviousPage,
canNextPage,
pageOptions,
pageCount,
gotoPage,
nextPage,
previousPage,
setPageSize,
state: { pageIndex, pageSize },
} = useTable({ columns, data, initialState: { pageIndex: 0, pageSize: 15 }}, useSortBy, usePagination)
Some things to note:
- The icons always return the second icon (
fa-sort-up). It returns the second icon regardless of the booleancolumn.isSortedDescvalue. - I've used this logic with version 7.2 on another project and had no problems. (I was using a SVG and not the
<i>element if that makes a difference?) - Bug happens with both version 7.2.2 and 7.6.2
Provide an example via Codesandbox! (required) Wish I had time to set this up in codesandbox but I don't because i've spent too much time trying to figure out this bug.
Ugh, here is the reason why: https://stackoverflow.com/questions/48358529/failed-to-execute-removechild-on-node-with-fontawesome-in-react
It was a FontAwesome problem, not react-table. Sorry! (hopefully somebody in the future finds this helpful)