-
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: Dialog周辺コンポーネントのロジックを整理する #5318
base: master
Are you sure you want to change the base?
Conversation
26197a7
to
a650f37
Compare
commit: |
a650f37
to
2e54a1d
Compare
onPressEscape = () => { | ||
/* noop */ | ||
}, | ||
onPressEscape, |
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.
onPressEscapeが存在しない場合、そもそも実行する必要すらない箇所だったので、初期化を削除しました
@@ -81,44 +71,39 @@ export const DialogContentInner: FC<DialogContentInnerProps & ElementProps> = ({ | |||
className, | |||
...rest | |||
}) => { | |||
const { layoutStyleProps, innerStyle, backgroundStyle } = useMemo(() => { | |||
const { layoutStyle, innerStyle, backgroundStyle } = useMemo(() => { |
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.
style属性とclass属性を同時にmemo化するメリットがない箇所だったので分割しました
} | ||
onPressEscape() | ||
}, [isOpen, onPressEscape]), | ||
useMemo(() => (onPressEscape && isOpen ? onPressEscape : undefined), [isOpen, onPressEscape]), |
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.
なるべくキャッシュが有効になるよう、onPressEscapeが存在し、かつ実行するひつようがあるときだけ参照渡しするようにしました
@@ -25,8 +25,9 @@ const dialogHeader = tv({ | |||
], | |||
}) | |||
|
|||
export const DialogHeader: React.FC<Props> = ({ title, subtitle, titleTag, titleId }) => { | |||
const style = dialogHeader() | |||
export const DialogHeader = React.memo<Props>(({ title, subtitle, titleTag, titleId }) => { |
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.
DialogのHeaderはほぼ再レンダリングが不要な場合が多いと予想されるため、丸ごとmemo化しました
const onClickTrigger = useCallback(() => setActive(true), []) | ||
const onClickClose = useCallback(() => setActive(false), []) |
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.
再生成が完全に不要な箇所だったため、memo化しています
useEffect(() => { | ||
if (!handleKeyPress) { |
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.
実行する必要が一切ない場合でもevent listnerが実行されるパターンが存在したため、早期終了を追加しました
関連URL
概要
変更内容
確認方法