-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn React with TypeScript
By :

In this section, we will learn how TanStack Query can be used to share state that usually comes from a server database across different React components. We will then move on to learn how state can be shared across components using URL search parameters.
We have already used TanStack Query in Chapter 8, Client Component Data Fetching and Mutations with TanStack Query, and used URL search parameters in Chapter 6, Creating a Multi-Page App with Next.js. So, we will focus on the state-sharing aspects rather than the full implementation details.
We will use an extension of the app we have been building to understand how both TanStack Query and URL search parameters can be used to share state. The app has been reworked to only return a user ID from a sign-in and to get information about the user using TanStack Query. The user information is shown in tabs, with the active tab stored as a URL search parameter.
Figure 10...