Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created March 16, 2023 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sibelius/04e8079cdf3f403f1be46826570eaa83 to your computer and use it in GitHub Desktop.
Save sibelius/04e8079cdf3f403f1be46826570eaa83 to your computer and use it in GitHub Desktop.
const useLoaderPreloadedQuery<Query> = () => {
const preloadedQueryRef = useLoaderData() as PreloadedQuery<Query>;
// clean up is important as we are using loadQuery directly without useQueryLoader
/ which will handle to dispose auto.
useEffect(() => () => preloadedQueryRef.dispose(), [preloadedQueryRef]);
return preloadedQueryRef
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment