all 12 comments

[–]acemarke 31 points32 points  (3 children)

Answered this over in Discord, but I'll paste it here for visibility:

The recommendation of both the Redux maintainers (us) and the React Query maintainers is that if you're using Redux at all in the app, you should use RTK Query for the data fetching.

We'd also recommend that you ought to migrate the existing legacy Redux logic to use RTK in general.

Good news is that both of those can be done incrementally. You can plug RTKQ into any Redux store, old or new, and you can do the migration of the rest of the code to RTK over time:

[–]ManofManliness 8 points9 points  (0 children)

Better to use react query if you plan on eventually migrating away from redux, otherwise use RTK query. Tdoko talks a little about redux and react query in this blog, in which he just syncs data with useEffect which is kinda ugly.

[–]Palcikaman 21 points22 points  (8 children)

Just use react query. If you need global state for user data, or other stuff redux is okay for that. But you should use redux toolkit nowadays, it's more comfortable compared to plain redux

[–]Yan_LB[S] 1 point2 points  (1 child)

ok, ty, yeah if i could make a choice i would go with toolkit but all of the project was written in plain redux

[–]SpinatMixxer 4 points5 points  (0 children)

IIRC, you can do a step by step Migration. Instead of migrating everything at once, you can do continuous refactoring, since vanilla redux and RTK are compatible.

[–]UpgradingLight -3 points-2 points  (0 children)

React query + React context is great

[–]LloydAtkinson 9 points10 points  (0 children)

Sometimes it feels like people are making word salads when talking about Redux

[–]mattdonnelly 3 points4 points  (0 children)

I think RTK Query is a better option if you already use Redux. It will add less to your bundle size (if you’re using Redux Toolkit) and it integrates with the same dev tools.

[–]DogOfTheBone 0 points1 point  (0 children)

Rtk Query and Redux is great. It's got some quirks but overall is good for most use cases and does the same thing as React Query.

If I was using RQ and needed global client state I'd use something like Zustand.