Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
21 replies
utdev

Prevent trpc refetching

Does anyone have an idea how I prevent trpc refetching, current I have following queries in a page:

const Game = () => {
  const { data: movies } = trpc.movie.getAll.useQuery();
  const { data: possibleAnswers } = trpc.movie.getThree.useQuery();


Which keeps refetching if I focus on the application.

I went through the docs https://tanstack.com/query/v4/docs/react/guides/window-focus-refetching

And tried:

  const { data: movies } = trpc.movie.getAll.useQuery({
    refetechOnWindowFocus: false,
  });


But I get this:

(property) refetechOnWindowFocus: boolean
Argument of type '{ refetechOnWindowFocus: boolean; }' is not assignable to parameter of type 'void'.ts(2345)
If a user leaves your application and returns to stale data, React Query automatically requests fresh data for you in the background. You can disable this globally or per-query using the refetchOnWindowFocus option:

Disabling Globally
Window Focus Refetching | TanStack Query Docs
Was this page helpful?