mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
redux example init
This commit is contained in:
23
docs/examples/todos/src/reducers/todos.js
Normal file
23
docs/examples/todos/src/reducers/todos.js
Normal 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
|
||||
Reference in New Issue
Block a user