TanStackT
TanStack12mo ago
4 replies
colourful-plum

onSuccess on useQuery() --> No overload match this call

The onSuccess callback seems to be removed from last version of TanStack Query causing "No overload match this call" Error. Why ???
  const { isLoading, error, data } = useQuery({
    queryKey: ['myData'], // Unique key for the query
    queryFn: async () => {
      const response = await fetch('/api/data');
      return response.json();
    },
    onSuccess: (data) => {
      // This function will be executed when the query is successful
      console.log('Data fetched successfully:', data);
      // You can perform actions with the data here, like updating state or displaying a success message
    },
  });
Was this page helpful?