Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Commit 3897b90

Browse files
committed
Merge pull request #31 from transedward/master
todoItem should be deleted if updated text is blank
2 parents be98281 + 6dfaead commit 3897b90

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

demos/todo/js/TodoItem.react.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,14 @@ var TodoItem = React.createClass({
9090
},
9191

9292
_stopEdit: function() {
93-
this.props.update(this.props.item.id, this.state.editText);
94-
this.setState({
93+
if (this.state.editText) {
94+
this.props.update(this.props.item.id, this.state.editText);
95+
this.setState({
9596
editing: false
96-
});
97+
});
98+
} else {
99+
this.props.destroy(this.props.item.id);
100+
}
97101
},
98102

99103
_removeItem: function() {

0 commit comments

Comments
 (0)