Skip to content

Conversation

kimsoyoung96
Copy link
Collaborator

요구사항

기본

상품 등록

  • 상품 등록 페이지 주소는 “/additem” 입니다.
  • 페이지 주소가 “/additem” 일때 상단네비게이션바의 '중고마켓' 버튼의 색상은 “3692FF”입니다.
  • 상품 이미지는 최대 한개 업로드가 가능합니다.
  • 이미지를 제외하고 input 에 모든 값을 입력하면 ‘등록' 버튼이 활성화 됩니다.
  • 각 input의 placeholder 값을 정확히 입력해주세요.
  • API를 통한 상품 등록은 추후 미션에서 적용합니다.

심화

  • 이미지 안의 X 버튼을 누르면 이미지가 삭제됩니다.
  • 추가된 태그 안의 X 버튼을 누르면 해당 태그는 삭제됩니다.

주요 변경사항

스크린샷

image

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

Copy link
Collaborator

@devToram devToram left a comment

Choose a reason for hiding this comment

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

수고 많으셨어요 👍

import styles from "./ItemCard.module.css";

function ItemCard({ className, item }) {
const thumbnailUrl = "https://example.com/...";
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 thumbnailUrl = "https://example.com/...";
const THUMBNAIL_URL = "https://example.com/..." as const;

Comment on lines 13 to 15
item.images.some((image) => image === thumbnailUrl)
? noImage
: item.images[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

요 부분은 위쪽에서 계산해주고 return 에는 결과만 내려줘도 될 거 같아요! item.images 가 변할 때에만 src 가 바뀌도록 useMemo 를 선언해주면 최적화도 될 거 같네요!

const imageSource = useMemo(() =>  
     item.images.some((image) => image === thumbnailUrl) ? noImage :  item.images[0], 
[item.images])

...

return (
   ...
  <img src={imageSource}>
)

import styles from "./ItemCard.module.css";

function ItemCard({ className, item }) {
const thumbnailUrl = "https://example.com/...";
Copy link
Collaborator

Choose a reason for hiding this comment

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

item 자체를 쓰는 경우는 없고 다 item 내의 프로퍼티들을 쓰니까 앞에서 구조 분해해서 가면 아래 코드도 간결해질 거 같아요
const {images, name, price, favoriteCount} = item

<div className="nav_center">{center}</div>
<div className="nav_user">{rightChild}</div>
</nav>
<div className={styles.Nav}>
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
<div className={styles.Nav}>
<div className={styles.�nav}>

@@ -1,12 +1,28 @@
import './Nav.css';
import styles from "./Nav.module.css";
import Nav_logo from "../assets/nav_panda_logo_img.png";
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
import Nav_logo from "../assets/nav_panda_logo_img.png";
import NavLogo from "../assets/nav_panda_logo_img.png";

Comment on lines 21 to 23
if (!emailRegex.test(email)) {
return "잘못된 이메일 형식입니다";
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

early return 💯

const Navigate = useNavigate();

// 이메일 값 체크
const EmailCheck = (email) => {
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 EmailCheck = (email) => {
const emailCheck = (email) => {


// 비밀번호 값 체크
const PasswordCheck = (password) => {
const PASSWORD_MIN_LEN = 8;
Copy link
Collaborator

Choose a reason for hiding this comment

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

요것도 컴포넌트 밖으로 뺴주셔용


if (!password.trim()) {
return `패스워드를 입력해주세요`;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기도 early return 쓰면 좋을 거 같아용

Comment on lines 97 to 109
if (
!emailError &&
!nickNameError &&
!passwordError &&
!passwordMatchError &&
email &&
nickName &&
password &&
passwordMatch
) {
return setIsButtonDisabled(false);
}
return setIsButtonDisabled(true);
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
if (
!emailError &&
!nickNameError &&
!passwordError &&
!passwordMatchError &&
email &&
nickName &&
password &&
passwordMatch
) {
return setIsButtonDisabled(false);
}
return setIsButtonDisabled(true);
const isNoError = !emailError && !nickNameError && !passwordError && !passwordMatchError
const hasAllInput = email && nickName && password && passwordMatch
setIsButtonDisabled(!(isNoError && hasAllInput))

@devToram
Copy link
Collaborator

devToram commented Feb 4, 2025

충돌사항들이 좀 있는데 해소하고 꼭 머지해주셔요 😃

@kimsoyoung96 kimsoyoung96 force-pushed the React-김소영-sprint7 branch from 36841dd to 4cf1edf Compare February 25, 2025 15:34
@devToram devToram merged commit a0e9226 into codeit-bootcamp-frontend:React-김소영 Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants