wallet-core/node_modules/react/lib/React.js

131 lines
5.0 KiB
JavaScript
Raw Normal View History

2017-05-03 15:35:00 +02:00
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
'use strict';
var _assign = require('object-assign');
2017-08-14 05:01:11 +02:00
var ReactBaseClasses = require('./ReactBaseClasses');
2017-05-03 15:35:00 +02:00
var ReactChildren = require('./ReactChildren');
var ReactDOMFactories = require('./ReactDOMFactories');
var ReactElement = require('./ReactElement');
var ReactPropTypes = require('./ReactPropTypes');
var ReactVersion = require('./ReactVersion');
2017-08-14 05:01:11 +02:00
var createReactClass = require('./createClass');
2017-05-03 15:35:00 +02:00
var onlyChild = require('./onlyChild');
var createElement = ReactElement.createElement;
var createFactory = ReactElement.createFactory;
var cloneElement = ReactElement.cloneElement;
if (process.env.NODE_ENV !== 'production') {
2017-08-14 05:01:11 +02:00
var lowPriorityWarning = require('./lowPriorityWarning');
2017-05-03 15:35:00 +02:00
var canDefineProperty = require('./canDefineProperty');
var ReactElementValidator = require('./ReactElementValidator');
var didWarnPropTypesDeprecated = false;
createElement = ReactElementValidator.createElement;
createFactory = ReactElementValidator.createFactory;
cloneElement = ReactElementValidator.cloneElement;
}
var __spread = _assign;
2017-08-14 05:01:11 +02:00
var createMixin = function (mixin) {
return mixin;
};
2017-05-03 15:35:00 +02:00
if (process.env.NODE_ENV !== 'production') {
2017-08-14 05:01:11 +02:00
var warnedForSpread = false;
var warnedForCreateMixin = false;
2017-05-03 15:35:00 +02:00
__spread = function () {
2017-08-14 05:01:11 +02:00
lowPriorityWarning(warnedForSpread, 'React.__spread is deprecated and should not be used. Use ' + 'Object.assign directly or another helper function with similar ' + 'semantics. You may be seeing this warning due to your compiler. ' + 'See https://fb.me/react-spread-deprecation for more details.');
warnedForSpread = true;
2017-05-03 15:35:00 +02:00
return _assign.apply(null, arguments);
};
2017-08-14 05:01:11 +02:00
createMixin = function (mixin) {
lowPriorityWarning(warnedForCreateMixin, 'React.createMixin is deprecated and should not be used. ' + 'In React v16.0, it will be removed. ' + 'You can use this mixin directly instead. ' + 'See https://fb.me/createmixin-was-never-implemented for more info.');
warnedForCreateMixin = true;
return mixin;
};
2017-05-03 15:35:00 +02:00
}
var React = {
// Modern
Children: {
map: ReactChildren.map,
forEach: ReactChildren.forEach,
count: ReactChildren.count,
toArray: ReactChildren.toArray,
only: onlyChild
},
2017-08-14 05:01:11 +02:00
Component: ReactBaseClasses.Component,
PureComponent: ReactBaseClasses.PureComponent,
2017-05-03 15:35:00 +02:00
createElement: createElement,
cloneElement: cloneElement,
isValidElement: ReactElement.isValidElement,
// Classic
PropTypes: ReactPropTypes,
2017-08-14 05:01:11 +02:00
createClass: createReactClass,
2017-05-03 15:35:00 +02:00
createFactory: createFactory,
2017-08-14 05:01:11 +02:00
createMixin: createMixin,
2017-05-03 15:35:00 +02:00
// This looks DOM specific but these are actually isomorphic helpers
// since they are just generating DOM strings.
DOM: ReactDOMFactories,
version: ReactVersion,
// Deprecated hook for JSX spread, don't use this for anything.
__spread: __spread
};
if (process.env.NODE_ENV !== 'production') {
2017-08-14 05:01:11 +02:00
var warnedForCreateClass = false;
2017-05-03 15:35:00 +02:00
if (canDefineProperty) {
Object.defineProperty(React, 'PropTypes', {
get: function () {
2017-08-14 05:01:11 +02:00
lowPriorityWarning(didWarnPropTypesDeprecated, 'Accessing PropTypes via the main React package is deprecated,' + ' and will be removed in React v16.0.' + ' Use the latest available v15.* prop-types package from npm instead.' + ' For info on usage, compatibility, migration and more, see ' + 'https://fb.me/prop-types-docs');
2017-05-03 15:35:00 +02:00
didWarnPropTypesDeprecated = true;
return ReactPropTypes;
}
});
2017-08-14 05:01:11 +02:00
Object.defineProperty(React, 'createClass', {
get: function () {
lowPriorityWarning(warnedForCreateClass, 'Accessing createClass via the main React package is deprecated,' + ' and will be removed in React v16.0.' + " Use a plain JavaScript class instead. If you're not yet " + 'ready to migrate, create-react-class v15.* is available ' + 'on npm as a temporary, drop-in replacement. ' + 'For more info see https://fb.me/react-create-class');
warnedForCreateClass = true;
return createReactClass;
}
});
2017-05-03 15:35:00 +02:00
}
2017-08-14 05:01:11 +02:00
// React.DOM factories are deprecated. Wrap these methods so that
// invocations of the React.DOM namespace and alert users to switch
// to the `react-dom-factories` package.
React.DOM = {};
var warnedForFactories = false;
Object.keys(ReactDOMFactories).forEach(function (factory) {
React.DOM[factory] = function () {
if (!warnedForFactories) {
lowPriorityWarning(false, 'Accessing factories like React.DOM.%s has been deprecated ' + 'and will be removed in v16.0+. Use the ' + 'react-dom-factories package instead. ' + ' Version 1.0 provides a drop-in replacement.' + ' For more info, see https://fb.me/react-dom-factories', factory);
warnedForFactories = true;
}
return ReactDOMFactories[factory].apply(ReactDOMFactories, arguments);
};
});
2017-05-03 15:35:00 +02:00
}
module.exports = React;