benkingcode / react-data-fetching-components

♻️ Asynchronously load data for your React components with SSR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage with redux & nested data fetching on the server-side

oyeanuj opened this issue · comments

commented

Hi @dbbk, thank you for open-sourcing this. This looks very promising.

I was wondering if there are any considerations to be kept in mind while using it with Redux? In a classic scenario, the initial requests might be populating the store, and via selectors, some props. So, at that point the need for data prop is less and a status of request more so.

As an example, a particular case in mind is in my app, I fire a redux action to load JWT token from the cookie, validate it from the server and fetch basic user action before anything can proceed.

Thank you!

commented

Hey @dbbk, just looping back to see if you could answer the query above, and one other query I had - what is the expect behavior on the server-side with nested getInitialData calls? Does it resolve one call, continues render and then resolves the nested call as well?

Here is an illustrative setup:

<App>
 <JWTHandler> /* <--- Fetch data */
  { (isLoggedIn) => (  
     <Switch>
      <Route>
        <ProfilePage />  /* <------- Fetch data */
      </Route>
     </Switch>
  )}
  </JWTHandler>
</App>

Would the ProfilePage component's getInitialData be fetched on the server-side as well?