Skip to content

Conversation

BXXNXXII
Copy link
Contributor

✅ 학습 내용 요약

  • 개념 학습: JSX, State, Props ⚛️
  • 순수 JavaScript, HTML, CSS로 구현했던 Todo List를 React 환경으로 리팩토링하는 학습을 진행했습니다.
  • 단일 CSS 파일 구조에서 각 컴포넌트가 독립적인 스타일을 갖도록 CSS 모듈화를 적용했습니다.

🤔 고민했던 부분

  • 처음에는 기존 style.css 파일을 그대로 App.jsx에만 연결해서 사용하는 것이 편하다고 생각했지만, 컴포넌트별로 JSX 파일은 분리하면서 CSS는 하나로 관리하는 것이 과연 "컴포넌트 기반 개발"의 장점을 제대로 살리는 것인지에 대한 고민이 있었습니다. 스타일이 겹치거나, 나중에 특정 컴포넌트의 스타일만 수정하고 싶을 때 거대한 CSS 파일 안에서 해당 부분을 찾아야 하는 불편함이 있을 것으로 생각했습니다.
  • 해결 방법: 각 컴포넌트가 자신만의 CSS 파일을 갖도록 구조를 변경했습니다. 컴포넌트의 독립성이 높아져 유지보수와 재사용성이 더 좋은 코드가 된다는 것을 느꼈습니다.

Copy link
Collaborator

@kwnP kwnP left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

id를 Date.now()로 하신 이유를 알려주세요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아직 간단한 형태로만 만들었는데, Date.now()를 통해서 할 일을 추가하는 순간마다 다 다른 값을 가지도록 해서, 새로운 할 일이 추가될 때마다 겹치지 않도록 id를 설정해놨습니다.
이후 추가적으로 입력된 할 일이 등록된 시간이 적히도록 코드를 수정하겠습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

왜 함수로 수정해야 할까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

함수 형태로 코드를 작성하면 React가 가장 최신 상태의 값을 가져와서 계산할 수 있기 때문이라고 알고 있습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Pretendard가 없는 환경에서도 잘 보일 수 있도록 웹폰트를 추가하시면 좋을 것 같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

감사합니다. 추후 수정하도록 하겠습니다 !!

Copy link
Collaborator

Choose a reason for hiding this comment

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

e.preventDefault();의 역할은 무엇인가요?

Copy link
Contributor Author

@BXXNXXII BXXNXXII Oct 8, 2025

Choose a reason for hiding this comment

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

html의

태그에서 기본 동작을 막아주는 역할로 알고 있습니다.
preventDefault를 넣지 않는다면, 텍스트 입력 후 추가 버튼을 누르면 입력된 내용이 할 일로 생성되자마자 바로 페이지가 새로고침되는데, preventDefault를 넣는다면 페이지 전체가 새로고침이 안되기 때문에 해당 코드를 사용했습니다.
(입력한 할 일이 그대로 남아있기 때문 !!)

@leesj0188 leesj0188 self-requested a review October 2, 2025 09:17
Copy link
Collaborator

@leesj0188 leesj0188 left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다! 투두리스트를 만드실 때, 컴포넌트 분리를 하셨던데 왜 분리하셨는지, 왜 이렇게 분리하셨는지 궁금합니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

왜 하나의 부모 요소로 감싸야 할까요? 만약에 감싸지 않는다면 어떻게 될까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

우선 컴포넌트 분리는 기능별로 코드를 나눠서 보면 가독성도 좋아지고 나중에 수정하기도 편할 것 같아서 분리했고,
JSX 문법상 return문 안에서는 하나의 요소만 반환할 수 있기 때문입니다. 부모 요소로 감싸지 않으면 에러가 발생합니다 !

Copy link
Collaborator

@KimDongHyeok0 KimDongHyeok0 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

trim()을 사용하신 이유가 뭔가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

사용자가 공백만 입력하거나, 입력값의 양 끝에 있는 불필요한 공백을 제거하고자 사용했습니다!!

Copy link
Collaborator

Choose a reason for hiding this comment

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

왜 css속성은 카멜 케이스로 작성해야 할까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

React에서 스타일을 적용할 때 JavaScript 문법을 따르기 때문이라고 알고 있습니다 !!
예를 들어 background-color는 JavaScript에서 빼기 연산으로 인식될 수 있어서 backgroundColor로 사용합니다.

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.

4 participants