Creating a Store

Learn how to create a Redux store, get the current state from the store, and pass actions to update the stored state.

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: ...