react 16.1.0 → 16.3.0-alpha.1
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 +175 -122
- package/cjs/react.production.min.js +14 -15
- package/package.json +1 -1
- package/umd/react.development.js +211 -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.1
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -9,20 +9,50 @@
|
|
|
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.1';
|
|
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
|
+
|
|
43
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
44
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
45
|
+
|
|
46
|
+
function getIteratorFn(maybeIterable) {
|
|
47
|
+
if (maybeIterable === null || typeof maybeIterable === 'undefined') {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
51
|
+
if (typeof maybeIterator === 'function') {
|
|
52
|
+
return maybeIterator;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
26
56
|
|
|
27
57
|
/**
|
|
28
58
|
* WARNING: DO NOT manually require this module.
|
|
@@ -31,21 +61,6 @@ var ReactVersion = '16.1.0';
|
|
|
31
61
|
* It always throws.
|
|
32
62
|
*/
|
|
33
63
|
|
|
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
64
|
/**
|
|
50
65
|
* Forked from fbjs/warning:
|
|
51
66
|
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
|
@@ -103,8 +118,8 @@ var didWarnStateUpdateForUnmountedComponent = {};
|
|
|
103
118
|
|
|
104
119
|
function warnNoop(publicInstance, callerName) {
|
|
105
120
|
{
|
|
106
|
-
var
|
|
107
|
-
var componentName =
|
|
121
|
+
var _constructor = publicInstance.constructor;
|
|
122
|
+
var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
|
108
123
|
var warningKey = componentName + '.' + callerName;
|
|
109
124
|
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
110
125
|
return;
|
|
@@ -269,46 +284,36 @@ Component.prototype.forceUpdate = function (callback) {
|
|
|
269
284
|
}
|
|
270
285
|
}
|
|
271
286
|
|
|
287
|
+
function ComponentDummy() {}
|
|
288
|
+
ComponentDummy.prototype = Component.prototype;
|
|
289
|
+
|
|
272
290
|
/**
|
|
273
|
-
*
|
|
291
|
+
* Convenience component with default shallow equality check for sCU.
|
|
274
292
|
*/
|
|
275
293
|
function PureComponent(props, context, updater) {
|
|
276
|
-
// Duplicated from Component.
|
|
277
294
|
this.props = props;
|
|
278
295
|
this.context = context;
|
|
279
296
|
this.refs = emptyObject;
|
|
280
|
-
// We initialize the default updater but the real one gets injected by the
|
|
281
|
-
// renderer.
|
|
282
297
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
283
298
|
}
|
|
284
299
|
|
|
285
|
-
function ComponentDummy() {}
|
|
286
|
-
ComponentDummy.prototype = Component.prototype;
|
|
287
300
|
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
288
301
|
pureComponentPrototype.constructor = PureComponent;
|
|
289
302
|
// Avoid an extra prototype jump for these methods.
|
|
290
303
|
_assign(pureComponentPrototype, Component.prototype);
|
|
291
304
|
pureComponentPrototype.isPureReactComponent = true;
|
|
292
305
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
306
|
+
// an immutable object with a single mutable value
|
|
307
|
+
function createRef() {
|
|
308
|
+
var refObject = {
|
|
309
|
+
value: null
|
|
310
|
+
};
|
|
311
|
+
{
|
|
312
|
+
Object.seal(refObject);
|
|
313
|
+
}
|
|
314
|
+
return refObject;
|
|
301
315
|
}
|
|
302
316
|
|
|
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
317
|
/**
|
|
313
318
|
* Keeps track of the current owner.
|
|
314
319
|
*
|
|
@@ -325,10 +330,6 @@ var ReactCurrentOwner = {
|
|
|
325
330
|
|
|
326
331
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
327
332
|
|
|
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
333
|
var RESERVED_PROPS = {
|
|
333
334
|
key: true,
|
|
334
335
|
ref: true,
|
|
@@ -336,8 +337,8 @@ var RESERVED_PROPS = {
|
|
|
336
337
|
__source: true
|
|
337
338
|
};
|
|
338
339
|
|
|
339
|
-
var specialPropKeyWarningShown;
|
|
340
|
-
var specialPropRefWarningShown;
|
|
340
|
+
var specialPropKeyWarningShown = void 0;
|
|
341
|
+
var specialPropRefWarningShown = void 0;
|
|
341
342
|
|
|
342
343
|
function hasValidRef(config) {
|
|
343
344
|
{
|
|
@@ -414,7 +415,7 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
414
415
|
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
415
416
|
var element = {
|
|
416
417
|
// This tag allow us to uniquely identify this as a React Element
|
|
417
|
-
$$typeof: REACT_ELEMENT_TYPE
|
|
418
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
418
419
|
|
|
419
420
|
// Built-in properties that belong on the element
|
|
420
421
|
type: type,
|
|
@@ -472,7 +473,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
472
473
|
* See https://reactjs.org/docs/react-api.html#createelement
|
|
473
474
|
*/
|
|
474
475
|
function createElement(type, config, children) {
|
|
475
|
-
var propName;
|
|
476
|
+
var propName = void 0;
|
|
476
477
|
|
|
477
478
|
// Reserved names are extracted
|
|
478
479
|
var props = {};
|
|
@@ -529,7 +530,7 @@ function createElement(type, config, children) {
|
|
|
529
530
|
}
|
|
530
531
|
{
|
|
531
532
|
if (key || ref) {
|
|
532
|
-
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE
|
|
533
|
+
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
|
|
533
534
|
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
534
535
|
if (key) {
|
|
535
536
|
defineKeyPropWarningGetter(props, displayName);
|
|
@@ -560,7 +561,7 @@ function cloneAndReplaceKey(oldElement, newKey) {
|
|
|
560
561
|
* See https://reactjs.org/docs/react-api.html#cloneelement
|
|
561
562
|
*/
|
|
562
563
|
function cloneElement(element, config, children) {
|
|
563
|
-
var propName;
|
|
564
|
+
var propName = void 0;
|
|
564
565
|
|
|
565
566
|
// Original props are copied
|
|
566
567
|
var props = _assign({}, element.props);
|
|
@@ -589,7 +590,7 @@ function cloneElement(element, config, children) {
|
|
|
589
590
|
}
|
|
590
591
|
|
|
591
592
|
// Remaining properties override existing props
|
|
592
|
-
var defaultProps;
|
|
593
|
+
var defaultProps = void 0;
|
|
593
594
|
if (element.type && element.type.defaultProps) {
|
|
594
595
|
defaultProps = element.type.defaultProps;
|
|
595
596
|
}
|
|
@@ -629,7 +630,7 @@ function cloneElement(element, config, children) {
|
|
|
629
630
|
* @final
|
|
630
631
|
*/
|
|
631
632
|
function isValidElement(object) {
|
|
632
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE
|
|
633
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
633
634
|
}
|
|
634
635
|
|
|
635
636
|
var ReactDebugCurrentFrame = {};
|
|
@@ -647,12 +648,6 @@ var ReactDebugCurrentFrame = {};
|
|
|
647
648
|
};
|
|
648
649
|
}
|
|
649
650
|
|
|
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
651
|
var SEPARATOR = '.';
|
|
657
652
|
var SUBSEPARATOR = ':';
|
|
658
653
|
|
|
@@ -736,10 +731,26 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
736
731
|
children = null;
|
|
737
732
|
}
|
|
738
733
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
734
|
+
var invokeCallback = false;
|
|
735
|
+
|
|
736
|
+
if (children === null) {
|
|
737
|
+
invokeCallback = true;
|
|
738
|
+
} else {
|
|
739
|
+
switch (type) {
|
|
740
|
+
case 'string':
|
|
741
|
+
case 'number':
|
|
742
|
+
invokeCallback = true;
|
|
743
|
+
break;
|
|
744
|
+
case 'object':
|
|
745
|
+
switch (children.$$typeof) {
|
|
746
|
+
case REACT_ELEMENT_TYPE:
|
|
747
|
+
case REACT_PORTAL_TYPE:
|
|
748
|
+
invokeCallback = true;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (invokeCallback) {
|
|
743
754
|
callback(traverseContext, children,
|
|
744
755
|
// If it's the only child, treat the name as if it was wrapped in an array
|
|
745
756
|
// so that it's consistent if the number of children grows.
|
|
@@ -747,8 +758,8 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
747
758
|
return 1;
|
|
748
759
|
}
|
|
749
760
|
|
|
750
|
-
var child;
|
|
751
|
-
var nextName;
|
|
761
|
+
var child = void 0;
|
|
762
|
+
var nextName = void 0;
|
|
752
763
|
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
753
764
|
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
754
765
|
|
|
@@ -759,7 +770,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
759
770
|
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
760
771
|
}
|
|
761
772
|
} else {
|
|
762
|
-
var iteratorFn =
|
|
773
|
+
var iteratorFn = getIteratorFn(children);
|
|
763
774
|
if (typeof iteratorFn === 'function') {
|
|
764
775
|
{
|
|
765
776
|
// Warn about using Maps as children
|
|
@@ -770,7 +781,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
770
781
|
}
|
|
771
782
|
|
|
772
783
|
var iterator = iteratorFn.call(children);
|
|
773
|
-
var step;
|
|
784
|
+
var step = void 0;
|
|
774
785
|
var ii = 0;
|
|
775
786
|
while (!(step = iterator.next()).done) {
|
|
776
787
|
child = step.value;
|
|
@@ -957,6 +968,39 @@ function onlyChild(children) {
|
|
|
957
968
|
return children;
|
|
958
969
|
}
|
|
959
970
|
|
|
971
|
+
function createContext(defaultValue, calculateChangedBits) {
|
|
972
|
+
if (calculateChangedBits === undefined) {
|
|
973
|
+
calculateChangedBits = null;
|
|
974
|
+
} else {
|
|
975
|
+
{
|
|
976
|
+
warning(calculateChangedBits === null || typeof calculateChangedBits === 'function', 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
var context = {
|
|
981
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
982
|
+
calculateChangedBits: calculateChangedBits,
|
|
983
|
+
defaultValue: defaultValue,
|
|
984
|
+
currentValue: defaultValue,
|
|
985
|
+
changedBits: 0,
|
|
986
|
+
// These are circular
|
|
987
|
+
Provider: null,
|
|
988
|
+
Consumer: null
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
context.Provider = {
|
|
992
|
+
$$typeof: REACT_PROVIDER_TYPE,
|
|
993
|
+
context: context
|
|
994
|
+
};
|
|
995
|
+
context.Consumer = context;
|
|
996
|
+
|
|
997
|
+
{
|
|
998
|
+
context._currentRenderer = null;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
return context;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
960
1004
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
961
1005
|
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
|
|
962
1006
|
};
|
|
@@ -964,11 +1008,21 @@ var describeComponentFrame = function (name, source, ownerName) {
|
|
|
964
1008
|
function getComponentName(fiber) {
|
|
965
1009
|
var type = fiber.type;
|
|
966
1010
|
|
|
1011
|
+
if (typeof type === 'function') {
|
|
1012
|
+
return type.displayName || type.name;
|
|
1013
|
+
}
|
|
967
1014
|
if (typeof type === 'string') {
|
|
968
1015
|
return type;
|
|
969
1016
|
}
|
|
970
|
-
|
|
971
|
-
|
|
1017
|
+
switch (type) {
|
|
1018
|
+
case REACT_FRAGMENT_TYPE:
|
|
1019
|
+
return 'ReactFragment';
|
|
1020
|
+
case REACT_PORTAL_TYPE:
|
|
1021
|
+
return 'ReactPortal';
|
|
1022
|
+
case REACT_CALL_TYPE:
|
|
1023
|
+
return 'ReactCall';
|
|
1024
|
+
case REACT_RETURN_TYPE:
|
|
1025
|
+
return 'ReactReturn';
|
|
972
1026
|
}
|
|
973
1027
|
return null;
|
|
974
1028
|
}
|
|
@@ -980,24 +1034,34 @@ function getComponentName(fiber) {
|
|
|
980
1034
|
* that support it.
|
|
981
1035
|
*/
|
|
982
1036
|
|
|
1037
|
+
var currentlyValidatingElement = void 0;
|
|
1038
|
+
var propTypesMisspellWarningShown = void 0;
|
|
1039
|
+
|
|
1040
|
+
var getDisplayName = function () {};
|
|
1041
|
+
var getStackAddendum = function () {};
|
|
1042
|
+
|
|
1043
|
+
var VALID_FRAGMENT_PROPS = void 0;
|
|
1044
|
+
|
|
983
1045
|
{
|
|
984
|
-
|
|
1046
|
+
currentlyValidatingElement = null;
|
|
1047
|
+
|
|
1048
|
+
propTypesMisspellWarningShown = false;
|
|
985
1049
|
|
|
986
|
-
|
|
1050
|
+
getDisplayName = function (element) {
|
|
987
1051
|
if (element == null) {
|
|
988
1052
|
return '#empty';
|
|
989
1053
|
} else if (typeof element === 'string' || typeof element === 'number') {
|
|
990
1054
|
return '#text';
|
|
991
1055
|
} else if (typeof element.type === 'string') {
|
|
992
1056
|
return element.type;
|
|
993
|
-
} else if (element.type === REACT_FRAGMENT_TYPE
|
|
1057
|
+
} else if (element.type === REACT_FRAGMENT_TYPE) {
|
|
994
1058
|
return 'React.Fragment';
|
|
995
1059
|
} else {
|
|
996
1060
|
return element.type.displayName || element.type.name || 'Unknown';
|
|
997
1061
|
}
|
|
998
1062
|
};
|
|
999
1063
|
|
|
1000
|
-
|
|
1064
|
+
getStackAddendum = function () {
|
|
1001
1065
|
var stack = '';
|
|
1002
1066
|
if (currentlyValidatingElement) {
|
|
1003
1067
|
var name = getDisplayName(currentlyValidatingElement);
|
|
@@ -1008,14 +1072,9 @@ function getComponentName(fiber) {
|
|
|
1008
1072
|
return stack;
|
|
1009
1073
|
};
|
|
1010
1074
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
var VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]);
|
|
1075
|
+
VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]);
|
|
1014
1076
|
}
|
|
1015
1077
|
|
|
1016
|
-
var ITERATOR_SYMBOL$1 = typeof Symbol === 'function' && Symbol.iterator;
|
|
1017
|
-
var FAUX_ITERATOR_SYMBOL$1 = '@@iterator'; // Before Symbol spec.
|
|
1018
|
-
|
|
1019
1078
|
function getDeclarationErrorAddendum() {
|
|
1020
1079
|
if (ReactCurrentOwner.current) {
|
|
1021
1080
|
var name = getComponentName(ReactCurrentOwner.current);
|
|
@@ -1120,13 +1179,13 @@ function validateChildKeys(node, parentType) {
|
|
|
1120
1179
|
node._store.validated = true;
|
|
1121
1180
|
}
|
|
1122
1181
|
} else if (node) {
|
|
1123
|
-
var iteratorFn =
|
|
1182
|
+
var iteratorFn = getIteratorFn(node);
|
|
1124
1183
|
if (typeof iteratorFn === 'function') {
|
|
1125
1184
|
// Entry iterators used to provide implicit keys,
|
|
1126
1185
|
// but now we print a separate warning for them later.
|
|
1127
1186
|
if (iteratorFn !== node.entries) {
|
|
1128
1187
|
var iterator = iteratorFn.call(node);
|
|
1129
|
-
var step;
|
|
1188
|
+
var step = void 0;
|
|
1130
1189
|
while (!(step = iterator.next()).done) {
|
|
1131
1190
|
if (isValidElement(step.value)) {
|
|
1132
1191
|
validateExplicitKey(step.value, parentType);
|
|
@@ -1150,11 +1209,13 @@ function validatePropTypes(element) {
|
|
|
1150
1209
|
}
|
|
1151
1210
|
var name = componentClass.displayName || componentClass.name;
|
|
1152
1211
|
var propTypes = componentClass.propTypes;
|
|
1153
|
-
|
|
1154
1212
|
if (propTypes) {
|
|
1155
1213
|
currentlyValidatingElement = element;
|
|
1156
1214
|
checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum);
|
|
1157
1215
|
currentlyValidatingElement = null;
|
|
1216
|
+
} else if (componentClass.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1217
|
+
propTypesMisspellWarningShown = true;
|
|
1218
|
+
warning(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
|
1158
1219
|
}
|
|
1159
1220
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
1160
1221
|
warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
@@ -1168,31 +1229,12 @@ function validatePropTypes(element) {
|
|
|
1168
1229
|
function validateFragmentProps(fragment) {
|
|
1169
1230
|
currentlyValidatingElement = fragment;
|
|
1170
1231
|
|
|
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
|
-
}
|
|
1232
|
+
var keys = Object.keys(fragment.props);
|
|
1233
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1234
|
+
var key = keys[i];
|
|
1235
|
+
if (!VALID_FRAGMENT_PROPS.has(key)) {
|
|
1236
|
+
warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
|
|
1237
|
+
break;
|
|
1196
1238
|
}
|
|
1197
1239
|
}
|
|
1198
1240
|
|
|
@@ -1204,13 +1246,16 @@ function validateFragmentProps(fragment) {
|
|
|
1204
1246
|
}
|
|
1205
1247
|
|
|
1206
1248
|
function createElementWithValidation(type, props, children) {
|
|
1207
|
-
var validType = typeof type === 'string' || typeof type === 'function' ||
|
|
1249
|
+
var validType = typeof type === 'string' || typeof type === 'function' ||
|
|
1250
|
+
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1251
|
+
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);
|
|
1252
|
+
|
|
1208
1253
|
// We warn in this case but don't throw. We expect the element creation to
|
|
1209
1254
|
// succeed and there will likely be errors in render.
|
|
1210
1255
|
if (!validType) {
|
|
1211
1256
|
var info = '';
|
|
1212
1257
|
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
1213
|
-
info += ' You likely forgot to export your component from the file ' + "it's defined in.";
|
|
1258
|
+
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.";
|
|
1214
1259
|
}
|
|
1215
1260
|
|
|
1216
1261
|
var sourceInfo = getSourceInfoErrorAddendum(props);
|
|
@@ -1222,7 +1267,16 @@ function createElementWithValidation(type, props, children) {
|
|
|
1222
1267
|
|
|
1223
1268
|
info += getStackAddendum() || '';
|
|
1224
1269
|
|
|
1225
|
-
|
|
1270
|
+
var typeString = void 0;
|
|
1271
|
+
if (type === null) {
|
|
1272
|
+
typeString = 'null';
|
|
1273
|
+
} else if (Array.isArray(type)) {
|
|
1274
|
+
typeString = 'array';
|
|
1275
|
+
} else {
|
|
1276
|
+
typeString = typeof type;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
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
1280
|
}
|
|
1227
1281
|
|
|
1228
1282
|
var element = createElement.apply(this, arguments);
|
|
@@ -1244,7 +1298,7 @@ function createElementWithValidation(type, props, children) {
|
|
|
1244
1298
|
}
|
|
1245
1299
|
}
|
|
1246
1300
|
|
|
1247
|
-
if (
|
|
1301
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
1248
1302
|
validateFragmentProps(element);
|
|
1249
1303
|
} else {
|
|
1250
1304
|
validatePropTypes(element);
|
|
@@ -1255,9 +1309,8 @@ function createElementWithValidation(type, props, children) {
|
|
|
1255
1309
|
|
|
1256
1310
|
function createFactoryWithValidation(type) {
|
|
1257
1311
|
var validatedFactory = createElementWithValidation.bind(null, type);
|
|
1258
|
-
// Legacy hook TODO: Warn if this is accessed
|
|
1259
1312
|
validatedFactory.type = type;
|
|
1260
|
-
|
|
1313
|
+
// Legacy hook: remove it
|
|
1261
1314
|
{
|
|
1262
1315
|
Object.defineProperty(validatedFactory, 'type', {
|
|
1263
1316
|
enumerable: false,
|
|
@@ -1283,8 +1336,6 @@ function cloneElementWithValidation(element, props, children) {
|
|
|
1283
1336
|
return newElement;
|
|
1284
1337
|
}
|
|
1285
1338
|
|
|
1286
|
-
var REACT_FRAGMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.fragment') || 0xeacb;
|
|
1287
|
-
|
|
1288
1339
|
var React = {
|
|
1289
1340
|
Children: {
|
|
1290
1341
|
map: mapChildren,
|
|
@@ -1294,9 +1345,15 @@ var React = {
|
|
|
1294
1345
|
only: onlyChild
|
|
1295
1346
|
},
|
|
1296
1347
|
|
|
1348
|
+
createRef: createRef,
|
|
1297
1349
|
Component: Component,
|
|
1298
1350
|
PureComponent: PureComponent,
|
|
1299
|
-
|
|
1351
|
+
|
|
1352
|
+
createContext: createContext,
|
|
1353
|
+
|
|
1354
|
+
Fragment: REACT_FRAGMENT_TYPE,
|
|
1355
|
+
StrictMode: REACT_STRICT_MODE_TYPE,
|
|
1356
|
+
unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
|
|
1300
1357
|
|
|
1301
1358
|
createElement: createElementWithValidation,
|
|
1302
1359
|
cloneElement: cloneElementWithValidation,
|
|
@@ -1312,10 +1369,6 @@ var React = {
|
|
|
1312
1369
|
}
|
|
1313
1370
|
};
|
|
1314
1371
|
|
|
1315
|
-
if (enableReactFragment) {
|
|
1316
|
-
React.Fragment = REACT_FRAGMENT_TYPE;
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
1372
|
{
|
|
1320
1373
|
_assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
|
1321
1374
|
// These should not be included in production.
|