diff --git a/src/ref.ts b/src/ref.ts index 8fa32ff6..7beb41c1 100644 --- a/src/ref.ts +++ b/src/ref.ts @@ -1,7 +1,7 @@ /* eslint-disable no-param-reassign */ import type * as React from 'react'; import { isValidElement, ReactNode } from 'react'; -import { isFragment, isMemo } from 'react-is'; +import { ForwardRef, isFragment, isMemo } from 'react-is'; import useMemo from './hooks/useMemo'; export function fillRef(ref: React.Ref, node: T) { @@ -43,14 +43,19 @@ export function supportRef(nodeOrComponent: any): boolean { : nodeOrComponent.type; // Function component node - if (typeof type === 'function' && !type.prototype?.render) { + if ( + typeof type === 'function' && + !type.prototype?.render && + type.$$typeof !== ForwardRef + ) { return false; } // Class component if ( typeof nodeOrComponent === 'function' && - !nodeOrComponent.prototype?.render + !nodeOrComponent.prototype?.render && + nodeOrComponent.$$typeof !== ForwardRef ) { return false; }