3 ms·
Check my demo using Redux: I populate the "initialState" on the server side [1] before React comes into the picture, and then populate it again on the client si
by firasd 10y ago
Check my demo using Redux: I populate the "initialState" on the server side [1] before React comes into the picture, and then populate it again on the client side [2], then client-side Redux can do its own thing.
Some explanation at [3] although that writeup (and this demo code) needs updating.
[1] https://github.com/firasd/react-server-tutorial/blob/master/server.js#L104 https://github.com/firasd/react-server-tutorial/blob/master/...
[2] https://github.com/firasd/react-server-tutorial/blob/master/public/index.js#L57 https://github.com/firasd/react-server-tutorial/blob/master/...
[3] https://medium.com/@firasd/quick-start-tutorial-universal-react-with-server-side-rendering-76fe5363d6e https://medium.com/@firasd/quick-start-tutorial-universal-re...
- idbehold 10y agoBut that means that I need to know which express routes are going to need what data. The react components should be able to declare the data they need and the server should be able to fetch that data before attempting to render server-side. There's not much of a point if I have to know ahead of time what data any react component rendered by a route will need.
- firasd 10y agoI'm not sure 'components declaring the data they need' is a necessary React idiom especially if you're using Flux. But I do understand that any large application will need 'partial' state and you can't fill out the entire app data for every request like I do in my smaller demo apps.