bertho-zero / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using react, redux, express and feathers
https://react-hot-example.herokuapp.com/
MIT License
635 stars 171 forks source link

feat(universal rendering): redial await fetch on a server-side only #502

Closed gmsorrow closed 5 years ago

bertho-zero commented 5 years ago

Why ?

We are always waiting for the result of fetch, it is defer which is deferred, defer is not executed server side.

If an operation should not be expected on either server side or client side then it should not be in a provideHooks.

gmsorrow commented 5 years ago

Why ?

We are always waiting for the result of fetch, it is defer which is deferred, defer is not executed server side.

If an operation should not be expected on either server side or client side then it should not be in a provideHooks.

To speed up interface If data is mandatory for server rendering, but can be deferred for frontend.

For example. Project has two pages Home, Contacts. Home page needs to fetch list of books only. Books fetch should use await on server to build entire page, but on client when user go to Home from Contacts he immediately sees a page with components and don't have to wait on books fetch.

bertho-zero commented 5 years ago

The goal of fetch is to block the page loading time. If you do not want to wait then do not return the promise in the provideHooks, only for the client in your case.