Share a data-loading component between multiple pages


I would like to create a reusable component that loads data asynchroneously.

For example, I have my blog page, and on the right side a sidebar with a list of item unrelated to the main content (e.g. a list of month to display posts of this month, a list of the last comments on the whole website, etc…).

How should I do that ? I have red that doing asynchroneous requests in components was not a good pratice. I can’t do it in a the route because the sidebar is not related on the context and I want to use it in any route.

Any idea ?



Getting data in a scenario like this is ok, in my opinion.

Here is an example of a pattern to follow that does it. You can do similar with ordinary promises.