-
Notifications
You must be signed in to change notification settings - Fork 1
[Week6/mission] Tanstack Query 입문 1편: useQuery와 useInfiniteQuery로 무한 스크롤과 효율적인 데이터 패칭하기 #34
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
Conversation
…ken 관리 방법, Google 로그인 실습)
…ken 관리 방법, Google 로그인 실습)
JeonSuna
left a comment
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.
수고하셨어요!!
갱주님 많이 급하셨나봐요!!! /apis/lp.ts에서 comment api 불러올 때 v1앞에 "/"가 빠져있어욤!!
수정하면 좋을 거 같습니다.
수고하셨어용...즐엠티
| }; | ||
|
|
||
| export const getLpComment = async(commentParams: LpCommentParams)=>{ | ||
| const {data} = await axiosInstance.get(`v1/lps/${commentParams.lpId}/comments`); |
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.
get 요청에 / 가 빠져서 못 불러오고 있는 거 같아요
| } bg-black flex-1 overflow-y-auto`} | ||
| > | ||
| <Outlet /> | ||
| {state?.backgroundLocation && <LpDetail />} |
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.
이런 식으로 구현한 이유가 따로 있을까요 ?
backgroundLocation으로 설정하면 어느 페이지에서 url만 바뀌고 Modal 형식으로 LpDetail이 뜨고 있는건지 헷갈리는 거 같아요
duwlsssss
left a comment
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.
고생하셨습니다!
| }, [inView, isFetching, hasNextPage, fetchNextPage]); | ||
|
|
||
|
|
||
| if (isLoading) { |
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.
데이터를 처음 가져오는 부분에서 isLoading 을 사용했는데
isLoading은 에러가 발생했을 때도 true일 수 있어 안전하게 사용하려면 isPending으로 상태 체크를 하는 게 좋을 것 같아요!
| return( | ||
| <div className="grid sm:grid-cols-3 md:grid-cols-5 gap-2 px-2"> | ||
| {Array.from({ length: 20 }).map((_, idx) => ( | ||
| <LpBoardSkeleton key={idx} /> |
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.
스켈레톤 컴포넌트에는 개수만 넘기고 컴포넌트 안에서 배열로 처리해줘도 깔끔할 것 같아요!
| <div className="grid sm:grid-cols-3 md:grid-cols-5 items-center justify-center px-2 gap-2"> | ||
| {lps?.pages?.map((page) => page.data.data)?.flat()?.map((lp:Lp) => ( | ||
| <div key={lp.id} className="relative"> | ||
| <LpBoard lp={lp} onClick={() => navigate(`/lps/${lp.id}`)} /> |
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.
import { useLocation } from "react-router-dom";
const location = useLocation(); // 현재 위치 기억
{lps?.pages?.map((page) => page.data.data)?.flat()?.map((lp: Lp) => (
<div key={lp.id} className="relative">
<LpBoard
lp={lp}
onClick={() =>
navigate(`/lps/${lp.id}`, {
state: { backgroundLocation: location },
})
}
/>
</div>
))}현재 Layout에서 사용하는 Modal 형식으로 사용하고 싶으면 이런 식으로 코드를 고쳐야할 거 같네요 !
✏️ 작업 내용
#️⃣ 연관된 이슈
#35
📷 작업 결과
Week6.mp4
💡 함께 공유하고 싶은 부분
🤔 질문
✅ 워크북 체크리스트
✅ 컨벤션 체크리스트