function Todo()

in Output/Llama31_405B/JS/contextual_experiment/translate_to_react/1722507915/components/Todo.tsx [7:27]


function Todo() {
  const todos = useSelector((state: any) => state.todos);
  const dispatch = useDispatch();

  const handleClearCompleted = () => {
    dispatch(clearCompleted());
  };

  return (
    <div>
      <TodoForm />
      <TodoList />
      {todos.length > 0 && (
        <div>
          <p>{todos.filter((todo: any) => !todo.completed).length} items left</p>
          <button onClick={handleClearCompleted}>Clear completed</button>
        </div>
      )}
    </div>
  );
}