Type Guard를 활용한 여러가지 Button 구현하기

ant·2025년 7월 6일

react-component

목록 보기
2/3
post-thumbnail
  1. [React Component] Type Guard를 활용한 여러가지 Button 구현하기

    "디자인 시스템의 Button, 단순히 props로 분기 처리하면 되지 않을까요?"
    처음엔 간단해 보였던 버튼 컴포넌트. 하지만 Solid, Outlined, Text 등 스타일마다 다른 Variant와 규칙을 적용하려다 보니 if문
    지옥과 타입 불안정성에 빠졌습니다. 이를 Discriminated Union(구별된 유니온)과 Type Guard로 우아하게 해결한 과정을 공유합니다.

    💡 핵심 포인트

0개의 댓글