Dummy @asyncConnect is required for server side rendering to work
See original GitHub issueI’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:
- Created 7 years ago
- Reactions:7
- Comments:6
After changing back to redux-async-connect v1.0.0-rc3 the problem is gone. Thanks for the tips guys.
Related: https://github.com/Rezonans/redux-async-connect/issues/69