T
TanStack•2y ago
mute-gold

Deleting Cached Data Programmatically in RTK Query after Mutation

Hello community, I am currently working with RTK Query in my project and facing a challenge that I couldn't find a solution for online. I have two different queries, each fetching different types of data, and both queries have defined tags. My goal is to automatically remove the cached data for both queries after the completion of a deletion mutation. The catch is that the solution using invalidatesTags doesn't work for me because it triggers a refetch of the data. However, the data in my application already has validations/checkers set, and I cannot afford to refresh or lose these states. Here's a brief overview of the situation: - I am using RTK Query. - I have two queries that fetch distinct types of data. - Both queries have defined tags. - After a deletion mutation, I want to programmatically remove the cached data for these two queries without triggering a refetch. If anyone has encountered a similar situation or knows how to achieve cache clearance in RTK Query without causing a refetch, I would greatly appreciate your guidance. Any insights, examples, or pointers to relevant documentation would be incredibly helpful. Thank you in advance for your assistance!
No description
1 Reply
correct-apricot
correct-apricot•2y ago
This is the react-query channel, not rtk-query 😅 . Try the reactiflux discord

Did you find this page helpful?