Skip to content

Commit 3103a93

Browse files
handleClearCompleted
1 parent e731f7a commit 3103a93

File tree

1 file changed

+6
-1
lines changed
  • ep13-clear-completed/app/components

1 file changed

+6
-1
lines changed

ep13-clear-completed/app/components/App.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export default class App extends React.Component {
4646
this.setState({ title: title });
4747
}
4848

49+
handleClearCompleted (event) {
50+
var newTodos = this.state.todos.filter((todo) => { return !todo.done});
51+
this.setState({ todos: newTodos });
52+
}
53+
4954
render () {
5055
return <div>
5156
<p> TODO </p>
@@ -58,7 +63,7 @@ export default class App extends React.Component {
5863
All: ({ this.state.todos.length }) |
5964
Completed: ({ this.state.todos.filter((todo) => { return todo.done }).length }) |
6065
Pending: ({ this.state.todos.filter((todo) => { return !todo.done }).length }) |
61-
<a href='#'>Clear Completed</a>
66+
<a href='#' onClick={this.handleClearCompleted.bind(this)}>Clear Completed</a>
6267
</p>
6368
<p>
6469
</p>

0 commit comments

Comments
 (0)