import React from 'react'; const FUNCTION_REGEX = /react(\d+)?./i; const classComponent = (item: any) => typeof item === 'function' && item.prototype && item.prototype.isReactComponent; const functionComponent = (item: any) => ( typeof item === 'function' && String(item).includes('return') && String(item).match(FUNCTION_REGEX) && String(item).includes('.createElement') ); const component = (item: any) => classComponent(item) || functionComponent(item); const element = (item: any) => React.isValidElement(item); const compatible = (item: any) => element(item) || component(item); export default compatible;