File size: 594 Bytes
cce8120 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import React from 'react';
function TodoList({ todos, onToggle, onDelete }) {
return (
<ul>
{todos.map(todo => (
<li key={todo.id} style={{ textDecoration: todo.completed ? 'line-through' : 'none' }}>
<input
type="checkbox"
checked={todo.completed}
onChange={() => onToggle(todo.id, !todo.completed)}
/>
{todo.title}
<button onClick={() => onDelete(todo.id)} style={{ marginLeft: '1rem' }}>
Delete
</button>
</li>
))}
</ul>
);
}
export default TodoList;
|