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] 옵션, 주소 검색 등의 UI 를 변경하고 옵션 버튼의 렌더링을 최적화한다. #616

Merged
merged 11 commits into from
Sep 21, 2024

Conversation

ooherin
Copy link
Contributor

@ooherin ooherin commented Sep 19, 2024

❗ Issue

✨ 구현한 기능

(1) 주소 버튼 부분을 바꿨습니다. 아이콘을 추가하여 명확성을 높였습니다.

스크린샷 2024-09-19 오후 5 27 35

(2) 옵션의 어색한 미디어 쿼리를 수정하였습니다.

(3) 편집 페이지에 옵션이 데이터에 set 되도록 수정하였습니다.

  • ⭐️ 추가
    (4) 옵션이 클릭된 옵션 외에는 리렌더링이 안되도록 최적화 작업을 진행하였습니다.
    useSelectedOptionsStore 에 isSelectedOption 을 사용해서 해당 옵션버튼의 props 로 isSelectedOption 을 전달해주었으며, 해당 값이 바뀔 때에만 memo 를 사용해서 리렌더링 되게 해주었습니다!
before after
2024-09-21.12.23.33.mov
2024-09-21.12.22.22.mov

📢 논의하고 싶은 내용

🎸 기타

Copy link

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.

확인했습니다~!

`,
Text: styled.span<{ size: ButtonSize }>`
${flexCenter}
min-width: ${({ size }) => size === 'full' && 80}px;
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 혼자 픽셀이네요,,,~ rem 처리해주세용

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.

확인했습니다. 머지이슈로 변경된 EditPage만 확인해주세요~

const selectedOptions = useOptionStore(state => state.selectedOptions);
const selectedOptions = useSelectedOptionStore(state => state.selectedOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

이건그냥 궁금증인데 useOptionStore랑 useSelectedOptionStore 차이가뭘까요?

Copy link
Contributor Author

@ooherin ooherin Sep 20, 2024

Choose a reason for hiding this comment

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

해당 명명은 파일명만 바뀌고 함수명이 바뀌지 않아서 수정한 것입니다~! + 파일명도 수정하였습니다 감사합니다👍

import OptionButton from '@/components/NewChecklist/Option/OptionButton/OptionButton';
import MemoziedOptionButton from '@/components/NewChecklist/Option/OptionButton/OptionButton';
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
Contributor Author

Choose a reason for hiding this comment

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

로직이 불완전하게 적혀 있었네요! 찾아주셔서 감사합니다...ㅎㅎ해당 메모제이션은 중요해서 본문에 추가해놓았습니다!

Comment on lines 64 to 74
const resetAndGoHome = () => {
roomInfoActions.resetAll();
resetChecklist();
selectedOptionActions.reset();
navigate(ROUTE_PATH.checklistList);
};

return (
<>
<Header
left={<Header.Backward />}
left={<Header.Backward onClick={resetAndGoHome} />}
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

@ooherin ooherin changed the title [FE] 옵션, 주소 검색 등의 UI 를 변경한다. [FE] 옵션, 주소 검색 등의 UI 를 변경하고 옵션 버튼의 렌더링을 최적화한다. Sep 20, 2024
Copy link

Copy link

@ooherin
Copy link
Contributor Author

ooherin commented Sep 20, 2024

옵션 버튼 메모제이션에 관한 내용을 본문의 마지막에 추가했습니다~!!

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.

기존 사항은 반영이 된 것 같아요

메모이제이션을 추가로 작업해주셨던데
파일이름 안바뀐거랑 arePropsEqual 관련해서 코멘트 달아두었습니다.

Comment on lines 43 to 53
const arePropsEqual = (prevProps: { isSelected: boolean }, nextProps: { isSelected: boolean }) => {
return prevProps.isSelected === nextProps.isSelected;
};

/*사용자가 누른 옵션 버튼만 리렌더링*/
const MemoizedOptionButton = React.memo((props: { option: OptionWithIcon; isSelected: boolean }) => {
const isSelected = useSelectedOptionStore(state => state.actions.isSelectedOption(props.option.id));
return <OptionButton option={props.option} isSelected={isSelected} />;
}, arePropsEqual);

export default MemoizedOptionButton;
Copy link
Contributor

@skiende74 skiende74 Sep 21, 2024

Choose a reason for hiding this comment

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

옵션버튼의 파일명이 여전히 OptionButton이라 같이바꿔주셔야 좋을 것 같아요~!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

사실 이건 애매한 부분인 것 같긴한데 원래 컴포넌트 명은 OptionButton 이 맞는 것 같습니다.
메모제이션은 기존 컴포넌트의 부가사항일 뿐이고, 이 메모 기능을 추가했다고 해서 파일명이 바뀌는 것은 혼란을 줄 수 있을 것 같은데요
제이드는 어떻게 생각하세요?

Copy link
Contributor

@skiende74 skiende74 Sep 21, 2024

Choose a reason for hiding this comment

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

음 아래에 관련코멘트 작성하였습니다 :)

Comment on lines 43 to 45
const arePropsEqual = (prevProps: { isSelected: boolean }, nextProps: { isSelected: boolean }) => {
return prevProps.isSelected === nextProps.isSelected;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

arePropsEqual을 굳이따로 안넣어줘도 메모이제이션가능한 상황같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아핫 그렇네요! 감사합니다 해당 코드는 삭제하도록 할게요!

@@ -1,11 +1,15 @@
import styled from '@emotion/styled';

import OptionButton from '@/components/NewChecklist/Option/OptionButton/OptionButton';
import MemoziedOptionButton from '@/components/NewChecklist/Option/OptionButton/OptionButton';
Copy link
Contributor

Choose a reason for hiding this comment

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

Memoized인데 Memozied로 오타가 난거같습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

Memoized인데 Memozied로 오타가 난거같습니다.

아직 반영이 안된 것 같아요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정했습니다! 감사합니다:)

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.

확인했습니다~! 제이드가 대부분 코멘트 해놔서 따로 없는거 같습니다~ 수고하셨습니당

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.

수고많으셨습니다.

반영 안 된 코멘트 하나랑 수정 관련 코멘트 하나 있습니다.
PR시간이 길어져서 우선 머지합니다~!
추후 PR에서 반영해주시면 좋을 것 같아요~

Comment on lines +44 to +49
const MemoizedOptionButton = React.memo((props: { option: OptionWithIcon; isSelected: boolean }) => {
const isSelected = useSelectedOptionStore(state => state.actions.isSelectedOption(props.option.id));
return <OptionButton option={props.option} isSelected={isSelected} />;
});

export default MemoizedOptionButton;
Copy link
Contributor

@skiende74 skiende74 Sep 21, 2024

Choose a reason for hiding this comment

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

prop으로 isSelected를 받고있는데 정작 isSelected를 사용하지는 않고,
내부에서 새로 지역변수를 만들어서 사용하고있네요.
이 45번줄은 지워져야할 것 같아요.

그리고 지금의 사용례라면 그냥 이 6줄 전체를 아래와 같이 대체할 수 있을 것 같아요

Suggested change
const MemoizedOptionButton = React.memo((props: { option: OptionWithIcon; isSelected: boolean }) => {
const isSelected = useSelectedOptionStore(state => state.actions.isSelectedOption(props.option.id));
return <OptionButton option={props.option} isSelected={isSelected} />;
});
export default MemoizedOptionButton;
export default React.memo(OptionButton);

@@ -1,11 +1,15 @@
import styled from '@emotion/styled';

import OptionButton from '@/components/NewChecklist/Option/OptionButton/OptionButton';
import MemoziedOptionButton from '@/components/NewChecklist/Option/OptionButton/OptionButton';
Copy link
Contributor

Choose a reason for hiding this comment

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

Memoized인데 Memozied로 오타가 난거같습니다.

아직 반영이 안된 것 같아요

@skiende74 skiende74 merged commit 483a6b1 into dev-fe Sep 21, 2024
2 checks passed
@skiende74 skiende74 deleted the fix/588-option branch September 21, 2024 10:48
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