MCPcopy
hub / github.com/react-guide/redux-tutorial-cn / userReducer

Function userReducer

06_dispatch-action.js:6–18  ·  view source on GitHub ↗
(state = {}, action)

Source from the content-addressed store, hash-verified

4// 我们将会用到上一章的 reducer ,并用它们处理一些 action:
5
6var 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}
19var itemsReducer = function (state = [], action) {
20 console.log('itemsReducer was called with state', state, 'and action', action)
21

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected