There is only one store in any Redux application. When using Redux with React, states will no longer need to be lifted up; thus, it makes it easier to trace which action causes any change.
Here I am creating an action to log in the user and dispatching it to the reducer. Reducers are pure functions that take the current state of the application and an action and then return a new state. Here is an example of a simple reducer:
In a reducer depending on the action type, it returns a new state. We can have multiple reducers to handle complex applications. To do so we can use combineReducers() which combines all reducers in the application into a single index reducer. Every reducer is responsible for its own part of the application’s state, and the state parameter is different for every reducer. The combineReducers() utility makes the file structure much easier to maintain.
Here is what my combine reducer looks like:
Lastly, this reducer will be passed in createstore. There is much more to explain but here, I just tried to highlight the main features.
Thank you for reading. Happy coding...