Browse Source

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.
main
PNikray 10 years ago
parent
commit
5725676aa7
  1. 4
      _js/examples/todo.js

4
_js/examples/todo.js

@ -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…
Cancel
Save