Created
March 21, 2020 22:21
-
-
Save jasonleehodges/623f9adccc8ca5a620dd5404438383c6 to your computer and use it in GitHub Desktop.
Configure Redux Store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AnyAction, applyMiddleware, compose, createStore } from 'redux'; | |
import combinedReducers, { RootState } from '../reducers'; | |
import thunk, { ThunkMiddleware } from 'redux-thunk'; | |
const devToolsCompose = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__; | |
const composeEnhancers = (devToolsCompose !== null && devToolsCompose !== undefined) | |
? devToolsCompose | |
: compose; | |
export type ThunkWithRootState = ThunkMiddleware<RootState, AnyAction>; | |
const reduxStore = (initialState: RootState = {} as RootState) => { | |
return createStore( | |
combinedReducers, | |
initialState, | |
composeEnhancers( | |
applyMiddleware(thunk as ThunkWithRootState) | |
), | |
); | |
} | |
export default reduxStore; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment