packages/material-ui-utils/src/getDisplayName.ts/getDisplayName
export default function getDisplayName(Component: React.ElementType): string | undefined {
  if (Component == null) {
    return undefined;
  }

  if (typeof Component === 'string') {
    return Component;
  }

  if (typeof Component === 'function') {
    return getFunctionComponentName(Component, 'Component');
  }

  // TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense`
  if (typeof Component === 'object') {
    switch ((Component as any).$$typeof) {
      case ForwardRef:
        return getWrappedName(Component, (Component as any).render, 'ForwardRef');
      case Memo:
        return getWrappedName(Component, (Component as any).type, 'memo');
      default:
        return undefined;
    }
  }

  return undefined;
}