redux example init

This commit is contained in:
Dmitry Vasilev
2023-06-15 18:16:56 +03:00
parent dc526137be
commit 4996e8f86d
18 changed files with 436 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
const todos = (state = [], action) => {
switch (action.type) {
case 'ADD_TODO':
return [
...state,
{
id: action.id,
text: action.text,
completed: false
}
]
case 'TOGGLE_TODO':
return state.map(todo =>
(todo.id === action.id)
? {...todo, completed: !todo.completed}
: todo
)
default:
return state
}
}
export default todos