question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server side rendering have no effect in 3.0.x

See original GitHub issue

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 few things have been done

  1. Upgrade babel to 7.x.
  2. Replace all import Loadable from "loadable-components"; with import Loadable from "@loadable/component";.
  3. Replace babel plugin loadable-components/babel with "@loadable/babel-plugin".
  4. 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:closed
  • Created 5 years ago
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
gregbergecommented, Oct 30, 2018

You must use loadable and not Loadable keyword, the babel plugin only applies on loadable. I think I will change it to read it from import X from '@loadable/component'.

0reactions
gregbergecommented, Nov 14, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >
SSR Cache issue 3.x Version - Stack Overflow
We have one peculiar issue in SSR rendering.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found