@wix/design-system
Version:
@wix/design-system
36 lines (34 loc) • 1.29 kB
JavaScript
;
exports.__esModule = true;
exports.wrapDisplayName = exports.isStatelessComponent = exports.isRefableComponent = exports.getDisplayName = void 0;
// these are taken from Recompose:
// https://github.com/acdlite/recompose/tree/7918e23eebb74dc930e6ff2d32eb1ead4750f061
//
// TODO: consider using the Recompose package
var getDisplayName = Component => {
if (typeof Component === 'string') {
return Component;
}
if (!Component) {
return undefined;
}
return Component.displayName || Component.name || 'Component';
};
exports.getDisplayName = getDisplayName;
var wrapDisplayName = (BaseComponent, hocName) => "".concat(hocName, "(").concat(getDisplayName(BaseComponent), ")");
exports.wrapDisplayName = wrapDisplayName;
var isStatelessComponent = Component => !(Component.prototype && Component.prototype.render);
exports.isStatelessComponent = isStatelessComponent;
var isRefableComponent = Component => {
// Class component
if (Component.prototype && typeof Component.prototype.isReactComponent === 'object') {
return true;
}
// forwardRef component
if (Component && Component.$$typeof === Symbol.for('react.forward_ref')) {
return true;
}
return false;
};
exports.isRefableComponent = isRefableComponent;
//# sourceMappingURL=hocUtils.js.map