我的应用程序中有一个 react-table 组件,并传递下一个属性:
<ReactTable
data={this.props.words}
columns={columns}
getTrProps={changing_state_func}
/>
changing_state_func
是一个改变包装react-table的组件状态的函数。具体来说,此函数填充一个包含行数据对象 ID 的数组。所以我想突出显示包含这些 id 数据的行...无法弄清楚如何使用这个特定的数据网格来做到这一点。也许有人有在这种情况下使用react-table和示例的经验。
最佳答案
我不确定你到底想做什么,但这是我的想法。
getTrProps
用于将 props 传递到表的行。
所以根据the module docs ,你可以传递任何你想要的东西。
该示例展示了如何更改满足特定条件的行的颜色:
// Any Tr element will be green if its (row.age > 20)
<ReactTable
getTrProps={(state, rowInfo, column) => {
return {
style: {
background: rowInfo.age > 20 ? 'green' : 'red'
}
}
}}
/>
关于reactjs - 如何重新渲染 react 表中的整个单行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42025991/