react-table component onClick event for a column

后端 未结 2 1724
陌清茗
陌清茗 2021-01-02 22:29

I am using the \'react-table\' component https://react-table.js.org

I want to add on click event for one column (later I will open a modal showing info based on this

2条回答
  •  情书的邮戳
    2021-01-02 22:57

    You add getTrProps to ReactTable like 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)
            }
        }
    }
    
    
    
    

提交回复
热议问题