Similar presentations:
The advantages of React Query
1.
The advantages of React QueryBy Hakob Sargsyan
1
2.
▸TanStack Query (FKA React Query) is often described as the missing data-fetching library
for web applications, but in more technical terms, it makes in your web applications a breeze.
▸ While most traditional state management libraries are great for working with client state, they
are not so great at working with async or server state. This is because server state is
totally different.
▸ Server state
• Is persisted remotely in a location you do not control or own
• Requires asynchronous APIs for fetching and updating
• Implies shared ownership and can be changed by other people without your knowledge
• Can potentially become "out of date" in your applications if you're not careful
▸ $ How
to install the library
npm i @tanstack/react-query
# or
$ pnpm add @tanstack/react-query
# or
$ yarn add @tanstack/react-query
2
3.
1.2. React Query is hands down one of the best libraries for managing server state.
3. It works amazingly well out-of-the-box, with zero-config, and can be customized to your liking as your
application grows.
4. React Query allows you to defeat and overcome the tricky challenges and hurdles of server state and control
your app data before it starts to control you.
5. On a more technical note, React Query will likely: Help you remove many lines of complicated and
misunderstood code from your application and replace with just a handful of lines of React Query logic.
6. Make your application more maintainable and easier to build new features without worrying about wiring up new
server state data sources
7. Have a direct impact on your end-users by making your application feel faster and more responsive than ever
before.
8. Potentially help you save on bandwidth and increase memory performance
3
4.
▸ Optimizations We Get With React Query• Caching... (possibly the hardest thing to do in programming)
• Deduping multiple requests for the same data into a single request
• Updating "out of date" data in the background
• Knowing when data is "out of date"
• Reflecting updates to data as quickly as possible
• Performance optimizations like pagination and lazy loading data
• Managing memory and garbage collection of server state
• Memoizing query results with structural sharing
4