Documentation: Redux Chinese Documentation The official Redux documentation defines Redux as: a predictable JavaScript application state management container. 1. The relationship between redux and reactRedux does not only provide state management for react applications, it also supports other frameworks. React is an abstraction layer for DOM (UI library), not a complete solution for web applications. Therefore, react is more complicated when it comes to data processing and communication between components. For large and complex applications, these two aspects are precisely the most critical. Therefore, it is difficult to write large applications using only React. Advantages of redux: Centrally store and manage application status When dealing with component communication issues, ignore the hierarchical relationship between components Simplify communication between components in large and complex applications The data flow is clear and it is easy to locate bugs 2. React multi-component sharingExtract the states of all components and construct a centralized state tree by analogy with the React component tree. This state tree corresponds one-to-one with the React component tree, which is equivalent to stateful modeling of the React component tree: ├── src ├── store # redux directory, generally called store │ ├── index.js # Define and export the store. The reducer will be imported │ └── reducer # reducer function ├── App.js # root component, import Father and Uncle components 1. Redux can ignore the component hierarchy 2. For the component system, redux is a third-party, global "variable" 3. Three core concepts of redux Core concepts: 1. storeStore is a warehouse, the core of Redux, integrating action and reducer, similar to the store of vuex Features:
import { createStore } from 'redux' // Create a store const store = createStore(reducer) 2. action Features:
const action1 = { type:'addN', payload: 12 } //store.dispatch(action1) const action2 = { type:'add', payload: 1 } 3. Reducer (pure function)effect: 1. Initialization state 2. Modify status Modify state: return a new state based on the old state and action passed in initState = 0 function reducer(state = initState, action) { return state } SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: The difference between mysql outer join and inner join query
>>: Content-type description, that is, the type of HTTP request header
HTML web page list tag learning tutorial. In HTML ...
This article introduces the sample code of CSS3 c...
Preface I have been working on some front-end pro...
Mac uses Shell (Terminal) SSH to connect to the r...
Given an array [1,8,5,4,3,9,2], write an algorith...
In this system, the # sign represents the root us...
Table of contents Write docker-compose.yml Run do...
Portainer is an excellent Docker graphical manage...
Table of contents 1 Nginx Installation 2 Configur...
I was working on a pop-up ad recently. Since the d...
Table of contents Start and stop Database related...
1. SSH remote management SSH is a secure channel ...
<br />The author used to be a novice in web ...
Table of contents Preface 1. Style penetration 1....
The database enables slow query logs Modify the c...