- Redux Quick Start Guide
- James Lee Tao Wei Suresh Kumar Mukhiya
- 345字
- 2021-07-02 12:40:31
Redux life cycle
It is quite important to understand the Redux life cycle. To understand the Redux life cycle, you must understand the steps involved in a complete cycle. A user interacts with an interface through some events, like clicking on a button to create some resource. For example, to save a doctor record to a database, the user enters the relevant information and hits the Save button. These events initiate some actions. As we mentioned previously, an action is a pure JavaScript object that tells us what happened.
Redux confirms whether the dispatched action contains the type property. After the confirmation, it is passed the main reducer. This is referred to as dispatching an action. An action is dispatched using the following function:
store.dispatch(action)
The entire concept of how Redux operates is illustrated in the following diagram:

The main reducer function, when called with the current state and dispatched action, passes the sub-states and action down to another reducer. As we mentioned in the previous section, the reducer is just a function, and it uses the previous state and provides the new state. Developers prefer to split the state tree into multiple slices and create a separate reducer for each state slice. Actions, on the other hand, can be concerned with more than one state slice. This method of splitting the reducers into smaller and easier to understand pieces is termed decomposition.
The new state is returned by the main reducer function and is saved in the Redux store, and all listener functions that are subscribed via store.subscribe() get called. This causes the re-render of user interfaces. We will look at the concept of Redux middleware more in Chapter 6, Extending Redux by Middleware.
So far, we have gone over a lot of theoretical concepts. If it does not make sense entirely, do not worry. It takes some time to sync with the concepts and the flow. To get better insight into how this works, let's get started with the very basic concept of making your first Redux Hello World application.
- Debian 7:System Administration Best Practices
- 自己動(dòng)手寫Java虛擬機(jī)
- Visual Basic編程:從基礎(chǔ)到實(shí)踐(第2版)
- Java Web基礎(chǔ)與實(shí)例教程(第2版·微課版)
- JavaScript語(yǔ)言精髓與編程實(shí)踐(第3版)
- Python機(jī)器學(xué)習(xí)實(shí)戰(zhàn)
- Python機(jī)器學(xué)習(xí)經(jīng)典實(shí)例
- Android Native Development Kit Cookbook
- Node.js全程實(shí)例
- Python:Deeper Insights into Machine Learning
- Extending Unity with Editor Scripting
- Troubleshooting Citrix XenApp?
- Distributed Computing in Java 9
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)(Windows 7+Office 2010)(IC3)
- Java Web開發(fā)教程:基于Struts2+Hibernate+Spring