@@ -3,28 +3,33 @@ import ReactDOM from 'react-dom'
33import { Provider } from 'react-redux'
44import { match , RouterContext } from 'react-router'
55import { BrowserRouter , StaticRouter } from 'react-router-dom' ;
6- import { matchRoutes , renderRoutes } from 'react-router-config'
6+ import { matchRoutes , renderRoutes } from 'react-router-config' ;
7+ import { AppContainer } from 'react-hot-loader' ;
78import Layout from 'framework/layout/layout.jsx' ;
89import Header from 'component/header/header' ;
910import SSR from 'component/spa/ssr/ssr' ;
1011import { create } from 'component/spa/ssr/store' ;
1112import routes from 'component/spa/ssr/routes'
12- import './spa.css' ;
1313
1414const clientRender = ( ) => {
1515 const store = create ( window . __INITIAL_STATE__ ) ;
1616 const url = store . getState ( ) . url ;
17- ReactDOM . render (
18- < div >
19- < Header > </ Header >
20- < Provider store = { store } >
21- < BrowserRouter >
22- < SSR url = { url } />
23- </ BrowserRouter >
24- </ Provider >
25- </ div > ,
26- document . getElementById ( 'app' )
17+ const Entry = ( ) => ( < div >
18+ < Header > </ Header >
19+ < Provider store = { store } >
20+ < BrowserRouter >
21+ < SSR url = { url } />
22+ </ BrowserRouter >
23+ </ Provider >
24+ </ div >
2725 ) ;
26+ const render = ( App ) => {
27+ ReactDOM . hydrate ( EASY_ENV_IS_DEV ? < AppContainer > < App /> </ AppContainer > : < App /> , document . getElementById ( 'app' ) ) ;
28+ } ;
29+ if ( EASY_ENV_IS_DEV && module . hot ) {
30+ module . hot . accept ( ) ;
31+ }
32+ render ( Entry ) ;
2833} ;
2934
3035const serverRender = ( context , options ) => {
@@ -55,8 +60,4 @@ const serverRender = (context, options)=> {
5560 )
5661 } ) ;
5762} ;
58-
59- export default EASY_ENV_IS_NODE ? serverRender : clientRender ( ) ;
60-
61-
62-
63+ export default EASY_ENV_IS_NODE ? serverRender : clientRender ( ) ;
0 commit comments