-
Notifications
You must be signed in to change notification settings - Fork 40
[김태완] Sprint12 #347
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
[김태완] Sprint12 #347
The head ref may contain hidden characters: "React-\uAE40\uD0DC\uC644-sprint11"
Conversation
…ithub-actions [Fix] delete merged branch github action
jyh0521
left a comment
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.
고생하셨습니다 👍
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.
혹시 일부러 개행을 해주신걸까요? package.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.
.env는 .gitignore에 추가해서 깃에 올라오지 않게 해주시는 것이 좋습니다.
| let postData: any = { | ||
| title: value.title, | ||
| content: value.content, | ||
| }; | ||
|
|
||
| // 이미지가 있을 경우만 imageUrl을 추가 | ||
| if (image) { | ||
| postData.image = await uploadImage(image); | ||
| } else if (articleDetail?.image) { | ||
| postData.image = articleDetail.image; | ||
| } |
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.
postData의 타입을 any로 지정하고 image url이 있는 경우에만 추가해서 사용하는 것은 타입에 대해 안전하지 않아 보입니다. any 대신 postData의 타입을 잘 설정해서 사용해보시면 좋을 것 같아요.
| await editArticle(postData, articleId); | ||
| toast.success("게시글이 수정되었습니다."); | ||
| navigate(`/board/${articleId}`); | ||
| } else { | ||
| // 게시글 등록 | ||
| const createdPost = await createPost(postData); |
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.
edit나 create 함수도 useMutation이라는 함수를 적용해보셔도 좋을 것 같아요~
| const FileInput = ({ initialValues = INITIAL_VALUES }) => { | ||
| // 이미지와 태그 상태를 별도로 관리 | ||
| const [preview, setPreview] = useState<string | null>(null); | ||
| const [preview, setPreview] = useState<string | null | undefined>(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.
null이 들어간다면 undefiend는 사용하지 않아도 될 것 같아보입니다.
| if (productId) { | ||
| // 상품 수정 모드 | ||
| return editProduct(newProduct, productId); // 상품 수정 API 호출 함수 | ||
| } else { | ||
| // 상품 등록 모드 | ||
| return postProduct(newProduct); // 상품 등록 API 호출 함수 | ||
| } |
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.
저는 개인적으로 mutation 하나당 하나의 api 요청을 보내는 것을 선호하긴 합니다. 추후에 로직이 길어진다면 분리해보는 것도 고려해보시면 좋을 것 같습니다.
| import React, { useState } from "react"; | ||
| import { FormatDateAgo } from "../../util/FormatDate"; | ||
| import styles from "./ArticleCommentInfo.module.css"; | ||
| import dotIcon from "../../assets/images/dotIcon.svg"; |
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.
alias path도 적용해보시면 좋을 것 같습니다.
|
|
||
| const handleEditSave = async (commentId: number, writerId: number) => { | ||
| if (writerId !== user.id) { | ||
| toast.warning("본인의 댓글만 수정할 수 있습니다."); |
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.
toast 라이브러리 활용 잘해주셨네요. 기회가 되면 만들어보시는 것도 추천드립니다.
| onSuccess: () => { | ||
| toast.success("게시글 좋아요가 완료되었습니다."); | ||
| setClickFavorite(true); | ||
| setCurrentCount((prev) => prev + 1); |
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.
낙관적 업데이트 하는 방법도 한번 알아보시면 좋을 것 같습니다.
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.
useDebounce 훅 잘 만들어주셨네요!
|
리액트 쿼리 잘 사용해주고 계신 것 같아요~ useMutation도 얼른 적용해보시면 좋을 것 같습니다! |
요구사항
기본
중고마켓
상품 상세
상품 등록
심화
주요 변경사항
스크린샷
배포
멘토에게
리뷰 중점사항(전체적으로 손대다보니 변경된 파일이 많았습니다. 자잘한 내용 제외하고 아래와 같이 정리했습니다.)
/components
/hooks/useDebounce -> 디바운스 적용하려고 커스텀 훅 하나 만들었습니다.
/redux -> 여러 컴포넌트에서 데이터 활용하기 위한 리덕스 추가