Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AZ Does it mean whenever client has a get request, server will iterate every route and fire API call for each one to fill Redux store? #12

Open
ArtixZ opened this issue Aug 9, 2018 · 0 comments

Comments

@ArtixZ
Copy link

ArtixZ commented Aug 9, 2018

app.get('*', (req, res) => {
  const store = createStore(req);

  const promises = matchRoutes(Routes, req.path)
    .map(({ route }) => {
      return route.loadData ? route.loadData(store) : null;
    })
    .map(promise => {
      if (promise) {
        return new Promise((resolve, reject) => {
          promise.then(resolve).catch(resolve);
        });
      }
    });

  Promise.all(promises).then(() => {
    const context = {};
    const content = renderer(req, store, context);

    if (context.url) {
      return res.redirect(301, context.url);
    }
    if (context.notFound) {
      res.status(404);
    }

    res.send(content);
  });
});

Looking at this part of code in index.js, this method is bind to every get request.

Does it mean there is a lot of overhead when user navigates frequently between screens?

Same issue raised here: https://www.udemy.com/server-side-rendering-with-react-and-redux/learn/v4/questions/4896838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant