diff --git a/components/_util/ref.ts b/components/_util/ref.ts deleted file mode 100644 index 875b504ffb..0000000000 --- a/components/_util/ref.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as React from 'react'; - -export function fillRef(ref: React.Ref, node: T) { - if (typeof ref === 'function') { - ref(node); - } else if (typeof ref === 'object' && ref && 'current' in ref) { - (ref as any).current = node; - } -} - -export function composeRef(...refs: React.Ref[]): React.Ref { - return (node: T) => { - refs.forEach(ref => { - fillRef(ref, node); - }); - }; -} diff --git a/components/avatar/avatar.tsx b/components/avatar/avatar.tsx index 009088d81e..74d108750a 100644 --- a/components/avatar/avatar.tsx +++ b/components/avatar/avatar.tsx @@ -1,10 +1,9 @@ import * as React from 'react'; import classNames from 'classnames'; import ResizeObserver from 'rc-resize-observer'; - +import { composeRef } from 'rc-util/lib/ref'; import { ConfigContext } from '../config-provider'; import devWarning from '../_util/devWarning'; -import { composeRef } from '../_util/ref'; import { Breakpoint, responsiveArray } from '../_util/responsiveObserve'; import useBreakpoint from '../grid/hooks/useBreakpoint'; import SizeContext, { AvatarSize } from './SizeContext'; diff --git a/components/mentions/index.tsx b/components/mentions/index.tsx index dbf5dcafad..c958040fc6 100644 --- a/components/mentions/index.tsx +++ b/components/mentions/index.tsx @@ -2,9 +2,9 @@ import * as React from 'react'; import classNames from 'classnames'; import RcMentions from 'rc-mentions'; import { MentionsProps as RcMentionsProps } from 'rc-mentions/lib/Mentions'; +import { composeRef } from 'rc-util/lib/ref'; import Spin from '../spin'; import { ConfigContext } from '../config-provider'; -import { composeRef } from '../_util/ref'; export const { Option } = RcMentions; diff --git a/components/radio/radio.tsx b/components/radio/radio.tsx index 0a55df4e99..72649cad75 100644 --- a/components/radio/radio.tsx +++ b/components/radio/radio.tsx @@ -1,10 +1,10 @@ import * as React from 'react'; import RcCheckbox from 'rc-checkbox'; import classNames from 'classnames'; +import { composeRef } from 'rc-util/lib/ref'; import { RadioProps, RadioChangeEvent } from './interface'; import { ConfigContext } from '../config-provider'; import RadioGroupContext from './context'; -import { composeRef } from '../_util/ref'; import devWarning from '../_util/devWarning'; const InternalRadio: React.ForwardRefRenderFunction = (props, ref) => { diff --git a/components/typography/Typography.tsx b/components/typography/Typography.tsx index 3df13d7026..0aa7ce5c9c 100644 --- a/components/typography/Typography.tsx +++ b/components/typography/Typography.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import classNames from 'classnames'; +import { composeRef } from 'rc-util/lib/ref'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import devWarning from '../_util/devWarning'; -import { composeRef } from '../_util/ref'; export interface TypographyProps { id?: string;