Reputation: 4380
In React-table, I have an accessor
as the function. I am using useFilter
to filter out the data, but it always returns an empty array.
Example Link: https://codesandbox.io/s/admiring-surf-78uz4
Upvotes: 0
Views: 1011
Reputation: 988
I think you have misunderstood what the accessor
is supposed to do. You are returning a React Element/JSX, and according to the docs,
The data returned by an accessor should be primitive and sortable.
To render the first cell as a link, change the accessor
to "firstName", and modify the tr
inside your tbody
like this:
<tr {...row.getRowProps()}>
{row.cells.map((cell, i) => {
const renderedCell = cell.render("Cell");
return (
<td {...cell.getCellProps()}>
{i ? renderedCell : <a href="#">{renderedCell}</a>}
</td>
);
})}
</tr>
Upvotes: 1