Creating a Store
Explore how to create a Redux store to manage React global state, understand reducer functions, and dispatch actions to update state values. This lesson helps you grasp the basics of state initialization and modification using Redux in React applications.
We'll cover the following...
The createStore function
To create a store that will manage the global state, we have to import the createStore function from the redux package. We can call it by passing it a reducer function. This function returns a store object to us, which contains all the methods necessary to interact with the store-namely, dispatch, getState, and subscribe. The latter two are not of the same importance when working with React, but we have mentioned them for the sake of completion. In React and Redux applications, the react-redux binding components take care of the rerendering
of components if they are affected by a change of the state. Let’s look at an example: ...