(state = {}, action)
| 4 | // 我们将会用到上一章的 reducer ,并用它们处理一些 action: |
| 5 | |
| 6 | var userReducer = function (state = {}, action) { |
| 7 | console.log('userReducer was called with state', state, 'and action', action) |
| 8 | |
| 9 | switch (action.type) { |
| 10 | case 'SET_NAME': |
| 11 | return { |
| 12 | ...state, |
| 13 | name: action.name |
| 14 | } |
| 15 | default: |
| 16 | return state; |
| 17 | } |
| 18 | } |
| 19 | var itemsReducer = function (state = [], action) { |
| 20 | console.log('itemsReducer was called with state', state, 'and action', action) |
| 21 |
nothing calls this directly
no outgoing calls
no test coverage detected