Skip to content

Conversation

qkrdmsthff
Copy link

@qkrdmsthff qkrdmsthff commented Oct 8, 2025

✅ 워크북 체크리스트

  • 모든 핵심 키워드 정리를 마쳤나요?
  • 핵심 키워드에 대해 완벽히 이해하셨나요?
  • 이론 학습 이후 직접 실습을 해보는 시간을 가졌나요?
  • 미션을 수행하셨나요?
  • 미션을 기록하셨나요?

✅ 컨벤션 체크리스트

  • 디렉토리 구조 컨벤션을 잘 지켰나요?
  • pr 제목을 컨벤션에 맞게 작성하였나요?
  • pr에 해당되는 이슈를 연결하였나요?(중요)
  • 적절한 라벨을 설정하였나요?
  • 파트장에게 code review를 요청하기 위해 reviewer를 등록하였나요?
  • 닉네임/main 브랜치의 최신 상태를 반영하고 있는지 확인했나요?(매우 중요!)

📌 주안점

@qkrdmsthff
Copy link
Author

썬더 ... 제가 서버 키는 도중에 설치가 안 돼서 2-3번 미션을 아직 덜 했습니당... 내일 스터디 전까지 완성해서 올릴게요 ㅠㅠ ...

Comment on lines +5 to +18
const useCustomFetch = () => {
const [movie, setMovie] = useState<MovieInfo[]>([]);
const [movieDetail, setMovieDetail] = useState<MovieInfo | null>(null);
const [credits, setCredits] = useState<CastMember[]>([]);

const [isPending, setIsPending] = useState(false);
const [isError, setIsError] = useState(false);
const [page, setPage] = useState(1);

const { category, movieId } = useParams();

const accessToken = import.meta.env.VITE_API_KEY;
const baseUrl = import.meta.env.VITE_API_BASE_URL;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useCustomFetch가 한 번에 목록·상세·출연을 다 묶어 처리해서, 필요 없는 요청까지 함께 돌고 상태도 섞여 보여요. 특정 화면에서 목록만 필요해도 상세/출연 요청의 pending·error가 함께 섞이고, 새로운 리소스가 생길 때마다 훅 내부에 코드를 계속 추가해야 하는 확장성 문제도 발생할 것 같습니다.

요청 URL과 쿼리(params)를 인자로 받는 범용 훅으로 일반화하거나, 리소스별 훅(useMoviesList, useMovieDetail, useMovieCredits)로 분리해 필요한 것만 가져오도록 바꾸면 더 좋을 것 같아요!

Comment on lines +25 to +28
export interface MovieCastDetail {
id: number;
cast: CastMember[];
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서버 응답 전체에서 타입을 명시하지 않고 원하는 부분만 설정할 수 있었네요 ! 저는 전체를 다 받아서 하나하나 명시하느라 코드가 엄청 길어졌었는데.. 다음부터는 이런 식으로 해야겠군요..

}

catch (e) {
alert('데이터 불러오는 중 오류 발생');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 빠른 페이지 전환이 발생할 때, 이전 요청 응답이 늦게 도착해 최신 상태를 덮는 레이스가 생길 수 있습니다.
(ex) page=2가 먼저 도착해 렌더된 뒤, 뒤늦은 page=1 응답이 다시 덮음)
새 요청이 시작되면 AbortController로 이전 요청을 취소하고, 각 요청에 reqId를 부여해 응답 처리 시 if (reqId !== latest) return 가드를 넣어 최신 요청의 응답만 반영되도록 해보는 걸 추천합니다.
유징의 피드백과 함께 이 부분까지 적용하면 React Query의 필요성을 더 선명하게 체감할 수 있을 것 같아요!

@sunnyinha
Copy link
Collaborator

치치, 4주차도 수고하셨습니다! 머지해주세요~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chapter04_사용자 인증부터 폼 유효성 검사까지, 서비스의 기본기 다지기

4 participants