Skip to content

Conversation

@seungwonHong
Copy link
Collaborator

@seungwonHong seungwonHong commented May 13, 2025

요구사항

기본

  • 게시글 등록 페이지 주소는 '/addboard'입니다
  • 게시판 이미지는 최대 한개 업로드가 가능합니다
  • 각 input의 placeholder 값을 정확히 입력해주세요
  • 이미지를 제외하고 input에 모든 값을 입력하면 '등록' 버튼이 활성화 됩니다
  • 게시글 상세 페이지 주소는 '/board/{id}' 입니다
  • 댓글 input 값을 입력하면 '등록' 버튼이 활성화 됩니다
  • 자유게시판 페이지에서 게시글을 누르면 게시물 상세 페이지로 이동합니다
  • 게시글 상세 페이지 주소는 'board/{id}'입니다
  • 댓글 input 값을 입력하면 '등록' 버튼이 활성화 됩니다

심화

  • 태블릿, 모바일 반응형 디자인을 구현해주세요

주요 변경사항

  • 반응형 디자인
  • 제품 상세 페이지
  • 게시글 등록

스크린샷

image

멘토에게

  • 테일윈드 같은 경우에 스타일이 길어지면 정리가 안되는데 저장을 하면 자동으로 줄을 바꿔준다거나 정리해주는 플러그인 같은게 있을까요?
  • 아직 포스팅 기능은 구현하지 않았습니다. 추후에 로그인과 회원가입을 연결하면 진행할 예정입니다.
  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@seungwonHong seungwonHong requested a review from dongqui May 13, 2025 07:14
@seungwonHong seungwonHong added the 순한맛🐑 마음이 많이 여립니다.. label May 13, 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.

승원님! 오랜만에 스프린트 하시느냐고 고생 많으셨습니다 :)
역시나 리엑트는 잘 써 주셨지만, next를 좀 더 적극적으로 써보시면 더욱 좋을 거 같습니다~!

테일윈드 같은 경우에 스타일이 길어지면 정리가 안되는데 저장을 하면 자동으로 줄을 바꿔준다거나 정리해주는 플러그인 같은게 있을까요?
-> 줄 바꿈은 tailwind 랑 별개로 프리티어를 활용하시는 것이 일관성에 맞을 거 같네요!
그외에 자동 완성이나
https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
순서 정렬을 고려해 볼 수 있겠습니다..!
https://marketplace.visualstudio.com/items?itemName=heybourn.headwind

또 지금 Arbitrary values도 많이 쓰이고 있는데, 해당 부분을 줄이는 것도 도움이 될 거 같네요!
https://fe-developers.kakaoent.com/2022/220303-tailwind-tips/#arbitrary-values-%EC%A4%84%EC%9D%B4%EA%B8%B0

마지막으로 컴포넌트를 조금 더 적극적으로 활용해 보시면 좋을 거 같습니다. 컴포넌트로 jsx를 추상화 하시는 것도 방법입니다!

그리고 꼭 버튼이나 인풋 같은 UI뿐만 아니라 유틸리티 형태의 컴포넌트를 작성해 보셔도 좋습니다.
예를 들면 가로 정렬을 시켜주는 Row같은 것들도 만드실 수 있겠죠!

function Row({ chidlren }) {
   return <div className="flex flex-row items-center">{children}</div>
}

const [disable, setDisable] = useState(true);
const [buttonColor, setButtonColor] = useState("#9CA3AF");

useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

title, content로 결정 되는 값들이라면 굳이 useEffect를 쓸 필요 없습니다!

const isDisabled =  !(title && content);
const buttonColor = title && content ? '#3692FF' : '#9CA3AF';

Copy link
Collaborator

Choose a reason for hiding this comment

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

그리고 버튼을 컴포넌트화 해서 활용했다면 상태 값을 내부에서 좀 더 깔끔하게 다룰 수 있었을 거 같네요 :)

import useScroll from "@/hooks/useScroll";
import Loading from "@/components/Loading";

const Page = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

next를 사용하시는 김에 다양한 렌더링을 써보시면 좋을 거 같습니다 :) 특히 상세 페이지의 경우 보통 SEO와 직결되므로 특히 더 고려해 볼 수 있겠죠!

}, [handleScroll]);

useEffect(() => {
const fetchMoreComment = async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

useScroll이 재사용 되기 위해서는, fetchMoreComment는 밖에서 처리하는 것이 좋겠습니다!
아니면 훅 이름을 useInfiniteComment 등으로 도메인이 포함된 이름으로 바꾸시는 것이 좋겠네요 :)

setComment(e.target.value);
};

useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기도 위와 마찬가지 입니다! 불필요한 useEffect 입니다 :)

useEffect의 경우 불필요한 렌더링을 발생시키고, 코드 흐름을 끊는 경향이 있어 주의해주시면 좋아요 :)

onChange={handleChange}
></textarea>
<div className=" flex flex-row justify-end">
<button
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 부분들도 공통 컴포넌트를 활용해 보시면 좋을 거 같습니다!

type="file"
name="addImage"
id="addImage"
className="hidden"
Copy link
Collaborator

Choose a reason for hiding this comment

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

class 말고 html hidden 속성을 쓰실 수 있어요 :)

day: "2-digit",
})
.replace(/\.$/, "");
const formattedDate = new Date(article.createdAt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

요런 부분은 utils로 빼시면 좋습니다~!

window.innerHeight + window.scrollY >=
document.documentElement.scrollHeight - 30
) {
setLoading(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

스크롤 -> 로딩 -> fetchMoreComment보다

스크롤 -> fetchMoreComment -> 로딩

흐름이 조금 더 자연스러울 거 같습니다 🤔

const [loading, setLoading] = useState(false);

const handleScroll = useCallback(() => {
if (
Copy link
Collaborator

Choose a reason for hiding this comment

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

무한 스크롤 경우 이벤트가 굉장히 많이 발생합니다. 쓰로틀, 디바운스를 고려해 보시거나 intersection observer를 활용해 보시면 좋습니다 :)

@dongqui dongqui merged commit 5f4224f into codeit-bootcamp-frontend:Next-홍승원 May 13, 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