Role of Reducer

Source: Internet
Author: User

########################################

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.