All files get-display-name.js

100% Statements 13/13
92.86% Branches 13/14
100% Functions 1/1
100% Lines 13/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  7x   7x   1x 6x   4x 4x 3x 2x 1x 1x     2x   1x     7x    
export default function getDisplayName(type, props) {
  let displayName = 'Unknown Element';
 
  if (type.displayName) {
    // if the component has a React `displayName`, let's use it
    displayName = type.displayName;
  } else if (typeof type === 'string') {
    // if it's a string, we'll use it straight up, then append some identifying stuff
    displayName = type;
    if (props) {
      if (typeof props.id === 'string') {
        displayName = `${displayName}#${props.id}`;
      } else Eif (typeof props.className === 'string') {
        displayName = [displayName, ...props.className.split(' ')].join('.');
      }
    }
  } else if (typeof type === 'function' && type.name) {
    // if it's a function, let's use the name if it's not blank!
    displayName = type.name;
  }
 
  return displayName;
}