-
Notifications
You must be signed in to change notification settings - Fork 6
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
[FE] 체크리스트 렌더링 성능을 최적화한다. #689
Conversation
68da5ca
to
5cc6873
Compare
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 MemoAnswerIcon = React.memo(AnswerIcon); | ||
const AnswerIconMemo = React.memo(AnswerIcon, (prevProps, nextProps) => { | ||
return prevProps.isSelected === nextProps.isSelected; | ||
}); | ||
|
||
export default MemoAnswerIcon; | ||
export default AnswerIconMemo; |
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 ChecklistQuestionItemMemo = React.memo(ChecklistQuestionItem); | ||
const ChecklistQuestionItemMemo = React.memo(ChecklistQuestionItem, (prevProps, nextProps) => { | ||
return prevProps.answer === nextProps.answer && prevProps.question.questionId === nextProps.question.questionId; | ||
}); | ||
|
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.
확인했습니당~
❗ Issue
✨ 구현한 기능
updateAndToggleAnswer
,useDefaultRoomName
를 사용처인 하위 컴포넌트로 내려주어 렌더링이 최대한 작은 범위에서 일어나도록 해주었습니다.참고 : zustand 의 상태를 쓰는 컴포넌트들은 memo 를 무시합니다. 이를 최대한 아래에서 사용해주어 최적화를 진행했습니다.
ChecklistQuestionAnswers
라는 컴포넌트로 나누어주었습니다.ChecklistQuestionAnswers
안에서만 store 를 구독하여, 렌더링이 최적화됩니다.2024-09-26.9.24.44.mov
2024-09-26.8.37.05.mov
📢 논의하고 싶은 내용
🎸 기타