Skip to content

Commit

Permalink
feat: remove unnecessary keepPreviousData
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT committed Sep 17, 2024
1 parent f385e8d commit 2f4b188
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/item/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import {
WebsocketClient,
} from '@graasp/sdk';

import {
keepPreviousData,
useInfiniteQuery,
useQuery,
} from '@tanstack/react-query';
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';

import { splitRequestByIdsAndReturn } from '../api/axios.js';
import {
Expand Down Expand Up @@ -163,12 +159,7 @@ const config = (

useDescendants: useDescendants(queryConfig),

useItem: (
id?: UUID,
options?: {
keepPreviousData?: boolean;
},
) =>
useItem: (id?: UUID) =>
useQuery({
queryKey: itemKeys.single(id).content,
queryFn: () => {
Expand All @@ -179,11 +170,6 @@ const config = (
},
enabled: Boolean(id),
...defaultQueryOptions,
placeholderData: options?.keepPreviousData
? // KeepPreviousData prevents unnecessary re-renders of the Player's three components
// when data is being fetched. This avoids flickering or visual glitches.
keepPreviousData
: undefined,
}),

useItems: (ids: UUID[]) => {
Expand Down

0 comments on commit 2f4b188

Please sign in to comment.