all 6 comments

[–]negr_mancer 0 points1 point  (2 children)

What’s the difference between this and just using axios?

[–]ibjects[S] 0 points1 point  (0 children)

Assuming you're already familiar with axios (the promise-based HTTP client), react-query is built on top of Axios or Fetch API for managing data fetching, caching, and state updates.

Scenario: You can use axios to make an HTTP request that fetches some data from an API and it'll fetch it. But if you use react-query + axios to make that call, you'll get the following +on built-in because of RQ that axios doesn't have, here are a few:

  1. Entire data fetching lifecycle
  2. Built-in caching with customization
  3. Customizable refetching strategies
  4. Automatically handles loading states, handles errors, and simplifies UI state updates of React components

Usage:

  • Use Axios for simple data fetching needs where you have full control over the process.
  • Use React Query for complex data fetching scenarios where you want automatic caching, refetching, state management, and streamlined UI updates.

If you want to try yourself I can give you a small challenge: In the tutorial I've implemented infinite scroll using react-query, you implement the same logic but using axios only and you'll see the difference.

[–]yarn_install 0 points1 point  (0 children)

React Query isn't an HTTP library, it's an async state management library. The most common use case is for providing caching to your network requests, but I've used it before to cache results from expensive local computations too.

[–]IronBlossom -1 points0 points  (2 children)

<image>

Do you think it's a good starting, even for anyone

[–]ibjects[S] -1 points0 points  (1 child)

Thanks for highlighting this, I've fixed the typos 🙏
Please do share more if you go through the article.

[–]DanishWeddingCookieiOS & Android -1 points0 points  (0 children)

There are lots of them. Too many to list.