So I am making a to-do list in React in order to learn redux and I've been wondering how can I use something like the map function to map over the state, so that I can show the data stored within in different divs? here's my initialState:
const tasks=
[
]
And then there's my reducer:
const taskReducer = (state=tasks,action) =>
{
switch(action.type){
case 'addTask':
return[
...state,
{
id: nextToDo+=1,
text: action.text,
completed: false
}
]
default:
return state;
}
}
What I want to do is something among the lines of:
{tasks.map(task=>
<div>
<h1>{task.text}</h1>
<div>)}
But it doesn't really work, what are some ways I can accomplish this?