Skip to content

Conversation

@dlwnsl
Copy link
Collaborator

@dlwnsl dlwnsl commented Nov 16, 2024

요구사항

기본

  • 스프린트 미션 5 ~ 7에 대해 typescript를 적용해주세요.

심화

  • any타입을 최소한으로 써주세요.

멘토에게

  • TypeScript로 변경하면서 커밋하는걸 까먹었습니당 ㅜㅜ
  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

hanseulhee and others added 30 commits October 10, 2023 14:22
…ithub-actions

[Fix] delete merged branch github action
@dlwnsl dlwnsl requested a review from kiJu2 November 16, 2024 01:08
@dlwnsl dlwnsl added the 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. label Nov 16, 2024
@kiJu2
Copy link
Collaborator

kiJu2 commented Nov 18, 2024

수고 하셨습니다 ! 스프리트 미션 하시느라 정말 수고 많으셨어요.
학습에 도움 되실 수 있게 꼼꼼히 리뷰 하도록 해보겠습니다. 😊

};

function AllItems() {
const [orderBy, setOrderBy] = useState<string>("recent");
Copy link
Collaborator

Choose a reason for hiding this comment

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

타입 범위를 좁혀볼까요 ?

Suggested change
const [orderBy, setOrderBy] = useState<string>("recent");
const [orderBy, setOrderBy] = useState<"recent" | "like">("recent");

위와 같이 유니온 타입으로 설정한다면 더욱 명확한 타입을 전달할 수 있어요 !

Comment on lines +7 to +9
interface BestItemCardProps {
item: Product;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

(제안) 컴포넌트에서 사용되는 타입들만 선언해볼 수 있어요 !

Suggested change
interface BestItemCardProps {
item: Product;
}
interface BestItemCardProps {
id: number;
name: string;
price: number;
description?: string;
images: string[];
favoriteCount?: number;
}
function BestItemCard({ id, name, price ... }: BestItemCardProps) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

그리고 호출부에서는 다음과 같이 사용할 수 있어요 !

<BestItemCard {...product} />

Comment on lines +11 to +15
function BestItemCard({ item }: BestItemCardProps) {
return (
<div className="item-card">
<Link to={`/items/${item.id}`}>
<img src={item.images[0]} alt={item.name} className="item-card-img" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

아니면 구조분해 할당을 사용해볼 수 있습니다 ! 😊

Suggested change
function BestItemCard({ item }: BestItemCardProps) {
return (
<div className="item-card">
<Link to={`/items/${item.id}`}>
<img src={item.images[0]} alt={item.name} className="item-card-img" />
function BestItemCard({ item }: BestItemCardProps) {
const { id, name, images } = item;
return (
<div className="item-card">
<Link to={`/items/${item.id}`}>
<img src={item.images[0]} alt={item.name} className="item-card-img" />

Comment on lines +64 to +65
if (loading) return <div>댓글을 불러오는 중입니다...</div>;
if (error) return <div>{error}</div>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

크으 -! 조건부 처리 잘해놨네요 ! 👍

Comment on lines +8 to +18
interface Comment {
id: number;
content: string;
createdAt: string;
updatedAt: string;
writer: {
id: number;
image: string;
nickname: string;
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

깔끔한 타입선언 ! 😊👍👍


function ItemComments() {
const { productId } = useParams<{ productId: string }>();
const [comments, setComments] = useState<Comment[]>([]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

굳굳~! 👍

Comment on lines +11 to +22
interface ProductDetail {
id: number;
name: string;
description: string;
price: number;
createdAt: string;
favoriteCount: number;
ownerNickname: string;
ownerId: number;
images: string[];
tags: string[];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

깔끔 -! 합니다 ㅎㅎㅎ 👍👍👍

벌써 적응 하셨군요 ㅎㅎㅎ

Comment on lines +10 to +19
}

function Pagination({
currentPage,
totalPageNum,
onPageChange,
}: PaginationProps) {
const pageNumbers = [];
const maxVisiblePages = 5; // 한 번에 표시할 최대 페이지 수

Copy link
Collaborator

Choose a reason for hiding this comment

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

컴포넌트 자원을 사용하지 않는다면 바깥으로 빼시는게 좋습니다 ! 😊

Suggested change
}
function Pagination({
currentPage,
totalPageNum,
onPageChange,
}: PaginationProps) {
const pageNumbers = [];
const maxVisiblePages = 5; // 한 번에 표시할 최대 페이지 수
}
const maxVisiblePages = 5; // 한 번에 표시할 최대 페이지 수
function Pagination({
currentPage,
totalPageNum,
onPageChange,
}: PaginationProps) {
const pageNumbers = [];

Comment on lines +27 to +31
const response = await axios.post(
"https://panda-market-api.vercel.app/products",
formData
);
const itemListResponse: ItemListResponse = response.data;
Copy link
Collaborator

Choose a reason for hiding this comment

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

다음과 같이 axios에 제네릭을 사용할 수 있어요 ㅎㅎㅎ 😊

Suggested change
const response = await axios.post(
"https://panda-market-api.vercel.app/products",
formData
);
const itemListResponse: ItemListResponse = response.data;
const response = await axios.post<ItemListResponse>(
"https://panda-market-api.vercel.app/products",
formData
);
const itemListResponse = response.data;

Comment on lines +8 to +18
interface Comment {
id: number;
content: string;
createdAt: string;
updatedAt: string;
writer: {
id: number;
image: string;
nickname: string;
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

지금 보니까 types.ts에 이미 정의되어있네요 ! 공통 타입을 import하는게 어떨까요 ?

@kiJu2
Copy link
Collaborator

kiJu2 commented Nov 18, 2024

수고하셨습니다 준희님 !! 타입스크립트 잘 적응하셨는데요 ?? 굳굳 👍
그 간 정말 수고 많으셨습니다 준희님 ㅎㅎㅎ
앞으로도 지금처럼 열정있게 개발 공부하시면 분명 빠르게 훌륭한 개발자가 될 수 있으실거로 보여요.

앞으로의 길 진심으로 승승장구하시길 바라겠습니다 !! 🙇‍♂️🙇‍♂️

@kiJu2 kiJu2 merged commit c91a490 into codeit-bootcamp-frontend:React-이준희 Nov 18, 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.

5 participants