React study Notes (iv) Data flow

Source: Internet
Author: User

The life cycle of the data in the Redux application follows the following 4 steps:

1. Call Store.dispatch (action):

You can call Store.dispatch anywhere, including components, XHR callbacks, and even timers.

The 2.Redux store calls the incoming reducer function:

Store will pass two parameters to reducer, the current state tree and action

The 3.reducer should combine multiple sub-reducer outputs into a single State tree:

Redux provides a combinereducers () helper function to split the root reducer into multiple functions for processing one branch of the state tree, respectively.

function Todos (state = [], action) {   //  omit processing logic   ... return  'show_all', action) {   //  omit processing logic   ... return  = combinereducers ({   todos,   visibletodofilter});

The 4,redux store holds the full state tree returned by the root reducer:

This new tree is the application of the next state! All listeners that subscribe to Store.subscribe (listener) will be called, and the listener can call Store.getstate () to get the current state.

React study Notes (iv) Data flow

Related Article

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.