-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feat/IGW-18/3-field 공용 컴포넌트 작성 #4
Conversation
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.
테스트까지 디테일하게 해주셔서 너무 좋습니다👍 수고하셨어요!!ㅠㅠ
src/components/Common/Input.tsx
Outdated
}: InputProps) => { | ||
// 현재 입력 필드의 상태를 관리합니다. | ||
const [currentStatus, setCurrentStatus] = useState< | ||
'DISABLED' | 'TYPING' | 'INVALID' |
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.
'INVALID' 같은 문자열들이 반복되어 쓰이는데 상수로 빼서 사용하면 오타방지되구 좋을 것 같습니다!
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.
안그래도 좀 고민 됐던게, const INVALID = 3
와 같이 선언해놓고 사용하면 오타는 방지되겠지만,
사용하는 입장에서나 나중에 Input.tsx
자체를 수정할 일이 생기면 inputType = {3}
과 같은 prop이나 currentStatus === 3
과 같은 조건문이 쉽게 눈에 들어오지 않을 것 같아요.
그래서 상태들은 텍스트로 남겨두는게 좋을 것 같다는 생각이 들어 이 방식을 사용했는데, 혹시 더 좋은 방법 없을까요..?
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.
아하 저는 텍스트 자체를 상수화 시키면 좋을 것 같다는 거였습니다
'INVALID' 문자열로 쓰고 있으니까는 예를 들어서 다음처럼요!
const INPUT_STATUS = {
DISABLED: 'DISABLED',
TYPING: 'TYPING',
}
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.
확실히 타입화 해두는게 useState<InputStatus>
와 같이 표시하기도 편하겠네요 반영하겠습니다~
Related issue 🛠
#3
Work Description ✏️
2024-10-17.2.06.45.mov
DropDown 컴포넌트
DatePicker
Uncompleted Tasks 😅
To Reviewers 📢