From 6cd8ec0c3047eef6daef44b2ca913c6543077497 Mon Sep 17 00:00:00 2001 From: Radoslaw Szwajkowski Date: Wed, 5 Jun 2024 12:51:43 +0200 Subject: [PATCH] Remove unnecessary initialData from useQuery calls Initial data is persisted in cache which results in: 1. isLoading flag always false 2. with custom staleTime, delaying first fetch until cache expires Signed-off-by: Radoslaw Szwajkowski --- client/src/app/queries/applications.ts | 1 - client/src/app/queries/archetypes.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/app/queries/applications.ts b/client/src/app/queries/applications.ts index 153a13d013..a6299f95b8 100644 --- a/client/src/app/queries/applications.ts +++ b/client/src/app/queries/applications.ts @@ -37,7 +37,6 @@ export const useFetchApplications = ( ) => { const queryClient = useQueryClient(); const { isLoading, error, refetch, data } = useQuery({ - initialData: [], queryKey: [ApplicationsQueryKey], queryFn: getApplications, refetchInterval: refetchInterval, diff --git a/client/src/app/queries/archetypes.ts b/client/src/app/queries/archetypes.ts index b64c191064..e08cff282f 100644 --- a/client/src/app/queries/archetypes.ts +++ b/client/src/app/queries/archetypes.ts @@ -19,8 +19,7 @@ export const useFetchArchetypes = (forApplication?: Application | null) => { const [filteredArchetypes, setFilteredArchetypes] = useState([]); const queryClient = useQueryClient(); - const { isLoading, isSuccess, error, refetch, data } = useQuery({ - initialData: [], + const { isLoading, isSuccess, error, refetch } = useQuery({ queryKey: [ARCHETYPES_QUERY_KEY, forApplication?.id], queryFn: getArchetypes, onSuccess: (fetchedArchetypes) => {