Created
February 26, 2024 20:32
-
-
Save isocroft/672e5ca2e73114b58ed78366929643be to your computer and use it in GitHub Desktop.
A custom ReactJS/NextJS hook based on @tanstack/react-query that queries the cache for the contents at a given query key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useQueryClient } from "@tanstack/react-query"; | |
export function useReactQueryCache<D, E>(queryKey: unknown[] = []) { | |
const queryClient = useQueryClient(); | |
const queryCache = queryClient.getQueryCache(); | |
return queryCache.find<D, E>(queryKey); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment