How to cache API response and use it later in react & redux?

后端 未结 3 765
再見小時候
再見小時候 2021-02-05 17:47

In my React based application, there is a rest API call which fetches all the data in one shot which is needed for the whole page. The response has data which can be used in a p

3条回答
  •  春和景丽
    2021-02-05 18:11

    As I guessed you are using redux for state management. And You want to cache api calls for efficient controll state changes for avoiding rerendering Components, unnecessarry API calls and being friendly for Mobile Users (with avoiding fetchig same data(not changed) multiple time). If so -> then you can use ready solution for it.

    redux-cache. please visit below link for additional information and investigate caching mechanizm briefly -> when you need cache data and when you need evict cache.

    https://github.com/JumboInteractiveLimited/redux-cache

    How do I implement caching in Redux?

提交回复
热议问题