I am trying to add an Edit button to each row of my react-table that opens up a Modal form that allows the user to save edits to different attributes of the row (some of which may or may not be displayed in the table). Upon clicking "save" in the Modal, a post request to the API is made and the row in the react-table is updated with the response.
I have attempted to add an onClick that calls a handleEdit function, but all that is passed to handleEdit is undefined? How can I access the row attributes (even the ones not being displayed in the table) and overwrite them with a new value?
Header: 'Action',
accessor: 'action',
Cell: row => (
<div>
<button onClick={row => handleEdit(row.original)}>Edit</button>
</div>
),
function handleEdit(row) {
console.log(row);
// display modal
// say user types in modal new firstName
// post request
// set row.firstName = newFirstName
}
Here is the sandbox: https://codesandbox.io/s/elated-currying-scvxk?fontsize=14&hidenavigation=1&theme=dark