-
Notifications
You must be signed in to change notification settings - Fork 0
[#1] 오류제보, 정답제보 탭 순차적 렌더링 구현 #10
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
Conversation
onClick={() => { | ||
setSubmitted(false); | ||
setErrorCategory(-1); | ||
setQuestionName(""); | ||
setDetailInput(""); | ||
}} |
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.
이런 로직이 onClick 다이렉트로 적어 놓는 것이 아니라 handleClick
이런식으로 빼서 위에 정의를 해놓는게, 가독성 면도 그렇고 의미 측면에서도 좋다고 생각합니다.
|
||
export default function ErrorReport() { | ||
const [submitted, setSubmitted] = useState(false); | ||
const [errorCategory, setErrorCategory] = useState(-1); |
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.
숫자가 아닌 실제 옵션 명으로 state가 정의 되어있으면 좋을 것 같아요. 숫자로 어떤 선택지인지 파악하기가 어렵습니다!
const [detailInput, setDetailInput] = useState(""); | ||
|
||
return submitted ? ( | ||
<div> |
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.
div 대신 용어를 담은 StyledComponent를 사용하면 해당 페이지의 구조를 더 파악하기 쉬울 것 같아요!
<label htmlFor="errorCategory2">기타</label> | ||
</div> | ||
|
||
{errorCategory === -1 || errorCategory === 1 ? null : ( |
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.
순차적 렌더링을 위해 분기가 많이 생길 수 밖에 없는데요! 이러한 부분도 handleClick을 분리 했던 것 처럼 로직을 return 외부로 분리 시키면 좋을 것 같아요. 예를 들면 isQuestionNameVisible
이런식으로 선언해둘 수 도 있겠네요! 이러한 비슷한 값들을 담은 하나의 객체나 상태를 선언해도 좋을 것 같구요
작업 내용
관련 Issue
Close #1
생각해볼 내용
이후 작업할 내용