방금 나온 따끈한 코드 #1
Replies: 5 comments 4 replies
-
|
첫글 써서 폭죽 터뜨려줌🎉🎉🎉🎉 |
Beta Was this translation helpful? Give feedback.
-
|
질문
|
Beta Was this translation helpful? Give feedback.
-
if (![privacy, marketing, analysis].every((item) => item)) {뭔가 이 조건 자체가 정말 자스스럽네요. 🤣🤣🤣 저 if문을 바꾸어 보자면 const allAgreed = privacy || marketing || analysis;혹은 const allAgreed = [privacy, marketing, analysis].some(Boolean);로 변수로 뺀 다음에 if문을 돌려보는건 어떨까유? |
Beta Was this translation helpful? Give feedback.
-
|
오우! 반복되는거 같아 고치고 싶은데 고치기 애매한 코드군요! 저였어도 아마 정규님 처럼 작성했을거 같긴하지만 재한님의 의견을 보고 const allAgreed = privacy && marketing && analysis;요런식으로 써서 every를 대체해도 괜찮지 않을까 생각합니당! |
Beta Was this translation helpful? Give feedback.
-
|
다들 넘나 좋은 의견을 많이 올려주셔서.. const [agreeied, setAgreeied] = useState({
privacy: false,
marketing: false,
analysis: false,
}); |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
첫 주니까 간단한 코드를 들고 왔읍니다.
"모두 동의" 버튼 로직
급하게 대처한 코드여서 길게 생각하지 않은 코드임덩. 그래서? 더 우아하고 깔-꼼하게 짤 수 있을 것 같은데.. 여러분의 고견이 듣고 싶어 공유합니다.
+++아무래도 도메인과 밀접해서 코드만으로는 이해하는 데 어려움을 겪으실 것 같아 이미지를 추가했습니다.

체크박스 하나 혹은 두 개를 체크했을 때 모두 동의를 선택하게 된다면, 사용자가 기대하는 동작에 대해 세 가지 상태 모두를 true로 변경하는 것이 낫겠다 판단하였습니다. 그렇게 해서 나오게 된 코드입니다.
Beta Was this translation helpful? Give feedback.
All reactions