Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[#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

Merged
merged 1 commit into from
Jun 30, 2022

Conversation

chaerin-dev
Copy link
Member

@chaerin-dev chaerin-dev commented Jun 30, 2022

작업 내용

  • useState를 이용한 순차적 렌더링 구현
  • 컴포넌트가 지나치게 분리되어있다는 피드백을 반영하여 한 페이지를 하나의 파일로 합침

관련 Issue

Close #1

생각해볼 내용

  • 막상 순차적으로 나타나는 인풋을 사용해보니 어색한 점이 있음. 차라리 필수 입력 항목을 글씨색이나 *표시 등으로 알려주고 제출버튼 활성화 여부만 달라지게 하는 것은 어떨지?

이후 작업할 내용

  • Styled Component 적용

@chaerin-dev chaerin-dev self-assigned this Jun 30, 2022
Comment on lines +13 to +18
onClick={() => {
setSubmitted(false);
setErrorCategory(-1);
setQuestionName("");
setDetailInput("");
}}
Copy link
Member

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);
Copy link
Member

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>
Copy link
Member

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 : (
Copy link
Member

Choose a reason for hiding this comment

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

순차적 렌더링을 위해 분기가 많이 생길 수 밖에 없는데요! 이러한 부분도 handleClick을 분리 했던 것 처럼 로직을 return 외부로 분리 시키면 좋을 것 같아요. 예를 들면 isQuestionNameVisible 이런식으로 선언해둘 수 도 있겠네요! 이러한 비슷한 값들을 담은 하나의 객체나 상태를 선언해도 좋을 것 같구요

@codeisneverodd codeisneverodd merged commit 4d9d4fd into develop Jun 30, 2022
@codeisneverodd codeisneverodd deleted the #1-feat-stepByStepInput-chaerindev branch June 30, 2022 17:49
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