Server side rendering have no effect in 3.0.x
See original GitHub issueHi!
I have writen a ssr demo using 2.2.3
,here is my demo.
Now i want to upgrade loadable-components
from 2.2.3
to 3.0.x
,only a few things have been done
- Upgrade babel to 7.x.
- Replace all
import Loadable from "loadable-components";
withimport Loadable from "@loadable/component";
. - Replace babel plugin
loadable-components/babel
with"@loadable/babel-plugin"
. - Using dynamic mode in
src/server.js
replace old api
.
server.js
const ReactDOMServer = require("react-dom/server");
const { LoadableState } = require("@loadable/server");
// ...
let component = createApp(context, req.url, store);
const loadableState = new LoadableState();
const loadableComponent = loadableState.collectChunks(component);
// ...
let html = ReactDOMServer.renderToString(loadableComponent);
let htmlStr = template
// some code
.replace("<!--react-ssr-outlet-->",
`<div id='app'>${html}</div>\n${loadableState.getScriptTags()}`);
After call ReactDOMServer.renderToString()
,i call loadableState.getScriptTags()
,but return <script>window.__LOADABLE_STATE__ = [];</script>
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:20 (20 by maintainers)
Top Results From Across the Web
Server side rendering have no effect in 3.0.x #128 - GitHub
Hi! I have writen a ssr demo using 2.2.3,here is my demo. Now i want to upgrade loadable-components from 2.2.3 to 3.0.x,only a...
Read more >How to Enable Server-Side Rendering for a React App
In this tutorial, you will initialize a React app using Create React App and then modify the project to enable server-side rendering.
Read more >Why Server-Side Rendering Alone Is Not the Solution
Whenever two applications communicate with each other over a network, there's a risk of a communication error involved. There's a possibility ...
Read more >Improve app performance with React server-side rendering
React server-side rendering offers performance benefits vs. client-side rendering. Learn about different React SSR frameworks.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You must use
loadable
and notLoadable
keyword, the babel plugin only applies onloadable
. I think I will change it to read it fromimport X from '@loadable/component'
.@code-mcx I see the problem, I think we should ignore “hot-update.js” files, they should not be added into scripts but only available to be loaded by Webpack Hot Loader runtime.
I will try to fix it soon. Thanks for your feedback.