react-test-renderer 16.9.0-rc.0 → 16.10.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/build-info.json +5 -5
- package/cjs/react-test-renderer-shallow.development.js +240 -160
- package/cjs/react-test-renderer-shallow.production.min.js +26 -26
- package/cjs/react-test-renderer.development.js +4880 -2970
- package/cjs/react-test-renderer.production.min.js +173 -164
- package/package.json +3 -3
- package/umd/react-test-renderer-shallow.development.js +257 -166
- package/umd/react-test-renderer-shallow.production.min.js +23 -23
- package/umd/react-test-renderer.development.js +4893 -2974
- package/umd/react-test-renderer.production.min.js +143 -140
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.10.2
|
|
2
2
|
* react-test-renderer-shallow.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -22,29 +22,26 @@
|
|
|
22
22
|
// Do not require this module directly! Use normal `invariant` calls with
|
|
23
23
|
// template literal strings. The messages will be converted to ReactError during
|
|
24
24
|
// build, and in production they will be minified.
|
|
25
|
-
|
|
26
25
|
function ReactError(error) {
|
|
27
26
|
error.name = 'Invariant Violation';
|
|
28
27
|
return error;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
32
|
-
|
|
33
31
|
var _assign = ReactInternals.assign;
|
|
34
32
|
|
|
35
33
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
36
34
|
// nor polyfill, then a plain number is used for performance.
|
|
37
35
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
38
|
-
|
|
39
36
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
40
37
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
41
38
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
42
39
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
43
40
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
44
41
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
45
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
46
|
-
// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
42
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
47
43
|
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
44
|
+
|
|
48
45
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
49
46
|
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
50
47
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
@@ -66,7 +63,6 @@ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
|
66
63
|
* paths. Removing the logging code for production environments will keep the
|
|
67
64
|
* same logic and follow the same code paths.
|
|
68
65
|
*/
|
|
69
|
-
|
|
70
66
|
{
|
|
71
67
|
|
|
72
68
|
}
|
|
@@ -74,6 +70,7 @@ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
|
74
70
|
function typeOf(object) {
|
|
75
71
|
if (typeof object === 'object' && object !== null) {
|
|
76
72
|
var $$typeof = object.$$typeof;
|
|
73
|
+
|
|
77
74
|
switch ($$typeof) {
|
|
78
75
|
case REACT_ELEMENT_TYPE:
|
|
79
76
|
var type = object.type;
|
|
@@ -86,6 +83,7 @@ function typeOf(object) {
|
|
|
86
83
|
case REACT_STRICT_MODE_TYPE:
|
|
87
84
|
case REACT_SUSPENSE_TYPE:
|
|
88
85
|
return type;
|
|
86
|
+
|
|
89
87
|
default:
|
|
90
88
|
var $$typeofType = type && type.$$typeof;
|
|
91
89
|
|
|
@@ -94,10 +92,13 @@ function typeOf(object) {
|
|
|
94
92
|
case REACT_FORWARD_REF_TYPE:
|
|
95
93
|
case REACT_PROVIDER_TYPE:
|
|
96
94
|
return $$typeofType;
|
|
95
|
+
|
|
97
96
|
default:
|
|
98
97
|
return $$typeof;
|
|
99
98
|
}
|
|
99
|
+
|
|
100
100
|
}
|
|
101
|
+
|
|
101
102
|
case REACT_LAZY_TYPE:
|
|
102
103
|
case REACT_MEMO_TYPE:
|
|
103
104
|
case REACT_PORTAL_TYPE:
|
|
@@ -106,9 +107,8 @@ function typeOf(object) {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
return undefined;
|
|
109
|
-
}
|
|
110
|
+
} // AsyncMode is deprecated along with isAsyncMode
|
|
110
111
|
|
|
111
|
-
// AsyncMode is deprecated along with isAsyncMode
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
|
|
@@ -123,8 +123,6 @@ var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
// AsyncMode should be deprecated
|
|
127
|
-
|
|
128
126
|
|
|
129
127
|
|
|
130
128
|
|
|
@@ -139,19 +137,22 @@ function isMemo(object) {
|
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
142
|
-
|
|
143
140
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
144
141
|
var sourceInfo = '';
|
|
142
|
+
|
|
145
143
|
if (source) {
|
|
146
144
|
var path = source.fileName;
|
|
147
145
|
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
146
|
+
|
|
148
147
|
{
|
|
149
148
|
// In DEV, include code for a common special case:
|
|
150
149
|
// prefer "folder/index.js" instead of just "index.js".
|
|
151
150
|
if (/^index\./.test(fileName)) {
|
|
152
151
|
var match = path.match(BEFORE_SLASH_RE);
|
|
152
|
+
|
|
153
153
|
if (match) {
|
|
154
154
|
var pathBeforeSlash = match[1];
|
|
155
|
+
|
|
155
156
|
if (pathBeforeSlash) {
|
|
156
157
|
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
157
158
|
fileName = folderName + '/' + fileName;
|
|
@@ -159,10 +160,12 @@ var describeComponentFrame = function (name, source, ownerName) {
|
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
}
|
|
163
|
+
|
|
162
164
|
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
163
165
|
} else if (ownerName) {
|
|
164
166
|
sourceInfo = ' (created by ' + ownerName + ')';
|
|
165
167
|
}
|
|
168
|
+
|
|
166
169
|
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
167
170
|
};
|
|
168
171
|
|
|
@@ -172,35 +175,37 @@ var describeComponentFrame = function (name, source, ownerName) {
|
|
|
172
175
|
* paths. Removing the logging code for production environments will keep the
|
|
173
176
|
* same logic and follow the same code paths.
|
|
174
177
|
*/
|
|
175
|
-
|
|
176
178
|
var warningWithoutStack = function () {};
|
|
177
179
|
|
|
178
180
|
{
|
|
179
181
|
warningWithoutStack = function (condition, format) {
|
|
180
|
-
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
182
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
181
183
|
args[_key - 2] = arguments[_key];
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
if (format === undefined) {
|
|
185
187
|
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
186
188
|
}
|
|
189
|
+
|
|
187
190
|
if (args.length > 8) {
|
|
188
191
|
// Check before the condition to catch violations early.
|
|
189
192
|
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
190
193
|
}
|
|
194
|
+
|
|
191
195
|
if (condition) {
|
|
192
196
|
return;
|
|
193
197
|
}
|
|
198
|
+
|
|
194
199
|
if (typeof console !== 'undefined') {
|
|
195
200
|
var argsWithFormat = args.map(function (item) {
|
|
196
201
|
return '' + item;
|
|
197
202
|
});
|
|
198
|
-
argsWithFormat.unshift('Warning: ' + format);
|
|
199
|
-
|
|
200
|
-
// We intentionally don't use spread (or .apply) directly because it
|
|
203
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
201
204
|
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
205
|
+
|
|
202
206
|
Function.prototype.apply.call(console.error, console, argsWithFormat);
|
|
203
207
|
}
|
|
208
|
+
|
|
204
209
|
try {
|
|
205
210
|
// --- Welcome to debugging React ---
|
|
206
211
|
// This error was thrown as a convenience so that you can use this stack
|
|
@@ -216,8 +221,51 @@ var warningWithoutStack = function () {};
|
|
|
216
221
|
|
|
217
222
|
var warningWithoutStack$1 = warningWithoutStack;
|
|
218
223
|
|
|
219
|
-
var
|
|
224
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
|
|
225
|
+
// Current owner and dispatcher used to share the same ref,
|
|
226
|
+
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
227
|
+
|
|
228
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
229
|
+
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
230
|
+
current: null
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
|
235
|
+
ReactSharedInternals.ReactCurrentBatchConfig = {
|
|
236
|
+
suspense: null
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
242
|
+
* This can be used to log issues in development environments in critical
|
|
243
|
+
* paths. Removing the logging code for production environments will keep the
|
|
244
|
+
* same logic and follow the same code paths.
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
var warning = warningWithoutStack$1;
|
|
248
|
+
|
|
249
|
+
{
|
|
250
|
+
warning = function (condition, format) {
|
|
251
|
+
if (condition) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
256
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
257
|
+
|
|
258
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
259
|
+
args[_key - 2] = arguments[_key];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
|
|
263
|
+
};
|
|
264
|
+
}
|
|
220
265
|
|
|
266
|
+
var warning$1 = warning;
|
|
267
|
+
|
|
268
|
+
var Resolved = 1;
|
|
221
269
|
|
|
222
270
|
function refineResolvedLazyComponent(lazyComponent) {
|
|
223
271
|
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
@@ -225,7 +273,7 @@ function refineResolvedLazyComponent(lazyComponent) {
|
|
|
225
273
|
|
|
226
274
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
227
275
|
var functionName = innerType.displayName || innerType.name || '';
|
|
228
|
-
return outerType.displayName || (functionName !== '' ? wrapperName +
|
|
276
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
229
277
|
}
|
|
230
278
|
|
|
231
279
|
function getComponentName(type) {
|
|
@@ -233,52 +281,69 @@ function getComponentName(type) {
|
|
|
233
281
|
// Host root, text node or just invalid type.
|
|
234
282
|
return null;
|
|
235
283
|
}
|
|
284
|
+
|
|
236
285
|
{
|
|
237
286
|
if (typeof type.tag === 'number') {
|
|
238
287
|
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
239
288
|
}
|
|
240
289
|
}
|
|
290
|
+
|
|
241
291
|
if (typeof type === 'function') {
|
|
242
292
|
return type.displayName || type.name || null;
|
|
243
293
|
}
|
|
294
|
+
|
|
244
295
|
if (typeof type === 'string') {
|
|
245
296
|
return type;
|
|
246
297
|
}
|
|
298
|
+
|
|
247
299
|
switch (type) {
|
|
248
300
|
case REACT_FRAGMENT_TYPE:
|
|
249
301
|
return 'Fragment';
|
|
302
|
+
|
|
250
303
|
case REACT_PORTAL_TYPE:
|
|
251
304
|
return 'Portal';
|
|
305
|
+
|
|
252
306
|
case REACT_PROFILER_TYPE:
|
|
253
|
-
return
|
|
307
|
+
return "Profiler";
|
|
308
|
+
|
|
254
309
|
case REACT_STRICT_MODE_TYPE:
|
|
255
310
|
return 'StrictMode';
|
|
311
|
+
|
|
256
312
|
case REACT_SUSPENSE_TYPE:
|
|
257
313
|
return 'Suspense';
|
|
314
|
+
|
|
258
315
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
259
316
|
return 'SuspenseList';
|
|
260
317
|
}
|
|
318
|
+
|
|
261
319
|
if (typeof type === 'object') {
|
|
262
320
|
switch (type.$$typeof) {
|
|
263
321
|
case REACT_CONTEXT_TYPE:
|
|
264
322
|
return 'Context.Consumer';
|
|
323
|
+
|
|
265
324
|
case REACT_PROVIDER_TYPE:
|
|
266
325
|
return 'Context.Provider';
|
|
326
|
+
|
|
267
327
|
case REACT_FORWARD_REF_TYPE:
|
|
268
328
|
return getWrappedName(type, type.render, 'ForwardRef');
|
|
329
|
+
|
|
269
330
|
case REACT_MEMO_TYPE:
|
|
270
331
|
return getComponentName(type.type);
|
|
332
|
+
|
|
271
333
|
case REACT_LAZY_TYPE:
|
|
272
334
|
{
|
|
273
335
|
var thenable = type;
|
|
274
336
|
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
337
|
+
|
|
275
338
|
if (resolvedThenable) {
|
|
276
339
|
return getComponentName(resolvedThenable);
|
|
277
340
|
}
|
|
341
|
+
|
|
278
342
|
break;
|
|
279
343
|
}
|
|
280
344
|
}
|
|
281
345
|
}
|
|
346
|
+
|
|
282
347
|
return null;
|
|
283
348
|
}
|
|
284
349
|
|
|
@@ -291,15 +356,17 @@ function is(x, y) {
|
|
|
291
356
|
;
|
|
292
357
|
}
|
|
293
358
|
|
|
294
|
-
var
|
|
359
|
+
var is$1 = typeof Object.is === 'function' ? Object.is : is;
|
|
295
360
|
|
|
361
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
296
362
|
/**
|
|
297
363
|
* Performs equality by iterating through keys on an object and returning false
|
|
298
364
|
* when any key has values which are not strictly equal between the arguments.
|
|
299
365
|
* Returns true when the values of all keys are strictly equal.
|
|
300
366
|
*/
|
|
367
|
+
|
|
301
368
|
function shallowEqual(objA, objB) {
|
|
302
|
-
if (is(objA, objB)) {
|
|
369
|
+
if (is$1(objA, objB)) {
|
|
303
370
|
return true;
|
|
304
371
|
}
|
|
305
372
|
|
|
@@ -312,11 +379,11 @@ function shallowEqual(objA, objB) {
|
|
|
312
379
|
|
|
313
380
|
if (keysA.length !== keysB.length) {
|
|
314
381
|
return false;
|
|
315
|
-
}
|
|
382
|
+
} // Test for A's keys different from B.
|
|
383
|
+
|
|
316
384
|
|
|
317
|
-
// Test for A's keys different from B.
|
|
318
385
|
for (var i = 0; i < keysA.length; i++) {
|
|
319
|
-
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
386
|
+
if (!hasOwnProperty.call(objB, keysA[i]) || !is$1(objA[keysA[i]], objB[keysA[i]])) {
|
|
320
387
|
return false;
|
|
321
388
|
}
|
|
322
389
|
}
|
|
@@ -362,6 +429,7 @@ var printWarning$1 = function() {};
|
|
|
362
429
|
{
|
|
363
430
|
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
364
431
|
var loggedTypeFailures = {};
|
|
432
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
365
433
|
|
|
366
434
|
printWarning$1 = function(text) {
|
|
367
435
|
var message = 'Warning: ' + text;
|
|
@@ -391,7 +459,7 @@ var printWarning$1 = function() {};
|
|
|
391
459
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
392
460
|
{
|
|
393
461
|
for (var typeSpecName in typeSpecs) {
|
|
394
|
-
if (typeSpecs
|
|
462
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
395
463
|
var error;
|
|
396
464
|
// Prop type validation may throw. In case they do, we don't want to
|
|
397
465
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -420,7 +488,6 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
420
488
|
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
421
489
|
'shape all require an argument).'
|
|
422
490
|
);
|
|
423
|
-
|
|
424
491
|
}
|
|
425
492
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
426
493
|
// Only monitor this failure once because there tends to be a lot of the
|
|
@@ -438,96 +505,64 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
438
505
|
}
|
|
439
506
|
}
|
|
440
507
|
|
|
441
|
-
var checkPropTypes_1 = checkPropTypes;
|
|
442
|
-
|
|
443
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
444
|
-
|
|
445
|
-
// Prevent newer renderers from RTE when used with older react package versions.
|
|
446
|
-
// Current owner and dispatcher used to share the same ref,
|
|
447
|
-
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
448
|
-
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
449
|
-
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
450
|
-
current: null
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
|
454
|
-
ReactSharedInternals.ReactCurrentBatchConfig = {
|
|
455
|
-
suspense: null
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
|
|
459
508
|
/**
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* same logic and follow the same code paths.
|
|
509
|
+
* Resets warning cache when testing.
|
|
510
|
+
*
|
|
511
|
+
* @private
|
|
464
512
|
*/
|
|
513
|
+
checkPropTypes.resetWarningCache = function() {
|
|
514
|
+
{
|
|
515
|
+
loggedTypeFailures = {};
|
|
516
|
+
}
|
|
517
|
+
};
|
|
465
518
|
|
|
466
|
-
var
|
|
467
|
-
|
|
468
|
-
{
|
|
469
|
-
warning = function (condition, format) {
|
|
470
|
-
if (condition) {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
474
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
475
|
-
// eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
476
|
-
|
|
477
|
-
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
478
|
-
args[_key - 2] = arguments[_key];
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
var warning$1 = warning;
|
|
486
|
-
|
|
487
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
519
|
+
var checkPropTypes_1 = checkPropTypes;
|
|
488
520
|
|
|
489
521
|
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
490
|
-
|
|
491
|
-
|
|
492
522
|
var RE_RENDER_LIMIT = 25;
|
|
493
|
-
|
|
494
523
|
var emptyObject = {};
|
|
524
|
+
|
|
495
525
|
{
|
|
496
526
|
Object.freeze(emptyObject);
|
|
497
|
-
}
|
|
527
|
+
} // In DEV, this is the name of the currently executing primitive hook
|
|
528
|
+
|
|
498
529
|
|
|
499
|
-
|
|
500
|
-
var currentHookNameInDev = void 0;
|
|
530
|
+
var currentHookNameInDev;
|
|
501
531
|
|
|
502
532
|
function areHookInputsEqual(nextDeps, prevDeps) {
|
|
503
533
|
if (prevDeps === null) {
|
|
504
534
|
warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
|
|
505
535
|
return false;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Don't bother comparing lengths in prod because these arrays should be
|
|
536
|
+
} // Don't bother comparing lengths in prod because these arrays should be
|
|
509
537
|
// passed inline.
|
|
538
|
+
|
|
539
|
+
|
|
510
540
|
if (nextDeps.length !== prevDeps.length) {
|
|
511
|
-
warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev,
|
|
541
|
+
warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + nextDeps.join(', ') + "]", "[" + prevDeps.join(', ') + "]");
|
|
512
542
|
}
|
|
543
|
+
|
|
513
544
|
for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
|
514
|
-
if (is(nextDeps[i], prevDeps[i])) {
|
|
545
|
+
if (is$1(nextDeps[i], prevDeps[i])) {
|
|
515
546
|
continue;
|
|
516
547
|
}
|
|
548
|
+
|
|
517
549
|
return false;
|
|
518
550
|
}
|
|
551
|
+
|
|
519
552
|
return true;
|
|
520
553
|
}
|
|
521
554
|
|
|
522
|
-
var Updater =
|
|
555
|
+
var Updater =
|
|
556
|
+
/*#__PURE__*/
|
|
557
|
+
function () {
|
|
523
558
|
function Updater(renderer) {
|
|
524
|
-
_classCallCheck(this, Updater);
|
|
525
|
-
|
|
526
559
|
this._renderer = renderer;
|
|
527
560
|
this._callbacks = [];
|
|
528
561
|
}
|
|
529
562
|
|
|
530
|
-
Updater.prototype
|
|
563
|
+
var _proto = Updater.prototype;
|
|
564
|
+
|
|
565
|
+
_proto._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
|
|
531
566
|
if (typeof callback === 'function' && publicInstance) {
|
|
532
567
|
this._callbacks.push({
|
|
533
568
|
callback: callback,
|
|
@@ -536,48 +571,51 @@ var Updater = function () {
|
|
|
536
571
|
}
|
|
537
572
|
};
|
|
538
573
|
|
|
539
|
-
|
|
574
|
+
_proto._invokeCallbacks = function _invokeCallbacks() {
|
|
540
575
|
var callbacks = this._callbacks;
|
|
541
576
|
this._callbacks = [];
|
|
542
|
-
|
|
543
577
|
callbacks.forEach(function (_ref) {
|
|
544
578
|
var callback = _ref.callback,
|
|
545
579
|
publicInstance = _ref.publicInstance;
|
|
546
|
-
|
|
547
580
|
callback.call(publicInstance);
|
|
548
581
|
});
|
|
549
582
|
};
|
|
550
583
|
|
|
551
|
-
|
|
584
|
+
_proto.isMounted = function isMounted(publicInstance) {
|
|
552
585
|
return !!this._renderer._element;
|
|
553
586
|
};
|
|
554
587
|
|
|
555
|
-
|
|
588
|
+
_proto.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
|
|
556
589
|
this._enqueueCallback(callback, publicInstance);
|
|
590
|
+
|
|
557
591
|
this._renderer._forcedUpdate = true;
|
|
592
|
+
|
|
558
593
|
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
559
594
|
};
|
|
560
595
|
|
|
561
|
-
|
|
596
|
+
_proto.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
|
|
562
597
|
this._enqueueCallback(callback, publicInstance);
|
|
598
|
+
|
|
563
599
|
this._renderer._newState = completeState;
|
|
600
|
+
|
|
564
601
|
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
565
602
|
};
|
|
566
603
|
|
|
567
|
-
|
|
604
|
+
_proto.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
|
|
568
605
|
this._enqueueCallback(callback, publicInstance);
|
|
606
|
+
|
|
569
607
|
var currentState = this._renderer._newState || publicInstance.state;
|
|
570
608
|
|
|
571
609
|
if (typeof partialState === 'function') {
|
|
572
610
|
partialState = partialState.call(publicInstance, currentState, publicInstance.props);
|
|
573
|
-
}
|
|
611
|
+
} // Null and undefined are treated as no-ops.
|
|
612
|
+
|
|
574
613
|
|
|
575
|
-
// Null and undefined are treated as no-ops.
|
|
576
614
|
if (partialState === null || partialState === undefined) {
|
|
577
615
|
return;
|
|
578
616
|
}
|
|
579
617
|
|
|
580
|
-
this._renderer._newState = _assign({}, currentState, partialState);
|
|
618
|
+
this._renderer._newState = _assign({}, currentState, {}, partialState);
|
|
581
619
|
|
|
582
620
|
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
583
621
|
};
|
|
@@ -597,14 +635,16 @@ function basicStateReducer(state, action) {
|
|
|
597
635
|
return typeof action === 'function' ? action(state) : action;
|
|
598
636
|
}
|
|
599
637
|
|
|
600
|
-
var ReactShallowRenderer =
|
|
638
|
+
var ReactShallowRenderer =
|
|
639
|
+
/*#__PURE__*/
|
|
640
|
+
function () {
|
|
601
641
|
function ReactShallowRenderer() {
|
|
602
|
-
_classCallCheck(this, ReactShallowRenderer);
|
|
603
|
-
|
|
604
642
|
this._reset();
|
|
605
643
|
}
|
|
606
644
|
|
|
607
|
-
ReactShallowRenderer.prototype
|
|
645
|
+
var _proto2 = ReactShallowRenderer.prototype;
|
|
646
|
+
|
|
647
|
+
_proto2._reset = function _reset() {
|
|
608
648
|
this._context = null;
|
|
609
649
|
this._element = null;
|
|
610
650
|
this._instance = null;
|
|
@@ -622,89 +662,106 @@ var ReactShallowRenderer = function () {
|
|
|
622
662
|
this._numberOfReRenders = 0;
|
|
623
663
|
};
|
|
624
664
|
|
|
625
|
-
|
|
665
|
+
_proto2._validateCurrentlyRenderingComponent = function _validateCurrentlyRenderingComponent() {
|
|
626
666
|
var _this = this;
|
|
627
667
|
|
|
628
668
|
(function () {
|
|
629
669
|
if (!(_this._rendering && !_this._instance)) {
|
|
630
670
|
{
|
|
631
|
-
throw ReactError(Error(
|
|
671
|
+
throw ReactError(Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem."));
|
|
632
672
|
}
|
|
633
673
|
}
|
|
634
674
|
})();
|
|
635
675
|
};
|
|
636
676
|
|
|
637
|
-
|
|
677
|
+
_proto2._createDispatcher = function _createDispatcher() {
|
|
638
678
|
var _this2 = this;
|
|
639
679
|
|
|
640
680
|
var useReducer = function (reducer, initialArg, init) {
|
|
641
681
|
_this2._validateCurrentlyRenderingComponent();
|
|
682
|
+
|
|
642
683
|
_this2._createWorkInProgressHook();
|
|
684
|
+
|
|
643
685
|
var workInProgressHook = _this2._workInProgressHook;
|
|
644
686
|
|
|
645
687
|
if (_this2._isReRender) {
|
|
646
688
|
// This is a re-render.
|
|
647
|
-
var
|
|
648
|
-
var
|
|
689
|
+
var queue = workInProgressHook.queue;
|
|
690
|
+
var dispatch = queue.dispatch;
|
|
691
|
+
|
|
649
692
|
if (_this2._numberOfReRenders > 0) {
|
|
650
693
|
// Apply the new render phase updates to the previous current hook.
|
|
651
694
|
if (_this2._renderPhaseUpdates !== null) {
|
|
652
695
|
// Render phase updates are stored in a map of queue -> linked list
|
|
653
|
-
var firstRenderPhaseUpdate = _this2._renderPhaseUpdates.get(
|
|
696
|
+
var firstRenderPhaseUpdate = _this2._renderPhaseUpdates.get(queue);
|
|
697
|
+
|
|
654
698
|
if (firstRenderPhaseUpdate !== undefined) {
|
|
655
|
-
_this2._renderPhaseUpdates.delete(
|
|
699
|
+
_this2._renderPhaseUpdates.delete(queue);
|
|
700
|
+
|
|
656
701
|
var _newState = workInProgressHook.memoizedState;
|
|
657
702
|
var _update = firstRenderPhaseUpdate;
|
|
703
|
+
|
|
658
704
|
do {
|
|
659
|
-
var
|
|
660
|
-
_newState = reducer(_newState,
|
|
705
|
+
var action = _update.action;
|
|
706
|
+
_newState = reducer(_newState, action);
|
|
661
707
|
_update = _update.next;
|
|
662
708
|
} while (_update !== null);
|
|
709
|
+
|
|
663
710
|
workInProgressHook.memoizedState = _newState;
|
|
664
|
-
return [_newState,
|
|
711
|
+
return [_newState, dispatch];
|
|
665
712
|
}
|
|
666
713
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
// Process updates outside of render
|
|
714
|
+
|
|
715
|
+
return [workInProgressHook.memoizedState, dispatch];
|
|
716
|
+
} // Process updates outside of render
|
|
717
|
+
|
|
718
|
+
|
|
670
719
|
var newState = workInProgressHook.memoizedState;
|
|
671
|
-
var update =
|
|
720
|
+
var update = queue.first;
|
|
721
|
+
|
|
672
722
|
if (update !== null) {
|
|
673
723
|
do {
|
|
674
|
-
var
|
|
675
|
-
newState = reducer(newState,
|
|
724
|
+
var _action = update.action;
|
|
725
|
+
newState = reducer(newState, _action);
|
|
676
726
|
update = update.next;
|
|
677
727
|
} while (update !== null);
|
|
678
|
-
|
|
728
|
+
|
|
729
|
+
queue.first = null;
|
|
679
730
|
workInProgressHook.memoizedState = newState;
|
|
680
731
|
}
|
|
681
|
-
|
|
732
|
+
|
|
733
|
+
return [newState, dispatch];
|
|
682
734
|
} else {
|
|
683
|
-
var initialState
|
|
735
|
+
var initialState;
|
|
736
|
+
|
|
684
737
|
if (reducer === basicStateReducer) {
|
|
685
738
|
// Special case for `useState`.
|
|
686
739
|
initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
|
|
687
740
|
} else {
|
|
688
741
|
initialState = init !== undefined ? init(initialArg) : initialArg;
|
|
689
742
|
}
|
|
743
|
+
|
|
690
744
|
workInProgressHook.memoizedState = initialState;
|
|
691
|
-
|
|
745
|
+
|
|
746
|
+
var _queue = workInProgressHook.queue = {
|
|
692
747
|
first: null,
|
|
693
748
|
dispatch: null
|
|
694
749
|
};
|
|
695
|
-
|
|
696
|
-
|
|
750
|
+
|
|
751
|
+
var _dispatch = _queue.dispatch = _this2._dispatchAction.bind(_this2, _queue);
|
|
752
|
+
|
|
753
|
+
return [workInProgressHook.memoizedState, _dispatch];
|
|
697
754
|
}
|
|
698
755
|
};
|
|
699
756
|
|
|
700
757
|
var useState = function (initialState) {
|
|
701
|
-
return useReducer(basicStateReducer,
|
|
702
|
-
// useReducer has a special case to support lazy useState initializers
|
|
758
|
+
return useReducer(basicStateReducer, // useReducer has a special case to support lazy useState initializers
|
|
703
759
|
initialState);
|
|
704
760
|
};
|
|
705
761
|
|
|
706
762
|
var useMemo = function (nextCreate, deps) {
|
|
707
763
|
_this2._validateCurrentlyRenderingComponent();
|
|
764
|
+
|
|
708
765
|
_this2._createWorkInProgressHook();
|
|
709
766
|
|
|
710
767
|
var nextDeps = deps !== undefined ? deps : null;
|
|
@@ -712,6 +769,7 @@ var ReactShallowRenderer = function () {
|
|
|
712
769
|
if (_this2._workInProgressHook !== null && _this2._workInProgressHook.memoizedState !== null) {
|
|
713
770
|
var prevState = _this2._workInProgressHook.memoizedState;
|
|
714
771
|
var prevDeps = prevState[1];
|
|
772
|
+
|
|
715
773
|
if (nextDeps !== null) {
|
|
716
774
|
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
|
717
775
|
return prevState[0];
|
|
@@ -726,13 +784,20 @@ var ReactShallowRenderer = function () {
|
|
|
726
784
|
|
|
727
785
|
var useRef = function (initialValue) {
|
|
728
786
|
_this2._validateCurrentlyRenderingComponent();
|
|
787
|
+
|
|
729
788
|
_this2._createWorkInProgressHook();
|
|
789
|
+
|
|
730
790
|
var previousRef = _this2._workInProgressHook.memoizedState;
|
|
791
|
+
|
|
731
792
|
if (previousRef === null) {
|
|
732
|
-
var ref = {
|
|
793
|
+
var ref = {
|
|
794
|
+
current: initialValue
|
|
795
|
+
};
|
|
796
|
+
|
|
733
797
|
{
|
|
734
798
|
Object.seal(ref);
|
|
735
799
|
}
|
|
800
|
+
|
|
736
801
|
_this2._workInProgressHook.memoizedState = ref;
|
|
737
802
|
return ref;
|
|
738
803
|
} else {
|
|
@@ -764,6 +829,7 @@ var ReactShallowRenderer = function () {
|
|
|
764
829
|
useCallback: identity,
|
|
765
830
|
useContext: function (context) {
|
|
766
831
|
_this2._validateCurrentlyRenderingComponent();
|
|
832
|
+
|
|
767
833
|
return readContext(context);
|
|
768
834
|
},
|
|
769
835
|
useDebugValue: noOp,
|
|
@@ -778,13 +844,13 @@ var ReactShallowRenderer = function () {
|
|
|
778
844
|
};
|
|
779
845
|
};
|
|
780
846
|
|
|
781
|
-
|
|
847
|
+
_proto2._dispatchAction = function _dispatchAction(queue, action) {
|
|
782
848
|
var _this3 = this;
|
|
783
849
|
|
|
784
850
|
(function () {
|
|
785
851
|
if (!(_this3._numberOfReRenders < RE_RENDER_LIMIT)) {
|
|
786
852
|
{
|
|
787
|
-
throw ReactError(Error(
|
|
853
|
+
throw ReactError(Error("Too many re-renders. React limits the number of renders to prevent an infinite loop."));
|
|
788
854
|
}
|
|
789
855
|
}
|
|
790
856
|
})();
|
|
@@ -799,43 +865,49 @@ var ReactShallowRenderer = function () {
|
|
|
799
865
|
next: null
|
|
800
866
|
};
|
|
801
867
|
var renderPhaseUpdates = this._renderPhaseUpdates;
|
|
868
|
+
|
|
802
869
|
if (renderPhaseUpdates === null) {
|
|
803
870
|
this._renderPhaseUpdates = renderPhaseUpdates = new Map();
|
|
804
871
|
}
|
|
872
|
+
|
|
805
873
|
var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
|
|
874
|
+
|
|
806
875
|
if (firstRenderPhaseUpdate === undefined) {
|
|
807
876
|
renderPhaseUpdates.set(queue, update);
|
|
808
877
|
} else {
|
|
809
878
|
// Append the update to the end of the list.
|
|
810
879
|
var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
|
|
880
|
+
|
|
811
881
|
while (lastRenderPhaseUpdate.next !== null) {
|
|
812
882
|
lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
|
813
883
|
}
|
|
884
|
+
|
|
814
885
|
lastRenderPhaseUpdate.next = update;
|
|
815
886
|
}
|
|
816
887
|
} else {
|
|
817
888
|
var _update2 = {
|
|
818
889
|
action: action,
|
|
819
890
|
next: null
|
|
820
|
-
};
|
|
891
|
+
}; // Append the update to the end of the list.
|
|
821
892
|
|
|
822
|
-
// Append the update to the end of the list.
|
|
823
893
|
var last = queue.first;
|
|
894
|
+
|
|
824
895
|
if (last === null) {
|
|
825
896
|
queue.first = _update2;
|
|
826
897
|
} else {
|
|
827
898
|
while (last.next !== null) {
|
|
828
899
|
last = last.next;
|
|
829
900
|
}
|
|
901
|
+
|
|
830
902
|
last.next = _update2;
|
|
831
|
-
}
|
|
903
|
+
} // Re-render now.
|
|
904
|
+
|
|
832
905
|
|
|
833
|
-
// Re-render now.
|
|
834
906
|
this.render(this._element, this._context);
|
|
835
907
|
}
|
|
836
908
|
};
|
|
837
909
|
|
|
838
|
-
|
|
910
|
+
_proto2._createWorkInProgressHook = function _createWorkInProgressHook() {
|
|
839
911
|
if (this._workInProgressHook === null) {
|
|
840
912
|
// This is the first hook in the list
|
|
841
913
|
if (this._firstWorkInProgressHook === null) {
|
|
@@ -848,8 +920,8 @@ var ReactShallowRenderer = function () {
|
|
|
848
920
|
}
|
|
849
921
|
} else {
|
|
850
922
|
if (this._workInProgressHook.next === null) {
|
|
851
|
-
this._isReRender = false;
|
|
852
|
-
|
|
923
|
+
this._isReRender = false; // Append to the end of the list
|
|
924
|
+
|
|
853
925
|
this._workInProgressHook = this._workInProgressHook.next = createHook();
|
|
854
926
|
} else {
|
|
855
927
|
// There's already a work-in-progress. Reuse it.
|
|
@@ -857,19 +929,19 @@ var ReactShallowRenderer = function () {
|
|
|
857
929
|
this._workInProgressHook = this._workInProgressHook.next;
|
|
858
930
|
}
|
|
859
931
|
}
|
|
932
|
+
|
|
860
933
|
return this._workInProgressHook;
|
|
861
934
|
};
|
|
862
935
|
|
|
863
|
-
|
|
936
|
+
_proto2._finishHooks = function _finishHooks(element, context) {
|
|
864
937
|
if (this._didScheduleRenderPhaseUpdate) {
|
|
865
938
|
// Updates were scheduled during the render phase. They are stored in
|
|
866
939
|
// the `renderPhaseUpdates` map. Call the component again, reusing the
|
|
867
940
|
// work-in-progress hooks and applying the additional updates on top. Keep
|
|
868
941
|
// restarting until no more updates are scheduled.
|
|
869
942
|
this._didScheduleRenderPhaseUpdate = false;
|
|
870
|
-
this._numberOfReRenders += 1;
|
|
943
|
+
this._numberOfReRenders += 1; // Start over from the beginning of the list
|
|
871
944
|
|
|
872
|
-
// Start over from the beginning of the list
|
|
873
945
|
this._workInProgressHook = null;
|
|
874
946
|
this._rendering = false;
|
|
875
947
|
this.render(element, context);
|
|
@@ -880,37 +952,39 @@ var ReactShallowRenderer = function () {
|
|
|
880
952
|
}
|
|
881
953
|
};
|
|
882
954
|
|
|
883
|
-
|
|
955
|
+
_proto2.getMountedInstance = function getMountedInstance() {
|
|
884
956
|
return this._instance;
|
|
885
957
|
};
|
|
886
958
|
|
|
887
|
-
|
|
959
|
+
_proto2.getRenderOutput = function getRenderOutput() {
|
|
888
960
|
return this._rendered;
|
|
889
961
|
};
|
|
890
962
|
|
|
891
|
-
|
|
963
|
+
_proto2.render = function render(element) {
|
|
892
964
|
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject;
|
|
893
965
|
|
|
894
966
|
(function () {
|
|
895
967
|
if (!React.isValidElement(element)) {
|
|
896
968
|
{
|
|
897
|
-
throw ReactError(Error(
|
|
969
|
+
throw ReactError(Error("ReactShallowRenderer render(): Invalid component element." + (typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '')));
|
|
898
970
|
}
|
|
899
971
|
}
|
|
900
972
|
})();
|
|
901
|
-
|
|
902
|
-
// Show a special message for host elements since it's a common case.
|
|
973
|
+
|
|
974
|
+
element = element; // Show a special message for host elements since it's a common case.
|
|
975
|
+
|
|
903
976
|
(function () {
|
|
904
977
|
if (!(typeof element.type !== 'string')) {
|
|
905
978
|
{
|
|
906
|
-
throw ReactError(Error(
|
|
979
|
+
throw ReactError(Error("ReactShallowRenderer render(): Shallow rendering works only with custom components, not primitives (" + element.type + "). Instead of calling `.render(el)` and inspecting the rendered output, look at `el.props` directly instead."));
|
|
907
980
|
}
|
|
908
981
|
}
|
|
909
982
|
})();
|
|
983
|
+
|
|
910
984
|
(function () {
|
|
911
985
|
if (!(isForwardRef(element) || typeof element.type === 'function' || isMemo(element.type))) {
|
|
912
986
|
{
|
|
913
|
-
throw ReactError(Error(
|
|
987
|
+
throw ReactError(Error("ReactShallowRenderer render(): Shallow rendering works only with custom components, but the provided element type was `" + (Array.isArray(element.type) ? 'array' : element.type === null ? 'null' : typeof element.type) + "`."));
|
|
914
988
|
}
|
|
915
989
|
}
|
|
916
990
|
})();
|
|
@@ -918,18 +992,17 @@ var ReactShallowRenderer = function () {
|
|
|
918
992
|
if (this._rendering) {
|
|
919
993
|
return;
|
|
920
994
|
}
|
|
995
|
+
|
|
921
996
|
if (this._element != null && this._element.type !== element.type) {
|
|
922
997
|
this._reset();
|
|
923
998
|
}
|
|
924
999
|
|
|
925
1000
|
var elementType = isMemo(element.type) ? element.type.type : element.type;
|
|
926
1001
|
var previousElement = this._element;
|
|
927
|
-
|
|
928
1002
|
this._rendering = true;
|
|
929
1003
|
this._element = element;
|
|
930
|
-
this._context = getMaskedContext(elementType.contextTypes, context);
|
|
1004
|
+
this._context = getMaskedContext(elementType.contextTypes, context); // Inner memo component props aren't currently validated in createElement.
|
|
931
1005
|
|
|
932
|
-
// Inner memo component props aren't currently validated in createElement.
|
|
933
1006
|
if (isMemo(element.type) && elementType.propTypes) {
|
|
934
1007
|
currentlyValidatingElement = element;
|
|
935
1008
|
checkPropTypes_1(elementType.propTypes, element.props, 'prop', getComponentName(elementType), getStackAddendum);
|
|
@@ -940,8 +1013,10 @@ var ReactShallowRenderer = function () {
|
|
|
940
1013
|
} else {
|
|
941
1014
|
if (shouldConstruct(elementType)) {
|
|
942
1015
|
this._instance = new elementType(element.props, this._context, this._updater);
|
|
1016
|
+
|
|
943
1017
|
if (typeof elementType.getDerivedStateFromProps === 'function') {
|
|
944
1018
|
var partialState = elementType.getDerivedStateFromProps.call(null, element.props, this._instance.state);
|
|
1019
|
+
|
|
945
1020
|
if (partialState != null) {
|
|
946
1021
|
this._instance.state = _assign({}, this._instance.state, partialState);
|
|
947
1022
|
}
|
|
@@ -950,23 +1025,26 @@ var ReactShallowRenderer = function () {
|
|
|
950
1025
|
if (elementType.contextTypes) {
|
|
951
1026
|
currentlyValidatingElement = element;
|
|
952
1027
|
checkPropTypes_1(elementType.contextTypes, this._context, 'context', getName(elementType, this._instance), getStackAddendum);
|
|
953
|
-
|
|
954
1028
|
currentlyValidatingElement = null;
|
|
955
1029
|
}
|
|
956
1030
|
|
|
957
1031
|
this._mountClassComponent(elementType, element, this._context);
|
|
958
1032
|
} else {
|
|
959
1033
|
var shouldRender = true;
|
|
1034
|
+
|
|
960
1035
|
if (isMemo(element.type) && previousElement !== null) {
|
|
961
1036
|
// This is a Memo component that is being re-rendered.
|
|
962
1037
|
var compare = element.type.compare || shallowEqual;
|
|
1038
|
+
|
|
963
1039
|
if (compare(previousElement.props, element.props)) {
|
|
964
1040
|
shouldRender = false;
|
|
965
1041
|
}
|
|
966
1042
|
}
|
|
1043
|
+
|
|
967
1044
|
if (shouldRender) {
|
|
968
1045
|
var prevDispatcher = ReactCurrentDispatcher.current;
|
|
969
1046
|
ReactCurrentDispatcher.current = this._dispatcher;
|
|
1047
|
+
|
|
970
1048
|
try {
|
|
971
1049
|
// elementType could still be a ForwardRef if it was
|
|
972
1050
|
// nested inside Memo.
|
|
@@ -974,10 +1052,11 @@ var ReactShallowRenderer = function () {
|
|
|
974
1052
|
(function () {
|
|
975
1053
|
if (!(typeof elementType.render === 'function')) {
|
|
976
1054
|
{
|
|
977
|
-
throw ReactError(Error(
|
|
1055
|
+
throw ReactError(Error("forwardRef requires a render function but was given " + typeof elementType.render + "."));
|
|
978
1056
|
}
|
|
979
1057
|
}
|
|
980
1058
|
})();
|
|
1059
|
+
|
|
981
1060
|
this._rendered = elementType.render.call(undefined, element.props, element.ref);
|
|
982
1061
|
} else {
|
|
983
1062
|
this._rendered = elementType(element.props, this._context);
|
|
@@ -985,61 +1064,61 @@ var ReactShallowRenderer = function () {
|
|
|
985
1064
|
} finally {
|
|
986
1065
|
ReactCurrentDispatcher.current = prevDispatcher;
|
|
987
1066
|
}
|
|
1067
|
+
|
|
988
1068
|
this._finishHooks(element, context);
|
|
989
1069
|
}
|
|
990
1070
|
}
|
|
991
1071
|
}
|
|
992
1072
|
|
|
993
1073
|
this._rendering = false;
|
|
1074
|
+
|
|
994
1075
|
this._updater._invokeCallbacks();
|
|
995
1076
|
|
|
996
1077
|
return this.getRenderOutput();
|
|
997
1078
|
};
|
|
998
1079
|
|
|
999
|
-
|
|
1080
|
+
_proto2.unmount = function unmount() {
|
|
1000
1081
|
if (this._instance) {
|
|
1001
1082
|
if (typeof this._instance.componentWillUnmount === 'function') {
|
|
1002
1083
|
this._instance.componentWillUnmount();
|
|
1003
1084
|
}
|
|
1004
1085
|
}
|
|
1086
|
+
|
|
1005
1087
|
this._reset();
|
|
1006
1088
|
};
|
|
1007
1089
|
|
|
1008
|
-
|
|
1090
|
+
_proto2._mountClassComponent = function _mountClassComponent(elementType, element, context) {
|
|
1009
1091
|
this._instance.context = context;
|
|
1010
1092
|
this._instance.props = element.props;
|
|
1011
1093
|
this._instance.state = this._instance.state || null;
|
|
1012
1094
|
this._instance.updater = this._updater;
|
|
1013
1095
|
|
|
1014
1096
|
if (typeof this._instance.UNSAFE_componentWillMount === 'function' || typeof this._instance.componentWillMount === 'function') {
|
|
1015
|
-
var beforeState = this._newState;
|
|
1016
|
-
|
|
1017
|
-
// In order to support react-lifecycles-compat polyfilled components,
|
|
1097
|
+
var beforeState = this._newState; // In order to support react-lifecycles-compat polyfilled components,
|
|
1018
1098
|
// Unsafe lifecycles should not be invoked for components using the new APIs.
|
|
1099
|
+
|
|
1019
1100
|
if (typeof elementType.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
|
|
1020
1101
|
if (typeof this._instance.componentWillMount === 'function') {
|
|
1021
1102
|
this._instance.componentWillMount();
|
|
1022
1103
|
}
|
|
1104
|
+
|
|
1023
1105
|
if (typeof this._instance.UNSAFE_componentWillMount === 'function') {
|
|
1024
1106
|
this._instance.UNSAFE_componentWillMount();
|
|
1025
1107
|
}
|
|
1026
|
-
}
|
|
1108
|
+
} // setState may have been called during cWM
|
|
1109
|
+
|
|
1027
1110
|
|
|
1028
|
-
// setState may have been called during cWM
|
|
1029
1111
|
if (beforeState !== this._newState) {
|
|
1030
1112
|
this._instance.state = this._newState || emptyObject;
|
|
1031
1113
|
}
|
|
1032
1114
|
}
|
|
1033
1115
|
|
|
1034
|
-
this._rendered = this._instance.render();
|
|
1035
|
-
// Intentionally do not call componentDidMount()
|
|
1116
|
+
this._rendered = this._instance.render(); // Intentionally do not call componentDidMount()
|
|
1036
1117
|
// because DOM refs are not available.
|
|
1037
1118
|
};
|
|
1038
1119
|
|
|
1039
|
-
|
|
1120
|
+
_proto2._updateClassComponent = function _updateClassComponent(elementType, element, context) {
|
|
1040
1121
|
var props = element.props;
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
1122
|
var oldState = this._instance.state || emptyObject;
|
|
1044
1123
|
var oldProps = this._instance.props;
|
|
1045
1124
|
|
|
@@ -1050,22 +1129,26 @@ var ReactShallowRenderer = function () {
|
|
|
1050
1129
|
if (typeof this._instance.componentWillReceiveProps === 'function') {
|
|
1051
1130
|
this._instance.componentWillReceiveProps(props, context);
|
|
1052
1131
|
}
|
|
1132
|
+
|
|
1053
1133
|
if (typeof this._instance.UNSAFE_componentWillReceiveProps === 'function') {
|
|
1054
1134
|
this._instance.UNSAFE_componentWillReceiveProps(props, context);
|
|
1055
1135
|
}
|
|
1056
1136
|
}
|
|
1057
|
-
}
|
|
1137
|
+
} // Read state after cWRP in case it calls setState
|
|
1138
|
+
|
|
1058
1139
|
|
|
1059
|
-
// Read state after cWRP in case it calls setState
|
|
1060
1140
|
var state = this._newState || oldState;
|
|
1141
|
+
|
|
1061
1142
|
if (typeof elementType.getDerivedStateFromProps === 'function') {
|
|
1062
1143
|
var partialState = elementType.getDerivedStateFromProps.call(null, props, state);
|
|
1144
|
+
|
|
1063
1145
|
if (partialState != null) {
|
|
1064
1146
|
state = _assign({}, state, partialState);
|
|
1065
1147
|
}
|
|
1066
1148
|
}
|
|
1067
1149
|
|
|
1068
1150
|
var shouldUpdate = true;
|
|
1151
|
+
|
|
1069
1152
|
if (this._forcedUpdate) {
|
|
1070
1153
|
shouldUpdate = true;
|
|
1071
1154
|
this._forcedUpdate = false;
|
|
@@ -1082,6 +1165,7 @@ var ReactShallowRenderer = function () {
|
|
|
1082
1165
|
if (typeof this._instance.componentWillUpdate === 'function') {
|
|
1083
1166
|
this._instance.componentWillUpdate(props, state, context);
|
|
1084
1167
|
}
|
|
1168
|
+
|
|
1085
1169
|
if (typeof this._instance.UNSAFE_componentWillUpdate === 'function') {
|
|
1086
1170
|
this._instance.UNSAFE_componentWillUpdate(props, state, context);
|
|
1087
1171
|
}
|
|
@@ -1095,9 +1179,9 @@ var ReactShallowRenderer = function () {
|
|
|
1095
1179
|
|
|
1096
1180
|
if (shouldUpdate) {
|
|
1097
1181
|
this._rendered = this._instance.render();
|
|
1098
|
-
}
|
|
1099
|
-
// Intentionally do not call componentDidUpdate()
|
|
1182
|
+
} // Intentionally do not call componentDidUpdate()
|
|
1100
1183
|
// because DOM refs are not available.
|
|
1184
|
+
|
|
1101
1185
|
};
|
|
1102
1186
|
|
|
1103
1187
|
return ReactShallowRenderer;
|
|
@@ -1124,11 +1208,13 @@ function getDisplayName(element) {
|
|
|
1124
1208
|
|
|
1125
1209
|
function getStackAddendum() {
|
|
1126
1210
|
var stack = '';
|
|
1211
|
+
|
|
1127
1212
|
if (currentlyValidatingElement) {
|
|
1128
1213
|
var name = getDisplayName(currentlyValidatingElement);
|
|
1129
1214
|
var owner = currentlyValidatingElement._owner;
|
|
1130
1215
|
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
1131
1216
|
}
|
|
1217
|
+
|
|
1132
1218
|
return stack;
|
|
1133
1219
|
}
|
|
1134
1220
|
|
|
@@ -1145,10 +1231,13 @@ function getMaskedContext(contextTypes, unmaskedContext) {
|
|
|
1145
1231
|
if (!contextTypes || !unmaskedContext) {
|
|
1146
1232
|
return emptyObject;
|
|
1147
1233
|
}
|
|
1234
|
+
|
|
1148
1235
|
var context = {};
|
|
1236
|
+
|
|
1149
1237
|
for (var key in contextTypes) {
|
|
1150
1238
|
context[key] = unmaskedContext[key];
|
|
1151
1239
|
}
|
|
1240
|
+
|
|
1152
1241
|
return context;
|
|
1153
1242
|
}
|
|
1154
1243
|
|
|
@@ -1162,6 +1251,8 @@ var ReactShallowRenderer$3 = ( ReactShallowRenderer$2 && ReactShallowRenderer )
|
|
|
1162
1251
|
|
|
1163
1252
|
// TODO: decide on the top-level export form.
|
|
1164
1253
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
1254
|
+
|
|
1255
|
+
|
|
1165
1256
|
var shallow = ReactShallowRenderer$3.default || ReactShallowRenderer$3;
|
|
1166
1257
|
|
|
1167
1258
|
return shallow;
|