Skip to content

Commit

Permalink
FE-42๐Ÿ’ก ์ฃผ์„ ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
  • Loading branch information
jisurk committed Jul 17, 2024
1 parent f0933cd commit cf43286
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/epigram/Comment/CommentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function CommentList({ epigramId, currentUserId }: EpigramCommentProps) {
const observerRef = useRef<IntersectionObserver | null>(null);
const lastCommentRef = useRef<HTMLDivElement | null>(null);

// NOTE: Observer ์ฝœ๋ฐฑ: ๋งˆ์ง€๋ง‰ ์š”์†Œ๊ฐ€ ํ™”๋ฉด์— ๋ณด์ด๋ฉด ๋‹ค์Œ ํŽ˜์ด์ง€(๋Œ“๊ธ€ ์ตœ๋Œ€3๊ฐœ๋ฅผ ๋ฌถ์–ด 1ํŽ˜์ด์ง€ ์ทจ๊ธ‰) ๋กœ๋“œ
const handleObserver = useCallback(
(entries: IntersectionObserverEntry[]) => {
const [target] = entries;
Expand All @@ -34,6 +35,7 @@ function CommentList({ epigramId, currentUserId }: EpigramCommentProps) {
}

return () => {
// NOTE: effect๊ฐ€ ์‹คํ–‰๋˜๊ธฐ์ „์— ํ˜ธ์ถœํ•ด์„œ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜๋ฅผ ๋ฐฉ์ง€ํ•ด์ค€๋‹ค๊ณ  ํ•จ
if (observerRef.current) {
observerRef.current.disconnect();
}
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useEpigramCommentsQueryHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CommentResponseType } from '@/schema/comment';
import getEpigramComments from '@/apis/epigramComment';

const useEpigramCommentsQuery = (epigramId: number) =>
// NOTE: ์ˆœ์„œ๋Œ€๋กœ API์‘๋‹ตํƒ€์ž…, ์—๋Ÿฌํƒ€์ž…, ๋ฐ˜ํ™˜๋˜๋Š”๋ฐ์ดํ„ฐํƒ€์ž…, ์ฟผ๋ฆฌ ํ‚ค ํƒ€์ž…, ํŽ˜์ด์ง€ ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ํƒ€์ž…
useInfiniteQuery<CommentResponseType, Error, InfiniteData<CommentResponseType>, [string, number], number | undefined>({
queryKey: ['epigramComments', epigramId],
queryFn: ({ pageParam }) => getEpigramComments({ id: epigramId, limit: 3, cursor: pageParam }),
Expand Down

0 comments on commit cf43286

Please sign in to comment.