Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Server-side rendering being discarded #31

Closed
luandro opened this issue Nov 16, 2015 · 4 comments
Closed

Server-side rendering being discarded #31

luandro opened this issue Nov 16, 2015 · 4 comments

Comments

@luandro
Copy link

luandro commented Nov 16, 2015

It's beautiful how simple it is to implement this. But I'm having some trouble with server-side rendering. I added the syncReduxAndRouter function where the client is initiated. But what should be done in the server? Since createHistory can't be used?

It's a little obvious but the markup from my server and my client are different, and my server-side rendering is being discarded. You can clone the redux-simple-router branch of my repo if you want to test it out.

git clone -b redux-simple-router https://github.com/luandro/hapi-universal-redux.git
npm i
npm run dev
@crossman
Copy link

You don't need to use it for your server side rendering. Just render it using regular old react-router on the server side and redux-react.

You'll end up having something to the effect of this inside your match callback

<Provider store={store}>
  <RoutingContext {...renderProps} />
</Provider>

@eriknyk
Copy link

eriknyk commented Nov 18, 2015

same here #33

@eriknyk
Copy link

eriknyk commented Nov 18, 2015

I get it work @crossman
you can see my example app working https://github.com/eriknyk/redux-universal-app/

@jlongster
Copy link
Member

Indeed. This project is not intended to document or take over routing at all, it's only meant to make sure the route state (the URL) is synced with the redux store so you can always recreate your app based on that state. All functionality (especially advanced stuff like server-side rendering) should just go through react-router.

I am going to document this somehow though. A few basic examples + links for where to look at react-router's docs would be nice.

Keep an eye on https://github.com/erikras/react-redux-universal-hot-example, we're going to switch it to this project soon and you can see server-rendering code there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants