|
1 | 1 | import React, { Component } from 'react'; |
2 | 2 | import { render } from 'react-dom'; |
3 | | -import { createStore, combineReducers, applyMiddleware } from 'redux'; |
| 3 | +import { createStore, combineReducers, applyMiddleware, compose } from 'redux'; |
4 | 4 | import thunk from 'redux-thunk'; |
5 | 5 | import { Provider } from 'react-redux'; |
6 | | -import { Router, Route, IndexRoute, hashHistory } from 'react-router'; |
7 | | -import { syncHistory, routeReducer } from 'react-router-redux'; |
8 | | -import { createHistory } from 'history'; |
| 6 | +import { Route } from 'react-router-dom'; |
| 7 | +import createHashHistory from 'history/createHashHistory'; |
| 8 | +import { ConnectedRouter, routerReducer, routerMiddleware } from 'react-router-redux'; |
9 | 9 | import reducer from './reducers'; |
10 | 10 | import App from './components/App'; |
11 | | -import Login from './components/Login'; |
12 | | -import User from './components/User'; |
13 | | -import Error from './components/Error'; |
14 | 11 |
|
15 | 12 | // load our css. there probably is a better way to do this |
16 | 13 | // but for now this is our move |
17 | 14 | require('./style.less'); |
18 | 15 |
|
19 | 16 | // Sync dispatched route actions to the history |
20 | | -const reduxRouterMiddleware = syncHistory(hashHistory) |
21 | | -const createStoreWithMiddleware = applyMiddleware( |
22 | | - thunk, |
23 | | - reduxRouterMiddleware |
24 | | -)(createStore) |
25 | | -const store = createStoreWithMiddleware(reducer) |
| 17 | +const hashHistory = createHashHistory(); |
| 18 | + |
| 19 | +const store = createStore(reducer, undefined, compose( |
| 20 | + applyMiddleware(thunk, routerMiddleware(history)), |
| 21 | + window.devToolsExtension ? window.devToolsExtension() : f => f, |
| 22 | +)); |
26 | 23 |
|
27 | 24 | class Root extends Component { |
28 | 25 | render() { |
29 | 26 | return ( |
30 | 27 | <Provider store={store}> |
31 | | - <Router history={hashHistory}> |
32 | | - <Route path="/" component={App}> |
33 | | - <IndexRoute component={Login} /> |
34 | | - <Route path="/user/:accessToken/:refreshToken" component={User} /> |
35 | | - <Route path="/error/:errorMsg" component={Error} /> |
36 | | - </Route> |
37 | | - </Router> |
| 28 | + <ConnectedRouter history={hashHistory}> |
| 29 | + <Route path="/" component={App}/> |
| 30 | + </ConnectedRouter> |
38 | 31 | </Provider> |
39 | 32 | ); |
40 | 33 | } |
|
0 commit comments