function TodoItem()

in Output/Llama31_405B/JS/contextual_experiment/translate_to_react/1722507915/components/TodoItem.tsx [11:29]


function TodoItem({ id, title, completed }: Props) {
  const dispatch = useDispatch();

  const handleToggle = () => {
    dispatch(toggleTodo(id));
  };

  const handleRemove = () => {
    dispatch(removeTodo(id));
  };

  return (
    <li>
      <input type='checkbox' checked={completed} onChange={handleToggle} />
      <span style={{ textDecoration: completed ? 'line-through' : 'none' }}>{title}</span>
      <button onClick={handleRemove}>Remove</button>
    </li>
  );
}