Open History to see the last commit
function useQueryClient(queryClient?: QueryClient): QueryClient;
Defined in: packages/svelte-query/src/useQueryClient.ts:24
The useQueryClient function returns the current QueryClient instance.
Parameters#
queryClient?#
Use this to use a custom QueryClient. Otherwise, the one from the nearest context will
be used.
Returns#
The current QueryClient instance.
Throws#
If no queryClient argument is passed and no QueryClientProvider is found in the
component tree.
Example#
<script lang="ts">
import { useQueryClient } from '@tanstack/svelte-query'
const queryClient = useQueryClient()
function refreshPosts() {
queryClient.invalidateQueries({ queryKey: ['posts'] })
}
</script>