What is Redux? Why we need Redux? When it is required?


Redux, the word is very painful for most of the people, those who all are learning Redux, because they think this is tough to learn. But really the learning curve of redux is very simple.
First of all, you need to understand, what is redux? Why we need redux? When it is required?

What is Redux?

Most of the people are think redux is a library, but Redux is not a library it is Design Pattern, Redux allow us to scale the application and maintain the state of a Javascript application.
Redux helps the app to scale by providing a sensical way to manage state through a unidirectional data flow model.

Why we need Redux?

Redux is used to maintain the state of the Javascript application and it provides a design pattern of the application. Mostly redux using with ReactJS because ReactJS is JavaScript Library to create the reusable component. To main the state of React application is difficult if the application grows or larger.

When it is required?

Redux is not always required for React or any other JavaScript application. It is required for large scale application to maintain the state if the application is small the Redux is not required.

Deep understanding with redux.

Let’s assume you are going to buy Tomato, Onion, Fish, and Chicken for your home.

You and your brother going to buy the products from the market you are buying Tomato and Onion from the Vegetable shop, your brother is buying the Fish from a fish market, He asked to you to buy the Chicken as well. Then you are going any non - veg shop, and buy the Chicken.

In this case, you both spend time in three shops, Let’s Assume If you people are going to the supermarket, what happened, the above four products are available in the supermarket, so you can all product buy at one place.

Here you understand single store concept; all the state(Products) of your application is available in the store and you can subscribe(Buy) whenever you want and where you want.

Redux is hold or maintain the application state in single store with unidirectional data flow.

You need to understand the following thing to learn redux. 


  •  Store
  •  Reducer
  •  Actions and Dispatch

Store

The store is used to maintain all the state in a single place.

Reducer

The reducers are used to update the store depending on the action, Reducer is the only way to update the store in redux.

Action

Action is a type of event to dispatch the type with payload to the reducer.

Related Articles


Comments