TanStackT
TanStack3y ago
7 replies
skinny-azure

QueryFn is by default on pause and not executed

Hello, for me it works, however for my work colleague on mac using the same node version and chrome version we get different results. We are not using any cache provider, but somehow the query is not executed for him and marked as paused. For me it is executed without issue (on Ubuntu). What could be reasons for that?

The hook looks like this:

export const fakeAPI = () =>
  new Promise((resolve) =>
    setTimeout(() => {
      resolve(someTestData);
    }, 100)
  );


const useDocuments = (): UseQueryResult<IDocument[], void> => {
  return useQuery({
    queryKey: ['documents'],
    queryFn: () => {
      console.log('useDocuments');
      return fakeAPI(); // this is simply 
    },
    onSuccess: (data) => data,
    onError: (error) => console.error(error)
  });
};


Here is how we use the provider:

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useState } from 'react';

const client = () => new QueryClient();

const TanStackQueryProvider: FC<PropsWithChildren> = ({ children }) => {
  const [queryClient] = useState(client);

  return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
};
Was this page helpful?