-
Notifications
You must be signed in to change notification settings - Fork 141
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
chore: MessageDialogの内部ロジックを整理する #5320
base: master
Are you sure you want to change the base?
Conversation
1a1921d
to
37587af
Compare
commit: |
if (!active) { | ||
return | ||
if (active) { | ||
onClickClose() | ||
} | ||
onClickClose() |
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.
早期returnに意味があるほど複雑なロジックではなく、逆に分かりづらいのでifの条件を整えています
|
||
return ( | ||
// eslint-disable-next-line smarthr/best-practice-for-layouts, smarthr/a11y-heading-in-sectioning-content | ||
<Stack gap={0} as="section" className={wrapper()}> |
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.
<Stack gap={0} as="section">
は実質 <Section>
と同義であり、余計な内部ロジックが実行されるだけだったので置き換えています
const FooterCluster = React.memo< | ||
Pick<MessageDialogContentInnerProps, 'onClickClose' | 'decorators'> & { className: string } | ||
>(({ onClickClose, decorators, className }) => { | ||
const children = useMemo( | ||
() => decorators?.closeButtonLabel?.(CLOSE_BUTTON_LABEL) || CLOSE_BUTTON_LABEL, | ||
[decorators], | ||
) | ||
|
||
return ( | ||
<Cluster as="footer" justify="flex-end" className={className}> | ||
<Button onClick={onClickClose} className="smarthr-ui-Dialog-closeButton"> | ||
{children} | ||
</Button> | ||
</Cluster> | ||
) | ||
}) |
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.
closeの関数などもmemo化されたもののため、FooterClusterはDialogの開閉で更新されるのみ、open状態ではほぼmemo化された状態が保てるはずです
関連URL
概要
変更内容
確認方法