Introduction to React Query

Published on 24 Jul, 2021

React Query is used to work with Asynchronous data in React. It helps to fetch, cache and update data in React and React Native applications.

Installation

React Query can be added in any project using:

yarn add react-query

3 Core Concepts

3 Core concepts in React Query are:

  1. Queries
  2. Mutations
  3. Query Validation

A query is used to fetch data using useQuery hook.

Mutations are used to create/update/delete data in server. We use useMutation hook.

Query Validation helps to check if queries are stale and potentially refetch data. We use useQueryClient for query validation.