From 3a318966f4eb73e8bbb123db16c78d0d417d3378 Mon Sep 17 00:00:00 2001 From: Radoslaw Szwajkowski Date: Mon, 10 Jun 2024 16:08:08 +0200 Subject: [PATCH] :bug: Remove unnecessary initialData from useQuery calls (#1940) 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) => {