diff --git a/src/pages/home/HomePage.tsx b/src/pages/home/HomePage.tsx index f1506e3e..908a7dbb 100644 --- a/src/pages/home/HomePage.tsx +++ b/src/pages/home/HomePage.tsx @@ -41,6 +41,7 @@ const HomePage = () => { }), getNextPageParam: (lastPage) => lastPage.nextCursorId ?? undefined, staleTime: 60 * 1000, + placeholderData: (previousData) => previousData, }); const handleCategoryChange = (selected: string[]) => { @@ -99,6 +100,9 @@ const HomePage = () => { return out; }, [data, isCategoryEmpty]); + const hasArticles = articles.length > 0; + const isInitialLoading = isLoading && !hasArticles; + // 카테고리 미선택 상태: API 호출 없이 안내 문구만 렌더 if (isCategoryEmpty) { return ( @@ -159,11 +163,11 @@ const HomePage = () => { {/* 기사 카드 그리드 */}
- {isLoading ? ( + {isInitialLoading ? (
잠시만요, 스낵이 기사를 담는 중이에요…
- ) : isError ? ( + ) : isError && !hasArticles ? (
{error instanceof Error @@ -171,7 +175,7 @@ const HomePage = () => { : '앗, 뉴스를 불러오지 못했어요. 잠시 후 다시 시도해 주세요.'}
- ) : articles.length === 0 ? ( + ) : !hasArticles ? (
아직 선택한 카테고리가 없어요.😭