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






המאמר מזכיר את האנשים הבאים: I am technology

המידע הזה מתפרסם לפי רישיון לשימוש חופשי במסמכים של גנו (GFDL)
אתה צריך להכנס למערכת על מנת לערוך את המאמר

תגובות

Please log in / register, to leave a comment

ברוכים הבאים ל JewAge!
חפש מידע אודות מקורות משפחתך