@@ -2,7 +2,6 @@ import React, { useState } from 'react';
22import { Box , Image , Text , Flex , IconButton , Link , HStack , Avatar , Button } from '@chakra-ui/react' ;
33import { useNavigate } from 'react-router-dom' ;
44import { ViewIcon , ChatIcon } from '@chakra-ui/icons' ;
5- import useMemoryCommentsCount from '../hooks/useMemoryCommentsCount' ;
65
76interface Author {
87 id : number ;
@@ -17,7 +16,6 @@ interface MemoryCardProps {
1716 author : Author ;
1817 comments : number ;
1918 source ?: string ; // sharing memories에서 온 경우 'sharing'
20- enableCommentsCount ?: boolean ; // 댓글 수 조회 활성화 여부
2119}
2220
2321const MemoryCard : React . FC < MemoryCardProps > = ( {
@@ -26,21 +24,11 @@ const MemoryCard: React.FC<MemoryCardProps> = ({
2624 description,
2725 author,
2826 comments,
29- source,
30- enableCommentsCount = false
27+ source
3128} ) => {
3229 const navigate = useNavigate ( ) ;
3330 const [ currentImageIndex , setCurrentImageIndex ] = useState ( 0 ) ;
3431 const [ isTextExpanded , setIsTextExpanded ] = useState ( false ) ;
35-
36- // 댓글 수 조회 (활성화된 경우만)
37- const { commentsCount : fetchedCommentsCount } = useMemoryCommentsCount ( {
38- memoryId,
39- enabled : enableCommentsCount
40- } ) ;
41-
42- // enableCommentsCount가 true면 조회된 댓글 수 사용, 아니면 props로 받은 댓글 수 사용
43- const displayCommentsCount = enableCommentsCount ? fetchedCommentsCount : comments ;
4432
4533 const handleViewDetail = ( ) => {
4634 // source가 있으면 query parameter로 전달
@@ -180,7 +168,7 @@ const MemoryCard: React.FC<MemoryCardProps> = ({
180168 onClick = { handleViewDetail }
181169 _hover = { { bg : 'gray.50' } }
182170 >
183- 댓글 { displayCommentsCount } 개
171+ 댓글 { comments } 개
184172 </ Button >
185173 </ HStack >
186174 </ Box >
0 commit comments