DEV Community

MD Zahid Hasan
MD Zahid Hasan

Posted on

Redux-A technology to know

What is Redux?

Considering Javascript Redux is a predictable state management library and for React, Redux is the most popular State container. It basically helps to avoid the Prop drilling nature of React. It holds all the states within the app and each component have access to this store. The core concepts of Redux are:

The Store: Everything that changes within an app is actually represented by a javascript object called the store. Store stored all the states of an application.

Application state is immutable: When states changes in an application Redux clone the state object and modify it and it replaces the original state with the new copy.

Reducers: Reducers are pure JavaScript functions that perform the action to update the state and return the new state. It takes the current value of a state, takes the action depending on the action type, and returns the new state.

Image description

Redux data flow:

  1. Store stores the states
  2. Event occurs in the UI
  3. That Event dispatch an action
  4. In a predictable way, Reducer updates the states
  5. UI accept the updated states

Advantages of Redux:

  • Redux can be used client and server-side both.
  • Redux is easy to test and also optimizes the performance of the application.
  • We can easily persist some of state to the local store.
  • We can maintain Redux easily

Disadvantages of Redux:

  • In a small project, everyone tries to avoid complex patterns like Redux.
  • When data come from a single data source per view.

Top comments (0)