@samitouri / QOS-React-2 / commits / 6e805dda24
Fork 0

The library for web and native user interfaces.

Change TodoMVC to not modify state in place

Instead, use .concat and make a new todos array. Test Plan: Added todo items successfully.

Ben Alpert committed May 30, 2013 at 17:42 UTC 6e805dda24a4b8ed53379f4aea9e15370512ad54
1 file changed +3 -3
examples/todomvc/js/app.js
+3 -3
@@ -98,12 +98,12 @@ var TodoApp = React.createClass({
98 var val = this.refs.newField.getDOMNode().value.trim();
99 if (val) {
100 var todos = this.state.todos;
101 - todos.push({
101 + var newTodo = {
102 id: Utils.uuid(),
103 title: val,
104 completed: false
105 - });
106 - this.setState({todos: todos});
105 + };
106 + this.setState({todos: todos.concat([newTodo])});
107 this.refs.newField.getDOMNode().value = '';
108 }
109 return false;