Created
September 29, 2019 18:07
-
-
Save wuzzeb/b15b4897dfa5590b344f60f52a97d285 to your computer and use it in GitHub Desktop.
Typescript redux store definition
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 { createStore } from "./typed-redux"; | |
import { compose, applyMiddleware } from "redux"; | |
export { SampleState, SampleAction, SampleActionType } from "./sample"; | |
import { sampleReducer } from "./sample"; | |
/* tslint:disable */ | |
const composeEnhancers = | |
typeof window === "object" && (window as any)["__REDUX_DEVTOOLS_EXTENSION_COMPOSE__"] | |
? (window as any)["__REDUX_DEVTOOLS_EXTENSION_COMPOSE__"] | |
: compose; | |
/* tslint:enable */ | |
const store = createStore( | |
{ | |
sample: sampleReducer | |
//foo: fooReducer, | |
//bar: barReducer | |
}, | |
m => m, //middleware, none in this example | |
m => composeEnhancers(applyMiddleware(m)) //enhancer | |
); | |
export const useSelector = store.useSelector; | |
export const useDispatch = store.useDispatch; | |
export const Provider = store.Provider; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment