Skip to content Skip to sidebar Skip to footer

Each Child In An Array Or Iterator Should Have A Unique "key" Prop

was getting the warning message () in the below code using react.js. I checked answers on the stackoverflow and tried to remove the warning message but it didn't help. Made a separ

Solution 1:

You just need to add a unique key to the returned component from map. In your map function receive define another parameter as key and for each tr that you return just add key={key} as a prop.

<tbody>
      {list.map(function(value, key){
             return(<tr className="gradeA" role="row" key={key}>
                        <td className="sorting_1">{ value.id }</td>
                        <td>{value.name}</td>                          
                        <td>{value.location}</td>
                     </tr>);                                        
            })
        }       
</tbody>

Post a Comment for "Each Child In An Array Or Iterator Should Have A Unique "key" Prop"