4 ms·
react-query to handle server updating state and per component hooks for local state items. react-query has hook wrappers that allow accessing data you've fetch
by dbetteridge 4y ago
react-query to handle server updating state and per component hooks for local state items.
react-query has hook wrappers that allow accessing data you've fetched once across multiple components.
Calling the refetch in one will update all components using that data.
It's clean and minimises the need to think about shared state
- parf02 4y agoThis. Along with a global state library of your choice for everything that is not server related data.
- lastofus 4y agoI've recently started working with React Query (now Tanstack Query since is supports Vue and others) and I absolutely love it. Coupled with a sprinkling of `useState` and context, I'm all set. Of all of the SPAs I've worked on, 90%+ of the "state" is just server side data, pulled down via APIs, to display to the user. Other state libs don't bother to take into account common things like cache invalidation, or loading states, but it's all built in to React Query.
- antigirl 4y agothis, hands down is the best solution. I was using Apollo initially for my graphQL needs and started using that for local state too, but moved to urQL as found Apollo bit slow and bloated. I love the loading/err/res conventions carried over to react-query.