'react table - passing row cell value to a function
I would like to call function and pass json element id value (column ID) to a function onBookAppointment().
I receive error message, id is not defined. I understand error message, but i do not know how to define it.
Data is coming from async function getData().
I would appreciate some guidance here.
PS! Learning react :)
const columns = React.useMemo(
() => [
{
Header: "ID",
accessor: "id", // accessor is the "key" in the data
},
{
Header: "Reserve",
accessor: "reserveButton",
Cell: row => (
<div>
<Button onClick={() => onBookAppointment(id)} variant="dark">{"product.add-appointment"}</Button>
</div>
),
},
],
[]
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
