Skip to content
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

Merged
merged 8 commits into from
Sep 26, 2024

Conversation

ooherin
Copy link
Contributor

@ooherin ooherin commented Sep 26, 2024

❗ Issue

✨ 구현한 기능

  • 방 이름 인풋 작성 시 렌더링이 해당 인풋만 되게 최적화
  • 체크리스트 작성할때, 선택한 질문 외에 다른 질문들 렌더링 안되게 최적화
  • 선택한 탭 외에 렌더링 안되게 최적화
  • 전역 상태를 사용하는 updateAndToggleAnswer, useDefaultRoomName 를 사용처인 하위 컴포넌트로 내려주어 렌더링이 최대한 작은 범위에서 일어나도록 해주었습니다.
    참고 : zustand 의 상태를 쓰는 컴포넌트들은 memo 를 무시합니다. 이를 최대한 아래에서 사용해주어 최적화를 진행했습니다.
  • 체크리스트 질문 & 답변 컴포넌트가 모두 렌더링 되어, 답변 파트를 ChecklistQuestionAnswers 라는 컴포넌트로 나누어주었습니다. ChecklistQuestionAnswers 안에서만 store 를 구독하여, 렌더링이 최적화됩니다.
before after
2024-09-26.9.24.44.mov
2024-09-26.8.37.05.mov

📢 논의하고 싶은 내용

🎸 기타

Copy link

Copy link
Contributor

@skiende74 skiende74 left a comment

Choose a reason for hiding this comment

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

수고하셨어요~!

Comment on lines 41 to 45
const MemoAnswerIcon = React.memo(AnswerIcon);
const AnswerIconMemo = React.memo(AnswerIcon, (prevProps, nextProps) => {
return prevProps.isSelected === nextProps.isSelected;
});

export default MemoAnswerIcon;
export default AnswerIconMemo;
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 이전 코드로는 메모이제이션이 안되던가요?

Comment on lines 44 to 33
const ChecklistQuestionItemMemo = React.memo(ChecklistQuestionItem);
const ChecklistQuestionItemMemo = React.memo(ChecklistQuestionItem, (prevProps, nextProps) => {
return prevProps.answer === nextProps.answer && prevProps.question.questionId === nextProps.question.questionId;
});

Copy link
Contributor

Choose a reason for hiding this comment

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

얘도 기존코드로 대응안되던가요?

Copy link

Copy link

Copy link

@ooherin ooherin requested a review from healim01 September 26, 2024 12:20
Copy link
Contributor

@healim01 healim01 left a comment

Choose a reason for hiding this comment

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

확인했습니당~

@skiende74 skiende74 merged commit 5d98be0 into dev-fe Sep 26, 2024
2 checks passed
@skiende74 skiende74 deleted the feat/672-rendering branch September 26, 2024 12:22
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants