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.

Async React.renderToString for server-side rendering

See original GitHub issue

It would really help if we could use the async version of the React.renderToString when rendering on the server-side.

app.get('*', function (req, res) {

  Router.run(routes, req.path, (Handler, router) => {
    // var content = React.renderToString(<Handler/>);
    // res.render('index', { content: content });
    React.renderToString(<Handler/>, function(content) {
      res.render('index', { content: content });
    });
});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Mar 24, 2021

There’s new work in this area in https://github.com/facebook/react/pull/20970.

0reactions
xpepermintcommented, Apr 30, 2015

Thanks! Following #3009 then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React server-side fetch (asynchronous rendering)
When you call renderToString from the server, react will call the constructor, componentWillMount and render, then create a string from the ...
Read more >
ReactDOMServer – React
renderToString ()​​ Render a React element to its initial HTML. React will return an HTML string. You can use this method to generate...
Read more >
Resolving async state while server-rendering · Pullstate
Universal fetching. Any action that is making use of useBeckon() (discussed in detail here) in the current render tree can have its state...
Read more >
Asynchronous Server side rendering with React - Medium
I'll try to keep this short and simple : This post will go over an implementation of asynchronous server side rendering in a...
Read more >
Dealing with Asynchronous APIs in Server-rendered React
You can add back traditional server-side rendering of web pages, typically with NodeJS, but this isn't a straightforward process, especially ...
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