Fetching Data with React Query
React Query allows you to fetch, cache, and handle your server state by leveraging one of its custom hooks called useQuery
. For your data to be cached, React Query has a concept called a query key. In combination with the query keys and a couple of strict defaults, React Query takes your server state management to the next level.
In this chapter, you will be introduced to the useQuery
hook and understand how React Query allows you to fetch and cache your data. During this process, you will get to know all the defaults that are used in all of your queries. You will also be introduced to some options you can use to make your useQuery
experience even better.
After becoming familiar with useQuery
, you can start using it to refetch your queries in certain scenarios. You will also be able to leverage some extra properties of useQuery
to fetch queries that depend on each other.
At the end of this chapter, we’ll review a code file to review what...