mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
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:
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user