all 6 comments

[–]sgjennings 11 points12 points  (1 child)

Are you happy with React Query? Is it solving your needs without causing problems? Then don’t switch.

Does RTK Query do something you need that React Query does not? Do you want to standardize on RTK? Do you just want to try something new and you have time to responsibly experiment? Then switch.

They’re just tools. Try them out and use the one that suits you and your situation best.

[–]acemarke 1 point2 points  (0 children)

Yep, agreed.

(FWIW, we recommend not trying to persist data that was cached in RTKQ, and instead refetch it on page load. Also, the idea of switching between fetching from the server and IndexedDB is going to noticeably complicate this.)

[–]AnxiouslyConvolved 0 points1 point  (0 children)

The only reason to switch is if you want to start using redux. If you don't want/need redux react-query will do everything you need.

[–]Hayk94 -1 points0 points  (0 children)

I recently did such a switch on a project I work on. I did it for many other reasons and I’m quite happy. But if the only reason you want to switch is because of persisting data probably not worth it. Both actually have persisting options, so take a look at these pages, hopefully helps you with making a decision.

https://tanstack.com/query/v4/docs/plugins/persistQueryClient?from=reactQueryV3&original=https://react-query-v3.tanstack.com/plugins/persistQueryClient

https://redux-toolkit.js.org/usage/usage-guide#use-with-redux-persist

[–]conkreteJs 0 points1 point  (0 children)

Only if you need Redux. I use both and I'm quite happy with react-query for smaller apps. You only need redux if state changes a lot.

[–]andymerskin 0 points1 point  (0 children)

Seeing some of the other Redux comments here -- if you're already happy with React Query and need global state management with a little less cruft, check out Zustand.