Skip to main content

Command Palette

Search for a command to run...

Actions, Reducer and Store in Redux

Published
1 min read
Actions, Reducer and Store in Redux
P

I'm a self taught web developer and a learner as well. I am sharing my experiences and knowledge here with a hope to help those who are beginners as sharing helps to grow together.

Actions

Action is the only way for the interaction between the store and the application.

It carries some information from the application to the Redux store.

Actions are plain JavaScript objects.

It must have a 'type' property that informs about the type of action to be performed.

The 'type' property is defined as string constants.

Reducer

Reducer specifies how the app's state changes in response to the actions sent to the store.

It is a function that accepts state and action as arguments and returns the next state of the application i.e.

(previousState, action) => newState

Redux Store

There is only one store for the entire application.

There are various responsibilities of the Redux store, such as-

It holds the application's state.

It allows access to the state using getState().

It provides a method dispatch(action) that allows updating the state.

It also provides a method called subscribe(listener) which is executed whenever the state in the Redux Store changes.