Posted on

nlm,.

// src/App.js

import React, { useState } from 'react';
import { useSelector, useDispatch } from 'react-redux'; //  state.todos); // <-- Read state from store
  const dispatch = useDispatch(); //  {
    if (todoText) {
      dispatch(addTodo(todoText)); // <-- Dispatch addTodo action
      setTodoText('');
    }
  };

  return (
    <div>
      <h1>Todo List</h1>
       setTodoText(e.target.value)}
        placeholder="Add a new todo"
      /&gt;
      <button>Add Todo</button>

      <ul>
        {todos.map((todo, index) =&gt; (
          <li> dispatch(toggleTodo(index))} // 
            {todo.text}
          </li>
        ))}
      </ul>
    </div>
  );
}

export default App;