reducer.js
1 export default (map, defaultState) => (currentState, action) => { 2 const state = !currentState ? defaultState : currentState 3 4 if (!action) { 5 return state 6 } 7 8 return Object.keys(map).includes(action.type) 9 ? map[action.type](state, action.payload) 10 : state 11 }