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:
parent
5714510ea4
commit
9c7f9b8de5
|
@ -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>;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue