Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

conditional-component

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conditional-component - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

60

index.js
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _react = require('react');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _react2 = _interopRequireDefault(_react);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _react = require('react');
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
var _react2 = _interopRequireDefault(_react);
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Conditional = (function (_Component) {
var Conditional = function (_Component) {
_inherits(Conditional, _Component);

@@ -27,3 +27,3 @@

_get(Object.getPrototypeOf(Conditional.prototype), 'constructor', this).apply(this, arguments);
return _possibleConstructorReturn(this, (Conditional.__proto__ || Object.getPrototypeOf(Conditional)).apply(this, arguments));
}

@@ -36,7 +36,7 @@

if (typeof this.props['if'] === 'function') {
if (this.props['if']()) {
if (typeof this.props.if === 'function') {
if (this.props.if()) {
content = this.props.children;
}
} else if (this.props['if']) {
} else if (this.props.if) {
content = this.props.children;

@@ -47,24 +47,20 @@ }

}
}], [{
key: 'propTypes',
value: {
/**
* Warn if children is missing or not a single element
* @type {Element}
*/
children: _react.PropTypes.element.isRequired,
/**
* The condition in which to render the child component
* @type {Boolean|Function}
*/
'if': _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.func]).isRequired
},
enumerable: true
}]);
return Conditional;
})(_react.Component);
}(_react.Component);
exports['default'] = Conditional;
module.exports = exports['default'];
Conditional.propTypes = {
/**
* Warn if children is missing or not a single element
* @type {Element}
*/
children: _react.PropTypes.element.isRequired,
/**
* The condition in which to render the child component
* @type {Boolean|Function}
*/
if: _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.func]).isRequired
};
exports.default = Conditional;
{
"name": "conditional-component",
"version": "1.0.0",
"version": "2.0.0",
"description": "Conditionally render a React component",

@@ -26,17 +26,25 @@ "main": "index.js",

"peerDependencies": {
"react": "^0.14",
"react-dom": "^0.14"
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"devDependencies": {
"babel": "^5.8.35",
"babel-core": "^5.8.35",
"babel-eslint": "4.1.6",
"babel-loader": "^5.4.0",
"babel-runtime": "^5.8.35",
"react": "^0.14.7",
"react-dom": "^0.14.7"
"babel-cli": "^6.5.2",
"babel-core": "^6.21.0",
"babel-eslint": "7.1.1",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-runtime": "^6.20.0",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"webpack": "^1.14.0"
},
"babel": {
"stage": 1
"presets": [
"es2015",
"react",
"stage-1"
]
}
}

@@ -6,3 +6,3 @@ # `<Conditional>` Component

### Example
## Example

@@ -44,1 +44,5 @@ ```js

```
## Install
`npm install --save conditional-component`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc