import { applyMiddleware , createStore } from "redux" ; import loggerMiddleware from "redux-logger" ; import thunkMiddleware , { ThunkAction } from "redux-thunk" ; const INCREMENT = "counter/increment" ; type Increment = { type : typeof INCREMENT ; } ; export function increment ( ) { return { type : INCREMENT } ; } export function incrementAsync ( ) { return dispatch => { dispatch ( increment ( ) ) ; } ; } type Action = Increment ; export type State = { value : number ; } ; const initialState = { value : 0 } ; const counter = ( state = initialState , action ) => { switch ( action . type ) { case INCREMENT : { return { ... state , value : state . value + 1 } ; } default : { return state ; } } } ; const store = createStore ( counter , applyMiddleware ( loggerMiddleware , thunkMiddleware ) ) ; export default store ;