########################################
Some ways you may walk with someone, and you may not be able to walk with others.
########################################
When a store is created, the reducer will immediately execute the statement. At this time, the initial state will be saved. If no setting is set, it will be saved to undefined.
The role of CER is to record the status of our changes. In order to let us return to the previous status, there is a switch branch in it for data judgment to see what is returned
1 var listreducer = (prevstate = [], Action ={}) =>{ 2 // the old state obtained by prevstate; 3 // action {type: "changelist", payload: [1, 2, 3, 4, 5, 6]} 4 var type = action. type; 5 6 switch (type) {7 case "changelist": 8 return [... prevstate ,... action. payload] 9 default: 10 return prevstate11} 12 Return prevstate; 13 // store. title = action. pa14} 15 16 17 export default listreducer;
Role of Reducer