mozilla / science.mozilla.org

Making research collaborative, accessible, and usable
https://science.mozilla.org
Mozilla Public License 2.0
46 stars 49 forks source link

Global state management #605

Open arush0311 opened 7 years ago

arush0311 commented 7 years ago

I think it will be lot better for our state be handled by some state management engine (Redux , mobx etc). It will also help with https://github.com/mozilla/science.mozilla.org/issues/604 and https://github.com/mozilla/science.mozilla.org/issues/135

alanmoo commented 7 years ago

Would this enable server-side fetching of external APIs? It would be great if we could serve pre-rendered pages instead of making the client fetch more data after it loads React.

arush0311 commented 7 years ago

I dont think redux has much to do with server side rendering aside from providing store. Do we want it for seo? I think node (or phantom js) server would be needed to do anything of the sorts.

alanmoo commented 7 years ago

We are using a node server. I haven't dug into the SEO situation with things like Projects and Events, but it's simply better UX to send the user all the information they need to render the page in one response, rather than forcing another roundtrip. I haven't dug into Redux/Flux/etc. but I believe they can transfer state from the server to the client, which means all the information could be made available in the initial payload.

arush0311 commented 7 years ago

We are using a node server

What do we use it for?

it's simply better UX to send the user all the information they need to render the page in one response, rather than forcing another roundtrip

Well its a problem of first rendering. And yes, during first render all the response and initial state is calculated on a node server and then sent to client

HassenPy commented 7 years ago

@arush0311, i think what @alanmoo wants is described in this article https://hackernoon.com/reconciling-djangos-mvc-templates-with-react-components-3aa986cf510a

alanmoo commented 7 years ago

Not quite. More like http://redux.js.org/docs/recipes/ServerRendering.html

arush0311 commented 7 years ago

Well yeah! Redux can store the first render state and pass it to client. Where do we to our node related stuff?

alanmoo commented 7 years ago

There's not much to it right now; server.js is what node is running on production.

arush0311 commented 7 years ago

Ah. I will look into it :)

arush0311 commented 7 years ago

This is an interesting approach https://aakashgoel.com/server-side-rendering-with-a-django-webserver-57c7356effd1 without changing the django backend. @alanmoo ^

arush0311 commented 7 years ago

will also help with https://github.com/mozilla/science.mozilla.org/issues/597