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.
David Hellsing committed
Nov 26, 2013 at 18:07 UTC
a79ef7fc29e4c58ebfc32aa96e7099cff1f5807a
1 file changed
+1
-1
examples/todomvc-backbone/js/app.js
+1
-1
@@ -236,7 +236,7 @@ var TodoApp = React.createClass({
236
var todoItems = this.props.todos.map(function(todo) {
237
return (
238
<TodoItem
239
- key={Math.random()}
239
+ key={todo.cid}
240
todo={todo}
241
onToggle={todo.toggle.bind(todo)}
242
onDestroy={todo.destroy.bind(todo)}