这是我的渲染方法:
render: function() {
var rows = this.state.users;
return (
<div className="container">
<dl className="row">
<div className="col-md-12">
<Table
rowHeight={50}
rowsCount={rows.length}
width={800}
height={500}
headerHeight={50}>
<Column
header={<Cell>First Name</Cell>}
cell={(_.map(rows, function(row) {
return <Cell key={row.id}>{row.firstname}</Cell>;
}))}
width={200}
/>
</Table>
<button type="button" onClick={this.formPopup}>Add User</button>
</div>
</dl>
</div>
);
为什么 View 仍然显示重复项? 这是完整代码的链接:https://github.com/DannyGarciaMartin/react-webpack/blob/master/js/source/comp/UserView.jsx
我不明白。我的映射不应该与固定数据表的输入呈现进行区分吗?
这是一张图片作为 key 不起作用的证据......
最佳答案
cell
属性应该是一个节点或函数,请参阅 this了解更多详情。
因此,将单元格
更改为
cell={props => (
<Cell {...props}>
{rows[props.rowIndex].firstname}
</Cell>
)}
关于javascript - 为什么我的 key 重复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42869424/