react-test-renderer 16.10.1 → 16.13.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/build-info.json +5 -5
- package/cjs/react-test-renderer-shallow.development.js +168 -209
- package/cjs/react-test-renderer-shallow.production.min.js +27 -26
- package/cjs/react-test-renderer.development.js +2708 -4961
- package/cjs/react-test-renderer.production.min.js +172 -172
- package/package.json +2 -2
- package/umd/react-test-renderer-shallow.development.js +874 -958
- package/umd/react-test-renderer-shallow.production.min.js +24 -24
- package/umd/react-test-renderer.development.js +12056 -14320
- package/umd/react-test-renderer.production.min.js +144 -143
package/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"branch": "
|
|
3
|
-
"buildNumber": "
|
|
4
|
-
"checksum": "
|
|
5
|
-
"commit": "
|
|
2
|
+
"branch": "master",
|
|
3
|
+
"buildNumber": "91354",
|
|
4
|
+
"checksum": "b0ed8f5",
|
|
5
|
+
"commit": "d28bd2994",
|
|
6
6
|
"environment": "ci",
|
|
7
|
-
"reactVersion": "16.
|
|
7
|
+
"reactVersion": "16.12.0-d28bd2994"
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.13.0
|
|
2
2
|
* react-test-renderer-shallow.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -21,19 +21,85 @@ var reactIs = require('react-is');
|
|
|
21
21
|
var checkPropTypes = require('prop-types/checkPropTypes');
|
|
22
22
|
|
|
23
23
|
// Do not require this module directly! Use normal `invariant` calls with
|
|
24
|
-
// template literal strings. The messages will be
|
|
25
|
-
// build
|
|
24
|
+
// template literal strings. The messages will be replaced with error codes
|
|
25
|
+
// during build.
|
|
26
|
+
function formatProdErrorMessage(code) {
|
|
27
|
+
var url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code;
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
error
|
|
32
|
-
|
|
29
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
30
|
+
url += '&args[]=' + encodeURIComponent(arguments[i]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return "Minified React error #" + code + "; visit " + url + " for the full message or " + 'use the non-minified dev environment for full errors and additional ' + 'helpful warnings.';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
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.
|
|
37
|
+
// Current owner and dispatcher used to share the same ref,
|
|
38
|
+
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
39
|
+
|
|
40
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
41
|
+
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
42
|
+
current: null
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
|
47
|
+
ReactSharedInternals.ReactCurrentBatchConfig = {
|
|
48
|
+
suspense: null
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function error(format) {
|
|
53
|
+
{
|
|
54
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
55
|
+
args[_key2 - 1] = arguments[_key2];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
printWarning('error', format, args);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function printWarning(level, format, args) {
|
|
63
|
+
// When changing this logic, you might want to also
|
|
64
|
+
// update consoleWithStackDev.www.js as well.
|
|
65
|
+
{
|
|
66
|
+
var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
|
|
67
|
+
|
|
68
|
+
if (!hasExistingStack) {
|
|
69
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
70
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
71
|
+
|
|
72
|
+
if (stack !== '') {
|
|
73
|
+
format += '%s';
|
|
74
|
+
args = args.concat([stack]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var argsWithFormat = args.map(function (item) {
|
|
79
|
+
return '' + item;
|
|
80
|
+
}); // Careful: RN currently depends on this prefix
|
|
81
|
+
|
|
82
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
83
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
84
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
85
|
+
|
|
86
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
// --- Welcome to debugging React ---
|
|
90
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
91
|
+
// to find the callsite that caused this warning to fire.
|
|
92
|
+
var argIndex = 0;
|
|
93
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
94
|
+
return args[argIndex++];
|
|
95
|
+
});
|
|
96
|
+
throw new Error(message);
|
|
97
|
+
} catch (x) {}
|
|
98
|
+
}
|
|
33
99
|
}
|
|
34
100
|
|
|
35
101
|
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
36
|
-
|
|
102
|
+
function describeComponentFrame (name, source, ownerName) {
|
|
37
103
|
var sourceInfo = '';
|
|
38
104
|
|
|
39
105
|
if (source) {
|
|
@@ -63,126 +129,25 @@ var describeComponentFrame = function (name, source, ownerName) {
|
|
|
63
129
|
}
|
|
64
130
|
|
|
65
131
|
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
|
70
|
-
* This can be used to log issues in development environments in critical
|
|
71
|
-
* paths. Removing the logging code for production environments will keep the
|
|
72
|
-
* same logic and follow the same code paths.
|
|
73
|
-
*/
|
|
74
|
-
var warningWithoutStack = function () {};
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
warningWithoutStack = function (condition, format) {
|
|
78
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
79
|
-
args[_key - 2] = arguments[_key];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (format === undefined) {
|
|
83
|
-
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (args.length > 8) {
|
|
87
|
-
// Check before the condition to catch violations early.
|
|
88
|
-
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (condition) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (typeof console !== 'undefined') {
|
|
96
|
-
var argsWithFormat = args.map(function (item) {
|
|
97
|
-
return '' + item;
|
|
98
|
-
});
|
|
99
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
100
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
101
|
-
|
|
102
|
-
Function.prototype.apply.call(console.error, console, argsWithFormat);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
// --- Welcome to debugging React ---
|
|
107
|
-
// This error was thrown as a convenience so that you can use this stack
|
|
108
|
-
// to find the callsite that caused this warning to fire.
|
|
109
|
-
var argIndex = 0;
|
|
110
|
-
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
111
|
-
return args[argIndex++];
|
|
112
|
-
});
|
|
113
|
-
throw new Error(message);
|
|
114
|
-
} catch (x) {}
|
|
115
|
-
};
|
|
116
132
|
}
|
|
117
133
|
|
|
118
|
-
var warningWithoutStack$1 = warningWithoutStack;
|
|
119
|
-
|
|
120
134
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
121
135
|
// nor polyfill, then a plain number is used for performance.
|
|
122
136
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
123
|
-
|
|
124
137
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
125
138
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
126
139
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
127
140
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
128
141
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
129
142
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
130
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
143
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
135
144
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
136
145
|
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
137
146
|
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
138
147
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
139
|
-
|
|
140
|
-
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.
|
|
141
|
-
// Current owner and dispatcher used to share the same ref,
|
|
142
|
-
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
143
|
-
|
|
144
|
-
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
145
|
-
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
146
|
-
current: null
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
|
151
|
-
ReactSharedInternals.ReactCurrentBatchConfig = {
|
|
152
|
-
suspense: null
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
|
158
|
-
* This can be used to log issues in development environments in critical
|
|
159
|
-
* paths. Removing the logging code for production environments will keep the
|
|
160
|
-
* same logic and follow the same code paths.
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
var warning = warningWithoutStack$1;
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
warning = function (condition, format) {
|
|
167
|
-
if (condition) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
172
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
173
|
-
|
|
174
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
175
|
-
args[_key - 2] = arguments[_key];
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
var warning$1 = warning;
|
|
148
|
+
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
183
149
|
|
|
184
150
|
var Resolved = 1;
|
|
185
|
-
|
|
186
151
|
function refineResolvedLazyComponent(lazyComponent) {
|
|
187
152
|
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
188
153
|
}
|
|
@@ -200,7 +165,7 @@ function getComponentName(type) {
|
|
|
200
165
|
|
|
201
166
|
{
|
|
202
167
|
if (typeof type.tag === 'number') {
|
|
203
|
-
|
|
168
|
+
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
204
169
|
}
|
|
205
170
|
}
|
|
206
171
|
|
|
@@ -246,6 +211,9 @@ function getComponentName(type) {
|
|
|
246
211
|
case REACT_MEMO_TYPE:
|
|
247
212
|
return getComponentName(type.type);
|
|
248
213
|
|
|
214
|
+
case REACT_BLOCK_TYPE:
|
|
215
|
+
return getComponentName(type.render);
|
|
216
|
+
|
|
249
217
|
case REACT_LAZY_TYPE:
|
|
250
218
|
{
|
|
251
219
|
var thenable = type;
|
|
@@ -272,7 +240,7 @@ function is(x, y) {
|
|
|
272
240
|
;
|
|
273
241
|
}
|
|
274
242
|
|
|
275
|
-
var
|
|
243
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
276
244
|
|
|
277
245
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
278
246
|
/**
|
|
@@ -282,7 +250,7 @@ var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
282
250
|
*/
|
|
283
251
|
|
|
284
252
|
function shallowEqual(objA, objB) {
|
|
285
|
-
if (
|
|
253
|
+
if (objectIs(objA, objB)) {
|
|
286
254
|
return true;
|
|
287
255
|
}
|
|
288
256
|
|
|
@@ -299,7 +267,7 @@ function shallowEqual(objA, objB) {
|
|
|
299
267
|
|
|
300
268
|
|
|
301
269
|
for (var i = 0; i < keysA.length; i++) {
|
|
302
|
-
if (!hasOwnProperty.call(objB, keysA[i]) || !
|
|
270
|
+
if (!hasOwnProperty.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) {
|
|
303
271
|
return false;
|
|
304
272
|
}
|
|
305
273
|
}
|
|
@@ -307,17 +275,6 @@ function shallowEqual(objA, objB) {
|
|
|
307
275
|
return true;
|
|
308
276
|
}
|
|
309
277
|
|
|
310
|
-
/**
|
|
311
|
-
* Use invariant() to assert state which your program assumes to be true.
|
|
312
|
-
*
|
|
313
|
-
* Provide sprintf-style format (only %s is supported) and arguments
|
|
314
|
-
* to provide information about what broke and what you were
|
|
315
|
-
* expecting.
|
|
316
|
-
*
|
|
317
|
-
* The invariant message will be stripped in production, but the invariant
|
|
318
|
-
* will remain to ensure logic does not differ in production.
|
|
319
|
-
*/
|
|
320
|
-
|
|
321
278
|
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
322
279
|
var RE_RENDER_LIMIT = 25;
|
|
323
280
|
var emptyObject = {};
|
|
@@ -331,18 +288,23 @@ var currentHookNameInDev;
|
|
|
331
288
|
|
|
332
289
|
function areHookInputsEqual(nextDeps, prevDeps) {
|
|
333
290
|
if (prevDeps === null) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
// passed inline.
|
|
291
|
+
{
|
|
292
|
+
error('%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);
|
|
293
|
+
}
|
|
338
294
|
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
339
297
|
|
|
340
|
-
|
|
341
|
-
|
|
298
|
+
{
|
|
299
|
+
// Don't bother comparing lengths in prod because these arrays should be
|
|
300
|
+
// passed inline.
|
|
301
|
+
if (nextDeps.length !== prevDeps.length) {
|
|
302
|
+
error('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(', ') + "]");
|
|
303
|
+
}
|
|
342
304
|
}
|
|
343
305
|
|
|
344
306
|
for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
|
345
|
-
if (
|
|
307
|
+
if (objectIs(nextDeps[i], prevDeps[i])) {
|
|
346
308
|
continue;
|
|
347
309
|
}
|
|
348
310
|
|
|
@@ -432,6 +394,7 @@ function createHook() {
|
|
|
432
394
|
}
|
|
433
395
|
|
|
434
396
|
function basicStateReducer(state, action) {
|
|
397
|
+
// $FlowFixMe: Flow doesn't like mixed types
|
|
435
398
|
return typeof action === 'function' ? action(state) : action;
|
|
436
399
|
}
|
|
437
400
|
|
|
@@ -463,40 +426,36 @@ function () {
|
|
|
463
426
|
};
|
|
464
427
|
|
|
465
428
|
_proto2._validateCurrentlyRenderingComponent = function _validateCurrentlyRenderingComponent() {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (!(_this._rendering && !_this._instance)) {
|
|
470
|
-
{
|
|
471
|
-
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."));
|
|
472
|
-
}
|
|
429
|
+
if (!(this._rendering && !this._instance)) {
|
|
430
|
+
{
|
|
431
|
+
throw 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." );
|
|
473
432
|
}
|
|
474
|
-
}
|
|
433
|
+
}
|
|
475
434
|
};
|
|
476
435
|
|
|
477
436
|
_proto2._createDispatcher = function _createDispatcher() {
|
|
478
|
-
var
|
|
437
|
+
var _this = this;
|
|
479
438
|
|
|
480
439
|
var useReducer = function (reducer, initialArg, init) {
|
|
481
|
-
|
|
440
|
+
_this._validateCurrentlyRenderingComponent();
|
|
482
441
|
|
|
483
|
-
|
|
442
|
+
_this._createWorkInProgressHook();
|
|
484
443
|
|
|
485
|
-
var workInProgressHook =
|
|
444
|
+
var workInProgressHook = _this._workInProgressHook;
|
|
486
445
|
|
|
487
|
-
if (
|
|
446
|
+
if (_this._isReRender) {
|
|
488
447
|
// This is a re-render.
|
|
489
448
|
var queue = workInProgressHook.queue;
|
|
490
449
|
var dispatch = queue.dispatch;
|
|
491
450
|
|
|
492
|
-
if (
|
|
451
|
+
if (_this._numberOfReRenders > 0) {
|
|
493
452
|
// Apply the new render phase updates to the previous current hook.
|
|
494
|
-
if (
|
|
453
|
+
if (_this._renderPhaseUpdates !== null) {
|
|
495
454
|
// Render phase updates are stored in a map of queue -> linked list
|
|
496
|
-
var firstRenderPhaseUpdate =
|
|
455
|
+
var firstRenderPhaseUpdate = _this._renderPhaseUpdates.get(queue);
|
|
497
456
|
|
|
498
457
|
if (firstRenderPhaseUpdate !== undefined) {
|
|
499
|
-
|
|
458
|
+
_this._renderPhaseUpdates.delete(queue);
|
|
500
459
|
|
|
501
460
|
var _newState = workInProgressHook.memoizedState;
|
|
502
461
|
var _update = firstRenderPhaseUpdate;
|
|
@@ -548,7 +507,7 @@ function () {
|
|
|
548
507
|
dispatch: null
|
|
549
508
|
};
|
|
550
509
|
|
|
551
|
-
var _dispatch = _queue.dispatch =
|
|
510
|
+
var _dispatch = _queue.dispatch = _this._dispatchAction.bind(_this, _queue);
|
|
552
511
|
|
|
553
512
|
return [workInProgressHook.memoizedState, _dispatch];
|
|
554
513
|
}
|
|
@@ -560,14 +519,14 @@ function () {
|
|
|
560
519
|
};
|
|
561
520
|
|
|
562
521
|
var useMemo = function (nextCreate, deps) {
|
|
563
|
-
|
|
522
|
+
_this._validateCurrentlyRenderingComponent();
|
|
564
523
|
|
|
565
|
-
|
|
524
|
+
_this._createWorkInProgressHook();
|
|
566
525
|
|
|
567
526
|
var nextDeps = deps !== undefined ? deps : null;
|
|
568
527
|
|
|
569
|
-
if (
|
|
570
|
-
var prevState =
|
|
528
|
+
if (_this._workInProgressHook !== null && _this._workInProgressHook.memoizedState !== null) {
|
|
529
|
+
var prevState = _this._workInProgressHook.memoizedState;
|
|
571
530
|
var prevDeps = prevState[1];
|
|
572
531
|
|
|
573
532
|
if (nextDeps !== null) {
|
|
@@ -578,16 +537,16 @@ function () {
|
|
|
578
537
|
}
|
|
579
538
|
|
|
580
539
|
var nextValue = nextCreate();
|
|
581
|
-
|
|
540
|
+
_this._workInProgressHook.memoizedState = [nextValue, nextDeps];
|
|
582
541
|
return nextValue;
|
|
583
542
|
};
|
|
584
543
|
|
|
585
544
|
var useRef = function (initialValue) {
|
|
586
|
-
|
|
545
|
+
_this._validateCurrentlyRenderingComponent();
|
|
587
546
|
|
|
588
|
-
|
|
547
|
+
_this._createWorkInProgressHook();
|
|
589
548
|
|
|
590
|
-
var previousRef =
|
|
549
|
+
var previousRef = _this._workInProgressHook.memoizedState;
|
|
591
550
|
|
|
592
551
|
if (previousRef === null) {
|
|
593
552
|
var ref = {
|
|
@@ -598,7 +557,7 @@ function () {
|
|
|
598
557
|
Object.seal(ref);
|
|
599
558
|
}
|
|
600
559
|
|
|
601
|
-
|
|
560
|
+
_this._workInProgressHook.memoizedState = ref;
|
|
602
561
|
return ref;
|
|
603
562
|
} else {
|
|
604
563
|
return previousRef;
|
|
@@ -610,7 +569,7 @@ function () {
|
|
|
610
569
|
};
|
|
611
570
|
|
|
612
571
|
var noOp = function () {
|
|
613
|
-
|
|
572
|
+
_this._validateCurrentlyRenderingComponent();
|
|
614
573
|
};
|
|
615
574
|
|
|
616
575
|
var identity = function (fn) {
|
|
@@ -622,13 +581,31 @@ function () {
|
|
|
622
581
|
props: props,
|
|
623
582
|
responder: responder
|
|
624
583
|
};
|
|
584
|
+
}; // TODO: implement if we decide to keep the shallow renderer
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
var useTransition = function (config) {
|
|
588
|
+
_this._validateCurrentlyRenderingComponent();
|
|
589
|
+
|
|
590
|
+
var startTransition = function (callback) {
|
|
591
|
+
callback();
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
return [startTransition, false];
|
|
595
|
+
}; // TODO: implement if we decide to keep the shallow renderer
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
var useDeferredValue = function (value, config) {
|
|
599
|
+
_this._validateCurrentlyRenderingComponent();
|
|
600
|
+
|
|
601
|
+
return value;
|
|
625
602
|
};
|
|
626
603
|
|
|
627
604
|
return {
|
|
628
605
|
readContext: readContext,
|
|
629
606
|
useCallback: identity,
|
|
630
607
|
useContext: function (context) {
|
|
631
|
-
|
|
608
|
+
_this._validateCurrentlyRenderingComponent();
|
|
632
609
|
|
|
633
610
|
return readContext(context);
|
|
634
611
|
},
|
|
@@ -640,20 +617,18 @@ function () {
|
|
|
640
617
|
useReducer: useReducer,
|
|
641
618
|
useRef: useRef,
|
|
642
619
|
useState: useState,
|
|
643
|
-
useResponder: useResponder
|
|
620
|
+
useResponder: useResponder,
|
|
621
|
+
useTransition: useTransition,
|
|
622
|
+
useDeferredValue: useDeferredValue
|
|
644
623
|
};
|
|
645
624
|
};
|
|
646
625
|
|
|
647
626
|
_proto2._dispatchAction = function _dispatchAction(queue, action) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
if (!(_this3._numberOfReRenders < RE_RENDER_LIMIT)) {
|
|
652
|
-
{
|
|
653
|
-
throw ReactError(Error("Too many re-renders. React limits the number of renders to prevent an infinite loop."));
|
|
654
|
-
}
|
|
627
|
+
if (!(this._numberOfReRenders < RE_RENDER_LIMIT)) {
|
|
628
|
+
{
|
|
629
|
+
throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." );
|
|
655
630
|
}
|
|
656
|
-
}
|
|
631
|
+
}
|
|
657
632
|
|
|
658
633
|
if (this._rendering) {
|
|
659
634
|
// This is a render phase update. Stash it in a lazily-created map of
|
|
@@ -763,31 +738,25 @@ function () {
|
|
|
763
738
|
_proto2.render = function render(element) {
|
|
764
739
|
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject;
|
|
765
740
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
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.' : '')));
|
|
770
|
-
}
|
|
741
|
+
if (!React.isValidElement(element)) {
|
|
742
|
+
{
|
|
743
|
+
throw 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.' : '') );
|
|
771
744
|
}
|
|
772
|
-
}
|
|
745
|
+
}
|
|
773
746
|
|
|
774
747
|
element = element; // Show a special message for host elements since it's a common case.
|
|
775
748
|
|
|
776
|
-
(
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
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."));
|
|
780
|
-
}
|
|
749
|
+
if (!(typeof element.type !== 'string')) {
|
|
750
|
+
{
|
|
751
|
+
throw 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." );
|
|
781
752
|
}
|
|
782
|
-
}
|
|
753
|
+
}
|
|
783
754
|
|
|
784
|
-
(function () {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
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) + "`."));
|
|
788
|
-
}
|
|
755
|
+
if (!(reactIs.isForwardRef(element) || typeof element.type === 'function' || reactIs.isMemo(element))) {
|
|
756
|
+
{
|
|
757
|
+
throw 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) + "`." );
|
|
789
758
|
}
|
|
790
|
-
}
|
|
759
|
+
}
|
|
791
760
|
|
|
792
761
|
if (this._rendering) {
|
|
793
762
|
return;
|
|
@@ -797,13 +766,13 @@ function () {
|
|
|
797
766
|
this._reset();
|
|
798
767
|
}
|
|
799
768
|
|
|
800
|
-
var elementType = reactIs.isMemo(element
|
|
769
|
+
var elementType = reactIs.isMemo(element) ? element.type.type : element.type;
|
|
801
770
|
var previousElement = this._element;
|
|
802
771
|
this._rendering = true;
|
|
803
772
|
this._element = element;
|
|
804
773
|
this._context = getMaskedContext(elementType.contextTypes, context); // Inner memo component props aren't currently validated in createElement.
|
|
805
774
|
|
|
806
|
-
if (reactIs.isMemo(element
|
|
775
|
+
if (reactIs.isMemo(element) && elementType.propTypes) {
|
|
807
776
|
currentlyValidatingElement = element;
|
|
808
777
|
checkPropTypes(elementType.propTypes, element.props, 'prop', getComponentName(elementType), getStackAddendum);
|
|
809
778
|
}
|
|
@@ -832,7 +801,7 @@ function () {
|
|
|
832
801
|
} else {
|
|
833
802
|
var shouldRender = true;
|
|
834
803
|
|
|
835
|
-
if (reactIs.isMemo(element
|
|
804
|
+
if (reactIs.isMemo(element) && previousElement !== null) {
|
|
836
805
|
// This is a Memo component that is being re-rendered.
|
|
837
806
|
var compare = element.type.compare || shallowEqual;
|
|
838
807
|
|
|
@@ -849,13 +818,11 @@ function () {
|
|
|
849
818
|
// elementType could still be a ForwardRef if it was
|
|
850
819
|
// nested inside Memo.
|
|
851
820
|
if (elementType.$$typeof === reactIs.ForwardRef) {
|
|
852
|
-
(function
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
throw ReactError(Error("forwardRef requires a render function but was given " + typeof elementType.render + "."));
|
|
856
|
-
}
|
|
821
|
+
if (!(typeof elementType.render === 'function')) {
|
|
822
|
+
{
|
|
823
|
+
throw Error(true ? "forwardRef requires a render function but was given " + typeof elementType.render + "." : formatProdErrorMessage(322, typeof elementType.render));
|
|
857
824
|
}
|
|
858
|
-
}
|
|
825
|
+
}
|
|
859
826
|
|
|
860
827
|
this._rendered = elementType.render.call(undefined, element.props, element.ref);
|
|
861
828
|
} else {
|
|
@@ -1001,7 +968,7 @@ function getDisplayName(element) {
|
|
|
1001
968
|
} else if (typeof element.type === 'string') {
|
|
1002
969
|
return element.type;
|
|
1003
970
|
} else {
|
|
1004
|
-
var elementType = reactIs.isMemo(element
|
|
971
|
+
var elementType = reactIs.isMemo(element) ? element.type.type : element.type;
|
|
1005
972
|
return elementType.displayName || elementType.name || 'Unknown';
|
|
1006
973
|
}
|
|
1007
974
|
}
|
|
@@ -1041,19 +1008,11 @@ function getMaskedContext(contextTypes, unmaskedContext) {
|
|
|
1041
1008
|
return context;
|
|
1042
1009
|
}
|
|
1043
1010
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
var ReactShallowRenderer$2 = Object.freeze({
|
|
1047
|
-
default: ReactShallowRenderer
|
|
1048
|
-
});
|
|
1049
|
-
|
|
1050
|
-
var ReactShallowRenderer$3 = ( ReactShallowRenderer$2 && ReactShallowRenderer ) || ReactShallowRenderer$2;
|
|
1051
|
-
|
|
1052
1011
|
// TODO: decide on the top-level export form.
|
|
1053
1012
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
1054
1013
|
|
|
1055
1014
|
|
|
1056
|
-
var shallow = ReactShallowRenderer
|
|
1015
|
+
var shallow = ReactShallowRenderer.default || ReactShallowRenderer;
|
|
1057
1016
|
|
|
1058
1017
|
module.exports = shallow;
|
|
1059
1018
|
})();
|