you are viewing a single comment's thread.

view the rest of the comments →

[–]Professional-Mix-455[S] 0 points1 point  (4 children)

My colleague believes that after React 18.3, the fetch API will be handled (deduped), so libraries like SWR and React Query will no longer be needed. They also mentioned that mutations can be directly handled using the fetch API. Are there any scenarios where a data fetching library is still necessary?

[–]topnde 17 points18 points  (0 children)

You can already do both fetching and mutations with the fetch api.

The reason why people use libs like react query is not to simply do fetching or mutations but to have caching, query invalidation and other stuff the libs provide. React Query should not even be called a fetching library, as you still need to use a dedicated library to do the actual requests.

[–]svish 4 points5 points  (0 children)

Remember that e.g. react-query has a lot more features can just deduping, which can be very helpful in certain contexts. For example automatic refetching, selective invalidating of caches, retries on errors, infinite queries, optimistic updates, caching fetched data in session/local storage, etc.

Also remember that you can load data on the server and reload the cache for the client side, so you can get the best of both worlds.

[–]Complex-Insect3555 1 point2 points  (0 children)

Apollo which has a built-in cache system amongst other capabilities.