1- import { useEffect , useState } from "react" ;
1+ import { useState } from "react" ;
22import { GetServerSidePropsContext } from "next" ;
33import { useRouter } from "next/router" ;
44import { parse } from "cookie" ;
55import { LinkData } from "@/types/linkTypes" ;
66import { FolderData } from "@/types/folderTypes" ;
77import { Modal } from "@/components/modal/modalManager/ModalManager" ;
8- import { useLinkCardStore } from "@/store/useLinkCardStore" ;
98import { SearchInput } from "../../components/Search/SearchInput" ;
109import axiosInstance from "@/lib/api/axiosInstanceApi" ;
1110import useModalStore from "@/store/useModalStore" ;
1211import Pagination from "@/components/Pagination" ;
13- import useFetchLinks from "@/hooks/useFetchLinks" ;
1412import AddLinkInput from "@/components/Link/AddLinkInput" ;
1513import Container from "@/components/Layout/Container" ;
1614import SearchResultMessage from "@/components/Search/SearchResultMessage" ;
@@ -20,6 +18,7 @@ import FolderActionsMenu from "@/components/Folder/FolderActionsMenu";
2018import CardsLayout from "@/components/Layout/CardsLayout" ;
2119import LinkCard from "@/components/Link/LinkCard" ;
2220import RenderEmptyLinkMessage from "@/components/Link/RenderEmptyLinkMessage" ;
21+ import useFetchLinks from "@/hooks/useFetchLinks" ;
2322import useViewport from "@/hooks/useViewport" ;
2423
2524interface LinkPageProps {
@@ -62,22 +61,18 @@ export const getServerSideProps = async (
6261const LinkPage = ( {
6362 linkList : initialLinkList ,
6463 folderList : initialFolderList ,
65- totalCount,
64+ totalCount : initialTotalCount ,
6665} : LinkPageProps ) => {
6766 const router = useRouter ( ) ;
6867 const { search, folder } = router . query ;
69- const { linkCardList, setLinkCardList } = useLinkCardStore . getState ( ) ;
7068 const { isOpen } = useModalStore ( ) ;
7169 const { isMobile } = useViewport ( ) ;
70+ const [ linkCardList , setLinkCardList ] = useState ( initialLinkList ) ;
7271 const [ folderList , setFolderList ] = useState ( initialFolderList ) ;
73-
74- // 클라이언트에서 초기 목록을 설정
75- useEffect ( ( ) => {
76- setLinkCardList ( initialLinkList ) ;
77- } , [ initialLinkList , setLinkCardList ] ) ;
72+ const [ totalCount , setTotalCount ] = useState ( initialTotalCount ) ;
7873
7974 // 링크페이지의 query가 바뀌면 새로운 리스트로 업데이트 해주는 훅
80- useFetchLinks ( setLinkCardList , router . query , router . pathname ) ;
75+ useFetchLinks ( setLinkCardList , setTotalCount , router . query , router . pathname ) ;
8176
8277 console . log ( linkCardList ) ;
8378
@@ -100,6 +95,7 @@ const LinkPage = ({
10095 < FolderActionsMenu
10196 setFolderList = { setFolderList }
10297 folderId = { folder }
98+ linkCount = { totalCount }
10399 />
104100 ) }
105101 </ div >
0 commit comments