Installing and configuring React Query
Installing this library is no different from any other dependency, we need to run an installation script. To do this using npm
, enter the following:
$ npm i @tanstack/react-query
Or if you would prefer to use yarn
, enter the following:
$ yarn add @tanstack/react-query
Once the library is installed, we will need to add some minimal boilerplate. We will need to let our app know that we’re using React Query. We will need to use a special wrapper. Do you see where I’m going with this? Yes! We will use a provider as follows:
// App.js import { QueryClient, QueryClientProvider, } from '@tanstack/react-query' //… const queryClient = new QueryClient() export default function App() { //… return ( <SafeAreaProvider> <QueryClientProvider client={queryClient}> //… &...