mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #31 from spicyj/immutable-state
Change TodoMVC to not modify state in place
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user