React Table 7 - How to change the state of an individual button created dynamically by the React-Table API #2203
-
I am using React Table 7 to create a table with the first cell of each row being a ChecOut/CheckIn Button. My goal is to create a tool where people can CheckOut and CheckIn equipment. My React Table CodeSandbox The idea is that when a user clicks the button, it will change from My issue is changing the state of an individual button and which functional component to define it in. The {
Header: "CheckIn/Out",
Cell: ({ row }) => (
<Button
key={row.id}
id={row.id}
onClick={e => checkClick(e)}
value={checkButton.value}
>
{checkButton.value}
</Button>
)
} I tried passing a function to I basically built this on top of the editable table code available on the React-Table website React-Table Editable Data CodeSandbox , examples section React-Table Examples . Any help is much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
This can be done is an easier way (without jQuery) by dynamically adding a column. An example of this is shown in RowSelect where a new column in added to show checkboxes. Essentially update your
and provide a custom Button component. For eg,
|
Beta Was this translation helpful? Give feedback.
This can be done is an easier way (without jQuery) by dynamically adding a column. An example of this is shown in RowSelect where a new column in added to show checkboxes.
I forked your code here, https://codesandbox.io/s/react-table-checkin-checkout-uks4x.
Essentially update your
useTable()
toand provide a custom Button component. For eg,