I have this in my code:
{
Header: "Amount",
accessor: "reward_amount",
Cell: ({ value }) => `$${value / 100.0}`,
}
So value is reward_amount, but I also need to look at another value on the row data in order to determine what the cell content should be.
Here's more of the code:
export default function myFunc(props) {
const [data, setData] = useState(props.stuff);
useEffect(() => {
setData(props.stuff);
}, [props.stuff]);
const columns = useMemo(
() => [
...
{
Header: "Amount",
accessor: "reward_amount",
Cell: ({ value }) => `$${value / 100.0}`,
},
...
],
[]
);
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } =
useTable(
{
columns,
data,
},
useRowSelect
);
return (...);
}
Cell: ({ value, anotherValue }) => value + anotherValue?valueisreward_value, ie. it's a different variable name. So I don't think I can access other values on the row like that.accessorthat gets the whole row as a prop.Cellfunction receives the row as an argument, and you're destructuringvaluefrom it. If you need additional properties from the row you should be able to destructure those too. Your current implementation is the equivalent of(row) => ${row.value / 100.0}.