-
Notifications
You must be signed in to change notification settings - Fork 1
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] today 페이지의 날짜 이동 기능 #170
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.
고생많으셨습니다!! 빌드에러만 잡아주세용
onClickPrevDate: (day: number) => void; | ||
onClickNextDate: (day: number) => void; |
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.
얘네 하나의 함수로 합칠 수 있을 것 같습니다!
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.
아쉽게도 버튼 형식을 맞추기 위해 오히려 함수가 늘어났다는 사실 ...
<ArrangeBtn color="BLACK" mode="DEFAULT" size="small" type="left" onClick={onClickPrevDate} /> | ||
<ArrangeBtn color="BLACK" mode="DEFAULT" size="small" type="right" onClick={onClickNextDate} /> |
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.
여기에서 -1, 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.
확인했습니다!! 👍 👍 최고최고
작업 내용 🧑💻
알게된 점 🚀
-
<Button onClick={onClickChangeDate(-1)}>
처음에 이런식으로 함수를 전달하고자하니 무한히 재렌더링되므로 "Too many re-renders" 오류가 발생하였습니다. 위의 코드는 onClickChangeDate 함수가 즉시 실행되며, 반환된 값이 onClick 이벤트 핸들러로 설정되어 무한 루프가 발생하는 것이었습니다.<Button onClick={() => onClickChangeDate(-1)}>
따라서 함수를 화살표 함수로 감싸 전달하여 실제로 버튼이 클릭될 때만 함수가 실행되도록 하였습니다.
리뷰 요구사항 💬
관련 이슈
close #168
스크린샷 (선택)
Screen.Recording.2024-07-17.at.7.32.09.PM.mov