1- import React from 'react' ;
2- import ReactDOM from 'react-dom' ;
3- import { createStore , applyMiddleware } from 'redux' ;
4- import { Provider } from 'react-redux' ;
5- import { composeWithDevTools } from 'redux-devtools-extension' ;
6- import thunk from 'redux-thunk' ;
7- import { ConnectedRouter , routerReducer , routerMiddleware , push } from 'react-router-redux' ;
8- import { AppContainer } from 'react-hot-loader' ;
9- import App from './App' ;
10- import createHistory from 'history/createBrowserHistory' ;
11- import rootReducer from './reducers/index' ;
12-
13- var FastClick = require ( 'fastclick' ) ;
1+ import React from 'react'
2+ import ReactDOM from 'react-dom'
3+ import { createStore , applyMiddleware , combineReducers } from 'redux'
4+ import { Provider } from 'react-redux'
5+ import { composeWithDevTools } from 'redux-devtools-extension'
6+ import thunk from 'redux-thunk'
7+ import { ConnectedRouter , routerReducer , routerMiddleware } from 'react-router-redux'
8+ import { AppContainer } from 'react-hot-loader'
9+ import App from './App'
10+ import createHistory from 'history/createBrowserHistory'
11+ import rootReducer from './reducers/index'
12+
13+ var FastClick = require ( 'fastclick' )
1414
1515//按模块导入lodash,可以有效减小vendor.js的大小
16- import isEmpty from 'lodash/isEmpty' ;
17- import isEqual from 'lodash/isEqual' ;
18- import debounce from 'lodash/debounce' ;
19- import isArray from 'lodash/isArray' ;
16+ import isEmpty from 'lodash/isEmpty'
17+ import isEqual from 'lodash/isEqual'
18+ import debounce from 'lodash/debounce'
19+ import isArray from 'lodash/isArray'
2020
21- window . isEmpty = isEmpty ;
22- window . isEqual = isEqual ;
23- window . debounce = debounce ;
24- window . isArray = isArray ;
21+ window . isEmpty = isEmpty
22+ window . isEqual = isEqual
23+ window . debounce = debounce
24+ window . isArray = isArray
2525
26- const history = createHistory ( ) ;
26+ const history = createHistory ( )
2727const middleware = routerMiddleware ( history )
2828
2929//解决移动端300毫秒延迟
30- FastClick . attach ( document . body ) ;
31- const middlewares = [ thunk , middleware ] ;
30+ FastClick . attach ( document . body )
31+ const middlewares = [ thunk , middleware ]
3232
33- const store = createStore ( rootReducer , composeWithDevTools ( applyMiddleware ( ...middlewares ) ) ) ;
33+ const store = createStore (
34+ combineReducers ( { routing : routerReducer , ...rootReducer } ) ,
35+ composeWithDevTools ( applyMiddleware ( ...middlewares ) )
36+ )
3437
3538const render = Component =>
3639 ReactDOM . render (
@@ -40,13 +43,13 @@ const render = Component =>
4043 </ Provider >
4144 </ AppContainer > ,
4245 document . getElementById ( 'root' )
43- ) ;
46+ )
4447
4548render ( App )
4649
4750if ( module . hot ) {
4851 module . hot . accept ( './App' , ( ) => {
4952 const NextRootContainer = require ( './App' ) . default
5053 render ( NextRootContainer )
51- } ) ;
54+ } )
5255}
0 commit comments