Skip to content

Commit

Permalink
chore: InformationPanelのHeadingをmemo化する
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM committed Jan 16, 2025
1 parent 2e5e2b6 commit 628038c
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,9 @@ export const InformationPanel: FC<Props> = ({
return (
<Base {...props} overflow="hidden" as="section" className={currentStyles.wrapper}>
<Cluster align="center" justify="space-between" className={currentStyles.header}>
{/* eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content */}
<Heading type="blockTitle" tag={titleTag} id={titleId} className={currentStyles.heading}>
<ResponseMessage type={type} iconGap={0.5}>
{title}
</ResponseMessage>
</Heading>
<MemoizedHeading tag={titleTag} id={titleId} className={currentStyles.heading} type={type}>
{title}
</MemoizedHeading>
{togglable && (
<TogglableButton
active={active}
Expand All @@ -192,6 +189,21 @@ export const InformationPanel: FC<Props> = ({
)
}

const MemoizedHeading = React.memo<
Pick<Props, 'type'> & {
tag: Props['titleTag']
id: string
className: string
children: Props['title']
}
>(({ type, children, ...rect }) => (
<Heading {...rect} type="blockTitle">
<ResponseMessage type={type} iconGap={0.5}>
{children}
</ResponseMessage>
</Heading>
))

const TogglableButton: React.FC<
Pick<Props, 'active' | 'onClickTrigger'> & {
setActive: (flg: boolean) => void
Expand Down

0 comments on commit 628038c

Please sign in to comment.