redux-async-connect icon indicating copy to clipboard operation
redux-async-connect copied to clipboard

rc3 -> rc4 breaks server side rendering

Open duro opened this issue 9 years ago • 10 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?

duro avatar Mar 07 '16 21:03 duro

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

kjanoudi avatar Mar 08 '16 03:03 kjanoudi

Related issue #61

The rc4 commit: https://github.com/Rezonans/redux-async-connect/commit/9af423c70b446ed63b9431c7d31770bebbf5f693

babsonmatt avatar Mar 09 '16 22:03 babsonmatt

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

Morriz avatar Apr 22 '16 13:04 Morriz

@Morriz find us the real fix man!

babsonmatt avatar Apr 22 '16 19:04 babsonmatt

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.

Morriz avatar Apr 22 '16 20:04 Morriz

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

Morriz avatar Apr 22 '16 20:04 Morriz

Related PR: https://github.com/Rezonans/redux-async-connect/pull/70

hanjukim avatar Apr 29 '16 14:04 hanjukim

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

akeemattelus avatar Oct 19 '16 18:10 akeemattelus

@Morriz How did you get it working?

njj avatar Jun 16 '17 17:06 njj

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

AVVS avatar Jun 16 '17 20:06 AVVS