TanStackT
TanStack2mo ago
5 replies
worthy-azure

Does the queryFn need to have a stable reference?

When providing useQuery with a queryFn, will the query fire each time it receives a new queryFn reference? E.g., when defining a function inline:

function useFoo() {
  const queryFn = () => Promise.resolve("ok");
  const q = useQuery({
    queryKey: ['foo', 'bar'],
    queryFn,
  });
}
Was this page helpful?