Skip to content

Commit

Permalink
Merge pull request #31 from spicyj/immutable-state
Browse files Browse the repository at this point in the history
Change TodoMVC to not modify state in place
  • Loading branch information
petehunt committed May 31, 2013
2 parents b20a7c2 + 6e805dd commit bb4788e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/todomvc/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ var TodoApp = React.createClass({
var val = this.refs.newField.getDOMNode().value.trim();
if (val) {
var todos = this.state.todos;
todos.push({
var newTodo = {
id: Utils.uuid(),
title: val,
completed: false
});
this.setState({todos: todos});
};
this.setState({todos: todos.concat([newTodo])});
this.refs.newField.getDOMNode().value = '';
}
return false;
Expand Down

0 comments on commit bb4788e

Please sign in to comment.