gpt4 book ai didi

javascript - 为什么我的 key 重复?

转载 作者:行者123 更新时间:2023-12-03 04:46:04 24 4
gpt4 key购买 nike

这是我的渲染方法:

  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 不起作用的证据......

enter image description here

最佳答案

cell 属性应该是一个节点或函数,请参阅 this了解更多详情。

因此,将单元格更改为

cell={props => (
<Cell {...props}>
{rows[props.rowIndex].firstname}
</Cell>
)}

关于javascript - 为什么我的 key 重复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42869424/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com