41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
exports.__esModule = true;
|
|
exports.default = deprecated;
|
|
|
|
var _warning = require('warning');
|
|
|
|
var _warning2 = _interopRequireDefault(_warning);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
var warned = {};
|
|
|
|
function deprecated(validator, reason) {
|
|
return function validate(props, propName, componentName, location, propFullName) {
|
|
var componentNameSafe = componentName || '<<anonymous>>';
|
|
var propFullNameSafe = propFullName || propName;
|
|
|
|
if (props[propName] != null) {
|
|
var messageKey = componentName + '.' + propName;
|
|
|
|
(0, _warning2.default)(warned[messageKey], 'The ' + location + ' `' + propFullNameSafe + '` of ' + ('`' + componentNameSafe + '` is deprecated. ' + reason + '.'));
|
|
|
|
warned[messageKey] = true;
|
|
}
|
|
|
|
for (var _len = arguments.length, args = Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
|
|
args[_key - 5] = arguments[_key];
|
|
}
|
|
|
|
return validator.apply(undefined, [props, propName, componentName, location, propFullName].concat(args));
|
|
};
|
|
}
|
|
|
|
/* eslint-disable no-underscore-dangle */
|
|
function _resetWarned() {
|
|
warned = {};
|
|
}
|
|
|
|
deprecated._resetWarned = _resetWarned;
|
|
/* eslint-enable no-underscore-dangle */ |