erikras / react-redux-universal-hot-example

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

Serverside rendering question #1290

Closed sathify closed 7 years ago

sathify commented 7 years ago

Hi folks! Looks like there is no guarantee that after an async API call on the server, the reducer will run first to generate new state object before the response is sent to the client. The server returns as soon as the api call is a success (when the promise is returned) but the state is set after by the reducer leading to a race condition. Any information/pointers on how this was solved would be greatly appreciated!

VSuryaBhargava commented 7 years ago

I think redux-async-connect Is doing most of the work.

In server.js the loadOnServer from redux-async-connect is called I think this makes sure all the promises are resolved before the page is rendered and sent to the clients.