forked from webclinic017/passiv-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
44 lines (36 loc) · 1.35 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { createBrowserHistory } from 'history';
import { createStore, applyMiddleware, Action } from 'redux';
import reduxThunk, { ThunkMiddleware } from 'redux-thunk';
import { composeWithDevTools } from 'redux-devtools-extension';
import { routerMiddleware } from 'connected-react-router';
import { persistReducer } from 'redux-persist';
import sessionStorage from 'redux-persist/lib/storage/session';
import { responsiveStoreEnhancer } from 'redux-responsive';
import createRootReducer from '../reducers';
import apiMiddleware from '../middleware/api';
export const history = createBrowserHistory();
const defaultState = {};
const persistConfig = {
key: 'root',
storage: sessionStorage,
blacklist: ['appTime', 'router', 'browser', 'updateServiceWorker', 'online'],
};
// create our root reducer
const rootReducer = createRootReducer(history);
// export the type for usage elsewhere
export type AppState = ReturnType<typeof rootReducer>;
const persistedReducer = persistReducer(persistConfig, rootReducer);
const composeEnhancers = composeWithDevTools({ trace: true, traceLimit: 25 });
const store = createStore(
persistedReducer,
defaultState,
composeEnhancers(
responsiveStoreEnhancer,
applyMiddleware(
routerMiddleware(history),
reduxThunk as ThunkMiddleware<AppState, Action<any>>,
apiMiddleware,
),
),
);
export default store;