Skip to content

Commit

Permalink
doc(readme): Improve the invalidating query example (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
seriouslag authored May 3, 2024
1 parent 0cd85e4 commit 35b03c0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,17 @@ import {

// App.tsx
function App() {
const { data } = usePetServiceFindPetsByStatus({ status: ["available"] });
const [status, setStatus] = React.useState(["available"]);
const { data } = usePetServiceFindPetsByStatus({ status });
const { mutate } = usePetServiceAddPet({
onSuccess: () => {
queryClient.invalidateQueries({
// 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
queryKey: [UsePetServiceFindPetsByStatusKeyFn()],
// 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
queryKey: [UsePetServiceFindPetsByStatusKeyFn({
status
})],
});
},
});
Expand Down

0 comments on commit 35b03c0

Please sign in to comment.