私のアプリが警告を持っていることを言う:Each child in an array or iterator should have a unique "key" prop. Check the render method of 'SortableTable'
聞くが、私のSortableTableファイルです:ユニークな「キー」小道具は、メソッドをレンダリング - ReactJS
import React from 'react';
import {Link} from 'react-router';
import {v4 as uuid} from 'node-uuid';
export default class SortableTable extends React.Component {
render() {
return (
<table style={{width: '100%'}} className={this.props.className} id={this.props.id}>
<thead>
<tr>
{this.props.headers.map(this.generateHeaders)}
</tr>
</thead>
<tbody>
{this.props.children}
</tbody>
</table>
);
}
generateHeaders = (value) => {
if (Object.keys(value).length === 0) return
let sort, colspan
if(value.sort) {
let {query} = this.props;
let nQuery, title, icon, colspan = 1;
if(query.sort === value.sort && query.sortDirection === 'desc') {
nQuery = Object.assign({}, query, {sort: value.sort, sortDirection: 'asc', page: 1})
title = 'asc';
icon = String.fromCharCode(0xe630)
} else {
nQuery = Object.assign({}, query, {sort: value.sort, sortDirection: 'desc', page: 1})
title = 'desc';
icon = String.fromCharCode(0xe62d)
}
sort = <Link to={this.props.link} query={nQuery} className="icon order active" title={title} data-icon={icon} />
}
let className = value.className ? value.className : ''
if(value.colspan) {
colspan = value.colspan
}
return <th className={className} colSpan={colspan}><span>{value.name}</span>{sort}</th>
}
誰かがこの警告を解決するために、キー小道具を設定する方法私を見ることができますか?
@Pavlo、Tom Fenech、Oleg Kutsenkoに感謝します。なぜ私はすべての名前にタグを付けることができないのですか?私の問題は解決しました。 :)) – vietanhyt
この質問を今後の訪問者に役立てたい場合は、一番好きな回答を受け入れてください(各回答の左に目盛りがあります)。あなたはまた、これからいくつかの評判を得るでしょう。 – Pavlo
ここにすべての答えが正しいです。 :D しかし、もう1つの質問[上記のSortableTableファイルの同じディレクトリにある別のファイルに関連しています]があります。私は主題に似ているので、新しい質問を発表したくない - キーの小道具がない。私は[ここ](http://textuploader.com/5i66s)にファイルの内容を投稿してください助けてください!私はインデックスのパラメータを追加しようとしましたが、うまくいきませんでした! – vietanhyt