|
1 | 1 | const React = require('react'); |
2 | 2 | const ReactDOM = require('react-dom'); |
3 | | -const { compose, createStore, combineReducers } = require('redux'); |
| 3 | +const { applyMiddleware, compose, createStore, combineReducers } = require('redux'); |
4 | 4 | const { Provider } = require('react-redux'); |
5 | 5 | const { Router, Route, IndexRoute } = require('react-router'); |
6 | 6 | const createHistory = require('history/lib/createHashHistory'); |
7 | | -const { syncReduxAndRouter, routeReducer } = require('redux-simple-router'); |
| 7 | +const { syncHistory, routeReducer } = require('redux-simple-router'); |
8 | 8 | import { devTools } from 'redux-devtools'; |
9 | 9 | const { DevTools, DebugPanel, LogMonitor } = require('redux-devtools/lib/react'); |
10 | 10 |
|
11 | 11 | const reducers = require('./reducers'); |
12 | 12 | const { App, Home, Foo, Bar } = require('./components'); |
13 | 13 |
|
| 14 | +const history = createHistory(); |
| 15 | +const middleware = syncHistory(history); |
14 | 16 | const reducer = combineReducers(Object.assign({}, reducers, { |
15 | 17 | routing: routeReducer |
16 | 18 | })); |
| 19 | + |
17 | 20 | const finalCreateStore = compose( |
| 21 | + applyMiddleware(middleware), |
18 | 22 | devTools() |
19 | 23 | )(createStore); |
20 | 24 | const store = finalCreateStore(reducer); |
21 | | -const history = createHistory(); |
22 | | - |
23 | | -syncReduxAndRouter(history, store); |
| 25 | +middleware.syncHistoryToStore(store); |
24 | 26 |
|
25 | 27 | ReactDOM.render( |
26 | 28 | <Provider store={store}> |
|
0 commit comments