상품 상세 페이지
상품 상세
- ProductDetailPage
- useFetchProduct.ts // 👈🏻 loading, error 대한 처리 hook
- ProductDetail.tsx // 👈🏻 Store 통해 상품 상세 얻기ProductDetailPage.tsx
Loading, Error UI 구현
useParams hook을 사용해서 productId 얻어오기
useParams hook을 사용해서 productId 얻어오기export default function ProductDetailPage() {
const params = useParams(); // 👈🏻 hooks
const { loading, error } = useFetchProduct({
productId: String(params.id),
});
if (loading) {
return (
<p>Loading...</p>
);
}
if (error) {
return (
<p>Error!</p>
);
}
return (
<ProductDetail />
);
}useFetchProduct.ts
ProductDetailStore.ts
Null Object 생성
useProductDetailStore.ts
✅ Refactor
상품 상세 정보 UI 구현
ProductDetail.tsx
Images.tsx
Description.tsx
여러줄로 처리된 데이터를 줄바꿈 처리
장바구니 상품 담기
AddToCartForm.tsx
AddToCartForm.test.tsx
Store 및 Store 사용을 위한 hooks 생성
Quantity : 수량 버튼 기능 구현
Price : 수량에 맞는 가격 UI 구현
Getter 이용한 방식
📖 Getter 와 Setter
SubmitButton : 장바구니 담기 버튼 기능 구현
SubmitButton.tsx
SubmitButton.test.tsx
ProductFormStore의 싱태 추가 및 액션 addToCart 추가
✅ Refactor
price.tsx
Options : 옵션 선택 기능 구현
🔗 참고
Last updated