What is Redux? What is action, reducer and store in Redux

In this blog we will discus about the redux, what is Redux and how you can use it in React application.

What is Redux?

Redux is a open source JavaScript library, Which is used for state management.

Redux is mostly used with popular frameworks like React and Angular

It provides direct access to the components for the data

It also provides centralized store for application state

It provides consistency of data across the application, so any component can access data from a central store anytime.

Why we use Redux in React Application?

In React we cannot access data directly from one component to another component, we have to pass the data through the props to access it.

Parent to Child and Child to Parent communication between the components is required, to understand this you can check our this blog Passing Events from parent to child component in React JS

But this type of communication makes application more complex and difficult to manage.

For small applications it can be good but in case of large application it will be very difficult to manage.

What is action, reducer and store?

To understand how redux works let’s take a look at its life cycle.

Redux has three main features.

Actions, Reducers and Store.

Actions

Actions is when a application do an action like create, delete, update etc.

Actions folder have all the actions related files for different components, for example, pages, posts, articles etc.

Action have two type of properties , type and payload. Type is basically a action type like ADD_COURSE, ADD_PAGE and payload is the data we pass through the action.

Reducers

Reducers are the functionality take take place when a action occur for example if action is ADD_COURSE then the reduce for this action will add this course to a object and that object will get updated in store where all the state got stored.

Reducers first check with central store for the value of old state for the current action and then update it to according to changes coming with new payload and it return a new state to the store.

Store

Redux have a central store where all the application states are store and when a reducer update store with new state of a component then a subscription occurs and it pass the new state to the props of component and the component get updated with new changes.

How Redux Works?

This is how redux work, first action take place, it calls reducer to do the necessary changes to the state and update it then this updated state get updated in store and this creates a subscription and by this subscription this new state get pass to the props of component and component get updated with changes.

Related Posts

angular vs react-min

What is the difference between Angular & React JS, Which one you should choose?

Angular & React JS both are use for Frontend Development, To make Single page applications or Web Apps. Here is a quick difference between both of them….

react js icon

What is useEffect Hook? How to Fetch data from API using useEffect

useEffect hook is used to manage side effects that are not related to component rendering. Mostly useEffect hook is used for managing console logs, animations, loading data,…

react js icon

What is useReducer Hook? What is the difference between useState and useReducer Hooks?

useReudcer hook takes the current state and returns a new state, it is used for state management. With useReducer, we can directly call the function inside the…

react js icon

Creating React JS App without using npx create-react-app command

It’s easy to create a react application by just running npx create-react-app project_name command, do you know what are the basic requirements for creating a react application…

react js icon

What is the useState() hooks in React JS | How to use useState() hook in React JS

Hooks are very important in react js and the most common hook is the useState Hook. In this blog, we will look into the functionality of this…

react js icon

How to use Style Module in React JS

This blog going to be the shortest one, because this is an easy topic but very important. So I decided to write a blog on this. Basically…

This Post Has One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *