MCPcopy Create free account
hub / github.com/dabbott/react-native-express / reducer

Function reducer

examples/files/TodoListRedux.js:29–49  ·  view source on GitHub ↗
(state = initialState, action)

Source from the content-addressed store, hash-verified

27// call reducer() with no state on startup, and we are expected to
28// return the initial state of the app in this case.
29export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected