Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/modules / ___dist / observable-utils / deps / decorateReactOnlyStatics.js
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.hoistReactOnlyStatics = hoistReactOnlyStatics;
exports.default = void 0;

var _exotic = require("../../exotic");

// const isNotNil = x => isNil(x) === false
const REACT_STATICS = Object.freeze(['childContextTypes', 'contextTypes', 'defaultProps', 'displayName', 'getDefaultProps', 'mixins', 'propTypes', 'type']);
/**
 * @todo - move REACT_STATICS const out
 *
 * @description currently hoists only if they do not exist
 * @see ./decorateComponentStatics
 * @see ./decorateHoistAllStatics
 *
 * @param {React.Component} targetComponent
 * @param {React.Component} sourceComponent
 * @return {void}
 */

function hoistReactOnlyStatics(targetComponent, sourceComponent) {
  // if (isString(sourceComponent) === false) return targetComponent
  for (let index = 0; index < REACT_STATICS.length; index++) {
    const STATIC_NAME = REACT_STATICS[index]; // target already has it
    // isNotNil

    if ((0, _exotic.hasOwnProp)(targetComponent, STATIC_NAME) === true) {
      continue;
    } // if we have it on source


    if ((0, _exotic.hasOwnProp)(sourceComponent, STATIC_NAME) === true) {
      targetComponent[STATIC_NAME] = sourceComponent[STATIC_NAME];
    }
  }
}

var _default = hoistReactOnlyStatics;
exports.default = _default;