Skip to content

Conversation

@yujin0408
Copy link
Collaborator

요구사항

Github에 PR(Pull Request)을 만들어서 미션을 제출합니다.
피그마 디자인에 맞게 페이지를 만들어 주세요.
React를 사용합니다

기본

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

심화

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

주요 변경사항

  • sprint 5 피드백 반영하여 리팩토링 했습니다

스크린샷

image
image
image

멘토에게

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

@yujin0408 yujin0408 requested a review from dongqui April 18, 2025 15:47
@yujin0408 yujin0408 added the 순한맛🐑 마음이 많이 여립니다.. label Apr 18, 2025
Copy link
Collaborator

@dongqui dongqui left a comment

Choose a reason for hiding this comment

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

유진님!
빠른 성장이 느껴집니다..🤣 프로젝트도 화이팅입니다~!


if (value) {
setError("*이미지 등록은 최대 1개까지 가능합니다.");
if (fileInputRef.current) fileInputRef.current.value = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

꼼꼼하게 잘 챙겨주셨네요! 👍

color: var(--color-gray400);
font-size: var(--text-lg);

input {
Copy link
Collaborator

Choose a reason for hiding this comment

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

hidden 속성을 쓰는 방법도 있습니다 :)

<input hidden />

if ((e.key === "Enter" || e.key === ",") && inputValue.trim()) {
e.preventDefault();
const newTag = inputValue.trim();
if (!tags.includes(newTag)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

중복 처리하실 때 Set을 서보셔도 좋아요 :)

onClick={onSearch}
></button>
)}
{type === "textarea" ? (
Copy link
Collaborator

Choose a reason for hiding this comment

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

type은 input이 가지고 있는 고유 html 속성이죠..! 커스텀하여 props로 쓰기에는 부적절합니다.

function A({ as }) {
  const Component = as;
  return <Component />
}

<A as='textarea' />
이런 식으로 쓰실  있어요!

</label>
)}
<div className="el-input">
{type === "search" && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

이것도 방법이 될 수 있지만 검색, 비밀번호 표시 같은 요소들은 밖에서 처리하시는 것이 좋습니다 :)
지금 상태라면 type이 늘어날 때 마다 분기처리나 onSearch 같은 코드들이 계속 추가됩니다! 컴포넌트가 너무 커지고, 사용하기 복잡해지는 문제가 생길 수 있습니다.

    <TextFiled
        prefix={
          <button
            type="submit"
            className="el-btn btn-search"
            aria-label="검색"
            onClick={onSearch}
          ></button>
        }
      />

이런식으로 밖에서 받아서 처리하시는 방법도 있어요!

const [searchParams, setSearchParams] = useSearchParams();
const navigate = useNavigate();

const searchQuery = searchParams.get("search") || "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

뚝딱뚝딱 금방 수정하시는군요..! 😮 👍

const params = { search: searchQuery, order, page, pageSize: itemCount };
const { items, isLoading, error } = useItemFetcher(getItems, params);

useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

이부분은 없어도 동작하는데 문제 없을 거 같네요 🤔

또한 onChange를 세밀하게 다룰 것이 아니라면 unControlled를 고려해 보셔도 좋습니다 :) form으로 이미 감싸셔서 submit event에 value가 들어올 거에요!

import TagInput from "../../components/Input/TageInput/TagInput";
import "./AddItem.scss";

function AddItem() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

전반적으로 깔끔하네요! 👍

useEffect(() => {
handleGetItmes();
}, [search, order, page, itemCount]);
if (error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Errorboundary를 사용하시면 컴포넌트 내에서 에러 관련 로직을 빼낼 수 있습니다 :)
https://fe-developers.kakaoent.com/2022/221110-error-boundary/

@dongqui dongqui merged commit 3035ea1 into codeit-bootcamp-frontend:React-이유진 Apr 21, 2025
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.

2 participants