From 5757c18b3e43cc0ceae8cc700bf544ef2cf13bd4 Mon Sep 17 00:00:00 2001 From: hyeongrok7874 Date: Tue, 5 Dec 2023 00:12:08 +0900 Subject: [PATCH 1/3] Add caching option in useGetGwangyaPostList --- src/hooks/api/gwangya/useGetGwangyaPostList.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hooks/api/gwangya/useGetGwangyaPostList.ts b/src/hooks/api/gwangya/useGetGwangyaPostList.ts index 624cdf5d..6ae314c7 100644 --- a/src/hooks/api/gwangya/useGetGwangyaPostList.ts +++ b/src/hooks/api/gwangya/useGetGwangyaPostList.ts @@ -2,7 +2,7 @@ import { useInfiniteQuery } from '@tanstack/react-query'; import { get, gwangyaQueryKeys, gwangyaUrl } from '@/libs'; import type { GwangyaPostType } from '@/types'; -import { getGwangyaToken } from '@/utils'; +import { getGwangyaToken, minutesToMs } from '@/utils'; const gwangyaToken = getGwangyaToken(); @@ -25,4 +25,6 @@ export const useGetGwangyaPostList = (initialData?: GwangyaPostType[]) => getPreviousPageParam: (firstPage) => firstPage[0]?.id, getNextPageParam: (lastPage) => lastPage[lastPage.length - 1]?.id, initialData: initialData && { pages: [initialData], pageParams: [0] }, + staleTime: minutesToMs(5), + gcTime: minutesToMs(5), }); From 18b612b620ed8a4268f70a57aaa160d3616b06b6 Mon Sep 17 00:00:00 2001 From: hyeongrok7874 Date: Tue, 5 Dec 2023 00:12:27 +0900 Subject: [PATCH 2/3] Update scrollTo top option --- src/pageContainer/gwangya/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pageContainer/gwangya/index.tsx b/src/pageContainer/gwangya/index.tsx index 02588bd3..ffa7c672 100644 --- a/src/pageContainer/gwangya/index.tsx +++ b/src/pageContainer/gwangya/index.tsx @@ -27,7 +27,7 @@ const Gwangya: React.FC = ({ initialData }) => { useEffect(() => { // 초기 데이터를 가져올 시, 스크롤을 최하단으로 이동 - postListRef.current?.scrollTo(0, 10000); + postListRef.current?.scrollTo(0, 99999); const isSuccess = isExistCookie('isSuccess'); From dd8cac0e5fb90fa9a9aa1cc7302be491b27527e2 Mon Sep 17 00:00:00 2001 From: hyeongrok7874 Date: Tue, 5 Dec 2023 00:42:43 +0900 Subject: [PATCH 3/3] Add height 100% in PostList --- src/pageContainer/gwangya/style.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pageContainer/gwangya/style.ts b/src/pageContainer/gwangya/style.ts index 2f1bfa6e..ac6ab4bf 100644 --- a/src/pageContainer/gwangya/style.ts +++ b/src/pageContainer/gwangya/style.ts @@ -41,6 +41,7 @@ export const LoadMoreTrigger = styled.div` `; export const PostList = styled.div<{ isFetching: boolean }>` + height: 100%; display: flex; flex-direction: column; gap: 2.25rem;