react-test-renderer 16.9.0 → 16.11.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.
@@ -1,4 +1,4 @@
1
- /** @license React v16.9.0
1
+ /** @license React v16.11.0
2
2
  * react-test-renderer-shallow.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -21,32 +21,26 @@ 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 converted to ReactError during
25
- // build, and in production they will be minified.
26
-
27
- // Do not require this module directly! Use normal `invariant` calls with
28
- // template literal strings. The messages will be converted to ReactError during
29
- // build, and in production they will be minified.
30
-
31
- function ReactError(error) {
32
- error.name = 'Invariant Violation';
33
- return error;
34
- }
24
+ // template literal strings. The messages will be replaced with error codes
25
+ // during build.
35
26
 
36
27
  var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
37
-
38
28
  var describeComponentFrame = function (name, source, ownerName) {
39
29
  var sourceInfo = '';
30
+
40
31
  if (source) {
41
32
  var path = source.fileName;
42
33
  var fileName = path.replace(BEFORE_SLASH_RE, '');
34
+
43
35
  {
44
36
  // In DEV, include code for a common special case:
45
37
  // prefer "folder/index.js" instead of just "index.js".
46
38
  if (/^index\./.test(fileName)) {
47
39
  var match = path.match(BEFORE_SLASH_RE);
40
+
48
41
  if (match) {
49
42
  var pathBeforeSlash = match[1];
43
+
50
44
  if (pathBeforeSlash) {
51
45
  var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
52
46
  fileName = folderName + '/' + fileName;
@@ -54,10 +48,12 @@ var describeComponentFrame = function (name, source, ownerName) {
54
48
  }
55
49
  }
56
50
  }
51
+
57
52
  sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
58
53
  } else if (ownerName) {
59
54
  sourceInfo = ' (created by ' + ownerName + ')';
60
55
  }
56
+
61
57
  return '\n in ' + (name || 'Unknown') + sourceInfo;
62
58
  };
63
59
 
@@ -67,35 +63,37 @@ var describeComponentFrame = function (name, source, ownerName) {
67
63
  * paths. Removing the logging code for production environments will keep the
68
64
  * same logic and follow the same code paths.
69
65
  */
70
-
71
66
  var warningWithoutStack = function () {};
72
67
 
73
68
  {
74
69
  warningWithoutStack = function (condition, format) {
75
- for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
70
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
76
71
  args[_key - 2] = arguments[_key];
77
72
  }
78
73
 
79
74
  if (format === undefined) {
80
75
  throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
81
76
  }
77
+
82
78
  if (args.length > 8) {
83
79
  // Check before the condition to catch violations early.
84
80
  throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
85
81
  }
82
+
86
83
  if (condition) {
87
84
  return;
88
85
  }
86
+
89
87
  if (typeof console !== 'undefined') {
90
88
  var argsWithFormat = args.map(function (item) {
91
89
  return '' + item;
92
90
  });
93
- argsWithFormat.unshift('Warning: ' + format);
94
-
95
- // We intentionally don't use spread (or .apply) directly because it
91
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
96
92
  // breaks IE9: https://github.com/facebook/react/issues/13610
93
+
97
94
  Function.prototype.apply.call(console.error, console, argsWithFormat);
98
95
  }
96
+
99
97
  try {
100
98
  // --- Welcome to debugging React ---
101
99
  // This error was thrown as a convenience so that you can use this stack
@@ -115,25 +113,67 @@ var warningWithoutStack$1 = warningWithoutStack;
115
113
  // nor polyfill, then a plain number is used for performance.
116
114
  var hasSymbol = typeof Symbol === 'function' && Symbol.for;
117
115
 
118
-
119
116
  var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
120
117
  var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
121
118
  var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
122
119
  var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
123
120
  var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
124
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
125
- // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
121
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
126
122
  // (unstable) APIs that have been removed. Can we remove the symbols?
127
123
 
128
124
 
125
+
129
126
  var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
130
127
  var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
131
128
  var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
132
129
  var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
133
130
  var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
134
131
 
135
- var Resolved = 1;
132
+ 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.
133
+ // Current owner and dispatcher used to share the same ref,
134
+ // but PR #14548 split them out to better support the react-debug-tools package.
135
+
136
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
137
+ ReactSharedInternals.ReactCurrentDispatcher = {
138
+ current: null
139
+ };
140
+ }
141
+
142
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
143
+ ReactSharedInternals.ReactCurrentBatchConfig = {
144
+ suspense: null
145
+ };
146
+ }
147
+
148
+ /**
149
+ * Similar to invariant but only logs a warning if the condition is not met.
150
+ * This can be used to log issues in development environments in critical
151
+ * paths. Removing the logging code for production environments will keep the
152
+ * same logic and follow the same code paths.
153
+ */
154
+
155
+ var warning = warningWithoutStack$1;
156
+
157
+ {
158
+ warning = function (condition, format) {
159
+ if (condition) {
160
+ return;
161
+ }
162
+
163
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
164
+ var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
165
+
166
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
167
+ args[_key - 2] = arguments[_key];
168
+ }
169
+
170
+ warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
171
+ };
172
+ }
173
+
174
+ var warning$1 = warning;
136
175
 
176
+ var Resolved = 1;
137
177
 
138
178
  function refineResolvedLazyComponent(lazyComponent) {
139
179
  return lazyComponent._status === Resolved ? lazyComponent._result : null;
@@ -141,7 +181,7 @@ function refineResolvedLazyComponent(lazyComponent) {
141
181
 
142
182
  function getWrappedName(outerType, innerType, wrapperName) {
143
183
  var functionName = innerType.displayName || innerType.name || '';
144
- return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
184
+ return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
145
185
  }
146
186
 
147
187
  function getComponentName(type) {
@@ -149,52 +189,69 @@ function getComponentName(type) {
149
189
  // Host root, text node or just invalid type.
150
190
  return null;
151
191
  }
192
+
152
193
  {
153
194
  if (typeof type.tag === 'number') {
154
195
  warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
155
196
  }
156
197
  }
198
+
157
199
  if (typeof type === 'function') {
158
200
  return type.displayName || type.name || null;
159
201
  }
202
+
160
203
  if (typeof type === 'string') {
161
204
  return type;
162
205
  }
206
+
163
207
  switch (type) {
164
208
  case REACT_FRAGMENT_TYPE:
165
209
  return 'Fragment';
210
+
166
211
  case REACT_PORTAL_TYPE:
167
212
  return 'Portal';
213
+
168
214
  case REACT_PROFILER_TYPE:
169
- return 'Profiler';
215
+ return "Profiler";
216
+
170
217
  case REACT_STRICT_MODE_TYPE:
171
218
  return 'StrictMode';
219
+
172
220
  case REACT_SUSPENSE_TYPE:
173
221
  return 'Suspense';
222
+
174
223
  case REACT_SUSPENSE_LIST_TYPE:
175
224
  return 'SuspenseList';
176
225
  }
226
+
177
227
  if (typeof type === 'object') {
178
228
  switch (type.$$typeof) {
179
229
  case REACT_CONTEXT_TYPE:
180
230
  return 'Context.Consumer';
231
+
181
232
  case REACT_PROVIDER_TYPE:
182
233
  return 'Context.Provider';
234
+
183
235
  case REACT_FORWARD_REF_TYPE:
184
236
  return getWrappedName(type, type.render, 'ForwardRef');
237
+
185
238
  case REACT_MEMO_TYPE:
186
239
  return getComponentName(type.type);
240
+
187
241
  case REACT_LAZY_TYPE:
188
242
  {
189
243
  var thenable = type;
190
244
  var resolvedThenable = refineResolvedLazyComponent(thenable);
245
+
191
246
  if (resolvedThenable) {
192
247
  return getComponentName(resolvedThenable);
193
248
  }
249
+
194
250
  break;
195
251
  }
196
252
  }
197
253
  }
254
+
198
255
  return null;
199
256
  }
200
257
 
@@ -207,15 +264,17 @@ function is(x, y) {
207
264
  ;
208
265
  }
209
266
 
210
- var hasOwnProperty = Object.prototype.hasOwnProperty;
267
+ var is$1 = typeof Object.is === 'function' ? Object.is : is;
211
268
 
269
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
212
270
  /**
213
271
  * Performs equality by iterating through keys on an object and returning false
214
272
  * when any key has values which are not strictly equal between the arguments.
215
273
  * Returns true when the values of all keys are strictly equal.
216
274
  */
275
+
217
276
  function shallowEqual(objA, objB) {
218
- if (is(objA, objB)) {
277
+ if (is$1(objA, objB)) {
219
278
  return true;
220
279
  }
221
280
 
@@ -228,11 +287,11 @@ function shallowEqual(objA, objB) {
228
287
 
229
288
  if (keysA.length !== keysB.length) {
230
289
  return false;
231
- }
290
+ } // Test for A's keys different from B.
291
+
232
292
 
233
- // Test for A's keys different from B.
234
293
  for (var i = 0; i < keysA.length; i++) {
235
- if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
294
+ if (!hasOwnProperty.call(objB, keysA[i]) || !is$1(objA[keysA[i]], objB[keysA[i]])) {
236
295
  return false;
237
296
  }
238
297
  }
@@ -251,94 +310,51 @@ function shallowEqual(objA, objB) {
251
310
  * will remain to ensure logic does not differ in production.
252
311
  */
253
312
 
254
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
255
-
256
- // Prevent newer renderers from RTE when used with older react package versions.
257
- // Current owner and dispatcher used to share the same ref,
258
- // but PR #14548 split them out to better support the react-debug-tools package.
259
- if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
260
- ReactSharedInternals.ReactCurrentDispatcher = {
261
- current: null
262
- };
263
- }
264
- if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
265
- ReactSharedInternals.ReactCurrentBatchConfig = {
266
- suspense: null
267
- };
268
- }
269
-
270
- /**
271
- * Similar to invariant but only logs a warning if the condition is not met.
272
- * This can be used to log issues in development environments in critical
273
- * paths. Removing the logging code for production environments will keep the
274
- * same logic and follow the same code paths.
275
- */
276
-
277
- var warning = warningWithoutStack$1;
278
-
279
- {
280
- warning = function (condition, format) {
281
- if (condition) {
282
- return;
283
- }
284
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
285
- var stack = ReactDebugCurrentFrame.getStackAddendum();
286
- // eslint-disable-next-line react-internal/warning-and-invariant-args
287
-
288
- for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
289
- args[_key - 2] = arguments[_key];
290
- }
291
-
292
- warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
293
- };
294
- }
295
-
296
- var warning$1 = warning;
297
-
298
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
299
-
300
313
  var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
301
-
302
-
303
314
  var RE_RENDER_LIMIT = 25;
304
-
305
315
  var emptyObject = {};
316
+
306
317
  {
307
318
  Object.freeze(emptyObject);
308
- }
319
+ } // In DEV, this is the name of the currently executing primitive hook
320
+
309
321
 
310
- // In DEV, this is the name of the currently executing primitive hook
311
- var currentHookNameInDev = void 0;
322
+ var currentHookNameInDev;
312
323
 
313
324
  function areHookInputsEqual(nextDeps, prevDeps) {
314
325
  if (prevDeps === null) {
315
326
  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);
316
327
  return false;
317
- }
318
-
319
- // Don't bother comparing lengths in prod because these arrays should be
328
+ } // Don't bother comparing lengths in prod because these arrays should be
320
329
  // passed inline.
330
+
331
+
321
332
  if (nextDeps.length !== prevDeps.length) {
322
- 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(', ') + ']');
333
+ 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(', ') + "]");
323
334
  }
335
+
324
336
  for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
325
- if (is(nextDeps[i], prevDeps[i])) {
337
+ if (is$1(nextDeps[i], prevDeps[i])) {
326
338
  continue;
327
339
  }
340
+
328
341
  return false;
329
342
  }
343
+
330
344
  return true;
331
345
  }
332
346
 
333
- var Updater = function () {
347
+ var Updater =
348
+ /*#__PURE__*/
349
+ function () {
334
350
  function Updater(renderer) {
335
- _classCallCheck(this, Updater);
336
-
337
351
  this._renderer = renderer;
338
352
  this._callbacks = [];
339
353
  }
340
354
 
341
- Updater.prototype._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
355
+ var _proto = Updater.prototype;
356
+
357
+ _proto._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
342
358
  if (typeof callback === 'function' && publicInstance) {
343
359
  this._callbacks.push({
344
360
  callback: callback,
@@ -347,48 +363,51 @@ var Updater = function () {
347
363
  }
348
364
  };
349
365
 
350
- Updater.prototype._invokeCallbacks = function _invokeCallbacks() {
366
+ _proto._invokeCallbacks = function _invokeCallbacks() {
351
367
  var callbacks = this._callbacks;
352
368
  this._callbacks = [];
353
-
354
369
  callbacks.forEach(function (_ref) {
355
370
  var callback = _ref.callback,
356
371
  publicInstance = _ref.publicInstance;
357
-
358
372
  callback.call(publicInstance);
359
373
  });
360
374
  };
361
375
 
362
- Updater.prototype.isMounted = function isMounted(publicInstance) {
376
+ _proto.isMounted = function isMounted(publicInstance) {
363
377
  return !!this._renderer._element;
364
378
  };
365
379
 
366
- Updater.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
380
+ _proto.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
367
381
  this._enqueueCallback(callback, publicInstance);
382
+
368
383
  this._renderer._forcedUpdate = true;
384
+
369
385
  this._renderer.render(this._renderer._element, this._renderer._context);
370
386
  };
371
387
 
372
- Updater.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
388
+ _proto.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
373
389
  this._enqueueCallback(callback, publicInstance);
390
+
374
391
  this._renderer._newState = completeState;
392
+
375
393
  this._renderer.render(this._renderer._element, this._renderer._context);
376
394
  };
377
395
 
378
- Updater.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
396
+ _proto.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
379
397
  this._enqueueCallback(callback, publicInstance);
398
+
380
399
  var currentState = this._renderer._newState || publicInstance.state;
381
400
 
382
401
  if (typeof partialState === 'function') {
383
402
  partialState = partialState.call(publicInstance, currentState, publicInstance.props);
384
- }
403
+ } // Null and undefined are treated as no-ops.
404
+
385
405
 
386
- // Null and undefined are treated as no-ops.
387
406
  if (partialState === null || partialState === undefined) {
388
407
  return;
389
408
  }
390
409
 
391
- this._renderer._newState = _assign({}, currentState, partialState);
410
+ this._renderer._newState = _assign({}, currentState, {}, partialState);
392
411
 
393
412
  this._renderer.render(this._renderer._element, this._renderer._context);
394
413
  };
@@ -408,14 +427,16 @@ function basicStateReducer(state, action) {
408
427
  return typeof action === 'function' ? action(state) : action;
409
428
  }
410
429
 
411
- var ReactShallowRenderer = function () {
430
+ var ReactShallowRenderer =
431
+ /*#__PURE__*/
432
+ function () {
412
433
  function ReactShallowRenderer() {
413
- _classCallCheck(this, ReactShallowRenderer);
414
-
415
434
  this._reset();
416
435
  }
417
436
 
418
- ReactShallowRenderer.prototype._reset = function _reset() {
437
+ var _proto2 = ReactShallowRenderer.prototype;
438
+
439
+ _proto2._reset = function _reset() {
419
440
  this._context = null;
420
441
  this._element = null;
421
442
  this._instance = null;
@@ -433,96 +454,110 @@ var ReactShallowRenderer = function () {
433
454
  this._numberOfReRenders = 0;
434
455
  };
435
456
 
436
- ReactShallowRenderer.prototype._validateCurrentlyRenderingComponent = function _validateCurrentlyRenderingComponent() {
437
- var _this = this;
438
-
439
- (function () {
440
- if (!(_this._rendering && !_this._instance)) {
441
- {
442
- 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.'));
443
- }
457
+ _proto2._validateCurrentlyRenderingComponent = function _validateCurrentlyRenderingComponent() {
458
+ if (!(this._rendering && !this._instance)) {
459
+ {
460
+ 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.");
444
461
  }
445
- })();
462
+ }
446
463
  };
447
464
 
448
- ReactShallowRenderer.prototype._createDispatcher = function _createDispatcher() {
449
- var _this2 = this;
465
+ _proto2._createDispatcher = function _createDispatcher() {
466
+ var _this = this;
450
467
 
451
468
  var useReducer = function (reducer, initialArg, init) {
452
- _this2._validateCurrentlyRenderingComponent();
453
- _this2._createWorkInProgressHook();
454
- var workInProgressHook = _this2._workInProgressHook;
469
+ _this._validateCurrentlyRenderingComponent();
470
+
471
+ _this._createWorkInProgressHook();
472
+
473
+ var workInProgressHook = _this._workInProgressHook;
455
474
 
456
- if (_this2._isReRender) {
475
+ if (_this._isReRender) {
457
476
  // This is a re-render.
458
- var _queue = workInProgressHook.queue;
459
- var _dispatch = _queue.dispatch;
460
- if (_this2._numberOfReRenders > 0) {
477
+ var queue = workInProgressHook.queue;
478
+ var dispatch = queue.dispatch;
479
+
480
+ if (_this._numberOfReRenders > 0) {
461
481
  // Apply the new render phase updates to the previous current hook.
462
- if (_this2._renderPhaseUpdates !== null) {
482
+ if (_this._renderPhaseUpdates !== null) {
463
483
  // Render phase updates are stored in a map of queue -> linked list
464
- var firstRenderPhaseUpdate = _this2._renderPhaseUpdates.get(_queue);
484
+ var firstRenderPhaseUpdate = _this._renderPhaseUpdates.get(queue);
485
+
465
486
  if (firstRenderPhaseUpdate !== undefined) {
466
- _this2._renderPhaseUpdates.delete(_queue);
487
+ _this._renderPhaseUpdates.delete(queue);
488
+
467
489
  var _newState = workInProgressHook.memoizedState;
468
490
  var _update = firstRenderPhaseUpdate;
491
+
469
492
  do {
470
- var _action = _update.action;
471
- _newState = reducer(_newState, _action);
493
+ var action = _update.action;
494
+ _newState = reducer(_newState, action);
472
495
  _update = _update.next;
473
496
  } while (_update !== null);
497
+
474
498
  workInProgressHook.memoizedState = _newState;
475
- return [_newState, _dispatch];
499
+ return [_newState, dispatch];
476
500
  }
477
501
  }
478
- return [workInProgressHook.memoizedState, _dispatch];
479
- }
480
- // Process updates outside of render
502
+
503
+ return [workInProgressHook.memoizedState, dispatch];
504
+ } // Process updates outside of render
505
+
506
+
481
507
  var newState = workInProgressHook.memoizedState;
482
- var update = _queue.first;
508
+ var update = queue.first;
509
+
483
510
  if (update !== null) {
484
511
  do {
485
- var _action2 = update.action;
486
- newState = reducer(newState, _action2);
512
+ var _action = update.action;
513
+ newState = reducer(newState, _action);
487
514
  update = update.next;
488
515
  } while (update !== null);
489
- _queue.first = null;
516
+
517
+ queue.first = null;
490
518
  workInProgressHook.memoizedState = newState;
491
519
  }
492
- return [newState, _dispatch];
520
+
521
+ return [newState, dispatch];
493
522
  } else {
494
- var initialState = void 0;
523
+ var initialState;
524
+
495
525
  if (reducer === basicStateReducer) {
496
526
  // Special case for `useState`.
497
527
  initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
498
528
  } else {
499
529
  initialState = init !== undefined ? init(initialArg) : initialArg;
500
530
  }
531
+
501
532
  workInProgressHook.memoizedState = initialState;
502
- var _queue2 = workInProgressHook.queue = {
533
+
534
+ var _queue = workInProgressHook.queue = {
503
535
  first: null,
504
536
  dispatch: null
505
537
  };
506
- var _dispatch2 = _queue2.dispatch = _this2._dispatchAction.bind(_this2, _queue2);
507
- return [workInProgressHook.memoizedState, _dispatch2];
538
+
539
+ var _dispatch = _queue.dispatch = _this._dispatchAction.bind(_this, _queue);
540
+
541
+ return [workInProgressHook.memoizedState, _dispatch];
508
542
  }
509
543
  };
510
544
 
511
545
  var useState = function (initialState) {
512
- return useReducer(basicStateReducer,
513
- // useReducer has a special case to support lazy useState initializers
546
+ return useReducer(basicStateReducer, // useReducer has a special case to support lazy useState initializers
514
547
  initialState);
515
548
  };
516
549
 
517
550
  var useMemo = function (nextCreate, deps) {
518
- _this2._validateCurrentlyRenderingComponent();
519
- _this2._createWorkInProgressHook();
551
+ _this._validateCurrentlyRenderingComponent();
552
+
553
+ _this._createWorkInProgressHook();
520
554
 
521
555
  var nextDeps = deps !== undefined ? deps : null;
522
556
 
523
- if (_this2._workInProgressHook !== null && _this2._workInProgressHook.memoizedState !== null) {
524
- var prevState = _this2._workInProgressHook.memoizedState;
557
+ if (_this._workInProgressHook !== null && _this._workInProgressHook.memoizedState !== null) {
558
+ var prevState = _this._workInProgressHook.memoizedState;
525
559
  var prevDeps = prevState[1];
560
+
526
561
  if (nextDeps !== null) {
527
562
  if (areHookInputsEqual(nextDeps, prevDeps)) {
528
563
  return prevState[0];
@@ -531,20 +566,27 @@ var ReactShallowRenderer = function () {
531
566
  }
532
567
 
533
568
  var nextValue = nextCreate();
534
- _this2._workInProgressHook.memoizedState = [nextValue, nextDeps];
569
+ _this._workInProgressHook.memoizedState = [nextValue, nextDeps];
535
570
  return nextValue;
536
571
  };
537
572
 
538
573
  var useRef = function (initialValue) {
539
- _this2._validateCurrentlyRenderingComponent();
540
- _this2._createWorkInProgressHook();
541
- var previousRef = _this2._workInProgressHook.memoizedState;
574
+ _this._validateCurrentlyRenderingComponent();
575
+
576
+ _this._createWorkInProgressHook();
577
+
578
+ var previousRef = _this._workInProgressHook.memoizedState;
579
+
542
580
  if (previousRef === null) {
543
- var ref = { current: initialValue };
581
+ var ref = {
582
+ current: initialValue
583
+ };
584
+
544
585
  {
545
586
  Object.seal(ref);
546
587
  }
547
- _this2._workInProgressHook.memoizedState = ref;
588
+
589
+ _this._workInProgressHook.memoizedState = ref;
548
590
  return ref;
549
591
  } else {
550
592
  return previousRef;
@@ -556,7 +598,7 @@ var ReactShallowRenderer = function () {
556
598
  };
557
599
 
558
600
  var noOp = function () {
559
- _this2._validateCurrentlyRenderingComponent();
601
+ _this._validateCurrentlyRenderingComponent();
560
602
  };
561
603
 
562
604
  var identity = function (fn) {
@@ -568,13 +610,32 @@ var ReactShallowRenderer = function () {
568
610
  props: props,
569
611
  responder: responder
570
612
  };
613
+ }; // TODO: implement if we decide to keep the shallow renderer
614
+
615
+
616
+ var useTransition = function (config) {
617
+ _this._validateCurrentlyRenderingComponent();
618
+
619
+ var startTransition = function (callback) {
620
+ callback();
621
+ };
622
+
623
+ return [startTransition, false];
624
+ }; // TODO: implement if we decide to keep the shallow renderer
625
+
626
+
627
+ var useDeferredValue = function (value, config) {
628
+ _this._validateCurrentlyRenderingComponent();
629
+
630
+ return value;
571
631
  };
572
632
 
573
633
  return {
574
634
  readContext: readContext,
575
635
  useCallback: identity,
576
636
  useContext: function (context) {
577
- _this2._validateCurrentlyRenderingComponent();
637
+ _this._validateCurrentlyRenderingComponent();
638
+
578
639
  return readContext(context);
579
640
  },
580
641
  useDebugValue: noOp,
@@ -585,20 +646,18 @@ var ReactShallowRenderer = function () {
585
646
  useReducer: useReducer,
586
647
  useRef: useRef,
587
648
  useState: useState,
588
- useResponder: useResponder
649
+ useResponder: useResponder,
650
+ useTransition: useTransition,
651
+ useDeferredValue: useDeferredValue
589
652
  };
590
653
  };
591
654
 
592
- ReactShallowRenderer.prototype._dispatchAction = function _dispatchAction(queue, action) {
593
- var _this3 = this;
594
-
595
- (function () {
596
- if (!(_this3._numberOfReRenders < RE_RENDER_LIMIT)) {
597
- {
598
- throw ReactError(Error('Too many re-renders. React limits the number of renders to prevent an infinite loop.'));
599
- }
655
+ _proto2._dispatchAction = function _dispatchAction(queue, action) {
656
+ if (!(this._numberOfReRenders < RE_RENDER_LIMIT)) {
657
+ {
658
+ throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
600
659
  }
601
- })();
660
+ }
602
661
 
603
662
  if (this._rendering) {
604
663
  // This is a render phase update. Stash it in a lazily-created map of
@@ -610,43 +669,49 @@ var ReactShallowRenderer = function () {
610
669
  next: null
611
670
  };
612
671
  var renderPhaseUpdates = this._renderPhaseUpdates;
672
+
613
673
  if (renderPhaseUpdates === null) {
614
674
  this._renderPhaseUpdates = renderPhaseUpdates = new Map();
615
675
  }
676
+
616
677
  var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
678
+
617
679
  if (firstRenderPhaseUpdate === undefined) {
618
680
  renderPhaseUpdates.set(queue, update);
619
681
  } else {
620
682
  // Append the update to the end of the list.
621
683
  var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
684
+
622
685
  while (lastRenderPhaseUpdate.next !== null) {
623
686
  lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
624
687
  }
688
+
625
689
  lastRenderPhaseUpdate.next = update;
626
690
  }
627
691
  } else {
628
692
  var _update2 = {
629
693
  action: action,
630
694
  next: null
631
- };
695
+ }; // Append the update to the end of the list.
632
696
 
633
- // Append the update to the end of the list.
634
697
  var last = queue.first;
698
+
635
699
  if (last === null) {
636
700
  queue.first = _update2;
637
701
  } else {
638
702
  while (last.next !== null) {
639
703
  last = last.next;
640
704
  }
705
+
641
706
  last.next = _update2;
642
- }
707
+ } // Re-render now.
708
+
643
709
 
644
- // Re-render now.
645
710
  this.render(this._element, this._context);
646
711
  }
647
712
  };
648
713
 
649
- ReactShallowRenderer.prototype._createWorkInProgressHook = function _createWorkInProgressHook() {
714
+ _proto2._createWorkInProgressHook = function _createWorkInProgressHook() {
650
715
  if (this._workInProgressHook === null) {
651
716
  // This is the first hook in the list
652
717
  if (this._firstWorkInProgressHook === null) {
@@ -659,8 +724,8 @@ var ReactShallowRenderer = function () {
659
724
  }
660
725
  } else {
661
726
  if (this._workInProgressHook.next === null) {
662
- this._isReRender = false;
663
- // Append to the end of the list
727
+ this._isReRender = false; // Append to the end of the list
728
+
664
729
  this._workInProgressHook = this._workInProgressHook.next = createHook();
665
730
  } else {
666
731
  // There's already a work-in-progress. Reuse it.
@@ -668,19 +733,19 @@ var ReactShallowRenderer = function () {
668
733
  this._workInProgressHook = this._workInProgressHook.next;
669
734
  }
670
735
  }
736
+
671
737
  return this._workInProgressHook;
672
738
  };
673
739
 
674
- ReactShallowRenderer.prototype._finishHooks = function _finishHooks(element, context) {
740
+ _proto2._finishHooks = function _finishHooks(element, context) {
675
741
  if (this._didScheduleRenderPhaseUpdate) {
676
742
  // Updates were scheduled during the render phase. They are stored in
677
743
  // the `renderPhaseUpdates` map. Call the component again, reusing the
678
744
  // work-in-progress hooks and applying the additional updates on top. Keep
679
745
  // restarting until no more updates are scheduled.
680
746
  this._didScheduleRenderPhaseUpdate = false;
681
- this._numberOfReRenders += 1;
747
+ this._numberOfReRenders += 1; // Start over from the beginning of the list
682
748
 
683
- // Start over from the beginning of the list
684
749
  this._workInProgressHook = null;
685
750
  this._rendering = false;
686
751
  this.render(element, context);
@@ -691,56 +756,51 @@ var ReactShallowRenderer = function () {
691
756
  }
692
757
  };
693
758
 
694
- ReactShallowRenderer.prototype.getMountedInstance = function getMountedInstance() {
759
+ _proto2.getMountedInstance = function getMountedInstance() {
695
760
  return this._instance;
696
761
  };
697
762
 
698
- ReactShallowRenderer.prototype.getRenderOutput = function getRenderOutput() {
763
+ _proto2.getRenderOutput = function getRenderOutput() {
699
764
  return this._rendered;
700
765
  };
701
766
 
702
- ReactShallowRenderer.prototype.render = function render(element) {
767
+ _proto2.render = function render(element) {
703
768
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject;
704
769
 
705
- (function () {
706
- if (!React.isValidElement(element)) {
707
- {
708
- 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.' : '')));
709
- }
770
+ if (!React.isValidElement(element)) {
771
+ {
772
+ 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.' : ''));
710
773
  }
711
- })();
712
- element = element;
713
- // Show a special message for host elements since it's a common case.
714
- (function () {
715
- if (!(typeof element.type !== 'string')) {
716
- {
717
- 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.'));
718
- }
774
+ }
775
+
776
+ element = element; // Show a special message for host elements since it's a common case.
777
+
778
+ if (!(typeof element.type !== 'string')) {
779
+ {
780
+ 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.");
719
781
  }
720
- })();
721
- (function () {
722
- if (!(reactIs.isForwardRef(element) || typeof element.type === 'function' || reactIs.isMemo(element.type))) {
723
- {
724
- 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) + '`.'));
725
- }
782
+ }
783
+
784
+ if (!(reactIs.isForwardRef(element) || typeof element.type === 'function' || reactIs.isMemo(element.type))) {
785
+ {
786
+ 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) + "`.");
726
787
  }
727
- })();
788
+ }
728
789
 
729
790
  if (this._rendering) {
730
791
  return;
731
792
  }
793
+
732
794
  if (this._element != null && this._element.type !== element.type) {
733
795
  this._reset();
734
796
  }
735
797
 
736
798
  var elementType = reactIs.isMemo(element.type) ? element.type.type : element.type;
737
799
  var previousElement = this._element;
738
-
739
800
  this._rendering = true;
740
801
  this._element = element;
741
- this._context = getMaskedContext(elementType.contextTypes, context);
802
+ this._context = getMaskedContext(elementType.contextTypes, context); // Inner memo component props aren't currently validated in createElement.
742
803
 
743
- // Inner memo component props aren't currently validated in createElement.
744
804
  if (reactIs.isMemo(element.type) && elementType.propTypes) {
745
805
  currentlyValidatingElement = element;
746
806
  checkPropTypes(elementType.propTypes, element.props, 'prop', getComponentName(elementType), getStackAddendum);
@@ -751,8 +811,10 @@ var ReactShallowRenderer = function () {
751
811
  } else {
752
812
  if (shouldConstruct(elementType)) {
753
813
  this._instance = new elementType(element.props, this._context, this._updater);
814
+
754
815
  if (typeof elementType.getDerivedStateFromProps === 'function') {
755
816
  var partialState = elementType.getDerivedStateFromProps.call(null, element.props, this._instance.state);
817
+
756
818
  if (partialState != null) {
757
819
  this._instance.state = _assign({}, this._instance.state, partialState);
758
820
  }
@@ -761,34 +823,36 @@ var ReactShallowRenderer = function () {
761
823
  if (elementType.contextTypes) {
762
824
  currentlyValidatingElement = element;
763
825
  checkPropTypes(elementType.contextTypes, this._context, 'context', getName(elementType, this._instance), getStackAddendum);
764
-
765
826
  currentlyValidatingElement = null;
766
827
  }
767
828
 
768
829
  this._mountClassComponent(elementType, element, this._context);
769
830
  } else {
770
831
  var shouldRender = true;
832
+
771
833
  if (reactIs.isMemo(element.type) && previousElement !== null) {
772
834
  // This is a Memo component that is being re-rendered.
773
835
  var compare = element.type.compare || shallowEqual;
836
+
774
837
  if (compare(previousElement.props, element.props)) {
775
838
  shouldRender = false;
776
839
  }
777
840
  }
841
+
778
842
  if (shouldRender) {
779
843
  var prevDispatcher = ReactCurrentDispatcher.current;
780
844
  ReactCurrentDispatcher.current = this._dispatcher;
845
+
781
846
  try {
782
847
  // elementType could still be a ForwardRef if it was
783
848
  // nested inside Memo.
784
849
  if (elementType.$$typeof === reactIs.ForwardRef) {
785
- (function () {
786
- if (!(typeof elementType.render === 'function')) {
787
- {
788
- throw ReactError(Error('forwardRef requires a render function but was given ' + typeof elementType.render + '.'));
789
- }
850
+ if (!(typeof elementType.render === 'function')) {
851
+ {
852
+ throw Error("forwardRef requires a render function but was given " + typeof elementType.render + ".");
790
853
  }
791
- })();
854
+ }
855
+
792
856
  this._rendered = elementType.render.call(undefined, element.props, element.ref);
793
857
  } else {
794
858
  this._rendered = elementType(element.props, this._context);
@@ -796,61 +860,61 @@ var ReactShallowRenderer = function () {
796
860
  } finally {
797
861
  ReactCurrentDispatcher.current = prevDispatcher;
798
862
  }
863
+
799
864
  this._finishHooks(element, context);
800
865
  }
801
866
  }
802
867
  }
803
868
 
804
869
  this._rendering = false;
870
+
805
871
  this._updater._invokeCallbacks();
806
872
 
807
873
  return this.getRenderOutput();
808
874
  };
809
875
 
810
- ReactShallowRenderer.prototype.unmount = function unmount() {
876
+ _proto2.unmount = function unmount() {
811
877
  if (this._instance) {
812
878
  if (typeof this._instance.componentWillUnmount === 'function') {
813
879
  this._instance.componentWillUnmount();
814
880
  }
815
881
  }
882
+
816
883
  this._reset();
817
884
  };
818
885
 
819
- ReactShallowRenderer.prototype._mountClassComponent = function _mountClassComponent(elementType, element, context) {
886
+ _proto2._mountClassComponent = function _mountClassComponent(elementType, element, context) {
820
887
  this._instance.context = context;
821
888
  this._instance.props = element.props;
822
889
  this._instance.state = this._instance.state || null;
823
890
  this._instance.updater = this._updater;
824
891
 
825
892
  if (typeof this._instance.UNSAFE_componentWillMount === 'function' || typeof this._instance.componentWillMount === 'function') {
826
- var beforeState = this._newState;
827
-
828
- // In order to support react-lifecycles-compat polyfilled components,
893
+ var beforeState = this._newState; // In order to support react-lifecycles-compat polyfilled components,
829
894
  // Unsafe lifecycles should not be invoked for components using the new APIs.
895
+
830
896
  if (typeof elementType.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
831
897
  if (typeof this._instance.componentWillMount === 'function') {
832
898
  this._instance.componentWillMount();
833
899
  }
900
+
834
901
  if (typeof this._instance.UNSAFE_componentWillMount === 'function') {
835
902
  this._instance.UNSAFE_componentWillMount();
836
903
  }
837
- }
904
+ } // setState may have been called during cWM
905
+
838
906
 
839
- // setState may have been called during cWM
840
907
  if (beforeState !== this._newState) {
841
908
  this._instance.state = this._newState || emptyObject;
842
909
  }
843
910
  }
844
911
 
845
- this._rendered = this._instance.render();
846
- // Intentionally do not call componentDidMount()
912
+ this._rendered = this._instance.render(); // Intentionally do not call componentDidMount()
847
913
  // because DOM refs are not available.
848
914
  };
849
915
 
850
- ReactShallowRenderer.prototype._updateClassComponent = function _updateClassComponent(elementType, element, context) {
916
+ _proto2._updateClassComponent = function _updateClassComponent(elementType, element, context) {
851
917
  var props = element.props;
852
-
853
-
854
918
  var oldState = this._instance.state || emptyObject;
855
919
  var oldProps = this._instance.props;
856
920
 
@@ -861,22 +925,26 @@ var ReactShallowRenderer = function () {
861
925
  if (typeof this._instance.componentWillReceiveProps === 'function') {
862
926
  this._instance.componentWillReceiveProps(props, context);
863
927
  }
928
+
864
929
  if (typeof this._instance.UNSAFE_componentWillReceiveProps === 'function') {
865
930
  this._instance.UNSAFE_componentWillReceiveProps(props, context);
866
931
  }
867
932
  }
868
- }
933
+ } // Read state after cWRP in case it calls setState
934
+
869
935
 
870
- // Read state after cWRP in case it calls setState
871
936
  var state = this._newState || oldState;
937
+
872
938
  if (typeof elementType.getDerivedStateFromProps === 'function') {
873
939
  var partialState = elementType.getDerivedStateFromProps.call(null, props, state);
940
+
874
941
  if (partialState != null) {
875
942
  state = _assign({}, state, partialState);
876
943
  }
877
944
  }
878
945
 
879
946
  var shouldUpdate = true;
947
+
880
948
  if (this._forcedUpdate) {
881
949
  shouldUpdate = true;
882
950
  this._forcedUpdate = false;
@@ -893,6 +961,7 @@ var ReactShallowRenderer = function () {
893
961
  if (typeof this._instance.componentWillUpdate === 'function') {
894
962
  this._instance.componentWillUpdate(props, state, context);
895
963
  }
964
+
896
965
  if (typeof this._instance.UNSAFE_componentWillUpdate === 'function') {
897
966
  this._instance.UNSAFE_componentWillUpdate(props, state, context);
898
967
  }
@@ -906,9 +975,9 @@ var ReactShallowRenderer = function () {
906
975
 
907
976
  if (shouldUpdate) {
908
977
  this._rendered = this._instance.render();
909
- }
910
- // Intentionally do not call componentDidUpdate()
978
+ } // Intentionally do not call componentDidUpdate()
911
979
  // because DOM refs are not available.
980
+
912
981
  };
913
982
 
914
983
  return ReactShallowRenderer;
@@ -935,11 +1004,13 @@ function getDisplayName(element) {
935
1004
 
936
1005
  function getStackAddendum() {
937
1006
  var stack = '';
1007
+
938
1008
  if (currentlyValidatingElement) {
939
1009
  var name = getDisplayName(currentlyValidatingElement);
940
1010
  var owner = currentlyValidatingElement._owner;
941
1011
  stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
942
1012
  }
1013
+
943
1014
  return stack;
944
1015
  }
945
1016
 
@@ -956,10 +1027,13 @@ function getMaskedContext(contextTypes, unmaskedContext) {
956
1027
  if (!contextTypes || !unmaskedContext) {
957
1028
  return emptyObject;
958
1029
  }
1030
+
959
1031
  var context = {};
1032
+
960
1033
  for (var key in contextTypes) {
961
1034
  context[key] = unmaskedContext[key];
962
1035
  }
1036
+
963
1037
  return context;
964
1038
  }
965
1039
 
@@ -973,6 +1047,8 @@ var ReactShallowRenderer$3 = ( ReactShallowRenderer$2 && ReactShallowRenderer )
973
1047
 
974
1048
  // TODO: decide on the top-level export form.
975
1049
  // This is hacky but makes it work with both Rollup and Jest.
1050
+
1051
+
976
1052
  var shallow = ReactShallowRenderer$3.default || ReactShallowRenderer$3;
977
1053
 
978
1054
  module.exports = shallow;