Skip to content

Commit c673e80

Browse files
authored
Improve SSR integration documentation (#166)
1 parent e9b6ffd commit c673e80

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,14 @@ res.send(`
642642
<body>
643643
<div id="app">${html}</div>
644644
<script src="/dist/manifest.js"></script>
645+
<script src="/dist/main.js"></script>
645646
${bundles.map(bundle => {
646647
return `<script src="/dist/${bundle.file}"></script>`
647648
// alternatively if you are using publicPath option in webpack config
648649
// you can use the publicPath value from bundle, e.g:
649650
// return `<script src="${bundle.publicPath}"></script>`
650651
}).join('\n')}
651-
<script src="/dist/main.js"></script>
652+
<script>window.main();</script>
652653
</body>
653654
</html>
654655
`);
@@ -669,9 +670,11 @@ import ReactDOM from 'react-dom';
669670
import Loadable from 'react-loadable';
670671
import App from './components/App';
671672

672-
Loadable.preloadReady().then(() => {
673-
ReactDOM.hydrate(<App/>, document.getElementById('app'));
674-
});
673+
window.main = () => {
674+
Loadable.preloadReady().then(() => {
675+
ReactDOM.hydrate(<App/>, document.getElementById('app'));
676+
});
677+
};
675678

676679
```
677680

0 commit comments

Comments
 (0)