react 16.1.1 → 16.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/react.development.js +188 -122
- package/cjs/react.production.min.js +15 -15
- package/package.json +1 -1
- package/umd/react.development.js +224 -160
- package/umd/react.production.min.js +14 -14
package/cjs/react.development.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.3.0-alpha.2
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -9,20 +9,51 @@
|
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
+
|
|
13
|
+
|
|
12
14
|
if (process.env.NODE_ENV !== "production") {
|
|
13
15
|
(function() {
|
|
14
16
|
'use strict';
|
|
15
17
|
|
|
16
18
|
var _assign = require('object-assign');
|
|
17
|
-
var invariant = require('fbjs/lib/invariant');
|
|
18
19
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
20
|
+
var invariant = require('fbjs/lib/invariant');
|
|
19
21
|
var warning = require('fbjs/lib/warning');
|
|
20
22
|
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
21
23
|
var checkPropTypes = require('prop-types/checkPropTypes');
|
|
22
24
|
|
|
23
25
|
// TODO: this is special because it gets imported during build.
|
|
24
26
|
|
|
25
|
-
var ReactVersion = '16.
|
|
27
|
+
var ReactVersion = '16.3.0-alpha.2';
|
|
28
|
+
|
|
29
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
30
|
+
// nor polyfill, then a plain number is used for performance.
|
|
31
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
|
|
32
|
+
|
|
33
|
+
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
|
|
34
|
+
var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
|
|
35
|
+
var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
|
|
36
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
|
|
37
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
|
|
38
|
+
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol['for']('react.strict_mode') : 0xeacc;
|
|
39
|
+
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol['for']('react.provider') : 0xeacd;
|
|
40
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol['for']('react.context') : 0xeace;
|
|
41
|
+
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol['for']('react.async_mode') : 0xeacf;
|
|
42
|
+
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol['for']('react.forward_ref') : 0xead0;
|
|
43
|
+
|
|
44
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
45
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
46
|
+
|
|
47
|
+
function getIteratorFn(maybeIterable) {
|
|
48
|
+
if (maybeIterable === null || typeof maybeIterable === 'undefined') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
52
|
+
if (typeof maybeIterator === 'function') {
|
|
53
|
+
return maybeIterator;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
26
57
|
|
|
27
58
|
/**
|
|
28
59
|
* WARNING: DO NOT manually require this module.
|
|
@@ -31,21 +62,6 @@ var ReactVersion = '16.1.1';
|
|
|
31
62
|
* It always throws.
|
|
32
63
|
*/
|
|
33
64
|
|
|
34
|
-
// Exports React.Fragment
|
|
35
|
-
var enableReactFragment = false;
|
|
36
|
-
// Exports ReactDOM.createRoot
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Mutating mode (React DOM, React ART, React Native):
|
|
41
|
-
|
|
42
|
-
// Experimental noop mode (currently unused):
|
|
43
|
-
|
|
44
|
-
// Experimental persistent mode (CS):
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Only used in www builds.
|
|
48
|
-
|
|
49
65
|
/**
|
|
50
66
|
* Forked from fbjs/warning:
|
|
51
67
|
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
|
@@ -103,8 +119,8 @@ var didWarnStateUpdateForUnmountedComponent = {};
|
|
|
103
119
|
|
|
104
120
|
function warnNoop(publicInstance, callerName) {
|
|
105
121
|
{
|
|
106
|
-
var
|
|
107
|
-
var componentName =
|
|
122
|
+
var _constructor = publicInstance.constructor;
|
|
123
|
+
var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
|
108
124
|
var warningKey = componentName + '.' + callerName;
|
|
109
125
|
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
110
126
|
return;
|
|
@@ -269,46 +285,36 @@ Component.prototype.forceUpdate = function (callback) {
|
|
|
269
285
|
}
|
|
270
286
|
}
|
|
271
287
|
|
|
288
|
+
function ComponentDummy() {}
|
|
289
|
+
ComponentDummy.prototype = Component.prototype;
|
|
290
|
+
|
|
272
291
|
/**
|
|
273
|
-
*
|
|
292
|
+
* Convenience component with default shallow equality check for sCU.
|
|
274
293
|
*/
|
|
275
294
|
function PureComponent(props, context, updater) {
|
|
276
|
-
// Duplicated from Component.
|
|
277
295
|
this.props = props;
|
|
278
296
|
this.context = context;
|
|
279
297
|
this.refs = emptyObject;
|
|
280
|
-
// We initialize the default updater but the real one gets injected by the
|
|
281
|
-
// renderer.
|
|
282
298
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
283
299
|
}
|
|
284
300
|
|
|
285
|
-
function ComponentDummy() {}
|
|
286
|
-
ComponentDummy.prototype = Component.prototype;
|
|
287
301
|
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
288
302
|
pureComponentPrototype.constructor = PureComponent;
|
|
289
303
|
// Avoid an extra prototype jump for these methods.
|
|
290
304
|
_assign(pureComponentPrototype, Component.prototype);
|
|
291
305
|
pureComponentPrototype.isPureReactComponent = true;
|
|
292
306
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
307
|
+
// an immutable object with a single mutable value
|
|
308
|
+
function createRef() {
|
|
309
|
+
var refObject = {
|
|
310
|
+
current: null
|
|
311
|
+
};
|
|
312
|
+
{
|
|
313
|
+
Object.seal(refObject);
|
|
314
|
+
}
|
|
315
|
+
return refObject;
|
|
301
316
|
}
|
|
302
317
|
|
|
303
|
-
var asyncComponentPrototype = AsyncComponent.prototype = new ComponentDummy();
|
|
304
|
-
asyncComponentPrototype.constructor = AsyncComponent;
|
|
305
|
-
// Avoid an extra prototype jump for these methods.
|
|
306
|
-
_assign(asyncComponentPrototype, Component.prototype);
|
|
307
|
-
asyncComponentPrototype.unstable_isAsyncReactComponent = true;
|
|
308
|
-
asyncComponentPrototype.render = function () {
|
|
309
|
-
return this.props.children;
|
|
310
|
-
};
|
|
311
|
-
|
|
312
318
|
/**
|
|
313
319
|
* Keeps track of the current owner.
|
|
314
320
|
*
|
|
@@ -325,10 +331,6 @@ var ReactCurrentOwner = {
|
|
|
325
331
|
|
|
326
332
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
327
333
|
|
|
328
|
-
// The Symbol used to tag the ReactElement type. If there is no native Symbol
|
|
329
|
-
// nor polyfill, then a plain number is used for performance.
|
|
330
|
-
var REACT_ELEMENT_TYPE$1 = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
|
|
331
|
-
|
|
332
334
|
var RESERVED_PROPS = {
|
|
333
335
|
key: true,
|
|
334
336
|
ref: true,
|
|
@@ -336,8 +338,8 @@ var RESERVED_PROPS = {
|
|
|
336
338
|
__source: true
|
|
337
339
|
};
|
|
338
340
|
|
|
339
|
-
var specialPropKeyWarningShown;
|
|
340
|
-
var specialPropRefWarningShown;
|
|
341
|
+
var specialPropKeyWarningShown = void 0;
|
|
342
|
+
var specialPropRefWarningShown = void 0;
|
|
341
343
|
|
|
342
344
|
function hasValidRef(config) {
|
|
343
345
|
{
|
|
@@ -413,8 +415,8 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
413
415
|
*/
|
|
414
416
|
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
415
417
|
var element = {
|
|
416
|
-
// This tag
|
|
417
|
-
$$typeof: REACT_ELEMENT_TYPE
|
|
418
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
419
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
418
420
|
|
|
419
421
|
// Built-in properties that belong on the element
|
|
420
422
|
type: type,
|
|
@@ -472,7 +474,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
472
474
|
* See https://reactjs.org/docs/react-api.html#createelement
|
|
473
475
|
*/
|
|
474
476
|
function createElement(type, config, children) {
|
|
475
|
-
var propName;
|
|
477
|
+
var propName = void 0;
|
|
476
478
|
|
|
477
479
|
// Reserved names are extracted
|
|
478
480
|
var props = {};
|
|
@@ -529,7 +531,7 @@ function createElement(type, config, children) {
|
|
|
529
531
|
}
|
|
530
532
|
{
|
|
531
533
|
if (key || ref) {
|
|
532
|
-
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE
|
|
534
|
+
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
|
|
533
535
|
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
534
536
|
if (key) {
|
|
535
537
|
defineKeyPropWarningGetter(props, displayName);
|
|
@@ -560,7 +562,7 @@ function cloneAndReplaceKey(oldElement, newKey) {
|
|
|
560
562
|
* See https://reactjs.org/docs/react-api.html#cloneelement
|
|
561
563
|
*/
|
|
562
564
|
function cloneElement(element, config, children) {
|
|
563
|
-
var propName;
|
|
565
|
+
var propName = void 0;
|
|
564
566
|
|
|
565
567
|
// Original props are copied
|
|
566
568
|
var props = _assign({}, element.props);
|
|
@@ -589,7 +591,7 @@ function cloneElement(element, config, children) {
|
|
|
589
591
|
}
|
|
590
592
|
|
|
591
593
|
// Remaining properties override existing props
|
|
592
|
-
var defaultProps;
|
|
594
|
+
var defaultProps = void 0;
|
|
593
595
|
if (element.type && element.type.defaultProps) {
|
|
594
596
|
defaultProps = element.type.defaultProps;
|
|
595
597
|
}
|
|
@@ -629,7 +631,7 @@ function cloneElement(element, config, children) {
|
|
|
629
631
|
* @final
|
|
630
632
|
*/
|
|
631
633
|
function isValidElement(object) {
|
|
632
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE
|
|
634
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
633
635
|
}
|
|
634
636
|
|
|
635
637
|
var ReactDebugCurrentFrame = {};
|
|
@@ -647,12 +649,6 @@ var ReactDebugCurrentFrame = {};
|
|
|
647
649
|
};
|
|
648
650
|
}
|
|
649
651
|
|
|
650
|
-
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
651
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
652
|
-
// The Symbol used to tag the ReactElement type. If there is no native Symbol
|
|
653
|
-
// nor polyfill, then a plain number is used for performance.
|
|
654
|
-
var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
|
|
655
|
-
var REACT_PORTAL_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.portal') || 0xeaca;
|
|
656
652
|
var SEPARATOR = '.';
|
|
657
653
|
var SUBSEPARATOR = ':';
|
|
658
654
|
|
|
@@ -736,10 +732,26 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
736
732
|
children = null;
|
|
737
733
|
}
|
|
738
734
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
735
|
+
var invokeCallback = false;
|
|
736
|
+
|
|
737
|
+
if (children === null) {
|
|
738
|
+
invokeCallback = true;
|
|
739
|
+
} else {
|
|
740
|
+
switch (type) {
|
|
741
|
+
case 'string':
|
|
742
|
+
case 'number':
|
|
743
|
+
invokeCallback = true;
|
|
744
|
+
break;
|
|
745
|
+
case 'object':
|
|
746
|
+
switch (children.$$typeof) {
|
|
747
|
+
case REACT_ELEMENT_TYPE:
|
|
748
|
+
case REACT_PORTAL_TYPE:
|
|
749
|
+
invokeCallback = true;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
if (invokeCallback) {
|
|
743
755
|
callback(traverseContext, children,
|
|
744
756
|
// If it's the only child, treat the name as if it was wrapped in an array
|
|
745
757
|
// so that it's consistent if the number of children grows.
|
|
@@ -747,8 +759,8 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
747
759
|
return 1;
|
|
748
760
|
}
|
|
749
761
|
|
|
750
|
-
var child;
|
|
751
|
-
var nextName;
|
|
762
|
+
var child = void 0;
|
|
763
|
+
var nextName = void 0;
|
|
752
764
|
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
753
765
|
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
754
766
|
|
|
@@ -759,7 +771,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
759
771
|
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
760
772
|
}
|
|
761
773
|
} else {
|
|
762
|
-
var iteratorFn =
|
|
774
|
+
var iteratorFn = getIteratorFn(children);
|
|
763
775
|
if (typeof iteratorFn === 'function') {
|
|
764
776
|
{
|
|
765
777
|
// Warn about using Maps as children
|
|
@@ -770,7 +782,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
770
782
|
}
|
|
771
783
|
|
|
772
784
|
var iterator = iteratorFn.call(children);
|
|
773
|
-
var step;
|
|
785
|
+
var step = void 0;
|
|
774
786
|
var ii = 0;
|
|
775
787
|
while (!(step = iterator.next()).done) {
|
|
776
788
|
child = step.value;
|
|
@@ -957,6 +969,50 @@ function onlyChild(children) {
|
|
|
957
969
|
return children;
|
|
958
970
|
}
|
|
959
971
|
|
|
972
|
+
function createContext(defaultValue, calculateChangedBits) {
|
|
973
|
+
if (calculateChangedBits === undefined) {
|
|
974
|
+
calculateChangedBits = null;
|
|
975
|
+
} else {
|
|
976
|
+
{
|
|
977
|
+
warning(calculateChangedBits === null || typeof calculateChangedBits === 'function', 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
var context = {
|
|
982
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
983
|
+
_calculateChangedBits: calculateChangedBits,
|
|
984
|
+
_defaultValue: defaultValue,
|
|
985
|
+
_currentValue: defaultValue,
|
|
986
|
+
_changedBits: 0,
|
|
987
|
+
// These are circular
|
|
988
|
+
Provider: null,
|
|
989
|
+
Consumer: null
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
context.Provider = {
|
|
993
|
+
$$typeof: REACT_PROVIDER_TYPE,
|
|
994
|
+
context: context
|
|
995
|
+
};
|
|
996
|
+
context.Consumer = context;
|
|
997
|
+
|
|
998
|
+
{
|
|
999
|
+
context._currentRenderer = null;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
return context;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
function forwardRef(render) {
|
|
1006
|
+
{
|
|
1007
|
+
warning(typeof render === 'function', 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
return {
|
|
1011
|
+
$$typeof: REACT_FORWARD_REF_TYPE,
|
|
1012
|
+
render: render
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
|
|
960
1016
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
961
1017
|
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
|
|
962
1018
|
};
|
|
@@ -964,11 +1020,21 @@ var describeComponentFrame = function (name, source, ownerName) {
|
|
|
964
1020
|
function getComponentName(fiber) {
|
|
965
1021
|
var type = fiber.type;
|
|
966
1022
|
|
|
1023
|
+
if (typeof type === 'function') {
|
|
1024
|
+
return type.displayName || type.name;
|
|
1025
|
+
}
|
|
967
1026
|
if (typeof type === 'string') {
|
|
968
1027
|
return type;
|
|
969
1028
|
}
|
|
970
|
-
|
|
971
|
-
|
|
1029
|
+
switch (type) {
|
|
1030
|
+
case REACT_FRAGMENT_TYPE:
|
|
1031
|
+
return 'ReactFragment';
|
|
1032
|
+
case REACT_PORTAL_TYPE:
|
|
1033
|
+
return 'ReactPortal';
|
|
1034
|
+
case REACT_CALL_TYPE:
|
|
1035
|
+
return 'ReactCall';
|
|
1036
|
+
case REACT_RETURN_TYPE:
|
|
1037
|
+
return 'ReactReturn';
|
|
972
1038
|
}
|
|
973
1039
|
return null;
|
|
974
1040
|
}
|
|
@@ -980,24 +1046,34 @@ function getComponentName(fiber) {
|
|
|
980
1046
|
* that support it.
|
|
981
1047
|
*/
|
|
982
1048
|
|
|
1049
|
+
var currentlyValidatingElement = void 0;
|
|
1050
|
+
var propTypesMisspellWarningShown = void 0;
|
|
1051
|
+
|
|
1052
|
+
var getDisplayName = function () {};
|
|
1053
|
+
var getStackAddendum = function () {};
|
|
1054
|
+
|
|
1055
|
+
var VALID_FRAGMENT_PROPS = void 0;
|
|
1056
|
+
|
|
983
1057
|
{
|
|
984
|
-
|
|
1058
|
+
currentlyValidatingElement = null;
|
|
1059
|
+
|
|
1060
|
+
propTypesMisspellWarningShown = false;
|
|
985
1061
|
|
|
986
|
-
|
|
1062
|
+
getDisplayName = function (element) {
|
|
987
1063
|
if (element == null) {
|
|
988
1064
|
return '#empty';
|
|
989
1065
|
} else if (typeof element === 'string' || typeof element === 'number') {
|
|
990
1066
|
return '#text';
|
|
991
1067
|
} else if (typeof element.type === 'string') {
|
|
992
1068
|
return element.type;
|
|
993
|
-
} else if (element.type === REACT_FRAGMENT_TYPE
|
|
1069
|
+
} else if (element.type === REACT_FRAGMENT_TYPE) {
|
|
994
1070
|
return 'React.Fragment';
|
|
995
1071
|
} else {
|
|
996
1072
|
return element.type.displayName || element.type.name || 'Unknown';
|
|
997
1073
|
}
|
|
998
1074
|
};
|
|
999
1075
|
|
|
1000
|
-
|
|
1076
|
+
getStackAddendum = function () {
|
|
1001
1077
|
var stack = '';
|
|
1002
1078
|
if (currentlyValidatingElement) {
|
|
1003
1079
|
var name = getDisplayName(currentlyValidatingElement);
|
|
@@ -1008,14 +1084,9 @@ function getComponentName(fiber) {
|
|
|
1008
1084
|
return stack;
|
|
1009
1085
|
};
|
|
1010
1086
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
var VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]);
|
|
1087
|
+
VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]);
|
|
1014
1088
|
}
|
|
1015
1089
|
|
|
1016
|
-
var ITERATOR_SYMBOL$1 = typeof Symbol === 'function' && Symbol.iterator;
|
|
1017
|
-
var FAUX_ITERATOR_SYMBOL$1 = '@@iterator'; // Before Symbol spec.
|
|
1018
|
-
|
|
1019
1090
|
function getDeclarationErrorAddendum() {
|
|
1020
1091
|
if (ReactCurrentOwner.current) {
|
|
1021
1092
|
var name = getComponentName(ReactCurrentOwner.current);
|
|
@@ -1120,13 +1191,13 @@ function validateChildKeys(node, parentType) {
|
|
|
1120
1191
|
node._store.validated = true;
|
|
1121
1192
|
}
|
|
1122
1193
|
} else if (node) {
|
|
1123
|
-
var iteratorFn =
|
|
1194
|
+
var iteratorFn = getIteratorFn(node);
|
|
1124
1195
|
if (typeof iteratorFn === 'function') {
|
|
1125
1196
|
// Entry iterators used to provide implicit keys,
|
|
1126
1197
|
// but now we print a separate warning for them later.
|
|
1127
1198
|
if (iteratorFn !== node.entries) {
|
|
1128
1199
|
var iterator = iteratorFn.call(node);
|
|
1129
|
-
var step;
|
|
1200
|
+
var step = void 0;
|
|
1130
1201
|
while (!(step = iterator.next()).done) {
|
|
1131
1202
|
if (isValidElement(step.value)) {
|
|
1132
1203
|
validateExplicitKey(step.value, parentType);
|
|
@@ -1150,11 +1221,13 @@ function validatePropTypes(element) {
|
|
|
1150
1221
|
}
|
|
1151
1222
|
var name = componentClass.displayName || componentClass.name;
|
|
1152
1223
|
var propTypes = componentClass.propTypes;
|
|
1153
|
-
|
|
1154
1224
|
if (propTypes) {
|
|
1155
1225
|
currentlyValidatingElement = element;
|
|
1156
1226
|
checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum);
|
|
1157
1227
|
currentlyValidatingElement = null;
|
|
1228
|
+
} else if (componentClass.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1229
|
+
propTypesMisspellWarningShown = true;
|
|
1230
|
+
warning(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
|
1158
1231
|
}
|
|
1159
1232
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
1160
1233
|
warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
@@ -1168,31 +1241,12 @@ function validatePropTypes(element) {
|
|
|
1168
1241
|
function validateFragmentProps(fragment) {
|
|
1169
1242
|
currentlyValidatingElement = fragment;
|
|
1170
1243
|
|
|
1171
|
-
var
|
|
1172
|
-
var
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
var key = _step.value;
|
|
1178
|
-
|
|
1179
|
-
if (!VALID_FRAGMENT_PROPS.has(key)) {
|
|
1180
|
-
warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
|
|
1181
|
-
break;
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
} catch (err) {
|
|
1185
|
-
_didIteratorError = true;
|
|
1186
|
-
_iteratorError = err;
|
|
1187
|
-
} finally {
|
|
1188
|
-
try {
|
|
1189
|
-
if (!_iteratorNormalCompletion && _iterator['return']) {
|
|
1190
|
-
_iterator['return']();
|
|
1191
|
-
}
|
|
1192
|
-
} finally {
|
|
1193
|
-
if (_didIteratorError) {
|
|
1194
|
-
throw _iteratorError;
|
|
1195
|
-
}
|
|
1244
|
+
var keys = Object.keys(fragment.props);
|
|
1245
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1246
|
+
var key = keys[i];
|
|
1247
|
+
if (!VALID_FRAGMENT_PROPS.has(key)) {
|
|
1248
|
+
warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
|
|
1249
|
+
break;
|
|
1196
1250
|
}
|
|
1197
1251
|
}
|
|
1198
1252
|
|
|
@@ -1204,7 +1258,10 @@ function validateFragmentProps(fragment) {
|
|
|
1204
1258
|
}
|
|
1205
1259
|
|
|
1206
1260
|
function createElementWithValidation(type, props, children) {
|
|
1207
|
-
var validType = typeof type === 'string' || typeof type === 'function' ||
|
|
1261
|
+
var validType = typeof type === 'string' || typeof type === 'function' ||
|
|
1262
|
+
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1263
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
|
1264
|
+
|
|
1208
1265
|
// We warn in this case but don't throw. We expect the element creation to
|
|
1209
1266
|
// succeed and there will likely be errors in render.
|
|
1210
1267
|
if (!validType) {
|
|
@@ -1222,7 +1279,16 @@ function createElementWithValidation(type, props, children) {
|
|
|
1222
1279
|
|
|
1223
1280
|
info += getStackAddendum() || '';
|
|
1224
1281
|
|
|
1225
|
-
|
|
1282
|
+
var typeString = void 0;
|
|
1283
|
+
if (type === null) {
|
|
1284
|
+
typeString = 'null';
|
|
1285
|
+
} else if (Array.isArray(type)) {
|
|
1286
|
+
typeString = 'array';
|
|
1287
|
+
} else {
|
|
1288
|
+
typeString = typeof type;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
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', typeString, info);
|
|
1226
1292
|
}
|
|
1227
1293
|
|
|
1228
1294
|
var element = createElement.apply(this, arguments);
|
|
@@ -1244,7 +1310,7 @@ function createElementWithValidation(type, props, children) {
|
|
|
1244
1310
|
}
|
|
1245
1311
|
}
|
|
1246
1312
|
|
|
1247
|
-
if (
|
|
1313
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
1248
1314
|
validateFragmentProps(element);
|
|
1249
1315
|
} else {
|
|
1250
1316
|
validatePropTypes(element);
|
|
@@ -1255,9 +1321,8 @@ function createElementWithValidation(type, props, children) {
|
|
|
1255
1321
|
|
|
1256
1322
|
function createFactoryWithValidation(type) {
|
|
1257
1323
|
var validatedFactory = createElementWithValidation.bind(null, type);
|
|
1258
|
-
// Legacy hook TODO: Warn if this is accessed
|
|
1259
1324
|
validatedFactory.type = type;
|
|
1260
|
-
|
|
1325
|
+
// Legacy hook: remove it
|
|
1261
1326
|
{
|
|
1262
1327
|
Object.defineProperty(validatedFactory, 'type', {
|
|
1263
1328
|
enumerable: false,
|
|
@@ -1283,8 +1348,6 @@ function cloneElementWithValidation(element, props, children) {
|
|
|
1283
1348
|
return newElement;
|
|
1284
1349
|
}
|
|
1285
1350
|
|
|
1286
|
-
var REACT_FRAGMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.fragment') || 0xeacb;
|
|
1287
|
-
|
|
1288
1351
|
var React = {
|
|
1289
1352
|
Children: {
|
|
1290
1353
|
map: mapChildren,
|
|
@@ -1294,9 +1357,16 @@ var React = {
|
|
|
1294
1357
|
only: onlyChild
|
|
1295
1358
|
},
|
|
1296
1359
|
|
|
1360
|
+
createRef: createRef,
|
|
1297
1361
|
Component: Component,
|
|
1298
1362
|
PureComponent: PureComponent,
|
|
1299
|
-
|
|
1363
|
+
|
|
1364
|
+
createContext: createContext,
|
|
1365
|
+
forwardRef: forwardRef,
|
|
1366
|
+
|
|
1367
|
+
Fragment: REACT_FRAGMENT_TYPE,
|
|
1368
|
+
StrictMode: REACT_STRICT_MODE_TYPE,
|
|
1369
|
+
unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
|
|
1300
1370
|
|
|
1301
1371
|
createElement: createElementWithValidation,
|
|
1302
1372
|
cloneElement: cloneElementWithValidation,
|
|
@@ -1312,10 +1382,6 @@ var React = {
|
|
|
1312
1382
|
}
|
|
1313
1383
|
};
|
|
1314
1384
|
|
|
1315
|
-
if (enableReactFragment) {
|
|
1316
|
-
React.Fragment = REACT_FRAGMENT_TYPE;
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
1385
|
{
|
|
1320
1386
|
_assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
|
1321
1387
|
// These should not be included in production.
|