Using react-query with redux-saga #3471
-
Hello there! I am looking for library which can help me to cache my requests. But there is no need for me to put useQuery hooks in component i get all my data and store all my data in redux. So is it possible to cache request without any hooks? Or should i do it another way. I haven't found any good examples for this case. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You can give your sagas access to the query client directly and they can use |
Beta Was this translation helpful? Give feedback.
-
if you are already using redux then consider using redux toolkit query instead https://redux-toolkit.js.org/rtk-query/overview |
Beta Was this translation helpful? Give feedback.
-
Hey everyone — I ended up exploring the same idea of combining Redux Saga and React Query while working on a micro frontends setup. To test the concept, I put together a working demo: 👉 react-query-saga-microfrontends Instead of using QueryClient directly in sagas, the approach relies on a custom abstraction layer that wraps queryClient.fetchQuery, invalidateQueries, and similar methods. This allows React Query to handle server cache, while Redux Saga takes care of control flow and side effects. 🔍 Highlights:
This isn’t intended as a production-ready solution, but rather a proof of concept to explore how this hybrid setup might work in practice. Feedback or improvements are welcome — hope this helps someone digging into similar patterns! |
Beta Was this translation helpful? Give feedback.
if you are already using redux then consider using redux toolkit query instead https://redux-toolkit.js.org/rtk-query/overview