react 16.4.2 → 16.5.0
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/README.md +4 -7
- package/cjs/react.development.js +352 -163
- package/cjs/react.production.min.js +16 -14
- package/cjs/react.profiling.min.js +24 -0
- package/package.json +3 -3
- package/umd/react.development.js +1222 -389
- package/umd/react.production.min.js +20 -15
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
# react
|
|
1
|
+
# `react`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
without also requiring the JSX transformer. This is especially useful for cases where you
|
|
5
|
-
want to [`browserify`](https://github.com/substack/node-browserify) your module using
|
|
6
|
-
`React`.
|
|
3
|
+
React is a JavaScript library for creating user interfaces.
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
The `react` package contains only the functionality necessary to define React components. It is typically used together with a React renderer like `react-dom` for the web, or `react-native` for the native environments.
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
**Note:** by default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages. Don't forget to use the [production build](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build) when deploying your application.
|
|
11
8
|
|
|
12
9
|
## Example Usage
|
|
13
10
|
|
package/cjs/react.development.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.5.0
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -16,15 +16,11 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
var _assign = require('object-assign');
|
|
19
|
-
var invariant = require('fbjs/lib/invariant');
|
|
20
|
-
var emptyObject = require('fbjs/lib/emptyObject');
|
|
21
|
-
var warning = require('fbjs/lib/warning');
|
|
22
|
-
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
23
19
|
var checkPropTypes = require('prop-types/checkPropTypes');
|
|
24
20
|
|
|
25
21
|
// TODO: this is special because it gets imported during build.
|
|
26
22
|
|
|
27
|
-
var ReactVersion = '16.
|
|
23
|
+
var ReactVersion = '16.5.0';
|
|
28
24
|
|
|
29
25
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
30
26
|
// nor polyfill, then a plain number is used for performance.
|
|
@@ -39,13 +35,13 @@ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
|
39
35
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
40
36
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
41
37
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
42
|
-
var
|
|
38
|
+
var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
|
|
43
39
|
|
|
44
40
|
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
45
41
|
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
46
42
|
|
|
47
43
|
function getIteratorFn(maybeIterable) {
|
|
48
|
-
if (maybeIterable === null || typeof maybeIterable
|
|
44
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
49
45
|
return null;
|
|
50
46
|
}
|
|
51
47
|
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
@@ -55,8 +51,50 @@ function getIteratorFn(maybeIterable) {
|
|
|
55
51
|
return null;
|
|
56
52
|
}
|
|
57
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
56
|
+
*
|
|
57
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
58
|
+
* to provide information about what broke and what you were
|
|
59
|
+
* expecting.
|
|
60
|
+
*
|
|
61
|
+
* The invariant message will be stripped in production, but the invariant
|
|
62
|
+
* will remain to ensure logic does not differ in production.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
var validateFormat = function () {};
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
validateFormat = function (format) {
|
|
69
|
+
if (format === undefined) {
|
|
70
|
+
throw new Error('invariant requires an error message argument');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function invariant(condition, format, a, b, c, d, e, f) {
|
|
76
|
+
validateFormat(format);
|
|
77
|
+
|
|
78
|
+
if (!condition) {
|
|
79
|
+
var error = void 0;
|
|
80
|
+
if (format === undefined) {
|
|
81
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
82
|
+
} else {
|
|
83
|
+
var args = [a, b, c, d, e, f];
|
|
84
|
+
var argIndex = 0;
|
|
85
|
+
error = new Error(format.replace(/%s/g, function () {
|
|
86
|
+
return args[argIndex++];
|
|
87
|
+
}));
|
|
88
|
+
error.name = 'Invariant Violation';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
58
96
|
// Relying on the `invariant()` implementation lets us
|
|
59
|
-
//
|
|
97
|
+
// preserve the format and params in the www builds.
|
|
60
98
|
|
|
61
99
|
// Exports ReactDOM.createRoot
|
|
62
100
|
|
|
@@ -88,6 +126,12 @@ var enableSuspense = false;
|
|
|
88
126
|
// Gather advanced timing metrics for Profiler subtrees.
|
|
89
127
|
|
|
90
128
|
|
|
129
|
+
// Track which interactions trigger each commit.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
// Only used in www builds.
|
|
133
|
+
|
|
134
|
+
|
|
91
135
|
// Only used in www builds.
|
|
92
136
|
|
|
93
137
|
/**
|
|
@@ -129,7 +173,7 @@ var lowPriorityWarning = function () {};
|
|
|
129
173
|
|
|
130
174
|
lowPriorityWarning = function (condition, format) {
|
|
131
175
|
if (format === undefined) {
|
|
132
|
-
throw new Error('`
|
|
176
|
+
throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
133
177
|
}
|
|
134
178
|
if (!condition) {
|
|
135
179
|
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
@@ -143,6 +187,50 @@ var lowPriorityWarning = function () {};
|
|
|
143
187
|
|
|
144
188
|
var lowPriorityWarning$1 = lowPriorityWarning;
|
|
145
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
192
|
+
* This can be used to log issues in development environments in critical
|
|
193
|
+
* paths. Removing the logging code for production environments will keep the
|
|
194
|
+
* same logic and follow the same code paths.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
var warningWithoutStack = function () {};
|
|
198
|
+
|
|
199
|
+
{
|
|
200
|
+
warningWithoutStack = function (condition, format) {
|
|
201
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
202
|
+
args[_key - 2] = arguments[_key];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (format === undefined) {
|
|
206
|
+
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
207
|
+
}
|
|
208
|
+
if (condition) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (typeof console !== 'undefined') {
|
|
212
|
+
var _console;
|
|
213
|
+
|
|
214
|
+
var stringArgs = args.map(function (item) {
|
|
215
|
+
return '' + item;
|
|
216
|
+
});
|
|
217
|
+
(_console = console).error.apply(_console, ['Warning: ' + format].concat(stringArgs));
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
// --- Welcome to debugging React ---
|
|
221
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
222
|
+
// to find the callsite that caused this warning to fire.
|
|
223
|
+
var argIndex = 0;
|
|
224
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
225
|
+
return args[argIndex++];
|
|
226
|
+
});
|
|
227
|
+
throw new Error(message);
|
|
228
|
+
} catch (x) {}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var warningWithoutStack$1 = warningWithoutStack;
|
|
233
|
+
|
|
146
234
|
var didWarnStateUpdateForUnmountedComponent = {};
|
|
147
235
|
|
|
148
236
|
function warnNoop(publicInstance, callerName) {
|
|
@@ -153,7 +241,7 @@ function warnNoop(publicInstance, callerName) {
|
|
|
153
241
|
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
154
242
|
return;
|
|
155
243
|
}
|
|
156
|
-
|
|
244
|
+
warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
|
|
157
245
|
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
|
158
246
|
}
|
|
159
247
|
}
|
|
@@ -226,12 +314,18 @@ var ReactNoopUpdateQueue = {
|
|
|
226
314
|
}
|
|
227
315
|
};
|
|
228
316
|
|
|
317
|
+
var emptyObject = {};
|
|
318
|
+
{
|
|
319
|
+
Object.freeze(emptyObject);
|
|
320
|
+
}
|
|
321
|
+
|
|
229
322
|
/**
|
|
230
323
|
* Base class helpers for the updating state of a component.
|
|
231
324
|
*/
|
|
232
325
|
function Component(props, context, updater) {
|
|
233
326
|
this.props = props;
|
|
234
327
|
this.context = context;
|
|
328
|
+
// If a component has string refs, we will assign a different object later.
|
|
235
329
|
this.refs = emptyObject;
|
|
236
330
|
// We initialize the default updater but the real one gets injected by the
|
|
237
331
|
// renderer.
|
|
@@ -322,6 +416,7 @@ ComponentDummy.prototype = Component.prototype;
|
|
|
322
416
|
function PureComponent(props, context, updater) {
|
|
323
417
|
this.props = props;
|
|
324
418
|
this.context = context;
|
|
419
|
+
// If a component has string refs, we will assign a different object later.
|
|
325
420
|
this.refs = emptyObject;
|
|
326
421
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
327
422
|
}
|
|
@@ -354,9 +449,177 @@ var ReactCurrentOwner = {
|
|
|
354
449
|
* @internal
|
|
355
450
|
* @type {ReactComponent}
|
|
356
451
|
*/
|
|
357
|
-
current: null
|
|
452
|
+
current: null,
|
|
453
|
+
currentDispatcher: null
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
457
|
+
|
|
458
|
+
var describeComponentFrame = function (name, source, ownerName) {
|
|
459
|
+
var sourceInfo = '';
|
|
460
|
+
if (source) {
|
|
461
|
+
var path = source.fileName;
|
|
462
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
463
|
+
{
|
|
464
|
+
// In DEV, include code for a common special case:
|
|
465
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
466
|
+
if (/^index\./.test(fileName)) {
|
|
467
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
468
|
+
if (match) {
|
|
469
|
+
var pathBeforeSlash = match[1];
|
|
470
|
+
if (pathBeforeSlash) {
|
|
471
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
472
|
+
fileName = folderName + '/' + fileName;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
478
|
+
} else if (ownerName) {
|
|
479
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
480
|
+
}
|
|
481
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
var Resolved = 1;
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
function refineResolvedThenable(thenable) {
|
|
490
|
+
return thenable._reactStatus === Resolved ? thenable._reactResult : null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function getComponentName(type) {
|
|
494
|
+
if (type == null) {
|
|
495
|
+
// Host root, text node or just invalid type.
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
{
|
|
499
|
+
if (typeof type.tag === 'number') {
|
|
500
|
+
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (typeof type === 'function') {
|
|
504
|
+
return type.displayName || type.name || null;
|
|
505
|
+
}
|
|
506
|
+
if (typeof type === 'string') {
|
|
507
|
+
return type;
|
|
508
|
+
}
|
|
509
|
+
switch (type) {
|
|
510
|
+
case REACT_ASYNC_MODE_TYPE:
|
|
511
|
+
return 'AsyncMode';
|
|
512
|
+
case REACT_FRAGMENT_TYPE:
|
|
513
|
+
return 'Fragment';
|
|
514
|
+
case REACT_PORTAL_TYPE:
|
|
515
|
+
return 'Portal';
|
|
516
|
+
case REACT_PROFILER_TYPE:
|
|
517
|
+
return 'Profiler';
|
|
518
|
+
case REACT_STRICT_MODE_TYPE:
|
|
519
|
+
return 'StrictMode';
|
|
520
|
+
case REACT_PLACEHOLDER_TYPE:
|
|
521
|
+
return 'Placeholder';
|
|
522
|
+
}
|
|
523
|
+
if (typeof type === 'object') {
|
|
524
|
+
switch (type.$$typeof) {
|
|
525
|
+
case REACT_CONTEXT_TYPE:
|
|
526
|
+
return 'Context.Consumer';
|
|
527
|
+
case REACT_PROVIDER_TYPE:
|
|
528
|
+
return 'Context.Provider';
|
|
529
|
+
case REACT_FORWARD_REF_TYPE:
|
|
530
|
+
var renderFn = type.render;
|
|
531
|
+
var functionName = renderFn.displayName || renderFn.name || '';
|
|
532
|
+
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
533
|
+
}
|
|
534
|
+
if (typeof type.then === 'function') {
|
|
535
|
+
var thenable = type;
|
|
536
|
+
var resolvedThenable = refineResolvedThenable(thenable);
|
|
537
|
+
if (resolvedThenable) {
|
|
538
|
+
return getComponentName(resolvedThenable);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
var ReactDebugCurrentFrame = {};
|
|
546
|
+
|
|
547
|
+
var currentlyValidatingElement = null;
|
|
548
|
+
|
|
549
|
+
function setCurrentlyValidatingElement(element) {
|
|
550
|
+
{
|
|
551
|
+
currentlyValidatingElement = element;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
{
|
|
556
|
+
// Stack implementation injected by the current renderer.
|
|
557
|
+
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
558
|
+
|
|
559
|
+
ReactDebugCurrentFrame.getStackAddendum = function () {
|
|
560
|
+
var stack = '';
|
|
561
|
+
|
|
562
|
+
// Add an extra top frame while an element is being validated
|
|
563
|
+
if (currentlyValidatingElement) {
|
|
564
|
+
var name = getComponentName(currentlyValidatingElement.type);
|
|
565
|
+
var owner = currentlyValidatingElement._owner;
|
|
566
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Delegate to the injected renderer-specific implementation
|
|
570
|
+
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
571
|
+
if (impl) {
|
|
572
|
+
stack += impl() || '';
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
return stack;
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
var ReactSharedInternals = {
|
|
580
|
+
ReactCurrentOwner: ReactCurrentOwner,
|
|
581
|
+
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
582
|
+
assign: _assign
|
|
358
583
|
};
|
|
359
584
|
|
|
585
|
+
{
|
|
586
|
+
_assign(ReactSharedInternals, {
|
|
587
|
+
// These should not be included in production.
|
|
588
|
+
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
|
589
|
+
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
|
|
590
|
+
// TODO: remove in React 17.0.
|
|
591
|
+
ReactComponentTreeHook: {}
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
597
|
+
* This can be used to log issues in development environments in critical
|
|
598
|
+
* paths. Removing the logging code for production environments will keep the
|
|
599
|
+
* same logic and follow the same code paths.
|
|
600
|
+
*/
|
|
601
|
+
|
|
602
|
+
var warning = warningWithoutStack$1;
|
|
603
|
+
|
|
604
|
+
{
|
|
605
|
+
warning = function (condition, format) {
|
|
606
|
+
if (condition) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
610
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
611
|
+
// eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
612
|
+
|
|
613
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
614
|
+
args[_key - 2] = arguments[_key];
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
var warning$1 = warning;
|
|
622
|
+
|
|
360
623
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
361
624
|
|
|
362
625
|
var RESERVED_PROPS = {
|
|
@@ -397,7 +660,7 @@ function defineKeyPropWarningGetter(props, displayName) {
|
|
|
397
660
|
var warnAboutAccessingKey = function () {
|
|
398
661
|
if (!specialPropKeyWarningShown) {
|
|
399
662
|
specialPropKeyWarningShown = true;
|
|
400
|
-
|
|
663
|
+
warningWithoutStack$1(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);
|
|
401
664
|
}
|
|
402
665
|
};
|
|
403
666
|
warnAboutAccessingKey.isReactWarning = true;
|
|
@@ -411,7 +674,7 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
411
674
|
var warnAboutAccessingRef = function () {
|
|
412
675
|
if (!specialPropRefWarningShown) {
|
|
413
676
|
specialPropRefWarningShown = true;
|
|
414
|
-
|
|
677
|
+
warningWithoutStack$1(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);
|
|
415
678
|
}
|
|
416
679
|
};
|
|
417
680
|
warnAboutAccessingRef.isReactWarning = true;
|
|
@@ -559,14 +822,12 @@ function createElement(type, config, children) {
|
|
|
559
822
|
}
|
|
560
823
|
{
|
|
561
824
|
if (key || ref) {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
defineRefPropWarningGetter(props, displayName);
|
|
569
|
-
}
|
|
825
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
826
|
+
if (key) {
|
|
827
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
828
|
+
}
|
|
829
|
+
if (ref) {
|
|
830
|
+
defineRefPropWarningGetter(props, displayName);
|
|
570
831
|
}
|
|
571
832
|
}
|
|
572
833
|
}
|
|
@@ -657,28 +918,13 @@ function cloneElement(element, config, children) {
|
|
|
657
918
|
* Verifies the object is a ReactElement.
|
|
658
919
|
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
659
920
|
* @param {?object} object
|
|
660
|
-
* @return {boolean} True if `object` is a
|
|
921
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
661
922
|
* @final
|
|
662
923
|
*/
|
|
663
924
|
function isValidElement(object) {
|
|
664
925
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
665
926
|
}
|
|
666
927
|
|
|
667
|
-
var ReactDebugCurrentFrame = {};
|
|
668
|
-
|
|
669
|
-
{
|
|
670
|
-
// Component that is being worked on
|
|
671
|
-
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
672
|
-
|
|
673
|
-
ReactDebugCurrentFrame.getStackAddendum = function () {
|
|
674
|
-
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
675
|
-
if (impl) {
|
|
676
|
-
return impl();
|
|
677
|
-
}
|
|
678
|
-
return null;
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
|
|
682
928
|
var SEPARATOR = '.';
|
|
683
929
|
var SUBSEPARATOR = ':';
|
|
684
930
|
|
|
@@ -806,7 +1052,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
806
1052
|
{
|
|
807
1053
|
// Warn about using Maps as children
|
|
808
1054
|
if (iteratorFn === children.entries) {
|
|
809
|
-
!didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead
|
|
1055
|
+
!didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
|
|
810
1056
|
didWarnAboutMaps = true;
|
|
811
1057
|
}
|
|
812
1058
|
}
|
|
@@ -911,7 +1157,9 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
|
911
1157
|
|
|
912
1158
|
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
913
1159
|
if (Array.isArray(mappedChild)) {
|
|
914
|
-
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey,
|
|
1160
|
+
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
|
|
1161
|
+
return c;
|
|
1162
|
+
});
|
|
915
1163
|
} else if (mappedChild != null) {
|
|
916
1164
|
if (isValidElement(mappedChild)) {
|
|
917
1165
|
mappedChild = cloneAndReplaceKey(mappedChild,
|
|
@@ -965,7 +1213,9 @@ function mapChildren(children, func, context) {
|
|
|
965
1213
|
* @return {number} The number of children.
|
|
966
1214
|
*/
|
|
967
1215
|
function countChildren(children) {
|
|
968
|
-
return traverseAllChildren(children,
|
|
1216
|
+
return traverseAllChildren(children, function () {
|
|
1217
|
+
return null;
|
|
1218
|
+
}, null);
|
|
969
1219
|
}
|
|
970
1220
|
|
|
971
1221
|
/**
|
|
@@ -976,7 +1226,9 @@ function countChildren(children) {
|
|
|
976
1226
|
*/
|
|
977
1227
|
function toArray(children) {
|
|
978
1228
|
var result = [];
|
|
979
|
-
mapIntoWithKeyPrefixInternal(children, result, null,
|
|
1229
|
+
mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
|
|
1230
|
+
return child;
|
|
1231
|
+
});
|
|
980
1232
|
return result;
|
|
981
1233
|
}
|
|
982
1234
|
|
|
@@ -999,31 +1251,35 @@ function onlyChild(children) {
|
|
|
999
1251
|
return children;
|
|
1000
1252
|
}
|
|
1001
1253
|
|
|
1254
|
+
function readContext(context, observedBits) {
|
|
1255
|
+
var dispatcher = ReactCurrentOwner.currentDispatcher;
|
|
1256
|
+
!(dispatcher !== null) ? invariant(false, 'Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0;
|
|
1257
|
+
return dispatcher.readContext(context, observedBits);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1002
1260
|
function createContext(defaultValue, calculateChangedBits) {
|
|
1003
1261
|
if (calculateChangedBits === undefined) {
|
|
1004
1262
|
calculateChangedBits = null;
|
|
1005
1263
|
} else {
|
|
1006
1264
|
{
|
|
1007
|
-
!(calculateChangedBits === null || typeof calculateChangedBits === 'function') ?
|
|
1265
|
+
!(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
|
|
1008
1266
|
}
|
|
1009
1267
|
}
|
|
1010
1268
|
|
|
1011
1269
|
var context = {
|
|
1012
1270
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
1013
1271
|
_calculateChangedBits: calculateChangedBits,
|
|
1014
|
-
_defaultValue: defaultValue,
|
|
1015
|
-
_currentValue: defaultValue,
|
|
1016
1272
|
// As a workaround to support multiple concurrent renderers, we categorize
|
|
1017
1273
|
// some renderers as primary and others as secondary. We only expect
|
|
1018
1274
|
// there to be two concurrent renderers at most: React Native (primary) and
|
|
1019
1275
|
// Fabric (secondary); React DOM (primary) and React ART (secondary).
|
|
1020
1276
|
// Secondary renderers store their context values on separate fields.
|
|
1277
|
+
_currentValue: defaultValue,
|
|
1021
1278
|
_currentValue2: defaultValue,
|
|
1022
|
-
_changedBits: 0,
|
|
1023
|
-
_changedBits2: 0,
|
|
1024
1279
|
// These are circular
|
|
1025
1280
|
Provider: null,
|
|
1026
|
-
Consumer: null
|
|
1281
|
+
Consumer: null,
|
|
1282
|
+
unstable_read: null
|
|
1027
1283
|
};
|
|
1028
1284
|
|
|
1029
1285
|
context.Provider = {
|
|
@@ -1031,6 +1287,7 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1031
1287
|
_context: context
|
|
1032
1288
|
};
|
|
1033
1289
|
context.Consumer = context;
|
|
1290
|
+
context.unstable_read = readContext.bind(null, context);
|
|
1034
1291
|
|
|
1035
1292
|
{
|
|
1036
1293
|
context._currentRenderer = null;
|
|
@@ -1040,12 +1297,34 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1040
1297
|
return context;
|
|
1041
1298
|
}
|
|
1042
1299
|
|
|
1300
|
+
function lazy(ctor) {
|
|
1301
|
+
var thenable = null;
|
|
1302
|
+
return {
|
|
1303
|
+
then: function (resolve, reject) {
|
|
1304
|
+
if (thenable === null) {
|
|
1305
|
+
// Lazily create thenable by wrapping in an extra thenable.
|
|
1306
|
+
thenable = ctor();
|
|
1307
|
+
ctor = null;
|
|
1308
|
+
}
|
|
1309
|
+
return thenable.then(resolve, reject);
|
|
1310
|
+
},
|
|
1311
|
+
|
|
1312
|
+
// React uses these fields to store the result.
|
|
1313
|
+
_reactStatus: -1,
|
|
1314
|
+
_reactResult: null
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1043
1318
|
function forwardRef(render) {
|
|
1044
1319
|
{
|
|
1045
|
-
|
|
1320
|
+
if (typeof render !== 'function') {
|
|
1321
|
+
warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
|
1322
|
+
} else {
|
|
1323
|
+
!(render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept two parameters: props and ref. ' + 'Did you forget to use the ref parameter?') : void 0;
|
|
1324
|
+
}
|
|
1046
1325
|
|
|
1047
1326
|
if (render != null) {
|
|
1048
|
-
!(render.defaultProps == null && render.propTypes == null) ?
|
|
1327
|
+
!(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
|
|
1049
1328
|
}
|
|
1050
1329
|
}
|
|
1051
1330
|
|
|
@@ -1055,51 +1334,10 @@ function forwardRef(render) {
|
|
|
1055
1334
|
};
|
|
1056
1335
|
}
|
|
1057
1336
|
|
|
1058
|
-
var describeComponentFrame = function (name, source, ownerName) {
|
|
1059
|
-
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
|
|
1060
|
-
};
|
|
1061
|
-
|
|
1062
1337
|
function isValidElementType(type) {
|
|
1063
1338
|
return typeof type === 'string' || typeof type === 'function' ||
|
|
1064
1339
|
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1065
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type ===
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
function getComponentName(fiber) {
|
|
1069
|
-
var type = fiber.type;
|
|
1070
|
-
|
|
1071
|
-
if (typeof type === 'function') {
|
|
1072
|
-
return type.displayName || type.name;
|
|
1073
|
-
}
|
|
1074
|
-
if (typeof type === 'string') {
|
|
1075
|
-
return type;
|
|
1076
|
-
}
|
|
1077
|
-
switch (type) {
|
|
1078
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
1079
|
-
return 'AsyncMode';
|
|
1080
|
-
case REACT_CONTEXT_TYPE:
|
|
1081
|
-
return 'Context.Consumer';
|
|
1082
|
-
case REACT_FRAGMENT_TYPE:
|
|
1083
|
-
return 'ReactFragment';
|
|
1084
|
-
case REACT_PORTAL_TYPE:
|
|
1085
|
-
return 'ReactPortal';
|
|
1086
|
-
case REACT_PROFILER_TYPE:
|
|
1087
|
-
return 'Profiler(' + fiber.pendingProps.id + ')';
|
|
1088
|
-
case REACT_PROVIDER_TYPE:
|
|
1089
|
-
return 'Context.Provider';
|
|
1090
|
-
case REACT_STRICT_MODE_TYPE:
|
|
1091
|
-
return 'StrictMode';
|
|
1092
|
-
case REACT_TIMEOUT_TYPE:
|
|
1093
|
-
return 'Timeout';
|
|
1094
|
-
}
|
|
1095
|
-
if (typeof type === 'object' && type !== null) {
|
|
1096
|
-
switch (type.$$typeof) {
|
|
1097
|
-
case REACT_FORWARD_REF_TYPE:
|
|
1098
|
-
var functionName = type.render.displayName || type.render.name || '';
|
|
1099
|
-
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
return null;
|
|
1340
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
|
1103
1341
|
}
|
|
1104
1342
|
|
|
1105
1343
|
/**
|
|
@@ -1109,52 +1347,15 @@ function getComponentName(fiber) {
|
|
|
1109
1347
|
* that support it.
|
|
1110
1348
|
*/
|
|
1111
1349
|
|
|
1112
|
-
var currentlyValidatingElement = void 0;
|
|
1113
1350
|
var propTypesMisspellWarningShown = void 0;
|
|
1114
1351
|
|
|
1115
|
-
var getDisplayName = function () {};
|
|
1116
|
-
var getStackAddendum = function () {};
|
|
1117
|
-
|
|
1118
1352
|
{
|
|
1119
|
-
currentlyValidatingElement = null;
|
|
1120
|
-
|
|
1121
1353
|
propTypesMisspellWarningShown = false;
|
|
1122
|
-
|
|
1123
|
-
getDisplayName = function (element) {
|
|
1124
|
-
if (element == null) {
|
|
1125
|
-
return '#empty';
|
|
1126
|
-
} else if (typeof element === 'string' || typeof element === 'number') {
|
|
1127
|
-
return '#text';
|
|
1128
|
-
} else if (typeof element.type === 'string') {
|
|
1129
|
-
return element.type;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
var type = element.type;
|
|
1133
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
|
1134
|
-
return 'React.Fragment';
|
|
1135
|
-
} else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
|
|
1136
|
-
var functionName = type.render.displayName || type.render.name || '';
|
|
1137
|
-
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
1138
|
-
} else {
|
|
1139
|
-
return type.displayName || type.name || 'Unknown';
|
|
1140
|
-
}
|
|
1141
|
-
};
|
|
1142
|
-
|
|
1143
|
-
getStackAddendum = function () {
|
|
1144
|
-
var stack = '';
|
|
1145
|
-
if (currentlyValidatingElement) {
|
|
1146
|
-
var name = getDisplayName(currentlyValidatingElement);
|
|
1147
|
-
var owner = currentlyValidatingElement._owner;
|
|
1148
|
-
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
|
|
1149
|
-
}
|
|
1150
|
-
stack += ReactDebugCurrentFrame.getStackAddendum() || '';
|
|
1151
|
-
return stack;
|
|
1152
|
-
};
|
|
1153
1354
|
}
|
|
1154
1355
|
|
|
1155
1356
|
function getDeclarationErrorAddendum() {
|
|
1156
1357
|
if (ReactCurrentOwner.current) {
|
|
1157
|
-
var name = getComponentName(ReactCurrentOwner.current);
|
|
1358
|
+
var name = getComponentName(ReactCurrentOwner.current.type);
|
|
1158
1359
|
if (name) {
|
|
1159
1360
|
return '\n\nCheck the render method of `' + name + '`.';
|
|
1160
1361
|
}
|
|
@@ -1220,14 +1421,14 @@ function validateExplicitKey(element, parentType) {
|
|
|
1220
1421
|
var childOwner = '';
|
|
1221
1422
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
1222
1423
|
// Give the component that originally created this child.
|
|
1223
|
-
childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
|
|
1424
|
+
childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
|
|
1224
1425
|
}
|
|
1225
1426
|
|
|
1226
|
-
|
|
1427
|
+
setCurrentlyValidatingElement(element);
|
|
1227
1428
|
{
|
|
1228
|
-
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
|
|
1429
|
+
warning$1(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.', currentComponentErrorInfo, childOwner);
|
|
1229
1430
|
}
|
|
1230
|
-
|
|
1431
|
+
setCurrentlyValidatingElement(null);
|
|
1231
1432
|
}
|
|
1232
1433
|
|
|
1233
1434
|
/**
|
|
@@ -1296,15 +1497,15 @@ function validatePropTypes(element) {
|
|
|
1296
1497
|
return;
|
|
1297
1498
|
}
|
|
1298
1499
|
if (propTypes) {
|
|
1299
|
-
|
|
1300
|
-
checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum);
|
|
1301
|
-
|
|
1500
|
+
setCurrentlyValidatingElement(element);
|
|
1501
|
+
checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
|
|
1502
|
+
setCurrentlyValidatingElement(null);
|
|
1302
1503
|
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1303
1504
|
propTypesMisspellWarningShown = true;
|
|
1304
|
-
|
|
1505
|
+
warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
|
1305
1506
|
}
|
|
1306
1507
|
if (typeof type.getDefaultProps === 'function') {
|
|
1307
|
-
!type.getDefaultProps.isReactClassApproved ?
|
|
1508
|
+
!type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
|
|
1308
1509
|
}
|
|
1309
1510
|
}
|
|
1310
1511
|
|
|
@@ -1313,22 +1514,22 @@ function validatePropTypes(element) {
|
|
|
1313
1514
|
* @param {ReactElement} fragment
|
|
1314
1515
|
*/
|
|
1315
1516
|
function validateFragmentProps(fragment) {
|
|
1316
|
-
|
|
1517
|
+
setCurrentlyValidatingElement(fragment);
|
|
1317
1518
|
|
|
1318
1519
|
var keys = Object.keys(fragment.props);
|
|
1319
1520
|
for (var i = 0; i < keys.length; i++) {
|
|
1320
1521
|
var key = keys[i];
|
|
1321
1522
|
if (key !== 'children' && key !== 'key') {
|
|
1322
|
-
warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props
|
|
1523
|
+
warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1323
1524
|
break;
|
|
1324
1525
|
}
|
|
1325
1526
|
}
|
|
1326
1527
|
|
|
1327
1528
|
if (fragment.ref !== null) {
|
|
1328
|
-
warning(false, 'Invalid attribute `ref` supplied to `React.Fragment
|
|
1529
|
+
warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
1329
1530
|
}
|
|
1330
1531
|
|
|
1331
|
-
|
|
1532
|
+
setCurrentlyValidatingElement(null);
|
|
1332
1533
|
}
|
|
1333
1534
|
|
|
1334
1535
|
function createElementWithValidation(type, props, children) {
|
|
@@ -1349,18 +1550,19 @@ function createElementWithValidation(type, props, children) {
|
|
|
1349
1550
|
info += getDeclarationErrorAddendum();
|
|
1350
1551
|
}
|
|
1351
1552
|
|
|
1352
|
-
info += getStackAddendum() || '';
|
|
1353
|
-
|
|
1354
1553
|
var typeString = void 0;
|
|
1355
1554
|
if (type === null) {
|
|
1356
1555
|
typeString = 'null';
|
|
1357
1556
|
} else if (Array.isArray(type)) {
|
|
1358
1557
|
typeString = 'array';
|
|
1558
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1559
|
+
typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
|
|
1560
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1359
1561
|
} else {
|
|
1360
1562
|
typeString = typeof type;
|
|
1361
1563
|
}
|
|
1362
1564
|
|
|
1363
|
-
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);
|
|
1565
|
+
warning$1(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);
|
|
1364
1566
|
}
|
|
1365
1567
|
|
|
1366
1568
|
var element = createElement.apply(this, arguments);
|
|
@@ -1448,25 +1650,12 @@ var React = {
|
|
|
1448
1650
|
|
|
1449
1651
|
version: ReactVersion,
|
|
1450
1652
|
|
|
1451
|
-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:
|
|
1452
|
-
ReactCurrentOwner: ReactCurrentOwner,
|
|
1453
|
-
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
1454
|
-
assign: _assign
|
|
1455
|
-
}
|
|
1653
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
|
|
1456
1654
|
};
|
|
1457
1655
|
|
|
1458
1656
|
if (enableSuspense) {
|
|
1459
|
-
React.
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
{
|
|
1463
|
-
_assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
|
1464
|
-
// These should not be included in production.
|
|
1465
|
-
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
|
1466
|
-
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
|
|
1467
|
-
// TODO: remove in React 17.0.
|
|
1468
|
-
ReactComponentTreeHook: {}
|
|
1469
|
-
});
|
|
1657
|
+
React.Placeholder = REACT_PLACEHOLDER_TYPE;
|
|
1658
|
+
React.lazy = lazy;
|
|
1470
1659
|
}
|
|
1471
1660
|
|
|
1472
1661
|
|
|
@@ -1479,7 +1668,7 @@ var React$3 = ( React$2 && React ) || React$2;
|
|
|
1479
1668
|
|
|
1480
1669
|
// TODO: decide on the top-level export form.
|
|
1481
1670
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
1482
|
-
var react = React$3.default
|
|
1671
|
+
var react = React$3.default || React$3;
|
|
1483
1672
|
|
|
1484
1673
|
module.exports = react;
|
|
1485
1674
|
})();
|