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.

Dummy @asyncConnect is required for server side rendering to work

See original GitHub issue

I’ve encountered a rather puzzling issue today, when a page reload yielded:

Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.

Typically, when there’s a difference between CSR and SSR, a short snippet of conflicting markup is shown, but not this time. As it happens, I have been heavily experimenting with client-side optimizations, so it took me quite a while to figure out none of that was at fault.

After substantial amount of hair pulling I’ve managed to narrow down the issue to the following fact that can be easily reproduced on the master branch: if none of the rendered components for the current route contain the @asyncConnect decorator, then SSR fails and you get the misleading message.

For now, I’ve worked around this issue in my project by defining a dummy @asyncConnect on my topmost component:

import React, { Component } from 'react';
import { asyncConnect } from 'redux-async-connect';

@asyncConnect([{
  promise: () => Promise.resolve()
}])
export default class App // ...
Node v4.3.1
Npm 2.14.12

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

1reaction
FisherYu-CNcommented, Apr 22, 2016

After changing back to redux-async-connect v1.0.0-rc3 the problem is gone. Thanks for the tips guys.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with Asynchronous APIs in Server-rendered React
Roger Jin explains how to get data from asynchronous APIs when using server-rendered React code.
Read more >
Server-side rendering - Apollo GraphQL Docs
Apollo Client provides a handy API for using it with server-side rendering, including a function that executes all of the GraphQL queries that...
Read more >
What's Server Side Rendering and do I need it? - Medium
A solution like this allows us to deliver responsive sites that work a lot faster than standard request-response model by removing the “request ......
Read more >
How to implement server-side rendering (SSR) in your React ...
In this tutorial I will show you how can you render your React application on server-side. A NodeJS application (which uses Express) will...
Read more >
Server-side rendering for async blocks - Plone 6 Documentation
To use it, add the getAsyncData key in your block configuration, pointing to a function that returns a list of promises. For example:...
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