how to update state by onclick function on column item #4806
Unanswered
Sumonche016
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
` export const columns=[ {
Header: () => <div style={{ textAlign: "center" }}>Stats,
accessor: "emailTracks",
Cell: ({ row }) => {
const emailTracks = row.original?.emailTracks;
const openRateSum = emailTracks?.reduce(
(acc, curr) => acc + (curr.openRate ?? 0),
0
);
const clickRateSum = emailTracks?.reduce(
(acc, curr) => acc + (curr.clickRate ?? 0),
0
);
const replyRate = emailTracks?.reduce(
(acc, curr) => acc + (curr.reply ? 1 : 0),
0
);
}]
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({ columns, data });
{ // Loop over the table rows rows.map((row) => { // Prepare the row for display prepareRow(row); return ( // Apply the row props { // Loop over the rows cells row.cells.map((cell) => { // Apply the cell props return ( { // Render the cell contents cell.render("Cell") } ); }) } ); }) }`
Beta Was this translation helpful? Give feedback.
All reactions