In the previous recipes, we have seen how to define reducers and actions. We have also seen how to create a dispatch function to dispatch actions for the reducers to update the state. The store is an object that provides a small API to put all of that together.
The redux module exposes the createStore method which we can use to create a store. It has the following signature:
createStore(reducer, preloadedState, enhancer)
The two last arguments are optional. For example, creating a store with a single reducer could look like this:
const TYPE = { INC_COUNTER: 'INC_COUNTER', DEC_COUNTER: 'DEC_COUNTER', } const initialState = { counter: 0, } const reducer = (state = initialState, action) => { switch (action.type) { case TYPE.INC_COUNTER: return { counter: state.counter + 1 } case...