redux example rename

This commit is contained in:
Dmitry Vasilev
2023-06-17 01:43:02 +03:00
parent af2ea7ea57
commit bfc4f8d440
16 changed files with 0 additions and 0 deletions

View File

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