Changed key from Math.random() to todo.cid

It doesn’t make much sense to generate a random key for each todo render, because it will re-draw all todo’s DOM nodes on each model change. I changed it to the unique identifier ``todo.cid`` already supplied by the backbone model.
This commit is contained in:
David Hellsing
2013-11-26 18:07:56 +01:00
parent 564c8669f8
commit a79ef7fc29
+1 -1
View File
@@ -236,7 +236,7 @@ var TodoApp = React.createClass({
var todoItems = this.props.todos.map(function(todo) {
return (
<TodoItem
key={Math.random()}
key={todo.cid}
todo={todo}
onToggle={todo.toggle.bind(todo)}
onDestroy={todo.destroy.bind(todo)}