Skip to content

Commit 177abc6

Browse files
committed
fix: url enabled여야 댓글 불러오도록 처리
1 parent 17b590f commit 177abc6

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/apis/comment/useGetCommentList.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ export const getCommentList = async (
2323
}
2424
};
2525

26-
export const useGetCommentList = (targetId: number, category: CategoryType) => {
26+
export const useGetCommentList = (
27+
targetId: number,
28+
category: CategoryType,
29+
enabled: boolean = true
30+
) => {
2731
return useQuery({
2832
queryKey: [queryKey.COMMENT_LIST, { targetId, category }],
2933
queryFn: () => getCommentList(targetId, category),
34+
enabled,
3035
});
3136
};

src/components/DetailView/Comment/CommentSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import LoadingSpinner from '../../LoadingSpinner';
1010

1111
const CommentSection = () => {
1212
const [comments, setComments] = useState<Comment[]>([]); // comments라는 상태를 배열로 관리
13-
const { category, targetId } = useCommentTarget();
13+
const { category, targetId, enabled } = useCommentTarget();
1414
const {
1515
data: commentList,
1616
isLoading,
1717
isPending,
1818
isError,
19-
} = useGetCommentList(targetId ?? 0, category ?? 'GOAL');
19+
} = useGetCommentList(targetId ?? 0, category ?? 'GOAL', enabled);
2020

2121
useEffect(() => {
2222
console.log('commentList', commentList);

0 commit comments

Comments
 (0)