Hi, can someone help me with an existential question about fetching data using React Server Components (RSC) versus using react-query?
I'm trying to figure out the benefits of using RSC for data fetching over react-query. Initially, I thought with react-query you can handle all states: pending, data, and error, in a single component...
With RSC, you need to manage the fetching in one component, create another component ('use client') to pass the fetched data to, have another for the pending state, and another for the error state. Additionally, you need to add two more components: Suspense and ErrorBoundary. These last two can't be used in the same component where the fetch is done. So, to ensure standard handling of an HTTP request with RSC, you have to use/create more components than with react-query.
Then there's the part about sharing fetched data between components. It seems the answer is the same for both cases: "use the cache". However, I feel I have more control over the cache with react-query than with the cache in Next.js...
Am I missing something? What benefits do I get with RSC over react-query?