dlmr/react-router-redial

SSR Client still makes initial fetch

LavaToaster opened this issue · 2 comments

Hey There,

Before I implemented this library I had some code that would listen to the browserHistory and only trigger defer on page load, and fetch / defer for every route change thereon.

Does this happen the same way in this library, or am I going back to checking if the data is in the store on the client before dispatching the redux action?

dlmr commented

Hello! 👋

There is currently no way to prevent the first fetch other than adding logic managing bailout (prevent fetching if the data already is present) in some way.

The reason for this is that we can't be sure that the server side fetching completed successfully and because of this we might need to do another fetch when we load the application in the client. In addition to that we will most likely want to implement a form of bailout anyhow since that we help us when going back and forth in the application preventing unnecessary fetching.

A way to manage this in a good way could be to use some form of Redux middleware that does this automatically, like redux-api-middleware#bailing-out.

I literally just checked this, saw no reply, closed it, and then got an email you replied. Haha, talk about timing.

Thanks for that, I'll take a gander into it. :)