cloverfield-tools / universal-react-boilerplate

A simple boilerplate Node app.
MIT License
904 stars 97 forks source link

How does one hydrate the initial state from a backend operation? #92

Open Twipped opened 8 years ago

Twipped commented 8 years ago

Your reducer is starting with an initial state that is hard coded into the file, but in most cases of a universal app that state will need to be setup from some sort of backend controller.

I'm not able to find any good examples on how that is done, either when rendering on the server side or when initializing the client. It would be helpful if this boilerplate could demonstrate that.

yanivkalfa commented 8 years ago

you will set the intitalState of store create to window.BOOTSTRAP_CLIENT_STATE i dont know why they haven't done it yet

look at:

https://github.com/cloverfield-tools/universal-react-boilerplate/blob/master/source/server/routes/main/index.js#L13-L23

https://github.com/cloverfield-tools/universal-react-boilerplate/blob/master/source/server/render-layout.js#L11