-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 전체 방 조회 API 연결 및 기능 구현 #164
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7e56c5d
feat: 전체 방 조회 msw API 및 쿼리 작성
chasj0326 0102f9e
feat: 방 전체 조회 API 연결
chasj0326 22986b2
feat: 옵저버 제외한 무한 fetching 기능 추가
chasj0326 69c865b
feat: 로딩 fallback 추가
chasj0326 587c984
feat: 무한스크롤 쿼리 로직 분리
chasj0326 9219c82
feat: 무한스크롤 커스텀 훅 구현 및 기능 연결
chasj0326 224e75e
Merge branch 'main' into feat/#157/search-page-api
chasj0326 d0b5207
feat: 옵저버 훅 및 UI 수정
chasj0326 e61dced
Merge branch 'main' into feat/#157/search-page-api
chasj0326 b4f6a34
Merge remote-tracking branch 'refs/remotes/origin/feat/#157/search-pa…
chasj0326 58f4589
feat: 코드 리뷰 반영
chasj0326 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
|
||
interface ResultListFallbackProps { | ||
size?: number; | ||
} | ||
|
||
const ResultListFallback = ({ size = 10 }: ResultListFallbackProps) => { | ||
return ( | ||
<div className="flex flex-col gap-2 opacity-60"> | ||
{Array.from({ length: size }, (_, index) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 size를 인수로 받아 개수를 자유롭게 설정할 수 있군요👍🏻👍🏻 |
||
<div | ||
key={index} | ||
className="my-1 h-24 w-full animate-pulse rounded-2xl bg-light-gray dark:bg-dark-gray" | ||
></div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ResultListFallback; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useCallback, useEffect, useRef } from 'react'; | ||
|
||
interface ObserverOptions { | ||
root?: Element | null; | ||
rootMargin?: string; | ||
threshold?: number; | ||
onObserve: VoidFunction; | ||
} | ||
|
||
const useIntersectionObserver = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오.. IntersectionObserver API를 쉽게 활용할 수 있게 hooks로 만들어주셨군요! 👍👍 |
||
onObserve, | ||
...options | ||
}: ObserverOptions) => { | ||
const intersectionRef = useRef<HTMLDivElement>(null); | ||
|
||
const handleIntersect: IntersectionObserverCallback = useCallback( | ||
(entries) => { | ||
entries.forEach((entry) => { | ||
if (entry.isIntersecting) { | ||
onObserve(); | ||
} | ||
}); | ||
}, | ||
[onObserve] | ||
); | ||
|
||
useEffect(() => { | ||
const observer = new IntersectionObserver(handleIntersect, options); | ||
const intersectionElement = intersectionRef.current; | ||
|
||
intersectionElement && observer.observe(intersectionElement); | ||
|
||
return () => { | ||
intersectionElement && observer.unobserve(intersectionElement); | ||
}; | ||
}, [handleIntersect, options]); | ||
|
||
return intersectionRef; | ||
}; | ||
|
||
export default useIntersectionObserver; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as useInfiniteSearch } from './useInfiniteSearch'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useSuspenseInfiniteQuery } from '@tanstack/react-query'; | ||
import { RoomSelectType } from '@/core/types'; | ||
import roomAPI from '../functions/roomAPI'; | ||
|
||
const useInfiniteSearch = ({ | ||
type, | ||
size | ||
}: { | ||
type: RoomSelectType; | ||
size: number; | ||
}) => { | ||
return useSuspenseInfiniteQuery({ | ||
queryKey: ['rooms', type], | ||
|
||
queryFn: ({ pageParam }) => | ||
roomAPI.getRoomsAll({ page: pageParam, type, size }), | ||
|
||
initialPageParam: 1, | ||
|
||
getNextPageParam: (lastPage, allPages, lastPageParam) => | ||
lastPage.length < size ? null : lastPageParam + 1, | ||
|
||
select: ({ pages }) => pages | ||
}); | ||
}; | ||
|
||
export default useInfiniteSearch; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 추후에 hasNextPage 속성을 이용해서 방이 더 이상 없다는 문구도 표시해주면 더 좋을 것 같습니다 ㄷㄷ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하 그렇네유 ! 문구 추천 부탁드립니다 꾸벅 ( _ _ )
더 이상 방이 없네요! 이거 .. ?