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.
PNikray committed
Feb 26, 2015 at 19:37 UTC
9c7f9b8de52f51cc9df7d5117e0e974e6dec4e0d
1 file changed
+2
-2
docs/_js/examples/todo.js
+2
-2
@@ -1,8 +1,8 @@
1
var TODO_COMPONENT = `
2
var TodoList = React.createClass({
3
render: function() {
4
- var createItem = function(itemText) {
5
- return <li>{itemText}</li>;
4
+ var createItem = function(itemText, index) {
5
+ return <li key={index}>{itemText}</li>;
6
};
7
return <ul>{this.props.items.map(createItem)}</ul>;
8
}