@@ -2,8 +2,8 @@ import { useState, useEffect, useCallback } from 'react';
22import { deleteComment , fetchComment , updateComment } from '../api/fetchComment' ;
33import { getApi } from '@/app/api/config/appConfig' ;
44import { CommentType } from '../types/post' ;
5- import { User } from '@/domains/shared/store/auth' ;
65import { ParamValue } from 'next/dist/server/request/params' ;
6+ import { User } from '@/domains/shared/store/auth' ;
77
88export function useComments ( postId : ParamValue , user : User | null ) {
99 const [ comments , setComments ] = useState < CommentType [ ] | null > ( null ) ;
@@ -15,12 +15,6 @@ export function useComments(postId: ParamValue, user: User | null) {
1515 } | null > ( null ) ;
1616
1717 const fetchData = useCallback ( async ( ) => {
18- // 로그인 상태일 때만 댓글 조회
19- if ( ! user ) {
20- setComments ( [ ] ) ;
21- return ;
22- }
23-
2418 const data = await fetchComment ( postId ) ;
2519 if ( ! data ) return ;
2620 setComments ( data ) ;
@@ -80,13 +74,11 @@ export function useComments(postId: ParamValue, user: User | null) {
8074 } ;
8175
8276 const loadMoreComments = async ( lastCommentId : number ) => {
83- if ( isEnd || isLoading || ! user ) return ;
77+ if ( isEnd || isLoading ) return ;
8478
8579 setIsLoading ( true ) ;
8680 try {
87- const res = await fetch ( `${ getApi } /posts/${ postId } /comments?lastId=${ lastCommentId } ` , {
88- credentials : 'include' ,
89- } ) ;
81+ const res = await fetch ( `${ getApi } /posts/${ postId } /comments?lastId=${ lastCommentId } ` , { } ) ;
9082 const newComments = await res . json ( ) ;
9183
9284 if ( newComments . data . length === 0 ) {
0 commit comments