Skip to content

Instantly share code, notes, and snippets.

@dineshigdd
Created May 23, 2023 01:52
Show Gist options
  • Save dineshigdd/d65719aec646fdcf55562c9ce25bce7b to your computer and use it in GitHub Desktop.
Save dineshigdd/d65719aec646fdcf55562c9ce25bce7b to your computer and use it in GitHub Desktop.
import { useQueryClient } from '@tanstack/react-query'
//creating queryClient object using useQueryClient hook
const queryClient = useQueryClient()
// Invalidate every query in the cache
queryClient.invalidateQueries()
// Invalidate every query with a key that starts with 'users'
queryClient.invalidateQueries({ queryKey: ['users'] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment