mAAdhaTTah/brookjs

View on GitHub
packages/brookjs-silt/src/wrapDisplayName.ts

Summary

Maintainability
A
0 mins
Test Coverage
const getDisplayName = function (Component: React.ComponentType<any> | string) {
  if (typeof Component === 'string') {
    return Component;
  }

  return Component.displayName || Component.name || 'Component';
};

export const wrapDisplayName = (
  BaseComponent: React.ComponentType<any> | string,
  hocName: string,
) => hocName + '(' + getDisplayName(BaseComponent) + ')';