import { createElement, type ComponentType, type MemoExoticComponent, } from 'react'; import type { IconProps } from '@unif/react-native-icons'; import { isForwardRef, isMemo } from 'react-is'; export function isIconComponent( value: unknown ): value is ComponentType { const seen = new Set(); while (typeof value === 'object' && value !== null) { if (seen.has(value)) return false; seen.add(value); const element = createElement(value as ComponentType); if (isForwardRef(element)) return true; if (!isMemo(element)) return false; value = (value as MemoExoticComponent>).type; } return typeof value === 'function'; }