(state = initialState, action)
| 27 | // call reducer() with no state on startup, and we are expected to |
| 28 | // return the initial state of the app in this case. |
| 29 | export const reducer = (state = initialState, action) => { |
| 30 | const { todos } = state |
| 31 | const { type, payload } = action |
| 32 | |
| 33 | switch (type) { |
| 34 | case types.ADD: { |
| 35 | return { |
| 36 | ...state, |
| 37 | todos: [payload, ...todos], |
| 38 | } |
| 39 | } |
| 40 | case types.REMOVE: { |
| 41 | return { |
| 42 | ...state, |
| 43 | todos: todos.filter((todo, i) => i !== payload), |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | return state |
| 49 | } |
nothing calls this directly
no outgoing calls
no test coverage detected