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: UpwardLinkのstyle生成をmemo化する #5244

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

AtsushiM
Copy link
Member

@AtsushiM AtsushiM commented Jan 9, 2025

関連URL

概要

  • 再レンダリングの度にtailwindのstyle生成が実行されるため、memo化するようにします

変更内容

確認方法

Copy link

pkg-pr-new bot commented Jan 9, 2025

Open in Stackblitz

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

commit: f89a1a0

@yagimushi yagimushi force-pushed the chore-memoized-upward-link branch from 951dea9 to 46fa1d6 Compare January 9, 2025 01:00
@yagimushi yagimushi force-pushed the chore-memoized-upward-link branch from 46fa1d6 to a3816cc Compare January 9, 2025 01:04
@AtsushiM AtsushiM marked this pull request as ready for review January 9, 2025 01:16
@AtsushiM AtsushiM requested a review from a team as a code owner January 9, 2025 01:16
@AtsushiM AtsushiM requested review from misako0927 and hiroki0525 and removed request for a team January 9, 2025 01:16
import { VariantProps, tv } from 'tailwind-variants'

import { FaArrowLeftIcon } from '../Icon'
import { TextLink } from '../TextLink'

const upwardLink = tv({
const styleGenerator = tv({
Copy link
Member Author

@AtsushiM AtsushiM Jan 10, 2025

Choose a reason for hiding this comment

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

[要モミ]
lintで tvで生成する変数の名称を統一する という意図が有るので /(S|s)tyleGenerator$/ にマッチする名称に変更しています。
この名称アタリ違和感ないでしょうか?

Copy link
Contributor

Choose a reason for hiding this comment

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

個人的に違和感ないです!良いと思いました

/** `TextLink`に渡す `elementAs` をオプションで指定 */
elementAs?: ComponentProps<typeof TextLink>['elementAs']
}

export const UpwardLink: React.FC<Props> = ({ indent = true, className, elementAs, ...rest }) => {
const style = upwardLink({ indent, className })
const style = useMemo(() => styleGenerator({ indent, className }), [indent, className])
Copy link
Member Author

Choose a reason for hiding this comment

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

smarthr-ui内で記法がブレているため、style関連の生成をuseMemoでラップするよう統一します

@uknmr uknmr marked this pull request as draft January 10, 2025 08:42
@AtsushiM AtsushiM marked this pull request as ready for review January 13, 2025 22:03
@AtsushiM AtsushiM requested review from oti and uknmr January 13, 2025 22:04
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.

styleGenerator() に違和感ないのでLGTM!

import { VariantProps, tv } from 'tailwind-variants'

import { FaArrowLeftIcon } from '../Icon'
import { TextLink } from '../TextLink'

const upwardLink = tv({
const styleGenerator = tv({
Copy link
Contributor

Choose a reason for hiding this comment

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

個人的に違和感ないです!良いと思いました

@AtsushiM AtsushiM merged commit 6184489 into master Jan 21, 2025
19 checks passed
@AtsushiM AtsushiM deleted the chore-memoized-upward-link branch January 21, 2025 00:18
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.

3 participants