Skip to content

This Project helps us to understand the use of tanstack-query formally known as react-query.

Notifications You must be signed in to change notification settings

Skynet966/React-Query-learnings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Query

What?

A library for fetching data in a React application.

Why?

  1. Since React is a UI library, there is not specific pattern for data fetching
  2. useEffect hook for data fetching and useState hook to maintain component state like loading, error or resulting data.
  3. If the data is needed throughtout the app, we tend to use state management libraries.card
  4. Most of the state managatment libraries are good for working with client state. Ex: 'theme' for the application/ whether a modal is open.
  5. State management libraires are not great for working with asynchronous or server state.em>

Client vs Server state


Client state

  • Persisted in your app memory and accessing or updating it is synchronous.

Server state

  • Persisted remotely and requires asynchronous APIs for fetching or updating.
  • Has shared ownership.
  • Data can be updated by someone else without your knowledge.
  • UI data may not be in sync with the remote data.
  • Challenging when you have to deal without caching, deduping multiple requests for the same data, updating stale data in the background, performance optimizations etc.

Content covered

  • Basic queries
  • Poll data
  • RQ dev tools
  • Create reusable query hooks
  • Query by ID
  • Parallel queries
  • Dynamic queries
  • Dependednt queries
  • Infinite & paginated queries
  • Update data using mutations
  • Invalidate queries
  • Optimistic updates
  • Axios Interceptor

About

This Project helps us to understand the use of tanstack-query formally known as react-query.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published