acdlite / redux-router

Redux bindings for React Router – keep your router state inside your Redux store
MIT License
2.3k stars 200 forks source link

alternative use case for createHistory in server rendering? #197

Closed ghost closed 8 years ago

ghost commented 8 years ago

import createHistory from 'history/lib/createBrowserHistory'

im having problems rendering to string with this include.

any ideas? thanks

Scarysize commented 8 years ago

@SkateFreak Do you speak about server-side rendering? Browser-history obvisouly won´t work on a server. You can use createMemoryHistory for that.

Take a look at the source code of this repo: https://github.com/erikras/react-redux-universal-hot-example

ghost commented 8 years ago

do i need that history on the server? or can i rule out the usage of it while rendering react on the server

Scarysize commented 8 years ago

I guess it should work without it as far as i can see. Just tried it with the boilerplate from the repo I recommended you (initiated the store with null instead of createHistory).

ghost commented 8 years ago

so far im not enjoining the company of the Router object in window.__INITIAL_STATE__ (after i ruled it out by checking if typeof(window) !== 'undefined'):

might be the 'null' you were talking about. thank you for your help.

for anyone who's interested, i uploaded my boilerplate (i had a hard time finding this combination in a simple way for me to start off from)

it includes: Universal Redux Router Redux DevTools HMR (works with the router nicely) Less Loader

https://github.com/SkateFreak/test

Scarysize commented 8 years ago

@SkateFreak Closing this up. For questions like this, try using stackoverflow, you might get your answer quicker.