Added the key attribute into the todo example

This is to solve the warning (that the key should be set) that was being raised when adding a new item.
This commit is contained in:
PNikray 2015-02-26 19:37:05 +01:00
parent 5714510ea4
commit 9c7f9b8de5
1 changed files with 2 additions and 2 deletions

View File

@ -1,8 +1,8 @@
var TODO_COMPONENT = `
var TodoList = React.createClass({
render: function() {
var createItem = function(itemText) {
return <li>{itemText}</li>;
var createItem = function(itemText, index) {
return <li key={index}>{itemText}</li>;
};
return <ul>{this.props.items.map(createItem)}</ul>;
}