DEV Community

Cover image for useQuery Hook (React Query)
Kudzai Murimi
Kudzai Murimi

Posted on • Edited on

useQuery Hook (React Query)

Tanstack Query is mainly accompanied by 2 main hooks namely

  1. useQuery
  2. useMutation

The easiest way for one to understand these hooks easily is by asking yourself these few simple questions:

In Tanstack Query, we have some common hooks, Which are they, when do we apply them and how do we apply them?

In article, we are going to talk about the useQuery Hook.

What is useQuery hook

  • it is a hook used to fetch data, it does a lot of work, caching data after its initial fetch, refetching data in the background.

The useQuery has commonly used properties.

FetchStatus in React Query

'fetchstatus'=== 'fetching' meaning that the query is currently fetching.
'fetchstatus'=== 'paused' meaning that the query wanted to fetch but is currently paused.
'fetchstatus'=== 'idle' meaning that the query is not doing anything at the moment.

Let's query dive into how to apply the useQuery hook in our code.

Top comments (0)