Skip to content

Commit daa5b60

Browse files
committed
queryclient code
1 parent bd4dfb4 commit daa5b60

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lessons/05-ecosystem/B-tanstack-query.md

+15
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
5151
<ReactQueryDevtools />
5252
```
5353

54+
Finally, we need to add the `QueryClient`. In `App.jsx`, add:
55+
56+
```javascript
57+
// Add imports
58+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
59+
60+
// Create a property under the router
61+
const queryClient = new QueryClient()
62+
63+
// Add the provider to the app
64+
<QueryClientProvider client={queryClient}>
65+
<RouterProvider router={router} />
66+
</QueryClientProvider>
67+
```
68+
5469
Now in the bottom right of your window you'll see a 🏝️. Click on that and we'll open the dev tools. We haven't used the dev tools yet so it'll be empty.
5570

5671
So react-query makes interacting with APIs very simple and makes it easy to read. You just read a hook and it'll either give you a `isLoading` status or the data. Once the data comes back, it'll refresh the component with the data. So let's start by writing our very simple fetch call. Create a folder called `api` inside of `src` and create getPastOrders.js and put

0 commit comments

Comments
 (0)