rofrischmann/react-look

View on GitHub
packages/react-look-core/modules/utils/getChildType.js

Summary

Maintainability
A
0 mins
Test Coverage
import _ from 'lodash'

/**
 * Returns a childs type
 * If child is an ES6 class it returns the displayName
 * @param {Object} child - child which type gets identified
 */
export default function getChildType(child) {
  if (_.isFunction(child.type)) {
    return child.type.hasOwnProperty('name') ? child.type.name : child.type
  }
  return child.type
}