Skip to content

Commit

Permalink
chore: UpwardLinkのstyle生成をmemo化する
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM committed Jan 9, 2025
1 parent 631ad61 commit 46fa1d6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/smarthr-ui/src/components/UpwardLink/UpwardLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type ComponentProps } from 'react'
import React, { type ComponentProps, useMemo } from 'react'
import { VariantProps, tv } from 'tailwind-variants'

import { FaArrowLeftIcon } from '../Icon'
Expand All @@ -20,8 +20,12 @@ type Props = Omit<ComponentProps<typeof TextLink>, 'prefix' | 'suffix'> &
elementAs?: ComponentProps<typeof TextLink>['elementAs']
}

export const UpwardLink: React.FC<Props> = ({ indent = true, className, elementAs, ...rest }) => {
const style = upwardLink({ indent, className })
export const UpwardLink: React.FC<Props> = ({ indent, className, elementAs, ...rest }) => {
const style = useMemo(
() => upwardLink({ indent: indent === undefined ? true : indent, className }),
[indent, className],
)

return (
<div className={style}>
<TextLink {...rest} elementAs={elementAs} prefix={<FaArrowLeftIcon />} />
Expand Down

0 comments on commit 46fa1d6

Please sign in to comment.