Redux is quite an excellent State Management Framework usually used with React.js library. In Single Page Application, data management at client side is far more complicated than just imagine. Now, you are familiar that, ReactJS is relying on the State of the application. However, In React.js state management is possible, but when the application gets bigger and bigger, unwanted errors and data changes are detected, and which module has changed which state and which view is updated, all these matters get complex, and we feel like, we trapped in our application. Facebook gives the solution. Its developer has created one State management pattern called Flux.
What Will I Get ?
Principles of Redux
Predictability of Redux is determined by three most important principles as given below −
Single Source of Truth
The state of your whole application is stored in an object tree within a single store. As whole application state is stored in a single tree, it makes debugging easy, and development faster.
State is Read-only
The only way to change the state is to emit an action, an object describing what happened. This means nobody can directly change the state of your application.
Changes are made with pure functions
To specify how the state tree is transformed by actions, you write pure reducers. A reducer is a central place where state modification takes place. Reducer is a function which takes state and action as arguments, and returns a newly updated state.
see several benefits that are commonly discussed:
Predictable state updates make it easier to understand how the data flow works in the application
The use of "pure" reducer functions makes logic easier to test, and enables useful features like "time-travel debugging".
Centralizing the state makes it easier to implement things like logging changes to the data, or persisting data between page refreshes