T
TanStack•12mo ago
stormy-gold

React Query vs "use-reducer-async" library

Hi, guys, i'm trying to do some comparasions to find the best way to handle Server State on our project. We're a e-commerce company that we're migrating to a new stack: From Django Template + React -> Next.js App Router Even with RSC, we still have some client state. Currently we have different things around from legacy code, - Some queries useFetch custom (useEffect) - Some queries use Redux with Saga - Some queries use "use-reducer-async" https://github.com/dai-shi/use-reducer-async I'm exploring introduce RQ or SWR as new alternative, but i haven't found any comparasions vs "use-reducer-async" library. It's seems like is a good way to handle your async state, it's simple and can be broken in different Contexts or Hooks. Can someone give me a good case for RQ or SWR, i really want to use them, but i need to present a good case for the decision.
GitHub
GitHub - dai-shi/use-reducer-async: React useReducer with async act...
React useReducer with async actions. Contribute to dai-shi/use-reducer-async development by creating an account on GitHub.
2 Replies
yappiest-sapphire
yappiest-sapphire•12mo ago
Here's a short list of things an async state manager needs to provide and/or handle: 1. Cache management 2. Cache invalidation 3. Auto refetching 4. Scroll recovery 5. Offline support and recovery 6. Window focus refetching 7. Dependent Queries 8. Paginated Queries 9. Request cancellation 10. Polling 11. Managed mutation lifecycles 12. Infinite scrolling 13. Data selectors 14. Network waterfalls 15. Cache preloading/prefetching 16. Race conditions 17. Declarative API's 18. Exponential backoff retries 19. React suspense support 20. Garbage collection 21. Stale while revalidate 22. Parallel queries 23. Cache persistance 24. Optimistic updates w/ rollbacks use-reducer-async is what you could create in an hour or two for a generic fetch function. Query and SWR are years of community effort solving big async problems. They don't really compare.
stormy-gold
stormy-goldOP•12mo ago
Thanks, you're the best 🙂

Did you find this page helpful?