react.development.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. /** @license React v16.2.0
  2. * react.development.js
  3. *
  4. * Copyright (c) 2013-present, Facebook, Inc.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. 'use strict';
  10. if (process.env.NODE_ENV !== "production") {
  11. (function() {
  12. 'use strict';
  13. var _assign = require('object-assign');
  14. var emptyObject = require('fbjs/lib/emptyObject');
  15. var invariant = require('fbjs/lib/invariant');
  16. var warning = require('fbjs/lib/warning');
  17. var emptyFunction = require('fbjs/lib/emptyFunction');
  18. var checkPropTypes = require('prop-types/checkPropTypes');
  19. // TODO: this is special because it gets imported during build.
  20. var ReactVersion = '16.2.0';
  21. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  22. // nor polyfill, then a plain number is used for performance.
  23. var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
  24. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
  25. var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
  26. var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
  27. var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
  28. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
  29. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  30. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  31. function getIteratorFn(maybeIterable) {
  32. if (maybeIterable === null || typeof maybeIterable === 'undefined') {
  33. return null;
  34. }
  35. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  36. if (typeof maybeIterator === 'function') {
  37. return maybeIterator;
  38. }
  39. return null;
  40. }
  41. /**
  42. * WARNING: DO NOT manually require this module.
  43. * This is a replacement for `invariant(...)` used by the error code system
  44. * and will _only_ be required by the corresponding babel pass.
  45. * It always throws.
  46. */
  47. /**
  48. * Forked from fbjs/warning:
  49. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  50. *
  51. * Only change is we use console.warn instead of console.error,
  52. * and do nothing when 'console' is not supported.
  53. * This really simplifies the code.
  54. * ---
  55. * Similar to invariant but only logs a warning if the condition is not met.
  56. * This can be used to log issues in development environments in critical
  57. * paths. Removing the logging code for production environments will keep the
  58. * same logic and follow the same code paths.
  59. */
  60. var lowPriorityWarning = function () {};
  61. {
  62. var printWarning = function (format) {
  63. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  64. args[_key - 1] = arguments[_key];
  65. }
  66. var argIndex = 0;
  67. var message = 'Warning: ' + format.replace(/%s/g, function () {
  68. return args[argIndex++];
  69. });
  70. if (typeof console !== 'undefined') {
  71. console.warn(message);
  72. }
  73. try {
  74. // --- Welcome to debugging React ---
  75. // This error was thrown as a convenience so that you can use this stack
  76. // to find the callsite that caused this warning to fire.
  77. throw new Error(message);
  78. } catch (x) {}
  79. };
  80. lowPriorityWarning = function (condition, format) {
  81. if (format === undefined) {
  82. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  83. }
  84. if (!condition) {
  85. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  86. args[_key2 - 2] = arguments[_key2];
  87. }
  88. printWarning.apply(undefined, [format].concat(args));
  89. }
  90. };
  91. }
  92. var lowPriorityWarning$1 = lowPriorityWarning;
  93. var didWarnStateUpdateForUnmountedComponent = {};
  94. function warnNoop(publicInstance, callerName) {
  95. {
  96. var constructor = publicInstance.constructor;
  97. var componentName = constructor && (constructor.displayName || constructor.name) || 'ReactClass';
  98. var warningKey = componentName + '.' + callerName;
  99. if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
  100. return;
  101. }
  102. warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName);
  103. didWarnStateUpdateForUnmountedComponent[warningKey] = true;
  104. }
  105. }
  106. /**
  107. * This is the abstract API for an update queue.
  108. */
  109. var ReactNoopUpdateQueue = {
  110. /**
  111. * Checks whether or not this composite component is mounted.
  112. * @param {ReactClass} publicInstance The instance we want to test.
  113. * @return {boolean} True if mounted, false otherwise.
  114. * @protected
  115. * @final
  116. */
  117. isMounted: function (publicInstance) {
  118. return false;
  119. },
  120. /**
  121. * Forces an update. This should only be invoked when it is known with
  122. * certainty that we are **not** in a DOM transaction.
  123. *
  124. * You may want to call this when you know that some deeper aspect of the
  125. * component's state has changed but `setState` was not called.
  126. *
  127. * This will not invoke `shouldComponentUpdate`, but it will invoke
  128. * `componentWillUpdate` and `componentDidUpdate`.
  129. *
  130. * @param {ReactClass} publicInstance The instance that should rerender.
  131. * @param {?function} callback Called after component is updated.
  132. * @param {?string} callerName name of the calling function in the public API.
  133. * @internal
  134. */
  135. enqueueForceUpdate: function (publicInstance, callback, callerName) {
  136. warnNoop(publicInstance, 'forceUpdate');
  137. },
  138. /**
  139. * Replaces all of the state. Always use this or `setState` to mutate state.
  140. * You should treat `this.state` as immutable.
  141. *
  142. * There is no guarantee that `this.state` will be immediately updated, so
  143. * accessing `this.state` after calling this method may return the old value.
  144. *
  145. * @param {ReactClass} publicInstance The instance that should rerender.
  146. * @param {object} completeState Next state.
  147. * @param {?function} callback Called after component is updated.
  148. * @param {?string} callerName name of the calling function in the public API.
  149. * @internal
  150. */
  151. enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
  152. warnNoop(publicInstance, 'replaceState');
  153. },
  154. /**
  155. * Sets a subset of the state. This only exists because _pendingState is
  156. * internal. This provides a merging strategy that is not available to deep
  157. * properties which is confusing. TODO: Expose pendingState or don't use it
  158. * during the merge.
  159. *
  160. * @param {ReactClass} publicInstance The instance that should rerender.
  161. * @param {object} partialState Next partial state to be merged with state.
  162. * @param {?function} callback Called after component is updated.
  163. * @param {?string} Name of the calling function in the public API.
  164. * @internal
  165. */
  166. enqueueSetState: function (publicInstance, partialState, callback, callerName) {
  167. warnNoop(publicInstance, 'setState');
  168. }
  169. };
  170. /**
  171. * Base class helpers for the updating state of a component.
  172. */
  173. function Component(props, context, updater) {
  174. this.props = props;
  175. this.context = context;
  176. this.refs = emptyObject;
  177. // We initialize the default updater but the real one gets injected by the
  178. // renderer.
  179. this.updater = updater || ReactNoopUpdateQueue;
  180. }
  181. Component.prototype.isReactComponent = {};
  182. /**
  183. * Sets a subset of the state. Always use this to mutate
  184. * state. You should treat `this.state` as immutable.
  185. *
  186. * There is no guarantee that `this.state` will be immediately updated, so
  187. * accessing `this.state` after calling this method may return the old value.
  188. *
  189. * There is no guarantee that calls to `setState` will run synchronously,
  190. * as they may eventually be batched together. You can provide an optional
  191. * callback that will be executed when the call to setState is actually
  192. * completed.
  193. *
  194. * When a function is provided to setState, it will be called at some point in
  195. * the future (not synchronously). It will be called with the up to date
  196. * component arguments (state, props, context). These values can be different
  197. * from this.* because your function may be called after receiveProps but before
  198. * shouldComponentUpdate, and this new state, props, and context will not yet be
  199. * assigned to this.
  200. *
  201. * @param {object|function} partialState Next partial state or function to
  202. * produce next partial state to be merged with current state.
  203. * @param {?function} callback Called after state is updated.
  204. * @final
  205. * @protected
  206. */
  207. Component.prototype.setState = function (partialState, callback) {
  208. !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
  209. this.updater.enqueueSetState(this, partialState, callback, 'setState');
  210. };
  211. /**
  212. * Forces an update. This should only be invoked when it is known with
  213. * certainty that we are **not** in a DOM transaction.
  214. *
  215. * You may want to call this when you know that some deeper aspect of the
  216. * component's state has changed but `setState` was not called.
  217. *
  218. * This will not invoke `shouldComponentUpdate`, but it will invoke
  219. * `componentWillUpdate` and `componentDidUpdate`.
  220. *
  221. * @param {?function} callback Called after update is complete.
  222. * @final
  223. * @protected
  224. */
  225. Component.prototype.forceUpdate = function (callback) {
  226. this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
  227. };
  228. /**
  229. * Deprecated APIs. These APIs used to exist on classic React classes but since
  230. * we would like to deprecate them, we're not going to move them over to this
  231. * modern base class. Instead, we define a getter that warns if it's accessed.
  232. */
  233. {
  234. var deprecatedAPIs = {
  235. isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
  236. replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
  237. };
  238. var defineDeprecationWarning = function (methodName, info) {
  239. Object.defineProperty(Component.prototype, methodName, {
  240. get: function () {
  241. lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
  242. return undefined;
  243. }
  244. });
  245. };
  246. for (var fnName in deprecatedAPIs) {
  247. if (deprecatedAPIs.hasOwnProperty(fnName)) {
  248. defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
  249. }
  250. }
  251. }
  252. /**
  253. * Base class helpers for the updating state of a component.
  254. */
  255. function PureComponent(props, context, updater) {
  256. // Duplicated from Component.
  257. this.props = props;
  258. this.context = context;
  259. this.refs = emptyObject;
  260. // We initialize the default updater but the real one gets injected by the
  261. // renderer.
  262. this.updater = updater || ReactNoopUpdateQueue;
  263. }
  264. function ComponentDummy() {}
  265. ComponentDummy.prototype = Component.prototype;
  266. var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
  267. pureComponentPrototype.constructor = PureComponent;
  268. // Avoid an extra prototype jump for these methods.
  269. _assign(pureComponentPrototype, Component.prototype);
  270. pureComponentPrototype.isPureReactComponent = true;
  271. function AsyncComponent(props, context, updater) {
  272. // Duplicated from Component.
  273. this.props = props;
  274. this.context = context;
  275. this.refs = emptyObject;
  276. // We initialize the default updater but the real one gets injected by the
  277. // renderer.
  278. this.updater = updater || ReactNoopUpdateQueue;
  279. }
  280. var asyncComponentPrototype = AsyncComponent.prototype = new ComponentDummy();
  281. asyncComponentPrototype.constructor = AsyncComponent;
  282. // Avoid an extra prototype jump for these methods.
  283. _assign(asyncComponentPrototype, Component.prototype);
  284. asyncComponentPrototype.unstable_isAsyncReactComponent = true;
  285. asyncComponentPrototype.render = function () {
  286. return this.props.children;
  287. };
  288. /**
  289. * Keeps track of the current owner.
  290. *
  291. * The current owner is the component who should own any components that are
  292. * currently being constructed.
  293. */
  294. var ReactCurrentOwner = {
  295. /**
  296. * @internal
  297. * @type {ReactComponent}
  298. */
  299. current: null
  300. };
  301. var hasOwnProperty = Object.prototype.hasOwnProperty;
  302. var RESERVED_PROPS = {
  303. key: true,
  304. ref: true,
  305. __self: true,
  306. __source: true
  307. };
  308. var specialPropKeyWarningShown;
  309. var specialPropRefWarningShown;
  310. function hasValidRef(config) {
  311. {
  312. if (hasOwnProperty.call(config, 'ref')) {
  313. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  314. if (getter && getter.isReactWarning) {
  315. return false;
  316. }
  317. }
  318. }
  319. return config.ref !== undefined;
  320. }
  321. function hasValidKey(config) {
  322. {
  323. if (hasOwnProperty.call(config, 'key')) {
  324. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  325. if (getter && getter.isReactWarning) {
  326. return false;
  327. }
  328. }
  329. }
  330. return config.key !== undefined;
  331. }
  332. function defineKeyPropWarningGetter(props, displayName) {
  333. var warnAboutAccessingKey = function () {
  334. if (!specialPropKeyWarningShown) {
  335. specialPropKeyWarningShown = true;
  336. warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  337. }
  338. };
  339. warnAboutAccessingKey.isReactWarning = true;
  340. Object.defineProperty(props, 'key', {
  341. get: warnAboutAccessingKey,
  342. configurable: true
  343. });
  344. }
  345. function defineRefPropWarningGetter(props, displayName) {
  346. var warnAboutAccessingRef = function () {
  347. if (!specialPropRefWarningShown) {
  348. specialPropRefWarningShown = true;
  349. warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  350. }
  351. };
  352. warnAboutAccessingRef.isReactWarning = true;
  353. Object.defineProperty(props, 'ref', {
  354. get: warnAboutAccessingRef,
  355. configurable: true
  356. });
  357. }
  358. /**
  359. * Factory method to create a new React element. This no longer adheres to
  360. * the class pattern, so do not use new to call it. Also, no instanceof check
  361. * will work. Instead test $$typeof field against Symbol.for('react.element') to check
  362. * if something is a React Element.
  363. *
  364. * @param {*} type
  365. * @param {*} key
  366. * @param {string|object} ref
  367. * @param {*} self A *temporary* helper to detect places where `this` is
  368. * different from the `owner` when React.createElement is called, so that we
  369. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  370. * functions, and as long as `this` and owner are the same, there will be no
  371. * change in behavior.
  372. * @param {*} source An annotation object (added by a transpiler or otherwise)
  373. * indicating filename, line number, and/or other information.
  374. * @param {*} owner
  375. * @param {*} props
  376. * @internal
  377. */
  378. var ReactElement = function (type, key, ref, self, source, owner, props) {
  379. var element = {
  380. // This tag allow us to uniquely identify this as a React Element
  381. $$typeof: REACT_ELEMENT_TYPE,
  382. // Built-in properties that belong on the element
  383. type: type,
  384. key: key,
  385. ref: ref,
  386. props: props,
  387. // Record the component responsible for creating this element.
  388. _owner: owner
  389. };
  390. {
  391. // The validation flag is currently mutative. We put it on
  392. // an external backing store so that we can freeze the whole object.
  393. // This can be replaced with a WeakMap once they are implemented in
  394. // commonly used development environments.
  395. element._store = {};
  396. // To make comparing ReactElements easier for testing purposes, we make
  397. // the validation flag non-enumerable (where possible, which should
  398. // include every environment we run tests in), so the test framework
  399. // ignores it.
  400. Object.defineProperty(element._store, 'validated', {
  401. configurable: false,
  402. enumerable: false,
  403. writable: true,
  404. value: false
  405. });
  406. // self and source are DEV only properties.
  407. Object.defineProperty(element, '_self', {
  408. configurable: false,
  409. enumerable: false,
  410. writable: false,
  411. value: self
  412. });
  413. // Two elements created in two different places should be considered
  414. // equal for testing purposes and therefore we hide it from enumeration.
  415. Object.defineProperty(element, '_source', {
  416. configurable: false,
  417. enumerable: false,
  418. writable: false,
  419. value: source
  420. });
  421. if (Object.freeze) {
  422. Object.freeze(element.props);
  423. Object.freeze(element);
  424. }
  425. }
  426. return element;
  427. };
  428. /**
  429. * Create and return a new ReactElement of the given type.
  430. * See https://reactjs.org/docs/react-api.html#createelement
  431. */
  432. function createElement(type, config, children) {
  433. var propName;
  434. // Reserved names are extracted
  435. var props = {};
  436. var key = null;
  437. var ref = null;
  438. var self = null;
  439. var source = null;
  440. if (config != null) {
  441. if (hasValidRef(config)) {
  442. ref = config.ref;
  443. }
  444. if (hasValidKey(config)) {
  445. key = '' + config.key;
  446. }
  447. self = config.__self === undefined ? null : config.__self;
  448. source = config.__source === undefined ? null : config.__source;
  449. // Remaining properties are added to a new props object
  450. for (propName in config) {
  451. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  452. props[propName] = config[propName];
  453. }
  454. }
  455. }
  456. // Children can be more than one argument, and those are transferred onto
  457. // the newly allocated props object.
  458. var childrenLength = arguments.length - 2;
  459. if (childrenLength === 1) {
  460. props.children = children;
  461. } else if (childrenLength > 1) {
  462. var childArray = Array(childrenLength);
  463. for (var i = 0; i < childrenLength; i++) {
  464. childArray[i] = arguments[i + 2];
  465. }
  466. {
  467. if (Object.freeze) {
  468. Object.freeze(childArray);
  469. }
  470. }
  471. props.children = childArray;
  472. }
  473. // Resolve default props
  474. if (type && type.defaultProps) {
  475. var defaultProps = type.defaultProps;
  476. for (propName in defaultProps) {
  477. if (props[propName] === undefined) {
  478. props[propName] = defaultProps[propName];
  479. }
  480. }
  481. }
  482. {
  483. if (key || ref) {
  484. if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
  485. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  486. if (key) {
  487. defineKeyPropWarningGetter(props, displayName);
  488. }
  489. if (ref) {
  490. defineRefPropWarningGetter(props, displayName);
  491. }
  492. }
  493. }
  494. }
  495. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  496. }
  497. /**
  498. * Return a function that produces ReactElements of a given type.
  499. * See https://reactjs.org/docs/react-api.html#createfactory
  500. */
  501. function cloneAndReplaceKey(oldElement, newKey) {
  502. var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
  503. return newElement;
  504. }
  505. /**
  506. * Clone and return a new ReactElement using element as the starting point.
  507. * See https://reactjs.org/docs/react-api.html#cloneelement
  508. */
  509. function cloneElement(element, config, children) {
  510. var propName;
  511. // Original props are copied
  512. var props = _assign({}, element.props);
  513. // Reserved names are extracted
  514. var key = element.key;
  515. var ref = element.ref;
  516. // Self is preserved since the owner is preserved.
  517. var self = element._self;
  518. // Source is preserved since cloneElement is unlikely to be targeted by a
  519. // transpiler, and the original source is probably a better indicator of the
  520. // true owner.
  521. var source = element._source;
  522. // Owner will be preserved, unless ref is overridden
  523. var owner = element._owner;
  524. if (config != null) {
  525. if (hasValidRef(config)) {
  526. // Silently steal the ref from the parent.
  527. ref = config.ref;
  528. owner = ReactCurrentOwner.current;
  529. }
  530. if (hasValidKey(config)) {
  531. key = '' + config.key;
  532. }
  533. // Remaining properties override existing props
  534. var defaultProps;
  535. if (element.type && element.type.defaultProps) {
  536. defaultProps = element.type.defaultProps;
  537. }
  538. for (propName in config) {
  539. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  540. if (config[propName] === undefined && defaultProps !== undefined) {
  541. // Resolve default props
  542. props[propName] = defaultProps[propName];
  543. } else {
  544. props[propName] = config[propName];
  545. }
  546. }
  547. }
  548. }
  549. // Children can be more than one argument, and those are transferred onto
  550. // the newly allocated props object.
  551. var childrenLength = arguments.length - 2;
  552. if (childrenLength === 1) {
  553. props.children = children;
  554. } else if (childrenLength > 1) {
  555. var childArray = Array(childrenLength);
  556. for (var i = 0; i < childrenLength; i++) {
  557. childArray[i] = arguments[i + 2];
  558. }
  559. props.children = childArray;
  560. }
  561. return ReactElement(element.type, key, ref, self, source, owner, props);
  562. }
  563. /**
  564. * Verifies the object is a ReactElement.
  565. * See https://reactjs.org/docs/react-api.html#isvalidelement
  566. * @param {?object} object
  567. * @return {boolean} True if `object` is a valid component.
  568. * @final
  569. */
  570. function isValidElement(object) {
  571. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  572. }
  573. var ReactDebugCurrentFrame = {};
  574. {
  575. // Component that is being worked on
  576. ReactDebugCurrentFrame.getCurrentStack = null;
  577. ReactDebugCurrentFrame.getStackAddendum = function () {
  578. var impl = ReactDebugCurrentFrame.getCurrentStack;
  579. if (impl) {
  580. return impl();
  581. }
  582. return null;
  583. };
  584. }
  585. var SEPARATOR = '.';
  586. var SUBSEPARATOR = ':';
  587. /**
  588. * Escape and wrap key so it is safe to use as a reactid
  589. *
  590. * @param {string} key to be escaped.
  591. * @return {string} the escaped key.
  592. */
  593. function escape(key) {
  594. var escapeRegex = /[=:]/g;
  595. var escaperLookup = {
  596. '=': '=0',
  597. ':': '=2'
  598. };
  599. var escapedString = ('' + key).replace(escapeRegex, function (match) {
  600. return escaperLookup[match];
  601. });
  602. return '$' + escapedString;
  603. }
  604. /**
  605. * TODO: Test that a single child and an array with one item have the same key
  606. * pattern.
  607. */
  608. var didWarnAboutMaps = false;
  609. var userProvidedKeyEscapeRegex = /\/+/g;
  610. function escapeUserProvidedKey(text) {
  611. return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
  612. }
  613. var POOL_SIZE = 10;
  614. var traverseContextPool = [];
  615. function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
  616. if (traverseContextPool.length) {
  617. var traverseContext = traverseContextPool.pop();
  618. traverseContext.result = mapResult;
  619. traverseContext.keyPrefix = keyPrefix;
  620. traverseContext.func = mapFunction;
  621. traverseContext.context = mapContext;
  622. traverseContext.count = 0;
  623. return traverseContext;
  624. } else {
  625. return {
  626. result: mapResult,
  627. keyPrefix: keyPrefix,
  628. func: mapFunction,
  629. context: mapContext,
  630. count: 0
  631. };
  632. }
  633. }
  634. function releaseTraverseContext(traverseContext) {
  635. traverseContext.result = null;
  636. traverseContext.keyPrefix = null;
  637. traverseContext.func = null;
  638. traverseContext.context = null;
  639. traverseContext.count = 0;
  640. if (traverseContextPool.length < POOL_SIZE) {
  641. traverseContextPool.push(traverseContext);
  642. }
  643. }
  644. /**
  645. * @param {?*} children Children tree container.
  646. * @param {!string} nameSoFar Name of the key path so far.
  647. * @param {!function} callback Callback to invoke with each child found.
  648. * @param {?*} traverseContext Used to pass information throughout the traversal
  649. * process.
  650. * @return {!number} The number of children in this subtree.
  651. */
  652. function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
  653. var type = typeof children;
  654. if (type === 'undefined' || type === 'boolean') {
  655. // All of the above are perceived as null.
  656. children = null;
  657. }
  658. var invokeCallback = false;
  659. if (children === null) {
  660. invokeCallback = true;
  661. } else {
  662. switch (type) {
  663. case 'string':
  664. case 'number':
  665. invokeCallback = true;
  666. break;
  667. case 'object':
  668. switch (children.$$typeof) {
  669. case REACT_ELEMENT_TYPE:
  670. case REACT_CALL_TYPE:
  671. case REACT_RETURN_TYPE:
  672. case REACT_PORTAL_TYPE:
  673. invokeCallback = true;
  674. }
  675. }
  676. }
  677. if (invokeCallback) {
  678. callback(traverseContext, children,
  679. // If it's the only child, treat the name as if it was wrapped in an array
  680. // so that it's consistent if the number of children grows.
  681. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
  682. return 1;
  683. }
  684. var child;
  685. var nextName;
  686. var subtreeCount = 0; // Count of children found in the current subtree.
  687. var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
  688. if (Array.isArray(children)) {
  689. for (var i = 0; i < children.length; i++) {
  690. child = children[i];
  691. nextName = nextNamePrefix + getComponentKey(child, i);
  692. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  693. }
  694. } else {
  695. var iteratorFn = getIteratorFn(children);
  696. if (typeof iteratorFn === 'function') {
  697. {
  698. // Warn about using Maps as children
  699. if (iteratorFn === children.entries) {
  700. warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum());
  701. didWarnAboutMaps = true;
  702. }
  703. }
  704. var iterator = iteratorFn.call(children);
  705. var step;
  706. var ii = 0;
  707. while (!(step = iterator.next()).done) {
  708. child = step.value;
  709. nextName = nextNamePrefix + getComponentKey(child, ii++);
  710. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  711. }
  712. } else if (type === 'object') {
  713. var addendum = '';
  714. {
  715. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
  716. }
  717. var childrenString = '' + children;
  718. invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
  719. }
  720. }
  721. return subtreeCount;
  722. }
  723. /**
  724. * Traverses children that are typically specified as `props.children`, but
  725. * might also be specified through attributes:
  726. *
  727. * - `traverseAllChildren(this.props.children, ...)`
  728. * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
  729. *
  730. * The `traverseContext` is an optional argument that is passed through the
  731. * entire traversal. It can be used to store accumulations or anything else that
  732. * the callback might find relevant.
  733. *
  734. * @param {?*} children Children tree object.
  735. * @param {!function} callback To invoke upon traversing each child.
  736. * @param {?*} traverseContext Context for traversal.
  737. * @return {!number} The number of children in this subtree.
  738. */
  739. function traverseAllChildren(children, callback, traverseContext) {
  740. if (children == null) {
  741. return 0;
  742. }
  743. return traverseAllChildrenImpl(children, '', callback, traverseContext);
  744. }
  745. /**
  746. * Generate a key string that identifies a component within a set.
  747. *
  748. * @param {*} component A component that could contain a manual key.
  749. * @param {number} index Index that is used if a manual key is not provided.
  750. * @return {string}
  751. */
  752. function getComponentKey(component, index) {
  753. // Do some typechecking here since we call this blindly. We want to ensure
  754. // that we don't block potential future ES APIs.
  755. if (typeof component === 'object' && component !== null && component.key != null) {
  756. // Explicit key
  757. return escape(component.key);
  758. }
  759. // Implicit key determined by the index in the set
  760. return index.toString(36);
  761. }
  762. function forEachSingleChild(bookKeeping, child, name) {
  763. var func = bookKeeping.func,
  764. context = bookKeeping.context;
  765. func.call(context, child, bookKeeping.count++);
  766. }
  767. /**
  768. * Iterates through children that are typically specified as `props.children`.
  769. *
  770. * See https://reactjs.org/docs/react-api.html#react.children.foreach
  771. *
  772. * The provided forEachFunc(child, index) will be called for each
  773. * leaf child.
  774. *
  775. * @param {?*} children Children tree container.
  776. * @param {function(*, int)} forEachFunc
  777. * @param {*} forEachContext Context for forEachContext.
  778. */
  779. function forEachChildren(children, forEachFunc, forEachContext) {
  780. if (children == null) {
  781. return children;
  782. }
  783. var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
  784. traverseAllChildren(children, forEachSingleChild, traverseContext);
  785. releaseTraverseContext(traverseContext);
  786. }
  787. function mapSingleChildIntoContext(bookKeeping, child, childKey) {
  788. var result = bookKeeping.result,
  789. keyPrefix = bookKeeping.keyPrefix,
  790. func = bookKeeping.func,
  791. context = bookKeeping.context;
  792. var mappedChild = func.call(context, child, bookKeeping.count++);
  793. if (Array.isArray(mappedChild)) {
  794. mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
  795. } else if (mappedChild != null) {
  796. if (isValidElement(mappedChild)) {
  797. mappedChild = cloneAndReplaceKey(mappedChild,
  798. // Keep both the (mapped) and old keys if they differ, just as
  799. // traverseAllChildren used to do for objects as children
  800. keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
  801. }
  802. result.push(mappedChild);
  803. }
  804. }
  805. function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
  806. var escapedPrefix = '';
  807. if (prefix != null) {
  808. escapedPrefix = escapeUserProvidedKey(prefix) + '/';
  809. }
  810. var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
  811. traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
  812. releaseTraverseContext(traverseContext);
  813. }
  814. /**
  815. * Maps children that are typically specified as `props.children`.
  816. *
  817. * See https://reactjs.org/docs/react-api.html#react.children.map
  818. *
  819. * The provided mapFunction(child, key, index) will be called for each
  820. * leaf child.
  821. *
  822. * @param {?*} children Children tree container.
  823. * @param {function(*, int)} func The map function.
  824. * @param {*} context Context for mapFunction.
  825. * @return {object} Object containing the ordered map of results.
  826. */
  827. function mapChildren(children, func, context) {
  828. if (children == null) {
  829. return children;
  830. }
  831. var result = [];
  832. mapIntoWithKeyPrefixInternal(children, result, null, func, context);
  833. return result;
  834. }
  835. /**
  836. * Count the number of children that are typically specified as
  837. * `props.children`.
  838. *
  839. * See https://reactjs.org/docs/react-api.html#react.children.count
  840. *
  841. * @param {?*} children Children tree container.
  842. * @return {number} The number of children.
  843. */
  844. function countChildren(children, context) {
  845. return traverseAllChildren(children, emptyFunction.thatReturnsNull, null);
  846. }
  847. /**
  848. * Flatten a children object (typically specified as `props.children`) and
  849. * return an array with appropriately re-keyed children.
  850. *
  851. * See https://reactjs.org/docs/react-api.html#react.children.toarray
  852. */
  853. function toArray(children) {
  854. var result = [];
  855. mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
  856. return result;
  857. }
  858. /**
  859. * Returns the first child in a collection of children and verifies that there
  860. * is only one child in the collection.
  861. *
  862. * See https://reactjs.org/docs/react-api.html#react.children.only
  863. *
  864. * The current implementation of this function assumes that a single child gets
  865. * passed without a wrapper, but the purpose of this helper function is to
  866. * abstract away the particular structure of children.
  867. *
  868. * @param {?object} children Child collection structure.
  869. * @return {ReactElement} The first and only `ReactElement` contained in the
  870. * structure.
  871. */
  872. function onlyChild(children) {
  873. !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
  874. return children;
  875. }
  876. var describeComponentFrame = function (name, source, ownerName) {
  877. return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
  878. };
  879. function getComponentName(fiber) {
  880. var type = fiber.type;
  881. if (typeof type === 'string') {
  882. return type;
  883. }
  884. if (typeof type === 'function') {
  885. return type.displayName || type.name;
  886. }
  887. return null;
  888. }
  889. /**
  890. * ReactElementValidator provides a wrapper around a element factory
  891. * which validates the props passed to the element. This is intended to be
  892. * used only in DEV and could be replaced by a static type checker for languages
  893. * that support it.
  894. */
  895. {
  896. var currentlyValidatingElement = null;
  897. var propTypesMisspellWarningShown = false;
  898. var getDisplayName = function (element) {
  899. if (element == null) {
  900. return '#empty';
  901. } else if (typeof element === 'string' || typeof element === 'number') {
  902. return '#text';
  903. } else if (typeof element.type === 'string') {
  904. return element.type;
  905. } else if (element.type === REACT_FRAGMENT_TYPE) {
  906. return 'React.Fragment';
  907. } else {
  908. return element.type.displayName || element.type.name || 'Unknown';
  909. }
  910. };
  911. var getStackAddendum = function () {
  912. var stack = '';
  913. if (currentlyValidatingElement) {
  914. var name = getDisplayName(currentlyValidatingElement);
  915. var owner = currentlyValidatingElement._owner;
  916. stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
  917. }
  918. stack += ReactDebugCurrentFrame.getStackAddendum() || '';
  919. return stack;
  920. };
  921. var VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]);
  922. }
  923. function getDeclarationErrorAddendum() {
  924. if (ReactCurrentOwner.current) {
  925. var name = getComponentName(ReactCurrentOwner.current);
  926. if (name) {
  927. return '\n\nCheck the render method of `' + name + '`.';
  928. }
  929. }
  930. return '';
  931. }
  932. function getSourceInfoErrorAddendum(elementProps) {
  933. if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
  934. var source = elementProps.__source;
  935. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  936. var lineNumber = source.lineNumber;
  937. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  938. }
  939. return '';
  940. }
  941. /**
  942. * Warn if there's no key explicitly set on dynamic arrays of children or
  943. * object keys are not valid. This allows us to keep track of children between
  944. * updates.
  945. */
  946. var ownerHasKeyUseWarning = {};
  947. function getCurrentComponentErrorInfo(parentType) {
  948. var info = getDeclarationErrorAddendum();
  949. if (!info) {
  950. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  951. if (parentName) {
  952. info = '\n\nCheck the top-level render call using <' + parentName + '>.';
  953. }
  954. }
  955. return info;
  956. }
  957. /**
  958. * Warn if the element doesn't have an explicit key assigned to it.
  959. * This element is in an array. The array could grow and shrink or be
  960. * reordered. All children that haven't already been validated are required to
  961. * have a "key" property assigned to it. Error statuses are cached so a warning
  962. * will only be shown once.
  963. *
  964. * @internal
  965. * @param {ReactElement} element Element that requires a key.
  966. * @param {*} parentType element's parent's type.
  967. */
  968. function validateExplicitKey(element, parentType) {
  969. if (!element._store || element._store.validated || element.key != null) {
  970. return;
  971. }
  972. element._store.validated = true;
  973. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  974. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  975. return;
  976. }
  977. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  978. // Usually the current owner is the offender, but if it accepts children as a
  979. // property, it may be the creator of the child that's responsible for
  980. // assigning it a key.
  981. var childOwner = '';
  982. if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
  983. // Give the component that originally created this child.
  984. childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
  985. }
  986. currentlyValidatingElement = element;
  987. {
  988. warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum());
  989. }
  990. currentlyValidatingElement = null;
  991. }
  992. /**
  993. * Ensure that every element either is passed in a static location, in an
  994. * array with an explicit keys property defined, or in an object literal
  995. * with valid key property.
  996. *
  997. * @internal
  998. * @param {ReactNode} node Statically passed child of any type.
  999. * @param {*} parentType node's parent's type.
  1000. */
  1001. function validateChildKeys(node, parentType) {
  1002. if (typeof node !== 'object') {
  1003. return;
  1004. }
  1005. if (Array.isArray(node)) {
  1006. for (var i = 0; i < node.length; i++) {
  1007. var child = node[i];
  1008. if (isValidElement(child)) {
  1009. validateExplicitKey(child, parentType);
  1010. }
  1011. }
  1012. } else if (isValidElement(node)) {
  1013. // This element was passed in a valid location.
  1014. if (node._store) {
  1015. node._store.validated = true;
  1016. }
  1017. } else if (node) {
  1018. var iteratorFn = getIteratorFn(node);
  1019. if (typeof iteratorFn === 'function') {
  1020. // Entry iterators used to provide implicit keys,
  1021. // but now we print a separate warning for them later.
  1022. if (iteratorFn !== node.entries) {
  1023. var iterator = iteratorFn.call(node);
  1024. var step;
  1025. while (!(step = iterator.next()).done) {
  1026. if (isValidElement(step.value)) {
  1027. validateExplicitKey(step.value, parentType);
  1028. }
  1029. }
  1030. }
  1031. }
  1032. }
  1033. }
  1034. /**
  1035. * Given an element, validate that its props follow the propTypes definition,
  1036. * provided by the type.
  1037. *
  1038. * @param {ReactElement} element
  1039. */
  1040. function validatePropTypes(element) {
  1041. var componentClass = element.type;
  1042. if (typeof componentClass !== 'function') {
  1043. return;
  1044. }
  1045. var name = componentClass.displayName || componentClass.name;
  1046. var propTypes = componentClass.propTypes;
  1047. if (propTypes) {
  1048. currentlyValidatingElement = element;
  1049. checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum);
  1050. currentlyValidatingElement = null;
  1051. } else if (componentClass.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  1052. propTypesMisspellWarningShown = true;
  1053. warning(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
  1054. }
  1055. if (typeof componentClass.getDefaultProps === 'function') {
  1056. warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
  1057. }
  1058. }
  1059. /**
  1060. * Given a fragment, validate that it can only be provided with fragment props
  1061. * @param {ReactElement} fragment
  1062. */
  1063. function validateFragmentProps(fragment) {
  1064. currentlyValidatingElement = fragment;
  1065. var _iteratorNormalCompletion = true;
  1066. var _didIteratorError = false;
  1067. var _iteratorError = undefined;
  1068. try {
  1069. for (var _iterator = Object.keys(fragment.props)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  1070. var key = _step.value;
  1071. if (!VALID_FRAGMENT_PROPS.has(key)) {
  1072. warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
  1073. break;
  1074. }
  1075. }
  1076. } catch (err) {
  1077. _didIteratorError = true;
  1078. _iteratorError = err;
  1079. } finally {
  1080. try {
  1081. if (!_iteratorNormalCompletion && _iterator['return']) {
  1082. _iterator['return']();
  1083. }
  1084. } finally {
  1085. if (_didIteratorError) {
  1086. throw _iteratorError;
  1087. }
  1088. }
  1089. }
  1090. if (fragment.ref !== null) {
  1091. warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
  1092. }
  1093. currentlyValidatingElement = null;
  1094. }
  1095. function createElementWithValidation(type, props, children) {
  1096. var validType = typeof type === 'string' || typeof type === 'function' || typeof type === 'symbol' || typeof type === 'number';
  1097. // We warn in this case but don't throw. We expect the element creation to
  1098. // succeed and there will likely be errors in render.
  1099. if (!validType) {
  1100. var info = '';
  1101. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  1102. info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
  1103. }
  1104. var sourceInfo = getSourceInfoErrorAddendum(props);
  1105. if (sourceInfo) {
  1106. info += sourceInfo;
  1107. } else {
  1108. info += getDeclarationErrorAddendum();
  1109. }
  1110. info += getStackAddendum() || '';
  1111. warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info);
  1112. }
  1113. var element = createElement.apply(this, arguments);
  1114. // The result can be nullish if a mock or a custom function is used.
  1115. // TODO: Drop this when these are no longer allowed as the type argument.
  1116. if (element == null) {
  1117. return element;
  1118. }
  1119. // Skip key warning if the type isn't valid since our key validation logic
  1120. // doesn't expect a non-string/function type and can throw confusing errors.
  1121. // We don't want exception behavior to differ between dev and prod.
  1122. // (Rendering will throw with a helpful message and as soon as the type is
  1123. // fixed, the key warnings will appear.)
  1124. if (validType) {
  1125. for (var i = 2; i < arguments.length; i++) {
  1126. validateChildKeys(arguments[i], type);
  1127. }
  1128. }
  1129. if (typeof type === 'symbol' && type === REACT_FRAGMENT_TYPE) {
  1130. validateFragmentProps(element);
  1131. } else {
  1132. validatePropTypes(element);
  1133. }
  1134. return element;
  1135. }
  1136. function createFactoryWithValidation(type) {
  1137. var validatedFactory = createElementWithValidation.bind(null, type);
  1138. // Legacy hook TODO: Warn if this is accessed
  1139. validatedFactory.type = type;
  1140. {
  1141. Object.defineProperty(validatedFactory, 'type', {
  1142. enumerable: false,
  1143. get: function () {
  1144. lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
  1145. Object.defineProperty(this, 'type', {
  1146. value: type
  1147. });
  1148. return type;
  1149. }
  1150. });
  1151. }
  1152. return validatedFactory;
  1153. }
  1154. function cloneElementWithValidation(element, props, children) {
  1155. var newElement = cloneElement.apply(this, arguments);
  1156. for (var i = 2; i < arguments.length; i++) {
  1157. validateChildKeys(arguments[i], newElement.type);
  1158. }
  1159. validatePropTypes(newElement);
  1160. return newElement;
  1161. }
  1162. var React = {
  1163. Children: {
  1164. map: mapChildren,
  1165. forEach: forEachChildren,
  1166. count: countChildren,
  1167. toArray: toArray,
  1168. only: onlyChild
  1169. },
  1170. Component: Component,
  1171. PureComponent: PureComponent,
  1172. unstable_AsyncComponent: AsyncComponent,
  1173. Fragment: REACT_FRAGMENT_TYPE,
  1174. createElement: createElementWithValidation,
  1175. cloneElement: cloneElementWithValidation,
  1176. createFactory: createFactoryWithValidation,
  1177. isValidElement: isValidElement,
  1178. version: ReactVersion,
  1179. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
  1180. ReactCurrentOwner: ReactCurrentOwner,
  1181. // Used by renderers to avoid bundling object-assign twice in UMD bundles:
  1182. assign: _assign
  1183. }
  1184. };
  1185. {
  1186. _assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
  1187. // These should not be included in production.
  1188. ReactDebugCurrentFrame: ReactDebugCurrentFrame,
  1189. // Shim for React DOM 16.0.0 which still destructured (but not used) this.
  1190. // TODO: remove in React 17.0.
  1191. ReactComponentTreeHook: {}
  1192. });
  1193. }
  1194. var React$2 = Object.freeze({
  1195. default: React
  1196. });
  1197. var React$3 = ( React$2 && React ) || React$2;
  1198. // TODO: decide on the top-level export form.
  1199. // This is hacky but makes it work with both Rollup and Jest.
  1200. var react = React$3['default'] ? React$3['default'] : React$3;
  1201. module.exports = react;
  1202. })();
  1203. }