UNPKG

react-admit-one

Version:

An admit-one ticket for your React components

21 lines (20 loc) 589 B
import { isForwardRefType, isMemoType } from './react-types'; export default function getDisplayName(type) { if (typeof type === 'string') { return type; } if (typeof type === 'function') { /* istanbul ignore next */ return type.displayName || type.name || 'Anonymous'; } /* istanbul ignore next */ if (isForwardRefType(type)) { return getDisplayName(type.render); } /* istanbul ignore next */ if (isMemoType(type)) { return getDisplayName(type.type); } /* istanbul ignore next */ return 'Unknown'; }