DEV Community

Wakeel Kehinde Ige
Wakeel Kehinde Ige

Posted on

How does Redux work? ^-^

The way Redux works is quite simple.

The states of the components of interest are held in a separate central store.

The states in the store are passed as props to those components. This makes them immutable.

Building Blocks: actions -> reducers -> store

i. Actions are events(JS objects with "type" field) through which data are sent from the application to the Redux store. The data can be from user interactions, user inputs, API calls, or even form submissions.

The action get dispatched into a reducer;

ii. Reducers are pure functions in which based on the actions dispatched into them take the current state, update if necessary and return a new state. These new states are stored as objects.

iii. The store gets updated with the new state, components that are interested listen to those changes and make the necessary changes.

Top comments (0)