-
Notifications
You must be signed in to change notification settings - Fork 79
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(재업로드) #611
The head ref may contain hidden characters: "React-\uBC30\uC601\uC900-sprint8"
[배영준] sprint8(재업로드) #611
Conversation
Theme, GlobalStyle, CommonStyle 변환
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.
import "./Header.css"; | ||
|
||
// react-router-dom의 NavLink를 이용하면 활성화된 네비게이션 항목을 하이라이트해줄 수 있어요! | ||
function getLinkStyle({ isActive }) { | ||
interface LinkStyleProps { |
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.
[참고해주세요]
일반적으로 Props는 리액트 컴포넌트에 사용되는 용어입니다.
현재는 getLinkStyle
유틸함수이기 때문에 props보다는 함수 타입을 만드시는게 더 적절할것 같아요.
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.
interface LinkStyleParams {
isActive: boolean;
}
type GetLinkStyle = (params: LinkStyleParams) => React.CSSProperties;
const getLinkStyle: GetLinkStyle = ({ isActive }) => ({
color: isActive ? "var(--blue)" : "inherit", // 기본값을 "inherit"로 명시
});
이렇게 수정하셔도 좋을것 같아요.
return { color: isActive ? "var(--blue)" : undefined }; | ||
} | ||
|
||
function Header() { | ||
const location = useLocation(); // 현재 경로 정보 | ||
const location: Location = useLocation(); |
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.
타입을 명확히 하셨군요 👍
onSortSelection: (sortType: string) => void; | ||
} | ||
|
||
const DropdownMenu: React.FC<DropdownMenuProps> = ({ onSortSelection }) => { |
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.
타입을 꼼꼼히 작성해주셨네요 👍
const handleImageChange = (event) => { | ||
const file = event.target.files[0]; | ||
const handleImageChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const file = event.target.files ? event.target.files[0] : null; |
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.
[참고해주세요]
아래처럼 개선해볼 수 있습니다.
const file = event.target.files?.[0] ?? null;
placeholder="개인정보를 공유 및 요청하거나, 명예 훼손, 무단 광고, 불법 정보 유포시 모니터링 후 삭제될 수 있으며, 이에 대한 민형사상 책임은 게시자에게 있습니다." | ||
isTextArea | ||
onKeyDown={undefined} |
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.
[참고해주세요]
onKeyDown을 넣지 않으면 자동으로 undefined가 되기 때문에, 빼셔도 괜찮습니다.
|
||
const fetchSortedData = async ({ orderBy, page, pageSize }) => { | ||
const fetchSortedData = async ({ |
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.
[참고해주세요]
type때문에 코드가 길어지고 있어요, 타입을 따로 분리하는걸 추천드립니다.
@@ -1,7 +1,14 @@ | |||
import React from "react"; | |||
import { ReactComponent as HeartIcon } from "../../../assets/images/icons/ic_heart.svg"; | |||
|
|||
function ItemCard({ item }) { | |||
interface Item { |
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.
[수정해주세요]
통일성 있게 ItemCardProps로 명명해주세요!
혹은
Item 타입은 그대로 두고, 아래에 ItemCardProps를 추가해 주세요.
itemTag: string[]; | ||
} | ||
|
||
export interface ItemType { |
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.
ItemType
에서 Item
을 추출해주세요.
export interface ItemType {
id: number;
name: string;
description: string;
price: number;
tags: string[];
images: string[];
ownerId: number;
favoriteCount: number;
createdAt: Date;
updatedAt: Date;
isFavorite: boolean;
}
type Item = Pick<ItemType, 'images' | 'name' | 'favoriteCount' | 'price'>;
이런식으로 사용하실 수 있습니다.
요구사항
기본
주요 변경사항
스크린샷
멘토에게
그동안 정말 감사했습니다!!!