簡體   English   中英

為什么我的密鑰重復?

[英]Why are my keys duplicating?

這是我的渲染方法:

  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>
    );

為什么視圖仍顯示重復項? 這是完整代碼的鏈接: https : //github.com/DannyGarciaMartin/react-webpack/blob/master/js/source/comp/UserView.jsx

我不明白 我的映射不應該與固定數據表的輸入內容區分開嗎?

這是一個圖像,證明按鍵不起作用...

在此處輸入圖片說明

cell prop應該是節點或函數,請參閱以獲取更多詳細信息。

因此,將cell更改為

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM