OnClick react-table component for column
I am using the "response-table" component https://react-table.js.org
I want to add a click event for one column (I will open a modal info display based on this event later).
+3
YO Developer
source
to share
2 answers
You add getTrProps to the ReactTable like in the example:
const onRowClick = (state, rowInfo, column, instance) => {
return {
onClick: e => {
console.log('A Td Element was clicked!')
console.log('it produced this event:', e)
console.log('It was in this column:', column)
console.log('It was in this row:', rowInfo)
console.log('It was in this table instance:', instance)
}
}
}
<ReactTable data={[]} columns={[]} getTrProps={onRowClick} />
+8
z0r0
source
to share
At the time of this writing, React-Table 6.8.0:
The "column" value in the getTrProps property is always undefined.
You need to use the getTdProps property instead.
+1
EwyynTomato
source
to share