blog/you-might-not-need-react-query #95
Replies: 16 comments 7 replies
-
In a sea of strong opinions which seems to be the trend right now, this was a refreshing read. Everything has its tradeoffs indeed. |
Beta Was this translation helpful? Give feedback.
-
may be not a right place to ask but, is server actions a react feature or a next.js one? |
Beta Was this translation helpful? Give feedback.
-
Good article! I personally prefer NestJS as backend framework |
Beta Was this translation helpful? Give feedback.
-
Great read and I couldn't agree more. react-query and RSC are not at odds, especially for apps with a variety of data fetching requirements. |
Beta Was this translation helpful? Give feedback.
-
Not everyone is doing SSR, so react query is still a valid choice |
Beta Was this translation helpful? Give feedback.
-
Very helpful article. Thank you 💯 🙏 |
Beta Was this translation helpful? Give feedback.
-
I think there are some good reasons not to use SSR. For example, with service workers, we can build web apps that are closer to native apps, as they only get source code from the server for updates. In this case, it would be silly to use SSR, as 99% of the time the app is loaded from cache. In this case, if we were to run code both on the client and the server, it would increase complexity. Personally, I think we should either do data fetching only on the server (with React Server Components), or on the client (with React Query). For websites, it makes sense to do things on the server, and for web apps things should be done on the client. I feel like true web apps (things you would expect from native, like 3D modelling, photo editing, etc.) should not be done with server-side libraries such as Next.js or Remix, but with client-side SPAs. We shouldn't neglect these types of apps. Great article though! |
Beta Was this translation helpful? Give feedback.
-
I'm stealing this quote to use as an answer to many React Hook Form question Lmao |
Beta Was this translation helpful? Give feedback.
-
From a high-level point of view, React-Query offers a generic wrapper around asynchronous operations. Data querying naturally just happens to be the most common one. I haven't used it for this, but I imagine it's generally useful in any cases where you have a long-running operation which needs any of the following:
I recently wrote about breaking up expensive blocking synchronous work into non-blocking asynchronous work, and I imagine that combining those cases with React-Query could be convenient in the React world. |
Beta Was this translation helpful? Give feedback.
-
Seeing this article show up confused me because React Query was never ONLY a data fetching tool for me. If data fetching was all I cared for, I would've stuck with fetch/axios. It seems that those who think React Query is dead doesn't realize data fetching itself was never a problem. RSC doesn't replace query caching, conditional cache invalidation, error handling, etc. If you think React Query is dead, you aren't using the library to its full potential. |
Beta Was this translation helpful? Give feedback.
-
really great read, it gave me some good ideas on how to implement react query while trying out RSC 🚀 |
Beta Was this translation helpful? Give feedback.
-
We've used server components with react query on a big app, it's working great. We just pass the data over to react query in a cache loading component and everything just works. Being able to then do everything on the client that tanstack query does is great. Optimistic loading particularly is something I think we would miss without it. |
Beta Was this translation helpful? Give feedback.
-
I can’t say I’m experienced in either React Query or Server Components. I only started migrating a personal project to React Query after reading your awesome posts, but I feel like you still need React Query in a lot of different situations. Maybe it’s due to my lack of understanding of Server Components. I was designing a page that displays a table with a lot of filtering (I can’t load all data and filter it on the client because it is a lot of data), I struggle to come up with a solution for Server Components. First, you can’t use state variables or hooks. I don’t really like to push every filtering change to URL (if that is the solution). I would rather have a custom useQuery hook with my filter variables (sorting, filtering, paginating) so React Query takes care of it instead. That way I don’t have to worry about which components will be server components and which components will be client components. Again I am not very experienced in either technology, so maybe I am thinking it incorrectly. But that’s my take so far after a week of experimenting with both. |
Beta Was this translation helpful? Give feedback.
-
Great article. |
Beta Was this translation helpful? Give feedback.
-
Absolutely! Stability is key in complex projects, and that's why many developers still rely on PHP (even with all the new frameworks emerging). The good news is, React Query's core functionality should remain relevant. The question is how it integrates with these exciting new features! |
Beta Was this translation helpful? Give feedback.
-
blog/you-might-not-need-react-query
React Query is a great library, but like any tool, you should choose it for the right problem
https://tkdodo.eu/blog/you-might-not-need-react-query#inject-comments
Beta Was this translation helpful? Give feedback.
All reactions