-
Notifications
You must be signed in to change notification settings - Fork 35
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
[김강우] sprint8 #245
The head ref may contain hidden characters: "React-\uAE40\uAC15\uC6B0-sprint8"
[김강우] sprint8 #245
Conversation
src/api/product.ts
Outdated
if (!response.ok) { | ||
throw new Error("getProduct 요청에 실패했습니다."); | ||
} | ||
const result: ProductsApi = await response.json(); |
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.
p3;
단일 제품에 대한 api의 결과이므로, 이에 맞게 타입명도 변경되면 좋을 것 같아요!
그냥 직관적으로는 Product
, ProductDetails
과 같은 타입명이 좋아보이고,
api의 응답결과인 것을 명시적으로 표현하고 싶으시다면 ProductResponse
등도 괜찮은 것 같습니다.
개인적으로는 Product
, ProductDetails
등이 가장 직관적인 것 같아요!
src/api/product.ts
Outdated
pageSize: number; | ||
orderBy: string; | ||
keyword: number; | ||
} |
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.
p4;
api 요청시 전달되는 QueryString은 �보통 옵셔널하게 전달할 수 있도록 설계되어 있을 것 같아요!
해당 인터페이스의 각 프로퍼티를 옵셔널하게 할 수 있도록 하면 좋을 것 같아요!
src/api/product.ts
Outdated
keyword, | ||
}: QueryType) => { | ||
const response = await fetch( | ||
`https://panda-market-api.vercel.app/products?page=${page}&pageSize=${pageSize}&orderBy=${orderBy}&keyword=${keyword}` |
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.
p4;
요부분도 URLSearchParams 등을 사용해서 쿼리스트링을 만들고 붙이면 어떨까 싶어요!
src/api/product.ts
Outdated
{ | ||
limit, | ||
cursor = 0, | ||
}: { |
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.
p4;
뒤에 붙는 limit와 cursor 같은 comment api 호출시 전달하는 옵션도 따로 interface로 정의해서 사용하면 더 깔끔할 것 같아요!
interface GetCommentsOptions {
limit?: number;
cursor?: number;
}
export const getComments = async (
id: number,
{ limit, cursor = 0 }: GetCommentsOptions
): Promise<CommentsApi> => {...}
src/components/Auth.tsx
Outdated
children: ReactNode; | ||
} | ||
|
||
const Submit = ({ isValid, children }: SubmitProps) => { |
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.
p4;
children을 직접 정의해도 되지만, React에서 제공하는 PropsWithChildren 유틸리티 타입을 사용해서 children prop을 자동으로 포함할 수 있습니다!
import { PropsWithChildren ... } from "react";
interface SubmitProps {
isValid: boolean;
}
const Submit = ({ isValid, children }: PropsWithChildren<SubmitProps>) => {
return (
<button >{children}</button>
);
};
src/components/ItemTop.tsx
Outdated
import searchIcon from "../assets/[email protected]"; | ||
import isDropdownIconPC from "../assets/[email protected]"; | ||
import isDropdownIconMobile from "../assets/[email protected]"; | ||
import "../styles/items.css"; | ||
|
||
const H1 = ({ children }) => { | ||
const H1 = ({ children }: { children: ReactNode }) => { |
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.
p4;
요 부분도, PropsWithChildren 유틸리티 타입을 사용해도 좋을 것 같아요!
추가적으로 Reac.FC 타입을 사용하면 가독성이 더 좋아질 것 같아요!
const H1: React.FC<PropsWithChildren> = ({ children }) => {
return <h1 className="h1__items">{children}</h1>;
};
<S.ContentTitle>상품 태그</S.ContentTitle> | ||
<S.TagList> | ||
{product?.tags.map((tag) => ( | ||
<S.Tag>#{tag}</S.Tag> |
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.
p3;
매핑되는 요소들에 적절한 key를 부여하면 좋을 것 같아요!
src/pages/AddItem.tsx
Outdated
@@ -13,6 +13,7 @@ import { | |||
import ItemFileInput from "../components/ItemFileInput"; | |||
import CancelLogo from "../assets/[email protected]"; | |||
import styled from "styled-components"; | |||
import { ItemKeyType, ItemType } from "src/types/type"; | |||
|
|||
const INITIAL_VALUE = { |
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.
p4;
INITIAL_VALUE가 ItemType이라는 것을 명시하면 더 좋을 것 같아요!
추가적으로 변수명이 조금더 구체화되면 좋을 것 같아요!
const INITIAL_ITEM_VALUE: ItemType = {
imageFile: null,
title: "",
content: "",
price: "",
tag: "",
};
src/pages/Items/index.tsx
Outdated
if (isMobile) return 4; | ||
if (isTablet) return 6; | ||
return 10; | ||
} |
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.
p3;
Sice -> Size 오타인듯 하네용
디바이스별 fetching size 옵션을 상수로 관리하는 건 어떨까요?
또한, getFetchingSiceByDevice 리턴하는 값도 단순 number가 아닌, 4,6,10으로 관리되도록 하면 아주 명확할 것 같아요!
const FETCHING_SIZE = {
MOBILE: 4,
TABLET: 6,
DEFAULT: 10,
} as const;
type FetchingSize = typeof FETCHING_SIZE[keyof typeof FETCHING_SIZE];
function getFetchingSizeByDevice(isMobile: boolean, isTablet: boolean): FetchingSize {
if (isMobile) return FETCHING_SIZE.MOBILE;
if (isTablet) return FETCHING_SIZE.TABLET;
return FETCHING_SIZE.DEFAULT;
}
src/styles/styled/media.ts
Outdated
|
||
const arr = Object.entries(breakpoints); | ||
|
||
const media = arr.reduce<MediaQueryType>((acc, [key, value]) => { |
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.
breakPoints 에 따라서 미디어 쿼리를 간편하게 적용할 수 있도록 타입 정와 더불어 유틸리티를 잘 정의하셨네요!
안녕하세요, 강우님! 타입스크립트 정의된 부분들 위주로 코드를 살펴봤어요. 코드를 보며 조금 개선하면 좋을 부분들에 대해서 간단한 리뷰들을 남겼습니다. +) 리뷰를 남긴 코멘트 위의 p(1~5); 마크의 의미는 아래와 같습니다! 참고하면 좋을 것 같아요!
|
요구사항
기본 요구사항
기본 체크리스트
멘토에게