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

chore: StatusLabel, SpreadsheetTable, SmartHRLogoの内部処理を整理する #5378

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

AtsushiM
Copy link
Member

関連URL

概要

変更内容

確認方法

@yagimushi yagimushi force-pushed the fix-format-StatusLabel branch from 0b427d5 to 670635a Compare February 11, 2025 22:24
Copy link

pkg-pr-new bot commented Feb 11, 2025

Open in Stackblitz

npm i https://pkg.pr.new/kufu/smarthr-ui@5378

commit: 63652bc

@yagimushi yagimushi force-pushed the fix-format-StatusLabel branch from 670635a to 2be4274 Compare February 11, 2025 22:26
@yagimushi yagimushi force-pushed the fix-format-StatusLabel branch 3 times, most recently from 8e136fe to 4f21f6e Compare February 14, 2025 01:58
@yagimushi yagimushi force-pushed the fix-format-StatusLabel branch from 4f21f6e to 63652bc Compare February 14, 2025 02:00
return <FaCircleExclamationIcon />
}
}
export const StatusLabel = memo<Props>(
Copy link
Member Author

Choose a reason for hiding this comment

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

StatusLable自体が再レンダリングする必要性がほぼないコンポーネントのため、全体をmemo化しています


export const SpreadsheetTableCorner = () => (
export const SpreadsheetTableCorner = memo(() => (
Copy link
Member Author

Choose a reason for hiding this comment

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

SpreadsheetTableCorner 自体が引数が一切ない、装飾用コンポーネントのためmemoで提供します

@@ -63,3 +59,27 @@ export const SpreadsheetTable: React.FC<Props & ElementProps> = ({
</table>
)
}

const MemoizedThead = memo<{ cols: number }>(({ cols }) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

引数一つでTheadをまるごとmemo化でき、かつ再レンダリングが必要になる可能性も低いためmemo化状態で提供します

Comment on lines +48 to +51
<tr key={i}>
<th>{i + 1}</th>
{row.map((cell, j) => (
<td key={`bodyCell-${i}-${j}`}>{cell}</td>
<td key={`${i}-${j}`}>{cell}</td>
Copy link
Member Author

Choose a reason for hiding this comment

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

ループ中でダブらないkeyにできればいいため、余計なテキストとの結合をやめます

}),
[className, fill, height, width],
)
export const SmartHRLogo = memo<Props & ElementProps>(
Copy link
Member Author

Choose a reason for hiding this comment

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

Logoは一度レンダリングすれば、再レンダリングが必要になる可能性が低いため、丸ごとmemoしています

@AtsushiM AtsushiM marked this pull request as ready for review February 14, 2025 02:23
@AtsushiM AtsushiM requested a review from a team as a code owner February 14, 2025 02:23
@AtsushiM AtsushiM requested review from Qs-F and s-sasaki-0529 and removed request for a team February 14, 2025 02:23
Copy link
Contributor

@oti oti left a comment

Choose a reason for hiding this comment

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

LGTM!

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

Successfully merging this pull request may close these issues.

2 participants