-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTodoListItem.js
51 lines (44 loc) · 1.38 KB
/
TodoListItem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from "react";
export default class TodoListItem extends React.Component {
constructor(props) {
super(props);
this.onCheckboxChange = this.onCheckboxChange.bind(this);
this.onRemoveClick = this.onRemoveClick.bind(this);
}
onCheckboxChange(event) {
// TODO(#18) Call this.props.onToggle with the todo ID.
// hint: How can you access the todo ID?
}
onRemoveClick(event) {
// TODO(#25) Call this.props.onRemove with the todo ID.
}
render() {
const id = `todo-id-${this.props.todo.id}`;
let className = "list-group-item d-flex justify-content-between align-items-center";
if (this.props.todo.isComplete) {
className += " list-group-item-success";
}
return (
<li className={className}>
<div className="form-check form-check-inline">
<input
id={id}
className="form-check-input"
type="checkbox"
checked={/* TODO(#19) Use the correct todo property. */}
onChange={/* TODO(#20) Use the correct event handler. */}
/>
<label htmlFor={id} className="form-check-label">
{this.props.todo.text}
</label>
</div>
<button
className="btn btn-danger btn-sm"
onClick={/* TODO(#26) Use the correct event handler */}
>
remove
</button>
</li>
);
}
}