brocoders / redux-async-connect

It allows you to request async data, store them in redux state and connect them to your react component.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rc3 -> rc4 breaks server side rendering

duro opened this issue · comments

I am using the erikras/react-redux-universal-hot-example boilerplate, which depends on this library.

When upgrading from rc3 to rc4, server side rendering breaks completely. Here is the implementation of redux-async-connect on the server:

loadOnServer({...renderProps, store, helpers: {client}}).then(() => {
  const component = (
    <Provider store={store} key="provider">
      <ReduxAsyncConnect {...renderProps} />
    </Provider>
  );

  res.status(200);

  global.navigator = {userAgent: req.headers['user-agent']};

  res.send('<!doctype html>\n' +
    ReactDOM.renderToString(<Html assets={webpackIsomorphicTools.assets()} component={component} store={store}/>));
});

I don't get any errors, but none of the components are output in the renderToString.

Did something change about the loadOnServer API that needs to be adjusted in the code above?

+1 on this. I'm having major issues loading components at different levels. For example, a Parent component loading one item through asynconnect, while it's Child component loads something else through asynconnect does not work at all.

commented

Related issue #61

The rc4 commit: 9af423c

I commented below the commit....I believe it's missing 'return ' in front of args.store.dispatch(endGlobalLoad());

Never mind...it's not meant to be chainable I think

commented

@Morriz find us the real fix man!

I have been debugging this issue all day, but couldn't get it to work. It's becoming too complex with all the parts outsmarting each other.

Well, fwiw, I have got server rendering working fine now with rc4 (and rc3 and 2), but find that the client renders a noscript. Probably because react-router is not coupled correctly and rendering is triggered too soon

Related PR: #70

commented

Why have a rc4 if the fix is the revert to rc3? Am I missing something?

commented

@Morriz How did you get it working?

try using https://github.com/makeomatic/redux-connect - its a fork with improvements