Skip to content

Commit

Permalink
chore: types/reactの型定義更新に伴うエラーを修正 (#4908)
Browse files Browse the repository at this point in the history
  • Loading branch information
masa0527 authored Sep 11, 2024
1 parent 1b0b967 commit 77b7d79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/smarthr-ui/src/components/TextLink/TextLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import React, {
ComponentPropsWithoutRef,
ElementType,
FC,
PropsWithoutRef,
ReactNode,
Ref,
forwardRef,
useMemo,
} from 'react'
Expand Down Expand Up @@ -60,8 +62,8 @@ export const TextLink: TextLinkComponent = forwardRef(
suffix,
className,
...others
}: Props<T> & ElementProps<T>,
ref: ElementRef<T>,
}: PropsWithoutRef<Props<T>> & ElementProps<T>,
ref: Ref<ElementRef<T>>,
) => {
const Component = elementAs || 'a'
const actualSuffix = useMemo(() => {
Expand Down
10 changes: 8 additions & 2 deletions packages/smarthr-ui/src/libs/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { type ReactNode, type Ref, type RefAttributes, forwardRef } from 'react'
import React, {
type PropsWithoutRef,
type ReactNode,
type Ref,
type RefAttributes,
forwardRef,
} from 'react'

export const includeDisabledTrigger = (trigger: React.ReactNode) =>
React.Children.map(trigger, (t) => React.isValidElement(t) && t.props.disabled)?.some(
Expand All @@ -8,5 +14,5 @@ export const includeDisabledTrigger = (trigger: React.ReactNode) =>
/** forwardRef でジェネリクスを使うためのラッパー
* via https://www.totaltypescript.com/forwardref-with-generic-components */
export const genericsForwardRef = <T, P = object>(
render: (props: P, ref: Ref<T>) => ReactNode,
render: (props: PropsWithoutRef<P>, ref: Ref<T>) => ReactNode,
): ((props: P & RefAttributes<T>) => ReactNode) => forwardRef(render) as any

0 comments on commit 77b7d79

Please sign in to comment.