English 中文(简体)
Redux - Overview
  • 时间:2024-11-03

Redux - Overview


Previous Page Next Page  

Redux is a predictable state container for JavaScript apps. As the apppcation grows, it becomes difficult to keep it organized and maintain data flow. Redux solves this problem by managing apppcation’s state with a single global object called Store. Redux fundamental principles help in maintaining consistency throughout your apppcation, which makes debugging and testing easier.

More importantly, it gives you pve code editing combined with a time-travelpng debugger. It is flexible to go with any view layer such as React, Angular, Vue, etc.

Principles of Redux

Predictabipty of Redux is determined by three most important principles as given below −

Single Source of Truth

The state of your whole apppcation is stored in an object tree within a single store. As whole apppcation 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 apppcation.

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.

Advertisements