|
@@ -46,6 +46,7 @@ class App extends Component {
|
|
|
value: ""
|
|
|
};
|
|
|
this.handleAddItem = this.handleAddItem.bind(this);
|
|
|
+ this.handleRemoveItem = this.handleRemoveItem.bind(this);
|
|
|
this.handleToggleAllComplete = this.handleToggleAllComplete.bind(this);
|
|
|
this.handleToggleComplete = this.handleToggleComplete.bind(this);
|
|
|
this.setSource = this.setSource.bind(this);
|
|
@@ -66,6 +67,11 @@ class App extends Component {
|
|
|
this.setSource(newItems, newItems, { value: "" });
|
|
|
}
|
|
|
|
|
|
+ handleRemoveItem(key) {
|
|
|
+ const newItems = this.state.items.filter((item) => item.key !== key);
|
|
|
+ this.setSource(newItems, newItems);
|
|
|
+ }
|
|
|
+
|
|
|
handleToggleAllComplete() {
|
|
|
const complete = !this.state.allComplete;
|
|
|
const newItems = this.state.items.map((item) => ({
|
|
@@ -110,6 +116,7 @@ class App extends Component {
|
|
|
<Row
|
|
|
key={key}
|
|
|
onComplete={(complete) => this.handleToggleComplete(key, complete)}
|
|
|
+ onRemove={() => this.handleRemoveItem(key)}
|
|
|
{ ...value }
|
|
|
/>
|
|
|
);
|