When the shepherd becomes angry with his flock he appoints for a leader one which is blind.

Baba Kamma 52a

What is Redux?

 

What is Redux?



Redux is a predictable state container made for helping developers write JavaScript apps that maintain consistency across client, server, and native components and are easy in testing.




In general, it’s useful as a state management tool with react, you can use it with any other JavaScript framework or library. It’s lightweight at 2KB which also includes dependencies. Thus, you don’t have to think about making your apps’ asset size big.




With Redux, the state of the application is kept in a store and each component can access any given state that it requires from this store.




Why use Redux?



Normally, an app consists of its state and that state is a combination of states of its internal components. Let us consider an example of an e-commerce website. An e-commerce website will incorporate various components such as a user profile, cart component, previous section and etc.




For instance, consider the cart component, it displays the number of items in a user’s cart. The state of the cart component will include all the items that the user adds to the cart. It will also comprise the total of those items. At each event the application is up and running, this component has to display the updated number of items in the user’s cart.




Here when a user adds a specific item to the cart, the application has to internally handle the event by adding that item to the cart object. It has to retain the state internally and display to the user the total number of items in the cart in the UI. Likewise, if a user is removing an item from the card the decrease in the number of items should occur internally.




This is handled when the app size is small. But, when the application size is extensive it becomes difficult to control multiple states from components with efficiency. Here is where Redux comes into the picture. Being a state management library, it will store and manage all the application states.




Further, it also provides some crucial APIs that one can use to make changes to the existing state. One can easily fetch the current state using such an API.




3 Principles of Redux...
Continue reading at Webbybutter






The article is about these people: I am technology

This information is published under GNU Free Document License (GFDL).
You should be logged in, in order to edit this article.

Discussion

Please log in / register, to leave a comment

Welcome to JewAge!
Learn about the origins of your family