I just need to put some data from backend apis to redux store,but not all. I wonder that will RTK Query put all data to store as default? If yes, it will lead to more memory assumption, and is it still recommended to manage all apis using RTK Query?
Asked
Active
Viewed 768 times
1 Answers
0
Yes, it will put all data there. You can use transformResponse
to remove data form the response if you don't want it in the store.
Generally, this might use more memory, but RTK-Q tracks which of your components are using which data and will remove cache values that are not required any more when your components unmount - which will in the end probably free up memory compared to managing that data by hand, where such behaviour is often an afterthought.

phry
- 35,762
- 5
- 67
- 81
-
Is RTK-Q the abbrev of RTK Query? Do you means that RTK Query will start put data that only used in current component and auto removed when component unmount? Any reference docs related with it? – ishowman Oct 05 '21 at 14:17
-
Yes, I use RTKQ or RTK-Q for RTK Query (which is also just short for Redux Toolkit Query). After the last component using a cache entry unmounts, the data is held for a while (usually 60 seconds) and then removed. Give https://redux-toolkit.js.org/rtk-query/usage/cache-behavior#default-cache-behavior a read. – phry Oct 05 '21 at 19:18