T
TanStack17mo ago
sensitive-blue

Percentage of Completion of React Query.

As title says, i need to return from this hook import { useQuery } from "@tanstack/react-query"; import { CustomerAPI } from "../../../api/CustomerAPI"; import { AuthProvider } from "../../../interfaces/auth/AuthProvider"; import { RootState } from "../../../redux/store"; import { useSelector } from "react-redux"; interface UseGetClientsRowsProps { page: number; itemsPerPage: number; searchString: string; } export function useGetClientsRows({ page, itemsPerPage, searchString, }: UseGetClientsRowsProps) { const queryKey = [clients]; const authProvider: AuthProvider = useSelector( (state: RootState) => state.auth.auth ); const { isLoading, error, isFetching, refetch, data } = useQuery(queryKey, { enabled: true, keepPreviousData: true, refetchOnWindowFocus: false,
queryFn: async () => { const response = await CustomerAPI.getClients( authProvider.cloudUrl, authProvider.email, authProvider.pin, authProvider.token, page * itemsPerPage - itemsPerPage, itemsPerPage, searchString ); return response; }, }); return { isLoading, error, isFetching, refetch, data }; } the percentage of the function so that i can show an appropiate loader
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?