Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
endmoseung
reviewed
Mar 29, 2025
| //로컬 이미지 테스트 하기 위해 localhost를 넣었습니다. | ||
| domains: ["sprint-fe-project.s3.ap-northeast-2.amazonaws.com", "localhost"], | ||
| }, | ||
| reactStrictMode: false, |
There was a problem hiding this comment.
로컬에서 작업하시면서 strict껐으면 git으로는 추적 안하는게 좋을것 같아요
Owner
Author
There was a problem hiding this comment.
안 그래도 이 부분 지우는 걸 잊고 있었는데, 우선 다음 작업까지 하고 다시 true로 해놓겠습니다!
Comment on lines
+53
to
+72
| useEffect(() => { | ||
| if (isLast) return; | ||
|
|
||
| const observer = new IntersectionObserver( | ||
| (entries) => { | ||
| if (entries[0].isIntersecting) { | ||
| handleLoad(); | ||
| } | ||
| }, | ||
| { threshold: 0.5 } | ||
| ); | ||
|
|
||
| const current = observerRef.current; | ||
| if (current) observer.observe(current); | ||
|
|
||
| return () => { | ||
| if (current) observer.unobserve(current); | ||
| observer.disconnect(); | ||
| }; | ||
| }, [cursorId, isLoading, isLast]); |
There was a problem hiding this comment.
observer하는거는 재사용의 목적 + 이 페이지에서는 비즈니스로직일 필요가 없어보여서 추상화해보면 좋겠네요.
useIntersection같은 커스텀훅으로요
Owner
Author
There was a problem hiding this comment.
다른 곳에서도 무한 스크롤을 사용해서 추상화해보면 좋겠네요. 의견 감사합니다!
Comment on lines
+14
to
+17
| let query = `size=${size}&columnId=${columnId}`; | ||
| if (cursorId !== null) { | ||
| query += `&cursorId=${cursorId}`; | ||
| } |
There was a problem hiding this comment.
여기도 다른분들 생산성을 위해서 query로 붙여주는 함수로 한번 분리해보는것도 좋겠네요.
저는 exceptEmptyValue라는 함수를 만들어서 값이 없는 인자는 쿼리를 안붙이도록 만들어서 쓰고 있어요.
Owner
Author
There was a problem hiding this comment.
감사합니다 고려해보고 해보도록 하겠습니다!
codeit-kkm
approved these changes
Mar 29, 2025
jihye5081
approved these changes
Mar 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#️⃣ Issue Number
#88
📝 요약
🛠️ PR 유형
📚 참고 자료
무한 스크롤 흐름
handleLoad함수를 호출하여 첫 페이지 카드들 불러옴ref연결ref요소, 즉 마지막 카드가 화면에 보이면IntersectionObserver감지handleLoad함수를 다시 호출하여 다음 페이지 카드들 불러옴isLast가true가 되고 데이터 불러오기 완료isLoading과isLaststate의 필요성isLoading데이터 요청 중 중복 호출 방지
isLast마지막 페이지 여부를 확인하여 무한 요청 방지
handleLoad함수isLast값을 갱신한다.(페이지 사이즈보다 데이터의 길이가 작거나nextCursorId가 null이면 마지막 페이지라는 의미)마지막 카드에만
ref걸기TaskCard리스트 중 마지막 TaskCard div에만ref를 달아준다.ref를 통해IntersectionObserver가 마지막 카드가 보이는 것을 감지한다.IntersectionObserver등록IntersectionObserver는 DOM 요소가 뷰포트에 들어오는 것을 감지한다.entries[0]이 뷰포트에 보이면handleLoad함수 실행observerRef.current(ref로 연결된 DOM 요소, 즉 마지막TaskCarddiv)를 감시하기 위해observer에 연결ref가 다른 요소에 재할당되는데, 이전ref에 연결된observer를 끊지 않으면 여러 요소가 동시에 감시되기 때문에, 현재 감시 중인 요소(current, 즉 마지막TaskCarddiv)를 그만 감시하도록 해준다.observer인스턴스를 메모리에서 정리해준다.