react-test-renderer 16.8.0-alpha.1 → 16.8.3
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 +331 -20
- package/cjs/react-test-renderer-shallow.production.min.js +25 -17
- package/cjs/react-test-renderer.development.js +4974 -4132
- package/cjs/react-test-renderer.production.min.js +153 -149
- package/package.json +8 -4
- package/umd/react-test-renderer-shallow.development.js +331 -20
- package/umd/react-test-renderer-shallow.production.min.js +23 -16
- package/umd/react-test-renderer.development.js +4982 -4132
- package/umd/react-test-renderer.production.min.js +129 -124
package/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"branch": "pull/
|
|
3
|
-
"buildNumber": "
|
|
4
|
-
"checksum": "
|
|
5
|
-
"commit": "
|
|
2
|
+
"branch": "pull/14902",
|
|
3
|
+
"buildNumber": "13558",
|
|
4
|
+
"checksum": "9da4ab1",
|
|
5
|
+
"commit": "29b7b775f",
|
|
6
6
|
"environment": "ci",
|
|
7
|
-
"reactVersion": "16.
|
|
7
|
+
"reactVersion": "16.8.2-canary-29b7b775f"
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.8.
|
|
1
|
+
/** @license React v16.8.3
|
|
2
2
|
* react-test-renderer-shallow.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -268,13 +268,80 @@ function shallowEqual(objA, objB) {
|
|
|
268
268
|
return true;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
272
|
+
|
|
273
|
+
// Prevent newer renderers from RTE when used with older react package versions.
|
|
274
|
+
// Current owner and dispatcher used to share the same ref,
|
|
275
|
+
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
276
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
277
|
+
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
278
|
+
current: null
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
284
|
+
* This can be used to log issues in development environments in critical
|
|
285
|
+
* paths. Removing the logging code for production environments will keep the
|
|
286
|
+
* same logic and follow the same code paths.
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
var warning = warningWithoutStack$1;
|
|
290
|
+
|
|
291
|
+
{
|
|
292
|
+
warning = function (condition, format) {
|
|
293
|
+
if (condition) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
297
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
298
|
+
// eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
299
|
+
|
|
300
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
301
|
+
args[_key - 2] = arguments[_key];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
var warning$1 = warning;
|
|
309
|
+
|
|
271
310
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
272
311
|
|
|
312
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
var RE_RENDER_LIMIT = 25;
|
|
316
|
+
|
|
273
317
|
var emptyObject = {};
|
|
274
318
|
{
|
|
275
319
|
Object.freeze(emptyObject);
|
|
276
320
|
}
|
|
277
321
|
|
|
322
|
+
// In DEV, this is the name of the currently executing primitive hook
|
|
323
|
+
var currentHookNameInDev = void 0;
|
|
324
|
+
|
|
325
|
+
function areHookInputsEqual(nextDeps, prevDeps) {
|
|
326
|
+
if (prevDeps === null) {
|
|
327
|
+
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);
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Don't bother comparing lengths in prod because these arrays should be
|
|
332
|
+
// passed inline.
|
|
333
|
+
if (nextDeps.length !== prevDeps.length) {
|
|
334
|
+
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(', ') + ']');
|
|
335
|
+
}
|
|
336
|
+
for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
|
337
|
+
if (is(nextDeps[i], prevDeps[i])) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
|
|
278
345
|
var Updater = function () {
|
|
279
346
|
function Updater(renderer) {
|
|
280
347
|
_classCallCheck(this, Updater);
|
|
@@ -341,6 +408,18 @@ var Updater = function () {
|
|
|
341
408
|
return Updater;
|
|
342
409
|
}();
|
|
343
410
|
|
|
411
|
+
function createHook() {
|
|
412
|
+
return {
|
|
413
|
+
memoizedState: null,
|
|
414
|
+
queue: null,
|
|
415
|
+
next: null
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function basicStateReducer(state, action) {
|
|
420
|
+
return typeof action === 'function' ? action(state) : action;
|
|
421
|
+
}
|
|
422
|
+
|
|
344
423
|
var ReactShallowRenderer = function () {
|
|
345
424
|
function ReactShallowRenderer() {
|
|
346
425
|
_classCallCheck(this, ReactShallowRenderer);
|
|
@@ -353,8 +432,233 @@ var ReactShallowRenderer = function () {
|
|
|
353
432
|
this._rendering = false;
|
|
354
433
|
this._forcedUpdate = false;
|
|
355
434
|
this._updater = new Updater(this);
|
|
435
|
+
this._dispatcher = this._createDispatcher();
|
|
436
|
+
this._workInProgressHook = null;
|
|
437
|
+
this._firstWorkInProgressHook = null;
|
|
438
|
+
this._isReRender = false;
|
|
439
|
+
this._didScheduleRenderPhaseUpdate = false;
|
|
440
|
+
this._renderPhaseUpdates = null;
|
|
441
|
+
this._currentlyRenderingComponent = null;
|
|
442
|
+
this._numberOfReRenders = 0;
|
|
443
|
+
this._previousComponentIdentity = null;
|
|
356
444
|
}
|
|
357
445
|
|
|
446
|
+
ReactShallowRenderer.prototype._validateCurrentlyRenderingComponent = function _validateCurrentlyRenderingComponent() {
|
|
447
|
+
!(this._currentlyRenderingComponent !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)') : void 0;
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
ReactShallowRenderer.prototype._createDispatcher = function _createDispatcher() {
|
|
451
|
+
var _this = this;
|
|
452
|
+
|
|
453
|
+
var useReducer = function (reducer, initialArg, init) {
|
|
454
|
+
_this._validateCurrentlyRenderingComponent();
|
|
455
|
+
_this._createWorkInProgressHook();
|
|
456
|
+
var workInProgressHook = _this._workInProgressHook;
|
|
457
|
+
if (_this._isReRender) {
|
|
458
|
+
// This is a re-render. Apply the new render phase updates to the previous
|
|
459
|
+
var _queue = workInProgressHook.queue;
|
|
460
|
+
var _dispatch = _queue.dispatch;
|
|
461
|
+
if (_this._renderPhaseUpdates !== null) {
|
|
462
|
+
// Render phase updates are stored in a map of queue -> linked list
|
|
463
|
+
var firstRenderPhaseUpdate = _this._renderPhaseUpdates.get(_queue);
|
|
464
|
+
if (firstRenderPhaseUpdate !== undefined) {
|
|
465
|
+
_this._renderPhaseUpdates.delete(_queue);
|
|
466
|
+
var newState = workInProgressHook.memoizedState;
|
|
467
|
+
var update = firstRenderPhaseUpdate;
|
|
468
|
+
do {
|
|
469
|
+
// Process this render phase update. We don't have to check the
|
|
470
|
+
// priority because it will always be the same as the current
|
|
471
|
+
// render's.
|
|
472
|
+
var _action = update.action;
|
|
473
|
+
newState = reducer(newState, _action);
|
|
474
|
+
update = update.next;
|
|
475
|
+
} while (update !== null);
|
|
476
|
+
|
|
477
|
+
workInProgressHook.memoizedState = newState;
|
|
478
|
+
|
|
479
|
+
return [newState, _dispatch];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return [workInProgressHook.memoizedState, _dispatch];
|
|
483
|
+
} else {
|
|
484
|
+
var initialState = void 0;
|
|
485
|
+
if (reducer === basicStateReducer) {
|
|
486
|
+
// Special case for `useState`.
|
|
487
|
+
initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
|
|
488
|
+
} else {
|
|
489
|
+
initialState = init !== undefined ? init(initialArg) : initialArg;
|
|
490
|
+
}
|
|
491
|
+
workInProgressHook.memoizedState = initialState;
|
|
492
|
+
var _queue2 = workInProgressHook.queue = {
|
|
493
|
+
last: null,
|
|
494
|
+
dispatch: null
|
|
495
|
+
};
|
|
496
|
+
var _dispatch2 = _queue2.dispatch = _this._dispatchAction.bind(_this, _this._currentlyRenderingComponent, _queue2);
|
|
497
|
+
return [workInProgressHook.memoizedState, _dispatch2];
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
var useState = function (initialState) {
|
|
502
|
+
return useReducer(basicStateReducer,
|
|
503
|
+
// useReducer has a special case to support lazy useState initializers
|
|
504
|
+
initialState);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
var useMemo = function (nextCreate, deps) {
|
|
508
|
+
_this._validateCurrentlyRenderingComponent();
|
|
509
|
+
_this._createWorkInProgressHook();
|
|
510
|
+
|
|
511
|
+
var nextDeps = deps !== undefined ? deps : null;
|
|
512
|
+
|
|
513
|
+
if (_this._workInProgressHook !== null && _this._workInProgressHook.memoizedState !== null) {
|
|
514
|
+
var prevState = _this._workInProgressHook.memoizedState;
|
|
515
|
+
var prevDeps = prevState[1];
|
|
516
|
+
if (nextDeps !== null) {
|
|
517
|
+
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
|
518
|
+
return prevState[0];
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var nextValue = nextCreate();
|
|
524
|
+
_this._workInProgressHook.memoizedState = [nextValue, nextDeps];
|
|
525
|
+
return nextValue;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
var useRef = function (initialValue) {
|
|
529
|
+
_this._validateCurrentlyRenderingComponent();
|
|
530
|
+
_this._createWorkInProgressHook();
|
|
531
|
+
var previousRef = _this._workInProgressHook.memoizedState;
|
|
532
|
+
if (previousRef === null) {
|
|
533
|
+
var ref = { current: initialValue };
|
|
534
|
+
{
|
|
535
|
+
Object.seal(ref);
|
|
536
|
+
}
|
|
537
|
+
_this._workInProgressHook.memoizedState = ref;
|
|
538
|
+
return ref;
|
|
539
|
+
} else {
|
|
540
|
+
return previousRef;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
var readContext = function (context, observedBits) {
|
|
545
|
+
return context._currentValue;
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
var noOp = function () {
|
|
549
|
+
_this._validateCurrentlyRenderingComponent();
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
var identity = function (fn) {
|
|
553
|
+
return fn;
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
return {
|
|
557
|
+
readContext: readContext,
|
|
558
|
+
useCallback: identity,
|
|
559
|
+
useContext: function (context) {
|
|
560
|
+
_this._validateCurrentlyRenderingComponent();
|
|
561
|
+
return readContext(context);
|
|
562
|
+
},
|
|
563
|
+
useDebugValue: noOp,
|
|
564
|
+
useEffect: noOp,
|
|
565
|
+
useImperativeHandle: noOp,
|
|
566
|
+
useLayoutEffect: noOp,
|
|
567
|
+
useMemo: useMemo,
|
|
568
|
+
useReducer: useReducer,
|
|
569
|
+
useRef: useRef,
|
|
570
|
+
useState: useState
|
|
571
|
+
};
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
ReactShallowRenderer.prototype._dispatchAction = function _dispatchAction(componentIdentity, queue, action) {
|
|
575
|
+
!(this._numberOfReRenders < RE_RENDER_LIMIT) ? invariant(false, 'Too many re-renders. React limits the number of renders to prevent an infinite loop.') : void 0;
|
|
576
|
+
|
|
577
|
+
if (componentIdentity === this._currentlyRenderingComponent) {
|
|
578
|
+
// This is a render phase update. Stash it in a lazily-created map of
|
|
579
|
+
// queue -> linked list of updates. After this render pass, we'll restart
|
|
580
|
+
// and apply the stashed updates on top of the work-in-progress hook.
|
|
581
|
+
this._didScheduleRenderPhaseUpdate = true;
|
|
582
|
+
var update = {
|
|
583
|
+
action: action,
|
|
584
|
+
next: null
|
|
585
|
+
};
|
|
586
|
+
var renderPhaseUpdates = this._renderPhaseUpdates;
|
|
587
|
+
if (renderPhaseUpdates === null) {
|
|
588
|
+
this._renderPhaseUpdates = renderPhaseUpdates = new Map();
|
|
589
|
+
}
|
|
590
|
+
var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
|
|
591
|
+
if (firstRenderPhaseUpdate === undefined) {
|
|
592
|
+
renderPhaseUpdates.set(queue, update);
|
|
593
|
+
} else {
|
|
594
|
+
// Append the update to the end of the list.
|
|
595
|
+
var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
|
|
596
|
+
while (lastRenderPhaseUpdate.next !== null) {
|
|
597
|
+
lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
|
598
|
+
}
|
|
599
|
+
lastRenderPhaseUpdate.next = update;
|
|
600
|
+
}
|
|
601
|
+
} else {
|
|
602
|
+
// This means an update has happened after the function component has
|
|
603
|
+
// returned. On the server this is a no-op. In React Fiber, the update
|
|
604
|
+
// would be scheduled for a future render.
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
ReactShallowRenderer.prototype._createWorkInProgressHook = function _createWorkInProgressHook() {
|
|
609
|
+
if (this._workInProgressHook === null) {
|
|
610
|
+
// This is the first hook in the list
|
|
611
|
+
if (this._firstWorkInProgressHook === null) {
|
|
612
|
+
this._isReRender = false;
|
|
613
|
+
this._firstWorkInProgressHook = this._workInProgressHook = createHook();
|
|
614
|
+
} else {
|
|
615
|
+
// There's already a work-in-progress. Reuse it.
|
|
616
|
+
this._isReRender = true;
|
|
617
|
+
this._workInProgressHook = this._firstWorkInProgressHook;
|
|
618
|
+
}
|
|
619
|
+
} else {
|
|
620
|
+
if (this._workInProgressHook.next === null) {
|
|
621
|
+
this._isReRender = false;
|
|
622
|
+
// Append to the end of the list
|
|
623
|
+
this._workInProgressHook = this._workInProgressHook.next = createHook();
|
|
624
|
+
} else {
|
|
625
|
+
// There's already a work-in-progress. Reuse it.
|
|
626
|
+
this._isReRender = true;
|
|
627
|
+
this._workInProgressHook = this._workInProgressHook.next;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return this._workInProgressHook;
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
ReactShallowRenderer.prototype._prepareToUseHooks = function _prepareToUseHooks(componentIdentity) {
|
|
634
|
+
if (this._previousComponentIdentity !== null && this._previousComponentIdentity !== componentIdentity) {
|
|
635
|
+
this._firstWorkInProgressHook = null;
|
|
636
|
+
}
|
|
637
|
+
this._currentlyRenderingComponent = componentIdentity;
|
|
638
|
+
this._previousComponentIdentity = componentIdentity;
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
ReactShallowRenderer.prototype._finishHooks = function _finishHooks(element, context) {
|
|
642
|
+
if (this._didScheduleRenderPhaseUpdate) {
|
|
643
|
+
// Updates were scheduled during the render phase. They are stored in
|
|
644
|
+
// the `renderPhaseUpdates` map. Call the component again, reusing the
|
|
645
|
+
// work-in-progress hooks and applying the additional updates on top. Keep
|
|
646
|
+
// restarting until no more updates are scheduled.
|
|
647
|
+
this._didScheduleRenderPhaseUpdate = false;
|
|
648
|
+
this._numberOfReRenders += 1;
|
|
649
|
+
|
|
650
|
+
// Start over from the beginning of the list
|
|
651
|
+
this._workInProgressHook = null;
|
|
652
|
+
this._rendering = false;
|
|
653
|
+
this.render(element, context);
|
|
654
|
+
} else {
|
|
655
|
+
this._currentlyRenderingComponent = null;
|
|
656
|
+
this._workInProgressHook = null;
|
|
657
|
+
this._renderPhaseUpdates = null;
|
|
658
|
+
this._numberOfReRenders = 0;
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
|
|
358
662
|
ReactShallowRenderer.prototype.getMountedInstance = function getMountedInstance() {
|
|
359
663
|
return this._instance;
|
|
360
664
|
};
|
|
@@ -367,6 +671,7 @@ var ReactShallowRenderer = function () {
|
|
|
367
671
|
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject;
|
|
368
672
|
|
|
369
673
|
!React.isValidElement(element) ? invariant(false, 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : void 0;
|
|
674
|
+
element = element;
|
|
370
675
|
// Show a special message for host elements since it's a common case.
|
|
371
676
|
!(typeof element.type !== 'string') ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom components, not primitives (%s). Instead of calling `.render(el)` and inspecting the rendered output, look at `el.props` directly instead.', element.type) : void 0;
|
|
372
677
|
!(reactIs.isForwardRef(element) || typeof element.type === 'function') ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom components, but the provided element type was `%s`.', Array.isArray(element.type) ? 'array' : element.type === null ? 'null' : typeof element.type) : void 0;
|
|
@@ -387,7 +692,12 @@ var ReactShallowRenderer = function () {
|
|
|
387
692
|
} else if (shouldConstruct(element.type)) {
|
|
388
693
|
this._instance = new element.type(element.props, this._context, this._updater);
|
|
389
694
|
|
|
390
|
-
|
|
695
|
+
if (typeof element.type.getDerivedStateFromProps === 'function') {
|
|
696
|
+
var partialState = element.type.getDerivedStateFromProps.call(null, element.props, this._instance.state);
|
|
697
|
+
if (partialState != null) {
|
|
698
|
+
this._instance.state = _assign({}, this._instance.state, partialState);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
391
701
|
|
|
392
702
|
if (element.type.hasOwnProperty('contextTypes')) {
|
|
393
703
|
currentlyValidatingElement = element;
|
|
@@ -399,7 +709,15 @@ var ReactShallowRenderer = function () {
|
|
|
399
709
|
|
|
400
710
|
this._mountClassComponent(element, this._context);
|
|
401
711
|
} else {
|
|
402
|
-
|
|
712
|
+
var prevDispatcher = ReactCurrentDispatcher.current;
|
|
713
|
+
ReactCurrentDispatcher.current = this._dispatcher;
|
|
714
|
+
this._prepareToUseHooks(element.type);
|
|
715
|
+
try {
|
|
716
|
+
this._rendered = element.type.call(undefined, element.props, this._context);
|
|
717
|
+
} finally {
|
|
718
|
+
ReactCurrentDispatcher.current = prevDispatcher;
|
|
719
|
+
}
|
|
720
|
+
this._finishHooks(element, context);
|
|
403
721
|
}
|
|
404
722
|
}
|
|
405
723
|
|
|
@@ -416,6 +734,8 @@ var ReactShallowRenderer = function () {
|
|
|
416
734
|
}
|
|
417
735
|
}
|
|
418
736
|
|
|
737
|
+
this._firstWorkInProgressHook = null;
|
|
738
|
+
this._previousComponentIdentity = null;
|
|
419
739
|
this._context = null;
|
|
420
740
|
this._element = null;
|
|
421
741
|
this._newState = null;
|
|
@@ -474,10 +794,15 @@ var ReactShallowRenderer = function () {
|
|
|
474
794
|
}
|
|
475
795
|
}
|
|
476
796
|
}
|
|
477
|
-
this._updateStateFromStaticLifecycle(props);
|
|
478
797
|
|
|
479
798
|
// Read state after cWRP in case it calls setState
|
|
480
799
|
var state = this._newState || oldState;
|
|
800
|
+
if (typeof type.getDerivedStateFromProps === 'function') {
|
|
801
|
+
var partialState = type.getDerivedStateFromProps.call(null, props, state);
|
|
802
|
+
if (partialState != null) {
|
|
803
|
+
state = _assign({}, state, partialState);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
481
806
|
|
|
482
807
|
var shouldUpdate = true;
|
|
483
808
|
if (this._forcedUpdate) {
|
|
@@ -505,6 +830,7 @@ var ReactShallowRenderer = function () {
|
|
|
505
830
|
this._instance.context = context;
|
|
506
831
|
this._instance.props = props;
|
|
507
832
|
this._instance.state = state;
|
|
833
|
+
this._newState = null;
|
|
508
834
|
|
|
509
835
|
if (shouldUpdate) {
|
|
510
836
|
this._rendered = this._instance.render();
|
|
@@ -513,21 +839,6 @@ var ReactShallowRenderer = function () {
|
|
|
513
839
|
// because DOM refs are not available.
|
|
514
840
|
};
|
|
515
841
|
|
|
516
|
-
ReactShallowRenderer.prototype._updateStateFromStaticLifecycle = function _updateStateFromStaticLifecycle(props) {
|
|
517
|
-
var type = this._element.type;
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (typeof type.getDerivedStateFromProps === 'function') {
|
|
521
|
-
var oldState = this._newState || this._instance.state;
|
|
522
|
-
var partialState = type.getDerivedStateFromProps.call(null, props, oldState);
|
|
523
|
-
|
|
524
|
-
if (partialState != null) {
|
|
525
|
-
var newState = _assign({}, oldState, partialState);
|
|
526
|
-
this._instance.state = this._newState = newState;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
|
|
531
842
|
return ReactShallowRenderer;
|
|
532
843
|
}();
|
|
533
844
|
|
|
@@ -569,7 +880,7 @@ function shouldConstruct(Component) {
|
|
|
569
880
|
}
|
|
570
881
|
|
|
571
882
|
function getMaskedContext(contextTypes, unmaskedContext) {
|
|
572
|
-
if (!contextTypes) {
|
|
883
|
+
if (!contextTypes || !unmaskedContext) {
|
|
573
884
|
return emptyObject;
|
|
574
885
|
}
|
|
575
886
|
var context = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.8.
|
|
1
|
+
/** @license React v16.8.3
|
|
2
2
|
* react-test-renderer-shallow.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -7,20 +7,28 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
'use strict';var
|
|
10
|
+
'use strict';var g=require("object-assign"),h=require("react"),m=require("react-is"),p=require("prop-types/checkPropTypes");function q(a,b,d,c,e,l,n,k){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[d,c,e,l,n,k],H=0;a=Error(b.replace(/%s/g,function(){return f[H++]}));a.name="Invariant Violation"}a.framesToPop=1;throw a;}}
|
|
11
11
|
function r(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)d+="&args[]="+encodeURIComponent(arguments[c+1]);q(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",d)}
|
|
12
|
-
var t=/^(.*)[\\\/]/,u="function"===typeof Symbol&&Symbol.for,v=u?Symbol.for("react.portal"):60106,w=u?Symbol.for("react.fragment"):60107,x=u?Symbol.for("react.strict_mode"):60108,y=u?Symbol.for("react.profiler"):60114,z=u?Symbol.for("react.provider"):60109,A=u?Symbol.for("react.context"):60110,B=u?Symbol.for("react.concurrent_mode"):60111,C=u?Symbol.for("react.forward_ref"):60112,
|
|
13
|
-
function
|
|
14
|
-
case
|
|
15
|
-
function
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
this._renderer._context))};return a}()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function
|
|
12
|
+
var t=/^(.*)[\\\/]/,u="function"===typeof Symbol&&Symbol.for,v=u?Symbol.for("react.portal"):60106,w=u?Symbol.for("react.fragment"):60107,x=u?Symbol.for("react.strict_mode"):60108,y=u?Symbol.for("react.profiler"):60114,z=u?Symbol.for("react.provider"):60109,A=u?Symbol.for("react.context"):60110,B=u?Symbol.for("react.concurrent_mode"):60111,C=u?Symbol.for("react.forward_ref"):60112,D=u?Symbol.for("react.suspense"):60113,E=u?Symbol.for("react.memo"):60115,F=u?Symbol.for("react.lazy"):60116;
|
|
13
|
+
function G(a){if(null==a)return null;if("function"===typeof a)return a.displayName||a.name||null;if("string"===typeof a)return a;switch(a){case B:return"ConcurrentMode";case w:return"Fragment";case v:return"Portal";case y:return"Profiler";case x:return"StrictMode";case D:return"Suspense"}if("object"===typeof a)switch(a.$$typeof){case A:return"Context.Consumer";case z:return"Context.Provider";case C:var b=a.render;b=b.displayName||b.name||"";return a.displayName||(""!==b?"ForwardRef("+b+")":"ForwardRef");
|
|
14
|
+
case E:return G(a.type);case F:if(a=1===a._status?a._result:null)return G(a)}return null}function I(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var J=Object.prototype.hasOwnProperty;function K(a,b){if(I(a,b))return!0;if("object"!==typeof a||null===a||"object"!==typeof b||null===b)return!1;var d=Object.keys(a),c=Object.keys(b);if(d.length!==c.length)return!1;for(c=0;c<d.length;c++)if(!J.call(b,d[c])||!I(a[d[c]],b[d[c]]))return!1;return!0}var L=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
15
|
+
L.hasOwnProperty("ReactCurrentDispatcher")||(L.ReactCurrentDispatcher={current:null});function M(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}
|
|
16
|
+
var N=L.ReactCurrentDispatcher,O={},P=function(){function a(b){M(this,a);this._renderer=b;this._callbacks=[]}a.prototype._enqueueCallback=function(b,a){"function"===typeof b&&a&&this._callbacks.push({callback:b,publicInstance:a})};a.prototype._invokeCallbacks=function(){var b=this._callbacks;this._callbacks=[];b.forEach(function(b){b.callback.call(b.publicInstance)})};a.prototype.isMounted=function(){return!!this._renderer._element};a.prototype.enqueueForceUpdate=function(b,a){this._enqueueCallback(a,
|
|
17
|
+
b);this._renderer._forcedUpdate=!0;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueReplaceState=function(b,a,c){this._enqueueCallback(c,b);this._renderer._newState=a;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueSetState=function(b,a,c){this._enqueueCallback(c,b);c=this._renderer._newState||b.state;"function"===typeof a&&(a=a.call(b,c,b.props));null!==a&&void 0!==a&&(this._renderer._newState=g({},c,a),this._renderer.render(this._renderer._element,
|
|
18
|
+
this._renderer._context))};return a}();function Q(){return{memoizedState:null,queue:null,next:null}}function R(a,b){return"function"===typeof b?b(a):b}
|
|
19
|
+
var U=function(){function a(){M(this,a);this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new P(this);this._dispatcher=this._createDispatcher();this._firstWorkInProgressHook=this._workInProgressHook=null;this._didScheduleRenderPhaseUpdate=this._isReRender=!1;this._currentlyRenderingComponent=this._renderPhaseUpdates=null;this._numberOfReRenders=0;this._previousComponentIdentity=null}a.prototype._validateCurrentlyRenderingComponent=
|
|
20
|
+
function(){null===this._currentlyRenderingComponent?r("307"):void 0};a.prototype._createDispatcher=function(){function b(){c._validateCurrentlyRenderingComponent()}function a(b,a,d){c._validateCurrentlyRenderingComponent();c._createWorkInProgressHook();var e=c._workInProgressHook;if(c._isReRender){var f=e.queue;a=f.dispatch;if(null!==c._renderPhaseUpdates&&(d=c._renderPhaseUpdates.get(f),void 0!==d)){c._renderPhaseUpdates.delete(f);f=e.memoizedState;do f=b(f,d.action),d=d.next;while(null!==d);e.memoizedState=
|
|
21
|
+
f;return[f,a]}return[e.memoizedState,a]}b=b===R?"function"===typeof a?a():a:void 0!==d?d(a):a;e.memoizedState=b;b=e.queue={last:null,dispatch:null};b=b.dispatch=c._dispatchAction.bind(c,c._currentlyRenderingComponent,b);return[e.memoizedState,b]}var c=this;return{readContext:function(b){return b._currentValue},useCallback:function(b){return b},useContext:function(b){c._validateCurrentlyRenderingComponent();return b._currentValue},useDebugValue:b,useEffect:b,useImperativeHandle:b,useLayoutEffect:b,
|
|
22
|
+
useMemo:function(b,a){c._validateCurrentlyRenderingComponent();c._createWorkInProgressHook();a=void 0!==a?a:null;if(null!==c._workInProgressHook&&null!==c._workInProgressHook.memoizedState){var d=c._workInProgressHook.memoizedState,e=d[1];if(null!==a){a:if(null===e)e=!1;else{for(var f=0;f<e.length&&f<a.length;f++)if(!I(a[f],e[f])){e=!1;break a}e=!0}if(e)return d[0]}}b=b();c._workInProgressHook.memoizedState=[b,a];return b},useReducer:a,useRef:function(b){c._validateCurrentlyRenderingComponent();c._createWorkInProgressHook();
|
|
23
|
+
var a=c._workInProgressHook.memoizedState;return null===a?(b={current:b},c._workInProgressHook.memoizedState=b):a},useState:function(b){return a(R,b)}}};a.prototype._dispatchAction=function(b,a,c){25>this._numberOfReRenders?void 0:r("301");if(b===this._currentlyRenderingComponent){this._didScheduleRenderPhaseUpdate=!0;b={action:c,next:null};c=this._renderPhaseUpdates;null===c&&(this._renderPhaseUpdates=c=new Map);var d=c.get(a);if(void 0===d)c.set(a,b);else{for(a=d;null!==a.next;)a=a.next;a.next=
|
|
24
|
+
b}}};a.prototype._createWorkInProgressHook=function(){null===this._workInProgressHook?null===this._firstWorkInProgressHook?(this._isReRender=!1,this._firstWorkInProgressHook=this._workInProgressHook=Q()):(this._isReRender=!0,this._workInProgressHook=this._firstWorkInProgressHook):null===this._workInProgressHook.next?(this._isReRender=!1,this._workInProgressHook=this._workInProgressHook.next=Q()):(this._isReRender=!0,this._workInProgressHook=this._workInProgressHook.next);return this._workInProgressHook};
|
|
25
|
+
a.prototype._prepareToUseHooks=function(b){null!==this._previousComponentIdentity&&this._previousComponentIdentity!==b&&(this._firstWorkInProgressHook=null);this._previousComponentIdentity=this._currentlyRenderingComponent=b};a.prototype._finishHooks=function(b,a){this._didScheduleRenderPhaseUpdate?(this._didScheduleRenderPhaseUpdate=!1,this._numberOfReRenders+=1,this._workInProgressHook=null,this._rendering=!1,this.render(b,a)):(this._renderPhaseUpdates=this._workInProgressHook=this._currentlyRenderingComponent=
|
|
26
|
+
null,this._numberOfReRenders=0)};a.prototype.getMountedInstance=function(){return this._instance};a.prototype.getRenderOutput=function(){return this._rendered};a.prototype.render=function(b){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:O;h.isValidElement(b)?void 0:r("12","function"===typeof b?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":"");"string"===typeof b.type?r("13",b.type):void 0;m.isForwardRef(b)||"function"===typeof b.type?
|
|
27
|
+
void 0:r("249",Array.isArray(b.type)?"array":null===b.type?"null":typeof b.type);if(!this._rendering){this._rendering=!0;this._element=b;var c;if((c=b.type.contextTypes)&&a){var e={},l;for(l in c)e[l]=a[l];c=e}else c=O;this._context=c;if(this._instance)this._updateClassComponent(b,this._context);else if(m.isForwardRef(b))this._rendered=b.type.render(b.props,b.ref);else if(c=b.type,c.prototype&&c.prototype.isReactComponent)this._instance=new b.type(b.props,this._context,this._updater),"function"===
|
|
28
|
+
typeof b.type.getDerivedStateFromProps&&(a=b.type.getDerivedStateFromProps.call(null,b.props,this._instance.state),null!=a&&(this._instance.state=g({},this._instance.state,a))),b.type.hasOwnProperty("contextTypes")&&(S=b,a=b.type,c=(c=this._instance)&&c.constructor,p(b.type.contextTypes,this._context,"context",a.displayName||c&&c.displayName||a.name||c&&c.name||null,T),S=null),this._mountClassComponent(b,this._context);else{c=N.current;N.current=this._dispatcher;this._prepareToUseHooks(b.type);try{this._rendered=
|
|
29
|
+
b.type.call(void 0,b.props,this._context)}finally{N.current=c}this._finishHooks(b,a)}this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};a.prototype.unmount=function(){this._instance&&"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=this._previousComponentIdentity=this._firstWorkInProgressHook=null};a.prototype._mountClassComponent=function(b,a){this._instance.context=
|
|
30
|
+
a;this._instance.props=b.props;this._instance.state=this._instance.state||null;this._instance.updater=this._updater;if("function"===typeof this._instance.UNSAFE_componentWillMount||"function"===typeof this._instance.componentWillMount)a=this._newState,"function"!==typeof b.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillMount&&this._instance.componentWillMount(),"function"===typeof this._instance.UNSAFE_componentWillMount&&
|
|
31
|
+
this._instance.UNSAFE_componentWillMount()),a!==this._newState&&(this._instance.state=this._newState||O);this._rendered=this._instance.render()};a.prototype._updateClassComponent=function(a,d){var b=a.props,e=a.type,l=this._instance.state||O,n=this._instance.props;n!==b&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&this._instance.componentWillReceiveProps(b,d),"function"===
|
|
32
|
+
typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(b,d));var k=this._newState||l;if("function"===typeof e.getDerivedStateFromProps){var f=e.getDerivedStateFromProps.call(null,b,k);null!=f&&(k=g({},k,f))}f=!0;this._forcedUpdate?(f=!0,this._forcedUpdate=!1):"function"===typeof this._instance.shouldComponentUpdate?f=!!this._instance.shouldComponentUpdate(b,k,d):e.prototype&&e.prototype.isPureReactComponent&&(f=!K(n,b)||!K(l,k));f&&"function"!==typeof a.type.getDerivedStateFromProps&&
|
|
33
|
+
"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(b,k,d),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(b,k,d));this._instance.context=d;this._instance.props=b;this._instance.state=k;this._newState=null;f&&(this._rendered=this._instance.render())};return a}();U.createRenderer=function(){return new U};var S=null;
|
|
34
|
+
function T(){var a="";if(S){var b=null==S?"#empty":"string"===typeof S||"number"===typeof S?"#text":"string"===typeof S.type?S.type:S.type.displayName||S.type.name||"Unknown",d=S._owner,c=S._source;d=d&&G(d.type);var e="";c?e=" (at "+c.fileName.replace(t,"")+":"+c.lineNumber+")":d&&(e=" (created by "+d+")");a+="\n in "+(b||"Unknown")+e}return a}var V={default:U},W=V&&U||V;module.exports=W.default||W;
|