Creating the store
The final task in Store.ts
is to create a function that creates the Redux store so that it can be provided to the React components. We need to feed all the store reducers into this function as well. Let's do this by performing the following steps:
- First, let's import the
Store
type and thecreateStore
andcombineReducers
functions from Redux:import { Store, createStore, combineReducers } from 'redux';
Store
is the top-level type representing the Redux store.We will use the
createStore
function to create the store later.combineReducers
is a function we can use to put multiple reducers together into a format required by thecreateStore
function. - Let's use the
combineReducers
function to create what is called a root reducer:const rootReducer = combineReducers<AppState>({ Â Â questions: questionsReducer });
An object literal is passed into
combineReducers
, which contains the properties in our app state, along with the...