Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
State Management with React Query
State Management with React Query

State Management with React Query: Improve developer and user experience by mastering server state in React

eBook
$9.99 $23.99
Paperback
$29.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

State Management with React Query

Part 1: Understanding State and Getting to Know React Query

State is what makes your applications move. What many of us are not often aware of is that there are different types of state. These different types lead to different challenges when managing the given state. In this part, we will understand more about state and how we manage it. During this process, we will understand that the server and client states have very different challenges that need to be handled separately and with different tools. To deal with server state, we will learn more about the TanStack Query React adapter called React Query and see how to add it to our applications.

This part includes the following chapters:

  • Chapter 1, What Is State and How Do We Manage It?
  • Chapter 2, Server State versus Client State
  • Chapter 3, React Query – Introducing, Installing, and Configuring It
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn how state is split into server and client state and the common challenges with each
  • Understand how React Query addresses server state challenges by facilitating data fetching and mutations
  • Apply the knowledge gained to improve developer experience and build applications with improved UX

Description

State management, a crucial aspect of the React ecosystem, has gained significant attention in recent times. While React offers various libraries and tools to handle state, each with different approaches and perspectives, one thing is clear: state management solutions for handling client state are not optimized for dealing with server state. React Query was created to address this issue of managing your server state, and this guide will equip you with the knowledge and skills needed to effectively use React Query for state management. Starting with a brief history of state management in the React ecosystem, you’ll find out what prompted the split from a global state to client and server state and thus understand the need for React Query. As you progress through the chapters, you'll see how React Query enables you to perform server state tasks such as fetching, caching, updating, and synchronizing your data with the server. But that’s not all; once you’ve mastered React Query, you’ll be able to apply this knowledge to handle server state with server-side rendering frameworks as well. You’ll also work with patterns to test your code by leveraging the testing library and Mock Service Worker. By the end of this book, you'll have gained a new perspective of state and be able to leverage React Query to overcome the obstacles associated with server state.

Who is this book for?

The book is for React developers who want to improve their state management skills and overcome the hurdles brought about by server state while improving their developer and user experience. Basic knowledge of web development and React will assist with understanding key concepts covered in this book. JavaScript developers will also find it useful.

What you will learn

  • Learn about state and how it s often managed
  • Discover how state splits into server state and Client state
  • Solve common challenges with server state using React Query
  • Install and configure React Query and its Devtools
  • Manage server state data fetching by using the useQuery hook
  • Create, update and delete data by using the useMutation hook
  • Discover the use of React Query with frameworks like Next.js and Remix
  • Explore MSW and the Testing Library to test React Query using hooks

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 12, 2023
Length: 228 pages
Edition : 1st
Language : English
ISBN-13 : 9781803244839
Vendor :
Facebook
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 12, 2023
Length: 228 pages
Edition : 1st
Language : English
ISBN-13 : 9781803244839
Vendor :
Facebook
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 119.97
State Management with React Query
$29.99
Learn React with TypeScript
$44.99
React 18 Design Patterns and Best Practices
$44.99
Total $ 119.97 Stars icon
Banner background image

Table of Contents

13 Chapters
Part 1: Understanding State and Getting to Know React Query Chevron down icon Chevron up icon
Chapter 1: What Is State and How Do We Manage It? Chevron down icon Chevron up icon
Chapter 2: Server State versus Client State Chevron down icon Chevron up icon
Chapter 3: React Query – Introducing, Installing, and Configuring It Chevron down icon Chevron up icon
Part 2: Managing Server State with React Query Chevron down icon Chevron up icon
Chapter 4: Fetching Data with React Query Chevron down icon Chevron up icon
Chapter 5: More Data-Fetching Challenges Chevron down icon Chevron up icon
Chapter 6: Performing Data Mutations with React Query Chevron down icon Chevron up icon
Chapter 7: Server-Side Rendering with Next.js or Remix Chevron down icon Chevron up icon
Chapter 8: Testing React Query Hooks and Components Chevron down icon Chevron up icon
Chapter 9: What Changes in React Query v5? Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(5 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
M. Jun 26, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
1) Starts with the absolute basics and slowly accelerates until you're going full-speed and don't even realize it.2) Uses simple, logical examples that are easy to understand and reapply later.3) Doesn't linger on any topic too long, rather a steady pace is maintained it the entire way through.4) Any React dev who picks up this book is walking away at least one valuable addition to their box of tricks.
Amazon Verified review Amazon
William Kotheimer May 31, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
“State Management with React Query” starts with comparing useState, useReducer, and useContext for managing state. You don’t need know how React hooks work to understand this. He really does a great job both explaining these concepts, and showing how one would use them in an increment/decrement app. In doing this, he also lays the conceptual groundwork for understanding what React Query does for api state, i.e. taking over this aspect so that these other hooks can focus on app state. I thought he did a great job of explaining these “separation of concerns” before delving into fetching apis and using state with react query.I was surprised by the depth of this book. Even only 100 pages in, he already covered getting api data with either fetch or Axios library, and setup for caching data and using it, and invalidating cache after a POST request is made that triggers a refetch. This was a great way to show how much control React Query offers over when to allow data fetches to occur, even better than when useEffect was used to trigger apis calls on page load and populate useState. In addition, he shows using callbacks after a success, conditional enabling, cache time, and notifications.I’d recommend this book for anyone who desired an overview of React Query. It doesn’t use typescript but that’s the only thing that seems to be missing here. The second half of the book delves into using Remix and Next.js with React Query for server side rendering, and testing.If you’re looking for something to get started with React Query, definitely try the docs, but if you are looking for something more, “State Management with React Query” by Daniel Afonso is a great choice.
Amazon Verified review Amazon
Yevhenii Jun 19, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
"State Management with React Query" surpassed my expectations with its comprehensive and accessible approach. The author skillfully explained the nuances of useState, useReducer, and useContext, making them easily understandable even for beginners. The book seamlessly integrated these state management techniques into an increment/decrement app, while also laying the groundwork for comprehending React Query's role in API state management. Furthermore, it covered essential topics such as fetching API data, caching, invalidation, and advanced features like callbacks and conditional enabling. Despite the lack of TypeScript implementation, I highly recommend this book as a valuable resource for anyone looking to gain a thorough understanding of React Query and its practical applications.
Amazon Verified review Amazon
CP MB Jun 02, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
From the beginning, I realized this book could be an excellent book, and in the end, it didn't disappoint. The author took the time to explain in detail the most popular current approaches to application state management and later explained why his approach is better, which I agree with. This book is well thought out and it feels like there was a significant amount of planning done by the author before writing the first chapter. If you want to implement application state the right way, read this book!
Amazon Verified review Amazon
Tudor Jun 06, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really like the book, it's smooth to read, and I like how the information is presented and how the author adds React specific explanations to help the readers refresh their knowledge and better understand a topic.From the start it doesn't rush things it sets the stage and shows the pain points so you better understand why you need React Query.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.