T
TanStack17mo ago
xenophobic-harlequin

How can I typecast these original rows

I am trying to calculate total number of persons when a filter changes, but im running into TypeScript errors, saying that .totalPersons : Property 'totalPersons' does not exist on type 'TData'.ts(2339) This is my code:
useEffect(() => {
if (filterValue) {
const filteredRows = table.getFilteredRowModel();
const original = filteredRows.rows.map((row) => row.original);

const totalPersons = original.reduce(
(acc, row) => acc + row.totalPersons,
0
);

console.log(totalPersons);
}
}, [filterValue, table]);
useEffect(() => {
if (filterValue) {
const filteredRows = table.getFilteredRowModel();
const original = filteredRows.rows.map((row) => row.original);

const totalPersons = original.reduce(
(acc, row) => acc + row.totalPersons,
0
);

console.log(totalPersons);
}
}, [filterValue, table]);
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?