Mhmd Backer Shehadi
Mhmd Backer Shehadi

Reputation: 589

Reactjs key warning even key is set

console shows this warning even key is set on the child component:

bundle.js:2215 Warning: Each child in an array or iterator should have a unique "key" prop

code so far:

 var requestList = this.state.data.map(function (request,index) {
            return (
                <Requests key={request.id}  info={request} index={index}  trigger={this.triggerChildRequests}></Requests>
            );
        }.bind(this));

Upvotes: 1

Views: 300

Answers (1)

cxxsn
cxxsn

Reputation: 188

Maybe request.id is undefined, try to use index as component's key.

var requestList = this.state.data.map(function (request,index) {
            return (
                <Requests key={index}  info={request} index={index}  trigger={this.triggerChildRequests}></Requests>
            );
        }.bind(this));

Upvotes: 2

Related Questions