Skip to content

Commit

Permalink
🐛 Remove unnecessary initialData from useQuery calls (#1940)
Browse files Browse the repository at this point in the history
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 <rszwajko@redhat.com>
  • Loading branch information
rszwajko committed Jun 10, 2024
1 parent 15c8ee4 commit 3a31896
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion client/src/app/queries/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const useFetchApplications = (
) => {
const queryClient = useQueryClient();
const { isLoading, error, refetch, data } = useQuery({
initialData: [],
queryKey: [ApplicationsQueryKey],
queryFn: getApplications,
refetchInterval: refetchInterval,
Expand Down
3 changes: 1 addition & 2 deletions client/src/app/queries/archetypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export const useFetchArchetypes = (forApplication?: Application | null) => {
const [filteredArchetypes, setFilteredArchetypes] = useState<Archetype[]>([]);

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) => {
Expand Down

0 comments on commit 3a31896

Please sign in to comment.