11import React from 'react' ;
2- // import createHistory from 'history/createBrowserHistory';
2+ import createHistory from 'history/createBrowserHistory' ;
33import { hydrate } from 'react-dom' ;
44import { Provider } from 'react-redux' ;
5- import { ConnectedRouter as Router } from 'react-router-redux' ;
5+ import { ConnectedRouter as Router , routerMiddleware } from 'react-router-redux' ;
66import App from '../shared/App' ;
77import IntlProvider from '../shared/i18n/IntlProvider' ;
8- // import { configureStore } from '../shared/store';
9- import { store , history } from '../shared/store' ;
8+ import { configureStore } from '../shared/store' ;
109
11- // const history = createHistory();
12- // const store = configureStore({
13- // initialState: window.__PRELOADED_STATE__,
14- // middleware: [routerMiddleware(history)],
15- // });
10+ const browserHistory = window . browserHistory || createHistory ( ) ;
11+ const store =
12+ window . store ||
13+ configureStore ( {
14+ initialState : window . __PRELOADED_STATE__ ,
15+ middleware : [ routerMiddleware ( history ) ] ,
16+ } ) ;
1617
1718hydrate (
1819 < Provider store = { store } >
19- < Router history = { history } >
20+ < Router history = { browserHistory } >
2021 < IntlProvider >
2122 < App />
2223 </ IntlProvider >
@@ -25,6 +26,13 @@ hydrate(
2526 document . getElementById ( 'app' )
2627) ;
2728
28- if ( module . hot ) {
29- module . hot . accept ( ) ;
29+ if ( process . env . NODE_ENV === 'development' ) {
30+ if ( module . hot ) {
31+ module . hot . accept ( ) ;
32+ }
33+
34+ if ( ! window . store || ! window . browserHistory ) {
35+ window . browserHistory = browserHistory ;
36+ window . store = store ;
37+ }
3038}
0 commit comments