Skip to content

Commit 35b03c0

Browse files
authored
doc(readme): Improve the invalidating query example (#108)
1 parent 0cd85e4 commit 35b03c0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,17 @@ import {
201201

202202
// App.tsx
203203
function App() {
204-
const { data } = usePetServiceFindPetsByStatus({ status: ["available"] });
204+
const [status, setStatus] = React.useState(["available"]);
205+
const { data } = usePetServiceFindPetsByStatus({ status });
205206
const { mutate } = usePetServiceAddPet({
206207
onSuccess: () => {
207208
queryClient.invalidateQueries({
208-
// Call the query key function to get the query key, this is important to ensure the query key is created the same way as the query hook, this insures the cache is invalidated correctly and is typed correctly
209-
queryKey: [UsePetServiceFindPetsByStatusKeyFn()],
209+
// Call the query key function to get the query key
210+
// This is important to ensure the query key is created the same way as the query hook
211+
// This insures the cache is invalidated correctly and is typed correctly
212+
queryKey: [UsePetServiceFindPetsByStatusKeyFn({
213+
status
214+
})],
210215
});
211216
},
212217
});

0 commit comments

Comments
 (0)