1
1
import { createStore , applyMiddleware , combineReducers , compose } from 'redux' ;
2
+ import { hashHistory } from 'react-router' ;
3
+ import { routerMiddleware , routerReducer as routing , push } from 'react-router-redux' ;
4
+ import persistState from 'redux-localstorage' ;
2
5
import thunk from 'redux-thunk' ;
3
6
4
- import user from '../reducers/user' ;
5
- import userActions from '../actions/user' ;
7
+ import user from './reducers/user' ;
8
+ import userActions from './actions/user' ;
9
+
10
+ const router = routerMiddleware ( hashHistory ) ;
6
11
7
12
const actionCreators = {
8
- ...userActions
13
+ ...userActions ,
14
+ push
9
15
} ;
10
16
11
17
const reducers = {
12
- user
18
+ user,
19
+ routing
13
20
} ;
14
21
15
- const middlewares = [ thunk ] ;
22
+ const middlewares = [ thunk , router ] ;
16
23
17
24
const composeEnhancers = ( ( ) => {
18
25
const compose_ = window && window . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ;
@@ -22,9 +29,9 @@ const composeEnhancers = (() => {
22
29
return compose ;
23
30
} ) ( ) ;
24
31
25
- const enhancer = composeEnhancers ( applyMiddleware ( ...middlewares ) ) ;
26
- const rootReducer = combineReducers ( reducers ) ;
27
-
28
32
export default function configureStore ( initialState ) {
33
+ const enhancer = composeEnhancers ( applyMiddleware ( ...middlewares ) , persistState ( ) ) ;
34
+ const rootReducer = combineReducers ( reducers ) ;
35
+
29
36
return createStore ( rootReducer , initialState , enhancer ) ;
30
37
}
0 commit comments