Reputation: 3948
I'm running a comparison between RTK Query and React Query, trying to decide which one to use in my React/Redux app.
One of the points for consideration is their integration with Redux.
I did some research and it seems like the only difference between the two in that regard, is that if using RTK Query you would see the query results in your Redux store and in the Redux DevTools which is a bit more convenient.
Am i missing something else? Or other than that, they both work the same with Redux?
Upvotes: 2
Views: 1936
Reputation: 131
If redux is being used then RTK query can be a good choice for cache management because then the reducer of the api services example: post service, can be easily used in the store by adding them in the reducer object in the store. And if RTK query will be used with redux then there will be a lesser requirement of writing middleware in the code for redux.
Upvotes: 0
Reputation: 44078
RTK Query is part of your Redux store and as such also internally works with Redux. Everything is an action. So you can listen for those actions in your own middlewares or you can have your normal slice reducers act on top of those actions.
Granted, both React Query and RTK Query take over cache management for you, so in both cases, that data will be kinda separated - just because it is conceptually not very interwoven with your other state in most situations.
Upvotes: 4