Skip to content

Commit 2a04c84

Browse files
committed
fixes #2 Add a key on Todo
1 parent 90c47f2 commit 2a04c84

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/components/Todo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var React = require('react');
22

3-
43
function Todo(props) {
54
return (
65
<li style={{

src/components/TodoList.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ var React = require('react');
33
var Todo = require('./Todo.js');
44

55
function TodoList(props) {
6-
var todoNodes = props.data.map(function(todo) {
7-
return (
8-
<Todo completed={todo.completed} text={todo.text} />
9-
);
10-
});
6+
var data = props.data;
117
return (
128
<div className="TodoList">
139
<ul>
14-
{todoNodes}
10+
{data.map(function(todo) {
11+
return <Todo key={todo.id} completed={todo.completed} text={todo.text} />
12+
})}
1513
</ul>
1614
</div>
1715
);

src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ var data = [
66
{id: 2, text: "Add data", completed: 1},
77
];
88

9-
109
var TodoApp = require('./components/TodoApp.js');
1110

1211
ReactDOM.render(

0 commit comments

Comments
 (0)