Hacker News new | ask | show | jobs
by soulchild77 1420 days ago
We're happy users of react-query[1]. Its stale-while-revalidate approach makes Redux and Co. unneccessary for most use-cases.

If you have an OpenAPI spec of your REST API you can auto-generate a react-query based frontend client with Orval[2]. Works pretty well, but probably takes a bit more time to set up.

[1] https://tanstack.com/query/v4/ [2] https://orval.dev/

1 comments

Thank you, react-query is one of the solutions we were looking into, glad to hear there are happy users of it.

One thing I like about the apollo client is that it handles a lot of the cache invalidation for you, where as react-query it seems to be a bit more of a manual process, how are you and your team handling cache invalidation?

react-query indeed doesn't automatically take care of this. We manually invalidate its caches (based on the query key, so you only ever invalidate what has changed) after a mutation happens. It's not as bad as it sounds because most of the time it's just one line of code.