New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[universal-redux] Hydrate store "on page load" #17
Comments
Hi, @0xsven I'm currently working on a project that implements it. It's still unfinished, but you can check that out to see how this works: https://github.com/tramaLabs/web These are the steps to implement that: 1. First you need to install some isomorphic cookie handler. I'm using
|
Also, read this section on the README for running sagas on the server side. |
Step 4/5 is where I was stuck! Thank you. I guess the api call "to get user data" I would do in some componentWillMount function of the particular component that needs the data? Btw. this thing I found quite helpful: https://github.com/mjrussell/redux-auth-wrapper |
You can do that and it will work on the client, but the server will not wait for the request to complete. There're many ways to solve this problem. The one I like, which is adopted by this boilerplate, is what's done on SamplePage. The caveat of this approach is that you can't do that on any component, but only on those are used by the router on src/routes.js (essentially pages). |
I would like to hydrate my store with user data "on page load" (meaning: before initial render). Basically something like that:
That code should be shared with the application so I can reuse it for the login form.
I am not sure when and how to do this with server side rendering. My thoughts are:
It would be great if you could give me your thoughts.
The text was updated successfully, but these errors were encountered: