(This is maybe not a redux question per sé)
My current strategy/thoughtprocess is this: every container component that needs data, dispatches an action that fetches that data in componentDidMount (which then triggers an api request, that dispatches an action that updates the store)
The problem with this: some components are fetching the exact same data. This also means that when I load my app a (sometimes "large") number of unneccessary requests and rerenders happen.
My question: what's a better way of handling this?
Personally I see two ways:
- somehow cache the data returned from the server, and if a new request is triggered that has cached data (and happens within a certain timeout), return that cached data instead of making a new request.
- fetch all my app data somewhere else in one spot. (the drawback I see is that my container components aren't "self-sufficient" then)
My guess is that there is some better way that I can't seem to see :)