Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
1234567891011121314151617181920212223
  1. // Fork of recompose/getDisplayName with added IE 11 support
  2. // Simplified polyfill for IE 11 support
  3. // https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
  4. const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
  5. export function getFunctionName(fn) {
  6. const match = `${fn}`.match(fnNameMatchRegex);
  7. const name = match && match[1];
  8. return name || '';
  9. }
  10. function getDisplayName(Component) {
  11. if (typeof Component === 'string') {
  12. return Component;
  13. }
  14. if (!Component) {
  15. return undefined;
  16. }
  17. return Component.displayName || Component.name || getFunctionName(Component) || 'Component';
  18. }
  19. export default getDisplayName;