Skip to content

Conversation

@najitwo
Copy link
Collaborator

@najitwo najitwo commented Dec 7, 2024

요구사항

기본

중고마켓

  • '상품 등록하기' 버튼을 누르면 “/additem” 로 이동합니다.
  • 각 상품 클릭 시 상품 상세 페이지로 이동합니다.
  • 상품 상세 페이지 주소는 “/items/{productId}” 입니다.

상품 상세

  • 내가 등록한 상품일 경우 상품 수정, 삭제가 가능합니다.
  • 문의하기 input창에 값을 입력 후 ‘등록’ 버튼을 누르면 댓글이 등록됩니다.
  • 내가 등록한 댓글은 수정, 삭제가 가능합니다.

상품 등록

  • 이미지를 제외하고 input 에 모든 값을 입력하면 ‘등록' 버튼이 활성화 됩니다.
  • 활성화된 ‘등록' 버튼을 누르면 상품 등록이 완료됩니다.
  • 등록이 완료되면 해당 상품 상세 페이지로 이동합니다.

심화

  • api 요청에 TanStack React Query를 활용해 주세요.

배포

https://najimarket.vercel.app/

멘토에게

  • 전에 만들었던 코드에 점진적으로 react query 적용하느라 디테일은 못챙겼습니다. 😅

@najitwo najitwo requested a review from GANGYIKIM December 7, 2024 14:59
@najitwo najitwo added 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. 미완성🫠 죄송합니다.. labels Dec 7, 2024
Copy link
Collaborator

@GANGYIKIM GANGYIKIM left a comment

Choose a reason for hiding this comment

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

지원님 스프린트 미션하시느라 고생하셨습니다~

그전 코드에다 react-query를 사용하시느라 약간 아쉬운 부분들이 있었는데 코드에서 부분적으로 적용한다고 해결될 부분들이 아니라 여기서 코멘트 드립니다.

쿼리키의 경우 다양한 형태를 가질 수 있어 타입정의가 쉽지 않으셨을 것 같습니다.
이럴때 가독성과 타입안정성을 위해 queryOption나 query factory 패턴을 통해 타입관련
문제를 해결할수있습니다.

관련 글을 읽어보시고 재사용가능한 queryKey, queryOption을 정의해보시면 좋겠습니다~

https://tkdodo.eu/blog/the-query-options-api

  • 배포 사이트에서 확인해보니 상품 등록하기가 로그인 하지 않아도 접근이 되어서 등록 버튼을 눌렀을때 에러가 나니 확인해보세요.

Comment on lines +4 to +8
return (
<>
<AddItemForm />
</>
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

P3:

Suggested change
return (
<>
<AddItemForm />
</>
);
return <AddItemForm />

Comment on lines +9 to +10
const ItemDetail = ({
images,
Copy link
Collaborator

Choose a reason for hiding this comment

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

P2:
컴포넌트는 본인이 필요한 것만 아는 것이 잘 분리된 것이라고 생각합니다~
가능하면 images라는 배열말고 image를 받으면 좋겠네요.

import styles from "./Card.module.css";
import emptyImg from "@/public/img_default.svg";

const Card = ({ product }: { product: ProductProps }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

P3:
product 객체로 받을 필요가 없어 보입니다.

Suggested change
const Card = ({ product }: { product: ProductProps }) => {
const Card = ({ id, name, images, price, favoriteCount }: ProductProps) => {

Comment on lines +25 to +30
const getPageSize = (width: number): PageSizeType => {
if (width < 768) return PAGE_SIZE_BY_SCREEN.MOBILE;
if (width < 1200) return PAGE_SIZE_BY_SCREEN.TABLET;

return PAGE_SIZE_BY_SCREEN.PC;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

P3:
이런 함수가 반복적으로 사용되니 유틸로 분리를 하시거나,
아니면 breakpoint라도 const로 관리하시면 좋을 것 같습니다~

queryKey: ["products", { order, pageSize: pageSize!, currentPage }],
queryFn: fetchProducts,
enabled: !!pageSize,
placeholderData: keepPreviousData,
Copy link
Collaborator

Choose a reason for hiding this comment

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

P3:
👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

P3:
👍

() =>
new QueryClient({
defaultOptions: {
queries: { staleTime: 60 * 1000, refetchOnWindowFocus: false },
Copy link
Collaborator

Choose a reason for hiding this comment

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

P3:
기본값으로 1분도 나쁘지 않은 것 같지만, 블로그에 의하면 추천 staleTime은.. 20초라고 합니당.
참고만 해주세요~

https://tkdodo.eu/blog/react-query-as-a-state-manager#customize-staletime

@GANGYIKIM GANGYIKIM merged commit d905c7c into codeit-bootcamp-frontend:Next-나지원 Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. 미완성🫠 죄송합니다..

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants