react-loading-switch
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -19,2 +19,2 @@ 'use strict'; | ||
exports.default = _LoadingSwitch2.default; | ||
const isPending = exports.isPending = _isPending3.default; | ||
var isPending = exports.isPending = _isPending3.default; |
'use strict'; | ||
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 _react = require('react'); | ||
@@ -11,2 +13,8 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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; } | ||
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; } | ||
/* | ||
@@ -40,31 +48,45 @@ LoadingSwitch | ||
class LoadingSwitch extends _react.Component { | ||
render() { | ||
const { | ||
children, | ||
error, | ||
errorWhenMissing, | ||
loading, | ||
renderError, | ||
renderLoading, | ||
require | ||
} = this.props; | ||
var LoadingSwitch = function (_Component) { | ||
_inherits(LoadingSwitch, _Component); | ||
if (error) { | ||
return renderError(error); | ||
} | ||
function LoadingSwitch() { | ||
_classCallCheck(this, LoadingSwitch); | ||
if ((0, _isPending2.default)(require)) { | ||
if (loading) { | ||
return renderLoading(); | ||
return _possibleConstructorReturn(this, (LoadingSwitch.__proto__ || Object.getPrototypeOf(LoadingSwitch)).apply(this, arguments)); | ||
} | ||
_createClass(LoadingSwitch, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _props = this.props, | ||
children = _props.children, | ||
error = _props.error, | ||
errorWhenMissing = _props.errorWhenMissing, | ||
loading = _props.loading, | ||
renderError = _props.renderError, | ||
renderLoading = _props.renderLoading, | ||
require = _props.require; | ||
if (error) { | ||
return renderError(error); | ||
} | ||
return renderError(errorWhenMissing && typeof errorWhenMissing === 'function' ? errorWhenMissing() : errorWhenMissing); | ||
if ((0, _isPending2.default)(require)) { | ||
if (loading) { | ||
return renderLoading(); | ||
} | ||
return renderError(errorWhenMissing && typeof errorWhenMissing === 'function' ? errorWhenMissing() : errorWhenMissing); | ||
} | ||
return children && typeof children === 'function' ? children() : children; | ||
} | ||
}]); | ||
return children && typeof children === 'function' ? children() : children; | ||
} | ||
} | ||
return LoadingSwitch; | ||
}(_react.Component); | ||
LoadingSwitch.displayName = 'LoadingSwitch'; | ||
module.exports = LoadingSwitch; |
"use strict"; | ||
module.exports = pendingValue => !pendingValue; | ||
module.exports = function (pendingValue) { | ||
return !pendingValue; | ||
}; | ||
// Isolated in case we want to modify this behavior in the future. |
{ | ||
"name": "react-loading-switch", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "React component API for easily composing the render logic surrounding react-apollo data fetching, loading, and error handling", | ||
@@ -8,3 +8,5 @@ "browser": "lib/index.js", | ||
"module": "src/index.js", | ||
"files": ["lib/"], | ||
"files": [ | ||
"lib/" | ||
], | ||
"scripts": { | ||
@@ -71,2 +73,3 @@ "lint": "./node_modules/.bin/eslint src/.", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-flow": "^6.23.0", | ||
@@ -90,4 +93,3 @@ "babel-preset-react": "^6.24.1", | ||
}, | ||
"dependencies": { | ||
} | ||
"dependencies": {} | ||
} |
14977
83
30