erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12k stars 2.5k forks source link

Question: How is window.__data being set by the server (and where?) #1259

Open davidfurlong opened 8 years ago

davidfurlong commented 8 years ago

I'm looking into storing the redux state in localStorage to be loaded initially, but it seems that the server is already doing this somehow? I'm a little confused as to where the data is setting window.__data and assume its some library call doing it. Thanks!

Additionally we've moved away from sessions and towards a RESTful API but I'm worried about performance in terms of server side rendering / redux model storage and how thats working. I appreciate any advice!

jdosullivan commented 8 years ago

It's being set in the HTML.js. No libraries or magic tricks, just a straightforward serialization of the redux store. Here is the line in HTML.js: <script dangerouslySetInnerHTML={{__html:window.__data=${serialize(store.getState())};`}} charSet="UTF-8"/> ` I'm not sure I understand the second question so if you can elaborate more I will try to answer.