Skip to content

[Step4] cactus - 재사용 가능한 컴포넌트 설계 - #9

Open
ehlung wants to merge 15 commits into
cactus-step3from
cactus-step4
Open

[Step4] cactus - 재사용 가능한 컴포넌트 설계#9
ehlung wants to merge 15 commits into
cactus-step3from
cactus-step4

Conversation

@ehlung

@ehlung ehlung commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

개인 목표 달성 여부

  • 폼 입력 상태를 controlled input으로 관리하고 uncontrolled와의 차이를 이해했다
  • children prop을 활용한 재사용 가능한 Modal 컴포넌트를 직접 설계했다
  • 폼 제출 시 입력값을 수집해 상위 컴포넌트 state를 업데이트하는 흐름을 구현했다

리뷰어에게

  • controlled input 대신 uncontrolled(FormData)를 쓰는 게 더 맞는 상황이 있는지 같이 얘기해보고 싶어요
  • 함수형 업데이트를 쓰는 게 좋은 구체적인 케이스가 있으면 공유해주세요!

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 584beb50-e4a1-4611-bfa5-a2fa70b5c2fa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cactus-step4

Comment @coderabbitai help to get the list of available commands and usage tips.

@ehlung
ehlung requested a review from meteorqz6 June 8, 2026 13:41
@ehlung ehlung self-assigned this Jun 8, 2026
Comment thread src/components/Modal/Modal.jsx Outdated

export default function Modal({ title, onClose, children }) {
return (
<div className={`${modalStyles.modal} ${modalStyles["modal--open"]}`}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[질문]
className={${modalStyles.modal} ${modalStyles["modal--open"]}}
이 코드가 필요한 이유가 무엇인가요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

유성님 README를 읽고 해당 CSS 패턴이 템플릿에서 그대로 가져온 거라 React 조건부 렌더링({isOpen && <Modal />})으로 전환한 코드에서는 불필요한 패턴인 것을 확인했습니다. 템플릿 구조를 그대로 써서 개선할 생각을 못 했는데 덕분에 수정했습니다! 함께 언급해주신 backdrop과 container도 둘 다 position: fixed라 부모 레이아웃에 영향을 받지 않아서 래퍼 <div>도 함께 제거하고 Fragment로 교체했습니다!


const handleSubmit = (e) => {
e.preventDefault();
onSubmit({ id: crypto.randomUUID(), category, name, description });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[배움]
crypto.randomUUID()를 사용해서 고유 ID를 생성한 점이 인상 깊었습니다!

Comment thread README.md
setNewRestaurants([...newRestaurants, newRestaurant]);

// 함수형 업데이트 — React가 최신 state를 prev로 전달
setNewRestaurants((prev) => [...prev, newRestaurant]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[논의]
두 방식을 스터디 세션 때 같이 정리하면 좋을 것 같습니다!

Comment on lines +37 to +41
{CATEGORIES.map((category) => (
<option key={category} value={category}>
{category}
</option>
))}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[배움]

<option value="">선택해 주세요</option>
<option value="한식">한식</option>
<option value="중식">중식</option>
<option value="일식">일식</option>
<option value="양식">양식</option>
<option value="아시안">아시안</option>
<option value="기타">기타</option>

저는 위와 같은 방식으로 구현했습니다. 이 부분을 배열과 map 메서드를 활용한 점이 인상 깊네요! 유지보수성과 가독성에 더 좋다는 점에서 저도 리팩토링해볼게요 !

@ehlung ehlung changed the title [Step4] cactus - controlled input & children prop 활용 [Step4] cactus - 재사용 가능한 컴포넌트 설계 Jun 14, 2026
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