forked from maidsafe/sn_browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.ts
53 lines (42 loc) · 1.26 KB
/
store.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
45
46
47
48
49
50
51
52
53
import { createStore, applyMiddleware, compose } from 'redux';
import { routerMiddleware, push } from 'connected-react-router';
import promise from 'redux-promise-middleware';
import thunk from 'redux-thunk';
import { createHashHistory } from 'history';
import { createLogger } from 'redux-logger';
import {
loadTranslations,
setLocale,
syncTranslationWithStore
} from 'react-redux-i18n';
import { createRootReducer } from './reducers';
import en from '../locales/en.json';
const translationsObject = {
en
};
const actionCreators = {
push
};
const logger = createLogger( {
level: 'info',
collapsed: true
} );
export const history = createHashHistory();
const router = routerMiddleware( history );
const enhancer = compose(
applyMiddleware( thunk, router, logger, promise ),
window.devToolsExtension
? window.devToolsExtension( { actionCreators } )
: ( noop ) => noop
);
export function configureStore( initialState ) {
const store = createStore(
createRootReducer( history ), // root reducer with router state
initialState,
enhancer
);
syncTranslationWithStore( store );
store.dispatch( loadTranslations( translationsObject ) );
store.dispatch( setLocale( 'en' ) );
return store;
}