(id)
| 2 | |
| 3 | function TodoItems(props) { |
| 4 | function removeItem(id) { |
| 5 | //add selected item to the completed list |
| 6 | const found = props.list.find(element => element.id === id); |
| 7 | if (found) { |
| 8 | props.updateCompleted(found.task); |
| 9 | } |
| 10 | |
| 11 | //remove the item from the list |
| 12 | props.handleList(props.list.filter(item => item.id !== id)); |
| 13 | } |
| 14 | |
| 15 | const elements = props.list.map(item => ( |
| 16 | <Checkbox onChange={() => removeItem(item.id)} key={item.id} value={item.task}> |