我正在尝试将一个唯一的id添加到我创建的一组react-tables中。我创建了一个使用react-table的自定义组件。
我尝试将id prop添加到标签中,但没有起作用,我猜这是因为库中没有定义id prop?
return <ReactTable data={props.data} columns={columns} showPagination={false} minRows={5} style={{height :"400px"}} id='someId'/>;我希望这会将id属性添加到由react-table库创建的div中,但这并没有发生
发布于 2019-05-09 04:36:35
看起来React Table通过ReactTable元素上的getProps属性来处理这个问题,该属性接受一个应该返回您的自定义属性的回调。在您的render()函数中尝试下面的代码片段。
const customProps = { id: 'my-table-id' };
return (
<ReactTable
data={props.data}
columns={columns}
showPagination={false}
minRows={5}
style={{height :"400px"}}
getProps={() => customProps}
/>
);https://stackoverflow.com/questions/56048566
复制相似问题