UNPKG

614 kBJavaScriptView Raw
1/** @license React v0.22.0
2 * react-reconciler-persistent.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12if (process.env.NODE_ENV !== "production") {
13 module.exports = function $$$reconciler($$$hostConfig) {
14'use strict';
15
16var _assign = require('object-assign');
17var React = require('react');
18var checkPropTypes = require('prop-types/checkPropTypes');
19var Scheduler = require('scheduler');
20var tracing = require('scheduler/tracing');
21
22// Do not require this module directly! Use normal `invariant` calls with
23// template literal strings. The messages will be converted to ReactError during
24// build, and in production they will be minified.
25
26// Do not require this module directly! Use normal `invariant` calls with
27// template literal strings. The messages will be converted to ReactError during
28// build, and in production they will be minified.
29function ReactError(error) {
30 error.name = 'Invariant Violation';
31 return error;
32}
33
34var FunctionComponent = 0;
35var ClassComponent = 1;
36var IndeterminateComponent = 2; // Before we know whether it is function or class
37
38var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
39
40var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
41
42var HostComponent = 5;
43var HostText = 6;
44var Fragment = 7;
45var Mode = 8;
46var ContextConsumer = 9;
47var ContextProvider = 10;
48var ForwardRef = 11;
49var Profiler = 12;
50var SuspenseComponent = 13;
51var MemoComponent = 14;
52var SimpleMemoComponent = 15;
53var LazyComponent = 16;
54var IncompleteClassComponent = 17;
55var DehydratedFragment = 18;
56var SuspenseListComponent = 19;
57var FundamentalComponent = 20;
58var ScopeComponent = 21;
59
60/**
61 * Use invariant() to assert state which your program assumes to be true.
62 *
63 * Provide sprintf-style format (only %s is supported) and arguments
64 * to provide information about what broke and what you were
65 * expecting.
66 *
67 * The invariant message will be stripped in production, but the invariant
68 * will remain to ensure logic does not differ in production.
69 */
70
71/**
72 * Similar to invariant but only logs a warning if the condition is not met.
73 * This can be used to log issues in development environments in critical
74 * paths. Removing the logging code for production environments will keep the
75 * same logic and follow the same code paths.
76 */
77var warningWithoutStack = function () {};
78
79{
80 warningWithoutStack = function (condition, format) {
81 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
82 args[_key - 2] = arguments[_key];
83 }
84
85 if (format === undefined) {
86 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
87 }
88
89 if (args.length > 8) {
90 // Check before the condition to catch violations early.
91 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
92 }
93
94 if (condition) {
95 return;
96 }
97
98 if (typeof console !== 'undefined') {
99 var argsWithFormat = args.map(function (item) {
100 return '' + item;
101 });
102 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
103 // breaks IE9: https://github.com/facebook/react/issues/13610
104
105 Function.prototype.apply.call(console.error, console, argsWithFormat);
106 }
107
108 try {
109 // --- Welcome to debugging React ---
110 // This error was thrown as a convenience so that you can use this stack
111 // to find the callsite that caused this warning to fire.
112 var argIndex = 0;
113 var message = 'Warning: ' + format.replace(/%s/g, function () {
114 return args[argIndex++];
115 });
116 throw new Error(message);
117 } catch (x) {}
118 };
119}
120
121var warningWithoutStack$1 = warningWithoutStack;
122
123/**
124 * `ReactInstanceMap` maintains a mapping from a public facing stateful
125 * instance (key) and the internal representation (value). This allows public
126 * methods to accept the user facing instance as an argument and map them back
127 * to internal methods.
128 *
129 * Note that this module is currently shared and assumed to be stateless.
130 * If this becomes an actual Map, that will break.
131 */
132
133/**
134 * This API should be called `delete` but we'd have to make sure to always
135 * transform these to strings for IE support. When this transform is fully
136 * supported we can rename it.
137 */
138
139function get(key) {
140 return key._reactInternalFiber;
141}
142
143function set(key, value) {
144 key._reactInternalFiber = value;
145}
146
147var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
148// Current owner and dispatcher used to share the same ref,
149// but PR #14548 split them out to better support the react-debug-tools package.
150
151if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
152 ReactSharedInternals.ReactCurrentDispatcher = {
153 current: null
154 };
155}
156
157if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
158 ReactSharedInternals.ReactCurrentBatchConfig = {
159 suspense: null
160 };
161}
162
163// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
164// nor polyfill, then a plain number is used for performance.
165var hasSymbol = typeof Symbol === 'function' && Symbol.for;
166var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
167var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
168var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
169var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
170var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
171var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
172var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
173// (unstable) APIs that have been removed. Can we remove the symbols?
174
175
176var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
177var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
178var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
179var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
180var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
181var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
182var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
183var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
184var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
185var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
186var FAUX_ITERATOR_SYMBOL = '@@iterator';
187function getIteratorFn(maybeIterable) {
188 if (maybeIterable === null || typeof maybeIterable !== 'object') {
189 return null;
190 }
191
192 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
193
194 if (typeof maybeIterator === 'function') {
195 return maybeIterator;
196 }
197
198 return null;
199}
200
201/**
202 * Similar to invariant but only logs a warning if the condition is not met.
203 * This can be used to log issues in development environments in critical
204 * paths. Removing the logging code for production environments will keep the
205 * same logic and follow the same code paths.
206 */
207
208var warning = warningWithoutStack$1;
209
210{
211 warning = function (condition, format) {
212 if (condition) {
213 return;
214 }
215
216 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
217 var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
218
219 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
220 args[_key - 2] = arguments[_key];
221 }
222
223 warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
224 };
225}
226
227var warning$1 = warning;
228
229var Uninitialized = -1;
230var Pending = 0;
231var Resolved = 1;
232var Rejected = 2;
233function refineResolvedLazyComponent(lazyComponent) {
234 return lazyComponent._status === Resolved ? lazyComponent._result : null;
235}
236function initializeLazyComponentType(lazyComponent) {
237 if (lazyComponent._status === Uninitialized) {
238 lazyComponent._status = Pending;
239 var ctor = lazyComponent._ctor;
240 var thenable = ctor();
241 lazyComponent._result = thenable;
242 thenable.then(function (moduleObject) {
243 if (lazyComponent._status === Pending) {
244 var defaultExport = moduleObject.default;
245
246 {
247 if (defaultExport === undefined) {
248 warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
249 }
250 }
251
252 lazyComponent._status = Resolved;
253 lazyComponent._result = defaultExport;
254 }
255 }, function (error) {
256 if (lazyComponent._status === Pending) {
257 lazyComponent._status = Rejected;
258 lazyComponent._result = error;
259 }
260 });
261 }
262}
263
264function getWrappedName(outerType, innerType, wrapperName) {
265 var functionName = innerType.displayName || innerType.name || '';
266 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
267}
268
269function getComponentName(type) {
270 if (type == null) {
271 // Host root, text node or just invalid type.
272 return null;
273 }
274
275 {
276 if (typeof type.tag === 'number') {
277 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
278 }
279 }
280
281 if (typeof type === 'function') {
282 return type.displayName || type.name || null;
283 }
284
285 if (typeof type === 'string') {
286 return type;
287 }
288
289 switch (type) {
290 case REACT_FRAGMENT_TYPE:
291 return 'Fragment';
292
293 case REACT_PORTAL_TYPE:
294 return 'Portal';
295
296 case REACT_PROFILER_TYPE:
297 return "Profiler";
298
299 case REACT_STRICT_MODE_TYPE:
300 return 'StrictMode';
301
302 case REACT_SUSPENSE_TYPE:
303 return 'Suspense';
304
305 case REACT_SUSPENSE_LIST_TYPE:
306 return 'SuspenseList';
307 }
308
309 if (typeof type === 'object') {
310 switch (type.$$typeof) {
311 case REACT_CONTEXT_TYPE:
312 return 'Context.Consumer';
313
314 case REACT_PROVIDER_TYPE:
315 return 'Context.Provider';
316
317 case REACT_FORWARD_REF_TYPE:
318 return getWrappedName(type, type.render, 'ForwardRef');
319
320 case REACT_MEMO_TYPE:
321 return getComponentName(type.type);
322
323 case REACT_LAZY_TYPE:
324 {
325 var thenable = type;
326 var resolvedThenable = refineResolvedLazyComponent(thenable);
327
328 if (resolvedThenable) {
329 return getComponentName(resolvedThenable);
330 }
331
332 break;
333 }
334 }
335 }
336
337 return null;
338}
339
340// Don't change these two values. They're used by React Dev Tools.
341var NoEffect =
342/* */
3430;
344var PerformedWork =
345/* */
3461; // You can change the rest (and add more).
347
348var Placement =
349/* */
3502;
351var Update =
352/* */
3534;
354var PlacementAndUpdate =
355/* */
3566;
357var Deletion =
358/* */
3598;
360var ContentReset =
361/* */
36216;
363var Callback =
364/* */
36532;
366var DidCapture =
367/* */
36864;
369var Ref =
370/* */
371128;
372var Snapshot =
373/* */
374256;
375var Passive =
376/* */
377512;
378var Hydrating =
379/* */
3801024;
381var HydratingAndUpdate =
382/* */
3831028; // Passive & Update & Callback & Ref & Snapshot
384
385var LifecycleEffectMask =
386/* */
387932; // Union of all host effects
388
389var HostEffectMask =
390/* */
3912047;
392var Incomplete =
393/* */
3942048;
395var ShouldCapture =
396/* */
3974096;
398
399var debugRenderPhaseSideEffects = false;
400var debugRenderPhaseSideEffectsForStrictMode = false;
401var enableUserTimingAPI = true;
402var warnAboutDeprecatedLifecycles = true;
403var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
404var enableProfilerTimer = true;
405var enableSchedulerTracing = true;
406var enableSuspenseServerRenderer = false;
407
408
409
410
411
412
413
414var enableFlareAPI = false;
415var enableFundamentalAPI = false;
416var enableScopeAPI = false;
417
418var warnAboutUnmockedScheduler = true;
419var flushSuspenseFallbacksInTests = true;
420
421var enableSuspenseCallback = false;
422var warnAboutDefaultPropsOnFunctionComponents = false;
423var warnAboutStringRefs = false;
424var disableLegacyContext = false;
425var disableSchedulerTimeoutBasedOnReactExpirationTime = false;
426 // Only used in www builds.
427
428 // Flow magic to verify the exports of this file match the original version.
429
430var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
431function getNearestMountedFiber(fiber) {
432 var node = fiber;
433 var nearestMounted = fiber;
434
435 if (!fiber.alternate) {
436 // If there is no alternate, this might be a new tree that isn't inserted
437 // yet. If it is, then it will have a pending insertion effect on it.
438 var nextNode = node;
439
440 do {
441 node = nextNode;
442
443 if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
444 // This is an insertion or in-progress hydration. The nearest possible
445 // mounted fiber is the parent but we need to continue to figure out
446 // if that one is still mounted.
447 nearestMounted = node.return;
448 }
449
450 nextNode = node.return;
451 } while (nextNode);
452 } else {
453 while (node.return) {
454 node = node.return;
455 }
456 }
457
458 if (node.tag === HostRoot) {
459 // TODO: Check if this was a nested HostRoot when used with
460 // renderContainerIntoSubtree.
461 return nearestMounted;
462 } // If we didn't hit the root, that means that we're in an disconnected tree
463 // that has been unmounted.
464
465
466 return null;
467}
468
469
470function isFiberMounted(fiber) {
471 return getNearestMountedFiber(fiber) === fiber;
472}
473function isMounted(component) {
474 {
475 var owner = ReactCurrentOwner.current;
476
477 if (owner !== null && owner.tag === ClassComponent) {
478 var ownerFiber = owner;
479 var instance = ownerFiber.stateNode;
480 !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component') : void 0;
481 instance._warnedAboutRefsInRender = true;
482 }
483 }
484
485 var fiber = get(component);
486
487 if (!fiber) {
488 return false;
489 }
490
491 return getNearestMountedFiber(fiber) === fiber;
492}
493
494function assertIsMounted(fiber) {
495 (function () {
496 if (!(getNearestMountedFiber(fiber) === fiber)) {
497 {
498 throw ReactError(Error("Unable to find node on an unmounted component."));
499 }
500 }
501 })();
502}
503
504function findCurrentFiberUsingSlowPath(fiber) {
505 var alternate = fiber.alternate;
506
507 if (!alternate) {
508 // If there is no alternate, then we only need to check if it is mounted.
509 var nearestMounted = getNearestMountedFiber(fiber);
510
511 (function () {
512 if (!(nearestMounted !== null)) {
513 {
514 throw ReactError(Error("Unable to find node on an unmounted component."));
515 }
516 }
517 })();
518
519 if (nearestMounted !== fiber) {
520 return null;
521 }
522
523 return fiber;
524 } // If we have two possible branches, we'll walk backwards up to the root
525 // to see what path the root points to. On the way we may hit one of the
526 // special cases and we'll deal with them.
527
528
529 var a = fiber;
530 var b = alternate;
531
532 while (true) {
533 var parentA = a.return;
534
535 if (parentA === null) {
536 // We're at the root.
537 break;
538 }
539
540 var parentB = parentA.alternate;
541
542 if (parentB === null) {
543 // There is no alternate. This is an unusual case. Currently, it only
544 // happens when a Suspense component is hidden. An extra fragment fiber
545 // is inserted in between the Suspense fiber and its children. Skip
546 // over this extra fragment fiber and proceed to the next parent.
547 var nextParent = parentA.return;
548
549 if (nextParent !== null) {
550 a = b = nextParent;
551 continue;
552 } // If there's no parent, we're at the root.
553
554
555 break;
556 } // If both copies of the parent fiber point to the same child, we can
557 // assume that the child is current. This happens when we bailout on low
558 // priority: the bailed out fiber's child reuses the current child.
559
560
561 if (parentA.child === parentB.child) {
562 var child = parentA.child;
563
564 while (child) {
565 if (child === a) {
566 // We've determined that A is the current branch.
567 assertIsMounted(parentA);
568 return fiber;
569 }
570
571 if (child === b) {
572 // We've determined that B is the current branch.
573 assertIsMounted(parentA);
574 return alternate;
575 }
576
577 child = child.sibling;
578 } // We should never have an alternate for any mounting node. So the only
579 // way this could possibly happen is if this was unmounted, if at all.
580
581
582 (function () {
583 {
584 {
585 throw ReactError(Error("Unable to find node on an unmounted component."));
586 }
587 }
588 })();
589 }
590
591 if (a.return !== b.return) {
592 // The return pointer of A and the return pointer of B point to different
593 // fibers. We assume that return pointers never criss-cross, so A must
594 // belong to the child set of A.return, and B must belong to the child
595 // set of B.return.
596 a = parentA;
597 b = parentB;
598 } else {
599 // The return pointers point to the same fiber. We'll have to use the
600 // default, slow path: scan the child sets of each parent alternate to see
601 // which child belongs to which set.
602 //
603 // Search parent A's child set
604 var didFindChild = false;
605 var _child = parentA.child;
606
607 while (_child) {
608 if (_child === a) {
609 didFindChild = true;
610 a = parentA;
611 b = parentB;
612 break;
613 }
614
615 if (_child === b) {
616 didFindChild = true;
617 b = parentA;
618 a = parentB;
619 break;
620 }
621
622 _child = _child.sibling;
623 }
624
625 if (!didFindChild) {
626 // Search parent B's child set
627 _child = parentB.child;
628
629 while (_child) {
630 if (_child === a) {
631 didFindChild = true;
632 a = parentB;
633 b = parentA;
634 break;
635 }
636
637 if (_child === b) {
638 didFindChild = true;
639 b = parentB;
640 a = parentA;
641 break;
642 }
643
644 _child = _child.sibling;
645 }
646
647 (function () {
648 if (!didFindChild) {
649 {
650 throw ReactError(Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."));
651 }
652 }
653 })();
654 }
655 }
656
657 (function () {
658 if (!(a.alternate === b)) {
659 {
660 throw ReactError(Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."));
661 }
662 }
663 })();
664 } // If the root is not a host container, we're in a disconnected tree. I.e.
665 // unmounted.
666
667
668 (function () {
669 if (!(a.tag === HostRoot)) {
670 {
671 throw ReactError(Error("Unable to find node on an unmounted component."));
672 }
673 }
674 })();
675
676 if (a.stateNode.current === a) {
677 // We've determined that A is the current branch.
678 return fiber;
679 } // Otherwise B has to be current branch.
680
681
682 return alternate;
683}
684function findCurrentHostFiber(parent) {
685 var currentParent = findCurrentFiberUsingSlowPath(parent);
686
687 if (!currentParent) {
688 return null;
689 } // Next we'll drill down this component to find the first HostComponent/Text.
690
691
692 var node = currentParent;
693
694 while (true) {
695 if (node.tag === HostComponent || node.tag === HostText) {
696 return node;
697 } else if (node.child) {
698 node.child.return = node;
699 node = node.child;
700 continue;
701 }
702
703 if (node === currentParent) {
704 return null;
705 }
706
707 while (!node.sibling) {
708 if (!node.return || node.return === currentParent) {
709 return null;
710 }
711
712 node = node.return;
713 }
714
715 node.sibling.return = node.return;
716 node = node.sibling;
717 } // Flow needs the return null here, but ESLint complains about it.
718 // eslint-disable-next-line no-unreachable
719
720
721 return null;
722}
723function findCurrentHostFiberWithNoPortals(parent) {
724 var currentParent = findCurrentFiberUsingSlowPath(parent);
725
726 if (!currentParent) {
727 return null;
728 } // Next we'll drill down this component to find the first HostComponent/Text.
729
730
731 var node = currentParent;
732
733 while (true) {
734 if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI && node.tag === FundamentalComponent) {
735 return node;
736 } else if (node.child && node.tag !== HostPortal) {
737 node.child.return = node;
738 node = node.child;
739 continue;
740 }
741
742 if (node === currentParent) {
743 return null;
744 }
745
746 while (!node.sibling) {
747 if (!node.return || node.return === currentParent) {
748 return null;
749 }
750
751 node = node.return;
752 }
753
754 node.sibling.return = node.return;
755 node = node.sibling;
756 } // Flow needs the return null here, but ESLint complains about it.
757 // eslint-disable-next-line no-unreachable
758
759
760 return null;
761}
762
763// This is a host config that's used for the `react-reconciler` package on npm.
764// It is only used by third-party renderers.
765//
766// Its API lets you pass the host config as an argument.
767// However, inside the `react-reconciler` we treat host config as a module.
768// This file is a shim between two worlds.
769//
770// It works because the `react-reconciler` bundle is wrapped in something like:
771//
772// module.exports = function ($$$config) {
773// /* reconciler code */
774// }
775//
776// So `$$$config` looks like a global variable, but it's
777// really an argument to a top-level wrapping function.
778// eslint-disable-line no-undef
779// eslint-disable-line no-undef
780// eslint-disable-line no-undef
781// eslint-disable-line no-undef
782// eslint-disable-line no-undef
783// eslint-disable-line no-undef
784// eslint-disable-line no-undef
785// eslint-disable-line no-undef
786// eslint-disable-line no-undef
787// eslint-disable-line no-undef
788// eslint-disable-line no-undef
789// eslint-disable-line no-undef
790// eslint-disable-line no-undef
791var getPublicInstance = $$$hostConfig.getPublicInstance;
792var getRootHostContext = $$$hostConfig.getRootHostContext;
793var getChildHostContext = $$$hostConfig.getChildHostContext;
794var prepareForCommit = $$$hostConfig.prepareForCommit;
795var resetAfterCommit = $$$hostConfig.resetAfterCommit;
796var createInstance = $$$hostConfig.createInstance;
797var appendInitialChild = $$$hostConfig.appendInitialChild;
798var finalizeInitialChildren = $$$hostConfig.finalizeInitialChildren;
799var prepareUpdate = $$$hostConfig.prepareUpdate;
800var shouldSetTextContent = $$$hostConfig.shouldSetTextContent;
801var shouldDeprioritizeSubtree = $$$hostConfig.shouldDeprioritizeSubtree;
802var createTextInstance = $$$hostConfig.createTextInstance;
803var scheduleTimeout = $$$hostConfig.setTimeout;
804var cancelTimeout = $$$hostConfig.clearTimeout;
805var noTimeout = $$$hostConfig.noTimeout;
806var now = $$$hostConfig.now;
807var isPrimaryRenderer = $$$hostConfig.isPrimaryRenderer;
808var warnsIfNotActing = $$$hostConfig.warnsIfNotActing;
809var supportsMutation = $$$hostConfig.supportsMutation;
810var supportsPersistence = $$$hostConfig.supportsPersistence;
811var supportsHydration = $$$hostConfig.supportsHydration;
812var mountResponderInstance = $$$hostConfig.mountResponderInstance;
813var unmountResponderInstance = $$$hostConfig.unmountResponderInstance;
814var getFundamentalComponentInstance = $$$hostConfig.getFundamentalComponentInstance;
815var mountFundamentalComponent = $$$hostConfig.mountFundamentalComponent;
816var shouldUpdateFundamentalComponent = $$$hostConfig.shouldUpdateFundamentalComponent; // -------------------
817// Mutation
818// (optional)
819// -------------------
820
821var appendChild = $$$hostConfig.appendChild;
822var appendChildToContainer = $$$hostConfig.appendChildToContainer;
823var commitTextUpdate = $$$hostConfig.commitTextUpdate;
824var commitMount = $$$hostConfig.commitMount;
825var commitUpdate = $$$hostConfig.commitUpdate;
826var insertBefore = $$$hostConfig.insertBefore;
827var insertInContainerBefore = $$$hostConfig.insertInContainerBefore;
828var removeChild = $$$hostConfig.removeChild;
829var removeChildFromContainer = $$$hostConfig.removeChildFromContainer;
830var resetTextContent = $$$hostConfig.resetTextContent;
831var hideInstance = $$$hostConfig.hideInstance;
832var hideTextInstance = $$$hostConfig.hideTextInstance;
833var unhideInstance = $$$hostConfig.unhideInstance;
834var unhideTextInstance = $$$hostConfig.unhideTextInstance;
835var updateFundamentalComponent = $$$hostConfig.updateFundamentalComponent;
836var unmountFundamentalComponent = $$$hostConfig.unmountFundamentalComponent; // -------------------
837// Persistence
838// (optional)
839// -------------------
840
841var cloneInstance = $$$hostConfig.cloneInstance;
842var createContainerChildSet = $$$hostConfig.createContainerChildSet;
843var appendChildToContainerChildSet = $$$hostConfig.appendChildToContainerChildSet;
844var finalizeContainerChildren = $$$hostConfig.finalizeContainerChildren;
845var replaceContainerChildren = $$$hostConfig.replaceContainerChildren;
846var cloneHiddenInstance = $$$hostConfig.cloneHiddenInstance;
847var cloneHiddenTextInstance = $$$hostConfig.cloneHiddenTextInstance;
848var cloneFundamentalInstance = $$$hostConfig.cloneInstance; // -------------------
849// Hydration
850// (optional)
851// -------------------
852
853var canHydrateInstance = $$$hostConfig.canHydrateInstance;
854var canHydrateTextInstance = $$$hostConfig.canHydrateTextInstance;
855var canHydrateSuspenseInstance = $$$hostConfig.canHydrateSuspenseInstance;
856var isSuspenseInstancePending = $$$hostConfig.isSuspenseInstancePending;
857var isSuspenseInstanceFallback = $$$hostConfig.isSuspenseInstanceFallback;
858var registerSuspenseInstanceRetry = $$$hostConfig.registerSuspenseInstanceRetry;
859var getNextHydratableSibling = $$$hostConfig.getNextHydratableSibling;
860var getFirstHydratableChild = $$$hostConfig.getFirstHydratableChild;
861var hydrateInstance = $$$hostConfig.hydrateInstance;
862var hydrateTextInstance = $$$hostConfig.hydrateTextInstance;
863var hydrateSuspenseInstance = $$$hostConfig.hydrateSuspenseInstance;
864var getNextHydratableInstanceAfterSuspenseInstance = $$$hostConfig.getNextHydratableInstanceAfterSuspenseInstance;
865var commitHydratedContainer = $$$hostConfig.commitHydratedContainer;
866var commitHydratedSuspenseInstance = $$$hostConfig.commitHydratedSuspenseInstance;
867var clearSuspenseBoundary = $$$hostConfig.clearSuspenseBoundary;
868var clearSuspenseBoundaryFromContainer = $$$hostConfig.clearSuspenseBoundaryFromContainer;
869var didNotMatchHydratedContainerTextInstance = $$$hostConfig.didNotMatchHydratedContainerTextInstance;
870var didNotMatchHydratedTextInstance = $$$hostConfig.didNotMatchHydratedTextInstance;
871var didNotHydrateContainerInstance = $$$hostConfig.didNotHydrateContainerInstance;
872var didNotHydrateInstance = $$$hostConfig.didNotHydrateInstance;
873var didNotFindHydratableContainerInstance = $$$hostConfig.didNotFindHydratableContainerInstance;
874var didNotFindHydratableContainerTextInstance = $$$hostConfig.didNotFindHydratableContainerTextInstance;
875var didNotFindHydratableContainerSuspenseInstance = $$$hostConfig.didNotFindHydratableContainerSuspenseInstance;
876var didNotFindHydratableInstance = $$$hostConfig.didNotFindHydratableInstance;
877var didNotFindHydratableTextInstance = $$$hostConfig.didNotFindHydratableTextInstance;
878var didNotFindHydratableSuspenseInstance = $$$hostConfig.didNotFindHydratableSuspenseInstance;
879
880var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
881var describeComponentFrame = function (name, source, ownerName) {
882 var sourceInfo = '';
883
884 if (source) {
885 var path = source.fileName;
886 var fileName = path.replace(BEFORE_SLASH_RE, '');
887
888 {
889 // In DEV, include code for a common special case:
890 // prefer "folder/index.js" instead of just "index.js".
891 if (/^index\./.test(fileName)) {
892 var match = path.match(BEFORE_SLASH_RE);
893
894 if (match) {
895 var pathBeforeSlash = match[1];
896
897 if (pathBeforeSlash) {
898 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
899 fileName = folderName + '/' + fileName;
900 }
901 }
902 }
903 }
904
905 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
906 } else if (ownerName) {
907 sourceInfo = ' (created by ' + ownerName + ')';
908 }
909
910 return '\n in ' + (name || 'Unknown') + sourceInfo;
911};
912
913var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
914
915function describeFiber(fiber) {
916 switch (fiber.tag) {
917 case HostRoot:
918 case HostPortal:
919 case HostText:
920 case Fragment:
921 case ContextProvider:
922 case ContextConsumer:
923 return '';
924
925 default:
926 var owner = fiber._debugOwner;
927 var source = fiber._debugSource;
928 var name = getComponentName(fiber.type);
929 var ownerName = null;
930
931 if (owner) {
932 ownerName = getComponentName(owner.type);
933 }
934
935 return describeComponentFrame(name, source, ownerName);
936 }
937}
938
939function getStackByFiberInDevAndProd(workInProgress) {
940 var info = '';
941 var node = workInProgress;
942
943 do {
944 info += describeFiber(node);
945 node = node.return;
946 } while (node);
947
948 return info;
949}
950var current = null;
951var phase = null;
952function getCurrentFiberOwnerNameInDevOrNull() {
953 {
954 if (current === null) {
955 return null;
956 }
957
958 var owner = current._debugOwner;
959
960 if (owner !== null && typeof owner !== 'undefined') {
961 return getComponentName(owner.type);
962 }
963 }
964
965 return null;
966}
967function getCurrentFiberStackInDev() {
968 {
969 if (current === null) {
970 return '';
971 } // Safe because if current fiber exists, we are reconciling,
972 // and it is guaranteed to be the work-in-progress version.
973
974
975 return getStackByFiberInDevAndProd(current);
976 }
977
978 return '';
979}
980function resetCurrentFiber() {
981 {
982 ReactDebugCurrentFrame.getCurrentStack = null;
983 current = null;
984 phase = null;
985 }
986}
987function setCurrentFiber(fiber) {
988 {
989 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
990 current = fiber;
991 phase = null;
992 }
993}
994function setCurrentPhase(lifeCyclePhase) {
995 {
996 phase = lifeCyclePhase;
997 }
998}
999
1000// Prefix measurements so that it's possible to filter them.
1001// Longer prefixes are hard to read in DevTools.
1002var reactEmoji = "\u269B";
1003var warningEmoji = "\u26D4";
1004var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause.
1005// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
1006
1007var currentFiber = null; // If we're in the middle of user code, which fiber and method is it?
1008// Reusing `currentFiber` would be confusing for this because user code fiber
1009// can change during commit phase too, but we don't need to unwind it (since
1010// lifecycles in the commit phase don't resemble a tree).
1011
1012var currentPhase = null;
1013var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem,
1014// so we will keep track of it, and include it in the report.
1015// Track commits caused by cascading updates.
1016
1017var isCommitting = false;
1018var hasScheduledUpdateInCurrentCommit = false;
1019var hasScheduledUpdateInCurrentPhase = false;
1020var commitCountInCurrentWorkLoop = 0;
1021var effectCountInCurrentCommit = 0;
1022// to avoid stretch the commit phase with measurement overhead.
1023
1024var labelsInCurrentCommit = new Set();
1025
1026var formatMarkName = function (markName) {
1027 return reactEmoji + " " + markName;
1028};
1029
1030var formatLabel = function (label, warning) {
1031 var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
1032 var suffix = warning ? " Warning: " + warning : '';
1033 return "" + prefix + label + suffix;
1034};
1035
1036var beginMark = function (markName) {
1037 performance.mark(formatMarkName(markName));
1038};
1039
1040var clearMark = function (markName) {
1041 performance.clearMarks(formatMarkName(markName));
1042};
1043
1044var endMark = function (label, markName, warning) {
1045 var formattedMarkName = formatMarkName(markName);
1046 var formattedLabel = formatLabel(label, warning);
1047
1048 try {
1049 performance.measure(formattedLabel, formattedMarkName);
1050 } catch (err) {} // If previous mark was missing for some reason, this will throw.
1051 // This could only happen if React crashed in an unexpected place earlier.
1052 // Don't pile on with more errors.
1053 // Clear marks immediately to avoid growing buffer.
1054
1055
1056 performance.clearMarks(formattedMarkName);
1057 performance.clearMeasures(formattedLabel);
1058};
1059
1060var getFiberMarkName = function (label, debugID) {
1061 return label + " (#" + debugID + ")";
1062};
1063
1064var getFiberLabel = function (componentName, isMounted, phase) {
1065 if (phase === null) {
1066 // These are composite component total time measurements.
1067 return componentName + " [" + (isMounted ? 'update' : 'mount') + "]";
1068 } else {
1069 // Composite component methods.
1070 return componentName + "." + phase;
1071 }
1072};
1073
1074var beginFiberMark = function (fiber, phase) {
1075 var componentName = getComponentName(fiber.type) || 'Unknown';
1076 var debugID = fiber._debugID;
1077 var isMounted = fiber.alternate !== null;
1078 var label = getFiberLabel(componentName, isMounted, phase);
1079
1080 if (isCommitting && labelsInCurrentCommit.has(label)) {
1081 // During the commit phase, we don't show duplicate labels because
1082 // there is a fixed overhead for every measurement, and we don't
1083 // want to stretch the commit phase beyond necessary.
1084 return false;
1085 }
1086
1087 labelsInCurrentCommit.add(label);
1088 var markName = getFiberMarkName(label, debugID);
1089 beginMark(markName);
1090 return true;
1091};
1092
1093var clearFiberMark = function (fiber, phase) {
1094 var componentName = getComponentName(fiber.type) || 'Unknown';
1095 var debugID = fiber._debugID;
1096 var isMounted = fiber.alternate !== null;
1097 var label = getFiberLabel(componentName, isMounted, phase);
1098 var markName = getFiberMarkName(label, debugID);
1099 clearMark(markName);
1100};
1101
1102var endFiberMark = function (fiber, phase, warning) {
1103 var componentName = getComponentName(fiber.type) || 'Unknown';
1104 var debugID = fiber._debugID;
1105 var isMounted = fiber.alternate !== null;
1106 var label = getFiberLabel(componentName, isMounted, phase);
1107 var markName = getFiberMarkName(label, debugID);
1108 endMark(label, markName, warning);
1109};
1110
1111var shouldIgnoreFiber = function (fiber) {
1112 // Host components should be skipped in the timeline.
1113 // We could check typeof fiber.type, but does this work with RN?
1114 switch (fiber.tag) {
1115 case HostRoot:
1116 case HostComponent:
1117 case HostText:
1118 case HostPortal:
1119 case Fragment:
1120 case ContextProvider:
1121 case ContextConsumer:
1122 case Mode:
1123 return true;
1124
1125 default:
1126 return false;
1127 }
1128};
1129
1130var clearPendingPhaseMeasurement = function () {
1131 if (currentPhase !== null && currentPhaseFiber !== null) {
1132 clearFiberMark(currentPhaseFiber, currentPhase);
1133 }
1134
1135 currentPhaseFiber = null;
1136 currentPhase = null;
1137 hasScheduledUpdateInCurrentPhase = false;
1138};
1139
1140var pauseTimers = function () {
1141 // Stops all currently active measurements so that they can be resumed
1142 // if we continue in a later deferred loop from the same unit of work.
1143 var fiber = currentFiber;
1144
1145 while (fiber) {
1146 if (fiber._debugIsCurrentlyTiming) {
1147 endFiberMark(fiber, null, null);
1148 }
1149
1150 fiber = fiber.return;
1151 }
1152};
1153
1154var resumeTimersRecursively = function (fiber) {
1155 if (fiber.return !== null) {
1156 resumeTimersRecursively(fiber.return);
1157 }
1158
1159 if (fiber._debugIsCurrentlyTiming) {
1160 beginFiberMark(fiber, null);
1161 }
1162};
1163
1164var resumeTimers = function () {
1165 // Resumes all measurements that were active during the last deferred loop.
1166 if (currentFiber !== null) {
1167 resumeTimersRecursively(currentFiber);
1168 }
1169};
1170
1171function recordEffect() {
1172 if (enableUserTimingAPI) {
1173 effectCountInCurrentCommit++;
1174 }
1175}
1176function recordScheduleUpdate() {
1177 if (enableUserTimingAPI) {
1178 if (isCommitting) {
1179 hasScheduledUpdateInCurrentCommit = true;
1180 }
1181
1182 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
1183 hasScheduledUpdateInCurrentPhase = true;
1184 }
1185 }
1186}
1187
1188
1189function startWorkTimer(fiber) {
1190 if (enableUserTimingAPI) {
1191 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1192 return;
1193 } // If we pause, this is the fiber to unwind from.
1194
1195
1196 currentFiber = fiber;
1197
1198 if (!beginFiberMark(fiber, null)) {
1199 return;
1200 }
1201
1202 fiber._debugIsCurrentlyTiming = true;
1203 }
1204}
1205function cancelWorkTimer(fiber) {
1206 if (enableUserTimingAPI) {
1207 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1208 return;
1209 } // Remember we shouldn't complete measurement for this fiber.
1210 // Otherwise flamechart will be deep even for small updates.
1211
1212
1213 fiber._debugIsCurrentlyTiming = false;
1214 clearFiberMark(fiber, null);
1215 }
1216}
1217function stopWorkTimer(fiber) {
1218 if (enableUserTimingAPI) {
1219 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1220 return;
1221 } // If we pause, its parent is the fiber to unwind from.
1222
1223
1224 currentFiber = fiber.return;
1225
1226 if (!fiber._debugIsCurrentlyTiming) {
1227 return;
1228 }
1229
1230 fiber._debugIsCurrentlyTiming = false;
1231 endFiberMark(fiber, null, null);
1232 }
1233}
1234function stopFailedWorkTimer(fiber) {
1235 if (enableUserTimingAPI) {
1236 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1237 return;
1238 } // If we pause, its parent is the fiber to unwind from.
1239
1240
1241 currentFiber = fiber.return;
1242
1243 if (!fiber._debugIsCurrentlyTiming) {
1244 return;
1245 }
1246
1247 fiber._debugIsCurrentlyTiming = false;
1248 var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1249 endFiberMark(fiber, null, warning);
1250 }
1251}
1252function startPhaseTimer(fiber, phase) {
1253 if (enableUserTimingAPI) {
1254 if (!supportsUserTiming) {
1255 return;
1256 }
1257
1258 clearPendingPhaseMeasurement();
1259
1260 if (!beginFiberMark(fiber, phase)) {
1261 return;
1262 }
1263
1264 currentPhaseFiber = fiber;
1265 currentPhase = phase;
1266 }
1267}
1268function stopPhaseTimer() {
1269 if (enableUserTimingAPI) {
1270 if (!supportsUserTiming) {
1271 return;
1272 }
1273
1274 if (currentPhase !== null && currentPhaseFiber !== null) {
1275 var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
1276 endFiberMark(currentPhaseFiber, currentPhase, warning);
1277 }
1278
1279 currentPhase = null;
1280 currentPhaseFiber = null;
1281 }
1282}
1283function startWorkLoopTimer(nextUnitOfWork) {
1284 if (enableUserTimingAPI) {
1285 currentFiber = nextUnitOfWork;
1286
1287 if (!supportsUserTiming) {
1288 return;
1289 }
1290
1291 commitCountInCurrentWorkLoop = 0; // This is top level call.
1292 // Any other measurements are performed within.
1293
1294 beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop.
1295
1296 resumeTimers();
1297 }
1298}
1299function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
1300 if (enableUserTimingAPI) {
1301 if (!supportsUserTiming) {
1302 return;
1303 }
1304
1305 var warning = null;
1306
1307 if (interruptedBy !== null) {
1308 if (interruptedBy.tag === HostRoot) {
1309 warning = 'A top-level update interrupted the previous render';
1310 } else {
1311 var componentName = getComponentName(interruptedBy.type) || 'Unknown';
1312 warning = "An update to " + componentName + " interrupted the previous render";
1313 }
1314 } else if (commitCountInCurrentWorkLoop > 1) {
1315 warning = 'There were cascading updates';
1316 }
1317
1318 commitCountInCurrentWorkLoop = 0;
1319 var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop.
1320
1321 pauseTimers();
1322 endMark(label, '(React Tree Reconciliation)', warning);
1323 }
1324}
1325function startCommitTimer() {
1326 if (enableUserTimingAPI) {
1327 if (!supportsUserTiming) {
1328 return;
1329 }
1330
1331 isCommitting = true;
1332 hasScheduledUpdateInCurrentCommit = false;
1333 labelsInCurrentCommit.clear();
1334 beginMark('(Committing Changes)');
1335 }
1336}
1337function stopCommitTimer() {
1338 if (enableUserTimingAPI) {
1339 if (!supportsUserTiming) {
1340 return;
1341 }
1342
1343 var warning = null;
1344
1345 if (hasScheduledUpdateInCurrentCommit) {
1346 warning = 'Lifecycle hook scheduled a cascading update';
1347 } else if (commitCountInCurrentWorkLoop > 0) {
1348 warning = 'Caused by a cascading update in earlier commit';
1349 }
1350
1351 hasScheduledUpdateInCurrentCommit = false;
1352 commitCountInCurrentWorkLoop++;
1353 isCommitting = false;
1354 labelsInCurrentCommit.clear();
1355 endMark('(Committing Changes)', '(Committing Changes)', warning);
1356 }
1357}
1358function startCommitSnapshotEffectsTimer() {
1359 if (enableUserTimingAPI) {
1360 if (!supportsUserTiming) {
1361 return;
1362 }
1363
1364 effectCountInCurrentCommit = 0;
1365 beginMark('(Committing Snapshot Effects)');
1366 }
1367}
1368function stopCommitSnapshotEffectsTimer() {
1369 if (enableUserTimingAPI) {
1370 if (!supportsUserTiming) {
1371 return;
1372 }
1373
1374 var count = effectCountInCurrentCommit;
1375 effectCountInCurrentCommit = 0;
1376 endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null);
1377 }
1378}
1379function startCommitHostEffectsTimer() {
1380 if (enableUserTimingAPI) {
1381 if (!supportsUserTiming) {
1382 return;
1383 }
1384
1385 effectCountInCurrentCommit = 0;
1386 beginMark('(Committing Host Effects)');
1387 }
1388}
1389function stopCommitHostEffectsTimer() {
1390 if (enableUserTimingAPI) {
1391 if (!supportsUserTiming) {
1392 return;
1393 }
1394
1395 var count = effectCountInCurrentCommit;
1396 effectCountInCurrentCommit = 0;
1397 endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null);
1398 }
1399}
1400function startCommitLifeCyclesTimer() {
1401 if (enableUserTimingAPI) {
1402 if (!supportsUserTiming) {
1403 return;
1404 }
1405
1406 effectCountInCurrentCommit = 0;
1407 beginMark('(Calling Lifecycle Methods)');
1408 }
1409}
1410function stopCommitLifeCyclesTimer() {
1411 if (enableUserTimingAPI) {
1412 if (!supportsUserTiming) {
1413 return;
1414 }
1415
1416 var count = effectCountInCurrentCommit;
1417 effectCountInCurrentCommit = 0;
1418 endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null);
1419 }
1420}
1421
1422var valueStack = [];
1423var fiberStack;
1424
1425{
1426 fiberStack = [];
1427}
1428
1429var index = -1;
1430
1431function createCursor(defaultValue) {
1432 return {
1433 current: defaultValue
1434 };
1435}
1436
1437function pop(cursor, fiber) {
1438 if (index < 0) {
1439 {
1440 warningWithoutStack$1(false, 'Unexpected pop.');
1441 }
1442
1443 return;
1444 }
1445
1446 {
1447 if (fiber !== fiberStack[index]) {
1448 warningWithoutStack$1(false, 'Unexpected Fiber popped.');
1449 }
1450 }
1451
1452 cursor.current = valueStack[index];
1453 valueStack[index] = null;
1454
1455 {
1456 fiberStack[index] = null;
1457 }
1458
1459 index--;
1460}
1461
1462function push(cursor, value, fiber) {
1463 index++;
1464 valueStack[index] = cursor.current;
1465
1466 {
1467 fiberStack[index] = fiber;
1468 }
1469
1470 cursor.current = value;
1471}
1472
1473var warnedAboutMissingGetChildContext;
1474
1475{
1476 warnedAboutMissingGetChildContext = {};
1477}
1478
1479var emptyContextObject = {};
1480
1481{
1482 Object.freeze(emptyContextObject);
1483} // A cursor to the current merged context object on the stack.
1484
1485
1486var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed.
1487
1488var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack.
1489// We use this to get access to the parent context after we have already
1490// pushed the next context provider, and now need to merge their contexts.
1491
1492var previousContext = emptyContextObject;
1493
1494function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
1495 if (disableLegacyContext) {
1496 return emptyContextObject;
1497 } else {
1498 if (didPushOwnContextIfProvider && isContextProvider(Component)) {
1499 // If the fiber is a context provider itself, when we read its context
1500 // we may have already pushed its own child context on the stack. A context
1501 // provider should not "see" its own child context. Therefore we read the
1502 // previous (parent) context instead for a context provider.
1503 return previousContext;
1504 }
1505
1506 return contextStackCursor.current;
1507 }
1508}
1509
1510function cacheContext(workInProgress, unmaskedContext, maskedContext) {
1511 if (disableLegacyContext) {
1512 return;
1513 } else {
1514 var instance = workInProgress.stateNode;
1515 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
1516 instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
1517 }
1518}
1519
1520function getMaskedContext(workInProgress, unmaskedContext) {
1521 if (disableLegacyContext) {
1522 return emptyContextObject;
1523 } else {
1524 var type = workInProgress.type;
1525 var contextTypes = type.contextTypes;
1526
1527 if (!contextTypes) {
1528 return emptyContextObject;
1529 } // Avoid recreating masked context unless unmasked context has changed.
1530 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
1531 // This may trigger infinite loops if componentWillReceiveProps calls setState.
1532
1533
1534 var instance = workInProgress.stateNode;
1535
1536 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
1537 return instance.__reactInternalMemoizedMaskedChildContext;
1538 }
1539
1540 var context = {};
1541
1542 for (var key in contextTypes) {
1543 context[key] = unmaskedContext[key];
1544 }
1545
1546 {
1547 var name = getComponentName(type) || 'Unknown';
1548 checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
1549 } // Cache unmasked context so we can avoid recreating masked context unless necessary.
1550 // Context is created before the class component is instantiated so check for instance.
1551
1552
1553 if (instance) {
1554 cacheContext(workInProgress, unmaskedContext, context);
1555 }
1556
1557 return context;
1558 }
1559}
1560
1561function hasContextChanged() {
1562 if (disableLegacyContext) {
1563 return false;
1564 } else {
1565 return didPerformWorkStackCursor.current;
1566 }
1567}
1568
1569function isContextProvider(type) {
1570 if (disableLegacyContext) {
1571 return false;
1572 } else {
1573 var childContextTypes = type.childContextTypes;
1574 return childContextTypes !== null && childContextTypes !== undefined;
1575 }
1576}
1577
1578function popContext(fiber) {
1579 if (disableLegacyContext) {
1580 return;
1581 } else {
1582 pop(didPerformWorkStackCursor, fiber);
1583 pop(contextStackCursor, fiber);
1584 }
1585}
1586
1587function popTopLevelContextObject(fiber) {
1588 if (disableLegacyContext) {
1589 return;
1590 } else {
1591 pop(didPerformWorkStackCursor, fiber);
1592 pop(contextStackCursor, fiber);
1593 }
1594}
1595
1596function pushTopLevelContextObject(fiber, context, didChange) {
1597 if (disableLegacyContext) {
1598 return;
1599 } else {
1600 (function () {
1601 if (!(contextStackCursor.current === emptyContextObject)) {
1602 {
1603 throw ReactError(Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."));
1604 }
1605 }
1606 })();
1607
1608 push(contextStackCursor, context, fiber);
1609 push(didPerformWorkStackCursor, didChange, fiber);
1610 }
1611}
1612
1613function processChildContext(fiber, type, parentContext) {
1614 if (disableLegacyContext) {
1615 return parentContext;
1616 } else {
1617 var instance = fiber.stateNode;
1618 var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future.
1619 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
1620
1621 if (typeof instance.getChildContext !== 'function') {
1622 {
1623 var componentName = getComponentName(type) || 'Unknown';
1624
1625 if (!warnedAboutMissingGetChildContext[componentName]) {
1626 warnedAboutMissingGetChildContext[componentName] = true;
1627 warningWithoutStack$1(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
1628 }
1629 }
1630
1631 return parentContext;
1632 }
1633
1634 var childContext;
1635
1636 {
1637 setCurrentPhase('getChildContext');
1638 }
1639
1640 startPhaseTimer(fiber, 'getChildContext');
1641 childContext = instance.getChildContext();
1642 stopPhaseTimer();
1643
1644 {
1645 setCurrentPhase(null);
1646 }
1647
1648 for (var contextKey in childContext) {
1649 (function () {
1650 if (!(contextKey in childContextTypes)) {
1651 {
1652 throw ReactError(Error((getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."));
1653 }
1654 }
1655 })();
1656 }
1657
1658 {
1659 var name = getComponentName(type) || 'Unknown';
1660 checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when
1661 // somebody calls unstable_renderSubtreeIntoContainer() and we process
1662 // context from the parent component instance. The stack will be missing
1663 // because it's outside of the reconciliation, and so the pointer has not
1664 // been set. This is rare and doesn't matter. We'll also remove that API.
1665 getCurrentFiberStackInDev);
1666 }
1667
1668 return _assign({}, parentContext, {}, childContext);
1669 }
1670}
1671
1672function pushContextProvider(workInProgress) {
1673 if (disableLegacyContext) {
1674 return false;
1675 } else {
1676 var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity.
1677 // If the instance does not exist yet, we will push null at first,
1678 // and replace it on the stack later when invalidating the context.
1679
1680 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later.
1681 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
1682
1683 previousContext = contextStackCursor.current;
1684 push(contextStackCursor, memoizedMergedChildContext, workInProgress);
1685 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
1686 return true;
1687 }
1688}
1689
1690function invalidateContextProvider(workInProgress, type, didChange) {
1691 if (disableLegacyContext) {
1692 return;
1693 } else {
1694 var instance = workInProgress.stateNode;
1695
1696 (function () {
1697 if (!instance) {
1698 {
1699 throw ReactError(Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."));
1700 }
1701 }
1702 })();
1703
1704 if (didChange) {
1705 // Merge parent and own context.
1706 // Skip this if we're not updating due to sCU.
1707 // This avoids unnecessarily recomputing memoized values.
1708 var mergedContext = processChildContext(workInProgress, type, previousContext);
1709 instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one.
1710 // It is important to unwind the context in the reverse order.
1711
1712 pop(didPerformWorkStackCursor, workInProgress);
1713 pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed.
1714
1715 push(contextStackCursor, mergedContext, workInProgress);
1716 push(didPerformWorkStackCursor, didChange, workInProgress);
1717 } else {
1718 pop(didPerformWorkStackCursor, workInProgress);
1719 push(didPerformWorkStackCursor, didChange, workInProgress);
1720 }
1721 }
1722}
1723
1724function findCurrentUnmaskedContext(fiber) {
1725 if (disableLegacyContext) {
1726 return emptyContextObject;
1727 } else {
1728 // Currently this is only used with renderSubtreeIntoContainer; not sure if it
1729 // makes sense elsewhere
1730 (function () {
1731 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
1732 {
1733 throw ReactError(Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."));
1734 }
1735 }
1736 })();
1737
1738 var node = fiber;
1739
1740 do {
1741 switch (node.tag) {
1742 case HostRoot:
1743 return node.stateNode.context;
1744
1745 case ClassComponent:
1746 {
1747 var Component = node.type;
1748
1749 if (isContextProvider(Component)) {
1750 return node.stateNode.__reactInternalMemoizedMergedChildContext;
1751 }
1752
1753 break;
1754 }
1755 }
1756
1757 node = node.return;
1758 } while (node !== null);
1759
1760 (function () {
1761 {
1762 {
1763 throw ReactError(Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."));
1764 }
1765 }
1766 })();
1767 }
1768}
1769
1770var BatchedRoot = 1;
1771var ConcurrentRoot = 2;
1772
1773// Intentionally not named imports because Rollup would use dynamic dispatch for
1774// CommonJS interop named imports.
1775var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority;
1776var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback;
1777var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback;
1778var Scheduler_shouldYield = Scheduler.unstable_shouldYield;
1779var Scheduler_requestPaint = Scheduler.unstable_requestPaint;
1780var Scheduler_now = Scheduler.unstable_now;
1781var Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
1782var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority;
1783var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
1784var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority;
1785var Scheduler_LowPriority = Scheduler.unstable_LowPriority;
1786var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
1787
1788if (enableSchedulerTracing) {
1789 // Provide explicit error message when production+profiling bundle of e.g.
1790 // react-dom is used with production (non-profiling) bundle of
1791 // scheduler/tracing
1792 (function () {
1793 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
1794 {
1795 throw ReactError(Error("It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling"));
1796 }
1797 }
1798 })();
1799}
1800
1801var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
1802// ascending numbers so we can compare them like numbers. They start at 90 to
1803// avoid clashing with Scheduler's priorities.
1804
1805var ImmediatePriority = 99;
1806var UserBlockingPriority = 98;
1807var NormalPriority = 97;
1808var LowPriority = 96;
1809var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
1810
1811var NoPriority = 90;
1812var shouldYield = Scheduler_shouldYield;
1813var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
1814Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
1815var syncQueue = null;
1816var immediateQueueCallbackNode = null;
1817var isFlushingSyncQueue = false;
1818var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
1819// This will be the case for modern browsers that support `performance.now`. In
1820// older browsers, Scheduler falls back to `Date.now`, which returns a Unix
1821// timestamp. In that case, subtract the module initialization time to simulate
1822// the behavior of performance.now and keep our times small enough to fit
1823// within 32 bits.
1824// TODO: Consider lifting this into Scheduler.
1825
1826var now$1 = initialTimeMs < 10000 ? Scheduler_now : function () {
1827 return Scheduler_now() - initialTimeMs;
1828};
1829function getCurrentPriorityLevel() {
1830 switch (Scheduler_getCurrentPriorityLevel()) {
1831 case Scheduler_ImmediatePriority:
1832 return ImmediatePriority;
1833
1834 case Scheduler_UserBlockingPriority:
1835 return UserBlockingPriority;
1836
1837 case Scheduler_NormalPriority:
1838 return NormalPriority;
1839
1840 case Scheduler_LowPriority:
1841 return LowPriority;
1842
1843 case Scheduler_IdlePriority:
1844 return IdlePriority;
1845
1846 default:
1847 (function () {
1848 {
1849 {
1850 throw ReactError(Error("Unknown priority level."));
1851 }
1852 }
1853 })();
1854
1855 }
1856}
1857
1858function reactPriorityToSchedulerPriority(reactPriorityLevel) {
1859 switch (reactPriorityLevel) {
1860 case ImmediatePriority:
1861 return Scheduler_ImmediatePriority;
1862
1863 case UserBlockingPriority:
1864 return Scheduler_UserBlockingPriority;
1865
1866 case NormalPriority:
1867 return Scheduler_NormalPriority;
1868
1869 case LowPriority:
1870 return Scheduler_LowPriority;
1871
1872 case IdlePriority:
1873 return Scheduler_IdlePriority;
1874
1875 default:
1876 (function () {
1877 {
1878 {
1879 throw ReactError(Error("Unknown priority level."));
1880 }
1881 }
1882 })();
1883
1884 }
1885}
1886
1887function runWithPriority(reactPriorityLevel, fn) {
1888 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
1889 return Scheduler_runWithPriority(priorityLevel, fn);
1890}
1891function scheduleCallback(reactPriorityLevel, callback, options) {
1892 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
1893 return Scheduler_scheduleCallback(priorityLevel, callback, options);
1894}
1895function scheduleSyncCallback(callback) {
1896 // Push this callback into an internal queue. We'll flush these either in
1897 // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
1898 if (syncQueue === null) {
1899 syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
1900
1901 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
1902 } else {
1903 // Push onto existing queue. Don't need to schedule a callback because
1904 // we already scheduled one when we created the queue.
1905 syncQueue.push(callback);
1906 }
1907
1908 return fakeCallbackNode;
1909}
1910function cancelCallback(callbackNode) {
1911 if (callbackNode !== fakeCallbackNode) {
1912 Scheduler_cancelCallback(callbackNode);
1913 }
1914}
1915function flushSyncCallbackQueue() {
1916 if (immediateQueueCallbackNode !== null) {
1917 var node = immediateQueueCallbackNode;
1918 immediateQueueCallbackNode = null;
1919 Scheduler_cancelCallback(node);
1920 }
1921
1922 flushSyncCallbackQueueImpl();
1923}
1924
1925function flushSyncCallbackQueueImpl() {
1926 if (!isFlushingSyncQueue && syncQueue !== null) {
1927 // Prevent re-entrancy.
1928 isFlushingSyncQueue = true;
1929 var i = 0;
1930
1931 try {
1932 var _isSync = true;
1933 var queue = syncQueue;
1934 runWithPriority(ImmediatePriority, function () {
1935 for (; i < queue.length; i++) {
1936 var callback = queue[i];
1937
1938 do {
1939 callback = callback(_isSync);
1940 } while (callback !== null);
1941 }
1942 });
1943 syncQueue = null;
1944 } catch (error) {
1945 // If something throws, leave the remaining callbacks on the queue.
1946 if (syncQueue !== null) {
1947 syncQueue = syncQueue.slice(i + 1);
1948 } // Resume flushing in the next tick
1949
1950
1951 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
1952 throw error;
1953 } finally {
1954 isFlushingSyncQueue = false;
1955 }
1956 }
1957}
1958
1959var NoMode = 0;
1960var StrictMode = 1; // TODO: Remove BatchedMode and ConcurrentMode by reading from the root
1961// tag instead
1962
1963var BatchedMode = 2;
1964var ConcurrentMode = 4;
1965var ProfileMode = 8;
1966
1967// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
1968// Math.pow(2, 30) - 1
1969// 0b111111111111111111111111111111
1970var MAX_SIGNED_31_BIT_INT = 1073741823;
1971
1972var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that
1973// Never work can be committed in an inconsistent state without tearing the UI.
1974// The main example is offscreen content, like a hidden subtree. So one possible
1975// name is Offscreen. However, it also includes dehydrated Suspense boundaries,
1976// which are inconsistent in the sense that they haven't finished yet, but
1977// aren't visibly inconsistent because the server rendered HTML matches what the
1978// hydrated tree would look like.
1979
1980var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in
1981// order to be consistent.
1982
1983var Idle = 2;
1984var Sync = MAX_SIGNED_31_BIT_INT;
1985var Batched = Sync - 1;
1986var UNIT_SIZE = 10;
1987var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms.
1988
1989function msToExpirationTime(ms) {
1990 // Always add an offset so that we don't clash with the magic number for NoWork.
1991 return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
1992}
1993function expirationTimeToMs(expirationTime) {
1994 return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
1995}
1996
1997function ceiling(num, precision) {
1998 return ((num / precision | 0) + 1) * precision;
1999}
2000
2001function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
2002 return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
2003} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
2004// the names to reflect.
2005
2006
2007var LOW_PRIORITY_EXPIRATION = 5000;
2008var LOW_PRIORITY_BATCH_SIZE = 250;
2009function computeAsyncExpiration(currentTime) {
2010 return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
2011}
2012function computeSuspenseExpiration(currentTime, timeoutMs) {
2013 // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
2014 return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
2015} // We intentionally set a higher expiration time for interactive updates in
2016// dev than in production.
2017//
2018// If the main thread is being blocked so long that you hit the expiration,
2019// it's a problem that could be solved with better scheduling.
2020//
2021// People will be more likely to notice this and fix it with the long
2022// expiration time in development.
2023//
2024// In production we opt for better UX at the risk of masking scheduling
2025// problems, by expiring fast.
2026
2027var HIGH_PRIORITY_EXPIRATION = 500;
2028var HIGH_PRIORITY_BATCH_SIZE = 100;
2029function computeInteractiveExpiration(currentTime) {
2030 return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
2031}
2032function inferPriorityFromExpirationTime(currentTime, expirationTime) {
2033 if (expirationTime === Sync) {
2034 return ImmediatePriority;
2035 }
2036
2037 if (expirationTime === Never || expirationTime === Idle) {
2038 return IdlePriority;
2039 }
2040
2041 var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
2042
2043 if (msUntil <= 0) {
2044 return ImmediatePriority;
2045 }
2046
2047 if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
2048 return UserBlockingPriority;
2049 }
2050
2051 if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
2052 return NormalPriority;
2053 } // TODO: Handle LowPriority
2054 // Assume anything lower has idle priority
2055
2056
2057 return IdlePriority;
2058}
2059
2060/**
2061 * inlined Object.is polyfill to avoid requiring consumers ship their own
2062 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
2063 */
2064function is(x, y) {
2065 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
2066 ;
2067}
2068
2069var is$1 = typeof Object.is === 'function' ? Object.is : is;
2070
2071var hasOwnProperty = Object.prototype.hasOwnProperty;
2072/**
2073 * Performs equality by iterating through keys on an object and returning false
2074 * when any key has values which are not strictly equal between the arguments.
2075 * Returns true when the values of all keys are strictly equal.
2076 */
2077
2078function shallowEqual(objA, objB) {
2079 if (is$1(objA, objB)) {
2080 return true;
2081 }
2082
2083 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
2084 return false;
2085 }
2086
2087 var keysA = Object.keys(objA);
2088 var keysB = Object.keys(objB);
2089
2090 if (keysA.length !== keysB.length) {
2091 return false;
2092 } // Test for A's keys different from B.
2093
2094
2095 for (var i = 0; i < keysA.length; i++) {
2096 if (!hasOwnProperty.call(objB, keysA[i]) || !is$1(objA[keysA[i]], objB[keysA[i]])) {
2097 return false;
2098 }
2099 }
2100
2101 return true;
2102}
2103
2104/**
2105 * Forked from fbjs/warning:
2106 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
2107 *
2108 * Only change is we use console.warn instead of console.error,
2109 * and do nothing when 'console' is not supported.
2110 * This really simplifies the code.
2111 * ---
2112 * Similar to invariant but only logs a warning if the condition is not met.
2113 * This can be used to log issues in development environments in critical
2114 * paths. Removing the logging code for production environments will keep the
2115 * same logic and follow the same code paths.
2116 */
2117var lowPriorityWarningWithoutStack = function () {};
2118
2119{
2120 var printWarning = function (format) {
2121 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2122 args[_key - 1] = arguments[_key];
2123 }
2124
2125 var argIndex = 0;
2126 var message = 'Warning: ' + format.replace(/%s/g, function () {
2127 return args[argIndex++];
2128 });
2129
2130 if (typeof console !== 'undefined') {
2131 console.warn(message);
2132 }
2133
2134 try {
2135 // --- Welcome to debugging React ---
2136 // This error was thrown as a convenience so that you can use this stack
2137 // to find the callsite that caused this warning to fire.
2138 throw new Error(message);
2139 } catch (x) {}
2140 };
2141
2142 lowPriorityWarningWithoutStack = function (condition, format) {
2143 if (format === undefined) {
2144 throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
2145 }
2146
2147 if (!condition) {
2148 for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2149 args[_key2 - 2] = arguments[_key2];
2150 }
2151
2152 printWarning.apply(void 0, [format].concat(args));
2153 }
2154 };
2155}
2156
2157var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
2158
2159var ReactStrictModeWarnings = {
2160 recordUnsafeLifecycleWarnings: function (fiber, instance) {},
2161 flushPendingUnsafeLifecycleWarnings: function () {},
2162 recordLegacyContextWarning: function (fiber, instance) {},
2163 flushLegacyContextWarning: function () {},
2164 discardPendingWarnings: function () {}
2165};
2166
2167{
2168 var findStrictRoot = function (fiber) {
2169 var maybeStrictRoot = null;
2170 var node = fiber;
2171
2172 while (node !== null) {
2173 if (node.mode & StrictMode) {
2174 maybeStrictRoot = node;
2175 }
2176
2177 node = node.return;
2178 }
2179
2180 return maybeStrictRoot;
2181 };
2182
2183 var setToSortedString = function (set) {
2184 var array = [];
2185 set.forEach(function (value) {
2186 array.push(value);
2187 });
2188 return array.sort().join(', ');
2189 };
2190
2191 var pendingComponentWillMountWarnings = [];
2192 var pendingUNSAFE_ComponentWillMountWarnings = [];
2193 var pendingComponentWillReceivePropsWarnings = [];
2194 var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2195 var pendingComponentWillUpdateWarnings = [];
2196 var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
2197
2198 var didWarnAboutUnsafeLifecycles = new Set();
2199
2200 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
2201 // Dedup strategy: Warn once per component.
2202 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
2203 return;
2204 }
2205
2206 if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components.
2207 instance.componentWillMount.__suppressDeprecationWarning !== true) {
2208 pendingComponentWillMountWarnings.push(fiber);
2209 }
2210
2211 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
2212 pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
2213 }
2214
2215 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
2216 pendingComponentWillReceivePropsWarnings.push(fiber);
2217 }
2218
2219 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
2220 pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
2221 }
2222
2223 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
2224 pendingComponentWillUpdateWarnings.push(fiber);
2225 }
2226
2227 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
2228 pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
2229 }
2230 };
2231
2232 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
2233 // We do an initial pass to gather component names
2234 var componentWillMountUniqueNames = new Set();
2235
2236 if (pendingComponentWillMountWarnings.length > 0) {
2237 pendingComponentWillMountWarnings.forEach(function (fiber) {
2238 componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
2239 didWarnAboutUnsafeLifecycles.add(fiber.type);
2240 });
2241 pendingComponentWillMountWarnings = [];
2242 }
2243
2244 var UNSAFE_componentWillMountUniqueNames = new Set();
2245
2246 if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
2247 pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
2248 UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
2249 didWarnAboutUnsafeLifecycles.add(fiber.type);
2250 });
2251 pendingUNSAFE_ComponentWillMountWarnings = [];
2252 }
2253
2254 var componentWillReceivePropsUniqueNames = new Set();
2255
2256 if (pendingComponentWillReceivePropsWarnings.length > 0) {
2257 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
2258 componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
2259 didWarnAboutUnsafeLifecycles.add(fiber.type);
2260 });
2261 pendingComponentWillReceivePropsWarnings = [];
2262 }
2263
2264 var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
2265
2266 if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
2267 pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
2268 UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
2269 didWarnAboutUnsafeLifecycles.add(fiber.type);
2270 });
2271 pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2272 }
2273
2274 var componentWillUpdateUniqueNames = new Set();
2275
2276 if (pendingComponentWillUpdateWarnings.length > 0) {
2277 pendingComponentWillUpdateWarnings.forEach(function (fiber) {
2278 componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
2279 didWarnAboutUnsafeLifecycles.add(fiber.type);
2280 });
2281 pendingComponentWillUpdateWarnings = [];
2282 }
2283
2284 var UNSAFE_componentWillUpdateUniqueNames = new Set();
2285
2286 if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
2287 pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
2288 UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
2289 didWarnAboutUnsafeLifecycles.add(fiber.type);
2290 });
2291 pendingUNSAFE_ComponentWillUpdateWarnings = [];
2292 } // Finally, we flush all the warnings
2293 // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
2294
2295
2296 if (UNSAFE_componentWillMountUniqueNames.size > 0) {
2297 var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
2298 warningWithoutStack$1(false, 'Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames);
2299 }
2300
2301 if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
2302 var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
2303
2304 warningWithoutStack$1(false, 'Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
2305 }
2306
2307 if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
2308 var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
2309
2310 warningWithoutStack$1(false, 'Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
2311 }
2312
2313 if (componentWillMountUniqueNames.size > 0) {
2314 var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
2315
2316 lowPriorityWarningWithoutStack$1(false, 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3);
2317 }
2318
2319 if (componentWillReceivePropsUniqueNames.size > 0) {
2320 var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
2321
2322 lowPriorityWarningWithoutStack$1(false, 'componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4);
2323 }
2324
2325 if (componentWillUpdateUniqueNames.size > 0) {
2326 var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
2327
2328 lowPriorityWarningWithoutStack$1(false, 'componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5);
2329 }
2330 };
2331
2332 var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
2333
2334 var didWarnAboutLegacyContext = new Set();
2335
2336 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
2337 var strictRoot = findStrictRoot(fiber);
2338
2339 if (strictRoot === null) {
2340 warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
2341 return;
2342 } // Dedup strategy: Warn once per component.
2343
2344
2345 if (didWarnAboutLegacyContext.has(fiber.type)) {
2346 return;
2347 }
2348
2349 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
2350
2351 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
2352 if (warningsForRoot === undefined) {
2353 warningsForRoot = [];
2354 pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
2355 }
2356
2357 warningsForRoot.push(fiber);
2358 }
2359 };
2360
2361 ReactStrictModeWarnings.flushLegacyContextWarning = function () {
2362 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
2363 var uniqueNames = new Set();
2364 fiberArray.forEach(function (fiber) {
2365 uniqueNames.add(getComponentName(fiber.type) || 'Component');
2366 didWarnAboutLegacyContext.add(fiber.type);
2367 });
2368 var sortedNames = setToSortedString(uniqueNames);
2369 var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
2370 warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, strictRootComponentStack);
2371 });
2372 };
2373
2374 ReactStrictModeWarnings.discardPendingWarnings = function () {
2375 pendingComponentWillMountWarnings = [];
2376 pendingUNSAFE_ComponentWillMountWarnings = [];
2377 pendingComponentWillReceivePropsWarnings = [];
2378 pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2379 pendingComponentWillUpdateWarnings = [];
2380 pendingUNSAFE_ComponentWillUpdateWarnings = [];
2381 pendingLegacyContextWarning = new Map();
2382 };
2383}
2384
2385var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
2386
2387var failedBoundaries = null;
2388var setRefreshHandler = function (handler) {
2389 {
2390 resolveFamily = handler;
2391 }
2392};
2393function resolveFunctionForHotReloading(type) {
2394 {
2395 if (resolveFamily === null) {
2396 // Hot reloading is disabled.
2397 return type;
2398 }
2399
2400 var family = resolveFamily(type);
2401
2402 if (family === undefined) {
2403 return type;
2404 } // Use the latest known implementation.
2405
2406
2407 return family.current;
2408 }
2409}
2410function resolveClassForHotReloading(type) {
2411 // No implementation differences.
2412 return resolveFunctionForHotReloading(type);
2413}
2414function resolveForwardRefForHotReloading(type) {
2415 {
2416 if (resolveFamily === null) {
2417 // Hot reloading is disabled.
2418 return type;
2419 }
2420
2421 var family = resolveFamily(type);
2422
2423 if (family === undefined) {
2424 // Check if we're dealing with a real forwardRef. Don't want to crash early.
2425 if (type !== null && type !== undefined && typeof type.render === 'function') {
2426 // ForwardRef is special because its resolved .type is an object,
2427 // but it's possible that we only have its inner render function in the map.
2428 // If that inner render function is different, we'll build a new forwardRef type.
2429 var currentRender = resolveFunctionForHotReloading(type.render);
2430
2431 if (type.render !== currentRender) {
2432 var syntheticType = {
2433 $$typeof: REACT_FORWARD_REF_TYPE,
2434 render: currentRender
2435 };
2436
2437 if (type.displayName !== undefined) {
2438 syntheticType.displayName = type.displayName;
2439 }
2440
2441 return syntheticType;
2442 }
2443 }
2444
2445 return type;
2446 } // Use the latest known implementation.
2447
2448
2449 return family.current;
2450 }
2451}
2452function isCompatibleFamilyForHotReloading(fiber, element) {
2453 {
2454 if (resolveFamily === null) {
2455 // Hot reloading is disabled.
2456 return false;
2457 }
2458
2459 var prevType = fiber.elementType;
2460 var nextType = element.type; // If we got here, we know types aren't === equal.
2461
2462 var needsCompareFamilies = false;
2463 var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
2464
2465 switch (fiber.tag) {
2466 case ClassComponent:
2467 {
2468 if (typeof nextType === 'function') {
2469 needsCompareFamilies = true;
2470 }
2471
2472 break;
2473 }
2474
2475 case FunctionComponent:
2476 {
2477 if (typeof nextType === 'function') {
2478 needsCompareFamilies = true;
2479 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2480 // We don't know the inner type yet.
2481 // We're going to assume that the lazy inner type is stable,
2482 // and so it is sufficient to avoid reconciling it away.
2483 // We're not going to unwrap or actually use the new lazy type.
2484 needsCompareFamilies = true;
2485 }
2486
2487 break;
2488 }
2489
2490 case ForwardRef:
2491 {
2492 if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
2493 needsCompareFamilies = true;
2494 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2495 needsCompareFamilies = true;
2496 }
2497
2498 break;
2499 }
2500
2501 case MemoComponent:
2502 case SimpleMemoComponent:
2503 {
2504 if ($$typeofNextType === REACT_MEMO_TYPE) {
2505 // TODO: if it was but can no longer be simple,
2506 // we shouldn't set this.
2507 needsCompareFamilies = true;
2508 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2509 needsCompareFamilies = true;
2510 }
2511
2512 break;
2513 }
2514
2515 default:
2516 return false;
2517 } // Check if both types have a family and it's the same one.
2518
2519
2520 if (needsCompareFamilies) {
2521 // Note: memo() and forwardRef() we'll compare outer rather than inner type.
2522 // This means both of them need to be registered to preserve state.
2523 // If we unwrapped and compared the inner types for wrappers instead,
2524 // then we would risk falsely saying two separate memo(Foo)
2525 // calls are equivalent because they wrap the same Foo function.
2526 var prevFamily = resolveFamily(prevType);
2527
2528 if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
2529 return true;
2530 }
2531 }
2532
2533 return false;
2534 }
2535}
2536function markFailedErrorBoundaryForHotReloading(fiber) {
2537 {
2538 if (resolveFamily === null) {
2539 // Hot reloading is disabled.
2540 return;
2541 }
2542
2543 if (typeof WeakSet !== 'function') {
2544 return;
2545 }
2546
2547 if (failedBoundaries === null) {
2548 failedBoundaries = new WeakSet();
2549 }
2550
2551 failedBoundaries.add(fiber);
2552 }
2553}
2554var scheduleRefresh = function (root, update) {
2555 {
2556 if (resolveFamily === null) {
2557 // Hot reloading is disabled.
2558 return;
2559 }
2560
2561 var staleFamilies = update.staleFamilies,
2562 updatedFamilies = update.updatedFamilies;
2563 flushPassiveEffects();
2564 flushSync(function () {
2565 scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
2566 });
2567 }
2568};
2569var scheduleRoot = function (root, element) {
2570 {
2571 if (root.context !== emptyContextObject) {
2572 // Super edge case: root has a legacy _renderSubtree context
2573 // but we don't know the parentComponent so we can't pass it.
2574 // Just ignore. We'll delete this with _renderSubtree code path later.
2575 return;
2576 }
2577
2578 flushPassiveEffects();
2579 updateContainerAtExpirationTime(element, root, null, Sync, null);
2580 }
2581};
2582
2583function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
2584 {
2585 var alternate = fiber.alternate,
2586 child = fiber.child,
2587 sibling = fiber.sibling,
2588 tag = fiber.tag,
2589 type = fiber.type;
2590 var candidateType = null;
2591
2592 switch (tag) {
2593 case FunctionComponent:
2594 case SimpleMemoComponent:
2595 case ClassComponent:
2596 candidateType = type;
2597 break;
2598
2599 case ForwardRef:
2600 candidateType = type.render;
2601 break;
2602
2603 default:
2604 break;
2605 }
2606
2607 if (resolveFamily === null) {
2608 throw new Error('Expected resolveFamily to be set during hot reload.');
2609 }
2610
2611 var needsRender = false;
2612 var needsRemount = false;
2613
2614 if (candidateType !== null) {
2615 var family = resolveFamily(candidateType);
2616
2617 if (family !== undefined) {
2618 if (staleFamilies.has(family)) {
2619 needsRemount = true;
2620 } else if (updatedFamilies.has(family)) {
2621 if (tag === ClassComponent) {
2622 needsRemount = true;
2623 } else {
2624 needsRender = true;
2625 }
2626 }
2627 }
2628 }
2629
2630 if (failedBoundaries !== null) {
2631 if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
2632 needsRemount = true;
2633 }
2634 }
2635
2636 if (needsRemount) {
2637 fiber._debugNeedsRemount = true;
2638 }
2639
2640 if (needsRemount || needsRender) {
2641 scheduleWork(fiber, Sync);
2642 }
2643
2644 if (child !== null && !needsRemount) {
2645 scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
2646 }
2647
2648 if (sibling !== null) {
2649 scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
2650 }
2651 }
2652}
2653
2654var findHostInstancesForRefresh = function (root, families) {
2655 {
2656 var hostInstances = new Set();
2657 var types = new Set(families.map(function (family) {
2658 return family.current;
2659 }));
2660 findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
2661 return hostInstances;
2662 }
2663};
2664
2665function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
2666 {
2667 var child = fiber.child,
2668 sibling = fiber.sibling,
2669 tag = fiber.tag,
2670 type = fiber.type;
2671 var candidateType = null;
2672
2673 switch (tag) {
2674 case FunctionComponent:
2675 case SimpleMemoComponent:
2676 case ClassComponent:
2677 candidateType = type;
2678 break;
2679
2680 case ForwardRef:
2681 candidateType = type.render;
2682 break;
2683
2684 default:
2685 break;
2686 }
2687
2688 var didMatch = false;
2689
2690 if (candidateType !== null) {
2691 if (types.has(candidateType)) {
2692 didMatch = true;
2693 }
2694 }
2695
2696 if (didMatch) {
2697 // We have a match. This only drills down to the closest host components.
2698 // There's no need to search deeper because for the purpose of giving
2699 // visual feedback, "flashing" outermost parent rectangles is sufficient.
2700 findHostInstancesForFiberShallowly(fiber, hostInstances);
2701 } else {
2702 // If there's no match, maybe there will be one further down in the child tree.
2703 if (child !== null) {
2704 findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
2705 }
2706 }
2707
2708 if (sibling !== null) {
2709 findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
2710 }
2711 }
2712}
2713
2714function findHostInstancesForFiberShallowly(fiber, hostInstances) {
2715 {
2716 var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
2717
2718 if (foundHostInstances) {
2719 return;
2720 } // If we didn't find any host children, fallback to closest host parent.
2721
2722
2723 var node = fiber;
2724
2725 while (true) {
2726 switch (node.tag) {
2727 case HostComponent:
2728 hostInstances.add(node.stateNode);
2729 return;
2730
2731 case HostPortal:
2732 hostInstances.add(node.stateNode.containerInfo);
2733 return;
2734
2735 case HostRoot:
2736 hostInstances.add(node.stateNode.containerInfo);
2737 return;
2738 }
2739
2740 if (node.return === null) {
2741 throw new Error('Expected to reach root first.');
2742 }
2743
2744 node = node.return;
2745 }
2746 }
2747}
2748
2749function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
2750 {
2751 var node = fiber;
2752 var foundHostInstances = false;
2753
2754 while (true) {
2755 if (node.tag === HostComponent) {
2756 // We got a match.
2757 foundHostInstances = true;
2758 hostInstances.add(node.stateNode); // There may still be more, so keep searching.
2759 } else if (node.child !== null) {
2760 node.child.return = node;
2761 node = node.child;
2762 continue;
2763 }
2764
2765 if (node === fiber) {
2766 return foundHostInstances;
2767 }
2768
2769 while (node.sibling === null) {
2770 if (node.return === null || node.return === fiber) {
2771 return foundHostInstances;
2772 }
2773
2774 node = node.return;
2775 }
2776
2777 node.sibling.return = node.return;
2778 node = node.sibling;
2779 }
2780 }
2781
2782 return false;
2783}
2784
2785function resolveDefaultProps(Component, baseProps) {
2786 if (Component && Component.defaultProps) {
2787 // Resolve default props. Taken from ReactElement
2788 var props = _assign({}, baseProps);
2789
2790 var defaultProps = Component.defaultProps;
2791
2792 for (var propName in defaultProps) {
2793 if (props[propName] === undefined) {
2794 props[propName] = defaultProps[propName];
2795 }
2796 }
2797
2798 return props;
2799 }
2800
2801 return baseProps;
2802}
2803function readLazyComponentType(lazyComponent) {
2804 initializeLazyComponentType(lazyComponent);
2805
2806 if (lazyComponent._status !== Resolved) {
2807 throw lazyComponent._result;
2808 }
2809
2810 return lazyComponent._result;
2811}
2812
2813var valueCursor = createCursor(null);
2814var rendererSigil;
2815
2816{
2817 // Use this to detect multiple renderers using the same context
2818 rendererSigil = {};
2819}
2820
2821var currentlyRenderingFiber = null;
2822var lastContextDependency = null;
2823var lastContextWithAllBitsObserved = null;
2824var isDisallowedContextReadInDEV = false;
2825function resetContextDependencies() {
2826 // This is called right before React yields execution, to ensure `readContext`
2827 // cannot be called outside the render phase.
2828 currentlyRenderingFiber = null;
2829 lastContextDependency = null;
2830 lastContextWithAllBitsObserved = null;
2831
2832 {
2833 isDisallowedContextReadInDEV = false;
2834 }
2835}
2836function enterDisallowedContextReadInDEV() {
2837 {
2838 isDisallowedContextReadInDEV = true;
2839 }
2840}
2841function exitDisallowedContextReadInDEV() {
2842 {
2843 isDisallowedContextReadInDEV = false;
2844 }
2845}
2846function pushProvider(providerFiber, nextValue) {
2847 var context = providerFiber.type._context;
2848
2849 if (isPrimaryRenderer) {
2850 push(valueCursor, context._currentValue, providerFiber);
2851 context._currentValue = nextValue;
2852
2853 {
2854 !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
2855 context._currentRenderer = rendererSigil;
2856 }
2857 } else {
2858 push(valueCursor, context._currentValue2, providerFiber);
2859 context._currentValue2 = nextValue;
2860
2861 {
2862 !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
2863 context._currentRenderer2 = rendererSigil;
2864 }
2865 }
2866}
2867function popProvider(providerFiber) {
2868 var currentValue = valueCursor.current;
2869 pop(valueCursor, providerFiber);
2870 var context = providerFiber.type._context;
2871
2872 if (isPrimaryRenderer) {
2873 context._currentValue = currentValue;
2874 } else {
2875 context._currentValue2 = currentValue;
2876 }
2877}
2878function calculateChangedBits(context, newValue, oldValue) {
2879 if (is$1(oldValue, newValue)) {
2880 // No change
2881 return 0;
2882 } else {
2883 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
2884
2885 {
2886 !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
2887 }
2888
2889 return changedBits | 0;
2890 }
2891}
2892function scheduleWorkOnParentPath(parent, renderExpirationTime) {
2893 // Update the child expiration time of all the ancestors, including
2894 // the alternates.
2895 var node = parent;
2896
2897 while (node !== null) {
2898 var alternate = node.alternate;
2899
2900 if (node.childExpirationTime < renderExpirationTime) {
2901 node.childExpirationTime = renderExpirationTime;
2902
2903 if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
2904 alternate.childExpirationTime = renderExpirationTime;
2905 }
2906 } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
2907 alternate.childExpirationTime = renderExpirationTime;
2908 } else {
2909 // Neither alternate was updated, which means the rest of the
2910 // ancestor path already has sufficient priority.
2911 break;
2912 }
2913
2914 node = node.return;
2915 }
2916}
2917function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
2918 var fiber = workInProgress.child;
2919
2920 if (fiber !== null) {
2921 // Set the return pointer of the child to the work-in-progress fiber.
2922 fiber.return = workInProgress;
2923 }
2924
2925 while (fiber !== null) {
2926 var nextFiber = void 0; // Visit this fiber.
2927
2928 var list = fiber.dependencies;
2929
2930 if (list !== null) {
2931 nextFiber = fiber.child;
2932 var dependency = list.firstContext;
2933
2934 while (dependency !== null) {
2935 // Check if the context matches.
2936 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
2937 // Match! Schedule an update on this fiber.
2938 if (fiber.tag === ClassComponent) {
2939 // Schedule a force update on the work-in-progress.
2940 var update = createUpdate(renderExpirationTime, null);
2941 update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
2942 // update to the current fiber, too, which means it will persist even if
2943 // this render is thrown away. Since it's a race condition, not sure it's
2944 // worth fixing.
2945
2946 enqueueUpdate(fiber, update);
2947 }
2948
2949 if (fiber.expirationTime < renderExpirationTime) {
2950 fiber.expirationTime = renderExpirationTime;
2951 }
2952
2953 var alternate = fiber.alternate;
2954
2955 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
2956 alternate.expirationTime = renderExpirationTime;
2957 }
2958
2959 scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
2960
2961 if (list.expirationTime < renderExpirationTime) {
2962 list.expirationTime = renderExpirationTime;
2963 } // Since we already found a match, we can stop traversing the
2964 // dependency list.
2965
2966
2967 break;
2968 }
2969
2970 dependency = dependency.next;
2971 }
2972 } else if (fiber.tag === ContextProvider) {
2973 // Don't scan deeper if this is a matching provider
2974 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
2975 } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedFragment) {
2976 // If a dehydrated suspense bounudary is in this subtree, we don't know
2977 // if it will have any context consumers in it. The best we can do is
2978 // mark it as having updates.
2979 var parentSuspense = fiber.return;
2980
2981 (function () {
2982 if (!(parentSuspense !== null)) {
2983 {
2984 throw ReactError(Error("We just came from a parent so we must have had a parent. This is a bug in React."));
2985 }
2986 }
2987 })();
2988
2989 if (parentSuspense.expirationTime < renderExpirationTime) {
2990 parentSuspense.expirationTime = renderExpirationTime;
2991 }
2992
2993 var _alternate = parentSuspense.alternate;
2994
2995 if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
2996 _alternate.expirationTime = renderExpirationTime;
2997 } // This is intentionally passing this fiber as the parent
2998 // because we want to schedule this fiber as having work
2999 // on its children. We'll use the childExpirationTime on
3000 // this fiber to indicate that a context has changed.
3001
3002
3003 scheduleWorkOnParentPath(parentSuspense, renderExpirationTime);
3004 nextFiber = fiber.sibling;
3005 } else {
3006 // Traverse down.
3007 nextFiber = fiber.child;
3008 }
3009
3010 if (nextFiber !== null) {
3011 // Set the return pointer of the child to the work-in-progress fiber.
3012 nextFiber.return = fiber;
3013 } else {
3014 // No child. Traverse to next sibling.
3015 nextFiber = fiber;
3016
3017 while (nextFiber !== null) {
3018 if (nextFiber === workInProgress) {
3019 // We're back to the root of this subtree. Exit.
3020 nextFiber = null;
3021 break;
3022 }
3023
3024 var sibling = nextFiber.sibling;
3025
3026 if (sibling !== null) {
3027 // Set the return pointer of the sibling to the work-in-progress fiber.
3028 sibling.return = nextFiber.return;
3029 nextFiber = sibling;
3030 break;
3031 } // No more siblings. Traverse up.
3032
3033
3034 nextFiber = nextFiber.return;
3035 }
3036 }
3037
3038 fiber = nextFiber;
3039 }
3040}
3041function prepareToReadContext(workInProgress, renderExpirationTime) {
3042 currentlyRenderingFiber = workInProgress;
3043 lastContextDependency = null;
3044 lastContextWithAllBitsObserved = null;
3045 var dependencies = workInProgress.dependencies;
3046
3047 if (dependencies !== null) {
3048 var firstContext = dependencies.firstContext;
3049
3050 if (firstContext !== null) {
3051 if (dependencies.expirationTime >= renderExpirationTime) {
3052 // Context list has a pending update. Mark that this fiber performed work.
3053 markWorkInProgressReceivedUpdate();
3054 } // Reset the work-in-progress list
3055
3056
3057 dependencies.firstContext = null;
3058 }
3059 }
3060}
3061function readContext(context, observedBits) {
3062 {
3063 // This warning would fire if you read context inside a Hook like useMemo.
3064 // Unlike the class check below, it's not enforced in production for perf.
3065 !!isDisallowedContextReadInDEV ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
3066 }
3067
3068 if (lastContextWithAllBitsObserved === context) {// Nothing to do. We already observe everything in this context.
3069 } else if (observedBits === false || observedBits === 0) {// Do not observe any updates.
3070 } else {
3071 var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types.
3072
3073 if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
3074 // Observe all updates.
3075 lastContextWithAllBitsObserved = context;
3076 resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
3077 } else {
3078 resolvedObservedBits = observedBits;
3079 }
3080
3081 var contextItem = {
3082 context: context,
3083 observedBits: resolvedObservedBits,
3084 next: null
3085 };
3086
3087 if (lastContextDependency === null) {
3088 (function () {
3089 if (!(currentlyRenderingFiber !== null)) {
3090 {
3091 throw ReactError(Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."));
3092 }
3093 }
3094 })(); // This is the first dependency for this component. Create a new list.
3095
3096
3097 lastContextDependency = contextItem;
3098 currentlyRenderingFiber.dependencies = {
3099 expirationTime: NoWork,
3100 firstContext: contextItem,
3101 responders: null
3102 };
3103 } else {
3104 // Append a new context item.
3105 lastContextDependency = lastContextDependency.next = contextItem;
3106 }
3107 }
3108
3109 return isPrimaryRenderer ? context._currentValue : context._currentValue2;
3110}
3111
3112// UpdateQueue is a linked list of prioritized updates.
3113//
3114// Like fibers, update queues come in pairs: a current queue, which represents
3115// the visible state of the screen, and a work-in-progress queue, which can be
3116// mutated and processed asynchronously before it is committed — a form of
3117// double buffering. If a work-in-progress render is discarded before finishing,
3118// we create a new work-in-progress by cloning the current queue.
3119//
3120// Both queues share a persistent, singly-linked list structure. To schedule an
3121// update, we append it to the end of both queues. Each queue maintains a
3122// pointer to first update in the persistent list that hasn't been processed.
3123// The work-in-progress pointer always has a position equal to or greater than
3124// the current queue, since we always work on that one. The current queue's
3125// pointer is only updated during the commit phase, when we swap in the
3126// work-in-progress.
3127//
3128// For example:
3129//
3130// Current pointer: A - B - C - D - E - F
3131// Work-in-progress pointer: D - E - F
3132// ^
3133// The work-in-progress queue has
3134// processed more updates than current.
3135//
3136// The reason we append to both queues is because otherwise we might drop
3137// updates without ever processing them. For example, if we only add updates to
3138// the work-in-progress queue, some updates could be lost whenever a work-in
3139// -progress render restarts by cloning from current. Similarly, if we only add
3140// updates to the current queue, the updates will be lost whenever an already
3141// in-progress queue commits and swaps with the current queue. However, by
3142// adding to both queues, we guarantee that the update will be part of the next
3143// work-in-progress. (And because the work-in-progress queue becomes the
3144// current queue once it commits, there's no danger of applying the same
3145// update twice.)
3146//
3147// Prioritization
3148// --------------
3149//
3150// Updates are not sorted by priority, but by insertion; new updates are always
3151// appended to the end of the list.
3152//
3153// The priority is still important, though. When processing the update queue
3154// during the render phase, only the updates with sufficient priority are
3155// included in the result. If we skip an update because it has insufficient
3156// priority, it remains in the queue to be processed later, during a lower
3157// priority render. Crucially, all updates subsequent to a skipped update also
3158// remain in the queue *regardless of their priority*. That means high priority
3159// updates are sometimes processed twice, at two separate priorities. We also
3160// keep track of a base state, that represents the state before the first
3161// update in the queue is applied.
3162//
3163// For example:
3164//
3165// Given a base state of '', and the following queue of updates
3166//
3167// A1 - B2 - C1 - D2
3168//
3169// where the number indicates the priority, and the update is applied to the
3170// previous state by appending a letter, React will process these updates as
3171// two separate renders, one per distinct priority level:
3172//
3173// First render, at priority 1:
3174// Base state: ''
3175// Updates: [A1, C1]
3176// Result state: 'AC'
3177//
3178// Second render, at priority 2:
3179// Base state: 'A' <- The base state does not include C1,
3180// because B2 was skipped.
3181// Updates: [B2, C1, D2] <- C1 was rebased on top of B2
3182// Result state: 'ABCD'
3183//
3184// Because we process updates in insertion order, and rebase high priority
3185// updates when preceding updates are skipped, the final result is deterministic
3186// regardless of priority. Intermediate state may vary according to system
3187// resources, but the final state is always the same.
3188var UpdateState = 0;
3189var ReplaceState = 1;
3190var ForceUpdate = 2;
3191var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`.
3192// It should only be read right after calling `processUpdateQueue`, via
3193// `checkHasForceUpdateAfterProcessing`.
3194
3195var hasForceUpdate = false;
3196var didWarnUpdateInsideUpdate;
3197var currentlyProcessingQueue;
3198
3199
3200{
3201 didWarnUpdateInsideUpdate = false;
3202 currentlyProcessingQueue = null;
3203
3204
3205}
3206
3207function createUpdateQueue(baseState) {
3208 var queue = {
3209 baseState: baseState,
3210 firstUpdate: null,
3211 lastUpdate: null,
3212 firstCapturedUpdate: null,
3213 lastCapturedUpdate: null,
3214 firstEffect: null,
3215 lastEffect: null,
3216 firstCapturedEffect: null,
3217 lastCapturedEffect: null
3218 };
3219 return queue;
3220}
3221
3222function cloneUpdateQueue(currentQueue) {
3223 var queue = {
3224 baseState: currentQueue.baseState,
3225 firstUpdate: currentQueue.firstUpdate,
3226 lastUpdate: currentQueue.lastUpdate,
3227 // TODO: With resuming, if we bail out and resuse the child tree, we should
3228 // keep these effects.
3229 firstCapturedUpdate: null,
3230 lastCapturedUpdate: null,
3231 firstEffect: null,
3232 lastEffect: null,
3233 firstCapturedEffect: null,
3234 lastCapturedEffect: null
3235 };
3236 return queue;
3237}
3238
3239function createUpdate(expirationTime, suspenseConfig) {
3240 var update = {
3241 expirationTime: expirationTime,
3242 suspenseConfig: suspenseConfig,
3243 tag: UpdateState,
3244 payload: null,
3245 callback: null,
3246 next: null,
3247 nextEffect: null
3248 };
3249
3250 {
3251 update.priority = getCurrentPriorityLevel();
3252 }
3253
3254 return update;
3255}
3256
3257function appendUpdateToQueue(queue, update) {
3258 // Append the update to the end of the list.
3259 if (queue.lastUpdate === null) {
3260 // Queue is empty
3261 queue.firstUpdate = queue.lastUpdate = update;
3262 } else {
3263 queue.lastUpdate.next = update;
3264 queue.lastUpdate = update;
3265 }
3266}
3267
3268function enqueueUpdate(fiber, update) {
3269 // Update queues are created lazily.
3270 var alternate = fiber.alternate;
3271 var queue1;
3272 var queue2;
3273
3274 if (alternate === null) {
3275 // There's only one fiber.
3276 queue1 = fiber.updateQueue;
3277 queue2 = null;
3278
3279 if (queue1 === null) {
3280 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
3281 }
3282 } else {
3283 // There are two owners.
3284 queue1 = fiber.updateQueue;
3285 queue2 = alternate.updateQueue;
3286
3287 if (queue1 === null) {
3288 if (queue2 === null) {
3289 // Neither fiber has an update queue. Create new ones.
3290 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
3291 queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
3292 } else {
3293 // Only one fiber has an update queue. Clone to create a new one.
3294 queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
3295 }
3296 } else {
3297 if (queue2 === null) {
3298 // Only one fiber has an update queue. Clone to create a new one.
3299 queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
3300 } else {// Both owners have an update queue.
3301 }
3302 }
3303 }
3304
3305 if (queue2 === null || queue1 === queue2) {
3306 // There's only a single queue.
3307 appendUpdateToQueue(queue1, update);
3308 } else {
3309 // There are two queues. We need to append the update to both queues,
3310 // while accounting for the persistent structure of the list — we don't
3311 // want the same update to be added multiple times.
3312 if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
3313 // One of the queues is not empty. We must add the update to both queues.
3314 appendUpdateToQueue(queue1, update);
3315 appendUpdateToQueue(queue2, update);
3316 } else {
3317 // Both queues are non-empty. The last update is the same in both lists,
3318 // because of structural sharing. So, only append to one of the lists.
3319 appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2.
3320
3321 queue2.lastUpdate = update;
3322 }
3323 }
3324
3325 {
3326 if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
3327 warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
3328 didWarnUpdateInsideUpdate = true;
3329 }
3330 }
3331}
3332function enqueueCapturedUpdate(workInProgress, update) {
3333 // Captured updates go into a separate list, and only on the work-in-
3334 // progress queue.
3335 var workInProgressQueue = workInProgress.updateQueue;
3336
3337 if (workInProgressQueue === null) {
3338 workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
3339 } else {
3340 // TODO: I put this here rather than createWorkInProgress so that we don't
3341 // clone the queue unnecessarily. There's probably a better way to
3342 // structure this.
3343 workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
3344 } // Append the update to the end of the list.
3345
3346
3347 if (workInProgressQueue.lastCapturedUpdate === null) {
3348 // This is the first render phase update
3349 workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
3350 } else {
3351 workInProgressQueue.lastCapturedUpdate.next = update;
3352 workInProgressQueue.lastCapturedUpdate = update;
3353 }
3354}
3355
3356function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
3357 var current = workInProgress.alternate;
3358
3359 if (current !== null) {
3360 // If the work-in-progress queue is equal to the current queue,
3361 // we need to clone it first.
3362 if (queue === current.updateQueue) {
3363 queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
3364 }
3365 }
3366
3367 return queue;
3368}
3369
3370function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
3371 switch (update.tag) {
3372 case ReplaceState:
3373 {
3374 var payload = update.payload;
3375
3376 if (typeof payload === 'function') {
3377 // Updater function
3378 {
3379 enterDisallowedContextReadInDEV();
3380
3381 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3382 payload.call(instance, prevState, nextProps);
3383 }
3384 }
3385
3386 var nextState = payload.call(instance, prevState, nextProps);
3387
3388 {
3389 exitDisallowedContextReadInDEV();
3390 }
3391
3392 return nextState;
3393 } // State object
3394
3395
3396 return payload;
3397 }
3398
3399 case CaptureUpdate:
3400 {
3401 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
3402 }
3403 // Intentional fallthrough
3404
3405 case UpdateState:
3406 {
3407 var _payload = update.payload;
3408 var partialState;
3409
3410 if (typeof _payload === 'function') {
3411 // Updater function
3412 {
3413 enterDisallowedContextReadInDEV();
3414
3415 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3416 _payload.call(instance, prevState, nextProps);
3417 }
3418 }
3419
3420 partialState = _payload.call(instance, prevState, nextProps);
3421
3422 {
3423 exitDisallowedContextReadInDEV();
3424 }
3425 } else {
3426 // Partial state object
3427 partialState = _payload;
3428 }
3429
3430 if (partialState === null || partialState === undefined) {
3431 // Null and undefined are treated as no-ops.
3432 return prevState;
3433 } // Merge the partial state and the previous state.
3434
3435
3436 return _assign({}, prevState, partialState);
3437 }
3438
3439 case ForceUpdate:
3440 {
3441 hasForceUpdate = true;
3442 return prevState;
3443 }
3444 }
3445
3446 return prevState;
3447}
3448
3449function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
3450 hasForceUpdate = false;
3451 queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
3452
3453 {
3454 currentlyProcessingQueue = queue;
3455 } // These values may change as we process the queue.
3456
3457
3458 var newBaseState = queue.baseState;
3459 var newFirstUpdate = null;
3460 var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result.
3461
3462 var update = queue.firstUpdate;
3463 var resultState = newBaseState;
3464
3465 while (update !== null) {
3466 var updateExpirationTime = update.expirationTime;
3467
3468 if (updateExpirationTime < renderExpirationTime) {
3469 // This update does not have sufficient priority. Skip it.
3470 if (newFirstUpdate === null) {
3471 // This is the first skipped update. It will be the first update in
3472 // the new list.
3473 newFirstUpdate = update; // Since this is the first update that was skipped, the current result
3474 // is the new base state.
3475
3476 newBaseState = resultState;
3477 } // Since this update will remain in the list, update the remaining
3478 // expiration time.
3479
3480
3481 if (newExpirationTime < updateExpirationTime) {
3482 newExpirationTime = updateExpirationTime;
3483 }
3484 } else {
3485 // This update does have sufficient priority.
3486 // Mark the event time of this update as relevant to this render pass.
3487 // TODO: This should ideally use the true event time of this update rather than
3488 // its priority which is a derived and not reverseable value.
3489 // TODO: We should skip this update if it was already committed but currently
3490 // we have no way of detecting the difference between a committed and suspended
3491 // update here.
3492 markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result.
3493
3494 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
3495 var callback = update.callback;
3496
3497 if (callback !== null) {
3498 workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
3499
3500 update.nextEffect = null;
3501
3502 if (queue.lastEffect === null) {
3503 queue.firstEffect = queue.lastEffect = update;
3504 } else {
3505 queue.lastEffect.nextEffect = update;
3506 queue.lastEffect = update;
3507 }
3508 }
3509 } // Continue to the next update.
3510
3511
3512 update = update.next;
3513 } // Separately, iterate though the list of captured updates.
3514
3515
3516 var newFirstCapturedUpdate = null;
3517 update = queue.firstCapturedUpdate;
3518
3519 while (update !== null) {
3520 var _updateExpirationTime = update.expirationTime;
3521
3522 if (_updateExpirationTime < renderExpirationTime) {
3523 // This update does not have sufficient priority. Skip it.
3524 if (newFirstCapturedUpdate === null) {
3525 // This is the first skipped captured update. It will be the first
3526 // update in the new list.
3527 newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is
3528 // the new base state.
3529
3530 if (newFirstUpdate === null) {
3531 newBaseState = resultState;
3532 }
3533 } // Since this update will remain in the list, update the remaining
3534 // expiration time.
3535
3536
3537 if (newExpirationTime < _updateExpirationTime) {
3538 newExpirationTime = _updateExpirationTime;
3539 }
3540 } else {
3541 // This update does have sufficient priority. Process it and compute
3542 // a new result.
3543 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
3544 var _callback = update.callback;
3545
3546 if (_callback !== null) {
3547 workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
3548
3549 update.nextEffect = null;
3550
3551 if (queue.lastCapturedEffect === null) {
3552 queue.firstCapturedEffect = queue.lastCapturedEffect = update;
3553 } else {
3554 queue.lastCapturedEffect.nextEffect = update;
3555 queue.lastCapturedEffect = update;
3556 }
3557 }
3558 }
3559
3560 update = update.next;
3561 }
3562
3563 if (newFirstUpdate === null) {
3564 queue.lastUpdate = null;
3565 }
3566
3567 if (newFirstCapturedUpdate === null) {
3568 queue.lastCapturedUpdate = null;
3569 } else {
3570 workInProgress.effectTag |= Callback;
3571 }
3572
3573 if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
3574 // We processed every update, without skipping. That means the new base
3575 // state is the same as the result state.
3576 newBaseState = resultState;
3577 }
3578
3579 queue.baseState = newBaseState;
3580 queue.firstUpdate = newFirstUpdate;
3581 queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue.
3582 // This should be fine because the only two other things that contribute to
3583 // expiration time are props and context. We're already in the middle of the
3584 // begin phase by the time we start processing the queue, so we've already
3585 // dealt with the props. Context in components that specify
3586 // shouldComponentUpdate is tricky; but we'll have to account for
3587 // that regardless.
3588
3589 markUnprocessedUpdateTime(newExpirationTime);
3590 workInProgress.expirationTime = newExpirationTime;
3591 workInProgress.memoizedState = resultState;
3592
3593 {
3594 currentlyProcessingQueue = null;
3595 }
3596}
3597
3598function callCallback(callback, context) {
3599 (function () {
3600 if (!(typeof callback === 'function')) {
3601 {
3602 throw ReactError(Error("Invalid argument passed as callback. Expected a function. Instead received: " + callback));
3603 }
3604 }
3605 })();
3606
3607 callback.call(context);
3608}
3609
3610function resetHasForceUpdateBeforeProcessing() {
3611 hasForceUpdate = false;
3612}
3613function checkHasForceUpdateAfterProcessing() {
3614 return hasForceUpdate;
3615}
3616function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
3617 // If the finished render included captured updates, and there are still
3618 // lower priority updates left over, we need to keep the captured updates
3619 // in the queue so that they are rebased and not dropped once we process the
3620 // queue again at the lower priority.
3621 if (finishedQueue.firstCapturedUpdate !== null) {
3622 // Join the captured update list to the end of the normal list.
3623 if (finishedQueue.lastUpdate !== null) {
3624 finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
3625 finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
3626 } // Clear the list of captured updates.
3627
3628
3629 finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
3630 } // Commit the effects
3631
3632
3633 commitUpdateEffects(finishedQueue.firstEffect, instance);
3634 finishedQueue.firstEffect = finishedQueue.lastEffect = null;
3635 commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
3636 finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
3637}
3638
3639function commitUpdateEffects(effect, instance) {
3640 while (effect !== null) {
3641 var callback = effect.callback;
3642
3643 if (callback !== null) {
3644 effect.callback = null;
3645 callCallback(callback, instance);
3646 }
3647
3648 effect = effect.nextEffect;
3649 }
3650}
3651
3652var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
3653function requestCurrentSuspenseConfig() {
3654 return ReactCurrentBatchConfig.suspense;
3655}
3656
3657var fakeInternalInstance = {};
3658var isArray$1 = Array.isArray; // React.Component uses a shared frozen object by default.
3659// We'll use it to determine whether we need to initialize legacy refs.
3660
3661var emptyRefsObject = new React.Component().refs;
3662var didWarnAboutStateAssignmentForComponent;
3663var didWarnAboutUninitializedState;
3664var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
3665var didWarnAboutLegacyLifecyclesAndDerivedState;
3666var didWarnAboutUndefinedDerivedState;
3667var warnOnUndefinedDerivedState;
3668var warnOnInvalidCallback;
3669var didWarnAboutDirectlyAssigningPropsToState;
3670var didWarnAboutContextTypeAndContextTypes;
3671var didWarnAboutInvalidateContextType;
3672
3673{
3674 didWarnAboutStateAssignmentForComponent = new Set();
3675 didWarnAboutUninitializedState = new Set();
3676 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
3677 didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
3678 didWarnAboutDirectlyAssigningPropsToState = new Set();
3679 didWarnAboutUndefinedDerivedState = new Set();
3680 didWarnAboutContextTypeAndContextTypes = new Set();
3681 didWarnAboutInvalidateContextType = new Set();
3682 var didWarnOnInvalidCallback = new Set();
3683
3684 warnOnInvalidCallback = function (callback, callerName) {
3685 if (callback === null || typeof callback === 'function') {
3686 return;
3687 }
3688
3689 var key = callerName + "_" + callback;
3690
3691 if (!didWarnOnInvalidCallback.has(key)) {
3692 didWarnOnInvalidCallback.add(key);
3693 warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
3694 }
3695 };
3696
3697 warnOnUndefinedDerivedState = function (type, partialState) {
3698 if (partialState === undefined) {
3699 var componentName = getComponentName(type) || 'Component';
3700
3701 if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
3702 didWarnAboutUndefinedDerivedState.add(componentName);
3703 warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
3704 }
3705 }
3706 }; // This is so gross but it's at least non-critical and can be removed if
3707 // it causes problems. This is meant to give a nicer error message for
3708 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
3709 // ...)) which otherwise throws a "_processChildContext is not a function"
3710 // exception.
3711
3712
3713 Object.defineProperty(fakeInternalInstance, '_processChildContext', {
3714 enumerable: false,
3715 value: function () {
3716 (function () {
3717 {
3718 {
3719 throw ReactError(Error("_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)."));
3720 }
3721 }
3722 })();
3723 }
3724 });
3725 Object.freeze(fakeInternalInstance);
3726}
3727
3728function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
3729 var prevState = workInProgress.memoizedState;
3730
3731 {
3732 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3733 // Invoke the function an extra time to help detect side-effects.
3734 getDerivedStateFromProps(nextProps, prevState);
3735 }
3736 }
3737
3738 var partialState = getDerivedStateFromProps(nextProps, prevState);
3739
3740 {
3741 warnOnUndefinedDerivedState(ctor, partialState);
3742 } // Merge the partial state and the previous state.
3743
3744
3745 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
3746 workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
3747 // base state.
3748
3749 var updateQueue = workInProgress.updateQueue;
3750
3751 if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
3752 updateQueue.baseState = memoizedState;
3753 }
3754}
3755var classComponentUpdater = {
3756 isMounted: isMounted,
3757 enqueueSetState: function (inst, payload, callback) {
3758 var fiber = get(inst);
3759 var currentTime = requestCurrentTime();
3760 var suspenseConfig = requestCurrentSuspenseConfig();
3761 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3762 var update = createUpdate(expirationTime, suspenseConfig);
3763 update.payload = payload;
3764
3765 if (callback !== undefined && callback !== null) {
3766 {
3767 warnOnInvalidCallback(callback, 'setState');
3768 }
3769
3770 update.callback = callback;
3771 }
3772
3773 enqueueUpdate(fiber, update);
3774 scheduleWork(fiber, expirationTime);
3775 },
3776 enqueueReplaceState: function (inst, payload, callback) {
3777 var fiber = get(inst);
3778 var currentTime = requestCurrentTime();
3779 var suspenseConfig = requestCurrentSuspenseConfig();
3780 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3781 var update = createUpdate(expirationTime, suspenseConfig);
3782 update.tag = ReplaceState;
3783 update.payload = payload;
3784
3785 if (callback !== undefined && callback !== null) {
3786 {
3787 warnOnInvalidCallback(callback, 'replaceState');
3788 }
3789
3790 update.callback = callback;
3791 }
3792
3793 enqueueUpdate(fiber, update);
3794 scheduleWork(fiber, expirationTime);
3795 },
3796 enqueueForceUpdate: function (inst, callback) {
3797 var fiber = get(inst);
3798 var currentTime = requestCurrentTime();
3799 var suspenseConfig = requestCurrentSuspenseConfig();
3800 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3801 var update = createUpdate(expirationTime, suspenseConfig);
3802 update.tag = ForceUpdate;
3803
3804 if (callback !== undefined && callback !== null) {
3805 {
3806 warnOnInvalidCallback(callback, 'forceUpdate');
3807 }
3808
3809 update.callback = callback;
3810 }
3811
3812 enqueueUpdate(fiber, update);
3813 scheduleWork(fiber, expirationTime);
3814 }
3815};
3816
3817function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
3818 var instance = workInProgress.stateNode;
3819
3820 if (typeof instance.shouldComponentUpdate === 'function') {
3821 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
3822 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
3823 stopPhaseTimer();
3824
3825 {
3826 !(shouldUpdate !== undefined) ? warningWithoutStack$1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component') : void 0;
3827 }
3828
3829 return shouldUpdate;
3830 }
3831
3832 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
3833 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
3834 }
3835
3836 return true;
3837}
3838
3839function checkClassInstance(workInProgress, ctor, newProps) {
3840 var instance = workInProgress.stateNode;
3841
3842 {
3843 var name = getComponentName(ctor) || 'Component';
3844 var renderPresent = instance.render;
3845
3846 if (!renderPresent) {
3847 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
3848 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
3849 } else {
3850 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
3851 }
3852 }
3853
3854 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
3855 !noGetInitialStateOnES6 ? warningWithoutStack$1(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
3856 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
3857 !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
3858 var noInstancePropTypes = !instance.propTypes;
3859 !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
3860 var noInstanceContextType = !instance.contextType;
3861 !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
3862
3863 if (disableLegacyContext) {
3864 if (ctor.childContextTypes) {
3865 warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', name);
3866 }
3867
3868 if (ctor.contextTypes) {
3869 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', name);
3870 }
3871 } else {
3872 var noInstanceContextTypes = !instance.contextTypes;
3873 !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
3874
3875 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
3876 didWarnAboutContextTypeAndContextTypes.add(ctor);
3877 warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
3878 }
3879 }
3880
3881 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
3882 !noComponentShouldUpdate ? warningWithoutStack$1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
3883
3884 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
3885 warningWithoutStack$1(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
3886 }
3887
3888 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
3889 !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
3890 var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
3891 !noComponentDidReceiveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
3892 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
3893 !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
3894 var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
3895 !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
3896 var hasMutatedProps = instance.props !== newProps;
3897 !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
3898 var noInstanceDefaultProps = !instance.defaultProps;
3899 !noInstanceDefaultProps ? warningWithoutStack$1(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
3900
3901 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
3902 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
3903 warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
3904 }
3905
3906 var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
3907 !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
3908 var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
3909 !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
3910 var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
3911 !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
3912 var _state = instance.state;
3913
3914 if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
3915 warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
3916 }
3917
3918 if (typeof instance.getChildContext === 'function') {
3919 !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
3920 }
3921 }
3922}
3923
3924function adoptClassInstance(workInProgress, instance) {
3925 instance.updater = classComponentUpdater;
3926 workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates
3927
3928 set(instance, workInProgress);
3929
3930 {
3931 instance._reactInternalInstance = fakeInternalInstance;
3932 }
3933}
3934
3935function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
3936 var isLegacyContextConsumer = false;
3937 var unmaskedContext = emptyContextObject;
3938 var context = emptyContextObject;
3939 var contextType = ctor.contextType;
3940
3941 {
3942 if ('contextType' in ctor) {
3943 var isValid = // Allow null for conditional declaration
3944 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
3945
3946 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
3947 didWarnAboutInvalidateContextType.add(ctor);
3948 var addendum = '';
3949
3950 if (contextType === undefined) {
3951 addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
3952 } else if (typeof contextType !== 'object') {
3953 addendum = ' However, it is set to a ' + typeof contextType + '.';
3954 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
3955 addendum = ' Did you accidentally pass the Context.Provider instead?';
3956 } else if (contextType._context !== undefined) {
3957 // <Context.Consumer>
3958 addendum = ' Did you accidentally pass the Context.Consumer instead?';
3959 } else {
3960 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
3961 }
3962
3963 warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
3964 }
3965 }
3966 }
3967
3968 if (typeof contextType === 'object' && contextType !== null) {
3969 context = readContext(contextType);
3970 } else if (!disableLegacyContext) {
3971 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
3972 var contextTypes = ctor.contextTypes;
3973 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
3974 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
3975 } // Instantiate twice to help detect side-effects.
3976
3977
3978 {
3979 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3980 new ctor(props, context); // eslint-disable-line no-new
3981 }
3982 }
3983
3984 var instance = new ctor(props, context);
3985 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
3986 adoptClassInstance(workInProgress, instance);
3987
3988 {
3989 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
3990 var componentName = getComponentName(ctor) || 'Component';
3991
3992 if (!didWarnAboutUninitializedState.has(componentName)) {
3993 didWarnAboutUninitializedState.add(componentName);
3994 warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
3995 }
3996 } // If new component APIs are defined, "unsafe" lifecycles won't be called.
3997 // Warn about these lifecycles if they are present.
3998 // Don't warn about react-lifecycles-compat polyfilled methods though.
3999
4000
4001 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
4002 var foundWillMountName = null;
4003 var foundWillReceivePropsName = null;
4004 var foundWillUpdateName = null;
4005
4006 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
4007 foundWillMountName = 'componentWillMount';
4008 } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
4009 foundWillMountName = 'UNSAFE_componentWillMount';
4010 }
4011
4012 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
4013 foundWillReceivePropsName = 'componentWillReceiveProps';
4014 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4015 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
4016 }
4017
4018 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
4019 foundWillUpdateName = 'componentWillUpdate';
4020 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4021 foundWillUpdateName = 'UNSAFE_componentWillUpdate';
4022 }
4023
4024 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
4025 var _componentName = getComponentName(ctor) || 'Component';
4026
4027 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
4028
4029 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
4030 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
4031 warningWithoutStack$1(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
4032 }
4033 }
4034 }
4035 } // Cache unmasked context so we can avoid recreating masked context unless necessary.
4036 // ReactFiberContext usually updates this cache but can't for newly-created instances.
4037
4038
4039 if (isLegacyContextConsumer) {
4040 cacheContext(workInProgress, unmaskedContext, context);
4041 }
4042
4043 return instance;
4044}
4045
4046function callComponentWillMount(workInProgress, instance) {
4047 startPhaseTimer(workInProgress, 'componentWillMount');
4048 var oldState = instance.state;
4049
4050 if (typeof instance.componentWillMount === 'function') {
4051 instance.componentWillMount();
4052 }
4053
4054 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4055 instance.UNSAFE_componentWillMount();
4056 }
4057
4058 stopPhaseTimer();
4059
4060 if (oldState !== instance.state) {
4061 {
4062 warningWithoutStack$1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
4063 }
4064
4065 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4066 }
4067}
4068
4069function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
4070 var oldState = instance.state;
4071 startPhaseTimer(workInProgress, 'componentWillReceiveProps');
4072
4073 if (typeof instance.componentWillReceiveProps === 'function') {
4074 instance.componentWillReceiveProps(newProps, nextContext);
4075 }
4076
4077 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4078 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
4079 }
4080
4081 stopPhaseTimer();
4082
4083 if (instance.state !== oldState) {
4084 {
4085 var componentName = getComponentName(workInProgress.type) || 'Component';
4086
4087 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
4088 didWarnAboutStateAssignmentForComponent.add(componentName);
4089 warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
4090 }
4091 }
4092
4093 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4094 }
4095} // Invokes the mount life-cycles on a previously never rendered instance.
4096
4097
4098function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4099 {
4100 checkClassInstance(workInProgress, ctor, newProps);
4101 }
4102
4103 var instance = workInProgress.stateNode;
4104 instance.props = newProps;
4105 instance.state = workInProgress.memoizedState;
4106 instance.refs = emptyRefsObject;
4107 var contextType = ctor.contextType;
4108
4109 if (typeof contextType === 'object' && contextType !== null) {
4110 instance.context = readContext(contextType);
4111 } else if (disableLegacyContext) {
4112 instance.context = emptyContextObject;
4113 } else {
4114 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4115 instance.context = getMaskedContext(workInProgress, unmaskedContext);
4116 }
4117
4118 {
4119 if (instance.state === newProps) {
4120 var componentName = getComponentName(ctor) || 'Component';
4121
4122 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
4123 didWarnAboutDirectlyAssigningPropsToState.add(componentName);
4124 warningWithoutStack$1(false, '%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
4125 }
4126 }
4127
4128 if (workInProgress.mode & StrictMode) {
4129 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
4130 }
4131
4132 if (warnAboutDeprecatedLifecycles) {
4133 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
4134 }
4135 }
4136
4137 var updateQueue = workInProgress.updateQueue;
4138
4139 if (updateQueue !== null) {
4140 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4141 instance.state = workInProgress.memoizedState;
4142 }
4143
4144 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4145
4146 if (typeof getDerivedStateFromProps === 'function') {
4147 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4148 instance.state = workInProgress.memoizedState;
4149 } // In order to support react-lifecycles-compat polyfilled components,
4150 // Unsafe lifecycles should not be invoked for components using the new APIs.
4151
4152
4153 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4154 callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
4155 // process them now.
4156
4157 updateQueue = workInProgress.updateQueue;
4158
4159 if (updateQueue !== null) {
4160 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4161 instance.state = workInProgress.memoizedState;
4162 }
4163 }
4164
4165 if (typeof instance.componentDidMount === 'function') {
4166 workInProgress.effectTag |= Update;
4167 }
4168}
4169
4170function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4171 var instance = workInProgress.stateNode;
4172 var oldProps = workInProgress.memoizedProps;
4173 instance.props = oldProps;
4174 var oldContext = instance.context;
4175 var contextType = ctor.contextType;
4176 var nextContext = emptyContextObject;
4177
4178 if (typeof contextType === 'object' && contextType !== null) {
4179 nextContext = readContext(contextType);
4180 } else if (!disableLegacyContext) {
4181 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4182 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4183 }
4184
4185 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4186 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
4187 // ever the previously attempted to render - not the "current". However,
4188 // during componentDidUpdate we pass the "current" props.
4189 // In order to support react-lifecycles-compat polyfilled components,
4190 // Unsafe lifecycles should not be invoked for components using the new APIs.
4191
4192 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4193 if (oldProps !== newProps || oldContext !== nextContext) {
4194 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4195 }
4196 }
4197
4198 resetHasForceUpdateBeforeProcessing();
4199 var oldState = workInProgress.memoizedState;
4200 var newState = instance.state = oldState;
4201 var updateQueue = workInProgress.updateQueue;
4202
4203 if (updateQueue !== null) {
4204 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4205 newState = workInProgress.memoizedState;
4206 }
4207
4208 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4209 // If an update was already in progress, we should schedule an Update
4210 // effect even though we're bailing out, so that cWU/cDU are called.
4211 if (typeof instance.componentDidMount === 'function') {
4212 workInProgress.effectTag |= Update;
4213 }
4214
4215 return false;
4216 }
4217
4218 if (typeof getDerivedStateFromProps === 'function') {
4219 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4220 newState = workInProgress.memoizedState;
4221 }
4222
4223 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4224
4225 if (shouldUpdate) {
4226 // In order to support react-lifecycles-compat polyfilled components,
4227 // Unsafe lifecycles should not be invoked for components using the new APIs.
4228 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4229 startPhaseTimer(workInProgress, 'componentWillMount');
4230
4231 if (typeof instance.componentWillMount === 'function') {
4232 instance.componentWillMount();
4233 }
4234
4235 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4236 instance.UNSAFE_componentWillMount();
4237 }
4238
4239 stopPhaseTimer();
4240 }
4241
4242 if (typeof instance.componentDidMount === 'function') {
4243 workInProgress.effectTag |= Update;
4244 }
4245 } else {
4246 // If an update was already in progress, we should schedule an Update
4247 // effect even though we're bailing out, so that cWU/cDU are called.
4248 if (typeof instance.componentDidMount === 'function') {
4249 workInProgress.effectTag |= Update;
4250 } // If shouldComponentUpdate returned false, we should still update the
4251 // memoized state to indicate that this work can be reused.
4252
4253
4254 workInProgress.memoizedProps = newProps;
4255 workInProgress.memoizedState = newState;
4256 } // Update the existing instance's state, props, and context pointers even
4257 // if shouldComponentUpdate returns false.
4258
4259
4260 instance.props = newProps;
4261 instance.state = newState;
4262 instance.context = nextContext;
4263 return shouldUpdate;
4264} // Invokes the update life-cycles and returns false if it shouldn't rerender.
4265
4266
4267function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
4268 var instance = workInProgress.stateNode;
4269 var oldProps = workInProgress.memoizedProps;
4270 instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
4271 var oldContext = instance.context;
4272 var contextType = ctor.contextType;
4273 var nextContext = emptyContextObject;
4274
4275 if (typeof contextType === 'object' && contextType !== null) {
4276 nextContext = readContext(contextType);
4277 } else if (!disableLegacyContext) {
4278 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4279 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
4280 }
4281
4282 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4283 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
4284 // ever the previously attempted to render - not the "current". However,
4285 // during componentDidUpdate we pass the "current" props.
4286 // In order to support react-lifecycles-compat polyfilled components,
4287 // Unsafe lifecycles should not be invoked for components using the new APIs.
4288
4289 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4290 if (oldProps !== newProps || oldContext !== nextContext) {
4291 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4292 }
4293 }
4294
4295 resetHasForceUpdateBeforeProcessing();
4296 var oldState = workInProgress.memoizedState;
4297 var newState = instance.state = oldState;
4298 var updateQueue = workInProgress.updateQueue;
4299
4300 if (updateQueue !== null) {
4301 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4302 newState = workInProgress.memoizedState;
4303 }
4304
4305 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4306 // If an update was already in progress, we should schedule an Update
4307 // effect even though we're bailing out, so that cWU/cDU are called.
4308 if (typeof instance.componentDidUpdate === 'function') {
4309 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4310 workInProgress.effectTag |= Update;
4311 }
4312 }
4313
4314 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4315 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4316 workInProgress.effectTag |= Snapshot;
4317 }
4318 }
4319
4320 return false;
4321 }
4322
4323 if (typeof getDerivedStateFromProps === 'function') {
4324 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4325 newState = workInProgress.memoizedState;
4326 }
4327
4328 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4329
4330 if (shouldUpdate) {
4331 // In order to support react-lifecycles-compat polyfilled components,
4332 // Unsafe lifecycles should not be invoked for components using the new APIs.
4333 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
4334 startPhaseTimer(workInProgress, 'componentWillUpdate');
4335
4336 if (typeof instance.componentWillUpdate === 'function') {
4337 instance.componentWillUpdate(newProps, newState, nextContext);
4338 }
4339
4340 if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4341 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
4342 }
4343
4344 stopPhaseTimer();
4345 }
4346
4347 if (typeof instance.componentDidUpdate === 'function') {
4348 workInProgress.effectTag |= Update;
4349 }
4350
4351 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4352 workInProgress.effectTag |= Snapshot;
4353 }
4354 } else {
4355 // If an update was already in progress, we should schedule an Update
4356 // effect even though we're bailing out, so that cWU/cDU are called.
4357 if (typeof instance.componentDidUpdate === 'function') {
4358 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4359 workInProgress.effectTag |= Update;
4360 }
4361 }
4362
4363 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4364 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4365 workInProgress.effectTag |= Snapshot;
4366 }
4367 } // If shouldComponentUpdate returned false, we should still update the
4368 // memoized props/state to indicate that this work can be reused.
4369
4370
4371 workInProgress.memoizedProps = newProps;
4372 workInProgress.memoizedState = newState;
4373 } // Update the existing instance's state, props, and context pointers even
4374 // if shouldComponentUpdate returns false.
4375
4376
4377 instance.props = newProps;
4378 instance.state = newState;
4379 instance.context = nextContext;
4380 return shouldUpdate;
4381}
4382
4383var didWarnAboutMaps;
4384var didWarnAboutGenerators;
4385var didWarnAboutStringRefs;
4386var ownerHasKeyUseWarning;
4387var ownerHasFunctionTypeWarning;
4388
4389var warnForMissingKey = function (child) {};
4390
4391{
4392 didWarnAboutMaps = false;
4393 didWarnAboutGenerators = false;
4394 didWarnAboutStringRefs = {};
4395 /**
4396 * Warn if there's no key explicitly set on dynamic arrays of children or
4397 * object keys are not valid. This allows us to keep track of children between
4398 * updates.
4399 */
4400
4401 ownerHasKeyUseWarning = {};
4402 ownerHasFunctionTypeWarning = {};
4403
4404 warnForMissingKey = function (child) {
4405 if (child === null || typeof child !== 'object') {
4406 return;
4407 }
4408
4409 if (!child._store || child._store.validated || child.key != null) {
4410 return;
4411 }
4412
4413 (function () {
4414 if (!(typeof child._store === 'object')) {
4415 {
4416 throw ReactError(Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue."));
4417 }
4418 }
4419 })();
4420
4421 child._store.validated = true;
4422 var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
4423
4424 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
4425 return;
4426 }
4427
4428 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
4429 warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
4430 };
4431}
4432
4433var isArray = Array.isArray;
4434
4435function coerceRef(returnFiber, current$$1, element) {
4436 var mixedRef = element.ref;
4437
4438 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
4439 {
4440 // TODO: Clean this up once we turn on the string ref warning for
4441 // everyone, because the strict mode case will no longer be relevant
4442 if (returnFiber.mode & StrictMode || warnAboutStringRefs) {
4443 var componentName = getComponentName(returnFiber.type) || 'Component';
4444
4445 if (!didWarnAboutStringRefs[componentName]) {
4446 if (warnAboutStringRefs) {
4447 warningWithoutStack$1(false, 'Component "%s" contains the string ref "%s". Support for string refs ' + 'will be removed in a future major release. We recommend using ' + 'useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', componentName, mixedRef, getStackByFiberInDevAndProd(returnFiber));
4448 } else {
4449 warningWithoutStack$1(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber));
4450 }
4451
4452 didWarnAboutStringRefs[componentName] = true;
4453 }
4454 }
4455 }
4456
4457 if (element._owner) {
4458 var owner = element._owner;
4459 var inst;
4460
4461 if (owner) {
4462 var ownerFiber = owner;
4463
4464 (function () {
4465 if (!(ownerFiber.tag === ClassComponent)) {
4466 {
4467 throw ReactError(Error("Function components cannot have refs. Did you mean to use React.forwardRef()?"));
4468 }
4469 }
4470 })();
4471
4472 inst = ownerFiber.stateNode;
4473 }
4474
4475 (function () {
4476 if (!inst) {
4477 {
4478 throw ReactError(Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue."));
4479 }
4480 }
4481 })();
4482
4483 var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref
4484
4485 if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
4486 return current$$1.ref;
4487 }
4488
4489 var ref = function (value) {
4490 var refs = inst.refs;
4491
4492 if (refs === emptyRefsObject) {
4493 // This is a lazy pooled frozen object, so we need to initialize.
4494 refs = inst.refs = {};
4495 }
4496
4497 if (value === null) {
4498 delete refs[stringRef];
4499 } else {
4500 refs[stringRef] = value;
4501 }
4502 };
4503
4504 ref._stringRef = stringRef;
4505 return ref;
4506 } else {
4507 (function () {
4508 if (!(typeof mixedRef === 'string')) {
4509 {
4510 throw ReactError(Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null."));
4511 }
4512 }
4513 })();
4514
4515 (function () {
4516 if (!element._owner) {
4517 {
4518 throw ReactError(Error("Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information."));
4519 }
4520 }
4521 })();
4522 }
4523 }
4524
4525 return mixedRef;
4526}
4527
4528function throwOnInvalidObjectType(returnFiber, newChild) {
4529 if (returnFiber.type !== 'textarea') {
4530 var addendum = '';
4531
4532 {
4533 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
4534 }
4535
4536 (function () {
4537 {
4538 {
4539 throw ReactError(Error("Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum));
4540 }
4541 }
4542 })();
4543 }
4544}
4545
4546function warnOnFunctionType() {
4547 var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev();
4548
4549 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
4550 return;
4551 }
4552
4553 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
4554 warning$1(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
4555} // This wrapper function exists because I expect to clone the code in each path
4556// to be able to optimize each path individually by branching early. This needs
4557// a compiler or we can do it manually. Helpers that don't need this branching
4558// live outside of this function.
4559
4560
4561function ChildReconciler(shouldTrackSideEffects) {
4562 function deleteChild(returnFiber, childToDelete) {
4563 if (!shouldTrackSideEffects) {
4564 // Noop.
4565 return;
4566 } // Deletions are added in reversed order so we add it to the front.
4567 // At this point, the return fiber's effect list is empty except for
4568 // deletions, so we can just append the deletion to the list. The remaining
4569 // effects aren't added until the complete phase. Once we implement
4570 // resuming, this may not be true.
4571
4572
4573 var last = returnFiber.lastEffect;
4574
4575 if (last !== null) {
4576 last.nextEffect = childToDelete;
4577 returnFiber.lastEffect = childToDelete;
4578 } else {
4579 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
4580 }
4581
4582 childToDelete.nextEffect = null;
4583 childToDelete.effectTag = Deletion;
4584 }
4585
4586 function deleteRemainingChildren(returnFiber, currentFirstChild) {
4587 if (!shouldTrackSideEffects) {
4588 // Noop.
4589 return null;
4590 } // TODO: For the shouldClone case, this could be micro-optimized a bit by
4591 // assuming that after the first child we've already added everything.
4592
4593
4594 var childToDelete = currentFirstChild;
4595
4596 while (childToDelete !== null) {
4597 deleteChild(returnFiber, childToDelete);
4598 childToDelete = childToDelete.sibling;
4599 }
4600
4601 return null;
4602 }
4603
4604 function mapRemainingChildren(returnFiber, currentFirstChild) {
4605 // Add the remaining children to a temporary map so that we can find them by
4606 // keys quickly. Implicit (null) keys get added to this set with their index
4607 // instead.
4608 var existingChildren = new Map();
4609 var existingChild = currentFirstChild;
4610
4611 while (existingChild !== null) {
4612 if (existingChild.key !== null) {
4613 existingChildren.set(existingChild.key, existingChild);
4614 } else {
4615 existingChildren.set(existingChild.index, existingChild);
4616 }
4617
4618 existingChild = existingChild.sibling;
4619 }
4620
4621 return existingChildren;
4622 }
4623
4624 function useFiber(fiber, pendingProps, expirationTime) {
4625 // We currently set sibling to null and index to 0 here because it is easy
4626 // to forget to do before returning it. E.g. for the single child case.
4627 var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
4628 clone.index = 0;
4629 clone.sibling = null;
4630 return clone;
4631 }
4632
4633 function placeChild(newFiber, lastPlacedIndex, newIndex) {
4634 newFiber.index = newIndex;
4635
4636 if (!shouldTrackSideEffects) {
4637 // Noop.
4638 return lastPlacedIndex;
4639 }
4640
4641 var current$$1 = newFiber.alternate;
4642
4643 if (current$$1 !== null) {
4644 var oldIndex = current$$1.index;
4645
4646 if (oldIndex < lastPlacedIndex) {
4647 // This is a move.
4648 newFiber.effectTag = Placement;
4649 return lastPlacedIndex;
4650 } else {
4651 // This item can stay in place.
4652 return oldIndex;
4653 }
4654 } else {
4655 // This is an insertion.
4656 newFiber.effectTag = Placement;
4657 return lastPlacedIndex;
4658 }
4659 }
4660
4661 function placeSingleChild(newFiber) {
4662 // This is simpler for the single child case. We only need to do a
4663 // placement for inserting new children.
4664 if (shouldTrackSideEffects && newFiber.alternate === null) {
4665 newFiber.effectTag = Placement;
4666 }
4667
4668 return newFiber;
4669 }
4670
4671 function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
4672 if (current$$1 === null || current$$1.tag !== HostText) {
4673 // Insert
4674 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
4675 created.return = returnFiber;
4676 return created;
4677 } else {
4678 // Update
4679 var existing = useFiber(current$$1, textContent, expirationTime);
4680 existing.return = returnFiber;
4681 return existing;
4682 }
4683 }
4684
4685 function updateElement(returnFiber, current$$1, element, expirationTime) {
4686 if (current$$1 !== null && (current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
4687 isCompatibleFamilyForHotReloading(current$$1, element)))) {
4688 // Move based on index
4689 var existing = useFiber(current$$1, element.props, expirationTime);
4690 existing.ref = coerceRef(returnFiber, current$$1, element);
4691 existing.return = returnFiber;
4692
4693 {
4694 existing._debugSource = element._source;
4695 existing._debugOwner = element._owner;
4696 }
4697
4698 return existing;
4699 } else {
4700 // Insert
4701 var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
4702 created.ref = coerceRef(returnFiber, current$$1, element);
4703 created.return = returnFiber;
4704 return created;
4705 }
4706 }
4707
4708 function updatePortal(returnFiber, current$$1, portal, expirationTime) {
4709 if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
4710 // Insert
4711 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
4712 created.return = returnFiber;
4713 return created;
4714 } else {
4715 // Update
4716 var existing = useFiber(current$$1, portal.children || [], expirationTime);
4717 existing.return = returnFiber;
4718 return existing;
4719 }
4720 }
4721
4722 function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
4723 if (current$$1 === null || current$$1.tag !== Fragment) {
4724 // Insert
4725 var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
4726 created.return = returnFiber;
4727 return created;
4728 } else {
4729 // Update
4730 var existing = useFiber(current$$1, fragment, expirationTime);
4731 existing.return = returnFiber;
4732 return existing;
4733 }
4734 }
4735
4736 function createChild(returnFiber, newChild, expirationTime) {
4737 if (typeof newChild === 'string' || typeof newChild === 'number') {
4738 // Text nodes don't have keys. If the previous node is implicitly keyed
4739 // we can continue to replace it without aborting even if it is not a text
4740 // node.
4741 var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
4742 created.return = returnFiber;
4743 return created;
4744 }
4745
4746 if (typeof newChild === 'object' && newChild !== null) {
4747 switch (newChild.$$typeof) {
4748 case REACT_ELEMENT_TYPE:
4749 {
4750 var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
4751
4752 _created.ref = coerceRef(returnFiber, null, newChild);
4753 _created.return = returnFiber;
4754 return _created;
4755 }
4756
4757 case REACT_PORTAL_TYPE:
4758 {
4759 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
4760
4761 _created2.return = returnFiber;
4762 return _created2;
4763 }
4764 }
4765
4766 if (isArray(newChild) || getIteratorFn(newChild)) {
4767 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
4768
4769 _created3.return = returnFiber;
4770 return _created3;
4771 }
4772
4773 throwOnInvalidObjectType(returnFiber, newChild);
4774 }
4775
4776 {
4777 if (typeof newChild === 'function') {
4778 warnOnFunctionType();
4779 }
4780 }
4781
4782 return null;
4783 }
4784
4785 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
4786 // Update the fiber if the keys match, otherwise return null.
4787 var key = oldFiber !== null ? oldFiber.key : null;
4788
4789 if (typeof newChild === 'string' || typeof newChild === 'number') {
4790 // Text nodes don't have keys. If the previous node is implicitly keyed
4791 // we can continue to replace it without aborting even if it is not a text
4792 // node.
4793 if (key !== null) {
4794 return null;
4795 }
4796
4797 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
4798 }
4799
4800 if (typeof newChild === 'object' && newChild !== null) {
4801 switch (newChild.$$typeof) {
4802 case REACT_ELEMENT_TYPE:
4803 {
4804 if (newChild.key === key) {
4805 if (newChild.type === REACT_FRAGMENT_TYPE) {
4806 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
4807 }
4808
4809 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
4810 } else {
4811 return null;
4812 }
4813 }
4814
4815 case REACT_PORTAL_TYPE:
4816 {
4817 if (newChild.key === key) {
4818 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
4819 } else {
4820 return null;
4821 }
4822 }
4823 }
4824
4825 if (isArray(newChild) || getIteratorFn(newChild)) {
4826 if (key !== null) {
4827 return null;
4828 }
4829
4830 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
4831 }
4832
4833 throwOnInvalidObjectType(returnFiber, newChild);
4834 }
4835
4836 {
4837 if (typeof newChild === 'function') {
4838 warnOnFunctionType();
4839 }
4840 }
4841
4842 return null;
4843 }
4844
4845 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
4846 if (typeof newChild === 'string' || typeof newChild === 'number') {
4847 // Text nodes don't have keys, so we neither have to check the old nor
4848 // new node for the key. If both are text nodes, they match.
4849 var matchedFiber = existingChildren.get(newIdx) || null;
4850 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
4851 }
4852
4853 if (typeof newChild === 'object' && newChild !== null) {
4854 switch (newChild.$$typeof) {
4855 case REACT_ELEMENT_TYPE:
4856 {
4857 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
4858
4859 if (newChild.type === REACT_FRAGMENT_TYPE) {
4860 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
4861 }
4862
4863 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
4864 }
4865
4866 case REACT_PORTAL_TYPE:
4867 {
4868 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
4869
4870 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
4871 }
4872 }
4873
4874 if (isArray(newChild) || getIteratorFn(newChild)) {
4875 var _matchedFiber3 = existingChildren.get(newIdx) || null;
4876
4877 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
4878 }
4879
4880 throwOnInvalidObjectType(returnFiber, newChild);
4881 }
4882
4883 {
4884 if (typeof newChild === 'function') {
4885 warnOnFunctionType();
4886 }
4887 }
4888
4889 return null;
4890 }
4891 /**
4892 * Warns if there is a duplicate or missing key
4893 */
4894
4895
4896 function warnOnInvalidKey(child, knownKeys) {
4897 {
4898 if (typeof child !== 'object' || child === null) {
4899 return knownKeys;
4900 }
4901
4902 switch (child.$$typeof) {
4903 case REACT_ELEMENT_TYPE:
4904 case REACT_PORTAL_TYPE:
4905 warnForMissingKey(child);
4906 var key = child.key;
4907
4908 if (typeof key !== 'string') {
4909 break;
4910 }
4911
4912 if (knownKeys === null) {
4913 knownKeys = new Set();
4914 knownKeys.add(key);
4915 break;
4916 }
4917
4918 if (!knownKeys.has(key)) {
4919 knownKeys.add(key);
4920 break;
4921 }
4922
4923 warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);
4924 break;
4925
4926 default:
4927 break;
4928 }
4929 }
4930
4931 return knownKeys;
4932 }
4933
4934 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
4935 // This algorithm can't optimize by searching from both ends since we
4936 // don't have backpointers on fibers. I'm trying to see how far we can get
4937 // with that model. If it ends up not being worth the tradeoffs, we can
4938 // add it later.
4939 // Even with a two ended optimization, we'd want to optimize for the case
4940 // where there are few changes and brute force the comparison instead of
4941 // going for the Map. It'd like to explore hitting that path first in
4942 // forward-only mode and only go for the Map once we notice that we need
4943 // lots of look ahead. This doesn't handle reversal as well as two ended
4944 // search but that's unusual. Besides, for the two ended optimization to
4945 // work on Iterables, we'd need to copy the whole set.
4946 // In this first iteration, we'll just live with hitting the bad case
4947 // (adding everything to a Map) in for every insert/move.
4948 // If you change this code, also update reconcileChildrenIterator() which
4949 // uses the same algorithm.
4950 {
4951 // First, validate keys.
4952 var knownKeys = null;
4953
4954 for (var i = 0; i < newChildren.length; i++) {
4955 var child = newChildren[i];
4956 knownKeys = warnOnInvalidKey(child, knownKeys);
4957 }
4958 }
4959
4960 var resultingFirstChild = null;
4961 var previousNewFiber = null;
4962 var oldFiber = currentFirstChild;
4963 var lastPlacedIndex = 0;
4964 var newIdx = 0;
4965 var nextOldFiber = null;
4966
4967 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
4968 if (oldFiber.index > newIdx) {
4969 nextOldFiber = oldFiber;
4970 oldFiber = null;
4971 } else {
4972 nextOldFiber = oldFiber.sibling;
4973 }
4974
4975 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
4976
4977 if (newFiber === null) {
4978 // TODO: This breaks on empty slots like null children. That's
4979 // unfortunate because it triggers the slow path all the time. We need
4980 // a better way to communicate whether this was a miss or null,
4981 // boolean, undefined, etc.
4982 if (oldFiber === null) {
4983 oldFiber = nextOldFiber;
4984 }
4985
4986 break;
4987 }
4988
4989 if (shouldTrackSideEffects) {
4990 if (oldFiber && newFiber.alternate === null) {
4991 // We matched the slot, but we didn't reuse the existing fiber, so we
4992 // need to delete the existing child.
4993 deleteChild(returnFiber, oldFiber);
4994 }
4995 }
4996
4997 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
4998
4999 if (previousNewFiber === null) {
5000 // TODO: Move out of the loop. This only happens for the first run.
5001 resultingFirstChild = newFiber;
5002 } else {
5003 // TODO: Defer siblings if we're not at the right index for this slot.
5004 // I.e. if we had null values before, then we want to defer this
5005 // for each null value. However, we also don't want to call updateSlot
5006 // with the previous one.
5007 previousNewFiber.sibling = newFiber;
5008 }
5009
5010 previousNewFiber = newFiber;
5011 oldFiber = nextOldFiber;
5012 }
5013
5014 if (newIdx === newChildren.length) {
5015 // We've reached the end of the new children. We can delete the rest.
5016 deleteRemainingChildren(returnFiber, oldFiber);
5017 return resultingFirstChild;
5018 }
5019
5020 if (oldFiber === null) {
5021 // If we don't have any more existing children we can choose a fast path
5022 // since the rest will all be insertions.
5023 for (; newIdx < newChildren.length; newIdx++) {
5024 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
5025
5026 if (_newFiber === null) {
5027 continue;
5028 }
5029
5030 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
5031
5032 if (previousNewFiber === null) {
5033 // TODO: Move out of the loop. This only happens for the first run.
5034 resultingFirstChild = _newFiber;
5035 } else {
5036 previousNewFiber.sibling = _newFiber;
5037 }
5038
5039 previousNewFiber = _newFiber;
5040 }
5041
5042 return resultingFirstChild;
5043 } // Add all children to a key map for quick lookups.
5044
5045
5046 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
5047
5048 for (; newIdx < newChildren.length; newIdx++) {
5049 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
5050
5051 if (_newFiber2 !== null) {
5052 if (shouldTrackSideEffects) {
5053 if (_newFiber2.alternate !== null) {
5054 // The new fiber is a work in progress, but if there exists a
5055 // current, that means that we reused the fiber. We need to delete
5056 // it from the child list so that we don't add it to the deletion
5057 // list.
5058 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
5059 }
5060 }
5061
5062 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
5063
5064 if (previousNewFiber === null) {
5065 resultingFirstChild = _newFiber2;
5066 } else {
5067 previousNewFiber.sibling = _newFiber2;
5068 }
5069
5070 previousNewFiber = _newFiber2;
5071 }
5072 }
5073
5074 if (shouldTrackSideEffects) {
5075 // Any existing children that weren't consumed above were deleted. We need
5076 // to add them to the deletion list.
5077 existingChildren.forEach(function (child) {
5078 return deleteChild(returnFiber, child);
5079 });
5080 }
5081
5082 return resultingFirstChild;
5083 }
5084
5085 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
5086 // This is the same implementation as reconcileChildrenArray(),
5087 // but using the iterator instead.
5088 var iteratorFn = getIteratorFn(newChildrenIterable);
5089
5090 (function () {
5091 if (!(typeof iteratorFn === 'function')) {
5092 {
5093 throw ReactError(Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue."));
5094 }
5095 }
5096 })();
5097
5098 {
5099 // We don't support rendering Generators because it's a mutation.
5100 // See https://github.com/facebook/react/issues/12995
5101 if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
5102 newChildrenIterable[Symbol.toStringTag] === 'Generator') {
5103 !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;
5104 didWarnAboutGenerators = true;
5105 } // Warn about using Maps as children
5106
5107
5108 if (newChildrenIterable.entries === iteratorFn) {
5109 !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
5110 didWarnAboutMaps = true;
5111 } // First, validate keys.
5112 // We'll get a different iterator later for the main pass.
5113
5114
5115 var _newChildren = iteratorFn.call(newChildrenIterable);
5116
5117 if (_newChildren) {
5118 var knownKeys = null;
5119
5120 var _step = _newChildren.next();
5121
5122 for (; !_step.done; _step = _newChildren.next()) {
5123 var child = _step.value;
5124 knownKeys = warnOnInvalidKey(child, knownKeys);
5125 }
5126 }
5127 }
5128
5129 var newChildren = iteratorFn.call(newChildrenIterable);
5130
5131 (function () {
5132 if (!(newChildren != null)) {
5133 {
5134 throw ReactError(Error("An iterable object provided no iterator."));
5135 }
5136 }
5137 })();
5138
5139 var resultingFirstChild = null;
5140 var previousNewFiber = null;
5141 var oldFiber = currentFirstChild;
5142 var lastPlacedIndex = 0;
5143 var newIdx = 0;
5144 var nextOldFiber = null;
5145 var step = newChildren.next();
5146
5147 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
5148 if (oldFiber.index > newIdx) {
5149 nextOldFiber = oldFiber;
5150 oldFiber = null;
5151 } else {
5152 nextOldFiber = oldFiber.sibling;
5153 }
5154
5155 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
5156
5157 if (newFiber === null) {
5158 // TODO: This breaks on empty slots like null children. That's
5159 // unfortunate because it triggers the slow path all the time. We need
5160 // a better way to communicate whether this was a miss or null,
5161 // boolean, undefined, etc.
5162 if (oldFiber === null) {
5163 oldFiber = nextOldFiber;
5164 }
5165
5166 break;
5167 }
5168
5169 if (shouldTrackSideEffects) {
5170 if (oldFiber && newFiber.alternate === null) {
5171 // We matched the slot, but we didn't reuse the existing fiber, so we
5172 // need to delete the existing child.
5173 deleteChild(returnFiber, oldFiber);
5174 }
5175 }
5176
5177 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
5178
5179 if (previousNewFiber === null) {
5180 // TODO: Move out of the loop. This only happens for the first run.
5181 resultingFirstChild = newFiber;
5182 } else {
5183 // TODO: Defer siblings if we're not at the right index for this slot.
5184 // I.e. if we had null values before, then we want to defer this
5185 // for each null value. However, we also don't want to call updateSlot
5186 // with the previous one.
5187 previousNewFiber.sibling = newFiber;
5188 }
5189
5190 previousNewFiber = newFiber;
5191 oldFiber = nextOldFiber;
5192 }
5193
5194 if (step.done) {
5195 // We've reached the end of the new children. We can delete the rest.
5196 deleteRemainingChildren(returnFiber, oldFiber);
5197 return resultingFirstChild;
5198 }
5199
5200 if (oldFiber === null) {
5201 // If we don't have any more existing children we can choose a fast path
5202 // since the rest will all be insertions.
5203 for (; !step.done; newIdx++, step = newChildren.next()) {
5204 var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
5205
5206 if (_newFiber3 === null) {
5207 continue;
5208 }
5209
5210 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
5211
5212 if (previousNewFiber === null) {
5213 // TODO: Move out of the loop. This only happens for the first run.
5214 resultingFirstChild = _newFiber3;
5215 } else {
5216 previousNewFiber.sibling = _newFiber3;
5217 }
5218
5219 previousNewFiber = _newFiber3;
5220 }
5221
5222 return resultingFirstChild;
5223 } // Add all children to a key map for quick lookups.
5224
5225
5226 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
5227
5228 for (; !step.done; newIdx++, step = newChildren.next()) {
5229 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
5230
5231 if (_newFiber4 !== null) {
5232 if (shouldTrackSideEffects) {
5233 if (_newFiber4.alternate !== null) {
5234 // The new fiber is a work in progress, but if there exists a
5235 // current, that means that we reused the fiber. We need to delete
5236 // it from the child list so that we don't add it to the deletion
5237 // list.
5238 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
5239 }
5240 }
5241
5242 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
5243
5244 if (previousNewFiber === null) {
5245 resultingFirstChild = _newFiber4;
5246 } else {
5247 previousNewFiber.sibling = _newFiber4;
5248 }
5249
5250 previousNewFiber = _newFiber4;
5251 }
5252 }
5253
5254 if (shouldTrackSideEffects) {
5255 // Any existing children that weren't consumed above were deleted. We need
5256 // to add them to the deletion list.
5257 existingChildren.forEach(function (child) {
5258 return deleteChild(returnFiber, child);
5259 });
5260 }
5261
5262 return resultingFirstChild;
5263 }
5264
5265 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
5266 // There's no need to check for keys on text nodes since we don't have a
5267 // way to define them.
5268 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
5269 // We already have an existing node so let's just update it and delete
5270 // the rest.
5271 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
5272 var existing = useFiber(currentFirstChild, textContent, expirationTime);
5273 existing.return = returnFiber;
5274 return existing;
5275 } // The existing first child is not a text node so we need to create one
5276 // and delete the existing ones.
5277
5278
5279 deleteRemainingChildren(returnFiber, currentFirstChild);
5280 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
5281 created.return = returnFiber;
5282 return created;
5283 }
5284
5285 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
5286 var key = element.key;
5287 var child = currentFirstChild;
5288
5289 while (child !== null) {
5290 // TODO: If key === null and child.key === null, then this only applies to
5291 // the first item in the list.
5292 if (child.key === key) {
5293 if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
5294 isCompatibleFamilyForHotReloading(child, element))) {
5295 deleteRemainingChildren(returnFiber, child.sibling);
5296 var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
5297 existing.ref = coerceRef(returnFiber, child, element);
5298 existing.return = returnFiber;
5299
5300 {
5301 existing._debugSource = element._source;
5302 existing._debugOwner = element._owner;
5303 }
5304
5305 return existing;
5306 } else {
5307 deleteRemainingChildren(returnFiber, child);
5308 break;
5309 }
5310 } else {
5311 deleteChild(returnFiber, child);
5312 }
5313
5314 child = child.sibling;
5315 }
5316
5317 if (element.type === REACT_FRAGMENT_TYPE) {
5318 var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
5319 created.return = returnFiber;
5320 return created;
5321 } else {
5322 var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
5323
5324 _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
5325 _created4.return = returnFiber;
5326 return _created4;
5327 }
5328 }
5329
5330 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
5331 var key = portal.key;
5332 var child = currentFirstChild;
5333
5334 while (child !== null) {
5335 // TODO: If key === null and child.key === null, then this only applies to
5336 // the first item in the list.
5337 if (child.key === key) {
5338 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
5339 deleteRemainingChildren(returnFiber, child.sibling);
5340 var existing = useFiber(child, portal.children || [], expirationTime);
5341 existing.return = returnFiber;
5342 return existing;
5343 } else {
5344 deleteRemainingChildren(returnFiber, child);
5345 break;
5346 }
5347 } else {
5348 deleteChild(returnFiber, child);
5349 }
5350
5351 child = child.sibling;
5352 }
5353
5354 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
5355 created.return = returnFiber;
5356 return created;
5357 } // This API will tag the children with the side-effect of the reconciliation
5358 // itself. They will be added to the side-effect list as we pass through the
5359 // children and the parent.
5360
5361
5362 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
5363 // This function is not recursive.
5364 // If the top level item is an array, we treat it as a set of children,
5365 // not as a fragment. Nested arrays on the other hand will be treated as
5366 // fragment nodes. Recursion happens at the normal flow.
5367 // Handle top level unkeyed fragments as if they were arrays.
5368 // This leads to an ambiguity between <>{[...]}</> and <>...</>.
5369 // We treat the ambiguous cases above the same.
5370 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
5371
5372 if (isUnkeyedTopLevelFragment) {
5373 newChild = newChild.props.children;
5374 } // Handle object types
5375
5376
5377 var isObject = typeof newChild === 'object' && newChild !== null;
5378
5379 if (isObject) {
5380 switch (newChild.$$typeof) {
5381 case REACT_ELEMENT_TYPE:
5382 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
5383
5384 case REACT_PORTAL_TYPE:
5385 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
5386 }
5387 }
5388
5389 if (typeof newChild === 'string' || typeof newChild === 'number') {
5390 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
5391 }
5392
5393 if (isArray(newChild)) {
5394 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
5395 }
5396
5397 if (getIteratorFn(newChild)) {
5398 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
5399 }
5400
5401 if (isObject) {
5402 throwOnInvalidObjectType(returnFiber, newChild);
5403 }
5404
5405 {
5406 if (typeof newChild === 'function') {
5407 warnOnFunctionType();
5408 }
5409 }
5410
5411 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
5412 // If the new child is undefined, and the return fiber is a composite
5413 // component, throw an error. If Fiber return types are disabled,
5414 // we already threw above.
5415 switch (returnFiber.tag) {
5416 case ClassComponent:
5417 {
5418 {
5419 var instance = returnFiber.stateNode;
5420
5421 if (instance.render._isMockFunction) {
5422 // We allow auto-mocks to proceed as if they're returning null.
5423 break;
5424 }
5425 }
5426 }
5427 // Intentionally fall through to the next case, which handles both
5428 // functions and classes
5429 // eslint-disable-next-lined no-fallthrough
5430
5431 case FunctionComponent:
5432 {
5433 var Component = returnFiber.type;
5434
5435 (function () {
5436 {
5437 {
5438 throw ReactError(Error((Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."));
5439 }
5440 }
5441 })();
5442 }
5443 }
5444 } // Remaining cases are all treated as empty.
5445
5446
5447 return deleteRemainingChildren(returnFiber, currentFirstChild);
5448 }
5449
5450 return reconcileChildFibers;
5451}
5452
5453var reconcileChildFibers = ChildReconciler(true);
5454var mountChildFibers = ChildReconciler(false);
5455function cloneChildFibers(current$$1, workInProgress) {
5456 (function () {
5457 if (!(current$$1 === null || workInProgress.child === current$$1.child)) {
5458 {
5459 throw ReactError(Error("Resuming work not yet implemented."));
5460 }
5461 }
5462 })();
5463
5464 if (workInProgress.child === null) {
5465 return;
5466 }
5467
5468 var currentChild = workInProgress.child;
5469 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5470 workInProgress.child = newChild;
5471 newChild.return = workInProgress;
5472
5473 while (currentChild.sibling !== null) {
5474 currentChild = currentChild.sibling;
5475 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5476 newChild.return = workInProgress;
5477 }
5478
5479 newChild.sibling = null;
5480} // Reset a workInProgress child set to prepare it for a second pass.
5481
5482function resetChildFibers(workInProgress, renderExpirationTime) {
5483 var child = workInProgress.child;
5484
5485 while (child !== null) {
5486 resetWorkInProgress(child, renderExpirationTime);
5487 child = child.sibling;
5488 }
5489}
5490
5491var NO_CONTEXT = {};
5492var contextStackCursor$1 = createCursor(NO_CONTEXT);
5493var contextFiberStackCursor = createCursor(NO_CONTEXT);
5494var rootInstanceStackCursor = createCursor(NO_CONTEXT);
5495
5496function requiredContext(c) {
5497 (function () {
5498 if (!(c !== NO_CONTEXT)) {
5499 {
5500 throw ReactError(Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."));
5501 }
5502 }
5503 })();
5504
5505 return c;
5506}
5507
5508function getRootHostContainer() {
5509 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5510 return rootInstance;
5511}
5512
5513function pushHostContainer(fiber, nextRootInstance) {
5514 // Push current root instance onto the stack;
5515 // This allows us to reset root when portals are popped.
5516 push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it.
5517 // This enables us to pop only Fibers that provide unique contexts.
5518
5519 push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack.
5520 // However, we can't just call getRootHostContext() and push it because
5521 // we'd have a different number of entries on the stack depending on
5522 // whether getRootHostContext() throws somewhere in renderer code or not.
5523 // So we push an empty value first. This lets us safely unwind on errors.
5524
5525 push(contextStackCursor$1, NO_CONTEXT, fiber);
5526 var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it.
5527
5528 pop(contextStackCursor$1, fiber);
5529 push(contextStackCursor$1, nextRootContext, fiber);
5530}
5531
5532function popHostContainer(fiber) {
5533 pop(contextStackCursor$1, fiber);
5534 pop(contextFiberStackCursor, fiber);
5535 pop(rootInstanceStackCursor, fiber);
5536}
5537
5538function getHostContext() {
5539 var context = requiredContext(contextStackCursor$1.current);
5540 return context;
5541}
5542
5543function pushHostContext(fiber) {
5544 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5545 var context = requiredContext(contextStackCursor$1.current);
5546 var nextContext = getChildHostContext(context, fiber.type, rootInstance); // Don't push this Fiber's context unless it's unique.
5547
5548 if (context === nextContext) {
5549 return;
5550 } // Track the context and the Fiber that provided it.
5551 // This enables us to pop only Fibers that provide unique contexts.
5552
5553
5554 push(contextFiberStackCursor, fiber, fiber);
5555 push(contextStackCursor$1, nextContext, fiber);
5556}
5557
5558function popHostContext(fiber) {
5559 // Do not pop unless this Fiber provided the current context.
5560 // pushHostContext() only pushes Fibers that provide unique contexts.
5561 if (contextFiberStackCursor.current !== fiber) {
5562 return;
5563 }
5564
5565 pop(contextStackCursor$1, fiber);
5566 pop(contextFiberStackCursor, fiber);
5567}
5568
5569var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is
5570// inherited deeply down the subtree. The upper bits only affect
5571// this immediate suspense boundary and gets reset each new
5572// boundary or suspense list.
5573
5574var SubtreeSuspenseContextMask = 1; // Subtree Flags:
5575// InvisibleParentSuspenseContext indicates that one of our parent Suspense
5576// boundaries is not currently showing visible main content.
5577// Either because it is already showing a fallback or is not mounted at all.
5578// We can use this to determine if it is desirable to trigger a fallback at
5579// the parent. If not, then we might need to trigger undesirable boundaries
5580// and/or suspend the commit to avoid hiding the parent content.
5581
5582var InvisibleParentSuspenseContext = 1; // Shallow Flags:
5583// ForceSuspenseFallback can be used by SuspenseList to force newly added
5584// items into their fallback state during one of the render passes.
5585
5586var ForceSuspenseFallback = 2;
5587var suspenseStackCursor = createCursor(DefaultSuspenseContext);
5588function hasSuspenseContext(parentContext, flag) {
5589 return (parentContext & flag) !== 0;
5590}
5591function setDefaultShallowSuspenseContext(parentContext) {
5592 return parentContext & SubtreeSuspenseContextMask;
5593}
5594function setShallowSuspenseContext(parentContext, shallowContext) {
5595 return parentContext & SubtreeSuspenseContextMask | shallowContext;
5596}
5597function addSubtreeSuspenseContext(parentContext, subtreeContext) {
5598 return parentContext | subtreeContext;
5599}
5600function pushSuspenseContext(fiber, newContext) {
5601 push(suspenseStackCursor, newContext, fiber);
5602}
5603function popSuspenseContext(fiber) {
5604 pop(suspenseStackCursor, fiber);
5605}
5606
5607function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
5608 // If it was the primary children that just suspended, capture and render the
5609 // fallback. Otherwise, don't capture and bubble to the next boundary.
5610 var nextState = workInProgress.memoizedState;
5611
5612 if (nextState !== null) {
5613 if (nextState.dehydrated !== null) {
5614 // A dehydrated boundary always captures.
5615 return true;
5616 }
5617
5618 return false;
5619 }
5620
5621 var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
5622
5623 if (props.fallback === undefined) {
5624 return false;
5625 } // Regular boundaries always capture.
5626
5627
5628 if (props.unstable_avoidThisFallback !== true) {
5629 return true;
5630 } // If it's a boundary we should avoid, then we prefer to bubble up to the
5631 // parent boundary if it is currently invisible.
5632
5633
5634 if (hasInvisibleParent) {
5635 return false;
5636 } // If the parent is not able to handle it, we must handle it.
5637
5638
5639 return true;
5640}
5641function findFirstSuspended(row) {
5642 var node = row;
5643
5644 while (node !== null) {
5645 if (node.tag === SuspenseComponent) {
5646 var state = node.memoizedState;
5647
5648 if (state !== null) {
5649 var dehydrated = state.dehydrated;
5650
5651 if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
5652 return node;
5653 }
5654 }
5655 } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't
5656 // keep track of whether it suspended or not.
5657 node.memoizedProps.revealOrder !== undefined) {
5658 var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
5659
5660 if (didSuspend) {
5661 return node;
5662 }
5663 } else if (node.child !== null) {
5664 node.child.return = node;
5665 node = node.child;
5666 continue;
5667 }
5668
5669 if (node === row) {
5670 return null;
5671 }
5672
5673 while (node.sibling === null) {
5674 if (node.return === null || node.return === row) {
5675 return null;
5676 }
5677
5678 node = node.return;
5679 }
5680
5681 node.sibling.return = node.return;
5682 node = node.sibling;
5683 }
5684
5685 return null;
5686}
5687
5688var emptyObject = {};
5689var isArray$2 = Array.isArray;
5690function createResponderInstance(responder, responderProps, responderState, fiber) {
5691 return {
5692 fiber: fiber,
5693 props: responderProps,
5694 responder: responder,
5695 rootEventTypes: null,
5696 state: responderState
5697 };
5698}
5699
5700function mountEventResponder(responder, responderProps, fiber, respondersMap, rootContainerInstance) {
5701 var responderState = emptyObject;
5702 var getInitialState = responder.getInitialState;
5703
5704 if (getInitialState !== null) {
5705 responderState = getInitialState(responderProps);
5706 }
5707
5708 var responderInstance = createResponderInstance(responder, responderProps, responderState, fiber);
5709
5710 if (!rootContainerInstance) {
5711 var node = fiber;
5712
5713 while (node !== null) {
5714 var tag = node.tag;
5715
5716 if (tag === HostComponent) {
5717 rootContainerInstance = node.stateNode;
5718 break;
5719 } else if (tag === HostRoot) {
5720 rootContainerInstance = node.stateNode.containerInfo;
5721 break;
5722 }
5723
5724 node = node.return;
5725 }
5726 }
5727
5728 mountResponderInstance(responder, responderInstance, responderProps, responderState, rootContainerInstance);
5729 respondersMap.set(responder, responderInstance);
5730}
5731
5732function updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance) {
5733 var responder;
5734 var props;
5735
5736 if (listener) {
5737 responder = listener.responder;
5738 props = listener.props;
5739 }
5740
5741 (function () {
5742 if (!(responder && responder.$$typeof === REACT_RESPONDER_TYPE)) {
5743 {
5744 throw ReactError(Error("An invalid value was used as an event listener. Expect one or many event listeners created via React.unstable_useResponder()."));
5745 }
5746 }
5747 })();
5748
5749 var listenerProps = props;
5750
5751 if (visistedResponders.has(responder)) {
5752 // show warning
5753 {
5754 warning$1(false, 'Duplicate event responder "%s" found in event listeners. ' + 'Event listeners passed to elements cannot use the same event responder more than once.', responder.displayName);
5755 }
5756
5757 return;
5758 }
5759
5760 visistedResponders.add(responder);
5761 var responderInstance = respondersMap.get(responder);
5762
5763 if (responderInstance === undefined) {
5764 // Mount (happens in either complete or commit phase)
5765 mountEventResponder(responder, listenerProps, fiber, respondersMap, rootContainerInstance);
5766 } else {
5767 // Update (happens during commit phase only)
5768 responderInstance.props = listenerProps;
5769 responderInstance.fiber = fiber;
5770 }
5771}
5772
5773function updateEventListeners(listeners, fiber, rootContainerInstance) {
5774 var visistedResponders = new Set();
5775 var dependencies = fiber.dependencies;
5776
5777 if (listeners != null) {
5778 if (dependencies === null) {
5779 dependencies = fiber.dependencies = {
5780 expirationTime: NoWork,
5781 firstContext: null,
5782 responders: new Map()
5783 };
5784 }
5785
5786 var respondersMap = dependencies.responders;
5787
5788 if (respondersMap === null) {
5789 respondersMap = new Map();
5790 }
5791
5792 if (isArray$2(listeners)) {
5793 for (var i = 0, length = listeners.length; i < length; i++) {
5794 var listener = listeners[i];
5795 updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance);
5796 }
5797 } else {
5798 updateEventListener(listeners, fiber, visistedResponders, respondersMap, rootContainerInstance);
5799 }
5800 }
5801
5802 if (dependencies !== null) {
5803 var _respondersMap = dependencies.responders;
5804
5805 if (_respondersMap !== null) {
5806 // Unmount
5807 var mountedResponders = Array.from(_respondersMap.keys());
5808
5809 for (var _i = 0, _length = mountedResponders.length; _i < _length; _i++) {
5810 var mountedResponder = mountedResponders[_i];
5811
5812 if (!visistedResponders.has(mountedResponder)) {
5813 var responderInstance = _respondersMap.get(mountedResponder);
5814
5815 unmountResponderInstance(responderInstance);
5816
5817 _respondersMap.delete(mountedResponder);
5818 }
5819 }
5820 }
5821 }
5822}
5823function createResponderListener(responder, props) {
5824 var eventResponderListener = {
5825 responder: responder,
5826 props: props
5827 };
5828
5829 {
5830 Object.freeze(eventResponderListener);
5831 }
5832
5833 return eventResponderListener;
5834}
5835
5836var NoEffect$1 =
5837/* */
58380;
5839var UnmountSnapshot =
5840/* */
58412;
5842var UnmountMutation =
5843/* */
58444;
5845var MountMutation =
5846/* */
58478;
5848var UnmountLayout =
5849/* */
585016;
5851var MountLayout =
5852/* */
585332;
5854var MountPassive =
5855/* */
585664;
5857var UnmountPassive =
5858/* */
5859128;
5860
5861var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
5862var didWarnAboutMismatchedHooksForComponent;
5863
5864{
5865 didWarnAboutMismatchedHooksForComponent = new Set();
5866}
5867
5868// These are set right before calling the component.
5869var renderExpirationTime$1 = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from
5870// the work-in-progress hook.
5871
5872var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
5873// current hook list is the list that belongs to the current fiber. The
5874// work-in-progress hook list is a new list that will be added to the
5875// work-in-progress fiber.
5876
5877var currentHook = null;
5878var nextCurrentHook = null;
5879var firstWorkInProgressHook = null;
5880var workInProgressHook = null;
5881var nextWorkInProgressHook = null;
5882var remainingExpirationTime = NoWork;
5883var componentUpdateQueue = null;
5884var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the
5885// end of the current pass. We can't store these updates on the normal queue,
5886// because if the work is aborted, they should be discarded. Because this is
5887// a relatively rare case, we also don't want to add an additional field to
5888// either the hook or queue object types. So we store them in a lazily create
5889// map of queue -> render-phase updates, which are discarded once the component
5890// completes without re-rendering.
5891// Whether an update was scheduled during the currently executing render pass.
5892
5893var didScheduleRenderPhaseUpdate = false; // Lazily created map of render-phase updates
5894
5895var renderPhaseUpdates = null; // Counter to prevent infinite loops.
5896
5897var numberOfReRenders = 0;
5898var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
5899
5900var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
5901// The list stores the order of hooks used during the initial render (mount).
5902// Subsequent renders (updates) reference this list.
5903
5904var hookTypesDev = null;
5905var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore
5906// the dependencies for Hooks that need them (e.g. useEffect or useMemo).
5907// When true, such Hooks will always be "remounted". Only used during hot reload.
5908
5909var ignorePreviousDependencies = false;
5910
5911function mountHookTypesDev() {
5912 {
5913 var hookName = currentHookNameInDev;
5914
5915 if (hookTypesDev === null) {
5916 hookTypesDev = [hookName];
5917 } else {
5918 hookTypesDev.push(hookName);
5919 }
5920 }
5921}
5922
5923function updateHookTypesDev() {
5924 {
5925 var hookName = currentHookNameInDev;
5926
5927 if (hookTypesDev !== null) {
5928 hookTypesUpdateIndexDev++;
5929
5930 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
5931 warnOnHookMismatchInDev(hookName);
5932 }
5933 }
5934 }
5935}
5936
5937function checkDepsAreArrayDev(deps) {
5938 {
5939 if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
5940 // Verify deps, but only on mount to avoid extra checks.
5941 // It's unlikely their type would change as usually you define them inline.
5942 warning$1(false, '%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps);
5943 }
5944 }
5945}
5946
5947function warnOnHookMismatchInDev(currentHookName) {
5948 {
5949 var componentName = getComponentName(currentlyRenderingFiber$1.type);
5950
5951 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
5952 didWarnAboutMismatchedHooksForComponent.add(componentName);
5953
5954 if (hookTypesDev !== null) {
5955 var table = '';
5956 var secondColumnStart = 30;
5957
5958 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
5959 var oldHookName = hookTypesDev[i];
5960 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
5961 var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up
5962 // lol @ IE not supporting String#repeat
5963
5964 while (row.length < secondColumnStart) {
5965 row += ' ';
5966 }
5967
5968 row += newHookName + '\n';
5969 table += row;
5970 }
5971
5972 warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
5973 }
5974 }
5975 }
5976}
5977
5978function throwInvalidHookError() {
5979 (function () {
5980 {
5981 {
5982 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."));
5983 }
5984 }
5985 })();
5986}
5987
5988function areHookInputsEqual(nextDeps, prevDeps) {
5989 {
5990 if (ignorePreviousDependencies) {
5991 // Only true when this component is being hot reloaded.
5992 return false;
5993 }
5994 }
5995
5996 if (prevDeps === null) {
5997 {
5998 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);
5999 }
6000
6001 return false;
6002 }
6003
6004 {
6005 // Don't bother comparing lengths in prod because these arrays should be
6006 // passed inline.
6007 if (nextDeps.length !== prevDeps.length) {
6008 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, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]");
6009 }
6010 }
6011
6012 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
6013 if (is$1(nextDeps[i], prevDeps[i])) {
6014 continue;
6015 }
6016
6017 return false;
6018 }
6019
6020 return true;
6021}
6022
6023function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
6024 renderExpirationTime$1 = nextRenderExpirationTime;
6025 currentlyRenderingFiber$1 = workInProgress;
6026 nextCurrentHook = current !== null ? current.memoizedState : null;
6027
6028 {
6029 hookTypesDev = current !== null ? current._debugHookTypes : null;
6030 hookTypesUpdateIndexDev = -1; // Used for hot reloading:
6031
6032 ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
6033 } // The following should have already been reset
6034 // currentHook = null;
6035 // workInProgressHook = null;
6036 // remainingExpirationTime = NoWork;
6037 // componentUpdateQueue = null;
6038 // didScheduleRenderPhaseUpdate = false;
6039 // renderPhaseUpdates = null;
6040 // numberOfReRenders = 0;
6041 // sideEffectTag = 0;
6042 // TODO Warn if no hooks are used at all during mount, then some are used during update.
6043 // Currently we will identify the update render as a mount because nextCurrentHook === null.
6044 // This is tricky because it's valid for certain types of components (e.g. React.lazy)
6045 // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
6046 // Non-stateful hooks (e.g. context) don't get added to memoizedState,
6047 // so nextCurrentHook would be null during updates and mounts.
6048
6049
6050 {
6051 if (nextCurrentHook !== null) {
6052 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
6053 } else if (hookTypesDev !== null) {
6054 // This dispatcher handles an edge case where a component is updating,
6055 // but no stateful hooks have been used.
6056 // We want to match the production code behavior (which will use HooksDispatcherOnMount),
6057 // but with the extra DEV validation to ensure hooks ordering hasn't changed.
6058 // This dispatcher does that.
6059 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
6060 } else {
6061 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
6062 }
6063 }
6064
6065 var children = Component(props, refOrContext);
6066
6067 if (didScheduleRenderPhaseUpdate) {
6068 do {
6069 didScheduleRenderPhaseUpdate = false;
6070 numberOfReRenders += 1;
6071
6072 {
6073 // Even when hot reloading, allow dependencies to stabilize
6074 // after first render to prevent infinite render phase updates.
6075 ignorePreviousDependencies = false;
6076 } // Start over from the beginning of the list
6077
6078
6079 nextCurrentHook = current !== null ? current.memoizedState : null;
6080 nextWorkInProgressHook = firstWorkInProgressHook;
6081 currentHook = null;
6082 workInProgressHook = null;
6083 componentUpdateQueue = null;
6084
6085 {
6086 // Also validate hook order for cascading updates.
6087 hookTypesUpdateIndexDev = -1;
6088 }
6089
6090 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
6091 children = Component(props, refOrContext);
6092 } while (didScheduleRenderPhaseUpdate);
6093
6094 renderPhaseUpdates = null;
6095 numberOfReRenders = 0;
6096 } // We can assume the previous dispatcher is always this one, since we set it
6097 // at the beginning of the render phase and there's no re-entrancy.
6098
6099
6100 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
6101 var renderedWork = currentlyRenderingFiber$1;
6102 renderedWork.memoizedState = firstWorkInProgressHook;
6103 renderedWork.expirationTime = remainingExpirationTime;
6104 renderedWork.updateQueue = componentUpdateQueue;
6105 renderedWork.effectTag |= sideEffectTag;
6106
6107 {
6108 renderedWork._debugHookTypes = hookTypesDev;
6109 } // This check uses currentHook so that it works the same in DEV and prod bundles.
6110 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
6111
6112
6113 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
6114 renderExpirationTime$1 = NoWork;
6115 currentlyRenderingFiber$1 = null;
6116 currentHook = null;
6117 nextCurrentHook = null;
6118 firstWorkInProgressHook = null;
6119 workInProgressHook = null;
6120 nextWorkInProgressHook = null;
6121
6122 {
6123 currentHookNameInDev = null;
6124 hookTypesDev = null;
6125 hookTypesUpdateIndexDev = -1;
6126 }
6127
6128 remainingExpirationTime = NoWork;
6129 componentUpdateQueue = null;
6130 sideEffectTag = 0; // These were reset above
6131 // didScheduleRenderPhaseUpdate = false;
6132 // renderPhaseUpdates = null;
6133 // numberOfReRenders = 0;
6134
6135 (function () {
6136 if (!!didRenderTooFewHooks) {
6137 {
6138 throw ReactError(Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement."));
6139 }
6140 }
6141 })();
6142
6143 return children;
6144}
6145function bailoutHooks(current, workInProgress, expirationTime) {
6146 workInProgress.updateQueue = current.updateQueue;
6147 workInProgress.effectTag &= ~(Passive | Update);
6148
6149 if (current.expirationTime <= expirationTime) {
6150 current.expirationTime = NoWork;
6151 }
6152}
6153function resetHooks() {
6154 // We can assume the previous dispatcher is always this one, since we set it
6155 // at the beginning of the render phase and there's no re-entrancy.
6156 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; // This is used to reset the state of this module when a component throws.
6157 // It's also called inside mountIndeterminateComponent if we determine the
6158 // component is a module-style component.
6159
6160 renderExpirationTime$1 = NoWork;
6161 currentlyRenderingFiber$1 = null;
6162 currentHook = null;
6163 nextCurrentHook = null;
6164 firstWorkInProgressHook = null;
6165 workInProgressHook = null;
6166 nextWorkInProgressHook = null;
6167
6168 {
6169 hookTypesDev = null;
6170 hookTypesUpdateIndexDev = -1;
6171 currentHookNameInDev = null;
6172 }
6173
6174 remainingExpirationTime = NoWork;
6175 componentUpdateQueue = null;
6176 sideEffectTag = 0;
6177 didScheduleRenderPhaseUpdate = false;
6178 renderPhaseUpdates = null;
6179 numberOfReRenders = 0;
6180}
6181
6182function mountWorkInProgressHook() {
6183 var hook = {
6184 memoizedState: null,
6185 baseState: null,
6186 queue: null,
6187 baseUpdate: null,
6188 next: null
6189 };
6190
6191 if (workInProgressHook === null) {
6192 // This is the first hook in the list
6193 firstWorkInProgressHook = workInProgressHook = hook;
6194 } else {
6195 // Append to the end of the list
6196 workInProgressHook = workInProgressHook.next = hook;
6197 }
6198
6199 return workInProgressHook;
6200}
6201
6202function updateWorkInProgressHook() {
6203 // This function is used both for updates and for re-renders triggered by a
6204 // render phase update. It assumes there is either a current hook we can
6205 // clone, or a work-in-progress hook from a previous render pass that we can
6206 // use as a base. When we reach the end of the base list, we must switch to
6207 // the dispatcher used for mounts.
6208 if (nextWorkInProgressHook !== null) {
6209 // There's already a work-in-progress. Reuse it.
6210 workInProgressHook = nextWorkInProgressHook;
6211 nextWorkInProgressHook = workInProgressHook.next;
6212 currentHook = nextCurrentHook;
6213 nextCurrentHook = currentHook !== null ? currentHook.next : null;
6214 } else {
6215 // Clone from the current hook.
6216 (function () {
6217 if (!(nextCurrentHook !== null)) {
6218 {
6219 throw ReactError(Error("Rendered more hooks than during the previous render."));
6220 }
6221 }
6222 })();
6223
6224 currentHook = nextCurrentHook;
6225 var newHook = {
6226 memoizedState: currentHook.memoizedState,
6227 baseState: currentHook.baseState,
6228 queue: currentHook.queue,
6229 baseUpdate: currentHook.baseUpdate,
6230 next: null
6231 };
6232
6233 if (workInProgressHook === null) {
6234 // This is the first hook in the list.
6235 workInProgressHook = firstWorkInProgressHook = newHook;
6236 } else {
6237 // Append to the end of the list.
6238 workInProgressHook = workInProgressHook.next = newHook;
6239 }
6240
6241 nextCurrentHook = currentHook.next;
6242 }
6243
6244 return workInProgressHook;
6245}
6246
6247function createFunctionComponentUpdateQueue() {
6248 return {
6249 lastEffect: null
6250 };
6251}
6252
6253function basicStateReducer(state, action) {
6254 return typeof action === 'function' ? action(state) : action;
6255}
6256
6257function mountReducer(reducer, initialArg, init) {
6258 var hook = mountWorkInProgressHook();
6259 var initialState;
6260
6261 if (init !== undefined) {
6262 initialState = init(initialArg);
6263 } else {
6264 initialState = initialArg;
6265 }
6266
6267 hook.memoizedState = hook.baseState = initialState;
6268 var queue = hook.queue = {
6269 last: null,
6270 dispatch: null,
6271 lastRenderedReducer: reducer,
6272 lastRenderedState: initialState
6273 };
6274 var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
6275 currentlyRenderingFiber$1, queue);
6276 return [hook.memoizedState, dispatch];
6277}
6278
6279function updateReducer(reducer, initialArg, init) {
6280 var hook = updateWorkInProgressHook();
6281 var queue = hook.queue;
6282
6283 (function () {
6284 if (!(queue !== null)) {
6285 {
6286 throw ReactError(Error("Should have a queue. This is likely a bug in React. Please file an issue."));
6287 }
6288 }
6289 })();
6290
6291 queue.lastRenderedReducer = reducer;
6292
6293 if (numberOfReRenders > 0) {
6294 // This is a re-render. Apply the new render phase updates to the previous
6295 // work-in-progress hook.
6296 var _dispatch = queue.dispatch;
6297
6298 if (renderPhaseUpdates !== null) {
6299 // Render phase updates are stored in a map of queue -> linked list
6300 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
6301
6302 if (firstRenderPhaseUpdate !== undefined) {
6303 renderPhaseUpdates.delete(queue);
6304 var newState = hook.memoizedState;
6305 var update = firstRenderPhaseUpdate;
6306
6307 do {
6308 // Process this render phase update. We don't have to check the
6309 // priority because it will always be the same as the current
6310 // render's.
6311 var action = update.action;
6312 newState = reducer(newState, action);
6313 update = update.next;
6314 } while (update !== null); // Mark that the fiber performed work, but only if the new state is
6315 // different from the current state.
6316
6317
6318 if (!is$1(newState, hook.memoizedState)) {
6319 markWorkInProgressReceivedUpdate();
6320 }
6321
6322 hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
6323 // the base state unless the queue is empty.
6324 // TODO: Not sure if this is the desired semantics, but it's what we
6325 // do for gDSFP. I can't remember why.
6326
6327 if (hook.baseUpdate === queue.last) {
6328 hook.baseState = newState;
6329 }
6330
6331 queue.lastRenderedState = newState;
6332 return [newState, _dispatch];
6333 }
6334 }
6335
6336 return [hook.memoizedState, _dispatch];
6337 } // The last update in the entire queue
6338
6339
6340 var last = queue.last; // The last update that is part of the base state.
6341
6342 var baseUpdate = hook.baseUpdate;
6343 var baseState = hook.baseState; // Find the first unprocessed update.
6344
6345 var first;
6346
6347 if (baseUpdate !== null) {
6348 if (last !== null) {
6349 // For the first update, the queue is a circular linked list where
6350 // `queue.last.next = queue.first`. Once the first update commits, and
6351 // the `baseUpdate` is no longer empty, we can unravel the list.
6352 last.next = null;
6353 }
6354
6355 first = baseUpdate.next;
6356 } else {
6357 first = last !== null ? last.next : null;
6358 }
6359
6360 if (first !== null) {
6361 var _newState = baseState;
6362 var newBaseState = null;
6363 var newBaseUpdate = null;
6364 var prevUpdate = baseUpdate;
6365 var _update = first;
6366 var didSkip = false;
6367
6368 do {
6369 var updateExpirationTime = _update.expirationTime;
6370
6371 if (updateExpirationTime < renderExpirationTime$1) {
6372 // Priority is insufficient. Skip this update. If this is the first
6373 // skipped update, the previous update/state is the new base
6374 // update/state.
6375 if (!didSkip) {
6376 didSkip = true;
6377 newBaseUpdate = prevUpdate;
6378 newBaseState = _newState;
6379 } // Update the remaining priority in the queue.
6380
6381
6382 if (updateExpirationTime > remainingExpirationTime) {
6383 remainingExpirationTime = updateExpirationTime;
6384 markUnprocessedUpdateTime(remainingExpirationTime);
6385 }
6386 } else {
6387 // This update does have sufficient priority.
6388 // Mark the event time of this update as relevant to this render pass.
6389 // TODO: This should ideally use the true event time of this update rather than
6390 // its priority which is a derived and not reverseable value.
6391 // TODO: We should skip this update if it was already committed but currently
6392 // we have no way of detecting the difference between a committed and suspended
6393 // update here.
6394 markRenderEventTimeAndConfig(updateExpirationTime, _update.suspenseConfig); // Process this update.
6395
6396 if (_update.eagerReducer === reducer) {
6397 // If this update was processed eagerly, and its reducer matches the
6398 // current reducer, we can use the eagerly computed state.
6399 _newState = _update.eagerState;
6400 } else {
6401 var _action = _update.action;
6402 _newState = reducer(_newState, _action);
6403 }
6404 }
6405
6406 prevUpdate = _update;
6407 _update = _update.next;
6408 } while (_update !== null && _update !== first);
6409
6410 if (!didSkip) {
6411 newBaseUpdate = prevUpdate;
6412 newBaseState = _newState;
6413 } // Mark that the fiber performed work, but only if the new state is
6414 // different from the current state.
6415
6416
6417 if (!is$1(_newState, hook.memoizedState)) {
6418 markWorkInProgressReceivedUpdate();
6419 }
6420
6421 hook.memoizedState = _newState;
6422 hook.baseUpdate = newBaseUpdate;
6423 hook.baseState = newBaseState;
6424 queue.lastRenderedState = _newState;
6425 }
6426
6427 var dispatch = queue.dispatch;
6428 return [hook.memoizedState, dispatch];
6429}
6430
6431function mountState(initialState) {
6432 var hook = mountWorkInProgressHook();
6433
6434 if (typeof initialState === 'function') {
6435 initialState = initialState();
6436 }
6437
6438 hook.memoizedState = hook.baseState = initialState;
6439 var queue = hook.queue = {
6440 last: null,
6441 dispatch: null,
6442 lastRenderedReducer: basicStateReducer,
6443 lastRenderedState: initialState
6444 };
6445 var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
6446 currentlyRenderingFiber$1, queue);
6447 return [hook.memoizedState, dispatch];
6448}
6449
6450function updateState(initialState) {
6451 return updateReducer(basicStateReducer, initialState);
6452}
6453
6454function pushEffect(tag, create, destroy, deps) {
6455 var effect = {
6456 tag: tag,
6457 create: create,
6458 destroy: destroy,
6459 deps: deps,
6460 // Circular
6461 next: null
6462 };
6463
6464 if (componentUpdateQueue === null) {
6465 componentUpdateQueue = createFunctionComponentUpdateQueue();
6466 componentUpdateQueue.lastEffect = effect.next = effect;
6467 } else {
6468 var lastEffect = componentUpdateQueue.lastEffect;
6469
6470 if (lastEffect === null) {
6471 componentUpdateQueue.lastEffect = effect.next = effect;
6472 } else {
6473 var firstEffect = lastEffect.next;
6474 lastEffect.next = effect;
6475 effect.next = firstEffect;
6476 componentUpdateQueue.lastEffect = effect;
6477 }
6478 }
6479
6480 return effect;
6481}
6482
6483function mountRef(initialValue) {
6484 var hook = mountWorkInProgressHook();
6485 var ref = {
6486 current: initialValue
6487 };
6488
6489 {
6490 Object.seal(ref);
6491 }
6492
6493 hook.memoizedState = ref;
6494 return ref;
6495}
6496
6497function updateRef(initialValue) {
6498 var hook = updateWorkInProgressHook();
6499 return hook.memoizedState;
6500}
6501
6502function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6503 var hook = mountWorkInProgressHook();
6504 var nextDeps = deps === undefined ? null : deps;
6505 sideEffectTag |= fiberEffectTag;
6506 hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
6507}
6508
6509function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6510 var hook = updateWorkInProgressHook();
6511 var nextDeps = deps === undefined ? null : deps;
6512 var destroy = undefined;
6513
6514 if (currentHook !== null) {
6515 var prevEffect = currentHook.memoizedState;
6516 destroy = prevEffect.destroy;
6517
6518 if (nextDeps !== null) {
6519 var prevDeps = prevEffect.deps;
6520
6521 if (areHookInputsEqual(nextDeps, prevDeps)) {
6522 pushEffect(NoEffect$1, create, destroy, nextDeps);
6523 return;
6524 }
6525 }
6526 }
6527
6528 sideEffectTag |= fiberEffectTag;
6529 hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
6530}
6531
6532function mountEffect(create, deps) {
6533 {
6534 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6535 if ('undefined' !== typeof jest) {
6536 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
6537 }
6538 }
6539
6540 return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6541}
6542
6543function updateEffect(create, deps) {
6544 {
6545 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6546 if ('undefined' !== typeof jest) {
6547 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
6548 }
6549 }
6550
6551 return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6552}
6553
6554function mountLayoutEffect(create, deps) {
6555 return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6556}
6557
6558function updateLayoutEffect(create, deps) {
6559 return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6560}
6561
6562function imperativeHandleEffect(create, ref) {
6563 if (typeof ref === 'function') {
6564 var refCallback = ref;
6565
6566 var _inst = create();
6567
6568 refCallback(_inst);
6569 return function () {
6570 refCallback(null);
6571 };
6572 } else if (ref !== null && ref !== undefined) {
6573 var refObject = ref;
6574
6575 {
6576 !refObject.hasOwnProperty('current') ? warning$1(false, 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}') : void 0;
6577 }
6578
6579 var _inst2 = create();
6580
6581 refObject.current = _inst2;
6582 return function () {
6583 refObject.current = null;
6584 };
6585 }
6586}
6587
6588function mountImperativeHandle(ref, create, deps) {
6589 {
6590 !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
6591 } // TODO: If deps are provided, should we skip comparing the ref itself?
6592
6593
6594 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6595 return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6596}
6597
6598function updateImperativeHandle(ref, create, deps) {
6599 {
6600 !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
6601 } // TODO: If deps are provided, should we skip comparing the ref itself?
6602
6603
6604 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6605 return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6606}
6607
6608function mountDebugValue(value, formatterFn) {// This hook is normally a no-op.
6609 // The react-debug-hooks package injects its own implementation
6610 // so that e.g. DevTools can display custom hook values.
6611}
6612
6613var updateDebugValue = mountDebugValue;
6614
6615function mountCallback(callback, deps) {
6616 var hook = mountWorkInProgressHook();
6617 var nextDeps = deps === undefined ? null : deps;
6618 hook.memoizedState = [callback, nextDeps];
6619 return callback;
6620}
6621
6622function updateCallback(callback, deps) {
6623 var hook = updateWorkInProgressHook();
6624 var nextDeps = deps === undefined ? null : deps;
6625 var prevState = hook.memoizedState;
6626
6627 if (prevState !== null) {
6628 if (nextDeps !== null) {
6629 var prevDeps = prevState[1];
6630
6631 if (areHookInputsEqual(nextDeps, prevDeps)) {
6632 return prevState[0];
6633 }
6634 }
6635 }
6636
6637 hook.memoizedState = [callback, nextDeps];
6638 return callback;
6639}
6640
6641function mountMemo(nextCreate, deps) {
6642 var hook = mountWorkInProgressHook();
6643 var nextDeps = deps === undefined ? null : deps;
6644 var nextValue = nextCreate();
6645 hook.memoizedState = [nextValue, nextDeps];
6646 return nextValue;
6647}
6648
6649function updateMemo(nextCreate, deps) {
6650 var hook = updateWorkInProgressHook();
6651 var nextDeps = deps === undefined ? null : deps;
6652 var prevState = hook.memoizedState;
6653
6654 if (prevState !== null) {
6655 // Assume these are defined. If they're not, areHookInputsEqual will warn.
6656 if (nextDeps !== null) {
6657 var prevDeps = prevState[1];
6658
6659 if (areHookInputsEqual(nextDeps, prevDeps)) {
6660 return prevState[0];
6661 }
6662 }
6663 }
6664
6665 var nextValue = nextCreate();
6666 hook.memoizedState = [nextValue, nextDeps];
6667 return nextValue;
6668}
6669
6670function dispatchAction(fiber, queue, action) {
6671 (function () {
6672 if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
6673 {
6674 throw ReactError(Error("Too many re-renders. React limits the number of renders to prevent an infinite loop."));
6675 }
6676 }
6677 })();
6678
6679 {
6680 !(typeof arguments[3] !== 'function') ? warning$1(false, "State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().') : void 0;
6681 }
6682
6683 var alternate = fiber.alternate;
6684
6685 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
6686 // This is a render phase update. Stash it in a lazily-created map of
6687 // queue -> linked list of updates. After this render pass, we'll restart
6688 // and apply the stashed updates on top of the work-in-progress hook.
6689 didScheduleRenderPhaseUpdate = true;
6690 var update = {
6691 expirationTime: renderExpirationTime$1,
6692 suspenseConfig: null,
6693 action: action,
6694 eagerReducer: null,
6695 eagerState: null,
6696 next: null
6697 };
6698
6699 {
6700 update.priority = getCurrentPriorityLevel();
6701 }
6702
6703 if (renderPhaseUpdates === null) {
6704 renderPhaseUpdates = new Map();
6705 }
6706
6707 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
6708
6709 if (firstRenderPhaseUpdate === undefined) {
6710 renderPhaseUpdates.set(queue, update);
6711 } else {
6712 // Append the update to the end of the list.
6713 var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
6714
6715 while (lastRenderPhaseUpdate.next !== null) {
6716 lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
6717 }
6718
6719 lastRenderPhaseUpdate.next = update;
6720 }
6721 } else {
6722 var currentTime = requestCurrentTime();
6723 var suspenseConfig = requestCurrentSuspenseConfig();
6724 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
6725 var _update2 = {
6726 expirationTime: expirationTime,
6727 suspenseConfig: suspenseConfig,
6728 action: action,
6729 eagerReducer: null,
6730 eagerState: null,
6731 next: null
6732 };
6733
6734 {
6735 _update2.priority = getCurrentPriorityLevel();
6736 } // Append the update to the end of the list.
6737
6738
6739 var last = queue.last;
6740
6741 if (last === null) {
6742 // This is the first update. Create a circular list.
6743 _update2.next = _update2;
6744 } else {
6745 var first = last.next;
6746
6747 if (first !== null) {
6748 // Still circular.
6749 _update2.next = first;
6750 }
6751
6752 last.next = _update2;
6753 }
6754
6755 queue.last = _update2;
6756
6757 if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
6758 // The queue is currently empty, which means we can eagerly compute the
6759 // next state before entering the render phase. If the new state is the
6760 // same as the current state, we may be able to bail out entirely.
6761 var lastRenderedReducer = queue.lastRenderedReducer;
6762
6763 if (lastRenderedReducer !== null) {
6764 var prevDispatcher;
6765
6766 {
6767 prevDispatcher = ReactCurrentDispatcher$1.current;
6768 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6769 }
6770
6771 try {
6772 var currentState = queue.lastRenderedState;
6773 var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute
6774 // it, on the update object. If the reducer hasn't changed by the
6775 // time we enter the render phase, then the eager state can be used
6776 // without calling the reducer again.
6777
6778 _update2.eagerReducer = lastRenderedReducer;
6779 _update2.eagerState = eagerState;
6780
6781 if (is$1(eagerState, currentState)) {
6782 // Fast path. We can bail out without scheduling React to re-render.
6783 // It's still possible that we'll need to rebase this update later,
6784 // if the component re-renders for a different reason and by that
6785 // time the reducer has changed.
6786 return;
6787 }
6788 } catch (error) {// Suppress the error. It will throw again in the render phase.
6789 } finally {
6790 {
6791 ReactCurrentDispatcher$1.current = prevDispatcher;
6792 }
6793 }
6794 }
6795 }
6796
6797 {
6798 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6799 if ('undefined' !== typeof jest) {
6800 warnIfNotScopedWithMatchingAct(fiber);
6801 warnIfNotCurrentlyActingUpdatesInDev(fiber);
6802 }
6803 }
6804
6805 scheduleWork(fiber, expirationTime);
6806 }
6807}
6808
6809var ContextOnlyDispatcher = {
6810 readContext: readContext,
6811 useCallback: throwInvalidHookError,
6812 useContext: throwInvalidHookError,
6813 useEffect: throwInvalidHookError,
6814 useImperativeHandle: throwInvalidHookError,
6815 useLayoutEffect: throwInvalidHookError,
6816 useMemo: throwInvalidHookError,
6817 useReducer: throwInvalidHookError,
6818 useRef: throwInvalidHookError,
6819 useState: throwInvalidHookError,
6820 useDebugValue: throwInvalidHookError,
6821 useResponder: throwInvalidHookError
6822};
6823var HooksDispatcherOnMountInDEV = null;
6824var HooksDispatcherOnMountWithHookTypesInDEV = null;
6825var HooksDispatcherOnUpdateInDEV = null;
6826var InvalidNestedHooksDispatcherOnMountInDEV = null;
6827var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
6828
6829{
6830 var warnInvalidContextAccess = function () {
6831 warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
6832 };
6833
6834 var warnInvalidHookAccess = function () {
6835 warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
6836 };
6837
6838 HooksDispatcherOnMountInDEV = {
6839 readContext: function (context, observedBits) {
6840 return readContext(context, observedBits);
6841 },
6842 useCallback: function (callback, deps) {
6843 currentHookNameInDev = 'useCallback';
6844 mountHookTypesDev();
6845 checkDepsAreArrayDev(deps);
6846 return mountCallback(callback, deps);
6847 },
6848 useContext: function (context, observedBits) {
6849 currentHookNameInDev = 'useContext';
6850 mountHookTypesDev();
6851 return readContext(context, observedBits);
6852 },
6853 useEffect: function (create, deps) {
6854 currentHookNameInDev = 'useEffect';
6855 mountHookTypesDev();
6856 checkDepsAreArrayDev(deps);
6857 return mountEffect(create, deps);
6858 },
6859 useImperativeHandle: function (ref, create, deps) {
6860 currentHookNameInDev = 'useImperativeHandle';
6861 mountHookTypesDev();
6862 checkDepsAreArrayDev(deps);
6863 return mountImperativeHandle(ref, create, deps);
6864 },
6865 useLayoutEffect: function (create, deps) {
6866 currentHookNameInDev = 'useLayoutEffect';
6867 mountHookTypesDev();
6868 checkDepsAreArrayDev(deps);
6869 return mountLayoutEffect(create, deps);
6870 },
6871 useMemo: function (create, deps) {
6872 currentHookNameInDev = 'useMemo';
6873 mountHookTypesDev();
6874 checkDepsAreArrayDev(deps);
6875 var prevDispatcher = ReactCurrentDispatcher$1.current;
6876 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6877
6878 try {
6879 return mountMemo(create, deps);
6880 } finally {
6881 ReactCurrentDispatcher$1.current = prevDispatcher;
6882 }
6883 },
6884 useReducer: function (reducer, initialArg, init) {
6885 currentHookNameInDev = 'useReducer';
6886 mountHookTypesDev();
6887 var prevDispatcher = ReactCurrentDispatcher$1.current;
6888 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6889
6890 try {
6891 return mountReducer(reducer, initialArg, init);
6892 } finally {
6893 ReactCurrentDispatcher$1.current = prevDispatcher;
6894 }
6895 },
6896 useRef: function (initialValue) {
6897 currentHookNameInDev = 'useRef';
6898 mountHookTypesDev();
6899 return mountRef(initialValue);
6900 },
6901 useState: function (initialState) {
6902 currentHookNameInDev = 'useState';
6903 mountHookTypesDev();
6904 var prevDispatcher = ReactCurrentDispatcher$1.current;
6905 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6906
6907 try {
6908 return mountState(initialState);
6909 } finally {
6910 ReactCurrentDispatcher$1.current = prevDispatcher;
6911 }
6912 },
6913 useDebugValue: function (value, formatterFn) {
6914 currentHookNameInDev = 'useDebugValue';
6915 mountHookTypesDev();
6916 return mountDebugValue(value, formatterFn);
6917 },
6918 useResponder: function (responder, props) {
6919 currentHookNameInDev = 'useResponder';
6920 mountHookTypesDev();
6921 return createResponderListener(responder, props);
6922 }
6923 };
6924 HooksDispatcherOnMountWithHookTypesInDEV = {
6925 readContext: function (context, observedBits) {
6926 return readContext(context, observedBits);
6927 },
6928 useCallback: function (callback, deps) {
6929 currentHookNameInDev = 'useCallback';
6930 updateHookTypesDev();
6931 return mountCallback(callback, deps);
6932 },
6933 useContext: function (context, observedBits) {
6934 currentHookNameInDev = 'useContext';
6935 updateHookTypesDev();
6936 return readContext(context, observedBits);
6937 },
6938 useEffect: function (create, deps) {
6939 currentHookNameInDev = 'useEffect';
6940 updateHookTypesDev();
6941 return mountEffect(create, deps);
6942 },
6943 useImperativeHandle: function (ref, create, deps) {
6944 currentHookNameInDev = 'useImperativeHandle';
6945 updateHookTypesDev();
6946 return mountImperativeHandle(ref, create, deps);
6947 },
6948 useLayoutEffect: function (create, deps) {
6949 currentHookNameInDev = 'useLayoutEffect';
6950 updateHookTypesDev();
6951 return mountLayoutEffect(create, deps);
6952 },
6953 useMemo: function (create, deps) {
6954 currentHookNameInDev = 'useMemo';
6955 updateHookTypesDev();
6956 var prevDispatcher = ReactCurrentDispatcher$1.current;
6957 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6958
6959 try {
6960 return mountMemo(create, deps);
6961 } finally {
6962 ReactCurrentDispatcher$1.current = prevDispatcher;
6963 }
6964 },
6965 useReducer: function (reducer, initialArg, init) {
6966 currentHookNameInDev = 'useReducer';
6967 updateHookTypesDev();
6968 var prevDispatcher = ReactCurrentDispatcher$1.current;
6969 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6970
6971 try {
6972 return mountReducer(reducer, initialArg, init);
6973 } finally {
6974 ReactCurrentDispatcher$1.current = prevDispatcher;
6975 }
6976 },
6977 useRef: function (initialValue) {
6978 currentHookNameInDev = 'useRef';
6979 updateHookTypesDev();
6980 return mountRef(initialValue);
6981 },
6982 useState: function (initialState) {
6983 currentHookNameInDev = 'useState';
6984 updateHookTypesDev();
6985 var prevDispatcher = ReactCurrentDispatcher$1.current;
6986 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6987
6988 try {
6989 return mountState(initialState);
6990 } finally {
6991 ReactCurrentDispatcher$1.current = prevDispatcher;
6992 }
6993 },
6994 useDebugValue: function (value, formatterFn) {
6995 currentHookNameInDev = 'useDebugValue';
6996 updateHookTypesDev();
6997 return mountDebugValue(value, formatterFn);
6998 },
6999 useResponder: function (responder, props) {
7000 currentHookNameInDev = 'useResponder';
7001 updateHookTypesDev();
7002 return createResponderListener(responder, props);
7003 }
7004 };
7005 HooksDispatcherOnUpdateInDEV = {
7006 readContext: function (context, observedBits) {
7007 return readContext(context, observedBits);
7008 },
7009 useCallback: function (callback, deps) {
7010 currentHookNameInDev = 'useCallback';
7011 updateHookTypesDev();
7012 return updateCallback(callback, deps);
7013 },
7014 useContext: function (context, observedBits) {
7015 currentHookNameInDev = 'useContext';
7016 updateHookTypesDev();
7017 return readContext(context, observedBits);
7018 },
7019 useEffect: function (create, deps) {
7020 currentHookNameInDev = 'useEffect';
7021 updateHookTypesDev();
7022 return updateEffect(create, deps);
7023 },
7024 useImperativeHandle: function (ref, create, deps) {
7025 currentHookNameInDev = 'useImperativeHandle';
7026 updateHookTypesDev();
7027 return updateImperativeHandle(ref, create, deps);
7028 },
7029 useLayoutEffect: function (create, deps) {
7030 currentHookNameInDev = 'useLayoutEffect';
7031 updateHookTypesDev();
7032 return updateLayoutEffect(create, deps);
7033 },
7034 useMemo: function (create, deps) {
7035 currentHookNameInDev = 'useMemo';
7036 updateHookTypesDev();
7037 var prevDispatcher = ReactCurrentDispatcher$1.current;
7038 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7039
7040 try {
7041 return updateMemo(create, deps);
7042 } finally {
7043 ReactCurrentDispatcher$1.current = prevDispatcher;
7044 }
7045 },
7046 useReducer: function (reducer, initialArg, init) {
7047 currentHookNameInDev = 'useReducer';
7048 updateHookTypesDev();
7049 var prevDispatcher = ReactCurrentDispatcher$1.current;
7050 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7051
7052 try {
7053 return updateReducer(reducer, initialArg, init);
7054 } finally {
7055 ReactCurrentDispatcher$1.current = prevDispatcher;
7056 }
7057 },
7058 useRef: function (initialValue) {
7059 currentHookNameInDev = 'useRef';
7060 updateHookTypesDev();
7061 return updateRef(initialValue);
7062 },
7063 useState: function (initialState) {
7064 currentHookNameInDev = 'useState';
7065 updateHookTypesDev();
7066 var prevDispatcher = ReactCurrentDispatcher$1.current;
7067 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7068
7069 try {
7070 return updateState(initialState);
7071 } finally {
7072 ReactCurrentDispatcher$1.current = prevDispatcher;
7073 }
7074 },
7075 useDebugValue: function (value, formatterFn) {
7076 currentHookNameInDev = 'useDebugValue';
7077 updateHookTypesDev();
7078 return updateDebugValue(value, formatterFn);
7079 },
7080 useResponder: function (responder, props) {
7081 currentHookNameInDev = 'useResponder';
7082 updateHookTypesDev();
7083 return createResponderListener(responder, props);
7084 }
7085 };
7086 InvalidNestedHooksDispatcherOnMountInDEV = {
7087 readContext: function (context, observedBits) {
7088 warnInvalidContextAccess();
7089 return readContext(context, observedBits);
7090 },
7091 useCallback: function (callback, deps) {
7092 currentHookNameInDev = 'useCallback';
7093 warnInvalidHookAccess();
7094 mountHookTypesDev();
7095 return mountCallback(callback, deps);
7096 },
7097 useContext: function (context, observedBits) {
7098 currentHookNameInDev = 'useContext';
7099 warnInvalidHookAccess();
7100 mountHookTypesDev();
7101 return readContext(context, observedBits);
7102 },
7103 useEffect: function (create, deps) {
7104 currentHookNameInDev = 'useEffect';
7105 warnInvalidHookAccess();
7106 mountHookTypesDev();
7107 return mountEffect(create, deps);
7108 },
7109 useImperativeHandle: function (ref, create, deps) {
7110 currentHookNameInDev = 'useImperativeHandle';
7111 warnInvalidHookAccess();
7112 mountHookTypesDev();
7113 return mountImperativeHandle(ref, create, deps);
7114 },
7115 useLayoutEffect: function (create, deps) {
7116 currentHookNameInDev = 'useLayoutEffect';
7117 warnInvalidHookAccess();
7118 mountHookTypesDev();
7119 return mountLayoutEffect(create, deps);
7120 },
7121 useMemo: function (create, deps) {
7122 currentHookNameInDev = 'useMemo';
7123 warnInvalidHookAccess();
7124 mountHookTypesDev();
7125 var prevDispatcher = ReactCurrentDispatcher$1.current;
7126 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7127
7128 try {
7129 return mountMemo(create, deps);
7130 } finally {
7131 ReactCurrentDispatcher$1.current = prevDispatcher;
7132 }
7133 },
7134 useReducer: function (reducer, initialArg, init) {
7135 currentHookNameInDev = 'useReducer';
7136 warnInvalidHookAccess();
7137 mountHookTypesDev();
7138 var prevDispatcher = ReactCurrentDispatcher$1.current;
7139 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7140
7141 try {
7142 return mountReducer(reducer, initialArg, init);
7143 } finally {
7144 ReactCurrentDispatcher$1.current = prevDispatcher;
7145 }
7146 },
7147 useRef: function (initialValue) {
7148 currentHookNameInDev = 'useRef';
7149 warnInvalidHookAccess();
7150 mountHookTypesDev();
7151 return mountRef(initialValue);
7152 },
7153 useState: function (initialState) {
7154 currentHookNameInDev = 'useState';
7155 warnInvalidHookAccess();
7156 mountHookTypesDev();
7157 var prevDispatcher = ReactCurrentDispatcher$1.current;
7158 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7159
7160 try {
7161 return mountState(initialState);
7162 } finally {
7163 ReactCurrentDispatcher$1.current = prevDispatcher;
7164 }
7165 },
7166 useDebugValue: function (value, formatterFn) {
7167 currentHookNameInDev = 'useDebugValue';
7168 warnInvalidHookAccess();
7169 mountHookTypesDev();
7170 return mountDebugValue(value, formatterFn);
7171 },
7172 useResponder: function (responder, props) {
7173 currentHookNameInDev = 'useResponder';
7174 warnInvalidHookAccess();
7175 mountHookTypesDev();
7176 return createResponderListener(responder, props);
7177 }
7178 };
7179 InvalidNestedHooksDispatcherOnUpdateInDEV = {
7180 readContext: function (context, observedBits) {
7181 warnInvalidContextAccess();
7182 return readContext(context, observedBits);
7183 },
7184 useCallback: function (callback, deps) {
7185 currentHookNameInDev = 'useCallback';
7186 warnInvalidHookAccess();
7187 updateHookTypesDev();
7188 return updateCallback(callback, deps);
7189 },
7190 useContext: function (context, observedBits) {
7191 currentHookNameInDev = 'useContext';
7192 warnInvalidHookAccess();
7193 updateHookTypesDev();
7194 return readContext(context, observedBits);
7195 },
7196 useEffect: function (create, deps) {
7197 currentHookNameInDev = 'useEffect';
7198 warnInvalidHookAccess();
7199 updateHookTypesDev();
7200 return updateEffect(create, deps);
7201 },
7202 useImperativeHandle: function (ref, create, deps) {
7203 currentHookNameInDev = 'useImperativeHandle';
7204 warnInvalidHookAccess();
7205 updateHookTypesDev();
7206 return updateImperativeHandle(ref, create, deps);
7207 },
7208 useLayoutEffect: function (create, deps) {
7209 currentHookNameInDev = 'useLayoutEffect';
7210 warnInvalidHookAccess();
7211 updateHookTypesDev();
7212 return updateLayoutEffect(create, deps);
7213 },
7214 useMemo: function (create, deps) {
7215 currentHookNameInDev = 'useMemo';
7216 warnInvalidHookAccess();
7217 updateHookTypesDev();
7218 var prevDispatcher = ReactCurrentDispatcher$1.current;
7219 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7220
7221 try {
7222 return updateMemo(create, deps);
7223 } finally {
7224 ReactCurrentDispatcher$1.current = prevDispatcher;
7225 }
7226 },
7227 useReducer: function (reducer, initialArg, init) {
7228 currentHookNameInDev = 'useReducer';
7229 warnInvalidHookAccess();
7230 updateHookTypesDev();
7231 var prevDispatcher = ReactCurrentDispatcher$1.current;
7232 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7233
7234 try {
7235 return updateReducer(reducer, initialArg, init);
7236 } finally {
7237 ReactCurrentDispatcher$1.current = prevDispatcher;
7238 }
7239 },
7240 useRef: function (initialValue) {
7241 currentHookNameInDev = 'useRef';
7242 warnInvalidHookAccess();
7243 updateHookTypesDev();
7244 return updateRef(initialValue);
7245 },
7246 useState: function (initialState) {
7247 currentHookNameInDev = 'useState';
7248 warnInvalidHookAccess();
7249 updateHookTypesDev();
7250 var prevDispatcher = ReactCurrentDispatcher$1.current;
7251 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7252
7253 try {
7254 return updateState(initialState);
7255 } finally {
7256 ReactCurrentDispatcher$1.current = prevDispatcher;
7257 }
7258 },
7259 useDebugValue: function (value, formatterFn) {
7260 currentHookNameInDev = 'useDebugValue';
7261 warnInvalidHookAccess();
7262 updateHookTypesDev();
7263 return updateDebugValue(value, formatterFn);
7264 },
7265 useResponder: function (responder, props) {
7266 currentHookNameInDev = 'useResponder';
7267 warnInvalidHookAccess();
7268 updateHookTypesDev();
7269 return createResponderListener(responder, props);
7270 }
7271 };
7272}
7273
7274// CommonJS interop named imports.
7275
7276var now$2 = Scheduler.unstable_now;
7277var commitTime = 0;
7278var profilerStartTime = -1;
7279
7280function getCommitTime() {
7281 return commitTime;
7282}
7283
7284function recordCommitTime() {
7285 if (!enableProfilerTimer) {
7286 return;
7287 }
7288
7289 commitTime = now$2();
7290}
7291
7292function startProfilerTimer(fiber) {
7293 if (!enableProfilerTimer) {
7294 return;
7295 }
7296
7297 profilerStartTime = now$2();
7298
7299 if (fiber.actualStartTime < 0) {
7300 fiber.actualStartTime = now$2();
7301 }
7302}
7303
7304function stopProfilerTimerIfRunning(fiber) {
7305 if (!enableProfilerTimer) {
7306 return;
7307 }
7308
7309 profilerStartTime = -1;
7310}
7311
7312function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
7313 if (!enableProfilerTimer) {
7314 return;
7315 }
7316
7317 if (profilerStartTime >= 0) {
7318 var elapsedTime = now$2() - profilerStartTime;
7319 fiber.actualDuration += elapsedTime;
7320
7321 if (overrideBaseTime) {
7322 fiber.selfBaseDuration = elapsedTime;
7323 }
7324
7325 profilerStartTime = -1;
7326 }
7327}
7328
7329// This may have been an insertion or a hydration.
7330
7331var hydrationParentFiber = null;
7332var nextHydratableInstance = null;
7333var isHydrating = false;
7334
7335function warnIfHydrating() {
7336 {
7337 !!isHydrating ? warning$1(false, 'We should not be hydrating here. This is a bug in React. Please file a bug.') : void 0;
7338 }
7339}
7340
7341function enterHydrationState(fiber) {
7342 if (!supportsHydration) {
7343 return false;
7344 }
7345
7346 var parentInstance = fiber.stateNode.containerInfo;
7347 nextHydratableInstance = getFirstHydratableChild(parentInstance);
7348 hydrationParentFiber = fiber;
7349 isHydrating = true;
7350 return true;
7351}
7352
7353function reenterHydrationStateFromDehydratedSuspenseInstance(fiber, suspenseInstance) {
7354 if (!supportsHydration) {
7355 return false;
7356 }
7357
7358 nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
7359 popToNextHostParent(fiber);
7360 isHydrating = true;
7361 return true;
7362}
7363
7364function deleteHydratableInstance(returnFiber, instance) {
7365 {
7366 switch (returnFiber.tag) {
7367 case HostRoot:
7368 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
7369 break;
7370
7371 case HostComponent:
7372 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
7373 break;
7374 }
7375 }
7376
7377 var childToDelete = createFiberFromHostInstanceForDeletion();
7378 childToDelete.stateNode = instance;
7379 childToDelete.return = returnFiber;
7380 childToDelete.effectTag = Deletion; // This might seem like it belongs on progressedFirstDeletion. However,
7381 // these children are not part of the reconciliation list of children.
7382 // Even if we abort and rereconcile the children, that will try to hydrate
7383 // again and the nodes are still in the host tree so these will be
7384 // recreated.
7385
7386 if (returnFiber.lastEffect !== null) {
7387 returnFiber.lastEffect.nextEffect = childToDelete;
7388 returnFiber.lastEffect = childToDelete;
7389 } else {
7390 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
7391 }
7392}
7393
7394function insertNonHydratedInstance(returnFiber, fiber) {
7395 fiber.effectTag = fiber.effectTag & ~Hydrating | Placement;
7396
7397 {
7398 switch (returnFiber.tag) {
7399 case HostRoot:
7400 {
7401 var parentContainer = returnFiber.stateNode.containerInfo;
7402
7403 switch (fiber.tag) {
7404 case HostComponent:
7405 var type = fiber.type;
7406 var props = fiber.pendingProps;
7407 didNotFindHydratableContainerInstance(parentContainer, type, props);
7408 break;
7409
7410 case HostText:
7411 var text = fiber.pendingProps;
7412 didNotFindHydratableContainerTextInstance(parentContainer, text);
7413 break;
7414
7415 case SuspenseComponent:
7416 didNotFindHydratableContainerSuspenseInstance(parentContainer);
7417 break;
7418 }
7419
7420 break;
7421 }
7422
7423 case HostComponent:
7424 {
7425 var parentType = returnFiber.type;
7426 var parentProps = returnFiber.memoizedProps;
7427 var parentInstance = returnFiber.stateNode;
7428
7429 switch (fiber.tag) {
7430 case HostComponent:
7431 var _type = fiber.type;
7432 var _props = fiber.pendingProps;
7433 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
7434 break;
7435
7436 case HostText:
7437 var _text = fiber.pendingProps;
7438 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
7439 break;
7440
7441 case SuspenseComponent:
7442 didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
7443 break;
7444 }
7445
7446 break;
7447 }
7448
7449 default:
7450 return;
7451 }
7452 }
7453}
7454
7455function tryHydrate(fiber, nextInstance) {
7456 switch (fiber.tag) {
7457 case HostComponent:
7458 {
7459 var type = fiber.type;
7460 var props = fiber.pendingProps;
7461 var instance = canHydrateInstance(nextInstance, type, props);
7462
7463 if (instance !== null) {
7464 fiber.stateNode = instance;
7465 return true;
7466 }
7467
7468 return false;
7469 }
7470
7471 case HostText:
7472 {
7473 var text = fiber.pendingProps;
7474 var textInstance = canHydrateTextInstance(nextInstance, text);
7475
7476 if (textInstance !== null) {
7477 fiber.stateNode = textInstance;
7478 return true;
7479 }
7480
7481 return false;
7482 }
7483
7484 case SuspenseComponent:
7485 {
7486 if (enableSuspenseServerRenderer) {
7487 var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
7488
7489 if (suspenseInstance !== null) {
7490 var suspenseState = {
7491 dehydrated: suspenseInstance,
7492 retryTime: Never
7493 };
7494 fiber.memoizedState = suspenseState; // Store the dehydrated fragment as a child fiber.
7495 // This simplifies the code for getHostSibling and deleting nodes,
7496 // since it doesn't have to consider all Suspense boundaries and
7497 // check if they're dehydrated ones or not.
7498
7499 var dehydratedFragment = createFiberFromDehydratedFragment(suspenseInstance);
7500 dehydratedFragment.return = fiber;
7501 fiber.child = dehydratedFragment;
7502 return true;
7503 }
7504 }
7505
7506 return false;
7507 }
7508
7509 default:
7510 return false;
7511 }
7512}
7513
7514function tryToClaimNextHydratableInstance(fiber) {
7515 if (!isHydrating) {
7516 return;
7517 }
7518
7519 var nextInstance = nextHydratableInstance;
7520
7521 if (!nextInstance) {
7522 // Nothing to hydrate. Make it an insertion.
7523 insertNonHydratedInstance(hydrationParentFiber, fiber);
7524 isHydrating = false;
7525 hydrationParentFiber = fiber;
7526 return;
7527 }
7528
7529 var firstAttemptedInstance = nextInstance;
7530
7531 if (!tryHydrate(fiber, nextInstance)) {
7532 // If we can't hydrate this instance let's try the next one.
7533 // We use this as a heuristic. It's based on intuition and not data so it
7534 // might be flawed or unnecessary.
7535 nextInstance = getNextHydratableSibling(firstAttemptedInstance);
7536
7537 if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
7538 // Nothing to hydrate. Make it an insertion.
7539 insertNonHydratedInstance(hydrationParentFiber, fiber);
7540 isHydrating = false;
7541 hydrationParentFiber = fiber;
7542 return;
7543 } // We matched the next one, we'll now assume that the first one was
7544 // superfluous and we'll delete it. Since we can't eagerly delete it
7545 // we'll have to schedule a deletion. To do that, this node needs a dummy
7546 // fiber associated with it.
7547
7548
7549 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
7550 }
7551
7552 hydrationParentFiber = fiber;
7553 nextHydratableInstance = getFirstHydratableChild(nextInstance);
7554}
7555
7556function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
7557 if (!supportsHydration) {
7558 (function () {
7559 {
7560 {
7561 throw ReactError(Error("Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7562 }
7563 }
7564 })();
7565 }
7566
7567 var instance = fiber.stateNode;
7568 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component.
7569
7570 fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
7571 // is a new ref we mark this as an update.
7572
7573 if (updatePayload !== null) {
7574 return true;
7575 }
7576
7577 return false;
7578}
7579
7580function prepareToHydrateHostTextInstance(fiber) {
7581 if (!supportsHydration) {
7582 (function () {
7583 {
7584 {
7585 throw ReactError(Error("Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7586 }
7587 }
7588 })();
7589 }
7590
7591 var textInstance = fiber.stateNode;
7592 var textContent = fiber.memoizedProps;
7593 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
7594
7595 {
7596 if (shouldUpdate) {
7597 // We assume that prepareToHydrateHostTextInstance is called in a context where the
7598 // hydration parent is the parent host component of this host text.
7599 var returnFiber = hydrationParentFiber;
7600
7601 if (returnFiber !== null) {
7602 switch (returnFiber.tag) {
7603 case HostRoot:
7604 {
7605 var parentContainer = returnFiber.stateNode.containerInfo;
7606 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
7607 break;
7608 }
7609
7610 case HostComponent:
7611 {
7612 var parentType = returnFiber.type;
7613 var parentProps = returnFiber.memoizedProps;
7614 var parentInstance = returnFiber.stateNode;
7615 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
7616 break;
7617 }
7618 }
7619 }
7620 }
7621 }
7622
7623 return shouldUpdate;
7624}
7625
7626function prepareToHydrateHostSuspenseInstance(fiber) {
7627 if (!supportsHydration) {
7628 (function () {
7629 {
7630 {
7631 throw ReactError(Error("Expected prepareToHydrateHostSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7632 }
7633 }
7634 })();
7635 }
7636
7637 var suspenseState = fiber.memoizedState;
7638 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
7639
7640 (function () {
7641 if (!suspenseInstance) {
7642 {
7643 throw ReactError(Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue."));
7644 }
7645 }
7646 })();
7647
7648 hydrateSuspenseInstance(suspenseInstance, fiber);
7649}
7650
7651function skipPastDehydratedSuspenseInstance(fiber) {
7652 if (!supportsHydration) {
7653 (function () {
7654 {
7655 {
7656 throw ReactError(Error("Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7657 }
7658 }
7659 })();
7660 }
7661
7662 var suspenseState = fiber.memoizedState;
7663 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
7664
7665 (function () {
7666 if (!suspenseInstance) {
7667 {
7668 throw ReactError(Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue."));
7669 }
7670 }
7671 })();
7672
7673 return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
7674}
7675
7676function popToNextHostParent(fiber) {
7677 var parent = fiber.return;
7678
7679 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
7680 parent = parent.return;
7681 }
7682
7683 hydrationParentFiber = parent;
7684}
7685
7686function popHydrationState(fiber) {
7687 if (!supportsHydration) {
7688 return false;
7689 }
7690
7691 if (fiber !== hydrationParentFiber) {
7692 // We're deeper than the current hydration context, inside an inserted
7693 // tree.
7694 return false;
7695 }
7696
7697 if (!isHydrating) {
7698 // If we're not currently hydrating but we're in a hydration context, then
7699 // we were an insertion and now need to pop up reenter hydration of our
7700 // siblings.
7701 popToNextHostParent(fiber);
7702 isHydrating = true;
7703 return false;
7704 }
7705
7706 var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now.
7707 // We only do this deeper than head and body since they tend to have random
7708 // other nodes in them. We also ignore components with pure text content in
7709 // side of them.
7710 // TODO: Better heuristic.
7711
7712 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
7713 var nextInstance = nextHydratableInstance;
7714
7715 while (nextInstance) {
7716 deleteHydratableInstance(fiber, nextInstance);
7717 nextInstance = getNextHydratableSibling(nextInstance);
7718 }
7719 }
7720
7721 popToNextHostParent(fiber);
7722
7723 if (fiber.tag === SuspenseComponent) {
7724 nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
7725 } else {
7726 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
7727 }
7728
7729 return true;
7730}
7731
7732function resetHydrationState() {
7733 if (!supportsHydration) {
7734 return;
7735 }
7736
7737 hydrationParentFiber = null;
7738 nextHydratableInstance = null;
7739 isHydrating = false;
7740}
7741
7742var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
7743var didReceiveUpdate = false;
7744var didWarnAboutBadClass;
7745var didWarnAboutModulePatternComponent;
7746var didWarnAboutContextTypeOnFunctionComponent;
7747var didWarnAboutGetDerivedStateOnFunctionComponent;
7748var didWarnAboutFunctionRefs;
7749var didWarnAboutReassigningProps;
7750var didWarnAboutMaxDuration;
7751var didWarnAboutRevealOrder;
7752var didWarnAboutTailOptions;
7753var didWarnAboutDefaultPropsOnFunctionComponent;
7754
7755{
7756 didWarnAboutBadClass = {};
7757 didWarnAboutModulePatternComponent = {};
7758 didWarnAboutContextTypeOnFunctionComponent = {};
7759 didWarnAboutGetDerivedStateOnFunctionComponent = {};
7760 didWarnAboutFunctionRefs = {};
7761 didWarnAboutReassigningProps = false;
7762 didWarnAboutMaxDuration = false;
7763 didWarnAboutRevealOrder = {};
7764 didWarnAboutTailOptions = {};
7765 didWarnAboutDefaultPropsOnFunctionComponent = {};
7766}
7767
7768function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7769 if (current$$1 === null) {
7770 // If this is a fresh new component that hasn't been rendered yet, we
7771 // won't update its child set by applying minimal side-effects. Instead,
7772 // we will add them all to the child before it gets rendered. That means
7773 // we can optimize this reconciliation pass by not tracking side-effects.
7774 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7775 } else {
7776 // If the current child is the same as the work in progress, it means that
7777 // we haven't yet started any work on these children. Therefore, we use
7778 // the clone algorithm to create a copy of all the current children.
7779 // If we had any progressed work already, that is invalid at this point so
7780 // let's throw it out.
7781 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
7782 }
7783}
7784
7785function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7786 // This function is fork of reconcileChildren. It's used in cases where we
7787 // want to reconcile without matching against the existing set. This has the
7788 // effect of all current children being unmounted; even if the type and key
7789 // are the same, the old child is unmounted and a new child is created.
7790 //
7791 // To do this, we're going to go through the reconcile algorithm twice. In
7792 // the first pass, we schedule a deletion for all the current children by
7793 // passing null.
7794 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime); // In the second pass, we mount the new children. The trick here is that we
7795 // pass null in place of where we usually pass the current child set. This has
7796 // the effect of remounting all children regardless of whether their their
7797 // identity matches.
7798
7799 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7800}
7801
7802function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7803 // TODO: current can be non-null here even if the component
7804 // hasn't yet mounted. This happens after the first render suspends.
7805 // We'll need to figure out if this is fine or can cause issues.
7806 {
7807 if (workInProgress.type !== workInProgress.elementType) {
7808 // Lazy component props can't be validated in createElement
7809 // because they're only guaranteed to be resolved here.
7810 var innerPropTypes = Component.propTypes;
7811
7812 if (innerPropTypes) {
7813 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7814 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7815 }
7816 }
7817 }
7818
7819 var render = Component.render;
7820 var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
7821
7822 var nextChildren;
7823 prepareToReadContext(workInProgress, renderExpirationTime);
7824
7825 {
7826 ReactCurrentOwner$2.current = workInProgress;
7827 setCurrentPhase('render');
7828 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7829
7830 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7831 // Only double-render components with Hooks
7832 if (workInProgress.memoizedState !== null) {
7833 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7834 }
7835 }
7836
7837 setCurrentPhase(null);
7838 }
7839
7840 if (current$$1 !== null && !didReceiveUpdate) {
7841 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
7842 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7843 } // React DevTools reads this flag.
7844
7845
7846 workInProgress.effectTag |= PerformedWork;
7847 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7848 return workInProgress.child;
7849}
7850
7851function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7852 if (current$$1 === null) {
7853 var type = Component.type;
7854
7855 if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
7856 Component.defaultProps === undefined) {
7857 var resolvedType = type;
7858
7859 {
7860 resolvedType = resolveFunctionForHotReloading(type);
7861 } // If this is a plain function component without default props,
7862 // and with only the default shallow comparison, we upgrade it
7863 // to a SimpleMemoComponent to allow fast path updates.
7864
7865
7866 workInProgress.tag = SimpleMemoComponent;
7867 workInProgress.type = resolvedType;
7868
7869 {
7870 validateFunctionComponentInDev(workInProgress, type);
7871 }
7872
7873 return updateSimpleMemoComponent(current$$1, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
7874 }
7875
7876 {
7877 var innerPropTypes = type.propTypes;
7878
7879 if (innerPropTypes) {
7880 // Inner memo component props aren't currently validated in createElement.
7881 // We could move it there, but we'd still need this for lazy code path.
7882 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7883 'prop', getComponentName(type), getCurrentFiberStackInDev);
7884 }
7885 }
7886
7887 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
7888 child.ref = workInProgress.ref;
7889 child.return = workInProgress;
7890 workInProgress.child = child;
7891 return child;
7892 }
7893
7894 {
7895 var _type = Component.type;
7896 var _innerPropTypes = _type.propTypes;
7897
7898 if (_innerPropTypes) {
7899 // Inner memo component props aren't currently validated in createElement.
7900 // We could move it there, but we'd still need this for lazy code path.
7901 checkPropTypes(_innerPropTypes, nextProps, // Resolved props
7902 'prop', getComponentName(_type), getCurrentFiberStackInDev);
7903 }
7904 }
7905
7906 var currentChild = current$$1.child; // This is always exactly one child
7907
7908 if (updateExpirationTime < renderExpirationTime) {
7909 // This will be the props with resolved defaultProps,
7910 // unlike current.memoizedProps which will be the unresolved ones.
7911 var prevProps = currentChild.memoizedProps; // Default to shallow comparison
7912
7913 var compare = Component.compare;
7914 compare = compare !== null ? compare : shallowEqual;
7915
7916 if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
7917 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7918 }
7919 } // React DevTools reads this flag.
7920
7921
7922 workInProgress.effectTag |= PerformedWork;
7923 var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
7924 newChild.ref = workInProgress.ref;
7925 newChild.return = workInProgress;
7926 workInProgress.child = newChild;
7927 return newChild;
7928}
7929
7930function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7931 // TODO: current can be non-null here even if the component
7932 // hasn't yet mounted. This happens when the inner render suspends.
7933 // We'll need to figure out if this is fine or can cause issues.
7934 {
7935 if (workInProgress.type !== workInProgress.elementType) {
7936 // Lazy component props can't be validated in createElement
7937 // because they're only guaranteed to be resolved here.
7938 var outerMemoType = workInProgress.elementType;
7939
7940 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
7941 // We warn when you define propTypes on lazy()
7942 // so let's just skip over it to find memo() outer wrapper.
7943 // Inner props for memo are validated later.
7944 outerMemoType = refineResolvedLazyComponent(outerMemoType);
7945 }
7946
7947 var outerPropTypes = outerMemoType && outerMemoType.propTypes;
7948
7949 if (outerPropTypes) {
7950 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
7951 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
7952 } // Inner propTypes will be validated in the function component path.
7953
7954 }
7955 }
7956
7957 if (current$$1 !== null) {
7958 var prevProps = current$$1.memoizedProps;
7959
7960 if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload:
7961 workInProgress.type === current$$1.type)) {
7962 didReceiveUpdate = false;
7963
7964 if (updateExpirationTime < renderExpirationTime) {
7965 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7966 }
7967 }
7968 }
7969
7970 return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
7971}
7972
7973function updateFragment(current$$1, workInProgress, renderExpirationTime) {
7974 var nextChildren = workInProgress.pendingProps;
7975 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7976 return workInProgress.child;
7977}
7978
7979function updateMode(current$$1, workInProgress, renderExpirationTime) {
7980 var nextChildren = workInProgress.pendingProps.children;
7981 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7982 return workInProgress.child;
7983}
7984
7985function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
7986 if (enableProfilerTimer) {
7987 workInProgress.effectTag |= Update;
7988 }
7989
7990 var nextProps = workInProgress.pendingProps;
7991 var nextChildren = nextProps.children;
7992 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7993 return workInProgress.child;
7994}
7995
7996function markRef(current$$1, workInProgress) {
7997 var ref = workInProgress.ref;
7998
7999 if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
8000 // Schedule a Ref effect
8001 workInProgress.effectTag |= Ref;
8002 }
8003}
8004
8005function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
8006 {
8007 if (workInProgress.type !== workInProgress.elementType) {
8008 // Lazy component props can't be validated in createElement
8009 // because they're only guaranteed to be resolved here.
8010 var innerPropTypes = Component.propTypes;
8011
8012 if (innerPropTypes) {
8013 checkPropTypes(innerPropTypes, nextProps, // Resolved props
8014 'prop', getComponentName(Component), getCurrentFiberStackInDev);
8015 }
8016 }
8017 }
8018
8019 var context;
8020
8021 if (!disableLegacyContext) {
8022 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
8023 context = getMaskedContext(workInProgress, unmaskedContext);
8024 }
8025
8026 var nextChildren;
8027 prepareToReadContext(workInProgress, renderExpirationTime);
8028
8029 {
8030 ReactCurrentOwner$2.current = workInProgress;
8031 setCurrentPhase('render');
8032 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
8033
8034 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8035 // Only double-render components with Hooks
8036 if (workInProgress.memoizedState !== null) {
8037 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
8038 }
8039 }
8040
8041 setCurrentPhase(null);
8042 }
8043
8044 if (current$$1 !== null && !didReceiveUpdate) {
8045 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
8046 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8047 } // React DevTools reads this flag.
8048
8049
8050 workInProgress.effectTag |= PerformedWork;
8051 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8052 return workInProgress.child;
8053}
8054
8055function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
8056 {
8057 if (workInProgress.type !== workInProgress.elementType) {
8058 // Lazy component props can't be validated in createElement
8059 // because they're only guaranteed to be resolved here.
8060 var innerPropTypes = Component.propTypes;
8061
8062 if (innerPropTypes) {
8063 checkPropTypes(innerPropTypes, nextProps, // Resolved props
8064 'prop', getComponentName(Component), getCurrentFiberStackInDev);
8065 }
8066 }
8067 } // Push context providers early to prevent context stack mismatches.
8068 // During mounting we don't know the child context yet as the instance doesn't exist.
8069 // We will invalidate the child context in finishClassComponent() right after rendering.
8070
8071
8072 var hasContext;
8073
8074 if (isContextProvider(Component)) {
8075 hasContext = true;
8076 pushContextProvider(workInProgress);
8077 } else {
8078 hasContext = false;
8079 }
8080
8081 prepareToReadContext(workInProgress, renderExpirationTime);
8082 var instance = workInProgress.stateNode;
8083 var shouldUpdate;
8084
8085 if (instance === null) {
8086 if (current$$1 !== null) {
8087 // An class component without an instance only mounts if it suspended
8088 // inside a non- concurrent tree, in an inconsistent state. We want to
8089 // tree it like a new mount, even though an empty version of it already
8090 // committed. Disconnect the alternate pointers.
8091 current$$1.alternate = null;
8092 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8093
8094 workInProgress.effectTag |= Placement;
8095 } // In the initial pass we might need to construct the instance.
8096
8097
8098 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8099 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8100 shouldUpdate = true;
8101 } else if (current$$1 === null) {
8102 // In a resume, we'll already have an instance we can reuse.
8103 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8104 } else {
8105 shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
8106 }
8107
8108 var nextUnitOfWork = finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
8109
8110 {
8111 var inst = workInProgress.stateNode;
8112
8113 if (inst.props !== nextProps) {
8114 !didWarnAboutReassigningProps ? warning$1(false, 'It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component') : void 0;
8115 didWarnAboutReassigningProps = true;
8116 }
8117 }
8118
8119 return nextUnitOfWork;
8120}
8121
8122function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
8123 // Refs should update even if shouldComponentUpdate returns false
8124 markRef(current$$1, workInProgress);
8125 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
8126
8127 if (!shouldUpdate && !didCaptureError) {
8128 // Context providers should defer to sCU for rendering
8129 if (hasContext) {
8130 invalidateContextProvider(workInProgress, Component, false);
8131 }
8132
8133 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8134 }
8135
8136 var instance = workInProgress.stateNode; // Rerender
8137
8138 ReactCurrentOwner$2.current = workInProgress;
8139 var nextChildren;
8140
8141 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
8142 // If we captured an error, but getDerivedStateFrom catch is not defined,
8143 // unmount all the children. componentDidCatch will schedule an update to
8144 // re-render a fallback. This is temporary until we migrate everyone to
8145 // the new API.
8146 // TODO: Warn in a future release.
8147 nextChildren = null;
8148
8149 if (enableProfilerTimer) {
8150 stopProfilerTimerIfRunning(workInProgress);
8151 }
8152 } else {
8153 {
8154 setCurrentPhase('render');
8155 nextChildren = instance.render();
8156
8157 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8158 instance.render();
8159 }
8160
8161 setCurrentPhase(null);
8162 }
8163 } // React DevTools reads this flag.
8164
8165
8166 workInProgress.effectTag |= PerformedWork;
8167
8168 if (current$$1 !== null && didCaptureError) {
8169 // If we're recovering from an error, reconcile without reusing any of
8170 // the existing children. Conceptually, the normal children and the children
8171 // that are shown on error are two different sets, so we shouldn't reuse
8172 // normal children even if their identities match.
8173 forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
8174 } else {
8175 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8176 } // Memoize state using the values we just used to render.
8177 // TODO: Restructure so we never read values from the instance.
8178
8179
8180 workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
8181
8182 if (hasContext) {
8183 invalidateContextProvider(workInProgress, Component, true);
8184 }
8185
8186 return workInProgress.child;
8187}
8188
8189function pushHostRootContext(workInProgress) {
8190 var root = workInProgress.stateNode;
8191
8192 if (root.pendingContext) {
8193 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
8194 } else if (root.context) {
8195 // Should always be set
8196 pushTopLevelContextObject(workInProgress, root.context, false);
8197 }
8198
8199 pushHostContainer(workInProgress, root.containerInfo);
8200}
8201
8202function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
8203 pushHostRootContext(workInProgress);
8204 var updateQueue = workInProgress.updateQueue;
8205
8206 (function () {
8207 if (!(updateQueue !== null)) {
8208 {
8209 throw ReactError(Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."));
8210 }
8211 }
8212 })();
8213
8214 var nextProps = workInProgress.pendingProps;
8215 var prevState = workInProgress.memoizedState;
8216 var prevChildren = prevState !== null ? prevState.element : null;
8217 processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
8218 var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
8219 // being called "element".
8220
8221 var nextChildren = nextState.element;
8222
8223 if (nextChildren === prevChildren) {
8224 // If the state is the same as before, that's a bailout because we had
8225 // no work that expires at this time.
8226 resetHydrationState();
8227 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8228 }
8229
8230 var root = workInProgress.stateNode;
8231
8232 if (root.hydrate && enterHydrationState(workInProgress)) {
8233 // If we don't have any current children this might be the first pass.
8234 // We always try to hydrate. If this isn't a hydration pass there won't
8235 // be any children to hydrate which is effectively the same thing as
8236 // not hydrating.
8237 var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
8238 workInProgress.child = child;
8239 var node = child;
8240
8241 while (node) {
8242 // Mark each child as hydrating. This is a fast path to know whether this
8243 // tree is part of a hydrating tree. This is used to determine if a child
8244 // node has fully mounted yet, and for scheduling event replaying.
8245 // Conceptually this is similar to Placement in that a new subtree is
8246 // inserted into the React tree here. It just happens to not need DOM
8247 // mutations because it already exists.
8248 node.effectTag = node.effectTag & ~Placement | Hydrating;
8249 node = node.sibling;
8250 }
8251 } else {
8252 // Otherwise reset hydration state in case we aborted and resumed another
8253 // root.
8254 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8255 resetHydrationState();
8256 }
8257
8258 return workInProgress.child;
8259}
8260
8261function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
8262 pushHostContext(workInProgress);
8263
8264 if (current$$1 === null) {
8265 tryToClaimNextHydratableInstance(workInProgress);
8266 }
8267
8268 var type = workInProgress.type;
8269 var nextProps = workInProgress.pendingProps;
8270 var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
8271 var nextChildren = nextProps.children;
8272 var isDirectTextChild = shouldSetTextContent(type, nextProps);
8273
8274 if (isDirectTextChild) {
8275 // We special case a direct text child of a host node. This is a common
8276 // case. We won't handle it as a reified child. We will instead handle
8277 // this in the host environment that also have access to this prop. That
8278 // avoids allocating another HostText fiber and traversing it.
8279 nextChildren = null;
8280 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
8281 // If we're switching from a direct text child to a normal child, or to
8282 // empty, we need to schedule the text content to be reset.
8283 workInProgress.effectTag |= ContentReset;
8284 }
8285
8286 markRef(current$$1, workInProgress); // Check the host config to see if the children are offscreen/hidden.
8287
8288 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
8289 if (enableSchedulerTracing) {
8290 markSpawnedWork(Never);
8291 } // Schedule this fiber to re-render at offscreen priority. Then bailout.
8292
8293
8294 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
8295 return null;
8296 }
8297
8298 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8299 return workInProgress.child;
8300}
8301
8302function updateHostText(current$$1, workInProgress) {
8303 if (current$$1 === null) {
8304 tryToClaimNextHydratableInstance(workInProgress);
8305 } // Nothing to do here. This is terminal. We'll do the completion step
8306 // immediately after.
8307
8308
8309 return null;
8310}
8311
8312function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
8313 if (_current !== null) {
8314 // An lazy component only mounts if it suspended inside a non-
8315 // concurrent tree, in an inconsistent state. We want to treat it like
8316 // a new mount, even though an empty version of it already committed.
8317 // Disconnect the alternate pointers.
8318 _current.alternate = null;
8319 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8320
8321 workInProgress.effectTag |= Placement;
8322 }
8323
8324 var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet.
8325 // Cancel and resume right after we know the tag.
8326
8327 cancelWorkTimer(workInProgress);
8328 var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type.
8329
8330 workInProgress.type = Component;
8331 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
8332 startWorkTimer(workInProgress);
8333 var resolvedProps = resolveDefaultProps(Component, props);
8334 var child;
8335
8336 switch (resolvedTag) {
8337 case FunctionComponent:
8338 {
8339 {
8340 validateFunctionComponentInDev(workInProgress, Component);
8341 workInProgress.type = Component = resolveFunctionForHotReloading(Component);
8342 }
8343
8344 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8345 break;
8346 }
8347
8348 case ClassComponent:
8349 {
8350 {
8351 workInProgress.type = Component = resolveClassForHotReloading(Component);
8352 }
8353
8354 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8355 break;
8356 }
8357
8358 case ForwardRef:
8359 {
8360 {
8361 workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
8362 }
8363
8364 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8365 break;
8366 }
8367
8368 case MemoComponent:
8369 {
8370 {
8371 if (workInProgress.type !== workInProgress.elementType) {
8372 var outerPropTypes = Component.propTypes;
8373
8374 if (outerPropTypes) {
8375 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
8376 'prop', getComponentName(Component), getCurrentFiberStackInDev);
8377 }
8378 }
8379 }
8380
8381 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
8382 updateExpirationTime, renderExpirationTime);
8383 break;
8384 }
8385
8386 default:
8387 {
8388 var hint = '';
8389
8390 {
8391 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
8392 hint = ' Did you wrap a component in React.lazy() more than once?';
8393 }
8394 } // This message intentionally doesn't mention ForwardRef or MemoComponent
8395 // because the fact that it's a separate type of work is an
8396 // implementation detail.
8397
8398
8399 (function () {
8400 {
8401 {
8402 throw ReactError(Error("Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint));
8403 }
8404 }
8405 })();
8406 }
8407 }
8408
8409 return child;
8410}
8411
8412function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
8413 if (_current !== null) {
8414 // An incomplete component only mounts if it suspended inside a non-
8415 // concurrent tree, in an inconsistent state. We want to treat it like
8416 // a new mount, even though an empty version of it already committed.
8417 // Disconnect the alternate pointers.
8418 _current.alternate = null;
8419 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8420
8421 workInProgress.effectTag |= Placement;
8422 } // Promote the fiber to a class and try rendering again.
8423
8424
8425 workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
8426 // Push context providers early to prevent context stack mismatches.
8427 // During mounting we don't know the child context yet as the instance doesn't exist.
8428 // We will invalidate the child context in finishClassComponent() right after rendering.
8429
8430 var hasContext;
8431
8432 if (isContextProvider(Component)) {
8433 hasContext = true;
8434 pushContextProvider(workInProgress);
8435 } else {
8436 hasContext = false;
8437 }
8438
8439 prepareToReadContext(workInProgress, renderExpirationTime);
8440 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8441 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8442 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
8443}
8444
8445function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
8446 if (_current !== null) {
8447 // An indeterminate component only mounts if it suspended inside a non-
8448 // concurrent tree, in an inconsistent state. We want to treat it like
8449 // a new mount, even though an empty version of it already committed.
8450 // Disconnect the alternate pointers.
8451 _current.alternate = null;
8452 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8453
8454 workInProgress.effectTag |= Placement;
8455 }
8456
8457 var props = workInProgress.pendingProps;
8458 var context;
8459
8460 if (!disableLegacyContext) {
8461 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
8462 context = getMaskedContext(workInProgress, unmaskedContext);
8463 }
8464
8465 prepareToReadContext(workInProgress, renderExpirationTime);
8466 var value;
8467
8468 {
8469 if (Component.prototype && typeof Component.prototype.render === 'function') {
8470 var componentName = getComponentName(Component) || 'Unknown';
8471
8472 if (!didWarnAboutBadClass[componentName]) {
8473 warningWithoutStack$1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
8474 didWarnAboutBadClass[componentName] = true;
8475 }
8476 }
8477
8478 if (workInProgress.mode & StrictMode) {
8479 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
8480 }
8481
8482 ReactCurrentOwner$2.current = workInProgress;
8483 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
8484 } // React DevTools reads this flag.
8485
8486
8487 workInProgress.effectTag |= PerformedWork;
8488
8489 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
8490 {
8491 var _componentName = getComponentName(Component) || 'Unknown';
8492
8493 if (!didWarnAboutModulePatternComponent[_componentName]) {
8494 warningWithoutStack$1(false, 'The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
8495 didWarnAboutModulePatternComponent[_componentName] = true;
8496 }
8497 } // Proceed under the assumption that this is a class instance
8498
8499
8500 workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
8501
8502 resetHooks(); // Push context providers early to prevent context stack mismatches.
8503 // During mounting we don't know the child context yet as the instance doesn't exist.
8504 // We will invalidate the child context in finishClassComponent() right after rendering.
8505
8506 var hasContext = false;
8507
8508 if (isContextProvider(Component)) {
8509 hasContext = true;
8510 pushContextProvider(workInProgress);
8511 } else {
8512 hasContext = false;
8513 }
8514
8515 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
8516 var getDerivedStateFromProps = Component.getDerivedStateFromProps;
8517
8518 if (typeof getDerivedStateFromProps === 'function') {
8519 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
8520 }
8521
8522 adoptClassInstance(workInProgress, value);
8523 mountClassInstance(workInProgress, Component, props, renderExpirationTime);
8524 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
8525 } else {
8526 // Proceed under the assumption that this is a function component
8527 workInProgress.tag = FunctionComponent;
8528
8529 {
8530 if (disableLegacyContext && Component.contextTypes) {
8531 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(Component) || 'Unknown');
8532 }
8533
8534 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8535 // Only double-render components with Hooks
8536 if (workInProgress.memoizedState !== null) {
8537 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
8538 }
8539 }
8540 }
8541
8542 reconcileChildren(null, workInProgress, value, renderExpirationTime);
8543
8544 {
8545 validateFunctionComponentInDev(workInProgress, Component);
8546 }
8547
8548 return workInProgress.child;
8549 }
8550}
8551
8552function validateFunctionComponentInDev(workInProgress, Component) {
8553 if (Component) {
8554 !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
8555 }
8556
8557 if (workInProgress.ref !== null) {
8558 var info = '';
8559 var ownerName = getCurrentFiberOwnerNameInDevOrNull();
8560
8561 if (ownerName) {
8562 info += '\n\nCheck the render method of `' + ownerName + '`.';
8563 }
8564
8565 var warningKey = ownerName || workInProgress._debugID || '';
8566 var debugSource = workInProgress._debugSource;
8567
8568 if (debugSource) {
8569 warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
8570 }
8571
8572 if (!didWarnAboutFunctionRefs[warningKey]) {
8573 didWarnAboutFunctionRefs[warningKey] = true;
8574 warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
8575 }
8576 }
8577
8578 if (warnAboutDefaultPropsOnFunctionComponents && Component.defaultProps !== undefined) {
8579 var componentName = getComponentName(Component) || 'Unknown';
8580
8581 if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
8582 warningWithoutStack$1(false, '%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
8583 didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
8584 }
8585 }
8586
8587 if (typeof Component.getDerivedStateFromProps === 'function') {
8588 var _componentName2 = getComponentName(Component) || 'Unknown';
8589
8590 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
8591 warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName2);
8592 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
8593 }
8594 }
8595
8596 if (typeof Component.contextType === 'object' && Component.contextType !== null) {
8597 var _componentName3 = getComponentName(Component) || 'Unknown';
8598
8599 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
8600 warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName3);
8601 didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
8602 }
8603 }
8604}
8605
8606var SUSPENDED_MARKER = {
8607 dehydrated: null,
8608 retryTime: Never
8609};
8610
8611function shouldRemainOnFallback(suspenseContext, current$$1, workInProgress) {
8612 // If the context is telling us that we should show a fallback, and we're not
8613 // already showing content, then we should show the fallback instead.
8614 return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current$$1 === null || current$$1.memoizedState !== null);
8615}
8616
8617function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
8618 var mode = workInProgress.mode;
8619 var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
8620
8621 {
8622 if (shouldSuspend(workInProgress)) {
8623 workInProgress.effectTag |= DidCapture;
8624 }
8625 }
8626
8627 var suspenseContext = suspenseStackCursor.current;
8628 var nextDidTimeout = false;
8629 var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
8630
8631 if (didSuspend || shouldRemainOnFallback(suspenseContext, current$$1, workInProgress)) {
8632 // Something in this boundary's subtree already suspended. Switch to
8633 // rendering the fallback children.
8634 nextDidTimeout = true;
8635 workInProgress.effectTag &= ~DidCapture;
8636 } else {
8637 // Attempting the main content
8638 if (current$$1 === null || current$$1.memoizedState !== null) {
8639 // This is a new mount or this boundary is already showing a fallback state.
8640 // Mark this subtree context as having at least one invisible parent that could
8641 // handle the fallback state.
8642 // Boundaries without fallbacks or should be avoided are not considered since
8643 // they cannot handle preferred fallback states.
8644 if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
8645 suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
8646 }
8647 }
8648 }
8649
8650 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
8651 pushSuspenseContext(workInProgress, suspenseContext);
8652
8653 {
8654 if ('maxDuration' in nextProps) {
8655 if (!didWarnAboutMaxDuration) {
8656 didWarnAboutMaxDuration = true;
8657 warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
8658 }
8659 }
8660 } // This next part is a bit confusing. If the children timeout, we switch to
8661 // showing the fallback children in place of the "primary" children.
8662 // However, we don't want to delete the primary children because then their
8663 // state will be lost (both the React state and the host state, e.g.
8664 // uncontrolled form inputs). Instead we keep them mounted and hide them.
8665 // Both the fallback children AND the primary children are rendered at the
8666 // same time. Once the primary children are un-suspended, we can delete
8667 // the fallback children — don't need to preserve their state.
8668 //
8669 // The two sets of children are siblings in the host environment, but
8670 // semantically, for purposes of reconciliation, they are two separate sets.
8671 // So we store them using two fragment fibers.
8672 //
8673 // However, we want to avoid allocating extra fibers for every placeholder.
8674 // They're only necessary when the children time out, because that's the
8675 // only time when both sets are mounted.
8676 //
8677 // So, the extra fragment fibers are only used if the children time out.
8678 // Otherwise, we render the primary children directly. This requires some
8679 // custom reconciliation logic to preserve the state of the primary
8680 // children. It's essentially a very basic form of re-parenting.
8681
8682
8683 if (current$$1 === null) {
8684 if (enableSuspenseServerRenderer) {
8685 // If we're currently hydrating, try to hydrate this boundary.
8686 // But only if this has a fallback.
8687 if (nextProps.fallback !== undefined) {
8688 tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component.
8689
8690 var suspenseState = workInProgress.memoizedState;
8691
8692 if (suspenseState !== null) {
8693 var dehydrated = suspenseState.dehydrated;
8694
8695 if (dehydrated !== null) {
8696 return mountDehydratedSuspenseComponent(workInProgress, dehydrated, renderExpirationTime);
8697 }
8698 }
8699 }
8700 } // This is the initial mount. This branch is pretty simple because there's
8701 // no previous state that needs to be preserved.
8702
8703
8704 if (nextDidTimeout) {
8705 // Mount separate fragments for primary and fallback children.
8706 var nextFallbackChildren = nextProps.fallback;
8707 var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
8708 primaryChildFragment.return = workInProgress;
8709
8710 if ((workInProgress.mode & BatchedMode) === NoMode) {
8711 // Outside of batched mode, we commit the effects from the
8712 // partially completed, timed-out tree, too.
8713 var progressedState = workInProgress.memoizedState;
8714 var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
8715 primaryChildFragment.child = progressedPrimaryChild;
8716 var progressedChild = progressedPrimaryChild;
8717
8718 while (progressedChild !== null) {
8719 progressedChild.return = primaryChildFragment;
8720 progressedChild = progressedChild.sibling;
8721 }
8722 }
8723
8724 var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
8725 fallbackChildFragment.return = workInProgress;
8726 primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the
8727 // fallback children.
8728
8729 workInProgress.memoizedState = SUSPENDED_MARKER;
8730 workInProgress.child = primaryChildFragment;
8731 return fallbackChildFragment;
8732 } else {
8733 // Mount the primary children without an intermediate fragment fiber.
8734 var nextPrimaryChildren = nextProps.children;
8735 workInProgress.memoizedState = null;
8736 return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
8737 }
8738 } else {
8739 // This is an update. This branch is more complicated because we need to
8740 // ensure the state of the primary children is preserved.
8741 var prevState = current$$1.memoizedState;
8742
8743 if (prevState !== null) {
8744 if (enableSuspenseServerRenderer) {
8745 var _dehydrated = prevState.dehydrated;
8746
8747 if (_dehydrated !== null) {
8748 if (!didSuspend) {
8749 return updateDehydratedSuspenseComponent(current$$1, workInProgress, _dehydrated, prevState, renderExpirationTime);
8750 } else if (workInProgress.memoizedState !== null) {
8751 // Something suspended and we should still be in dehydrated mode.
8752 // Leave the existing child in place.
8753 workInProgress.child = current$$1.child; // The dehydrated completion pass expects this flag to be there
8754 // but the normal suspense pass doesn't.
8755
8756 workInProgress.effectTag |= DidCapture;
8757 return null;
8758 } else {
8759 // Suspended but we should no longer be in dehydrated mode.
8760 // Therefore we now have to render the fallback. Wrap the children
8761 // in a fragment fiber to keep them separate from the fallback
8762 // children.
8763 var _nextFallbackChildren = nextProps.fallback;
8764
8765 var _primaryChildFragment = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
8766 // going to render this fragment.
8767 null, mode, NoWork, null);
8768
8769 _primaryChildFragment.return = workInProgress; // This is always null since we never want the previous child
8770 // that we're not going to hydrate.
8771
8772 _primaryChildFragment.child = null;
8773
8774 if ((workInProgress.mode & BatchedMode) === NoMode) {
8775 // Outside of batched mode, we commit the effects from the
8776 // partially completed, timed-out tree, too.
8777 var _progressedChild = _primaryChildFragment.child = workInProgress.child;
8778
8779 while (_progressedChild !== null) {
8780 _progressedChild.return = _primaryChildFragment;
8781 _progressedChild = _progressedChild.sibling;
8782 }
8783 } else {
8784 // We will have dropped the effect list which contains the deletion.
8785 // We need to reconcile to delete the current child.
8786 reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
8787 } // Because primaryChildFragment is a new fiber that we're inserting as the
8788 // parent of a new tree, we need to set its treeBaseDuration.
8789
8790
8791 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8792 // treeBaseDuration is the sum of all the child tree base durations.
8793 var treeBaseDuration = 0;
8794 var hiddenChild = _primaryChildFragment.child;
8795
8796 while (hiddenChild !== null) {
8797 treeBaseDuration += hiddenChild.treeBaseDuration;
8798 hiddenChild = hiddenChild.sibling;
8799 }
8800
8801 _primaryChildFragment.treeBaseDuration = treeBaseDuration;
8802 } // Create a fragment from the fallback children, too.
8803
8804
8805 var _fallbackChildFragment = createFiberFromFragment(_nextFallbackChildren, mode, renderExpirationTime, null);
8806
8807 _fallbackChildFragment.return = workInProgress;
8808 _primaryChildFragment.sibling = _fallbackChildFragment;
8809 _fallbackChildFragment.effectTag |= Placement;
8810 _primaryChildFragment.childExpirationTime = NoWork;
8811 workInProgress.memoizedState = SUSPENDED_MARKER;
8812 workInProgress.child = _primaryChildFragment; // Skip the primary children, and continue working on the
8813 // fallback children.
8814
8815 return _fallbackChildFragment;
8816 }
8817 }
8818 } // The current tree already timed out. That means each child set is
8819 // wrapped in a fragment fiber.
8820
8821
8822 var currentPrimaryChildFragment = current$$1.child;
8823 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
8824
8825 if (nextDidTimeout) {
8826 // Still timed out. Reuse the current primary children by cloning
8827 // its fragment. We're going to skip over these entirely.
8828 var _nextFallbackChildren2 = nextProps.fallback;
8829
8830 var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
8831
8832 _primaryChildFragment2.return = workInProgress;
8833
8834 if ((workInProgress.mode & BatchedMode) === NoMode) {
8835 // Outside of batched mode, we commit the effects from the
8836 // partially completed, timed-out tree, too.
8837 var _progressedState = workInProgress.memoizedState;
8838
8839 var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
8840
8841 if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
8842 _primaryChildFragment2.child = _progressedPrimaryChild;
8843 var _progressedChild2 = _progressedPrimaryChild;
8844
8845 while (_progressedChild2 !== null) {
8846 _progressedChild2.return = _primaryChildFragment2;
8847 _progressedChild2 = _progressedChild2.sibling;
8848 }
8849 }
8850 } // Because primaryChildFragment is a new fiber that we're inserting as the
8851 // parent of a new tree, we need to set its treeBaseDuration.
8852
8853
8854 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8855 // treeBaseDuration is the sum of all the child tree base durations.
8856 var _treeBaseDuration = 0;
8857 var _hiddenChild = _primaryChildFragment2.child;
8858
8859 while (_hiddenChild !== null) {
8860 _treeBaseDuration += _hiddenChild.treeBaseDuration;
8861 _hiddenChild = _hiddenChild.sibling;
8862 }
8863
8864 _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
8865 } // Clone the fallback child fragment, too. These we'll continue
8866 // working on.
8867
8868
8869 var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2, currentFallbackChildFragment.expirationTime);
8870
8871 _fallbackChildFragment2.return = workInProgress;
8872 _primaryChildFragment2.sibling = _fallbackChildFragment2;
8873 _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
8874 // fallback children.
8875
8876 workInProgress.memoizedState = SUSPENDED_MARKER;
8877 workInProgress.child = _primaryChildFragment2;
8878 return _fallbackChildFragment2;
8879 } else {
8880 // No longer suspended. Switch back to showing the primary children,
8881 // and remove the intermediate fragment fiber.
8882 var _nextPrimaryChildren = nextProps.children;
8883 var currentPrimaryChild = currentPrimaryChildFragment.child;
8884 var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime); // If this render doesn't suspend, we need to delete the fallback
8885 // children. Wait until the complete phase, after we've confirmed the
8886 // fallback is no longer needed.
8887 // TODO: Would it be better to store the fallback fragment on
8888 // the stateNode?
8889 // Continue rendering the children, like we normally do.
8890
8891 workInProgress.memoizedState = null;
8892 return workInProgress.child = primaryChild;
8893 }
8894 } else {
8895 // The current tree has not already timed out. That means the primary
8896 // children are not wrapped in a fragment fiber.
8897 var _currentPrimaryChild = current$$1.child;
8898
8899 if (nextDidTimeout) {
8900 // Timed out. Wrap the children in a fragment fiber to keep them
8901 // separate from the fallback children.
8902 var _nextFallbackChildren3 = nextProps.fallback;
8903
8904 var _primaryChildFragment3 = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
8905 // going to render this fragment.
8906 null, mode, NoWork, null);
8907
8908 _primaryChildFragment3.return = workInProgress;
8909 _primaryChildFragment3.child = _currentPrimaryChild;
8910
8911 if (_currentPrimaryChild !== null) {
8912 _currentPrimaryChild.return = _primaryChildFragment3;
8913 } // Even though we're creating a new fiber, there are no new children,
8914 // because we're reusing an already mounted tree. So we don't need to
8915 // schedule a placement.
8916 // primaryChildFragment.effectTag |= Placement;
8917
8918
8919 if ((workInProgress.mode & BatchedMode) === NoMode) {
8920 // Outside of batched mode, we commit the effects from the
8921 // partially completed, timed-out tree, too.
8922 var _progressedState2 = workInProgress.memoizedState;
8923
8924 var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
8925
8926 _primaryChildFragment3.child = _progressedPrimaryChild2;
8927 var _progressedChild3 = _progressedPrimaryChild2;
8928
8929 while (_progressedChild3 !== null) {
8930 _progressedChild3.return = _primaryChildFragment3;
8931 _progressedChild3 = _progressedChild3.sibling;
8932 }
8933 } // Because primaryChildFragment is a new fiber that we're inserting as the
8934 // parent of a new tree, we need to set its treeBaseDuration.
8935
8936
8937 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8938 // treeBaseDuration is the sum of all the child tree base durations.
8939 var _treeBaseDuration2 = 0;
8940 var _hiddenChild2 = _primaryChildFragment3.child;
8941
8942 while (_hiddenChild2 !== null) {
8943 _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
8944 _hiddenChild2 = _hiddenChild2.sibling;
8945 }
8946
8947 _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
8948 } // Create a fragment from the fallback children, too.
8949
8950
8951 var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null);
8952
8953 _fallbackChildFragment3.return = workInProgress;
8954 _primaryChildFragment3.sibling = _fallbackChildFragment3;
8955 _fallbackChildFragment3.effectTag |= Placement;
8956 _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
8957 // fallback children.
8958
8959 workInProgress.memoizedState = SUSPENDED_MARKER;
8960 workInProgress.child = _primaryChildFragment3;
8961 return _fallbackChildFragment3;
8962 } else {
8963 // Still haven't timed out. Continue rendering the children, like we
8964 // normally do.
8965 workInProgress.memoizedState = null;
8966 var _nextPrimaryChildren2 = nextProps.children;
8967 return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
8968 }
8969 }
8970 }
8971}
8972
8973function retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime) {
8974 // We're now not suspended nor dehydrated.
8975 workInProgress.memoizedState = null; // Retry with the full children.
8976
8977 var nextProps = workInProgress.pendingProps;
8978 var nextChildren = nextProps.children; // This will ensure that the children get Placement effects and
8979 // that the old child gets a Deletion effect.
8980 // We could also call forceUnmountCurrentAndReconcile.
8981
8982 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8983 return workInProgress.child;
8984}
8985
8986function mountDehydratedSuspenseComponent(workInProgress, suspenseInstance, renderExpirationTime) {
8987 // During the first pass, we'll bail out and not drill into the children.
8988 // Instead, we'll leave the content in place and try to hydrate it later.
8989 if ((workInProgress.mode & BatchedMode) === NoMode) {
8990 {
8991 warning$1(false, 'Cannot hydrate Suspense in legacy mode. Switch from ' + 'ReactDOM.hydrate(element, container) to ' + 'ReactDOM.unstable_createSyncRoot(container, { hydrate: true })' + '.render(element) or remove the Suspense components from ' + 'the server rendered components.');
8992 }
8993
8994 workInProgress.expirationTime = Sync;
8995 } else if (isSuspenseInstanceFallback(suspenseInstance)) {
8996 // This is a client-only boundary. Since we won't get any content from the server
8997 // for this, we need to schedule that at a higher priority based on when it would
8998 // have timed out. In theory we could render it in this pass but it would have the
8999 // wrong priority associated with it and will prevent hydration of parent path.
9000 // Instead, we'll leave work left on it to render it in a separate commit.
9001 // TODO This time should be the time at which the server rendered response that is
9002 // a parent to this boundary was displayed. However, since we currently don't have
9003 // a protocol to transfer that time, we'll just estimate it by using the current
9004 // time. This will mean that Suspense timeouts are slightly shifted to later than
9005 // they should be.
9006 var serverDisplayTime = requestCurrentTime(); // Schedule a normal pri update to render this content.
9007
9008 var newExpirationTime = computeAsyncExpiration(serverDisplayTime);
9009
9010 if (enableSchedulerTracing) {
9011 markSpawnedWork(newExpirationTime);
9012 }
9013
9014 workInProgress.expirationTime = newExpirationTime;
9015 } else {
9016 // We'll continue hydrating the rest at offscreen priority since we'll already
9017 // be showing the right content coming from the server, it is no rush.
9018 workInProgress.expirationTime = Never;
9019
9020 if (enableSchedulerTracing) {
9021 markSpawnedWork(Never);
9022 }
9023 }
9024
9025 return null;
9026}
9027
9028function updateDehydratedSuspenseComponent(current$$1, workInProgress, suspenseInstance, suspenseState, renderExpirationTime) {
9029 // We should never be hydrating at this point because it is the first pass,
9030 // but after we've already committed once.
9031 warnIfHydrating();
9032
9033 if ((workInProgress.mode & BatchedMode) === NoMode) {
9034 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
9035 }
9036
9037 if (isSuspenseInstanceFallback(suspenseInstance)) {
9038 // This boundary is in a permanent fallback state. In this case, we'll never
9039 // get an update and we'll never be able to hydrate the final content. Let's just try the
9040 // client side render instead.
9041 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
9042 } // We use childExpirationTime to indicate that a child might depend on context, so if
9043 // any context has changed, we need to treat is as if the input might have changed.
9044
9045
9046 var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
9047
9048 if (didReceiveUpdate || hasContextChanged$$1) {
9049 // This boundary has changed since the first render. This means that we are now unable to
9050 // hydrate it. We might still be able to hydrate it using an earlier expiration time, if
9051 // we are rendering at lower expiration than sync.
9052 if (renderExpirationTime < Sync) {
9053 if (suspenseState.retryTime <= renderExpirationTime) {
9054 // This render is even higher pri than we've seen before, let's try again
9055 // at even higher pri.
9056 var attemptHydrationAtExpirationTime = renderExpirationTime + 1;
9057 suspenseState.retryTime = attemptHydrationAtExpirationTime;
9058 scheduleWork(current$$1, attemptHydrationAtExpirationTime); // TODO: Early abort this render.
9059 } else {// We have already tried to ping at a higher priority than we're rendering with
9060 // so if we got here, we must have failed to hydrate at those levels. We must
9061 // now give up. Instead, we're going to delete the whole subtree and instead inject
9062 // a new real Suspense boundary to take its place, which may render content
9063 // or fallback. This might suspend for a while and if it does we might still have
9064 // an opportunity to hydrate before this pass commits.
9065 }
9066 } // If we have scheduled higher pri work above, this will probably just abort the render
9067 // since we now have higher priority work, but in case it doesn't, we need to prepare to
9068 // render something, if we time out. Even if that requires us to delete everything and
9069 // skip hydration.
9070 // Delay having to do this as long as the suspense timeout allows us.
9071
9072
9073 renderDidSuspendDelayIfPossible();
9074 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
9075 } else if (isSuspenseInstancePending(suspenseInstance)) {
9076 // This component is still pending more data from the server, so we can't hydrate its
9077 // content. We treat it as if this component suspended itself. It might seem as if
9078 // we could just try to render it client-side instead. However, this will perform a
9079 // lot of unnecessary work and is unlikely to complete since it often will suspend
9080 // on missing data anyway. Additionally, the server might be able to render more
9081 // than we can on the client yet. In that case we'd end up with more fallback states
9082 // on the client than if we just leave it alone. If the server times out or errors
9083 // these should update this boundary to the permanent Fallback state instead.
9084 // Mark it as having captured (i.e. suspended).
9085 workInProgress.effectTag |= DidCapture; // Leave the child in place. I.e. the dehydrated fragment.
9086
9087 workInProgress.child = current$$1.child; // Register a callback to retry this boundary once the server has sent the result.
9088
9089 registerSuspenseInstanceRetry(suspenseInstance, retryDehydratedSuspenseBoundary.bind(null, current$$1));
9090 return null;
9091 } else {
9092 // This is the first attempt.
9093 reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress, suspenseInstance);
9094 var nextProps = workInProgress.pendingProps;
9095 var nextChildren = nextProps.children;
9096 var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
9097 var node = child;
9098
9099 while (node) {
9100 // Mark each child as hydrating. This is a fast path to know whether this
9101 // tree is part of a hydrating tree. This is used to determine if a child
9102 // node has fully mounted yet, and for scheduling event replaying.
9103 // Conceptually this is similar to Placement in that a new subtree is
9104 // inserted into the React tree here. It just happens to not need DOM
9105 // mutations because it already exists.
9106 node.effectTag |= Hydrating;
9107 node = node.sibling;
9108 }
9109
9110 workInProgress.child = child;
9111 return workInProgress.child;
9112 }
9113}
9114
9115function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
9116 // Mark any Suspense boundaries with fallbacks as having work to do.
9117 // If they were previously forced into fallbacks, they may now be able
9118 // to unblock.
9119 var node = firstChild;
9120
9121 while (node !== null) {
9122 if (node.tag === SuspenseComponent) {
9123 var state = node.memoizedState;
9124
9125 if (state !== null) {
9126 if (node.expirationTime < renderExpirationTime) {
9127 node.expirationTime = renderExpirationTime;
9128 }
9129
9130 var alternate = node.alternate;
9131
9132 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
9133 alternate.expirationTime = renderExpirationTime;
9134 }
9135
9136 scheduleWorkOnParentPath(node.return, renderExpirationTime);
9137 }
9138 } else if (node.child !== null) {
9139 node.child.return = node;
9140 node = node.child;
9141 continue;
9142 }
9143
9144 if (node === workInProgress) {
9145 return;
9146 }
9147
9148 while (node.sibling === null) {
9149 if (node.return === null || node.return === workInProgress) {
9150 return;
9151 }
9152
9153 node = node.return;
9154 }
9155
9156 node.sibling.return = node.return;
9157 node = node.sibling;
9158 }
9159}
9160
9161function findLastContentRow(firstChild) {
9162 // This is going to find the last row among these children that is already
9163 // showing content on the screen, as opposed to being in fallback state or
9164 // new. If a row has multiple Suspense boundaries, any of them being in the
9165 // fallback state, counts as the whole row being in a fallback state.
9166 // Note that the "rows" will be workInProgress, but any nested children
9167 // will still be current since we haven't rendered them yet. The mounted
9168 // order may not be the same as the new order. We use the new order.
9169 var row = firstChild;
9170 var lastContentRow = null;
9171
9172 while (row !== null) {
9173 var currentRow = row.alternate; // New rows can't be content rows.
9174
9175 if (currentRow !== null && findFirstSuspended(currentRow) === null) {
9176 lastContentRow = row;
9177 }
9178
9179 row = row.sibling;
9180 }
9181
9182 return lastContentRow;
9183}
9184
9185function validateRevealOrder(revealOrder) {
9186 {
9187 if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
9188 didWarnAboutRevealOrder[revealOrder] = true;
9189
9190 if (typeof revealOrder === 'string') {
9191 switch (revealOrder.toLowerCase()) {
9192 case 'together':
9193 case 'forwards':
9194 case 'backwards':
9195 {
9196 warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
9197 break;
9198 }
9199
9200 case 'forward':
9201 case 'backward':
9202 {
9203 warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
9204 break;
9205 }
9206
9207 default:
9208 warning$1(false, '"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
9209 break;
9210 }
9211 } else {
9212 warning$1(false, '%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
9213 }
9214 }
9215 }
9216}
9217
9218function validateTailOptions(tailMode, revealOrder) {
9219 {
9220 if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
9221 if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
9222 didWarnAboutTailOptions[tailMode] = true;
9223 warning$1(false, '"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
9224 } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
9225 didWarnAboutTailOptions[tailMode] = true;
9226 warning$1(false, '<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
9227 }
9228 }
9229 }
9230}
9231
9232function validateSuspenseListNestedChild(childSlot, index) {
9233 {
9234 var isArray = Array.isArray(childSlot);
9235 var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
9236
9237 if (isArray || isIterable) {
9238 var type = isArray ? 'array' : 'iterable';
9239 warning$1(false, 'A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type);
9240 return false;
9241 }
9242 }
9243
9244 return true;
9245}
9246
9247function validateSuspenseListChildren(children, revealOrder) {
9248 {
9249 if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
9250 if (Array.isArray(children)) {
9251 for (var i = 0; i < children.length; i++) {
9252 if (!validateSuspenseListNestedChild(children[i], i)) {
9253 return;
9254 }
9255 }
9256 } else {
9257 var iteratorFn = getIteratorFn(children);
9258
9259 if (typeof iteratorFn === 'function') {
9260 var childrenIterator = iteratorFn.call(children);
9261
9262 if (childrenIterator) {
9263 var step = childrenIterator.next();
9264 var _i = 0;
9265
9266 for (; !step.done; step = childrenIterator.next()) {
9267 if (!validateSuspenseListNestedChild(step.value, _i)) {
9268 return;
9269 }
9270
9271 _i++;
9272 }
9273 }
9274 } else {
9275 warning$1(false, 'A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder);
9276 }
9277 }
9278 }
9279 }
9280}
9281
9282function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode) {
9283 var renderState = workInProgress.memoizedState;
9284
9285 if (renderState === null) {
9286 workInProgress.memoizedState = {
9287 isBackwards: isBackwards,
9288 rendering: null,
9289 last: lastContentRow,
9290 tail: tail,
9291 tailExpiration: 0,
9292 tailMode: tailMode
9293 };
9294 } else {
9295 // We can reuse the existing object from previous renders.
9296 renderState.isBackwards = isBackwards;
9297 renderState.rendering = null;
9298 renderState.last = lastContentRow;
9299 renderState.tail = tail;
9300 renderState.tailExpiration = 0;
9301 renderState.tailMode = tailMode;
9302 }
9303} // This can end up rendering this component multiple passes.
9304// The first pass splits the children fibers into two sets. A head and tail.
9305// We first render the head. If anything is in fallback state, we do another
9306// pass through beginWork to rerender all children (including the tail) with
9307// the force suspend context. If the first render didn't have anything in
9308// in fallback state. Then we render each row in the tail one-by-one.
9309// That happens in the completeWork phase without going back to beginWork.
9310
9311
9312function updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime) {
9313 var nextProps = workInProgress.pendingProps;
9314 var revealOrder = nextProps.revealOrder;
9315 var tailMode = nextProps.tail;
9316 var newChildren = nextProps.children;
9317 validateRevealOrder(revealOrder);
9318 validateTailOptions(tailMode, revealOrder);
9319 validateSuspenseListChildren(newChildren, revealOrder);
9320 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9321 var suspenseContext = suspenseStackCursor.current;
9322 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
9323
9324 if (shouldForceFallback) {
9325 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
9326 workInProgress.effectTag |= DidCapture;
9327 } else {
9328 var didSuspendBefore = current$$1 !== null && (current$$1.effectTag & DidCapture) !== NoEffect;
9329
9330 if (didSuspendBefore) {
9331 // If we previously forced a fallback, we need to schedule work
9332 // on any nested boundaries to let them know to try to render
9333 // again. This is the same as context updating.
9334 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
9335 }
9336
9337 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
9338 }
9339
9340 pushSuspenseContext(workInProgress, suspenseContext);
9341
9342 if ((workInProgress.mode & BatchedMode) === NoMode) {
9343 // Outside of batched mode, SuspenseList doesn't work so we just
9344 // use make it a noop by treating it as the default revealOrder.
9345 workInProgress.memoizedState = null;
9346 } else {
9347 switch (revealOrder) {
9348 case 'forwards':
9349 {
9350 var lastContentRow = findLastContentRow(workInProgress.child);
9351 var tail;
9352
9353 if (lastContentRow === null) {
9354 // The whole list is part of the tail.
9355 // TODO: We could fast path by just rendering the tail now.
9356 tail = workInProgress.child;
9357 workInProgress.child = null;
9358 } else {
9359 // Disconnect the tail rows after the content row.
9360 // We're going to render them separately later.
9361 tail = lastContentRow.sibling;
9362 lastContentRow.sibling = null;
9363 }
9364
9365 initSuspenseListRenderState(workInProgress, false, // isBackwards
9366 tail, lastContentRow, tailMode);
9367 break;
9368 }
9369
9370 case 'backwards':
9371 {
9372 // We're going to find the first row that has existing content.
9373 // At the same time we're going to reverse the list of everything
9374 // we pass in the meantime. That's going to be our tail in reverse
9375 // order.
9376 var _tail = null;
9377 var row = workInProgress.child;
9378 workInProgress.child = null;
9379
9380 while (row !== null) {
9381 var currentRow = row.alternate; // New rows can't be content rows.
9382
9383 if (currentRow !== null && findFirstSuspended(currentRow) === null) {
9384 // This is the beginning of the main content.
9385 workInProgress.child = row;
9386 break;
9387 }
9388
9389 var nextRow = row.sibling;
9390 row.sibling = _tail;
9391 _tail = row;
9392 row = nextRow;
9393 } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
9394
9395
9396 initSuspenseListRenderState(workInProgress, true, // isBackwards
9397 _tail, null, // last
9398 tailMode);
9399 break;
9400 }
9401
9402 case 'together':
9403 {
9404 initSuspenseListRenderState(workInProgress, false, // isBackwards
9405 null, // tail
9406 null, // last
9407 undefined);
9408 break;
9409 }
9410
9411 default:
9412 {
9413 // The default reveal order is the same as not having
9414 // a boundary.
9415 workInProgress.memoizedState = null;
9416 }
9417 }
9418 }
9419
9420 return workInProgress.child;
9421}
9422
9423function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
9424 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
9425 var nextChildren = workInProgress.pendingProps;
9426
9427 if (current$$1 === null) {
9428 // Portals are special because we don't append the children during mount
9429 // but at commit. Therefore we need to track insertions which the normal
9430 // flow doesn't do during mount. This doesn't happen at the root because
9431 // the root always starts with a "current" with a null child.
9432 // TODO: Consider unifying this with how the root works.
9433 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
9434 } else {
9435 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9436 }
9437
9438 return workInProgress.child;
9439}
9440
9441function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
9442 var providerType = workInProgress.type;
9443 var context = providerType._context;
9444 var newProps = workInProgress.pendingProps;
9445 var oldProps = workInProgress.memoizedProps;
9446 var newValue = newProps.value;
9447
9448 {
9449 var providerPropTypes = workInProgress.type.propTypes;
9450
9451 if (providerPropTypes) {
9452 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
9453 }
9454 }
9455
9456 pushProvider(workInProgress, newValue);
9457
9458 if (oldProps !== null) {
9459 var oldValue = oldProps.value;
9460 var changedBits = calculateChangedBits(context, newValue, oldValue);
9461
9462 if (changedBits === 0) {
9463 // No change. Bailout early if children are the same.
9464 if (oldProps.children === newProps.children && !hasContextChanged()) {
9465 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9466 }
9467 } else {
9468 // The context value changed. Search for matching consumers and schedule
9469 // them to update.
9470 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
9471 }
9472 }
9473
9474 var newChildren = newProps.children;
9475 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9476 return workInProgress.child;
9477}
9478
9479var hasWarnedAboutUsingContextAsConsumer = false;
9480
9481function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
9482 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
9483 // DEV mode, we create a separate object for Context.Consumer that acts
9484 // like a proxy to Context. This proxy object adds unnecessary code in PROD
9485 // so we use the old behaviour (Context.Consumer references Context) to
9486 // reduce size and overhead. The separate object references context via
9487 // a property called "_context", which also gives us the ability to check
9488 // in DEV mode if this property exists or not and warn if it does not.
9489
9490 {
9491 if (context._context === undefined) {
9492 // This may be because it's a Context (rather than a Consumer).
9493 // Or it may be because it's older React where they're the same thing.
9494 // We only want to warn if we're sure it's a new React.
9495 if (context !== context.Consumer) {
9496 if (!hasWarnedAboutUsingContextAsConsumer) {
9497 hasWarnedAboutUsingContextAsConsumer = true;
9498 warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
9499 }
9500 }
9501 } else {
9502 context = context._context;
9503 }
9504 }
9505
9506 var newProps = workInProgress.pendingProps;
9507 var render = newProps.children;
9508
9509 {
9510 !(typeof render === 'function') ? warningWithoutStack$1(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
9511 }
9512
9513 prepareToReadContext(workInProgress, renderExpirationTime);
9514 var newValue = readContext(context, newProps.unstable_observedBits);
9515 var newChildren;
9516
9517 {
9518 ReactCurrentOwner$2.current = workInProgress;
9519 setCurrentPhase('render');
9520 newChildren = render(newValue);
9521 setCurrentPhase(null);
9522 } // React DevTools reads this flag.
9523
9524
9525 workInProgress.effectTag |= PerformedWork;
9526 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9527 return workInProgress.child;
9528}
9529
9530function updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime) {
9531 var fundamentalImpl = workInProgress.type.impl;
9532
9533 if (fundamentalImpl.reconcileChildren === false) {
9534 return null;
9535 }
9536
9537 var nextProps = workInProgress.pendingProps;
9538 var nextChildren = nextProps.children;
9539 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9540 return workInProgress.child;
9541}
9542
9543function updateScopeComponent(current$$1, workInProgress, renderExpirationTime) {
9544 var nextProps = workInProgress.pendingProps;
9545 var nextChildren = nextProps.children;
9546 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9547 return workInProgress.child;
9548}
9549
9550function markWorkInProgressReceivedUpdate() {
9551 didReceiveUpdate = true;
9552}
9553
9554function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
9555 cancelWorkTimer(workInProgress);
9556
9557 if (current$$1 !== null) {
9558 // Reuse previous dependencies
9559 workInProgress.dependencies = current$$1.dependencies;
9560 }
9561
9562 if (enableProfilerTimer) {
9563 // Don't update "base" render times for bailouts.
9564 stopProfilerTimerIfRunning(workInProgress);
9565 }
9566
9567 var updateExpirationTime = workInProgress.expirationTime;
9568
9569 if (updateExpirationTime !== NoWork) {
9570 markUnprocessedUpdateTime(updateExpirationTime);
9571 } // Check if the children have any pending work.
9572
9573
9574 var childExpirationTime = workInProgress.childExpirationTime;
9575
9576 if (childExpirationTime < renderExpirationTime) {
9577 // The children don't have any work either. We can skip them.
9578 // TODO: Once we add back resuming, we should check if the children are
9579 // a work-in-progress set. If so, we need to transfer their effects.
9580 return null;
9581 } else {
9582 // This fiber doesn't have work, but its subtree does. Clone the child
9583 // fibers and continue.
9584 cloneChildFibers(current$$1, workInProgress);
9585 return workInProgress.child;
9586 }
9587}
9588
9589function remountFiber(current$$1, oldWorkInProgress, newWorkInProgress) {
9590 {
9591 var returnFiber = oldWorkInProgress.return;
9592
9593 if (returnFiber === null) {
9594 throw new Error('Cannot swap the root fiber.');
9595 } // Disconnect from the old current.
9596 // It will get deleted.
9597
9598
9599 current$$1.alternate = null;
9600 oldWorkInProgress.alternate = null; // Connect to the new tree.
9601
9602 newWorkInProgress.index = oldWorkInProgress.index;
9603 newWorkInProgress.sibling = oldWorkInProgress.sibling;
9604 newWorkInProgress.return = oldWorkInProgress.return;
9605 newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
9606
9607 if (oldWorkInProgress === returnFiber.child) {
9608 returnFiber.child = newWorkInProgress;
9609 } else {
9610 var prevSibling = returnFiber.child;
9611
9612 if (prevSibling === null) {
9613 throw new Error('Expected parent to have a child.');
9614 }
9615
9616 while (prevSibling.sibling !== oldWorkInProgress) {
9617 prevSibling = prevSibling.sibling;
9618
9619 if (prevSibling === null) {
9620 throw new Error('Expected to find the previous sibling.');
9621 }
9622 }
9623
9624 prevSibling.sibling = newWorkInProgress;
9625 } // Delete the old fiber and place the new one.
9626 // Since the old fiber is disconnected, we have to schedule it manually.
9627
9628
9629 var last = returnFiber.lastEffect;
9630
9631 if (last !== null) {
9632 last.nextEffect = current$$1;
9633 returnFiber.lastEffect = current$$1;
9634 } else {
9635 returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
9636 }
9637
9638 current$$1.nextEffect = null;
9639 current$$1.effectTag = Deletion;
9640 newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber.
9641
9642 return newWorkInProgress;
9643 }
9644}
9645
9646function beginWork$1(current$$1, workInProgress, renderExpirationTime) {
9647 var updateExpirationTime = workInProgress.expirationTime;
9648
9649 {
9650 if (workInProgress._debugNeedsRemount && current$$1 !== null) {
9651 // This will restart the begin phase with a new fiber.
9652 return remountFiber(current$$1, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
9653 }
9654 }
9655
9656 if (current$$1 !== null) {
9657 var oldProps = current$$1.memoizedProps;
9658 var newProps = workInProgress.pendingProps;
9659
9660 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:
9661 workInProgress.type !== current$$1.type)) {
9662 // If props or context changed, mark the fiber as having performed work.
9663 // This may be unset if the props are determined to be equal later (memo).
9664 didReceiveUpdate = true;
9665 } else if (updateExpirationTime < renderExpirationTime) {
9666 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
9667 // the begin phase. There's still some bookkeeping we that needs to be done
9668 // in this optimized path, mostly pushing stuff onto the stack.
9669
9670 switch (workInProgress.tag) {
9671 case HostRoot:
9672 pushHostRootContext(workInProgress);
9673 resetHydrationState();
9674 break;
9675
9676 case HostComponent:
9677 pushHostContext(workInProgress);
9678
9679 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
9680 if (enableSchedulerTracing) {
9681 markSpawnedWork(Never);
9682 } // Schedule this fiber to re-render at offscreen priority. Then bailout.
9683
9684
9685 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
9686 return null;
9687 }
9688
9689 break;
9690
9691 case ClassComponent:
9692 {
9693 var Component = workInProgress.type;
9694
9695 if (isContextProvider(Component)) {
9696 pushContextProvider(workInProgress);
9697 }
9698
9699 break;
9700 }
9701
9702 case HostPortal:
9703 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
9704 break;
9705
9706 case ContextProvider:
9707 {
9708 var newValue = workInProgress.memoizedProps.value;
9709 pushProvider(workInProgress, newValue);
9710 break;
9711 }
9712
9713 case Profiler:
9714 if (enableProfilerTimer) {
9715 workInProgress.effectTag |= Update;
9716 }
9717
9718 break;
9719
9720 case SuspenseComponent:
9721 {
9722 var state = workInProgress.memoizedState;
9723
9724 if (state !== null) {
9725 if (enableSuspenseServerRenderer) {
9726 if (state.dehydrated !== null) {
9727 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // We know that this component will suspend again because if it has
9728 // been unsuspended it has committed as a resolved Suspense component.
9729 // If it needs to be retried, it should have work scheduled on it.
9730
9731 workInProgress.effectTag |= DidCapture;
9732 break;
9733 }
9734 } // If this boundary is currently timed out, we need to decide
9735 // whether to retry the primary children, or to skip over it and
9736 // go straight to the fallback. Check the priority of the primary
9737 // child fragment.
9738
9739
9740 var primaryChildFragment = workInProgress.child;
9741 var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
9742
9743 if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
9744 // The primary children have pending work. Use the normal path
9745 // to attempt to render the primary children again.
9746 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
9747 } else {
9748 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient
9749 // priority. Bailout.
9750
9751 var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9752
9753 if (child !== null) {
9754 // The fallback children have pending work. Skip over the
9755 // primary children and work on the fallback.
9756 return child.sibling;
9757 } else {
9758 return null;
9759 }
9760 }
9761 } else {
9762 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
9763 }
9764
9765 break;
9766 }
9767
9768 case SuspenseListComponent:
9769 {
9770 var didSuspendBefore = (current$$1.effectTag & DidCapture) !== NoEffect;
9771 var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
9772
9773 if (didSuspendBefore) {
9774 if (hasChildWork) {
9775 // If something was in fallback state last time, and we have all the
9776 // same children then we're still in progressive loading state.
9777 // Something might get unblocked by state updates or retries in the
9778 // tree which will affect the tail. So we need to use the normal
9779 // path to compute the correct tail.
9780 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
9781 } // If none of the children had any work, that means that none of
9782 // them got retried so they'll still be blocked in the same way
9783 // as before. We can fast bail out.
9784
9785
9786 workInProgress.effectTag |= DidCapture;
9787 } // If nothing suspended before and we're rendering the same children,
9788 // then the tail doesn't matter. Anything new that suspends will work
9789 // in the "together" mode, so we can continue from the state we had.
9790
9791
9792 var renderState = workInProgress.memoizedState;
9793
9794 if (renderState !== null) {
9795 // Reset to the "together" mode in case we've started a different
9796 // update in the past but didn't complete it.
9797 renderState.rendering = null;
9798 renderState.tail = null;
9799 }
9800
9801 pushSuspenseContext(workInProgress, suspenseStackCursor.current);
9802
9803 if (hasChildWork) {
9804 break;
9805 } else {
9806 // If none of the children had any work, that means that none of
9807 // them got retried so they'll still be blocked in the same way
9808 // as before. We can fast bail out.
9809 return null;
9810 }
9811 }
9812 }
9813
9814 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9815 } else {
9816 // An update was scheduled on this fiber, but there are no new props
9817 // nor legacy context. Set this to false. If an update queue or context
9818 // consumer produces a changed value, it will set this to true. Otherwise,
9819 // the component will assume the children have not changed and bail out.
9820 didReceiveUpdate = false;
9821 }
9822 } else {
9823 didReceiveUpdate = false;
9824 } // Before entering the begin phase, clear the expiration time.
9825
9826
9827 workInProgress.expirationTime = NoWork;
9828
9829 switch (workInProgress.tag) {
9830 case IndeterminateComponent:
9831 {
9832 return mountIndeterminateComponent(current$$1, workInProgress, workInProgress.type, renderExpirationTime);
9833 }
9834
9835 case LazyComponent:
9836 {
9837 var elementType = workInProgress.elementType;
9838 return mountLazyComponent(current$$1, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
9839 }
9840
9841 case FunctionComponent:
9842 {
9843 var _Component = workInProgress.type;
9844 var unresolvedProps = workInProgress.pendingProps;
9845 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
9846 return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
9847 }
9848
9849 case ClassComponent:
9850 {
9851 var _Component2 = workInProgress.type;
9852 var _unresolvedProps = workInProgress.pendingProps;
9853
9854 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
9855
9856 return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
9857 }
9858
9859 case HostRoot:
9860 return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
9861
9862 case HostComponent:
9863 return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
9864
9865 case HostText:
9866 return updateHostText(current$$1, workInProgress);
9867
9868 case SuspenseComponent:
9869 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
9870
9871 case HostPortal:
9872 return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
9873
9874 case ForwardRef:
9875 {
9876 var type = workInProgress.type;
9877 var _unresolvedProps2 = workInProgress.pendingProps;
9878
9879 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
9880
9881 return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
9882 }
9883
9884 case Fragment:
9885 return updateFragment(current$$1, workInProgress, renderExpirationTime);
9886
9887 case Mode:
9888 return updateMode(current$$1, workInProgress, renderExpirationTime);
9889
9890 case Profiler:
9891 return updateProfiler(current$$1, workInProgress, renderExpirationTime);
9892
9893 case ContextProvider:
9894 return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
9895
9896 case ContextConsumer:
9897 return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
9898
9899 case MemoComponent:
9900 {
9901 var _type2 = workInProgress.type;
9902 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
9903
9904 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
9905
9906 {
9907 if (workInProgress.type !== workInProgress.elementType) {
9908 var outerPropTypes = _type2.propTypes;
9909
9910 if (outerPropTypes) {
9911 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
9912 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
9913 }
9914 }
9915 }
9916
9917 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
9918 return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
9919 }
9920
9921 case SimpleMemoComponent:
9922 {
9923 return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
9924 }
9925
9926 case IncompleteClassComponent:
9927 {
9928 var _Component3 = workInProgress.type;
9929 var _unresolvedProps4 = workInProgress.pendingProps;
9930
9931 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
9932
9933 return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
9934 }
9935
9936 case SuspenseListComponent:
9937 {
9938 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
9939 }
9940
9941 case FundamentalComponent:
9942 {
9943 if (enableFundamentalAPI) {
9944 return updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime);
9945 }
9946
9947 break;
9948 }
9949
9950 case ScopeComponent:
9951 {
9952 if (enableScopeAPI) {
9953 return updateScopeComponent(current$$1, workInProgress, renderExpirationTime);
9954 }
9955
9956 break;
9957 }
9958 }
9959
9960 (function () {
9961 {
9962 {
9963 throw ReactError(Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue."));
9964 }
9965 }
9966 })();
9967}
9968
9969function createFundamentalStateInstance(currentFiber, props, impl, state) {
9970 return {
9971 currentFiber: currentFiber,
9972 impl: impl,
9973 instance: null,
9974 prevProps: null,
9975 props: props,
9976 state: state
9977 };
9978}
9979
9980function isFiberSuspenseAndTimedOut(fiber) {
9981 return fiber.tag === SuspenseComponent && fiber.memoizedState !== null;
9982}
9983
9984function getSuspenseFallbackChild(fiber) {
9985 return fiber.child.sibling.child;
9986}
9987
9988function collectScopedNodes(node, fn, scopedNodes) {
9989 if (enableScopeAPI) {
9990 if (node.tag === HostComponent) {
9991 var _type = node.type,
9992 memoizedProps = node.memoizedProps;
9993
9994 if (fn(_type, memoizedProps) === true) {
9995 scopedNodes.push(getPublicInstance(node.stateNode));
9996 }
9997 }
9998
9999 var child = node.child;
10000
10001 if (isFiberSuspenseAndTimedOut(node)) {
10002 child = getSuspenseFallbackChild(node);
10003 }
10004
10005 if (child !== null) {
10006 collectScopedNodesFromChildren(child, fn, scopedNodes);
10007 }
10008 }
10009}
10010
10011function collectScopedNodesFromChildren(startingChild, fn, scopedNodes) {
10012 var child = startingChild;
10013
10014 while (child !== null) {
10015 collectScopedNodes(child, fn, scopedNodes);
10016 child = child.sibling;
10017 }
10018}
10019
10020function collectNearestScopeMethods(node, scope, childrenScopes) {
10021 if (isValidScopeNode(node, scope)) {
10022 childrenScopes.push(node.stateNode.methods);
10023 } else {
10024 var child = node.child;
10025
10026 if (isFiberSuspenseAndTimedOut(node)) {
10027 child = getSuspenseFallbackChild(node);
10028 }
10029
10030 if (child !== null) {
10031 collectNearestChildScopeMethods(child, scope, childrenScopes);
10032 }
10033 }
10034}
10035
10036function collectNearestChildScopeMethods(startingChild, scope, childrenScopes) {
10037 var child = startingChild;
10038
10039 while (child !== null) {
10040 collectNearestScopeMethods(child, scope, childrenScopes);
10041 child = child.sibling;
10042 }
10043}
10044
10045function isValidScopeNode(node, scope) {
10046 return node.tag === ScopeComponent && node.type === scope;
10047}
10048
10049function createScopeMethods(scope, instance) {
10050 var fn = scope.fn;
10051 return {
10052 getChildren: function () {
10053 var currentFiber = instance.fiber;
10054 var child = currentFiber.child;
10055 var childrenScopes = [];
10056
10057 if (child !== null) {
10058 collectNearestChildScopeMethods(child, scope, childrenScopes);
10059 }
10060
10061 return childrenScopes.length === 0 ? null : childrenScopes;
10062 },
10063 getChildrenFromRoot: function () {
10064 var currentFiber = instance.fiber;
10065 var node = currentFiber;
10066
10067 while (node !== null) {
10068 var parent = node.return;
10069
10070 if (parent === null) {
10071 break;
10072 }
10073
10074 node = parent;
10075
10076 if (node.tag === ScopeComponent && node.type === scope) {
10077 break;
10078 }
10079 }
10080
10081 var childrenScopes = [];
10082 collectNearestChildScopeMethods(node.child, scope, childrenScopes);
10083 return childrenScopes.length === 0 ? null : childrenScopes;
10084 },
10085 getParent: function () {
10086 var node = instance.fiber.return;
10087
10088 while (node !== null) {
10089 if (node.tag === ScopeComponent && node.type === scope) {
10090 return node.stateNode.methods;
10091 }
10092
10093 node = node.return;
10094 }
10095
10096 return null;
10097 },
10098 getProps: function () {
10099 var currentFiber = instance.fiber;
10100 return currentFiber.memoizedProps;
10101 },
10102 getScopedNodes: function () {
10103 var currentFiber = instance.fiber;
10104 var child = currentFiber.child;
10105 var scopedNodes = [];
10106
10107 if (child !== null) {
10108 collectScopedNodesFromChildren(child, fn, scopedNodes);
10109 }
10110
10111 return scopedNodes.length === 0 ? null : scopedNodes;
10112 }
10113 };
10114}
10115
10116function markUpdate(workInProgress) {
10117 // Tag the fiber with an update effect. This turns a Placement into
10118 // a PlacementAndUpdate.
10119 workInProgress.effectTag |= Update;
10120}
10121
10122function markRef$1(workInProgress) {
10123 workInProgress.effectTag |= Ref;
10124}
10125
10126var appendAllChildren;
10127var updateHostContainer;
10128var updateHostComponent$1;
10129var updateHostText$1;
10130
10131if (supportsMutation) {
10132 // Mutation mode
10133 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
10134 // We only have the top Fiber that was created but we need recurse down its
10135 // children to find all the terminal nodes.
10136 var node = workInProgress.child;
10137
10138 while (node !== null) {
10139 if (node.tag === HostComponent || node.tag === HostText) {
10140 appendInitialChild(parent, node.stateNode);
10141 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
10142 appendInitialChild(parent, node.stateNode.instance);
10143 } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
10144 // down its children. Instead, we'll get insertions from each child in
10145 // the portal directly.
10146 } else if (node.child !== null) {
10147 node.child.return = node;
10148 node = node.child;
10149 continue;
10150 }
10151
10152 if (node === workInProgress) {
10153 return;
10154 }
10155
10156 while (node.sibling === null) {
10157 if (node.return === null || node.return === workInProgress) {
10158 return;
10159 }
10160
10161 node = node.return;
10162 }
10163
10164 node.sibling.return = node.return;
10165 node = node.sibling;
10166 }
10167 };
10168
10169 updateHostContainer = function (workInProgress) {// Noop
10170 };
10171
10172 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
10173 // If we have an alternate, that means this is an update and we need to
10174 // schedule a side-effect to do the updates.
10175 var oldProps = current.memoizedProps;
10176
10177 if (oldProps === newProps) {
10178 // In mutation mode, this is sufficient for a bailout because
10179 // we won't touch this node even if children changed.
10180 return;
10181 } // If we get updated because one of our children updated, we don't
10182 // have newProps so we'll have to reuse them.
10183 // TODO: Split the update API as separate for the props vs. children.
10184 // Even better would be if children weren't special cased at all tho.
10185
10186
10187 var instance = workInProgress.stateNode;
10188 var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
10189 // component is hitting the resume path. Figure out why. Possibly
10190 // related to `hidden`.
10191
10192 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component.
10193
10194 workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
10195 // is a new ref we mark this as an update. All the work is done in commitWork.
10196
10197 if (updatePayload) {
10198 markUpdate(workInProgress);
10199 }
10200 };
10201
10202 updateHostText$1 = function (current, workInProgress, oldText, newText) {
10203 // If the text differs, mark it as an update. All the work in done in commitWork.
10204 if (oldText !== newText) {
10205 markUpdate(workInProgress);
10206 }
10207 };
10208} else if (supportsPersistence) {
10209 // Persistent host tree mode
10210 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
10211 // We only have the top Fiber that was created but we need recurse down its
10212 // children to find all the terminal nodes.
10213 var node = workInProgress.child;
10214
10215 while (node !== null) {
10216 // eslint-disable-next-line no-labels
10217 branches: if (node.tag === HostComponent) {
10218 var instance = node.stateNode;
10219
10220 if (needsVisibilityToggle && isHidden) {
10221 // This child is inside a timed out tree. Hide it.
10222 var props = node.memoizedProps;
10223 var type = node.type;
10224 instance = cloneHiddenInstance(instance, type, props, node);
10225 }
10226
10227 appendInitialChild(parent, instance);
10228 } else if (node.tag === HostText) {
10229 var _instance = node.stateNode;
10230
10231 if (needsVisibilityToggle && isHidden) {
10232 // This child is inside a timed out tree. Hide it.
10233 var text = node.memoizedProps;
10234 _instance = cloneHiddenTextInstance(_instance, text, node);
10235 }
10236
10237 appendInitialChild(parent, _instance);
10238 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
10239 var _instance2 = node.stateNode.instance;
10240
10241 if (needsVisibilityToggle && isHidden) {
10242 // This child is inside a timed out tree. Hide it.
10243 var _props = node.memoizedProps;
10244 var _type = node.type;
10245 _instance2 = cloneHiddenInstance(_instance2, _type, _props, node);
10246 }
10247
10248 appendInitialChild(parent, _instance2);
10249 } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
10250 // down its children. Instead, we'll get insertions from each child in
10251 // the portal directly.
10252 } else if (node.tag === SuspenseComponent) {
10253 if ((node.effectTag & Update) !== NoEffect) {
10254 // Need to toggle the visibility of the primary children.
10255 var newIsHidden = node.memoizedState !== null;
10256
10257 if (newIsHidden) {
10258 var primaryChildParent = node.child;
10259
10260 if (primaryChildParent !== null) {
10261 if (primaryChildParent.child !== null) {
10262 primaryChildParent.child.return = primaryChildParent;
10263 appendAllChildren(parent, primaryChildParent, true, newIsHidden);
10264 }
10265
10266 var fallbackChildParent = primaryChildParent.sibling;
10267
10268 if (fallbackChildParent !== null) {
10269 fallbackChildParent.return = node;
10270 node = fallbackChildParent;
10271 continue;
10272 }
10273 }
10274 }
10275 }
10276
10277 if (node.child !== null) {
10278 // Continue traversing like normal
10279 node.child.return = node;
10280 node = node.child;
10281 continue;
10282 }
10283 } else if (node.child !== null) {
10284 node.child.return = node;
10285 node = node.child;
10286 continue;
10287 } // $FlowFixMe This is correct but Flow is confused by the labeled break.
10288
10289
10290 node = node;
10291
10292 if (node === workInProgress) {
10293 return;
10294 }
10295
10296 while (node.sibling === null) {
10297 if (node.return === null || node.return === workInProgress) {
10298 return;
10299 }
10300
10301 node = node.return;
10302 }
10303
10304 node.sibling.return = node.return;
10305 node = node.sibling;
10306 }
10307 }; // An unfortunate fork of appendAllChildren because we have two different parent types.
10308
10309
10310 var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
10311 // We only have the top Fiber that was created but we need recurse down its
10312 // children to find all the terminal nodes.
10313 var node = workInProgress.child;
10314
10315 while (node !== null) {
10316 // eslint-disable-next-line no-labels
10317 branches: if (node.tag === HostComponent) {
10318 var instance = node.stateNode;
10319
10320 if (needsVisibilityToggle && isHidden) {
10321 // This child is inside a timed out tree. Hide it.
10322 var props = node.memoizedProps;
10323 var type = node.type;
10324 instance = cloneHiddenInstance(instance, type, props, node);
10325 }
10326
10327 appendChildToContainerChildSet(containerChildSet, instance);
10328 } else if (node.tag === HostText) {
10329 var _instance3 = node.stateNode;
10330
10331 if (needsVisibilityToggle && isHidden) {
10332 // This child is inside a timed out tree. Hide it.
10333 var text = node.memoizedProps;
10334 _instance3 = cloneHiddenTextInstance(_instance3, text, node);
10335 }
10336
10337 appendChildToContainerChildSet(containerChildSet, _instance3);
10338 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
10339 var _instance4 = node.stateNode.instance;
10340
10341 if (needsVisibilityToggle && isHidden) {
10342 // This child is inside a timed out tree. Hide it.
10343 var _props2 = node.memoizedProps;
10344 var _type2 = node.type;
10345 _instance4 = cloneHiddenInstance(_instance4, _type2, _props2, node);
10346 }
10347
10348 appendChildToContainerChildSet(containerChildSet, _instance4);
10349 } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
10350 // down its children. Instead, we'll get insertions from each child in
10351 // the portal directly.
10352 } else if (node.tag === SuspenseComponent) {
10353 if ((node.effectTag & Update) !== NoEffect) {
10354 // Need to toggle the visibility of the primary children.
10355 var newIsHidden = node.memoizedState !== null;
10356
10357 if (newIsHidden) {
10358 var primaryChildParent = node.child;
10359
10360 if (primaryChildParent !== null) {
10361 if (primaryChildParent.child !== null) {
10362 primaryChildParent.child.return = primaryChildParent;
10363 appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
10364 }
10365
10366 var fallbackChildParent = primaryChildParent.sibling;
10367
10368 if (fallbackChildParent !== null) {
10369 fallbackChildParent.return = node;
10370 node = fallbackChildParent;
10371 continue;
10372 }
10373 }
10374 }
10375 }
10376
10377 if (node.child !== null) {
10378 // Continue traversing like normal
10379 node.child.return = node;
10380 node = node.child;
10381 continue;
10382 }
10383 } else if (node.child !== null) {
10384 node.child.return = node;
10385 node = node.child;
10386 continue;
10387 } // $FlowFixMe This is correct but Flow is confused by the labeled break.
10388
10389
10390 node = node;
10391
10392 if (node === workInProgress) {
10393 return;
10394 }
10395
10396 while (node.sibling === null) {
10397 if (node.return === null || node.return === workInProgress) {
10398 return;
10399 }
10400
10401 node = node.return;
10402 }
10403
10404 node.sibling.return = node.return;
10405 node = node.sibling;
10406 }
10407 };
10408
10409 updateHostContainer = function (workInProgress) {
10410 var portalOrRoot = workInProgress.stateNode;
10411 var childrenUnchanged = workInProgress.firstEffect === null;
10412
10413 if (childrenUnchanged) {// No changes, just reuse the existing instance.
10414 } else {
10415 var container = portalOrRoot.containerInfo;
10416 var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set.
10417
10418 appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
10419 portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container.
10420
10421 markUpdate(workInProgress);
10422 finalizeContainerChildren(container, newChildSet);
10423 }
10424 };
10425
10426 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
10427 var currentInstance = current.stateNode;
10428 var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates.
10429 // This guarantees that we can reuse all of them.
10430
10431 var childrenUnchanged = workInProgress.firstEffect === null;
10432
10433 if (childrenUnchanged && oldProps === newProps) {
10434 // No changes, just reuse the existing instance.
10435 // Note that this might release a previous clone.
10436 workInProgress.stateNode = currentInstance;
10437 return;
10438 }
10439
10440 var recyclableInstance = workInProgress.stateNode;
10441 var currentHostContext = getHostContext();
10442 var updatePayload = null;
10443
10444 if (oldProps !== newProps) {
10445 updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
10446 }
10447
10448 if (childrenUnchanged && updatePayload === null) {
10449 // No changes, just reuse the existing instance.
10450 // Note that this might release a previous clone.
10451 workInProgress.stateNode = currentInstance;
10452 return;
10453 }
10454
10455 var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
10456
10457 if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
10458 markUpdate(workInProgress);
10459 }
10460
10461 workInProgress.stateNode = newInstance;
10462
10463 if (childrenUnchanged) {
10464 // If there are no other effects in this tree, we need to flag this node as having one.
10465 // Even though we're not going to use it for anything.
10466 // Otherwise parents won't know that there are new children to propagate upwards.
10467 markUpdate(workInProgress);
10468 } else {
10469 // If children might have changed, we have to add them all to the set.
10470 appendAllChildren(newInstance, workInProgress, false, false);
10471 }
10472 };
10473
10474 updateHostText$1 = function (current, workInProgress, oldText, newText) {
10475 if (oldText !== newText) {
10476 // If the text content differs, we'll create a new text instance for it.
10477 var rootContainerInstance = getRootHostContainer();
10478 var currentHostContext = getHostContext();
10479 workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress); // We'll have to mark it as having an effect, even though we won't use the effect for anything.
10480 // This lets the parents know that at least one of their children has changed.
10481
10482 markUpdate(workInProgress);
10483 }
10484 };
10485} else {
10486 // No host operations
10487 updateHostContainer = function (workInProgress) {// Noop
10488 };
10489
10490 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {// Noop
10491 };
10492
10493 updateHostText$1 = function (current, workInProgress, oldText, newText) {// Noop
10494 };
10495}
10496
10497function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
10498 switch (renderState.tailMode) {
10499 case 'hidden':
10500 {
10501 // Any insertions at the end of the tail list after this point
10502 // should be invisible. If there are already mounted boundaries
10503 // anything before them are not considered for collapsing.
10504 // Therefore we need to go through the whole tail to find if
10505 // there are any.
10506 var tailNode = renderState.tail;
10507 var lastTailNode = null;
10508
10509 while (tailNode !== null) {
10510 if (tailNode.alternate !== null) {
10511 lastTailNode = tailNode;
10512 }
10513
10514 tailNode = tailNode.sibling;
10515 } // Next we're simply going to delete all insertions after the
10516 // last rendered item.
10517
10518
10519 if (lastTailNode === null) {
10520 // All remaining items in the tail are insertions.
10521 renderState.tail = null;
10522 } else {
10523 // Detach the insertion after the last node that was already
10524 // inserted.
10525 lastTailNode.sibling = null;
10526 }
10527
10528 break;
10529 }
10530
10531 case 'collapsed':
10532 {
10533 // Any insertions at the end of the tail list after this point
10534 // should be invisible. If there are already mounted boundaries
10535 // anything before them are not considered for collapsing.
10536 // Therefore we need to go through the whole tail to find if
10537 // there are any.
10538 var _tailNode = renderState.tail;
10539 var _lastTailNode = null;
10540
10541 while (_tailNode !== null) {
10542 if (_tailNode.alternate !== null) {
10543 _lastTailNode = _tailNode;
10544 }
10545
10546 _tailNode = _tailNode.sibling;
10547 } // Next we're simply going to delete all insertions after the
10548 // last rendered item.
10549
10550
10551 if (_lastTailNode === null) {
10552 // All remaining items in the tail are insertions.
10553 if (!hasRenderedATailFallback && renderState.tail !== null) {
10554 // We suspended during the head. We want to show at least one
10555 // row at the tail. So we'll keep on and cut off the rest.
10556 renderState.tail.sibling = null;
10557 } else {
10558 renderState.tail = null;
10559 }
10560 } else {
10561 // Detach the insertion after the last node that was already
10562 // inserted.
10563 _lastTailNode.sibling = null;
10564 }
10565
10566 break;
10567 }
10568 }
10569}
10570
10571function completeWork(current, workInProgress, renderExpirationTime) {
10572 var newProps = workInProgress.pendingProps;
10573
10574 switch (workInProgress.tag) {
10575 case IndeterminateComponent:
10576 break;
10577
10578 case LazyComponent:
10579 break;
10580
10581 case SimpleMemoComponent:
10582 case FunctionComponent:
10583 break;
10584
10585 case ClassComponent:
10586 {
10587 var Component = workInProgress.type;
10588
10589 if (isContextProvider(Component)) {
10590 popContext(workInProgress);
10591 }
10592
10593 break;
10594 }
10595
10596 case HostRoot:
10597 {
10598 popHostContainer(workInProgress);
10599 popTopLevelContextObject(workInProgress);
10600 var fiberRoot = workInProgress.stateNode;
10601
10602 if (fiberRoot.pendingContext) {
10603 fiberRoot.context = fiberRoot.pendingContext;
10604 fiberRoot.pendingContext = null;
10605 }
10606
10607 if (current === null || current.child === null) {
10608 // If we hydrated, pop so that we can delete any remaining children
10609 // that weren't hydrated.
10610 var wasHydrated = popHydrationState(workInProgress);
10611
10612 if (wasHydrated) {
10613 // If we hydrated, then we'll need to schedule an update for
10614 // the commit side-effects on the root.
10615 markUpdate(workInProgress);
10616 }
10617 }
10618
10619 updateHostContainer(workInProgress);
10620 break;
10621 }
10622
10623 case HostComponent:
10624 {
10625 popHostContext(workInProgress);
10626 var rootContainerInstance = getRootHostContainer();
10627 var type = workInProgress.type;
10628
10629 if (current !== null && workInProgress.stateNode != null) {
10630 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
10631
10632 if (enableFlareAPI) {
10633 var prevListeners = current.memoizedProps.listeners;
10634 var nextListeners = newProps.listeners;
10635
10636 if (prevListeners !== nextListeners) {
10637 markUpdate(workInProgress);
10638 }
10639 }
10640
10641 if (current.ref !== workInProgress.ref) {
10642 markRef$1(workInProgress);
10643 }
10644 } else {
10645 if (!newProps) {
10646 (function () {
10647 if (!(workInProgress.stateNode !== null)) {
10648 {
10649 throw ReactError(Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."));
10650 }
10651 }
10652 })(); // This can happen when we abort work.
10653
10654
10655 break;
10656 }
10657
10658 var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
10659 // "stack" as the parent. Then append children as we go in beginWork
10660 // or completeWork depending on we want to add then top->down or
10661 // bottom->up. Top->down is faster in IE11.
10662
10663 var _wasHydrated = popHydrationState(workInProgress);
10664
10665 if (_wasHydrated) {
10666 // TODO: Move this and createInstance step into the beginPhase
10667 // to consolidate.
10668 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
10669 // If changes to the hydrated node needs to be applied at the
10670 // commit-phase we mark this as such.
10671 markUpdate(workInProgress);
10672 }
10673
10674 if (enableFlareAPI) {
10675 var listeners = newProps.listeners;
10676
10677 if (listeners != null) {
10678 updateEventListeners(listeners, workInProgress, rootContainerInstance);
10679 }
10680 }
10681 } else {
10682 var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
10683 appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners
10684
10685 workInProgress.stateNode = instance;
10686
10687 if (enableFlareAPI) {
10688 var _listeners = newProps.listeners;
10689
10690 if (_listeners != null) {
10691 updateEventListeners(_listeners, workInProgress, rootContainerInstance);
10692 }
10693 } // Certain renderers require commit-time effects for initial mount.
10694 // (eg DOM renderer supports auto-focus for certain elements).
10695 // Make sure such renderers get scheduled for later work.
10696
10697
10698 if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
10699 markUpdate(workInProgress);
10700 }
10701 }
10702
10703 if (workInProgress.ref !== null) {
10704 // If there is a ref on a host node we need to schedule a callback
10705 markRef$1(workInProgress);
10706 }
10707 }
10708
10709 break;
10710 }
10711
10712 case HostText:
10713 {
10714 var newText = newProps;
10715
10716 if (current && workInProgress.stateNode != null) {
10717 var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
10718 // to schedule a side-effect to do the updates.
10719
10720 updateHostText$1(current, workInProgress, oldText, newText);
10721 } else {
10722 if (typeof newText !== 'string') {
10723 (function () {
10724 if (!(workInProgress.stateNode !== null)) {
10725 {
10726 throw ReactError(Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."));
10727 }
10728 }
10729 })(); // This can happen when we abort work.
10730
10731 }
10732
10733 var _rootContainerInstance = getRootHostContainer();
10734
10735 var _currentHostContext = getHostContext();
10736
10737 var _wasHydrated2 = popHydrationState(workInProgress);
10738
10739 if (_wasHydrated2) {
10740 if (prepareToHydrateHostTextInstance(workInProgress)) {
10741 markUpdate(workInProgress);
10742 }
10743 } else {
10744 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
10745 }
10746 }
10747
10748 break;
10749 }
10750
10751 case ForwardRef:
10752 break;
10753
10754 case SuspenseComponent:
10755 {
10756 popSuspenseContext(workInProgress);
10757 var nextState = workInProgress.memoizedState;
10758
10759 if (enableSuspenseServerRenderer) {
10760 if (nextState !== null && nextState.dehydrated !== null) {
10761 if (current === null) {
10762 var _wasHydrated3 = popHydrationState(workInProgress);
10763
10764 (function () {
10765 if (!_wasHydrated3) {
10766 {
10767 throw ReactError(Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React."));
10768 }
10769 }
10770 })();
10771
10772 prepareToHydrateHostSuspenseInstance(workInProgress);
10773
10774 if (enableSchedulerTracing) {
10775 markSpawnedWork(Never);
10776 }
10777
10778 return null;
10779 } else {
10780 // We should never have been in a hydration state if we didn't have a current.
10781 // However, in some of those paths, we might have reentered a hydration state
10782 // and then we might be inside a hydration state. In that case, we'll need to
10783 // exit out of it.
10784 resetHydrationState();
10785
10786 if ((workInProgress.effectTag & DidCapture) === NoEffect) {
10787 // This boundary did not suspend so it's now hydrated and unsuspended.
10788 workInProgress.memoizedState = null;
10789 } // If nothing suspended, we need to schedule an effect to mark this boundary
10790 // as having hydrated so events know that they're free be invoked.
10791 // It's also a signal to replay events and the suspense callback.
10792 // If something suspended, schedule an effect to attach retry listeners.
10793 // So we might as well always mark this.
10794
10795
10796 workInProgress.effectTag |= Update;
10797 return null;
10798 }
10799 }
10800 }
10801
10802 if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
10803 // Something suspended. Re-render with the fallback children.
10804 workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list.
10805
10806 return workInProgress;
10807 }
10808
10809 var nextDidTimeout = nextState !== null;
10810 var prevDidTimeout = false;
10811
10812 if (current === null) {
10813 // In cases where we didn't find a suitable hydration boundary we never
10814 // put this in dehydrated mode, but we still need to pop the hydration
10815 // state since we might be inside the insertion tree.
10816 popHydrationState(workInProgress);
10817 } else {
10818 var prevState = current.memoizedState;
10819 prevDidTimeout = prevState !== null;
10820
10821 if (!nextDidTimeout && prevState !== null) {
10822 // We just switched from the fallback to the normal children.
10823 // Delete the fallback.
10824 // TODO: Would it be better to store the fallback fragment on
10825 // the stateNode during the begin phase?
10826 var currentFallbackChild = current.child.sibling;
10827
10828 if (currentFallbackChild !== null) {
10829 // Deletions go at the beginning of the return fiber's effect list
10830 var first = workInProgress.firstEffect;
10831
10832 if (first !== null) {
10833 workInProgress.firstEffect = currentFallbackChild;
10834 currentFallbackChild.nextEffect = first;
10835 } else {
10836 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
10837 currentFallbackChild.nextEffect = null;
10838 }
10839
10840 currentFallbackChild.effectTag = Deletion;
10841 }
10842 }
10843 }
10844
10845 if (nextDidTimeout && !prevDidTimeout) {
10846 // If this subtreee is running in batched mode we can suspend,
10847 // otherwise we won't suspend.
10848 // TODO: This will still suspend a synchronous tree if anything
10849 // in the concurrent tree already suspended during this render.
10850 // This is a known bug.
10851 if ((workInProgress.mode & BatchedMode) !== NoMode) {
10852 // TODO: Move this back to throwException because this is too late
10853 // if this is a large tree which is common for initial loads. We
10854 // don't know if we should restart a render or not until we get
10855 // this marker, and this is too late.
10856 // If this render already had a ping or lower pri updates,
10857 // and this is the first time we know we're going to suspend we
10858 // should be able to immediately restart from within throwException.
10859 var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
10860
10861 if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
10862 // If this was in an invisible tree or a new render, then showing
10863 // this boundary is ok.
10864 renderDidSuspend();
10865 } else {
10866 // Otherwise, we're going to have to hide content so we should
10867 // suspend for longer if possible.
10868 renderDidSuspendDelayIfPossible();
10869 }
10870 }
10871 }
10872
10873 if (supportsPersistence) {
10874 // TODO: Only schedule updates if not prevDidTimeout.
10875 if (nextDidTimeout) {
10876 // If this boundary just timed out, schedule an effect to attach a
10877 // retry listener to the proimse. This flag is also used to hide the
10878 // primary children.
10879 workInProgress.effectTag |= Update;
10880 }
10881 }
10882
10883 if (supportsMutation) {
10884 // TODO: Only schedule updates if these values are non equal, i.e. it changed.
10885 if (nextDidTimeout || prevDidTimeout) {
10886 // If this boundary just timed out, schedule an effect to attach a
10887 // retry listener to the proimse. This flag is also used to hide the
10888 // primary children. In mutation mode, we also need the flag to
10889 // *unhide* children that were previously hidden, so check if the
10890 // is currently timed out, too.
10891 workInProgress.effectTag |= Update;
10892 }
10893 }
10894
10895 if (enableSuspenseCallback && workInProgress.updateQueue !== null && workInProgress.memoizedProps.suspenseCallback != null) {
10896 // Always notify the callback
10897 workInProgress.effectTag |= Update;
10898 }
10899
10900 break;
10901 }
10902
10903 case Fragment:
10904 break;
10905
10906 case Mode:
10907 break;
10908
10909 case Profiler:
10910 break;
10911
10912 case HostPortal:
10913 popHostContainer(workInProgress);
10914 updateHostContainer(workInProgress);
10915 break;
10916
10917 case ContextProvider:
10918 // Pop provider fiber
10919 popProvider(workInProgress);
10920 break;
10921
10922 case ContextConsumer:
10923 break;
10924
10925 case MemoComponent:
10926 break;
10927
10928 case IncompleteClassComponent:
10929 {
10930 // Same as class component case. I put it down here so that the tags are
10931 // sequential to ensure this switch is compiled to a jump table.
10932 var _Component = workInProgress.type;
10933
10934 if (isContextProvider(_Component)) {
10935 popContext(workInProgress);
10936 }
10937
10938 break;
10939 }
10940
10941 case SuspenseListComponent:
10942 {
10943 popSuspenseContext(workInProgress);
10944 var renderState = workInProgress.memoizedState;
10945
10946 if (renderState === null) {
10947 // We're running in the default, "independent" mode. We don't do anything
10948 // in this mode.
10949 break;
10950 }
10951
10952 var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
10953 var renderedTail = renderState.rendering;
10954
10955 if (renderedTail === null) {
10956 // We just rendered the head.
10957 if (!didSuspendAlready) {
10958 // This is the first pass. We need to figure out if anything is still
10959 // suspended in the rendered set.
10960 // If new content unsuspended, but there's still some content that
10961 // didn't. Then we need to do a second pass that forces everything
10962 // to keep showing their fallbacks.
10963 // We might be suspended if something in this render pass suspended, or
10964 // something in the previous committed pass suspended. Otherwise,
10965 // there's no chance so we can skip the expensive call to
10966 // findFirstSuspended.
10967 var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
10968
10969 if (!cannotBeSuspended) {
10970 var row = workInProgress.child;
10971
10972 while (row !== null) {
10973 var suspended = findFirstSuspended(row);
10974
10975 if (suspended !== null) {
10976 didSuspendAlready = true;
10977 workInProgress.effectTag |= DidCapture;
10978 cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
10979 // part of the second pass. In that case nothing will subscribe to
10980 // its thennables. Instead, we'll transfer its thennables to the
10981 // SuspenseList so that it can retry if they resolve.
10982 // There might be multiple of these in the list but since we're
10983 // going to wait for all of them anyway, it doesn't really matter
10984 // which ones gets to ping. In theory we could get clever and keep
10985 // track of how many dependencies remain but it gets tricky because
10986 // in the meantime, we can add/remove/change items and dependencies.
10987 // We might bail out of the loop before finding any but that
10988 // doesn't matter since that means that the other boundaries that
10989 // we did find already has their listeners attached.
10990
10991 var newThennables = suspended.updateQueue;
10992
10993 if (newThennables !== null) {
10994 workInProgress.updateQueue = newThennables;
10995 workInProgress.effectTag |= Update;
10996 } // Rerender the whole list, but this time, we'll force fallbacks
10997 // to stay in place.
10998 // Reset the effect list before doing the second pass since that's now invalid.
10999
11000
11001 workInProgress.firstEffect = workInProgress.lastEffect = null; // Reset the child fibers to their original state.
11002
11003 resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately
11004 // rerender the children.
11005
11006 pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
11007 return workInProgress.child;
11008 }
11009
11010 row = row.sibling;
11011 }
11012 }
11013 } else {
11014 cutOffTailIfNeeded(renderState, false);
11015 } // Next we're going to render the tail.
11016
11017 } else {
11018 // Append the rendered row to the child list.
11019 if (!didSuspendAlready) {
11020 var _suspended = findFirstSuspended(renderedTail);
11021
11022 if (_suspended !== null) {
11023 workInProgress.effectTag |= DidCapture;
11024 didSuspendAlready = true;
11025 cutOffTailIfNeeded(renderState, true); // This might have been modified.
11026
11027 if (renderState.tail === null && renderState.tailMode === 'hidden') {
11028 // We need to delete the row we just rendered.
11029 // Ensure we transfer the update queue to the parent.
11030 var _newThennables = _suspended.updateQueue;
11031
11032 if (_newThennables !== null) {
11033 workInProgress.updateQueue = _newThennables;
11034 workInProgress.effectTag |= Update;
11035 } // Reset the effect list to what it w as before we rendered this
11036 // child. The nested children have already appended themselves.
11037
11038
11039 var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point.
11040
11041 if (lastEffect !== null) {
11042 lastEffect.nextEffect = null;
11043 } // We're done.
11044
11045
11046 return null;
11047 }
11048 } else if (now$1() > renderState.tailExpiration && renderExpirationTime > Never) {
11049 // We have now passed our CPU deadline and we'll just give up further
11050 // attempts to render the main content and only render fallbacks.
11051 // The assumption is that this is usually faster.
11052 workInProgress.effectTag |= DidCapture;
11053 didSuspendAlready = true;
11054 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
11055 // to get it started back up to attempt the next item. If we can show
11056 // them, then they really have the same priority as this render.
11057 // So we'll pick it back up the very next render pass once we've had
11058 // an opportunity to yield for paint.
11059
11060 var nextPriority = renderExpirationTime - 1;
11061 workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
11062
11063 if (enableSchedulerTracing) {
11064 markSpawnedWork(nextPriority);
11065 }
11066 }
11067 }
11068
11069 if (renderState.isBackwards) {
11070 // The effect list of the backwards tail will have been added
11071 // to the end. This breaks the guarantee that life-cycles fire in
11072 // sibling order but that isn't a strong guarantee promised by React.
11073 // Especially since these might also just pop in during future commits.
11074 // Append to the beginning of the list.
11075 renderedTail.sibling = workInProgress.child;
11076 workInProgress.child = renderedTail;
11077 } else {
11078 var previousSibling = renderState.last;
11079
11080 if (previousSibling !== null) {
11081 previousSibling.sibling = renderedTail;
11082 } else {
11083 workInProgress.child = renderedTail;
11084 }
11085
11086 renderState.last = renderedTail;
11087 }
11088 }
11089
11090 if (renderState.tail !== null) {
11091 // We still have tail rows to render.
11092 if (renderState.tailExpiration === 0) {
11093 // Heuristic for how long we're willing to spend rendering rows
11094 // until we just give up and show what we have so far.
11095 var TAIL_EXPIRATION_TIMEOUT_MS = 500;
11096 renderState.tailExpiration = now$1() + TAIL_EXPIRATION_TIMEOUT_MS;
11097 } // Pop a row.
11098
11099
11100 var next = renderState.tail;
11101 renderState.rendering = next;
11102 renderState.tail = next.sibling;
11103 renderState.lastEffect = workInProgress.lastEffect;
11104 next.sibling = null; // Restore the context.
11105 // TODO: We can probably just avoid popping it instead and only
11106 // setting it the first time we go from not suspended to suspended.
11107
11108 var suspenseContext = suspenseStackCursor.current;
11109
11110 if (didSuspendAlready) {
11111 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
11112 } else {
11113 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
11114 }
11115
11116 pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
11117
11118 return next;
11119 }
11120
11121 break;
11122 }
11123
11124 case FundamentalComponent:
11125 {
11126 if (enableFundamentalAPI) {
11127 var fundamentalImpl = workInProgress.type.impl;
11128 var fundamentalInstance = workInProgress.stateNode;
11129
11130 if (fundamentalInstance === null) {
11131 var getInitialState = fundamentalImpl.getInitialState;
11132 var fundamentalState;
11133
11134 if (getInitialState !== undefined) {
11135 fundamentalState = getInitialState(newProps);
11136 }
11137
11138 fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance(workInProgress, newProps, fundamentalImpl, fundamentalState || {});
11139
11140 var _instance5 = getFundamentalComponentInstance(fundamentalInstance);
11141
11142 fundamentalInstance.instance = _instance5;
11143
11144 if (fundamentalImpl.reconcileChildren === false) {
11145 return null;
11146 }
11147
11148 appendAllChildren(_instance5, workInProgress, false, false);
11149 mountFundamentalComponent(fundamentalInstance);
11150 } else {
11151 // We fire update in commit phase
11152 var prevProps = fundamentalInstance.props;
11153 fundamentalInstance.prevProps = prevProps;
11154 fundamentalInstance.props = newProps;
11155 fundamentalInstance.currentFiber = workInProgress;
11156
11157 if (supportsPersistence) {
11158 var _instance6 = cloneFundamentalInstance(fundamentalInstance);
11159
11160 fundamentalInstance.instance = _instance6;
11161 appendAllChildren(_instance6, workInProgress, false, false);
11162 }
11163
11164 var shouldUpdate = shouldUpdateFundamentalComponent(fundamentalInstance);
11165
11166 if (shouldUpdate) {
11167 markUpdate(workInProgress);
11168 }
11169 }
11170 }
11171
11172 break;
11173 }
11174
11175 case ScopeComponent:
11176 {
11177 if (enableScopeAPI) {
11178 if (current === null) {
11179 var _type3 = workInProgress.type;
11180 var scopeInstance = {
11181 fiber: workInProgress,
11182 methods: null
11183 };
11184 workInProgress.stateNode = scopeInstance;
11185 scopeInstance.methods = createScopeMethods(_type3, scopeInstance);
11186
11187 if (enableFlareAPI) {
11188 var _listeners2 = newProps.listeners;
11189
11190 if (_listeners2 != null) {
11191 var _rootContainerInstance2 = getRootHostContainer();
11192
11193 updateEventListeners(_listeners2, workInProgress, _rootContainerInstance2);
11194 }
11195 }
11196
11197 if (workInProgress.ref !== null) {
11198 markRef$1(workInProgress);
11199 markUpdate(workInProgress);
11200 }
11201 } else {
11202 if (enableFlareAPI) {
11203 var _prevListeners = current.memoizedProps.listeners;
11204 var _nextListeners = newProps.listeners;
11205
11206 if (_prevListeners !== _nextListeners || workInProgress.ref !== null) {
11207 markUpdate(workInProgress);
11208 }
11209 } else {
11210 if (workInProgress.ref !== null) {
11211 markUpdate(workInProgress);
11212 }
11213 }
11214
11215 if (current.ref !== workInProgress.ref) {
11216 markRef$1(workInProgress);
11217 }
11218 }
11219 }
11220
11221 break;
11222 }
11223
11224 default:
11225 (function () {
11226 {
11227 {
11228 throw ReactError(Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue."));
11229 }
11230 }
11231 })();
11232
11233 }
11234
11235 return null;
11236}
11237
11238function unwindWork(workInProgress, renderExpirationTime) {
11239 switch (workInProgress.tag) {
11240 case ClassComponent:
11241 {
11242 var Component = workInProgress.type;
11243
11244 if (isContextProvider(Component)) {
11245 popContext(workInProgress);
11246 }
11247
11248 var effectTag = workInProgress.effectTag;
11249
11250 if (effectTag & ShouldCapture) {
11251 workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
11252 return workInProgress;
11253 }
11254
11255 return null;
11256 }
11257
11258 case HostRoot:
11259 {
11260 popHostContainer(workInProgress);
11261 popTopLevelContextObject(workInProgress);
11262 var _effectTag = workInProgress.effectTag;
11263
11264 (function () {
11265 if (!((_effectTag & DidCapture) === NoEffect)) {
11266 {
11267 throw ReactError(Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue."));
11268 }
11269 }
11270 })();
11271
11272 workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
11273 return workInProgress;
11274 }
11275
11276 case HostComponent:
11277 {
11278 // TODO: popHydrationState
11279 popHostContext(workInProgress);
11280 return null;
11281 }
11282
11283 case SuspenseComponent:
11284 {
11285 popSuspenseContext(workInProgress);
11286
11287 if (enableSuspenseServerRenderer) {
11288 var suspenseState = workInProgress.memoizedState;
11289
11290 if (suspenseState !== null && suspenseState.dehydrated !== null) {
11291 (function () {
11292 if (!(workInProgress.alternate !== null)) {
11293 {
11294 throw ReactError(Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue."));
11295 }
11296 }
11297 })();
11298
11299 resetHydrationState();
11300 }
11301 }
11302
11303 var _effectTag2 = workInProgress.effectTag;
11304
11305 if (_effectTag2 & ShouldCapture) {
11306 workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary.
11307
11308 return workInProgress;
11309 }
11310
11311 return null;
11312 }
11313
11314 case SuspenseListComponent:
11315 {
11316 popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
11317 // caught by a nested boundary. If not, it should bubble through.
11318
11319 return null;
11320 }
11321
11322 case HostPortal:
11323 popHostContainer(workInProgress);
11324 return null;
11325
11326 case ContextProvider:
11327 popProvider(workInProgress);
11328 return null;
11329
11330 default:
11331 return null;
11332 }
11333}
11334
11335function unwindInterruptedWork(interruptedWork) {
11336 switch (interruptedWork.tag) {
11337 case ClassComponent:
11338 {
11339 var childContextTypes = interruptedWork.type.childContextTypes;
11340
11341 if (childContextTypes !== null && childContextTypes !== undefined) {
11342 popContext(interruptedWork);
11343 }
11344
11345 break;
11346 }
11347
11348 case HostRoot:
11349 {
11350 popHostContainer(interruptedWork);
11351 popTopLevelContextObject(interruptedWork);
11352 break;
11353 }
11354
11355 case HostComponent:
11356 {
11357 popHostContext(interruptedWork);
11358 break;
11359 }
11360
11361 case HostPortal:
11362 popHostContainer(interruptedWork);
11363 break;
11364
11365 case SuspenseComponent:
11366 popSuspenseContext(interruptedWork);
11367 break;
11368
11369 case SuspenseListComponent:
11370 popSuspenseContext(interruptedWork);
11371 break;
11372
11373 case ContextProvider:
11374 popProvider(interruptedWork);
11375 break;
11376
11377 default:
11378 break;
11379 }
11380}
11381
11382function createCapturedValue(value, source) {
11383 // If the value is an error, call this function immediately after it is thrown
11384 // so the stack is accurate.
11385 return {
11386 value: value,
11387 source: source,
11388 stack: getStackByFiberInDevAndProd(source)
11389 };
11390}
11391
11392var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
11393 var funcArgs = Array.prototype.slice.call(arguments, 3);
11394
11395 try {
11396 func.apply(context, funcArgs);
11397 } catch (error) {
11398 this.onError(error);
11399 }
11400};
11401
11402{
11403 // In DEV mode, we swap out invokeGuardedCallback for a special version
11404 // that plays more nicely with the browser's DevTools. The idea is to preserve
11405 // "Pause on exceptions" behavior. Because React wraps all user-provided
11406 // functions in invokeGuardedCallback, and the production version of
11407 // invokeGuardedCallback uses a try-catch, all user exceptions are treated
11408 // like caught exceptions, and the DevTools won't pause unless the developer
11409 // takes the extra step of enabling pause on caught exceptions. This is
11410 // unintuitive, though, because even though React has caught the error, from
11411 // the developer's perspective, the error is uncaught.
11412 //
11413 // To preserve the expected "Pause on exceptions" behavior, we don't use a
11414 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
11415 // DOM node, and call the user-provided callback from inside an event handler
11416 // for that fake event. If the callback throws, the error is "captured" using
11417 // a global event handler. But because the error happens in a different
11418 // event loop context, it does not interrupt the normal program flow.
11419 // Effectively, this gives us try-catch behavior without actually using
11420 // try-catch. Neat!
11421 // Check that the browser supports the APIs we need to implement our special
11422 // DEV version of invokeGuardedCallback
11423 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
11424 var fakeNode = document.createElement('react');
11425
11426 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
11427 // If document doesn't exist we know for sure we will crash in this method
11428 // when we call document.createEvent(). However this can cause confusing
11429 // errors: https://github.com/facebookincubator/create-react-app/issues/3482
11430 // So we preemptively throw with a better message instead.
11431 (function () {
11432 if (!(typeof document !== 'undefined')) {
11433 {
11434 throw ReactError(Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."));
11435 }
11436 }
11437 })();
11438
11439 var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
11440 // set this to true at the beginning, then set it to false right after
11441 // calling the function. If the function errors, `didError` will never be
11442 // set to false. This strategy works even if the browser is flaky and
11443 // fails to call our global error handler, because it doesn't rely on
11444 // the error event at all.
11445
11446 var didError = true; // Keeps track of the value of window.event so that we can reset it
11447 // during the callback to let user code access window.event in the
11448 // browsers that support it.
11449
11450 var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
11451 // dispatching: https://github.com/facebook/react/issues/13688
11452
11453 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously
11454 // dispatch our fake event using `dispatchEvent`. Inside the handler, we
11455 // call the user-provided callback.
11456
11457 var funcArgs = Array.prototype.slice.call(arguments, 3);
11458
11459 function callCallback() {
11460 // We immediately remove the callback from event listeners so that
11461 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
11462 // nested call would trigger the fake event handlers of any call higher
11463 // in the stack.
11464 fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
11465 // window.event assignment in both IE <= 10 as they throw an error
11466 // "Member not found" in strict mode, and in Firefox which does not
11467 // support window.event.
11468
11469 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
11470 window.event = windowEvent;
11471 }
11472
11473 func.apply(context, funcArgs);
11474 didError = false;
11475 } // Create a global error event handler. We use this to capture the value
11476 // that was thrown. It's possible that this error handler will fire more
11477 // than once; for example, if non-React code also calls `dispatchEvent`
11478 // and a handler for that event throws. We should be resilient to most of
11479 // those cases. Even if our error event handler fires more than once, the
11480 // last error event is always used. If the callback actually does error,
11481 // we know that the last error event is the correct one, because it's not
11482 // possible for anything else to have happened in between our callback
11483 // erroring and the code that follows the `dispatchEvent` call below. If
11484 // the callback doesn't error, but the error event was fired, we know to
11485 // ignore it because `didError` will be false, as described above.
11486
11487
11488 var error; // Use this to track whether the error event is ever called.
11489
11490 var didSetError = false;
11491 var isCrossOriginError = false;
11492
11493 function handleWindowError(event) {
11494 error = event.error;
11495 didSetError = true;
11496
11497 if (error === null && event.colno === 0 && event.lineno === 0) {
11498 isCrossOriginError = true;
11499 }
11500
11501 if (event.defaultPrevented) {
11502 // Some other error handler has prevented default.
11503 // Browsers silence the error report if this happens.
11504 // We'll remember this to later decide whether to log it or not.
11505 if (error != null && typeof error === 'object') {
11506 try {
11507 error._suppressLogging = true;
11508 } catch (inner) {// Ignore.
11509 }
11510 }
11511 }
11512 } // Create a fake event type.
11513
11514
11515 var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
11516
11517 window.addEventListener('error', handleWindowError);
11518 fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
11519 // errors, it will trigger our global error handler.
11520
11521 evt.initEvent(evtType, false, false);
11522 fakeNode.dispatchEvent(evt);
11523
11524 if (windowEventDescriptor) {
11525 Object.defineProperty(window, 'event', windowEventDescriptor);
11526 }
11527
11528 if (didError) {
11529 if (!didSetError) {
11530 // The callback errored, but the error event never fired.
11531 error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
11532 } else if (isCrossOriginError) {
11533 error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
11534 }
11535
11536 this.onError(error);
11537 } // Remove our event listeners
11538
11539
11540 window.removeEventListener('error', handleWindowError);
11541 };
11542
11543 invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
11544 }
11545}
11546
11547var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
11548
11549var hasError = false;
11550var caughtError = null; // Used by event system to capture/rethrow the first error.
11551
11552var reporter = {
11553 onError: function (error) {
11554 hasError = true;
11555 caughtError = error;
11556 }
11557};
11558/**
11559 * Call a function while guarding against errors that happens within it.
11560 * Returns an error if it throws, otherwise null.
11561 *
11562 * In production, this is implemented using a try-catch. The reason we don't
11563 * use a try-catch directly is so that we can swap out a different
11564 * implementation in DEV mode.
11565 *
11566 * @param {String} name of the guard to use for logging or debugging
11567 * @param {Function} func The function to invoke
11568 * @param {*} context The context to use when calling the function
11569 * @param {...*} args Arguments for function
11570 */
11571
11572function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
11573 hasError = false;
11574 caughtError = null;
11575 invokeGuardedCallbackImpl$1.apply(reporter, arguments);
11576}
11577/**
11578 * Same as invokeGuardedCallback, but instead of returning an error, it stores
11579 * it in a global so it can be rethrown by `rethrowCaughtError` later.
11580 * TODO: See if caughtError and rethrowError can be unified.
11581 *
11582 * @param {String} name of the guard to use for logging or debugging
11583 * @param {Function} func The function to invoke
11584 * @param {*} context The context to use when calling the function
11585 * @param {...*} args Arguments for function
11586 */
11587
11588
11589/**
11590 * During execution of guarded functions we will capture the first error which
11591 * we will rethrow to be handled by the top level error handler.
11592 */
11593
11594
11595function hasCaughtError() {
11596 return hasError;
11597}
11598function clearCaughtError() {
11599 if (hasError) {
11600 var error = caughtError;
11601 hasError = false;
11602 caughtError = null;
11603 return error;
11604 } else {
11605 (function () {
11606 {
11607 {
11608 throw ReactError(Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."));
11609 }
11610 }
11611 })();
11612 }
11613}
11614
11615// This module is forked in different environments.
11616// By default, return `true` to log errors to the console.
11617// Forks can return `false` if this isn't desirable.
11618function showErrorDialog(capturedError) {
11619 return true;
11620}
11621
11622function logCapturedError(capturedError) {
11623 var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging.
11624 // This enables renderers like ReactNative to better manage redbox behavior.
11625
11626 if (logError === false) {
11627 return;
11628 }
11629
11630 var error = capturedError.error;
11631
11632 {
11633 var componentName = capturedError.componentName,
11634 componentStack = capturedError.componentStack,
11635 errorBoundaryName = capturedError.errorBoundaryName,
11636 errorBoundaryFound = capturedError.errorBoundaryFound,
11637 willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
11638 // `preventDefault()` in window `error` handler.
11639 // We record this information as an expando on the error.
11640
11641 if (error != null && error._suppressLogging) {
11642 if (errorBoundaryFound && willRetry) {
11643 // The error is recoverable and was silenced.
11644 // Ignore it and don't print the stack addendum.
11645 // This is handy for testing error boundaries without noise.
11646 return;
11647 } // The error is fatal. Since the silencing might have
11648 // been accidental, we'll surface it anyway.
11649 // However, the browser would have silenced the original error
11650 // so we'll print it first, and then print the stack addendum.
11651
11652
11653 console.error(error); // For a more detailed description of this block, see:
11654 // https://github.com/facebook/react/pull/13384
11655 }
11656
11657 var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
11658 var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
11659
11660 if (errorBoundaryFound && errorBoundaryName) {
11661 if (willRetry) {
11662 errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
11663 } else {
11664 errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
11665 }
11666 } else {
11667 errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
11668 }
11669
11670 var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
11671 // We don't include the original error message and JS stack because the browser
11672 // has already printed it. Even if the application swallows the error, it is still
11673 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
11674
11675 console.error(combinedMessage);
11676 }
11677}
11678
11679var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
11680
11681{
11682 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
11683}
11684
11685var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
11686function logError(boundary, errorInfo) {
11687 var source = errorInfo.source;
11688 var stack = errorInfo.stack;
11689
11690 if (stack === null && source !== null) {
11691 stack = getStackByFiberInDevAndProd(source);
11692 }
11693
11694 var capturedError = {
11695 componentName: source !== null ? getComponentName(source.type) : null,
11696 componentStack: stack !== null ? stack : '',
11697 error: errorInfo.value,
11698 errorBoundary: null,
11699 errorBoundaryName: null,
11700 errorBoundaryFound: false,
11701 willRetry: false
11702 };
11703
11704 if (boundary !== null && boundary.tag === ClassComponent) {
11705 capturedError.errorBoundary = boundary.stateNode;
11706 capturedError.errorBoundaryName = getComponentName(boundary.type);
11707 capturedError.errorBoundaryFound = true;
11708 capturedError.willRetry = true;
11709 }
11710
11711 try {
11712 logCapturedError(capturedError);
11713 } catch (e) {
11714 // This method must not throw, or React internal state will get messed up.
11715 // If console.error is overridden, or logCapturedError() shows a dialog that throws,
11716 // we want to report this error outside of the normal stack as a last resort.
11717 // https://github.com/facebook/react/issues/13188
11718 setTimeout(function () {
11719 throw e;
11720 });
11721 }
11722}
11723
11724var callComponentWillUnmountWithTimer = function (current$$1, instance) {
11725 startPhaseTimer(current$$1, 'componentWillUnmount');
11726 instance.props = current$$1.memoizedProps;
11727 instance.state = current$$1.memoizedState;
11728 instance.componentWillUnmount();
11729 stopPhaseTimer();
11730}; // Capture errors so they don't interrupt unmounting.
11731
11732
11733function safelyCallComponentWillUnmount(current$$1, instance) {
11734 {
11735 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
11736
11737 if (hasCaughtError()) {
11738 var unmountError = clearCaughtError();
11739 captureCommitPhaseError(current$$1, unmountError);
11740 }
11741 }
11742}
11743
11744function safelyDetachRef(current$$1) {
11745 var ref = current$$1.ref;
11746
11747 if (ref !== null) {
11748 if (typeof ref === 'function') {
11749 {
11750 invokeGuardedCallback(null, ref, null, null);
11751
11752 if (hasCaughtError()) {
11753 var refError = clearCaughtError();
11754 captureCommitPhaseError(current$$1, refError);
11755 }
11756 }
11757 } else {
11758 ref.current = null;
11759 }
11760 }
11761}
11762
11763function safelyCallDestroy(current$$1, destroy) {
11764 {
11765 invokeGuardedCallback(null, destroy, null);
11766
11767 if (hasCaughtError()) {
11768 var error = clearCaughtError();
11769 captureCommitPhaseError(current$$1, error);
11770 }
11771 }
11772}
11773
11774function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
11775 switch (finishedWork.tag) {
11776 case FunctionComponent:
11777 case ForwardRef:
11778 case SimpleMemoComponent:
11779 {
11780 commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
11781 return;
11782 }
11783
11784 case ClassComponent:
11785 {
11786 if (finishedWork.effectTag & Snapshot) {
11787 if (current$$1 !== null) {
11788 var prevProps = current$$1.memoizedProps;
11789 var prevState = current$$1.memoizedState;
11790 startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
11791 var instance = finishedWork.stateNode; // We could update instance props and state here,
11792 // but instead we rely on them being set during last render.
11793 // TODO: revisit this when we implement resuming.
11794
11795 {
11796 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11797 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11798 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11799 }
11800 }
11801
11802 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
11803
11804 {
11805 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
11806
11807 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
11808 didWarnSet.add(finishedWork.type);
11809 warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
11810 }
11811 }
11812
11813 instance.__reactInternalSnapshotBeforeUpdate = snapshot;
11814 stopPhaseTimer();
11815 }
11816 }
11817
11818 return;
11819 }
11820
11821 case HostRoot:
11822 case HostComponent:
11823 case HostText:
11824 case HostPortal:
11825 case IncompleteClassComponent:
11826 // Nothing to do for these component types
11827 return;
11828
11829 default:
11830 {
11831 (function () {
11832 {
11833 {
11834 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
11835 }
11836 }
11837 })();
11838 }
11839 }
11840}
11841
11842function commitHookEffectList(unmountTag, mountTag, finishedWork) {
11843 var updateQueue = finishedWork.updateQueue;
11844 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
11845
11846 if (lastEffect !== null) {
11847 var firstEffect = lastEffect.next;
11848 var effect = firstEffect;
11849
11850 do {
11851 if ((effect.tag & unmountTag) !== NoEffect$1) {
11852 // Unmount
11853 var destroy = effect.destroy;
11854 effect.destroy = undefined;
11855
11856 if (destroy !== undefined) {
11857 destroy();
11858 }
11859 }
11860
11861 if ((effect.tag & mountTag) !== NoEffect$1) {
11862 // Mount
11863 var create = effect.create;
11864 effect.destroy = create();
11865
11866 {
11867 var _destroy = effect.destroy;
11868
11869 if (_destroy !== undefined && typeof _destroy !== 'function') {
11870 var addendum = void 0;
11871
11872 if (_destroy === null) {
11873 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
11874 } else if (typeof _destroy.then === 'function') {
11875 addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
11876 } else {
11877 addendum = ' You returned: ' + _destroy;
11878 }
11879
11880 warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
11881 }
11882 }
11883 }
11884
11885 effect = effect.next;
11886 } while (effect !== firstEffect);
11887 }
11888}
11889
11890function commitPassiveHookEffects(finishedWork) {
11891 if ((finishedWork.effectTag & Passive) !== NoEffect) {
11892 switch (finishedWork.tag) {
11893 case FunctionComponent:
11894 case ForwardRef:
11895 case SimpleMemoComponent:
11896 {
11897 commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
11898 commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
11899 break;
11900 }
11901
11902 default:
11903 break;
11904 }
11905 }
11906}
11907
11908function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
11909 switch (finishedWork.tag) {
11910 case FunctionComponent:
11911 case ForwardRef:
11912 case SimpleMemoComponent:
11913 {
11914 commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
11915 break;
11916 }
11917
11918 case ClassComponent:
11919 {
11920 var instance = finishedWork.stateNode;
11921
11922 if (finishedWork.effectTag & Update) {
11923 if (current$$1 === null) {
11924 startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here,
11925 // but instead we rely on them being set during last render.
11926 // TODO: revisit this when we implement resuming.
11927
11928 {
11929 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11930 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11931 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11932 }
11933 }
11934
11935 instance.componentDidMount();
11936 stopPhaseTimer();
11937 } else {
11938 var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
11939 var prevState = current$$1.memoizedState;
11940 startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here,
11941 // but instead we rely on them being set during last render.
11942 // TODO: revisit this when we implement resuming.
11943
11944 {
11945 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11946 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11947 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11948 }
11949 }
11950
11951 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
11952 stopPhaseTimer();
11953 }
11954 }
11955
11956 var updateQueue = finishedWork.updateQueue;
11957
11958 if (updateQueue !== null) {
11959 {
11960 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11961 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11962 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11963 }
11964 } // We could update instance props and state here,
11965 // but instead we rely on them being set during last render.
11966 // TODO: revisit this when we implement resuming.
11967
11968
11969 commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
11970 }
11971
11972 return;
11973 }
11974
11975 case HostRoot:
11976 {
11977 var _updateQueue = finishedWork.updateQueue;
11978
11979 if (_updateQueue !== null) {
11980 var _instance = null;
11981
11982 if (finishedWork.child !== null) {
11983 switch (finishedWork.child.tag) {
11984 case HostComponent:
11985 _instance = getPublicInstance(finishedWork.child.stateNode);
11986 break;
11987
11988 case ClassComponent:
11989 _instance = finishedWork.child.stateNode;
11990 break;
11991 }
11992 }
11993
11994 commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
11995 }
11996
11997 return;
11998 }
11999
12000 case HostComponent:
12001 {
12002 var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted
12003 // (eg DOM renderer may schedule auto-focus for inputs and form controls).
12004 // These effects should only be committed when components are first mounted,
12005 // aka when there is no current/alternate.
12006
12007 if (current$$1 === null && finishedWork.effectTag & Update) {
12008 var type = finishedWork.type;
12009 var props = finishedWork.memoizedProps;
12010 commitMount(_instance2, type, props, finishedWork);
12011 }
12012
12013 return;
12014 }
12015
12016 case HostText:
12017 {
12018 // We have no life-cycles associated with text.
12019 return;
12020 }
12021
12022 case HostPortal:
12023 {
12024 // We have no life-cycles associated with portals.
12025 return;
12026 }
12027
12028 case Profiler:
12029 {
12030 if (enableProfilerTimer) {
12031 var onRender = finishedWork.memoizedProps.onRender;
12032
12033 if (typeof onRender === 'function') {
12034 if (enableSchedulerTracing) {
12035 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
12036 } else {
12037 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
12038 }
12039 }
12040 }
12041
12042 return;
12043 }
12044
12045 case SuspenseComponent:
12046 {
12047 commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
12048 return;
12049 }
12050
12051 case SuspenseListComponent:
12052 case IncompleteClassComponent:
12053 case FundamentalComponent:
12054 case ScopeComponent:
12055 return;
12056
12057 default:
12058 {
12059 (function () {
12060 {
12061 {
12062 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
12063 }
12064 }
12065 })();
12066 }
12067 }
12068}
12069
12070function hideOrUnhideAllChildren(finishedWork, isHidden) {
12071 if (supportsMutation) {
12072 // We only have the top Fiber that was inserted but we need to recurse down its
12073 // children to find all the terminal nodes.
12074 var node = finishedWork;
12075
12076 while (true) {
12077 if (node.tag === HostComponent) {
12078 var instance = node.stateNode;
12079
12080 if (isHidden) {
12081 hideInstance(instance);
12082 } else {
12083 unhideInstance(node.stateNode, node.memoizedProps);
12084 }
12085 } else if (node.tag === HostText) {
12086 var _instance3 = node.stateNode;
12087
12088 if (isHidden) {
12089 hideTextInstance(_instance3);
12090 } else {
12091 unhideTextInstance(_instance3, node.memoizedProps);
12092 }
12093 } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) {
12094 // Found a nested Suspense component that timed out. Skip over the
12095 // primary child fragment, which should remain hidden.
12096 var fallbackChildFragment = node.child.sibling;
12097 fallbackChildFragment.return = node;
12098 node = fallbackChildFragment;
12099 continue;
12100 } else if (node.child !== null) {
12101 node.child.return = node;
12102 node = node.child;
12103 continue;
12104 }
12105
12106 if (node === finishedWork) {
12107 return;
12108 }
12109
12110 while (node.sibling === null) {
12111 if (node.return === null || node.return === finishedWork) {
12112 return;
12113 }
12114
12115 node = node.return;
12116 }
12117
12118 node.sibling.return = node.return;
12119 node = node.sibling;
12120 }
12121 }
12122}
12123
12124function commitAttachRef(finishedWork) {
12125 var ref = finishedWork.ref;
12126
12127 if (ref !== null) {
12128 var instance = finishedWork.stateNode;
12129 var instanceToUse;
12130
12131 switch (finishedWork.tag) {
12132 case HostComponent:
12133 instanceToUse = getPublicInstance(instance);
12134 break;
12135
12136 default:
12137 instanceToUse = instance;
12138 } // Moved outside to ensure DCE works with this flag
12139
12140
12141 if (enableScopeAPI && finishedWork.tag === ScopeComponent) {
12142 instanceToUse = instance.methods;
12143 }
12144
12145 if (typeof ref === 'function') {
12146 ref(instanceToUse);
12147 } else {
12148 {
12149 if (!ref.hasOwnProperty('current')) {
12150 warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
12151 }
12152 }
12153
12154 ref.current = instanceToUse;
12155 }
12156 }
12157}
12158
12159function commitDetachRef(current$$1) {
12160 var currentRef = current$$1.ref;
12161
12162 if (currentRef !== null) {
12163 if (typeof currentRef === 'function') {
12164 currentRef(null);
12165 } else {
12166 currentRef.current = null;
12167 }
12168 }
12169} // User-originating errors (lifecycles and refs) should not interrupt
12170// deletion, so don't let them throw. Host-originating errors should
12171// interrupt deletion, so it's okay
12172
12173
12174function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) {
12175 onCommitUnmount(current$$1);
12176
12177 switch (current$$1.tag) {
12178 case FunctionComponent:
12179 case ForwardRef:
12180 case MemoComponent:
12181 case SimpleMemoComponent:
12182 {
12183 var updateQueue = current$$1.updateQueue;
12184
12185 if (updateQueue !== null) {
12186 var lastEffect = updateQueue.lastEffect;
12187
12188 if (lastEffect !== null) {
12189 var firstEffect = lastEffect.next; // When the owner fiber is deleted, the destroy function of a passive
12190 // effect hook is called during the synchronous commit phase. This is
12191 // a concession to implementation complexity. Calling it in the
12192 // passive effect phase (like they usually are, when dependencies
12193 // change during an update) would require either traversing the
12194 // children of the deleted fiber again, or including unmount effects
12195 // as part of the fiber effect list.
12196 //
12197 // Because this is during the sync commit phase, we need to change
12198 // the priority.
12199 //
12200 // TODO: Reconsider this implementation trade off.
12201
12202 var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
12203 runWithPriority(priorityLevel, function () {
12204 var effect = firstEffect;
12205
12206 do {
12207 var destroy = effect.destroy;
12208
12209 if (destroy !== undefined) {
12210 safelyCallDestroy(current$$1, destroy);
12211 }
12212
12213 effect = effect.next;
12214 } while (effect !== firstEffect);
12215 });
12216 }
12217 }
12218
12219 break;
12220 }
12221
12222 case ClassComponent:
12223 {
12224 safelyDetachRef(current$$1);
12225 var instance = current$$1.stateNode;
12226
12227 if (typeof instance.componentWillUnmount === 'function') {
12228 safelyCallComponentWillUnmount(current$$1, instance);
12229 }
12230
12231 return;
12232 }
12233
12234 case HostComponent:
12235 {
12236 if (enableFlareAPI) {
12237 var dependencies = current$$1.dependencies;
12238
12239 if (dependencies !== null) {
12240 var respondersMap = dependencies.responders;
12241
12242 if (respondersMap !== null) {
12243 var responderInstances = Array.from(respondersMap.values());
12244
12245 for (var i = 0, length = responderInstances.length; i < length; i++) {
12246 var responderInstance = responderInstances[i];
12247 unmountResponderInstance(responderInstance);
12248 }
12249
12250 dependencies.responders = null;
12251 }
12252 }
12253 }
12254
12255 safelyDetachRef(current$$1);
12256 return;
12257 }
12258
12259 case HostPortal:
12260 {
12261 // TODO: this is recursive.
12262 // We are also not using this parent because
12263 // the portal will get pushed immediately.
12264 if (supportsMutation) {
12265 unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
12266 } else if (supportsPersistence) {
12267 emptyPortalContainer(current$$1);
12268 }
12269
12270 return;
12271 }
12272
12273 case FundamentalComponent:
12274 {
12275 if (enableFundamentalAPI) {
12276 var fundamentalInstance = current$$1.stateNode;
12277
12278 if (fundamentalInstance !== null) {
12279 unmountFundamentalComponent(fundamentalInstance);
12280 current$$1.stateNode = null;
12281 }
12282 }
12283
12284 return;
12285 }
12286
12287 case DehydratedFragment:
12288 {
12289 if (enableSuspenseCallback) {
12290 var hydrationCallbacks = finishedRoot.hydrationCallbacks;
12291
12292 if (hydrationCallbacks !== null) {
12293 var onDeleted = hydrationCallbacks.onDeleted;
12294
12295 if (onDeleted) {
12296 onDeleted(current$$1.stateNode);
12297 }
12298 }
12299 }
12300
12301 return;
12302 }
12303
12304 case ScopeComponent:
12305 {
12306 if (enableScopeAPI) {
12307 safelyDetachRef(current$$1);
12308 }
12309 }
12310 }
12311}
12312
12313function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
12314 // While we're inside a removed host node we don't want to call
12315 // removeChild on the inner nodes because they're removed by the top
12316 // call anyway. We also want to call componentWillUnmount on all
12317 // composites before this host node is removed from the tree. Therefore
12318 // we do an inner loop while we're still inside the host node.
12319 var node = root;
12320
12321 while (true) {
12322 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes.
12323 // Skip portals because commitUnmount() currently visits them recursively.
12324
12325 if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above.
12326 // If we don't use mutation we drill down into portals here instead.
12327 !supportsMutation || node.tag !== HostPortal)) {
12328 node.child.return = node;
12329 node = node.child;
12330 continue;
12331 }
12332
12333 if (node === root) {
12334 return;
12335 }
12336
12337 while (node.sibling === null) {
12338 if (node.return === null || node.return === root) {
12339 return;
12340 }
12341
12342 node = node.return;
12343 }
12344
12345 node.sibling.return = node.return;
12346 node = node.sibling;
12347 }
12348}
12349
12350function detachFiber(current$$1) {
12351 var alternate = current$$1.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we
12352 // should clear the child pointer of the parent alternate to let this
12353 // get GC:ed but we don't know which for sure which parent is the current
12354 // one so we'll settle for GC:ing the subtree of this child. This child
12355 // itself will be GC:ed when the parent updates the next time.
12356
12357 current$$1.return = null;
12358 current$$1.child = null;
12359 current$$1.memoizedState = null;
12360 current$$1.updateQueue = null;
12361 current$$1.dependencies = null;
12362 current$$1.alternate = null;
12363 current$$1.firstEffect = null;
12364 current$$1.lastEffect = null;
12365 current$$1.pendingProps = null;
12366 current$$1.memoizedProps = null;
12367
12368 if (alternate !== null) {
12369 detachFiber(alternate);
12370 }
12371}
12372
12373function emptyPortalContainer(current$$1) {
12374 if (!supportsPersistence) {
12375 return;
12376 }
12377
12378 var portal = current$$1.stateNode;
12379 var containerInfo = portal.containerInfo;
12380 var emptyChildSet = createContainerChildSet(containerInfo);
12381 replaceContainerChildren(containerInfo, emptyChildSet);
12382}
12383
12384function commitContainer(finishedWork) {
12385 if (!supportsPersistence) {
12386 return;
12387 }
12388
12389 switch (finishedWork.tag) {
12390 case ClassComponent:
12391 case HostComponent:
12392 case HostText:
12393 case FundamentalComponent:
12394 {
12395 return;
12396 }
12397
12398 case HostRoot:
12399 case HostPortal:
12400 {
12401 var portalOrRoot = finishedWork.stateNode;
12402 var containerInfo = portalOrRoot.containerInfo,
12403 pendingChildren = portalOrRoot.pendingChildren;
12404 replaceContainerChildren(containerInfo, pendingChildren);
12405 return;
12406 }
12407
12408 default:
12409 {
12410 (function () {
12411 {
12412 {
12413 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
12414 }
12415 }
12416 })();
12417 }
12418 }
12419}
12420
12421function getHostParentFiber(fiber) {
12422 var parent = fiber.return;
12423
12424 while (parent !== null) {
12425 if (isHostParent(parent)) {
12426 return parent;
12427 }
12428
12429 parent = parent.return;
12430 }
12431
12432 (function () {
12433 {
12434 {
12435 throw ReactError(Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."));
12436 }
12437 }
12438 })();
12439}
12440
12441function isHostParent(fiber) {
12442 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
12443}
12444
12445function getHostSibling(fiber) {
12446 // We're going to search forward into the tree until we find a sibling host
12447 // node. Unfortunately, if multiple insertions are done in a row we have to
12448 // search past them. This leads to exponential search for the next sibling.
12449 // TODO: Find a more efficient way to do this.
12450 var node = fiber;
12451
12452 siblings: while (true) {
12453 // If we didn't find anything, let's try the next sibling.
12454 while (node.sibling === null) {
12455 if (node.return === null || isHostParent(node.return)) {
12456 // If we pop out of the root or hit the parent the fiber we are the
12457 // last sibling.
12458 return null;
12459 }
12460
12461 node = node.return;
12462 }
12463
12464 node.sibling.return = node.return;
12465 node = node.sibling;
12466
12467 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
12468 // If it is not host node and, we might have a host node inside it.
12469 // Try to search down until we find one.
12470 if (node.effectTag & Placement) {
12471 // If we don't have a child, try the siblings instead.
12472 continue siblings;
12473 } // If we don't have a child, try the siblings instead.
12474 // We also skip portals because they are not part of this host tree.
12475
12476
12477 if (node.child === null || node.tag === HostPortal) {
12478 continue siblings;
12479 } else {
12480 node.child.return = node;
12481 node = node.child;
12482 }
12483 } // Check if this host node is stable or about to be placed.
12484
12485
12486 if (!(node.effectTag & Placement)) {
12487 // Found it!
12488 return node.stateNode;
12489 }
12490 }
12491}
12492
12493function commitPlacement(finishedWork) {
12494 if (!supportsMutation) {
12495 return;
12496 } // Recursively insert all host nodes into the parent.
12497
12498
12499 var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together.
12500
12501 var parent;
12502 var isContainer;
12503 var parentStateNode = parentFiber.stateNode;
12504
12505 switch (parentFiber.tag) {
12506 case HostComponent:
12507 parent = parentStateNode;
12508 isContainer = false;
12509 break;
12510
12511 case HostRoot:
12512 parent = parentStateNode.containerInfo;
12513 isContainer = true;
12514 break;
12515
12516 case HostPortal:
12517 parent = parentStateNode.containerInfo;
12518 isContainer = true;
12519 break;
12520
12521 case FundamentalComponent:
12522 if (enableFundamentalAPI) {
12523 parent = parentStateNode.instance;
12524 isContainer = false;
12525 }
12526
12527 // eslint-disable-next-line-no-fallthrough
12528
12529 default:
12530 (function () {
12531 {
12532 {
12533 throw ReactError(Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue."));
12534 }
12535 }
12536 })();
12537
12538 }
12539
12540 if (parentFiber.effectTag & ContentReset) {
12541 // Reset the text content of the parent before doing any insertions
12542 resetTextContent(parent); // Clear ContentReset from the effect tag
12543
12544 parentFiber.effectTag &= ~ContentReset;
12545 }
12546
12547 var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
12548 // children to find all the terminal nodes.
12549
12550 var node = finishedWork;
12551
12552 while (true) {
12553 var isHost = node.tag === HostComponent || node.tag === HostText;
12554
12555 if (isHost || enableFundamentalAPI && node.tag === FundamentalComponent) {
12556 var stateNode = isHost ? node.stateNode : node.stateNode.instance;
12557
12558 if (before) {
12559 if (isContainer) {
12560 insertInContainerBefore(parent, stateNode, before);
12561 } else {
12562 insertBefore(parent, stateNode, before);
12563 }
12564 } else {
12565 if (isContainer) {
12566 appendChildToContainer(parent, stateNode);
12567 } else {
12568 appendChild(parent, stateNode);
12569 }
12570 }
12571 } else if (node.tag === HostPortal) {// If the insertion itself is a portal, then we don't want to traverse
12572 // down its children. Instead, we'll get insertions from each child in
12573 // the portal directly.
12574 } else if (node.child !== null) {
12575 node.child.return = node;
12576 node = node.child;
12577 continue;
12578 }
12579
12580 if (node === finishedWork) {
12581 return;
12582 }
12583
12584 while (node.sibling === null) {
12585 if (node.return === null || node.return === finishedWork) {
12586 return;
12587 }
12588
12589 node = node.return;
12590 }
12591
12592 node.sibling.return = node.return;
12593 node = node.sibling;
12594 }
12595}
12596
12597function unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel) {
12598 // We only have the top Fiber that was deleted but we need to recurse down its
12599 // children to find all the terminal nodes.
12600 var node = current$$1; // Each iteration, currentParent is populated with node's host parent if not
12601 // currentParentIsValid.
12602
12603 var currentParentIsValid = false; // Note: these two variables *must* always be updated together.
12604
12605 var currentParent;
12606 var currentParentIsContainer;
12607
12608 while (true) {
12609 if (!currentParentIsValid) {
12610 var parent = node.return;
12611
12612 findParent: while (true) {
12613 (function () {
12614 if (!(parent !== null)) {
12615 {
12616 throw ReactError(Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."));
12617 }
12618 }
12619 })();
12620
12621 var parentStateNode = parent.stateNode;
12622
12623 switch (parent.tag) {
12624 case HostComponent:
12625 currentParent = parentStateNode;
12626 currentParentIsContainer = false;
12627 break findParent;
12628
12629 case HostRoot:
12630 currentParent = parentStateNode.containerInfo;
12631 currentParentIsContainer = true;
12632 break findParent;
12633
12634 case HostPortal:
12635 currentParent = parentStateNode.containerInfo;
12636 currentParentIsContainer = true;
12637 break findParent;
12638
12639 case FundamentalComponent:
12640 if (enableFundamentalAPI) {
12641 currentParent = parentStateNode.instance;
12642 currentParentIsContainer = false;
12643 }
12644
12645 }
12646
12647 parent = parent.return;
12648 }
12649
12650 currentParentIsValid = true;
12651 }
12652
12653 if (node.tag === HostComponent || node.tag === HostText) {
12654 commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
12655 // node from the tree.
12656
12657 if (currentParentIsContainer) {
12658 removeChildFromContainer(currentParent, node.stateNode);
12659 } else {
12660 removeChild(currentParent, node.stateNode);
12661 } // Don't visit children because we already visited them.
12662
12663 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
12664 var fundamentalNode = node.stateNode.instance;
12665 commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
12666 // node from the tree.
12667
12668 if (currentParentIsContainer) {
12669 removeChildFromContainer(currentParent, fundamentalNode);
12670 } else {
12671 removeChild(currentParent, fundamentalNode);
12672 }
12673 } else if (enableSuspenseServerRenderer && node.tag === DehydratedFragment) {
12674 if (enableSuspenseCallback) {
12675 var hydrationCallbacks = finishedRoot.hydrationCallbacks;
12676
12677 if (hydrationCallbacks !== null) {
12678 var onDeleted = hydrationCallbacks.onDeleted;
12679
12680 if (onDeleted) {
12681 onDeleted(node.stateNode);
12682 }
12683 }
12684 } // Delete the dehydrated suspense boundary and all of its content.
12685
12686
12687 if (currentParentIsContainer) {
12688 clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
12689 } else {
12690 clearSuspenseBoundary(currentParent, node.stateNode);
12691 }
12692 } else if (node.tag === HostPortal) {
12693 if (node.child !== null) {
12694 // When we go into a portal, it becomes the parent to remove from.
12695 // We will reassign it back when we pop the portal on the way up.
12696 currentParent = node.stateNode.containerInfo;
12697 currentParentIsContainer = true; // Visit children because portals might contain host components.
12698
12699 node.child.return = node;
12700 node = node.child;
12701 continue;
12702 }
12703 } else {
12704 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below.
12705
12706 if (node.child !== null) {
12707 node.child.return = node;
12708 node = node.child;
12709 continue;
12710 }
12711 }
12712
12713 if (node === current$$1) {
12714 return;
12715 }
12716
12717 while (node.sibling === null) {
12718 if (node.return === null || node.return === current$$1) {
12719 return;
12720 }
12721
12722 node = node.return;
12723
12724 if (node.tag === HostPortal) {
12725 // When we go out of the portal, we need to restore the parent.
12726 // Since we don't keep a stack of them, we will search for it.
12727 currentParentIsValid = false;
12728 }
12729 }
12730
12731 node.sibling.return = node.return;
12732 node = node.sibling;
12733 }
12734}
12735
12736function commitDeletion(finishedRoot, current$$1, renderPriorityLevel) {
12737 if (supportsMutation) {
12738 // Recursively delete all host nodes from the parent.
12739 // Detach refs and call componentWillUnmount() on the whole subtree.
12740 unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
12741 } else {
12742 // Detach refs and call componentWillUnmount() on the whole subtree.
12743 commitNestedUnmounts(finishedRoot, current$$1, renderPriorityLevel);
12744 }
12745
12746 detachFiber(current$$1);
12747}
12748
12749function commitWork(current$$1, finishedWork) {
12750 if (!supportsMutation) {
12751 switch (finishedWork.tag) {
12752 case FunctionComponent:
12753 case ForwardRef:
12754 case MemoComponent:
12755 case SimpleMemoComponent:
12756 {
12757 // Note: We currently never use MountMutation, but useLayout uses
12758 // UnmountMutation.
12759 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
12760 return;
12761 }
12762
12763 case Profiler:
12764 {
12765 return;
12766 }
12767
12768 case SuspenseComponent:
12769 {
12770 commitSuspenseComponent(finishedWork);
12771 attachSuspenseRetryListeners(finishedWork);
12772 return;
12773 }
12774
12775 case SuspenseListComponent:
12776 {
12777 attachSuspenseRetryListeners(finishedWork);
12778 return;
12779 }
12780
12781 case HostRoot:
12782 {
12783 if (supportsHydration) {
12784 var root = finishedWork.stateNode;
12785
12786 if (root.hydrate) {
12787 // We've just hydrated. No need to hydrate again.
12788 root.hydrate = false;
12789 commitHydratedContainer(root.containerInfo);
12790 }
12791 }
12792
12793 break;
12794 }
12795 }
12796
12797 commitContainer(finishedWork);
12798 return;
12799 }
12800
12801 switch (finishedWork.tag) {
12802 case FunctionComponent:
12803 case ForwardRef:
12804 case MemoComponent:
12805 case SimpleMemoComponent:
12806 {
12807 // Note: We currently never use MountMutation, but useLayout uses
12808 // UnmountMutation.
12809 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
12810 return;
12811 }
12812
12813 case ClassComponent:
12814 {
12815 return;
12816 }
12817
12818 case HostComponent:
12819 {
12820 var instance = finishedWork.stateNode;
12821
12822 if (instance != null) {
12823 // Commit the work prepared earlier.
12824 var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
12825 // as the newProps. The updatePayload will contain the real change in
12826 // this case.
12827
12828 var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
12829 var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components.
12830
12831 var updatePayload = finishedWork.updateQueue;
12832 finishedWork.updateQueue = null;
12833
12834 if (updatePayload !== null) {
12835 commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
12836 }
12837
12838 if (enableFlareAPI) {
12839 var prevListeners = oldProps.listeners;
12840 var nextListeners = newProps.listeners;
12841
12842 if (prevListeners !== nextListeners) {
12843 updateEventListeners(nextListeners, finishedWork, null);
12844 }
12845 }
12846 }
12847
12848 return;
12849 }
12850
12851 case HostText:
12852 {
12853 (function () {
12854 if (!(finishedWork.stateNode !== null)) {
12855 {
12856 throw ReactError(Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue."));
12857 }
12858 }
12859 })();
12860
12861 var textInstance = finishedWork.stateNode;
12862 var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
12863 // as the newProps. The updatePayload will contain the real change in
12864 // this case.
12865
12866 var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
12867 commitTextUpdate(textInstance, oldText, newText);
12868 return;
12869 }
12870
12871 case HostRoot:
12872 {
12873 if (supportsHydration) {
12874 var _root = finishedWork.stateNode;
12875
12876 if (_root.hydrate) {
12877 // We've just hydrated. No need to hydrate again.
12878 _root.hydrate = false;
12879 commitHydratedContainer(_root.containerInfo);
12880 }
12881 }
12882
12883 return;
12884 }
12885
12886 case Profiler:
12887 {
12888 return;
12889 }
12890
12891 case SuspenseComponent:
12892 {
12893 commitSuspenseComponent(finishedWork);
12894 attachSuspenseRetryListeners(finishedWork);
12895 return;
12896 }
12897
12898 case SuspenseListComponent:
12899 {
12900 attachSuspenseRetryListeners(finishedWork);
12901 return;
12902 }
12903
12904 case IncompleteClassComponent:
12905 {
12906 return;
12907 }
12908
12909 case FundamentalComponent:
12910 {
12911 if (enableFundamentalAPI) {
12912 var fundamentalInstance = finishedWork.stateNode;
12913 updateFundamentalComponent(fundamentalInstance);
12914 }
12915
12916 return;
12917 }
12918
12919 case ScopeComponent:
12920 {
12921 if (enableScopeAPI) {
12922 var scopeInstance = finishedWork.stateNode;
12923 scopeInstance.fiber = finishedWork;
12924
12925 if (enableFlareAPI) {
12926 var _newProps = finishedWork.memoizedProps;
12927
12928 var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps;
12929
12930 var _prevListeners = _oldProps.listeners;
12931 var _nextListeners = _newProps.listeners;
12932
12933 if (_prevListeners !== _nextListeners) {
12934 updateEventListeners(_nextListeners, finishedWork, null);
12935 }
12936 }
12937 }
12938
12939 return;
12940 }
12941
12942 default:
12943 {
12944 (function () {
12945 {
12946 {
12947 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
12948 }
12949 }
12950 })();
12951 }
12952 }
12953}
12954
12955function commitSuspenseComponent(finishedWork) {
12956 var newState = finishedWork.memoizedState;
12957 var newDidTimeout;
12958 var primaryChildParent = finishedWork;
12959
12960 if (newState === null) {
12961 newDidTimeout = false;
12962 } else {
12963 newDidTimeout = true;
12964 primaryChildParent = finishedWork.child;
12965 markCommitTimeOfFallback();
12966 }
12967
12968 if (supportsMutation && primaryChildParent !== null) {
12969 hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
12970 }
12971
12972 if (enableSuspenseCallback && newState !== null) {
12973 var suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
12974
12975 if (typeof suspenseCallback === 'function') {
12976 var thenables = finishedWork.updateQueue;
12977
12978 if (thenables !== null) {
12979 suspenseCallback(new Set(thenables));
12980 }
12981 } else {
12982 if (suspenseCallback !== undefined) {
12983 warning$1(false, 'Unexpected type for suspenseCallback.');
12984 }
12985 }
12986 }
12987}
12988
12989function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
12990 if (!supportsHydration) {
12991 return;
12992 }
12993
12994 var newState = finishedWork.memoizedState;
12995
12996 if (newState === null) {
12997 var current$$1 = finishedWork.alternate;
12998
12999 if (current$$1 !== null) {
13000 var prevState = current$$1.memoizedState;
13001
13002 if (prevState !== null) {
13003 var suspenseInstance = prevState.dehydrated;
13004
13005 if (suspenseInstance !== null) {
13006 commitHydratedSuspenseInstance(suspenseInstance);
13007
13008 if (enableSuspenseCallback) {
13009 var hydrationCallbacks = finishedRoot.hydrationCallbacks;
13010
13011 if (hydrationCallbacks !== null) {
13012 var onHydrated = hydrationCallbacks.onHydrated;
13013
13014 if (onHydrated) {
13015 onHydrated(suspenseInstance);
13016 }
13017 }
13018 }
13019 }
13020 }
13021 }
13022 }
13023}
13024
13025function attachSuspenseRetryListeners(finishedWork) {
13026 // If this boundary just timed out, then it will have a set of thenables.
13027 // For each thenable, attach a listener so that when it resolves, React
13028 // attempts to re-render the boundary in the primary (pre-timeout) state.
13029 var thenables = finishedWork.updateQueue;
13030
13031 if (thenables !== null) {
13032 finishedWork.updateQueue = null;
13033 var retryCache = finishedWork.stateNode;
13034
13035 if (retryCache === null) {
13036 retryCache = finishedWork.stateNode = new PossiblyWeakSet();
13037 }
13038
13039 thenables.forEach(function (thenable) {
13040 // Memoize using the boundary fiber to prevent redundant listeners.
13041 var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
13042
13043 if (!retryCache.has(thenable)) {
13044 if (enableSchedulerTracing) {
13045 if (thenable.__reactDoNotTraceInteractions !== true) {
13046 retry = tracing.unstable_wrap(retry);
13047 }
13048 }
13049
13050 retryCache.add(thenable);
13051 thenable.then(retry, retry);
13052 }
13053 });
13054 }
13055}
13056
13057function commitResetTextContent(current$$1) {
13058 if (!supportsMutation) {
13059 return;
13060 }
13061
13062 resetTextContent(current$$1.stateNode);
13063}
13064
13065var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
13066
13067function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
13068 var update = createUpdate(expirationTime, null); // Unmount the root by rendering null.
13069
13070 update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
13071 // being called "element".
13072
13073 update.payload = {
13074 element: null
13075 };
13076 var error = errorInfo.value;
13077
13078 update.callback = function () {
13079 onUncaughtError(error);
13080 logError(fiber, errorInfo);
13081 };
13082
13083 return update;
13084}
13085
13086function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
13087 var update = createUpdate(expirationTime, null);
13088 update.tag = CaptureUpdate;
13089 var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
13090
13091 if (typeof getDerivedStateFromError === 'function') {
13092 var error = errorInfo.value;
13093
13094 update.payload = function () {
13095 logError(fiber, errorInfo);
13096 return getDerivedStateFromError(error);
13097 };
13098 }
13099
13100 var inst = fiber.stateNode;
13101
13102 if (inst !== null && typeof inst.componentDidCatch === 'function') {
13103 update.callback = function callback() {
13104 {
13105 markFailedErrorBoundaryForHotReloading(fiber);
13106 }
13107
13108 if (typeof getDerivedStateFromError !== 'function') {
13109 // To preserve the preexisting retry behavior of error boundaries,
13110 // we keep track of which ones already failed during this batch.
13111 // This gets reset before we yield back to the browser.
13112 // TODO: Warn in strict mode if getDerivedStateFromError is
13113 // not defined.
13114 markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
13115
13116 logError(fiber, errorInfo);
13117 }
13118
13119 var error = errorInfo.value;
13120 var stack = errorInfo.stack;
13121 this.componentDidCatch(error, {
13122 componentStack: stack !== null ? stack : ''
13123 });
13124
13125 {
13126 if (typeof getDerivedStateFromError !== 'function') {
13127 // If componentDidCatch is the only error boundary method defined,
13128 // then it needs to call setState to recover from errors.
13129 // If no state update is scheduled then the boundary will swallow the error.
13130 !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown') : void 0;
13131 }
13132 }
13133 };
13134 } else {
13135 update.callback = function () {
13136 markFailedErrorBoundaryForHotReloading(fiber);
13137 };
13138 }
13139
13140 return update;
13141}
13142
13143function attachPingListener(root, renderExpirationTime, thenable) {
13144 // Attach a listener to the promise to "ping" the root and retry. But
13145 // only if one does not already exist for the current render expiration
13146 // time (which acts like a "thread ID" here).
13147 var pingCache = root.pingCache;
13148 var threadIDs;
13149
13150 if (pingCache === null) {
13151 pingCache = root.pingCache = new PossiblyWeakMap();
13152 threadIDs = new Set();
13153 pingCache.set(thenable, threadIDs);
13154 } else {
13155 threadIDs = pingCache.get(thenable);
13156
13157 if (threadIDs === undefined) {
13158 threadIDs = new Set();
13159 pingCache.set(thenable, threadIDs);
13160 }
13161 }
13162
13163 if (!threadIDs.has(renderExpirationTime)) {
13164 // Memoize using the thread ID to prevent redundant listeners.
13165 threadIDs.add(renderExpirationTime);
13166 var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
13167 thenable.then(ping, ping);
13168 }
13169}
13170
13171function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
13172 // The source fiber did not complete.
13173 sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
13174
13175 sourceFiber.firstEffect = sourceFiber.lastEffect = null;
13176
13177 if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
13178 // This is a thenable.
13179 var thenable = value;
13180 checkForWrongSuspensePriorityInDEV(sourceFiber);
13181 var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view.
13182
13183 var _workInProgress = returnFiber;
13184
13185 do {
13186 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
13187 // Found the nearest boundary.
13188 // Stash the promise on the boundary fiber. If the boundary times out, we'll
13189 // attach another listener to flip the boundary back to its normal state.
13190 var thenables = _workInProgress.updateQueue;
13191
13192 if (thenables === null) {
13193 var updateQueue = new Set();
13194 updateQueue.add(thenable);
13195 _workInProgress.updateQueue = updateQueue;
13196 } else {
13197 thenables.add(thenable);
13198 } // If the boundary is outside of batched mode, we should *not*
13199 // suspend the commit. Pretend as if the suspended component rendered
13200 // null and keep rendering. In the commit phase, we'll schedule a
13201 // subsequent synchronous update to re-render the Suspense.
13202 //
13203 // Note: It doesn't matter whether the component that suspended was
13204 // inside a batched mode tree. If the Suspense is outside of it, we
13205 // should *not* suspend the commit.
13206
13207
13208 if ((_workInProgress.mode & BatchedMode) === NoMode) {
13209 _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete.
13210 // But we shouldn't call any lifecycle methods or callbacks. Remove
13211 // all lifecycle effect tags.
13212
13213 sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
13214
13215 if (sourceFiber.tag === ClassComponent) {
13216 var currentSourceFiber = sourceFiber.alternate;
13217
13218 if (currentSourceFiber === null) {
13219 // This is a new mount. Change the tag so it's not mistaken for a
13220 // completed class component. For example, we should not call
13221 // componentWillUnmount if it is deleted.
13222 sourceFiber.tag = IncompleteClassComponent;
13223 } else {
13224 // When we try rendering again, we should not reuse the current fiber,
13225 // since it's known to be in an inconsistent state. Use a force update to
13226 // prevent a bail out.
13227 var update = createUpdate(Sync, null);
13228 update.tag = ForceUpdate;
13229 enqueueUpdate(sourceFiber, update);
13230 }
13231 } // The source fiber did not complete. Mark it with Sync priority to
13232 // indicate that it still has pending work.
13233
13234
13235 sourceFiber.expirationTime = Sync; // Exit without suspending.
13236
13237 return;
13238 } // Confirmed that the boundary is in a concurrent mode tree. Continue
13239 // with the normal suspend path.
13240 //
13241 // After this we'll use a set of heuristics to determine whether this
13242 // render pass will run to completion or restart or "suspend" the commit.
13243 // The actual logic for this is spread out in different places.
13244 //
13245 // This first principle is that if we're going to suspend when we complete
13246 // a root, then we should also restart if we get an update or ping that
13247 // might unsuspend it, and vice versa. The only reason to suspend is
13248 // because you think you might want to restart before committing. However,
13249 // it doesn't make sense to restart only while in the period we're suspended.
13250 //
13251 // Restarting too aggressively is also not good because it starves out any
13252 // intermediate loading state. So we use heuristics to determine when.
13253 // Suspense Heuristics
13254 //
13255 // If nothing threw a Promise or all the same fallbacks are already showing,
13256 // then don't suspend/restart.
13257 //
13258 // If this is an initial render of a new tree of Suspense boundaries and
13259 // those trigger a fallback, then don't suspend/restart. We want to ensure
13260 // that we can show the initial loading state as quickly as possible.
13261 //
13262 // If we hit a "Delayed" case, such as when we'd switch from content back into
13263 // a fallback, then we should always suspend/restart. SuspenseConfig applies to
13264 // this case. If none is defined, JND is used instead.
13265 //
13266 // If we're already showing a fallback and it gets "retried", allowing us to show
13267 // another level, but there's still an inner boundary that would show a fallback,
13268 // then we suspend/restart for 500ms since the last time we showed a fallback
13269 // anywhere in the tree. This effectively throttles progressive loading into a
13270 // consistent train of commits. This also gives us an opportunity to restart to
13271 // get to the completed state slightly earlier.
13272 //
13273 // If there's ambiguity due to batching it's resolved in preference of:
13274 // 1) "delayed", 2) "initial render", 3) "retry".
13275 //
13276 // We want to ensure that a "busy" state doesn't get force committed. We want to
13277 // ensure that new initial loading states can commit as soon as possible.
13278
13279
13280 attachPingListener(root, renderExpirationTime, thenable);
13281 _workInProgress.effectTag |= ShouldCapture;
13282 _workInProgress.expirationTime = renderExpirationTime;
13283 return;
13284 } // This boundary already captured during this render. Continue to the next
13285 // boundary.
13286
13287
13288 _workInProgress = _workInProgress.return;
13289 } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
13290 // TODO: Use invariant so the message is stripped in prod?
13291
13292
13293 value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber));
13294 } // We didn't find a boundary that could handle this type of exception. Start
13295 // over and traverse parent path again, this time treating the exception
13296 // as an error.
13297
13298
13299 renderDidError();
13300 value = createCapturedValue(value, sourceFiber);
13301 var workInProgress = returnFiber;
13302
13303 do {
13304 switch (workInProgress.tag) {
13305 case HostRoot:
13306 {
13307 var _errorInfo = value;
13308 workInProgress.effectTag |= ShouldCapture;
13309 workInProgress.expirationTime = renderExpirationTime;
13310
13311 var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
13312
13313 enqueueCapturedUpdate(workInProgress, _update);
13314 return;
13315 }
13316
13317 case ClassComponent:
13318 // Capture and retry
13319 var errorInfo = value;
13320 var ctor = workInProgress.type;
13321 var instance = workInProgress.stateNode;
13322
13323 if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
13324 workInProgress.effectTag |= ShouldCapture;
13325 workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state
13326
13327 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
13328
13329 enqueueCapturedUpdate(workInProgress, _update2);
13330 return;
13331 }
13332
13333 break;
13334
13335 default:
13336 break;
13337 }
13338
13339 workInProgress = workInProgress.return;
13340 } while (workInProgress !== null);
13341}
13342
13343var ceil = Math.ceil;
13344var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
13345var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
13346var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
13347var NoContext =
13348/* */
133490;
13350var BatchedContext =
13351/* */
133521;
13353var EventContext =
13354/* */
133552;
13356var DiscreteEventContext =
13357/* */
133584;
13359var LegacyUnbatchedContext =
13360/* */
133618;
13362var RenderContext =
13363/* */
1336416;
13365var CommitContext =
13366/* */
1336732;
13368var RootIncomplete = 0;
13369var RootFatalErrored = 1;
13370var RootErrored = 2;
13371var RootSuspended = 3;
13372var RootSuspendedWithDelay = 4;
13373var RootCompleted = 5;
13374var RootLocked = 6;
13375// Describes where we are in the React execution stack
13376var executionContext = NoContext; // The root we're working on
13377
13378var workInProgressRoot = null; // The fiber we're working on
13379
13380var workInProgress = null; // The expiration time we're rendering
13381
13382var renderExpirationTime = NoWork; // Whether to root completed, errored, suspended, etc.
13383
13384var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
13385
13386var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render.
13387// This is conceptually a time stamp but expressed in terms of an ExpirationTime
13388// because we deal mostly with expiration times in the hot path, so this avoids
13389// the conversion happening in the hot path.
13390
13391var workInProgressRootLatestProcessedExpirationTime = Sync;
13392var workInProgressRootLatestSuspenseTimeout = Sync;
13393var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only
13394// includes unprocessed updates, not work in bailed out children.
13395
13396var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately.
13397// This flag determines if it might be worthwhile to restart if an opportunity
13398// happens latere.
13399
13400var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train
13401// model where we don't commit new loading states in too quick succession.
13402
13403var globalMostRecentFallbackTime = 0;
13404var FALLBACK_THROTTLE_MS = 500;
13405var nextEffect = null;
13406var hasUncaughtError = false;
13407var firstUncaughtError = null;
13408var legacyErrorBoundariesThatAlreadyFailed = null;
13409var rootDoesHavePassiveEffects = false;
13410var rootWithPendingPassiveEffects = null;
13411var pendingPassiveEffectsRenderPriority = NoPriority;
13412var pendingPassiveEffectsExpirationTime = NoWork;
13413var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
13414
13415var NESTED_UPDATE_LIMIT = 50;
13416var nestedUpdateCount = 0;
13417var rootWithNestedUpdates = null;
13418var NESTED_PASSIVE_UPDATE_LIMIT = 50;
13419var nestedPassiveUpdateCount = 0;
13420var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times
13421// during the commit phase. This enables them to be traced across components
13422// that spawn new work during render. E.g. hidden boundaries, suspended SSR
13423// hydration or SuspenseList.
13424
13425var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start
13426// time). However, if two updates are scheduled within the same event, we
13427// should treat their start times as simultaneous, even if the actual clock
13428// time has advanced between the first and second call.
13429// In other words, because expiration times determine how updates are batched,
13430// we want all updates of like priority that occur within the same event to
13431// receive the same expiration time. Otherwise we get tearing.
13432
13433var currentEventTime = NoWork;
13434function requestCurrentTime() {
13435 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
13436 // We're inside React, so it's fine to read the actual time.
13437 return msToExpirationTime(now$1());
13438 } // We're not inside React, so we may be in the middle of a browser event.
13439
13440
13441 if (currentEventTime !== NoWork) {
13442 // Use the same start time for all updates until we enter React again.
13443 return currentEventTime;
13444 } // This is the first update since React yielded. Compute a new start time.
13445
13446
13447 currentEventTime = msToExpirationTime(now$1());
13448 return currentEventTime;
13449}
13450function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
13451 var mode = fiber.mode;
13452
13453 if ((mode & BatchedMode) === NoMode) {
13454 return Sync;
13455 }
13456
13457 var priorityLevel = getCurrentPriorityLevel();
13458
13459 if ((mode & ConcurrentMode) === NoMode) {
13460 return priorityLevel === ImmediatePriority ? Sync : Batched;
13461 }
13462
13463 if ((executionContext & RenderContext) !== NoContext) {
13464 // Use whatever time we're already rendering
13465 // TODO: Should there be a way to opt out, like with `runWithPriority`?
13466 return renderExpirationTime;
13467 }
13468
13469 var expirationTime;
13470
13471 if (suspenseConfig !== null) {
13472 // Compute an expiration time based on the Suspense timeout.
13473 expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
13474 } else {
13475 // Compute an expiration time based on the Scheduler priority.
13476 switch (priorityLevel) {
13477 case ImmediatePriority:
13478 expirationTime = Sync;
13479 break;
13480
13481 case UserBlockingPriority:
13482 // TODO: Rename this to computeUserBlockingExpiration
13483 expirationTime = computeInteractiveExpiration(currentTime);
13484 break;
13485
13486 case NormalPriority:
13487 case LowPriority:
13488 // TODO: Handle LowPriority
13489 // TODO: Rename this to... something better.
13490 expirationTime = computeAsyncExpiration(currentTime);
13491 break;
13492
13493 case IdlePriority:
13494 expirationTime = Idle;
13495 break;
13496
13497 default:
13498 (function () {
13499 {
13500 {
13501 throw ReactError(Error("Expected a valid priority level"));
13502 }
13503 }
13504 })();
13505
13506 }
13507 } // If we're in the middle of rendering a tree, do not update at the same
13508 // expiration time that is already rendering.
13509 // TODO: We shouldn't have to do this if the update is on a different root.
13510 // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
13511 // the root when we check for this condition.
13512
13513
13514 if (workInProgressRoot !== null && expirationTime === renderExpirationTime) {
13515 // This is a trick to move this update into a separate batch
13516 expirationTime -= 1;
13517 }
13518
13519 return expirationTime;
13520}
13521var lastUniqueAsyncExpiration = NoWork;
13522function computeUniqueAsyncExpiration() {
13523 var currentTime = requestCurrentTime();
13524 var result = computeAsyncExpiration(currentTime);
13525
13526 if (result <= lastUniqueAsyncExpiration) {
13527 // Since we assume the current time monotonically increases, we only hit
13528 // this branch when computeUniqueAsyncExpiration is fired multiple times
13529 // within a 200ms window (or whatever the async bucket size is).
13530 result -= 1;
13531 }
13532
13533 lastUniqueAsyncExpiration = result;
13534 return result;
13535}
13536function scheduleUpdateOnFiber(fiber, expirationTime) {
13537 checkForNestedUpdates();
13538 warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
13539 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
13540
13541 if (root === null) {
13542 warnAboutUpdateOnUnmountedFiberInDEV(fiber);
13543 return;
13544 }
13545
13546 checkForInterruption(fiber, expirationTime);
13547 recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
13548 // priority as an argument to that function and this one.
13549
13550 var priorityLevel = getCurrentPriorityLevel();
13551
13552 if (expirationTime === Sync) {
13553 if ( // Check if we're inside unbatchedUpdates
13554 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
13555 (executionContext & (RenderContext | CommitContext)) === NoContext) {
13556 // Register pending interactions on the root to avoid losing traced interaction data.
13557 schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
13558 // root inside of batchedUpdates should be synchronous, but layout updates
13559 // should be deferred until the end of the batch.
13560
13561 performSyncWorkOnRoot(root);
13562 } else {
13563 ensureRootIsScheduled(root);
13564 schedulePendingInteractions(root, expirationTime);
13565
13566 if (executionContext === NoContext) {
13567 // Flush the synchronous work now, unless we're already working or inside
13568 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
13569 // scheduleCallbackForFiber to preserve the ability to schedule a callback
13570 // without immediately flushing it. We only do this for user-initiated
13571 // updates, to preserve historical behavior of sync mode.
13572 flushSyncCallbackQueue();
13573 }
13574 }
13575 } else {
13576 ensureRootIsScheduled(root);
13577 schedulePendingInteractions(root, expirationTime);
13578 }
13579
13580 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
13581 // discrete, even inside a discrete event.
13582 priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority)) {
13583 // This is the result of a discrete event. Track the lowest priority
13584 // discrete update per root so we can flush them early, if needed.
13585 if (rootsWithPendingDiscreteUpdates === null) {
13586 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
13587 } else {
13588 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
13589
13590 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
13591 rootsWithPendingDiscreteUpdates.set(root, expirationTime);
13592 }
13593 }
13594 }
13595}
13596var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending
13597// work without treating it as a typical update that originates from an event;
13598// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
13599// on a fiber.
13600
13601function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
13602 // Update the source fiber's expiration time
13603 if (fiber.expirationTime < expirationTime) {
13604 fiber.expirationTime = expirationTime;
13605 }
13606
13607 var alternate = fiber.alternate;
13608
13609 if (alternate !== null && alternate.expirationTime < expirationTime) {
13610 alternate.expirationTime = expirationTime;
13611 } // Walk the parent path to the root and update the child expiration time.
13612
13613
13614 var node = fiber.return;
13615 var root = null;
13616
13617 if (node === null && fiber.tag === HostRoot) {
13618 root = fiber.stateNode;
13619 } else {
13620 while (node !== null) {
13621 alternate = node.alternate;
13622
13623 if (node.childExpirationTime < expirationTime) {
13624 node.childExpirationTime = expirationTime;
13625
13626 if (alternate !== null && alternate.childExpirationTime < expirationTime) {
13627 alternate.childExpirationTime = expirationTime;
13628 }
13629 } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
13630 alternate.childExpirationTime = expirationTime;
13631 }
13632
13633 if (node.return === null && node.tag === HostRoot) {
13634 root = node.stateNode;
13635 break;
13636 }
13637
13638 node = node.return;
13639 }
13640 }
13641
13642 if (root !== null) {
13643 if (workInProgressRoot === root) {
13644 // Received an update to a tree that's in the middle of rendering. Mark
13645 // that's unprocessed work on this root.
13646 markUnprocessedUpdateTime(expirationTime);
13647
13648 if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
13649 // The root already suspended with a delay, which means this render
13650 // definitely won't finish. Since we have a new update, let's mark it as
13651 // suspended now, right before marking the incoming update. This has the
13652 // effect of interrupting the current render and switching to the update.
13653 // TODO: This happens to work when receiving an update during the render
13654 // phase, because of the trick inside computeExpirationForFiber to
13655 // subtract 1 from `renderExpirationTime` to move it into a
13656 // separate bucket. But we should probably model it with an exception,
13657 // using the same mechanism we use to force hydration of a subtree.
13658 // TODO: This does not account for low pri updates that were already
13659 // scheduled before the root started rendering. Need to track the next
13660 // pending expiration time (perhaps by backtracking the return path) and
13661 // then trigger a restart in the `renderDidSuspendDelayIfPossible` path.
13662 markRootSuspendedAtTime(root, renderExpirationTime);
13663 }
13664 } // Mark that the root has a pending update.
13665
13666
13667 markRootUpdatedAtTime(root, expirationTime);
13668 }
13669
13670 return root;
13671}
13672
13673function getNextRootExpirationTimeToWorkOn(root) {
13674 // Determines the next expiration time that the root should render, taking
13675 // into account levels that may be suspended, or levels that may have
13676 // received a ping.
13677 var lastExpiredTime = root.lastExpiredTime;
13678
13679 if (lastExpiredTime !== NoWork) {
13680 return lastExpiredTime;
13681 } // "Pending" refers to any update that hasn't committed yet, including if it
13682 // suspended. The "suspended" range is therefore a subset.
13683
13684
13685 var firstPendingTime = root.firstPendingTime;
13686
13687 if (!isRootSuspendedAtTime(root, firstPendingTime)) {
13688 // The highest priority pending time is not suspended. Let's work on that.
13689 return firstPendingTime;
13690 } // If the first pending time is suspended, check if there's a lower priority
13691 // pending level that we know about. Or check if we received a ping. Work
13692 // on whichever is higher priority.
13693
13694
13695 var lastPingedTime = root.lastPingedTime;
13696 var nextKnownPendingLevel = root.nextKnownPendingLevel;
13697 return lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel;
13698} // Use this function to schedule a task for a root. There's only one task per
13699// root; if a task was already scheduled, we'll check to make sure the
13700// expiration time of the existing task is the same as the expiration time of
13701// the next level that the root has work on. This function is called on every
13702// update, and right before exiting a task.
13703
13704
13705function ensureRootIsScheduled(root) {
13706 var lastExpiredTime = root.lastExpiredTime;
13707
13708 if (lastExpiredTime !== NoWork) {
13709 // Special case: Expired work should flush synchronously.
13710 root.callbackExpirationTime = Sync;
13711 root.callbackPriority = ImmediatePriority;
13712 root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
13713 return;
13714 }
13715
13716 var expirationTime = getNextRootExpirationTimeToWorkOn(root);
13717 var existingCallbackNode = root.callbackNode;
13718
13719 if (expirationTime === NoWork) {
13720 // There's nothing to work on.
13721 if (existingCallbackNode !== null) {
13722 root.callbackNode = null;
13723 root.callbackExpirationTime = NoWork;
13724 root.callbackPriority = NoPriority;
13725 }
13726
13727 return;
13728 } // TODO: If this is an update, we already read the current time. Pass the
13729 // time as an argument.
13730
13731
13732 var currentTime = requestCurrentTime();
13733 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and
13734 // expiration time. Otherwise, we'll cancel it and schedule a new one.
13735
13736 if (existingCallbackNode !== null) {
13737 var existingCallbackPriority = root.callbackPriority;
13738 var existingCallbackExpirationTime = root.callbackExpirationTime;
13739
13740 if ( // Callback must have the exact same expiration time.
13741 existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority.
13742 existingCallbackPriority >= priorityLevel) {
13743 // Existing callback is sufficient.
13744 return;
13745 } // Need to schedule a new task.
13746 // TODO: Instead of scheduling a new task, we should be able to change the
13747 // priority of the existing one.
13748
13749
13750 cancelCallback(existingCallbackNode);
13751 }
13752
13753 root.callbackExpirationTime = expirationTime;
13754 root.callbackPriority = priorityLevel;
13755 var callbackNode;
13756
13757 if (expirationTime === Sync) {
13758 // Sync React callbacks are scheduled on a special internal queue
13759 callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
13760 } else if (disableSchedulerTimeoutBasedOnReactExpirationTime) {
13761 callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root));
13762 } else {
13763 callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects
13764 // ordering because tasks are processed in timeout order.
13765 {
13766 timeout: expirationTimeToMs(expirationTime) - now$1()
13767 });
13768 }
13769
13770 root.callbackNode = callbackNode;
13771} // This is the entry point for every concurrent task, i.e. anything that
13772// goes through Scheduler.
13773
13774
13775function performConcurrentWorkOnRoot(root, didTimeout) {
13776 // Since we know we're in a React event, we can clear the current
13777 // event time. The next update will compute a new event time.
13778 currentEventTime = NoWork;
13779
13780 if (didTimeout) {
13781 // The render task took too long to complete. Mark the current time as
13782 // expired to synchronously render all expired work in a single batch.
13783 var currentTime = requestCurrentTime();
13784 markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback.
13785
13786 ensureRootIsScheduled(root);
13787 return null;
13788 } // Determine the next expiration time to work on, using the fields stored
13789 // on the root.
13790
13791
13792 var expirationTime = getNextRootExpirationTimeToWorkOn(root);
13793
13794 if (expirationTime !== NoWork) {
13795 var originalCallbackNode = root.callbackNode;
13796
13797 (function () {
13798 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
13799 {
13800 throw ReactError(Error("Should not already be working."));
13801 }
13802 }
13803 })();
13804
13805 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
13806 // and prepare a fresh one. Otherwise we'll continue where we left off.
13807
13808 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
13809 prepareFreshStack(root, expirationTime);
13810 startWorkOnPendingInteractions(root, expirationTime);
13811 } // If we have a work-in-progress fiber, it means there's still work to do
13812 // in this root.
13813
13814
13815 if (workInProgress !== null) {
13816 var prevExecutionContext = executionContext;
13817 executionContext |= RenderContext;
13818 var prevDispatcher = pushDispatcher(root);
13819 var prevInteractions = pushInteractions(root);
13820 startWorkLoopTimer(workInProgress);
13821
13822 do {
13823 try {
13824 workLoopConcurrent();
13825 break;
13826 } catch (thrownValue) {
13827 handleError(root, thrownValue);
13828 }
13829 } while (true);
13830
13831 resetContextDependencies();
13832 executionContext = prevExecutionContext;
13833 popDispatcher(prevDispatcher);
13834
13835 if (enableSchedulerTracing) {
13836 popInteractions(prevInteractions);
13837 }
13838
13839 if (workInProgressRootExitStatus === RootFatalErrored) {
13840 var fatalError = workInProgressRootFatalError;
13841 stopInterruptedWorkLoopTimer();
13842 prepareFreshStack(root, expirationTime);
13843 markRootSuspendedAtTime(root, expirationTime);
13844 ensureRootIsScheduled(root);
13845 throw fatalError;
13846 }
13847
13848 if (workInProgress !== null) {
13849 // There's still work left over. Exit without committing.
13850 stopInterruptedWorkLoopTimer();
13851 } else {
13852 // We now have a consistent tree. The next step is either to commit it,
13853 // or, if something suspended, wait to commit it after a timeout.
13854 stopFinishedWorkLoopTimer();
13855 var finishedWork = root.finishedWork = root.current.alternate;
13856 root.finishedExpirationTime = expirationTime;
13857 resolveLocksOnRoot(root, expirationTime);
13858 finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime);
13859 }
13860
13861 ensureRootIsScheduled(root);
13862
13863 if (root.callbackNode === originalCallbackNode) {
13864 // The task node scheduled for this root is the same one that's
13865 // currently executed. Need to return a continuation.
13866 return performConcurrentWorkOnRoot.bind(null, root);
13867 }
13868 }
13869 }
13870
13871 return null;
13872}
13873
13874function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
13875 // Set this to null to indicate there's no in-progress render.
13876 workInProgressRoot = null;
13877
13878 switch (exitStatus) {
13879 case RootIncomplete:
13880 case RootFatalErrored:
13881 {
13882 (function () {
13883 {
13884 {
13885 throw ReactError(Error("Root did not complete. This is a bug in React."));
13886 }
13887 }
13888 })();
13889 }
13890 // Flow knows about invariant, so it complains if I add a break
13891 // statement, but eslint doesn't know about invariant, so it complains
13892 // if I do. eslint-disable-next-line no-fallthrough
13893
13894 case RootErrored:
13895 {
13896 if (expirationTime !== Idle) {
13897 // If this was an async render, the error may have happened due to
13898 // a mutation in a concurrent event. Try rendering one more time,
13899 // synchronously, to see if the error goes away. If there are
13900 // lower priority updates, let's include those, too, in case they
13901 // fix the inconsistency. Render at Idle to include all updates.
13902 markRootExpiredAtTime(root, Idle);
13903 break;
13904 } // Commit the root in its errored state.
13905
13906
13907 commitRoot(root);
13908 break;
13909 }
13910
13911 case RootSuspended:
13912 {
13913 markRootSuspendedAtTime(root, expirationTime);
13914 var lastSuspendedTime = root.lastSuspendedTime;
13915
13916 if (expirationTime === lastSuspendedTime) {
13917 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
13918 }
13919
13920 flushSuspensePriorityWarningInDEV(); // We have an acceptable loading state. We need to figure out if we
13921 // should immediately commit it or wait a bit.
13922 // If we have processed new updates during this render, we may now
13923 // have a new loading state ready. We want to ensure that we commit
13924 // that as soon as possible.
13925
13926 var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
13927
13928 if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
13929 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
13930 // If we have not processed any new updates during this pass, then
13931 // this is either a retry of an existing fallback state or a
13932 // hidden tree. Hidden trees shouldn't be batched with other work
13933 // and after that's fixed it can only be a retry. We're going to
13934 // throttle committing retries so that we don't show too many
13935 // loading states too quickly.
13936 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now$1(); // Don't bother with a very short suspense time.
13937
13938 if (msUntilTimeout > 10) {
13939 if (workInProgressRootHasPendingPing) {
13940 var lastPingedTime = root.lastPingedTime;
13941
13942 if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
13943 // This render was pinged but we didn't get to restart
13944 // earlier so try restarting now instead.
13945 root.lastPingedTime = expirationTime;
13946 prepareFreshStack(root, expirationTime);
13947 break;
13948 }
13949 }
13950
13951 var nextTime = getNextRootExpirationTimeToWorkOn(root);
13952
13953 if (nextTime !== NoWork && nextTime !== expirationTime) {
13954 // There's additional work on this root.
13955 break;
13956 }
13957
13958 if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) {
13959 // We should prefer to render the fallback of at the last
13960 // suspended level. Ping the last suspended level to try
13961 // rendering it again.
13962 root.lastPingedTime = lastSuspendedTime;
13963 break;
13964 } // The render is suspended, it hasn't timed out, and there's no
13965 // lower priority work to do. Instead of committing the fallback
13966 // immediately, wait for more data to arrive.
13967
13968
13969 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
13970 break;
13971 }
13972 } // The work expired. Commit immediately.
13973
13974
13975 commitRoot(root);
13976 break;
13977 }
13978
13979 case RootSuspendedWithDelay:
13980 {
13981 markRootSuspendedAtTime(root, expirationTime);
13982 var _lastSuspendedTime = root.lastSuspendedTime;
13983
13984 if (expirationTime === _lastSuspendedTime) {
13985 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
13986 }
13987
13988 flushSuspensePriorityWarningInDEV();
13989
13990 if ( // do not delay if we're inside an act() scope
13991 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
13992 // We're suspended in a state that should be avoided. We'll try to
13993 // avoid committing it for as long as the timeouts let us.
13994 if (workInProgressRootHasPendingPing) {
13995 var _lastPingedTime = root.lastPingedTime;
13996
13997 if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
13998 // This render was pinged but we didn't get to restart earlier
13999 // so try restarting now instead.
14000 root.lastPingedTime = expirationTime;
14001 prepareFreshStack(root, expirationTime);
14002 break;
14003 }
14004 }
14005
14006 var _nextTime = getNextRootExpirationTimeToWorkOn(root);
14007
14008 if (_nextTime !== NoWork && _nextTime !== expirationTime) {
14009 // There's additional work on this root.
14010 break;
14011 }
14012
14013 if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) {
14014 // We should prefer to render the fallback of at the last
14015 // suspended level. Ping the last suspended level to try
14016 // rendering it again.
14017 root.lastPingedTime = _lastSuspendedTime;
14018 break;
14019 }
14020
14021 var _msUntilTimeout;
14022
14023 if (workInProgressRootLatestSuspenseTimeout !== Sync) {
14024 // We have processed a suspense config whose expiration time we
14025 // can use as the timeout.
14026 _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now$1();
14027 } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
14028 // This should never normally happen because only new updates
14029 // cause delayed states, so we should have processed something.
14030 // However, this could also happen in an offscreen tree.
14031 _msUntilTimeout = 0;
14032 } else {
14033 // If we don't have a suspense config, we're going to use a
14034 // heuristic to determine how long we can suspend.
14035 var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
14036 var currentTimeMs = now$1();
14037 var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
14038 var timeElapsed = currentTimeMs - eventTimeMs;
14039
14040 if (timeElapsed < 0) {
14041 // We get this wrong some time since we estimate the time.
14042 timeElapsed = 0;
14043 }
14044
14045 _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the
14046 // event time is exact instead of inferred from expiration time
14047 // we don't need this.
14048
14049 if (timeUntilExpirationMs < _msUntilTimeout) {
14050 _msUntilTimeout = timeUntilExpirationMs;
14051 }
14052 } // Don't bother with a very short suspense time.
14053
14054
14055 if (_msUntilTimeout > 10) {
14056 // The render is suspended, it hasn't timed out, and there's no
14057 // lower priority work to do. Instead of committing the fallback
14058 // immediately, wait for more data to arrive.
14059 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
14060 break;
14061 }
14062 } // The work expired. Commit immediately.
14063
14064
14065 commitRoot(root);
14066 break;
14067 }
14068
14069 case RootCompleted:
14070 {
14071 // The work completed. Ready to commit.
14072 if ( // do not delay if we're inside an act() scope
14073 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
14074 // If we have exceeded the minimum loading delay, which probably
14075 // means we have shown a spinner already, we might have to suspend
14076 // a bit longer to ensure that the spinner is shown for
14077 // enough time.
14078 var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
14079
14080 if (_msUntilTimeout2 > 10) {
14081 markRootSuspendedAtTime(root, expirationTime);
14082 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
14083 break;
14084 }
14085 }
14086
14087 commitRoot(root);
14088 break;
14089 }
14090
14091 case RootLocked:
14092 {
14093 // This root has a lock that prevents it from committing. Exit. If
14094 // we begin work on the root again, without any intervening updates,
14095 // it will finish without doing additional work.
14096 markRootSuspendedAtTime(root, expirationTime);
14097 break;
14098 }
14099
14100 default:
14101 {
14102 (function () {
14103 {
14104 {
14105 throw ReactError(Error("Unknown root exit status."));
14106 }
14107 }
14108 })();
14109 }
14110 }
14111} // This is the entry point for synchronous tasks that don't go
14112// through Scheduler
14113
14114
14115function performSyncWorkOnRoot(root) {
14116 // Check if there's expired work on this root. Otherwise, render at Sync.
14117 var lastExpiredTime = root.lastExpiredTime;
14118 var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync;
14119
14120 if (root.finishedExpirationTime === expirationTime) {
14121 // There's already a pending commit at this expiration time.
14122 // TODO: This is poorly factored. This case only exists for the
14123 // batch.commit() API.
14124 commitRoot(root);
14125 } else {
14126 (function () {
14127 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
14128 {
14129 throw ReactError(Error("Should not already be working."));
14130 }
14131 }
14132 })();
14133
14134 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
14135 // and prepare a fresh one. Otherwise we'll continue where we left off.
14136
14137 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
14138 prepareFreshStack(root, expirationTime);
14139 startWorkOnPendingInteractions(root, expirationTime);
14140 } // If we have a work-in-progress fiber, it means there's still work to do
14141 // in this root.
14142
14143
14144 if (workInProgress !== null) {
14145 var prevExecutionContext = executionContext;
14146 executionContext |= RenderContext;
14147 var prevDispatcher = pushDispatcher(root);
14148 var prevInteractions = pushInteractions(root);
14149 startWorkLoopTimer(workInProgress);
14150
14151 do {
14152 try {
14153 workLoopSync();
14154 break;
14155 } catch (thrownValue) {
14156 handleError(root, thrownValue);
14157 }
14158 } while (true);
14159
14160 resetContextDependencies();
14161 executionContext = prevExecutionContext;
14162 popDispatcher(prevDispatcher);
14163
14164 if (enableSchedulerTracing) {
14165 popInteractions(prevInteractions);
14166 }
14167
14168 if (workInProgressRootExitStatus === RootFatalErrored) {
14169 var fatalError = workInProgressRootFatalError;
14170 stopInterruptedWorkLoopTimer();
14171 prepareFreshStack(root, expirationTime);
14172 markRootSuspendedAtTime(root, expirationTime);
14173 ensureRootIsScheduled(root);
14174 throw fatalError;
14175 }
14176
14177 if (workInProgress !== null) {
14178 // This is a sync render, so we should have finished the whole tree.
14179 (function () {
14180 {
14181 {
14182 throw ReactError(Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."));
14183 }
14184 }
14185 })();
14186 } else {
14187 // We now have a consistent tree. Because this is a sync render, we
14188 // will commit it even if something suspended. The only exception is
14189 // if the root is locked (using the unstable_createBatch API).
14190 stopFinishedWorkLoopTimer();
14191 root.finishedWork = root.current.alternate;
14192 root.finishedExpirationTime = expirationTime;
14193 resolveLocksOnRoot(root, expirationTime);
14194 finishSyncRender(root, workInProgressRootExitStatus, expirationTime);
14195 } // Before exiting, make sure there's a callback scheduled for the next
14196 // pending level.
14197
14198
14199 ensureRootIsScheduled(root);
14200 }
14201 }
14202
14203 return null;
14204}
14205
14206function finishSyncRender(root, exitStatus, expirationTime) {
14207 if (exitStatus === RootLocked) {
14208 // This root has a lock that prevents it from committing. Exit. If we
14209 // begin work on the root again, without any intervening updates, it
14210 // will finish without doing additional work.
14211 markRootSuspendedAtTime(root, expirationTime);
14212 } else {
14213 // Set this to null to indicate there's no in-progress render.
14214 workInProgressRoot = null;
14215
14216 {
14217 if (exitStatus === RootSuspended || exitStatus === RootSuspendedWithDelay) {
14218 flushSuspensePriorityWarningInDEV();
14219 }
14220 }
14221
14222 commitRoot(root);
14223 }
14224}
14225
14226function flushRoot(root, expirationTime) {
14227 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
14228 (function () {
14229 {
14230 {
14231 throw ReactError(Error("work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method."));
14232 }
14233 }
14234 })();
14235 }
14236
14237 markRootExpiredAtTime(root, expirationTime);
14238 ensureRootIsScheduled(root);
14239 flushSyncCallbackQueue();
14240}
14241function flushDiscreteUpdates() {
14242 // TODO: Should be able to flush inside batchedUpdates, but not inside `act`.
14243 // However, `act` uses `batchedUpdates`, so there's no way to distinguish
14244 // those two cases. Need to fix this before exposing flushDiscreteUpdates
14245 // as a public API.
14246 if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
14247 if (true && (executionContext & RenderContext) !== NoContext) {
14248 warning$1(false, 'unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.');
14249 } // We're already rendering, so we can't synchronously flush pending work.
14250 // This is probably a nested event dispatch triggered by a lifecycle/effect,
14251 // like `el.focus()`. Exit.
14252
14253
14254 return;
14255 }
14256
14257 flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that
14258 // they fire before the next serial event.
14259
14260 flushPassiveEffects();
14261}
14262
14263function resolveLocksOnRoot(root, expirationTime) {
14264 var firstBatch = root.firstBatch;
14265
14266 if (firstBatch !== null && firstBatch._defer && firstBatch._expirationTime >= expirationTime) {
14267 scheduleCallback(NormalPriority, function () {
14268 firstBatch._onComplete();
14269
14270 return null;
14271 });
14272 workInProgressRootExitStatus = RootLocked;
14273 }
14274}
14275
14276function deferredUpdates(fn) {
14277 // TODO: Remove in favor of Scheduler.next
14278 return runWithPriority(NormalPriority, fn);
14279}
14280function syncUpdates(fn, a, b, c) {
14281 return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c));
14282}
14283
14284function flushPendingDiscreteUpdates() {
14285 if (rootsWithPendingDiscreteUpdates !== null) {
14286 // For each root with pending discrete updates, schedule a callback to
14287 // immediately flush them.
14288 var roots = rootsWithPendingDiscreteUpdates;
14289 rootsWithPendingDiscreteUpdates = null;
14290 roots.forEach(function (expirationTime, root) {
14291 markRootExpiredAtTime(root, expirationTime);
14292 ensureRootIsScheduled(root);
14293 }); // Now flush the immediate queue.
14294
14295 flushSyncCallbackQueue();
14296 }
14297}
14298
14299function batchedUpdates(fn, a) {
14300 var prevExecutionContext = executionContext;
14301 executionContext |= BatchedContext;
14302
14303 try {
14304 return fn(a);
14305 } finally {
14306 executionContext = prevExecutionContext;
14307
14308 if (executionContext === NoContext) {
14309 // Flush the immediate callbacks that were scheduled during this batch
14310 flushSyncCallbackQueue();
14311 }
14312 }
14313}
14314function batchedEventUpdates(fn, a) {
14315 var prevExecutionContext = executionContext;
14316 executionContext |= EventContext;
14317
14318 try {
14319 return fn(a);
14320 } finally {
14321 executionContext = prevExecutionContext;
14322
14323 if (executionContext === NoContext) {
14324 // Flush the immediate callbacks that were scheduled during this batch
14325 flushSyncCallbackQueue();
14326 }
14327 }
14328}
14329function discreteUpdates(fn, a, b, c) {
14330 var prevExecutionContext = executionContext;
14331 executionContext |= DiscreteEventContext;
14332
14333 try {
14334 // Should this
14335 return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c));
14336 } finally {
14337 executionContext = prevExecutionContext;
14338
14339 if (executionContext === NoContext) {
14340 // Flush the immediate callbacks that were scheduled during this batch
14341 flushSyncCallbackQueue();
14342 }
14343 }
14344}
14345function unbatchedUpdates(fn, a) {
14346 var prevExecutionContext = executionContext;
14347 executionContext &= ~BatchedContext;
14348 executionContext |= LegacyUnbatchedContext;
14349
14350 try {
14351 return fn(a);
14352 } finally {
14353 executionContext = prevExecutionContext;
14354
14355 if (executionContext === NoContext) {
14356 // Flush the immediate callbacks that were scheduled during this batch
14357 flushSyncCallbackQueue();
14358 }
14359 }
14360}
14361function flushSync(fn, a) {
14362 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
14363 (function () {
14364 {
14365 {
14366 throw ReactError(Error("flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering."));
14367 }
14368 }
14369 })();
14370 }
14371
14372 var prevExecutionContext = executionContext;
14373 executionContext |= BatchedContext;
14374
14375 try {
14376 return runWithPriority(ImmediatePriority, fn.bind(null, a));
14377 } finally {
14378 executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
14379 // Note that this will happen even if batchedUpdates is higher up
14380 // the stack.
14381
14382 flushSyncCallbackQueue();
14383 }
14384}
14385function flushControlled(fn) {
14386 var prevExecutionContext = executionContext;
14387 executionContext |= BatchedContext;
14388
14389 try {
14390 runWithPriority(ImmediatePriority, fn);
14391 } finally {
14392 executionContext = prevExecutionContext;
14393
14394 if (executionContext === NoContext) {
14395 // Flush the immediate callbacks that were scheduled during this batch
14396 flushSyncCallbackQueue();
14397 }
14398 }
14399}
14400
14401function prepareFreshStack(root, expirationTime) {
14402 root.finishedWork = null;
14403 root.finishedExpirationTime = NoWork;
14404 var timeoutHandle = root.timeoutHandle;
14405
14406 if (timeoutHandle !== noTimeout) {
14407 // The root previous suspended and scheduled a timeout to commit a fallback
14408 // state. Now that we have additional work, cancel the timeout.
14409 root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
14410
14411 cancelTimeout(timeoutHandle);
14412 }
14413
14414 if (workInProgress !== null) {
14415 var interruptedWork = workInProgress.return;
14416
14417 while (interruptedWork !== null) {
14418 unwindInterruptedWork(interruptedWork);
14419 interruptedWork = interruptedWork.return;
14420 }
14421 }
14422
14423 workInProgressRoot = root;
14424 workInProgress = createWorkInProgress(root.current, null, expirationTime);
14425 renderExpirationTime = expirationTime;
14426 workInProgressRootExitStatus = RootIncomplete;
14427 workInProgressRootFatalError = null;
14428 workInProgressRootLatestProcessedExpirationTime = Sync;
14429 workInProgressRootLatestSuspenseTimeout = Sync;
14430 workInProgressRootCanSuspendUsingConfig = null;
14431 workInProgressRootNextUnprocessedUpdateTime = NoWork;
14432 workInProgressRootHasPendingPing = false;
14433
14434 if (enableSchedulerTracing) {
14435 spawnedWorkDuringRender = null;
14436 }
14437
14438 {
14439 ReactStrictModeWarnings.discardPendingWarnings();
14440 componentsThatTriggeredHighPriSuspend = null;
14441 }
14442}
14443
14444function handleError(root, thrownValue) {
14445 do {
14446 try {
14447 // Reset module-level state that was set during the render phase.
14448 resetContextDependencies();
14449 resetHooks();
14450
14451 if (workInProgress === null || workInProgress.return === null) {
14452 // Expected to be working on a non-root fiber. This is a fatal error
14453 // because there's no ancestor that can handle it; the root is
14454 // supposed to capture all errors that weren't caught by an error
14455 // boundary.
14456 workInProgressRootExitStatus = RootFatalErrored;
14457 workInProgressRootFatalError = thrownValue;
14458 return null;
14459 }
14460
14461 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
14462 // Record the time spent rendering before an error was thrown. This
14463 // avoids inaccurate Profiler durations in the case of a
14464 // suspended render.
14465 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
14466 }
14467
14468 throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime);
14469 workInProgress = completeUnitOfWork(workInProgress);
14470 } catch (yetAnotherThrownValue) {
14471 // Something in the return path also threw.
14472 thrownValue = yetAnotherThrownValue;
14473 continue;
14474 } // Return to the normal work loop.
14475
14476
14477 return;
14478 } while (true);
14479}
14480
14481function pushDispatcher(root) {
14482 var prevDispatcher = ReactCurrentDispatcher.current;
14483 ReactCurrentDispatcher.current = ContextOnlyDispatcher;
14484
14485 if (prevDispatcher === null) {
14486 // The React isomorphic package does not include a default dispatcher.
14487 // Instead the first renderer will lazily attach one, in order to give
14488 // nicer error messages.
14489 return ContextOnlyDispatcher;
14490 } else {
14491 return prevDispatcher;
14492 }
14493}
14494
14495function popDispatcher(prevDispatcher) {
14496 ReactCurrentDispatcher.current = prevDispatcher;
14497}
14498
14499function pushInteractions(root) {
14500 if (enableSchedulerTracing) {
14501 var prevInteractions = tracing.__interactionsRef.current;
14502 tracing.__interactionsRef.current = root.memoizedInteractions;
14503 return prevInteractions;
14504 }
14505
14506 return null;
14507}
14508
14509function popInteractions(prevInteractions) {
14510 if (enableSchedulerTracing) {
14511 tracing.__interactionsRef.current = prevInteractions;
14512 }
14513}
14514
14515function markCommitTimeOfFallback() {
14516 globalMostRecentFallbackTime = now$1();
14517}
14518function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
14519 if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) {
14520 workInProgressRootLatestProcessedExpirationTime = expirationTime;
14521 }
14522
14523 if (suspenseConfig !== null) {
14524 if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) {
14525 workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad.
14526
14527 workInProgressRootCanSuspendUsingConfig = suspenseConfig;
14528 }
14529 }
14530}
14531function markUnprocessedUpdateTime(expirationTime) {
14532 if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
14533 workInProgressRootNextUnprocessedUpdateTime = expirationTime;
14534 }
14535}
14536function renderDidSuspend() {
14537 if (workInProgressRootExitStatus === RootIncomplete) {
14538 workInProgressRootExitStatus = RootSuspended;
14539 }
14540}
14541function renderDidSuspendDelayIfPossible() {
14542 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
14543 workInProgressRootExitStatus = RootSuspendedWithDelay;
14544 } // Check if there's a lower priority update somewhere else in the tree.
14545
14546
14547 if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) {
14548 // Mark the current render as suspended, and then mark that there's a
14549 // pending update.
14550 // TODO: This should immediately interrupt the current render, instead
14551 // of waiting until the next time we yield.
14552 markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime);
14553 markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime);
14554 }
14555}
14556function renderDidError() {
14557 if (workInProgressRootExitStatus !== RootCompleted) {
14558 workInProgressRootExitStatus = RootErrored;
14559 }
14560} // Called during render to determine if anything has suspended.
14561// Returns false if we're not sure.
14562
14563function renderHasNotSuspendedYet() {
14564 // If something errored or completed, we can't really be sure,
14565 // so those are false.
14566 return workInProgressRootExitStatus === RootIncomplete;
14567}
14568
14569function inferTimeFromExpirationTime(expirationTime) {
14570 // We don't know exactly when the update was scheduled, but we can infer an
14571 // approximate start time from the expiration time.
14572 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
14573 return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
14574}
14575
14576function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
14577 // We don't know exactly when the update was scheduled, but we can infer an
14578 // approximate start time from the expiration time by subtracting the timeout
14579 // that was added to the event time.
14580 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
14581 return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
14582} // The work loop is an extremely hot path. Tell Closure not to inline it.
14583
14584/** @noinline */
14585
14586
14587function workLoopSync() {
14588 // Already timed out, so perform work without checking if we need to yield.
14589 while (workInProgress !== null) {
14590 workInProgress = performUnitOfWork(workInProgress);
14591 }
14592}
14593/** @noinline */
14594
14595
14596function workLoopConcurrent() {
14597 // Perform work until Scheduler asks us to yield
14598 while (workInProgress !== null && !shouldYield()) {
14599 workInProgress = performUnitOfWork(workInProgress);
14600 }
14601}
14602
14603function performUnitOfWork(unitOfWork) {
14604 // The current, flushed, state of this fiber is the alternate. Ideally
14605 // nothing should rely on this, but relying on it here means that we don't
14606 // need an additional field on the work in progress.
14607 var current$$1 = unitOfWork.alternate;
14608 startWorkTimer(unitOfWork);
14609 setCurrentFiber(unitOfWork);
14610 var next;
14611
14612 if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
14613 startProfilerTimer(unitOfWork);
14614 next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
14615 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
14616 } else {
14617 next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
14618 }
14619
14620 resetCurrentFiber();
14621 unitOfWork.memoizedProps = unitOfWork.pendingProps;
14622
14623 if (next === null) {
14624 // If this doesn't spawn new work, complete the current work.
14625 next = completeUnitOfWork(unitOfWork);
14626 }
14627
14628 ReactCurrentOwner$1.current = null;
14629 return next;
14630}
14631
14632function completeUnitOfWork(unitOfWork) {
14633 // Attempt to complete the current unit of work, then move to the next
14634 // sibling. If there are no more siblings, return to the parent fiber.
14635 workInProgress = unitOfWork;
14636
14637 do {
14638 // The current, flushed, state of this fiber is the alternate. Ideally
14639 // nothing should rely on this, but relying on it here means that we don't
14640 // need an additional field on the work in progress.
14641 var current$$1 = workInProgress.alternate;
14642 var returnFiber = workInProgress.return; // Check if the work completed or if something threw.
14643
14644 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
14645 setCurrentFiber(workInProgress);
14646 var next = void 0;
14647
14648 if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoMode) {
14649 next = completeWork(current$$1, workInProgress, renderExpirationTime);
14650 } else {
14651 startProfilerTimer(workInProgress);
14652 next = completeWork(current$$1, workInProgress, renderExpirationTime); // Update render duration assuming we didn't error.
14653
14654 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
14655 }
14656
14657 stopWorkTimer(workInProgress);
14658 resetCurrentFiber();
14659 resetChildExpirationTime(workInProgress);
14660
14661 if (next !== null) {
14662 // Completing this fiber spawned new work. Work on that next.
14663 return next;
14664 }
14665
14666 if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
14667 (returnFiber.effectTag & Incomplete) === NoEffect) {
14668 // Append all the effects of the subtree and this fiber onto the effect
14669 // list of the parent. The completion order of the children affects the
14670 // side-effect order.
14671 if (returnFiber.firstEffect === null) {
14672 returnFiber.firstEffect = workInProgress.firstEffect;
14673 }
14674
14675 if (workInProgress.lastEffect !== null) {
14676 if (returnFiber.lastEffect !== null) {
14677 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
14678 }
14679
14680 returnFiber.lastEffect = workInProgress.lastEffect;
14681 } // If this fiber had side-effects, we append it AFTER the children's
14682 // side-effects. We can perform certain side-effects earlier if needed,
14683 // by doing multiple passes over the effect list. We don't want to
14684 // schedule our own side-effect on our own list because if end up
14685 // reusing children we'll schedule this effect onto itself since we're
14686 // at the end.
14687
14688
14689 var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
14690 // list. PerformedWork effect is read by React DevTools but shouldn't be
14691 // committed.
14692
14693 if (effectTag > PerformedWork) {
14694 if (returnFiber.lastEffect !== null) {
14695 returnFiber.lastEffect.nextEffect = workInProgress;
14696 } else {
14697 returnFiber.firstEffect = workInProgress;
14698 }
14699
14700 returnFiber.lastEffect = workInProgress;
14701 }
14702 }
14703 } else {
14704 // This fiber did not complete because something threw. Pop values off
14705 // the stack without entering the complete phase. If this is a boundary,
14706 // capture values if possible.
14707 var _next = unwindWork(workInProgress, renderExpirationTime); // Because this fiber did not complete, don't reset its expiration time.
14708
14709
14710 if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode) {
14711 // Record the render duration for the fiber that errored.
14712 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing.
14713
14714 var actualDuration = workInProgress.actualDuration;
14715 var child = workInProgress.child;
14716
14717 while (child !== null) {
14718 actualDuration += child.actualDuration;
14719 child = child.sibling;
14720 }
14721
14722 workInProgress.actualDuration = actualDuration;
14723 }
14724
14725 if (_next !== null) {
14726 // If completing this work spawned new work, do that next. We'll come
14727 // back here again.
14728 // Since we're restarting, remove anything that is not a host effect
14729 // from the effect tag.
14730 // TODO: The name stopFailedWorkTimer is misleading because Suspense
14731 // also captures and restarts.
14732 stopFailedWorkTimer(workInProgress);
14733 _next.effectTag &= HostEffectMask;
14734 return _next;
14735 }
14736
14737 stopWorkTimer(workInProgress);
14738
14739 if (returnFiber !== null) {
14740 // Mark the parent fiber as incomplete and clear its effect list.
14741 returnFiber.firstEffect = returnFiber.lastEffect = null;
14742 returnFiber.effectTag |= Incomplete;
14743 }
14744 }
14745
14746 var siblingFiber = workInProgress.sibling;
14747
14748 if (siblingFiber !== null) {
14749 // If there is more work to do in this returnFiber, do that next.
14750 return siblingFiber;
14751 } // Otherwise, return to the parent
14752
14753
14754 workInProgress = returnFiber;
14755 } while (workInProgress !== null); // We've reached the root.
14756
14757
14758 if (workInProgressRootExitStatus === RootIncomplete) {
14759 workInProgressRootExitStatus = RootCompleted;
14760 }
14761
14762 return null;
14763}
14764
14765function getRemainingExpirationTime(fiber) {
14766 var updateExpirationTime = fiber.expirationTime;
14767 var childExpirationTime = fiber.childExpirationTime;
14768 return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime;
14769}
14770
14771function resetChildExpirationTime(completedWork) {
14772 if (renderExpirationTime !== Never && completedWork.childExpirationTime === Never) {
14773 // The children of this component are hidden. Don't bubble their
14774 // expiration times.
14775 return;
14776 }
14777
14778 var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time.
14779
14780 if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
14781 // In profiling mode, resetChildExpirationTime is also used to reset
14782 // profiler durations.
14783 var actualDuration = completedWork.actualDuration;
14784 var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
14785 // only be updated if work is done on the fiber (i.e. it doesn't bailout).
14786 // When work is done, it should bubble to the parent's actualDuration. If
14787 // the fiber has not been cloned though, (meaning no work was done), then
14788 // this value will reflect the amount of time spent working on a previous
14789 // render. In that case it should not bubble. We determine whether it was
14790 // cloned by comparing the child pointer.
14791
14792 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
14793 var child = completedWork.child;
14794
14795 while (child !== null) {
14796 var childUpdateExpirationTime = child.expirationTime;
14797 var childChildExpirationTime = child.childExpirationTime;
14798
14799 if (childUpdateExpirationTime > newChildExpirationTime) {
14800 newChildExpirationTime = childUpdateExpirationTime;
14801 }
14802
14803 if (childChildExpirationTime > newChildExpirationTime) {
14804 newChildExpirationTime = childChildExpirationTime;
14805 }
14806
14807 if (shouldBubbleActualDurations) {
14808 actualDuration += child.actualDuration;
14809 }
14810
14811 treeBaseDuration += child.treeBaseDuration;
14812 child = child.sibling;
14813 }
14814
14815 completedWork.actualDuration = actualDuration;
14816 completedWork.treeBaseDuration = treeBaseDuration;
14817 } else {
14818 var _child = completedWork.child;
14819
14820 while (_child !== null) {
14821 var _childUpdateExpirationTime = _child.expirationTime;
14822 var _childChildExpirationTime = _child.childExpirationTime;
14823
14824 if (_childUpdateExpirationTime > newChildExpirationTime) {
14825 newChildExpirationTime = _childUpdateExpirationTime;
14826 }
14827
14828 if (_childChildExpirationTime > newChildExpirationTime) {
14829 newChildExpirationTime = _childChildExpirationTime;
14830 }
14831
14832 _child = _child.sibling;
14833 }
14834 }
14835
14836 completedWork.childExpirationTime = newChildExpirationTime;
14837}
14838
14839function commitRoot(root) {
14840 var renderPriorityLevel = getCurrentPriorityLevel();
14841 runWithPriority(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
14842 return null;
14843}
14844
14845function commitRootImpl(root, renderPriorityLevel) {
14846 flushPassiveEffects();
14847 flushRenderPhaseStrictModeWarningsInDEV();
14848
14849 (function () {
14850 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
14851 {
14852 throw ReactError(Error("Should not already be working."));
14853 }
14854 }
14855 })();
14856
14857 var finishedWork = root.finishedWork;
14858 var expirationTime = root.finishedExpirationTime;
14859
14860 if (finishedWork === null) {
14861 return null;
14862 }
14863
14864 root.finishedWork = null;
14865 root.finishedExpirationTime = NoWork;
14866
14867 (function () {
14868 if (!(finishedWork !== root.current)) {
14869 {
14870 throw ReactError(Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."));
14871 }
14872 }
14873 })(); // commitRoot never returns a continuation; it always finishes synchronously.
14874 // So we can clear these now to allow a new callback to be scheduled.
14875
14876
14877 root.callbackNode = null;
14878 root.callbackExpirationTime = NoWork;
14879 root.callbackPriority = NoPriority;
14880 root.nextKnownPendingLevel = NoWork;
14881 startCommitTimer(); // Update the first and last pending times on this root. The new first
14882 // pending time is whatever is left on the root fiber.
14883
14884 var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
14885 markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
14886
14887 if (root === workInProgressRoot) {
14888 // We can reset these now that they are finished.
14889 workInProgressRoot = null;
14890 workInProgress = null;
14891 renderExpirationTime = NoWork;
14892 } else {} // This indicates that the last root we worked on is not the same one that
14893 // we're committing now. This most commonly happens when a suspended root
14894 // times out.
14895 // Get the list of effects.
14896
14897
14898 var firstEffect;
14899
14900 if (finishedWork.effectTag > PerformedWork) {
14901 // A fiber's effect list consists only of its children, not itself. So if
14902 // the root has an effect, we need to add it to the end of the list. The
14903 // resulting list is the set that would belong to the root's parent, if it
14904 // had one; that is, all the effects in the tree including the root.
14905 if (finishedWork.lastEffect !== null) {
14906 finishedWork.lastEffect.nextEffect = finishedWork;
14907 firstEffect = finishedWork.firstEffect;
14908 } else {
14909 firstEffect = finishedWork;
14910 }
14911 } else {
14912 // There is no effect on the root.
14913 firstEffect = finishedWork.firstEffect;
14914 }
14915
14916 if (firstEffect !== null) {
14917 var prevExecutionContext = executionContext;
14918 executionContext |= CommitContext;
14919 var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
14920
14921 ReactCurrentOwner$1.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
14922 // of the effect list for each phase: all mutation effects come before all
14923 // layout effects, and so on.
14924 // The first phase a "before mutation" phase. We use this phase to read the
14925 // state of the host tree right before we mutate it. This is where
14926 // getSnapshotBeforeUpdate is called.
14927
14928 startCommitSnapshotEffectsTimer();
14929 prepareForCommit(root.containerInfo);
14930 nextEffect = firstEffect;
14931
14932 do {
14933 {
14934 invokeGuardedCallback(null, commitBeforeMutationEffects, null);
14935
14936 if (hasCaughtError()) {
14937 (function () {
14938 if (!(nextEffect !== null)) {
14939 {
14940 throw ReactError(Error("Should be working on an effect."));
14941 }
14942 }
14943 })();
14944
14945 var error = clearCaughtError();
14946 captureCommitPhaseError(nextEffect, error);
14947 nextEffect = nextEffect.nextEffect;
14948 }
14949 }
14950 } while (nextEffect !== null);
14951
14952 stopCommitSnapshotEffectsTimer();
14953
14954 if (enableProfilerTimer) {
14955 // Mark the current commit time to be shared by all Profilers in this
14956 // batch. This enables them to be grouped later.
14957 recordCommitTime();
14958 } // The next phase is the mutation phase, where we mutate the host tree.
14959
14960
14961 startCommitHostEffectsTimer();
14962 nextEffect = firstEffect;
14963
14964 do {
14965 {
14966 invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
14967
14968 if (hasCaughtError()) {
14969 (function () {
14970 if (!(nextEffect !== null)) {
14971 {
14972 throw ReactError(Error("Should be working on an effect."));
14973 }
14974 }
14975 })();
14976
14977 var _error = clearCaughtError();
14978
14979 captureCommitPhaseError(nextEffect, _error);
14980 nextEffect = nextEffect.nextEffect;
14981 }
14982 }
14983 } while (nextEffect !== null);
14984
14985 stopCommitHostEffectsTimer();
14986 resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
14987 // the mutation phase, so that the previous tree is still current during
14988 // componentWillUnmount, but before the layout phase, so that the finished
14989 // work is current during componentDidMount/Update.
14990
14991 root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
14992 // the host tree after it's been mutated. The idiomatic use case for this is
14993 // layout, but class component lifecycles also fire here for legacy reasons.
14994
14995 startCommitLifeCyclesTimer();
14996 nextEffect = firstEffect;
14997
14998 do {
14999 {
15000 invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
15001
15002 if (hasCaughtError()) {
15003 (function () {
15004 if (!(nextEffect !== null)) {
15005 {
15006 throw ReactError(Error("Should be working on an effect."));
15007 }
15008 }
15009 })();
15010
15011 var _error2 = clearCaughtError();
15012
15013 captureCommitPhaseError(nextEffect, _error2);
15014 nextEffect = nextEffect.nextEffect;
15015 }
15016 }
15017 } while (nextEffect !== null);
15018
15019 stopCommitLifeCyclesTimer();
15020 nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
15021 // opportunity to paint.
15022
15023 requestPaint();
15024
15025 if (enableSchedulerTracing) {
15026 popInteractions(prevInteractions);
15027 }
15028
15029 executionContext = prevExecutionContext;
15030 } else {
15031 // No effects.
15032 root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
15033 // no effects.
15034 // TODO: Maybe there's a better way to report this.
15035
15036 startCommitSnapshotEffectsTimer();
15037 stopCommitSnapshotEffectsTimer();
15038
15039 if (enableProfilerTimer) {
15040 recordCommitTime();
15041 }
15042
15043 startCommitHostEffectsTimer();
15044 stopCommitHostEffectsTimer();
15045 startCommitLifeCyclesTimer();
15046 stopCommitLifeCyclesTimer();
15047 }
15048
15049 stopCommitTimer();
15050 var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
15051
15052 if (rootDoesHavePassiveEffects) {
15053 // This commit has passive effects. Stash a reference to them. But don't
15054 // schedule a callback until after flushing layout work.
15055 rootDoesHavePassiveEffects = false;
15056 rootWithPendingPassiveEffects = root;
15057 pendingPassiveEffectsExpirationTime = expirationTime;
15058 pendingPassiveEffectsRenderPriority = renderPriorityLevel;
15059 } else {
15060 // We are done with the effect chain at this point so let's clear the
15061 // nextEffect pointers to assist with GC. If we have passive effects, we'll
15062 // clear this in flushPassiveEffects.
15063 nextEffect = firstEffect;
15064
15065 while (nextEffect !== null) {
15066 var nextNextEffect = nextEffect.nextEffect;
15067 nextEffect.nextEffect = null;
15068 nextEffect = nextNextEffect;
15069 }
15070 } // Check if there's remaining work on this root
15071
15072
15073 var remainingExpirationTime = root.firstPendingTime;
15074
15075 if (remainingExpirationTime !== NoWork) {
15076 if (enableSchedulerTracing) {
15077 if (spawnedWorkDuringRender !== null) {
15078 var expirationTimes = spawnedWorkDuringRender;
15079 spawnedWorkDuringRender = null;
15080
15081 for (var i = 0; i < expirationTimes.length; i++) {
15082 scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
15083 }
15084 }
15085
15086 schedulePendingInteractions(root, remainingExpirationTime);
15087 }
15088 } else {
15089 // If there's no remaining work, we can clear the set of already failed
15090 // error boundaries.
15091 legacyErrorBoundariesThatAlreadyFailed = null;
15092 }
15093
15094 if (enableSchedulerTracing) {
15095 if (!rootDidHavePassiveEffects) {
15096 // If there are no passive effects, then we can complete the pending interactions.
15097 // Otherwise, we'll wait until after the passive effects are flushed.
15098 // Wait to do this until after remaining work has been scheduled,
15099 // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
15100 finishPendingInteractions(root, expirationTime);
15101 }
15102 }
15103
15104 if (remainingExpirationTime === Sync) {
15105 // Count the number of times the root synchronously re-renders without
15106 // finishing. If there are too many, it indicates an infinite update loop.
15107 if (root === rootWithNestedUpdates) {
15108 nestedUpdateCount++;
15109 } else {
15110 nestedUpdateCount = 0;
15111 rootWithNestedUpdates = root;
15112 }
15113 } else {
15114 nestedUpdateCount = 0;
15115 }
15116
15117 onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any
15118 // additional work on this root is scheduled.
15119
15120 ensureRootIsScheduled(root);
15121
15122 if (hasUncaughtError) {
15123 hasUncaughtError = false;
15124 var _error3 = firstUncaughtError;
15125 firstUncaughtError = null;
15126 throw _error3;
15127 }
15128
15129 if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
15130 // This is a legacy edge case. We just committed the initial mount of
15131 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
15132 // synchronously, but layout updates should be deferred until the end
15133 // of the batch.
15134 return null;
15135 } // If layout work was scheduled, flush it now.
15136
15137
15138 flushSyncCallbackQueue();
15139 return null;
15140}
15141
15142function commitBeforeMutationEffects() {
15143 while (nextEffect !== null) {
15144 var effectTag = nextEffect.effectTag;
15145
15146 if ((effectTag & Snapshot) !== NoEffect) {
15147 setCurrentFiber(nextEffect);
15148 recordEffect();
15149 var current$$1 = nextEffect.alternate;
15150 commitBeforeMutationLifeCycles(current$$1, nextEffect);
15151 resetCurrentFiber();
15152 }
15153
15154 if ((effectTag & Passive) !== NoEffect) {
15155 // If there are passive effects, schedule a callback to flush at
15156 // the earliest opportunity.
15157 if (!rootDoesHavePassiveEffects) {
15158 rootDoesHavePassiveEffects = true;
15159 scheduleCallback(NormalPriority, function () {
15160 flushPassiveEffects();
15161 return null;
15162 });
15163 }
15164 }
15165
15166 nextEffect = nextEffect.nextEffect;
15167 }
15168}
15169
15170function commitMutationEffects(root, renderPriorityLevel) {
15171 // TODO: Should probably move the bulk of this function to commitWork.
15172 while (nextEffect !== null) {
15173 setCurrentFiber(nextEffect);
15174 var effectTag = nextEffect.effectTag;
15175
15176 if (effectTag & ContentReset) {
15177 commitResetTextContent(nextEffect);
15178 }
15179
15180 if (effectTag & Ref) {
15181 var current$$1 = nextEffect.alternate;
15182
15183 if (current$$1 !== null) {
15184 commitDetachRef(current$$1);
15185 }
15186 } // The following switch statement is only concerned about placement,
15187 // updates, and deletions. To avoid needing to add a case for every possible
15188 // bitmap value, we remove the secondary effects from the effect tag and
15189 // switch on that value.
15190
15191
15192 var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating);
15193
15194 switch (primaryEffectTag) {
15195 case Placement:
15196 {
15197 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
15198 // inserted, before any life-cycles like componentDidMount gets called.
15199 // TODO: findDOMNode doesn't rely on this any more but isMounted does
15200 // and isMounted is deprecated anyway so we should be able to kill this.
15201
15202 nextEffect.effectTag &= ~Placement;
15203 break;
15204 }
15205
15206 case PlacementAndUpdate:
15207 {
15208 // Placement
15209 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
15210 // inserted, before any life-cycles like componentDidMount gets called.
15211
15212 nextEffect.effectTag &= ~Placement; // Update
15213
15214 var _current = nextEffect.alternate;
15215 commitWork(_current, nextEffect);
15216 break;
15217 }
15218
15219 case Hydrating:
15220 {
15221 nextEffect.effectTag &= ~Hydrating;
15222 break;
15223 }
15224
15225 case HydratingAndUpdate:
15226 {
15227 nextEffect.effectTag &= ~Hydrating; // Update
15228
15229 var _current2 = nextEffect.alternate;
15230 commitWork(_current2, nextEffect);
15231 break;
15232 }
15233
15234 case Update:
15235 {
15236 var _current3 = nextEffect.alternate;
15237 commitWork(_current3, nextEffect);
15238 break;
15239 }
15240
15241 case Deletion:
15242 {
15243 commitDeletion(root, nextEffect, renderPriorityLevel);
15244 break;
15245 }
15246 } // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
15247
15248
15249 recordEffect();
15250 resetCurrentFiber();
15251 nextEffect = nextEffect.nextEffect;
15252 }
15253}
15254
15255function commitLayoutEffects(root, committedExpirationTime) {
15256 // TODO: Should probably move the bulk of this function to commitWork.
15257 while (nextEffect !== null) {
15258 setCurrentFiber(nextEffect);
15259 var effectTag = nextEffect.effectTag;
15260
15261 if (effectTag & (Update | Callback)) {
15262 recordEffect();
15263 var current$$1 = nextEffect.alternate;
15264 commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime);
15265 }
15266
15267 if (effectTag & Ref) {
15268 recordEffect();
15269 commitAttachRef(nextEffect);
15270 }
15271
15272 resetCurrentFiber();
15273 nextEffect = nextEffect.nextEffect;
15274 }
15275}
15276
15277function flushPassiveEffects() {
15278 if (pendingPassiveEffectsRenderPriority !== NoPriority) {
15279 var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority;
15280 pendingPassiveEffectsRenderPriority = NoPriority;
15281 return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
15282 }
15283}
15284
15285function flushPassiveEffectsImpl() {
15286 if (rootWithPendingPassiveEffects === null) {
15287 return false;
15288 }
15289
15290 var root = rootWithPendingPassiveEffects;
15291 var expirationTime = pendingPassiveEffectsExpirationTime;
15292 rootWithPendingPassiveEffects = null;
15293 pendingPassiveEffectsExpirationTime = NoWork;
15294
15295 (function () {
15296 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
15297 {
15298 throw ReactError(Error("Cannot flush passive effects while already rendering."));
15299 }
15300 }
15301 })();
15302
15303 var prevExecutionContext = executionContext;
15304 executionContext |= CommitContext;
15305 var prevInteractions = pushInteractions(root); // Note: This currently assumes there are no passive effects on the root
15306 // fiber, because the root is not part of its own effect list. This could
15307 // change in the future.
15308
15309 var effect = root.current.firstEffect;
15310
15311 while (effect !== null) {
15312 {
15313 setCurrentFiber(effect);
15314 invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
15315
15316 if (hasCaughtError()) {
15317 (function () {
15318 if (!(effect !== null)) {
15319 {
15320 throw ReactError(Error("Should be working on an effect."));
15321 }
15322 }
15323 })();
15324
15325 var error = clearCaughtError();
15326 captureCommitPhaseError(effect, error);
15327 }
15328
15329 resetCurrentFiber();
15330 }
15331
15332 var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
15333
15334 effect.nextEffect = null;
15335 effect = nextNextEffect;
15336 }
15337
15338 if (enableSchedulerTracing) {
15339 popInteractions(prevInteractions);
15340 finishPendingInteractions(root, expirationTime);
15341 }
15342
15343 executionContext = prevExecutionContext;
15344 flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
15345 // exceeds the limit, we'll fire a warning.
15346
15347 nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
15348 return true;
15349}
15350
15351function isAlreadyFailedLegacyErrorBoundary(instance) {
15352 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
15353}
15354function markLegacyErrorBoundaryAsFailed(instance) {
15355 if (legacyErrorBoundariesThatAlreadyFailed === null) {
15356 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
15357 } else {
15358 legacyErrorBoundariesThatAlreadyFailed.add(instance);
15359 }
15360}
15361
15362function prepareToThrowUncaughtError(error) {
15363 if (!hasUncaughtError) {
15364 hasUncaughtError = true;
15365 firstUncaughtError = error;
15366 }
15367}
15368
15369var onUncaughtError = prepareToThrowUncaughtError;
15370
15371function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
15372 var errorInfo = createCapturedValue(error, sourceFiber);
15373 var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
15374 enqueueUpdate(rootFiber, update);
15375 var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
15376
15377 if (root !== null) {
15378 ensureRootIsScheduled(root);
15379 schedulePendingInteractions(root, Sync);
15380 }
15381}
15382
15383function captureCommitPhaseError(sourceFiber, error) {
15384 if (sourceFiber.tag === HostRoot) {
15385 // Error was thrown at the root. There is no parent, so the root
15386 // itself should capture it.
15387 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
15388 return;
15389 }
15390
15391 var fiber = sourceFiber.return;
15392
15393 while (fiber !== null) {
15394 if (fiber.tag === HostRoot) {
15395 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
15396 return;
15397 } else if (fiber.tag === ClassComponent) {
15398 var ctor = fiber.type;
15399 var instance = fiber.stateNode;
15400
15401 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
15402 var errorInfo = createCapturedValue(error, sourceFiber);
15403 var update = createClassErrorUpdate(fiber, errorInfo, // TODO: This is always sync
15404 Sync);
15405 enqueueUpdate(fiber, update);
15406 var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
15407
15408 if (root !== null) {
15409 ensureRootIsScheduled(root);
15410 schedulePendingInteractions(root, Sync);
15411 }
15412
15413 return;
15414 }
15415 }
15416
15417 fiber = fiber.return;
15418 }
15419}
15420function pingSuspendedRoot(root, thenable, suspendedTime) {
15421 var pingCache = root.pingCache;
15422
15423 if (pingCache !== null) {
15424 // The thenable resolved, so we no longer need to memoize, because it will
15425 // never be thrown again.
15426 pingCache.delete(thenable);
15427 }
15428
15429 if (workInProgressRoot === root && renderExpirationTime === suspendedTime) {
15430 // Received a ping at the same priority level at which we're currently
15431 // rendering. We might want to restart this render. This should mirror
15432 // the logic of whether or not a root suspends once it completes.
15433 // TODO: If we're rendering sync either due to Sync, Batched or expired,
15434 // we should probably never restart.
15435 // If we're suspended with delay, we'll always suspend so we can always
15436 // restart. If we're suspended without any updates, it might be a retry.
15437 // If it's early in the retry we can restart. We can't know for sure
15438 // whether we'll eventually process an update during this render pass,
15439 // but it's somewhat unlikely that we get to a ping before that, since
15440 // getting to the root most update is usually very fast.
15441 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now$1() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
15442 // Restart from the root. Don't need to schedule a ping because
15443 // we're already working on this tree.
15444 prepareFreshStack(root, renderExpirationTime);
15445 } else {
15446 // Even though we can't restart right now, we might get an
15447 // opportunity later. So we mark this render as having a ping.
15448 workInProgressRootHasPendingPing = true;
15449 }
15450
15451 return;
15452 }
15453
15454 if (!isRootSuspendedAtTime(root, suspendedTime)) {
15455 // The root is no longer suspended at this time.
15456 return;
15457 }
15458
15459 var lastPingedTime = root.lastPingedTime;
15460
15461 if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
15462 // There's already a lower priority ping scheduled.
15463 return;
15464 } // Mark the time at which this ping was scheduled.
15465
15466
15467 root.lastPingedTime = suspendedTime;
15468
15469 if (root.finishedExpirationTime === suspendedTime) {
15470 // If there's a pending fallback waiting to commit, throw it away.
15471 root.finishedExpirationTime = NoWork;
15472 root.finishedWork = null;
15473 }
15474
15475 ensureRootIsScheduled(root);
15476 schedulePendingInteractions(root, suspendedTime);
15477}
15478
15479function retryTimedOutBoundary(boundaryFiber, retryTime) {
15480 // The boundary fiber (a Suspense component or SuspenseList component)
15481 // previously was rendered in its fallback state. One of the promises that
15482 // suspended it has resolved, which means at least part of the tree was
15483 // likely unblocked. Try rendering again, at a new expiration time.
15484 if (retryTime === Never) {
15485 var suspenseConfig = null; // Retries don't carry over the already committed update.
15486
15487 var currentTime = requestCurrentTime();
15488 retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
15489 } // TODO: Special case idle priority?
15490
15491
15492 var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
15493
15494 if (root !== null) {
15495 ensureRootIsScheduled(root);
15496 schedulePendingInteractions(root, retryTime);
15497 }
15498}
15499
15500function retryDehydratedSuspenseBoundary(boundaryFiber) {
15501 var suspenseState = boundaryFiber.memoizedState;
15502 var retryTime = Never;
15503
15504 if (suspenseState !== null) {
15505 retryTime = suspenseState.retryTime;
15506 }
15507
15508 retryTimedOutBoundary(boundaryFiber, retryTime);
15509}
15510function resolveRetryThenable(boundaryFiber, thenable) {
15511 var retryTime = Never; // Default
15512
15513 var retryCache;
15514
15515 if (enableSuspenseServerRenderer) {
15516 switch (boundaryFiber.tag) {
15517 case SuspenseComponent:
15518 retryCache = boundaryFiber.stateNode;
15519 var suspenseState = boundaryFiber.memoizedState;
15520
15521 if (suspenseState !== null) {
15522 retryTime = suspenseState.retryTime;
15523 }
15524
15525 break;
15526
15527 case SuspenseListComponent:
15528 retryCache = boundaryFiber.stateNode;
15529 break;
15530
15531 default:
15532 (function () {
15533 {
15534 {
15535 throw ReactError(Error("Pinged unknown suspense boundary type. This is probably a bug in React."));
15536 }
15537 }
15538 })();
15539
15540 }
15541 } else {
15542 retryCache = boundaryFiber.stateNode;
15543 }
15544
15545 if (retryCache !== null) {
15546 // The thenable resolved, so we no longer need to memoize, because it will
15547 // never be thrown again.
15548 retryCache.delete(thenable);
15549 }
15550
15551 retryTimedOutBoundary(boundaryFiber, retryTime);
15552} // Computes the next Just Noticeable Difference (JND) boundary.
15553// The theory is that a person can't tell the difference between small differences in time.
15554// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
15555// difference in the experience. However, waiting for longer might mean that we can avoid
15556// showing an intermediate loading state. The longer we have already waited, the harder it
15557// is to tell small differences in time. Therefore, the longer we've already waited,
15558// the longer we can wait additionally. At some point we have to give up though.
15559// We pick a train model where the next boundary commits at a consistent schedule.
15560// These particular numbers are vague estimates. We expect to adjust them based on research.
15561
15562function jnd(timeElapsed) {
15563 return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
15564}
15565
15566function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
15567 var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
15568
15569 if (busyMinDurationMs <= 0) {
15570 return 0;
15571 }
15572
15573 var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
15574
15575 var currentTimeMs = now$1();
15576 var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
15577 var timeElapsed = currentTimeMs - eventTimeMs;
15578
15579 if (timeElapsed <= busyDelayMs) {
15580 // If we haven't yet waited longer than the initial delay, we don't
15581 // have to wait any additional time.
15582 return 0;
15583 }
15584
15585 var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
15586
15587 return msUntilTimeout;
15588}
15589
15590function checkForNestedUpdates() {
15591 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
15592 nestedUpdateCount = 0;
15593 rootWithNestedUpdates = null;
15594
15595 (function () {
15596 {
15597 {
15598 throw ReactError(Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."));
15599 }
15600 }
15601 })();
15602 }
15603
15604 {
15605 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
15606 nestedPassiveUpdateCount = 0;
15607 warning$1(false, 'Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.');
15608 }
15609 }
15610}
15611
15612function flushRenderPhaseStrictModeWarningsInDEV() {
15613 {
15614 ReactStrictModeWarnings.flushLegacyContextWarning();
15615
15616 if (warnAboutDeprecatedLifecycles) {
15617 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
15618 }
15619 }
15620}
15621
15622function stopFinishedWorkLoopTimer() {
15623 var didCompleteRoot = true;
15624 stopWorkLoopTimer(interruptedBy, didCompleteRoot);
15625 interruptedBy = null;
15626}
15627
15628function stopInterruptedWorkLoopTimer() {
15629 // TODO: Track which fiber caused the interruption.
15630 var didCompleteRoot = false;
15631 stopWorkLoopTimer(interruptedBy, didCompleteRoot);
15632 interruptedBy = null;
15633}
15634
15635function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
15636 if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime) {
15637 interruptedBy = fiberThatReceivedUpdate;
15638 }
15639}
15640
15641var didWarnStateUpdateForUnmountedComponent = null;
15642
15643function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
15644 {
15645 var tag = fiber.tag;
15646
15647 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
15648 // Only warn for user-defined components, not internal ones like Suspense.
15649 return;
15650 } // We show the whole stack but dedupe on the top component's name because
15651 // the problematic code almost always lies inside that component.
15652
15653
15654 var componentName = getComponentName(fiber.type) || 'ReactComponent';
15655
15656 if (didWarnStateUpdateForUnmountedComponent !== null) {
15657 if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
15658 return;
15659 }
15660
15661 didWarnStateUpdateForUnmountedComponent.add(componentName);
15662 } else {
15663 didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
15664 }
15665
15666 warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
15667 }
15668}
15669
15670var beginWork$$1;
15671
15672if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
15673 var dummyFiber = null;
15674
15675 beginWork$$1 = function (current$$1, unitOfWork, expirationTime) {
15676 // If a component throws an error, we replay it again in a synchronously
15677 // dispatched event, so that the debugger will treat it as an uncaught
15678 // error See ReactErrorUtils for more information.
15679 // Before entering the begin phase, copy the work-in-progress onto a dummy
15680 // fiber. If beginWork throws, we'll use this to reset the state.
15681 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
15682
15683 try {
15684 return beginWork$1(current$$1, unitOfWork, expirationTime);
15685 } catch (originalError) {
15686 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
15687 // Don't replay promises. Treat everything else like an error.
15688 throw originalError;
15689 } // Keep this code in sync with renderRoot; any changes here must have
15690 // corresponding changes there.
15691
15692
15693 resetContextDependencies();
15694 resetHooks(); // Unwind the failed stack frame
15695
15696 unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
15697
15698 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
15699
15700 if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
15701 // Reset the profiler timer.
15702 startProfilerTimer(unitOfWork);
15703 } // Run beginWork again.
15704
15705
15706 invokeGuardedCallback(null, beginWork$1, null, current$$1, unitOfWork, expirationTime);
15707
15708 if (hasCaughtError()) {
15709 var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
15710 // Rethrow this error instead of the original one.
15711
15712 throw replayError;
15713 } else {
15714 // This branch is reachable if the render phase is impure.
15715 throw originalError;
15716 }
15717 }
15718 };
15719} else {
15720 beginWork$$1 = beginWork$1;
15721}
15722
15723var didWarnAboutUpdateInRender = false;
15724var didWarnAboutUpdateInGetChildContext = false;
15725
15726function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
15727 {
15728 if (fiber.tag === ClassComponent) {
15729 switch (phase) {
15730 case 'getChildContext':
15731 if (didWarnAboutUpdateInGetChildContext) {
15732 return;
15733 }
15734
15735 warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
15736 didWarnAboutUpdateInGetChildContext = true;
15737 break;
15738
15739 case 'render':
15740 if (didWarnAboutUpdateInRender) {
15741 return;
15742 }
15743
15744 warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure function of ' + 'props and state.');
15745 didWarnAboutUpdateInRender = true;
15746 break;
15747 }
15748 }
15749 }
15750} // a 'shared' variable that changes when act() opens/closes in tests.
15751
15752
15753var IsThisRendererActing = {
15754 current: false
15755};
15756function warnIfNotScopedWithMatchingAct(fiber) {
15757 {
15758 if (warnsIfNotActing === true && IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
15759 warningWithoutStack$1(false, "It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber));
15760 }
15761 }
15762}
15763function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
15764 {
15765 if (warnsIfNotActing === true && (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
15766 warningWithoutStack$1(false, 'An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
15767 }
15768 }
15769}
15770
15771function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
15772 {
15773 if (warnsIfNotActing === true && executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
15774 warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
15775 }
15776 }
15777}
15778
15779var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
15780
15781var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
15782// scheduler is the actual recommendation. The alternative could be a testing build,
15783// a new lib, or whatever; we dunno just yet. This message is for early adopters
15784// to get their tests right.
15785
15786function warnIfUnmockedScheduler(fiber) {
15787 {
15788 if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
15789 if (fiber.mode & BatchedMode || fiber.mode & ConcurrentMode) {
15790 didWarnAboutUnmockedScheduler = true;
15791 warningWithoutStack$1(false, 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
15792 } else if (warnAboutUnmockedScheduler === true) {
15793 didWarnAboutUnmockedScheduler = true;
15794 warningWithoutStack$1(false, 'Starting from React v17, the "scheduler" module will need to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
15795 }
15796 }
15797 }
15798}
15799var componentsThatTriggeredHighPriSuspend = null;
15800function checkForWrongSuspensePriorityInDEV(sourceFiber) {
15801 {
15802 var currentPriorityLevel = getCurrentPriorityLevel();
15803
15804 if ((sourceFiber.mode & ConcurrentMode) !== NoEffect && (currentPriorityLevel === UserBlockingPriority || currentPriorityLevel === ImmediatePriority)) {
15805 var workInProgressNode = sourceFiber;
15806
15807 while (workInProgressNode !== null) {
15808 // Add the component that triggered the suspense
15809 var current$$1 = workInProgressNode.alternate;
15810
15811 if (current$$1 !== null) {
15812 // TODO: warn component that triggers the high priority
15813 // suspend is the HostRoot
15814 switch (workInProgressNode.tag) {
15815 case ClassComponent:
15816 // Loop through the component's update queue and see whether the component
15817 // has triggered any high priority updates
15818 var updateQueue = current$$1.updateQueue;
15819
15820 if (updateQueue !== null) {
15821 var update = updateQueue.firstUpdate;
15822
15823 while (update !== null) {
15824 var priorityLevel = update.priority;
15825
15826 if (priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority) {
15827 if (componentsThatTriggeredHighPriSuspend === null) {
15828 componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
15829 } else {
15830 componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
15831 }
15832
15833 break;
15834 }
15835
15836 update = update.next;
15837 }
15838 }
15839
15840 break;
15841
15842 case FunctionComponent:
15843 case ForwardRef:
15844 case SimpleMemoComponent:
15845 if (workInProgressNode.memoizedState !== null && workInProgressNode.memoizedState.baseUpdate !== null) {
15846 var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether
15847 // the component has triggered any high pri updates
15848
15849 while (_update !== null) {
15850 var priority = _update.priority;
15851
15852 if (priority === UserBlockingPriority || priority === ImmediatePriority) {
15853 if (componentsThatTriggeredHighPriSuspend === null) {
15854 componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
15855 } else {
15856 componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
15857 }
15858
15859 break;
15860 }
15861
15862 if (_update.next === workInProgressNode.memoizedState.baseUpdate) {
15863 break;
15864 }
15865
15866 _update = _update.next;
15867 }
15868 }
15869
15870 break;
15871
15872 default:
15873 break;
15874 }
15875 }
15876
15877 workInProgressNode = workInProgressNode.return;
15878 }
15879 }
15880 }
15881}
15882
15883function flushSuspensePriorityWarningInDEV() {
15884 {
15885 if (componentsThatTriggeredHighPriSuspend !== null) {
15886 var componentNames = [];
15887 componentsThatTriggeredHighPriSuspend.forEach(function (name) {
15888 return componentNames.push(name);
15889 });
15890 componentsThatTriggeredHighPriSuspend = null;
15891
15892 if (componentNames.length > 0) {
15893 warningWithoutStack$1(false, '%s triggered a user-blocking update that suspended.' + '\n\n' + 'The fix is to split the update into multiple parts: a user-blocking ' + 'update to provide immediate feedback, and another update that ' + 'triggers the bulk of the changes.' + '\n\n' + 'Refer to the documentation for useSuspenseTransition to learn how ' + 'to implement this pattern.', // TODO: Add link to React docs with more information, once it exists
15894 componentNames.sort().join(', '));
15895 }
15896 }
15897 }
15898}
15899
15900function computeThreadID(root, expirationTime) {
15901 // Interaction threads are unique per root and expiration time.
15902 return expirationTime * 1000 + root.interactionThreadID;
15903}
15904
15905function markSpawnedWork(expirationTime) {
15906 if (!enableSchedulerTracing) {
15907 return;
15908 }
15909
15910 if (spawnedWorkDuringRender === null) {
15911 spawnedWorkDuringRender = [expirationTime];
15912 } else {
15913 spawnedWorkDuringRender.push(expirationTime);
15914 }
15915}
15916
15917function scheduleInteractions(root, expirationTime, interactions) {
15918 if (!enableSchedulerTracing) {
15919 return;
15920 }
15921
15922 if (interactions.size > 0) {
15923 var pendingInteractionMap = root.pendingInteractionMap;
15924 var pendingInteractions = pendingInteractionMap.get(expirationTime);
15925
15926 if (pendingInteractions != null) {
15927 interactions.forEach(function (interaction) {
15928 if (!pendingInteractions.has(interaction)) {
15929 // Update the pending async work count for previously unscheduled interaction.
15930 interaction.__count++;
15931 }
15932
15933 pendingInteractions.add(interaction);
15934 });
15935 } else {
15936 pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions.
15937
15938 interactions.forEach(function (interaction) {
15939 interaction.__count++;
15940 });
15941 }
15942
15943 var subscriber = tracing.__subscriberRef.current;
15944
15945 if (subscriber !== null) {
15946 var threadID = computeThreadID(root, expirationTime);
15947 subscriber.onWorkScheduled(interactions, threadID);
15948 }
15949 }
15950}
15951
15952function schedulePendingInteractions(root, expirationTime) {
15953 // This is called when work is scheduled on a root.
15954 // It associates the current interactions with the newly-scheduled expiration.
15955 // They will be restored when that expiration is later committed.
15956 if (!enableSchedulerTracing) {
15957 return;
15958 }
15959
15960 scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
15961}
15962
15963function startWorkOnPendingInteractions(root, expirationTime) {
15964 // This is called when new work is started on a root.
15965 if (!enableSchedulerTracing) {
15966 return;
15967 } // Determine which interactions this batch of work currently includes, So that
15968 // we can accurately attribute time spent working on it, And so that cascading
15969 // work triggered during the render phase will be associated with it.
15970
15971
15972 var interactions = new Set();
15973 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
15974 if (scheduledExpirationTime >= expirationTime) {
15975 scheduledInteractions.forEach(function (interaction) {
15976 return interactions.add(interaction);
15977 });
15978 }
15979 }); // Store the current set of interactions on the FiberRoot for a few reasons:
15980 // We can re-use it in hot functions like renderRoot() without having to
15981 // recalculate it. We will also use it in commitWork() to pass to any Profiler
15982 // onRender() hooks. This also provides DevTools with a way to access it when
15983 // the onCommitRoot() hook is called.
15984
15985 root.memoizedInteractions = interactions;
15986
15987 if (interactions.size > 0) {
15988 var subscriber = tracing.__subscriberRef.current;
15989
15990 if (subscriber !== null) {
15991 var threadID = computeThreadID(root, expirationTime);
15992
15993 try {
15994 subscriber.onWorkStarted(interactions, threadID);
15995 } catch (error) {
15996 // If the subscriber throws, rethrow it in a separate task
15997 scheduleCallback(ImmediatePriority, function () {
15998 throw error;
15999 });
16000 }
16001 }
16002 }
16003}
16004
16005function finishPendingInteractions(root, committedExpirationTime) {
16006 if (!enableSchedulerTracing) {
16007 return;
16008 }
16009
16010 var earliestRemainingTimeAfterCommit = root.firstPendingTime;
16011 var subscriber;
16012
16013 try {
16014 subscriber = tracing.__subscriberRef.current;
16015
16016 if (subscriber !== null && root.memoizedInteractions.size > 0) {
16017 var threadID = computeThreadID(root, committedExpirationTime);
16018 subscriber.onWorkStopped(root.memoizedInteractions, threadID);
16019 }
16020 } catch (error) {
16021 // If the subscriber throws, rethrow it in a separate task
16022 scheduleCallback(ImmediatePriority, function () {
16023 throw error;
16024 });
16025 } finally {
16026 // Clear completed interactions from the pending Map.
16027 // Unless the render was suspended or cascading work was scheduled,
16028 // In which case– leave pending interactions until the subsequent render.
16029 var pendingInteractionMap = root.pendingInteractionMap;
16030 pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
16031 // Only decrement the pending interaction count if we're done.
16032 // If there's still work at the current priority,
16033 // That indicates that we are waiting for suspense data.
16034 if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
16035 pendingInteractionMap.delete(scheduledExpirationTime);
16036 scheduledInteractions.forEach(function (interaction) {
16037 interaction.__count--;
16038
16039 if (subscriber !== null && interaction.__count === 0) {
16040 try {
16041 subscriber.onInteractionScheduledWorkCompleted(interaction);
16042 } catch (error) {
16043 // If the subscriber throws, rethrow it in a separate task
16044 scheduleCallback(ImmediatePriority, function () {
16045 throw error;
16046 });
16047 }
16048 }
16049 });
16050 }
16051 });
16052 }
16053}
16054
16055var onCommitFiberRoot = null;
16056var onCommitFiberUnmount = null;
16057var hasLoggedError = false;
16058var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
16059function injectInternals(internals) {
16060 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
16061 // No DevTools
16062 return false;
16063 }
16064
16065 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
16066
16067 if (hook.isDisabled) {
16068 // This isn't a real property on the hook, but it can be set to opt out
16069 // of DevTools integration and associated warnings and logs.
16070 // https://github.com/facebook/react/issues/3877
16071 return true;
16072 }
16073
16074 if (!hook.supportsFiber) {
16075 {
16076 warningWithoutStack$1(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
16077 } // DevTools exists, even though it doesn't support Fiber.
16078
16079
16080 return true;
16081 }
16082
16083 try {
16084 var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
16085
16086 onCommitFiberRoot = function (root, expirationTime) {
16087 try {
16088 var didError = (root.current.effectTag & DidCapture) === DidCapture;
16089
16090 if (enableProfilerTimer) {
16091 var currentTime = requestCurrentTime();
16092 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
16093 hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
16094 } else {
16095 hook.onCommitFiberRoot(rendererID, root, undefined, didError);
16096 }
16097 } catch (err) {
16098 if (true && !hasLoggedError) {
16099 hasLoggedError = true;
16100 warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
16101 }
16102 }
16103 };
16104
16105 onCommitFiberUnmount = function (fiber) {
16106 try {
16107 hook.onCommitFiberUnmount(rendererID, fiber);
16108 } catch (err) {
16109 if (true && !hasLoggedError) {
16110 hasLoggedError = true;
16111 warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
16112 }
16113 }
16114 };
16115 } catch (err) {
16116 // Catch all errors because it is unsafe to throw during initialization.
16117 {
16118 warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
16119 }
16120 } // DevTools exists
16121
16122
16123 return true;
16124}
16125function onCommitRoot(root, expirationTime) {
16126 if (typeof onCommitFiberRoot === 'function') {
16127 onCommitFiberRoot(root, expirationTime);
16128 }
16129}
16130function onCommitUnmount(fiber) {
16131 if (typeof onCommitFiberUnmount === 'function') {
16132 onCommitFiberUnmount(fiber);
16133 }
16134}
16135
16136var hasBadMapPolyfill;
16137
16138{
16139 hasBadMapPolyfill = false;
16140
16141 try {
16142 var nonExtensibleObject = Object.preventExtensions({});
16143 var testMap = new Map([[nonExtensibleObject, null]]);
16144 var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused.
16145 // https://github.com/rollup/rollup/issues/1771
16146 // TODO: we can remove these if Rollup fixes the bug.
16147
16148 testMap.set(0, 0);
16149 testSet.add(0);
16150 } catch (e) {
16151 // TODO: Consider warning about bad polyfills
16152 hasBadMapPolyfill = true;
16153 }
16154}
16155
16156var debugCounter = 1;
16157
16158function FiberNode(tag, pendingProps, key, mode) {
16159 // Instance
16160 this.tag = tag;
16161 this.key = key;
16162 this.elementType = null;
16163 this.type = null;
16164 this.stateNode = null; // Fiber
16165
16166 this.return = null;
16167 this.child = null;
16168 this.sibling = null;
16169 this.index = 0;
16170 this.ref = null;
16171 this.pendingProps = pendingProps;
16172 this.memoizedProps = null;
16173 this.updateQueue = null;
16174 this.memoizedState = null;
16175 this.dependencies = null;
16176 this.mode = mode; // Effects
16177
16178 this.effectTag = NoEffect;
16179 this.nextEffect = null;
16180 this.firstEffect = null;
16181 this.lastEffect = null;
16182 this.expirationTime = NoWork;
16183 this.childExpirationTime = NoWork;
16184 this.alternate = null;
16185
16186 if (enableProfilerTimer) {
16187 // Note: The following is done to avoid a v8 performance cliff.
16188 //
16189 // Initializing the fields below to smis and later updating them with
16190 // double values will cause Fibers to end up having separate shapes.
16191 // This behavior/bug has something to do with Object.preventExtension().
16192 // Fortunately this only impacts DEV builds.
16193 // Unfortunately it makes React unusably slow for some applications.
16194 // To work around this, initialize the fields below with doubles.
16195 //
16196 // Learn more about this here:
16197 // https://github.com/facebook/react/issues/14365
16198 // https://bugs.chromium.org/p/v8/issues/detail?id=8538
16199 this.actualDuration = Number.NaN;
16200 this.actualStartTime = Number.NaN;
16201 this.selfBaseDuration = Number.NaN;
16202 this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization.
16203 // This won't trigger the performance cliff mentioned above,
16204 // and it simplifies other profiler code (including DevTools).
16205
16206 this.actualDuration = 0;
16207 this.actualStartTime = -1;
16208 this.selfBaseDuration = 0;
16209 this.treeBaseDuration = 0;
16210 } // This is normally DEV-only except www when it adds listeners.
16211 // TODO: remove the User Timing integration in favor of Root Events.
16212
16213
16214 if (enableUserTimingAPI) {
16215 this._debugID = debugCounter++;
16216 this._debugIsCurrentlyTiming = false;
16217 }
16218
16219 {
16220 this._debugSource = null;
16221 this._debugOwner = null;
16222 this._debugNeedsRemount = false;
16223 this._debugHookTypes = null;
16224
16225 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
16226 Object.preventExtensions(this);
16227 }
16228 }
16229} // This is a constructor function, rather than a POJO constructor, still
16230// please ensure we do the following:
16231// 1) Nobody should add any instance methods on this. Instance methods can be
16232// more difficult to predict when they get optimized and they are almost
16233// never inlined properly in static compilers.
16234// 2) Nobody should rely on `instanceof Fiber` for type testing. We should
16235// always know when it is a fiber.
16236// 3) We might want to experiment with using numeric keys since they are easier
16237// to optimize in a non-JIT environment.
16238// 4) We can easily go from a constructor to a createFiber object literal if that
16239// is faster.
16240// 5) It should be easy to port this to a C struct and keep a C implementation
16241// compatible.
16242
16243
16244var createFiber = function (tag, pendingProps, key, mode) {
16245 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
16246 return new FiberNode(tag, pendingProps, key, mode);
16247};
16248
16249function shouldConstruct(Component) {
16250 var prototype = Component.prototype;
16251 return !!(prototype && prototype.isReactComponent);
16252}
16253
16254function isSimpleFunctionComponent(type) {
16255 return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
16256}
16257function resolveLazyComponentTag(Component) {
16258 if (typeof Component === 'function') {
16259 return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
16260 } else if (Component !== undefined && Component !== null) {
16261 var $$typeof = Component.$$typeof;
16262
16263 if ($$typeof === REACT_FORWARD_REF_TYPE) {
16264 return ForwardRef;
16265 }
16266
16267 if ($$typeof === REACT_MEMO_TYPE) {
16268 return MemoComponent;
16269 }
16270 }
16271
16272 return IndeterminateComponent;
16273} // This is used to create an alternate fiber to do work on.
16274
16275function createWorkInProgress(current, pendingProps, expirationTime) {
16276 var workInProgress = current.alternate;
16277
16278 if (workInProgress === null) {
16279 // We use a double buffering pooling technique because we know that we'll
16280 // only ever need at most two versions of a tree. We pool the "other" unused
16281 // node that we're free to reuse. This is lazily created to avoid allocating
16282 // extra objects for things that are never updated. It also allow us to
16283 // reclaim the extra memory if needed.
16284 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
16285 workInProgress.elementType = current.elementType;
16286 workInProgress.type = current.type;
16287 workInProgress.stateNode = current.stateNode;
16288
16289 {
16290 // DEV-only fields
16291 workInProgress._debugID = current._debugID;
16292 workInProgress._debugSource = current._debugSource;
16293 workInProgress._debugOwner = current._debugOwner;
16294 workInProgress._debugHookTypes = current._debugHookTypes;
16295 }
16296
16297 workInProgress.alternate = current;
16298 current.alternate = workInProgress;
16299 } else {
16300 workInProgress.pendingProps = pendingProps; // We already have an alternate.
16301 // Reset the effect tag.
16302
16303 workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
16304
16305 workInProgress.nextEffect = null;
16306 workInProgress.firstEffect = null;
16307 workInProgress.lastEffect = null;
16308
16309 if (enableProfilerTimer) {
16310 // We intentionally reset, rather than copy, actualDuration & actualStartTime.
16311 // This prevents time from endlessly accumulating in new commits.
16312 // This has the downside of resetting values for different priority renders,
16313 // But works for yielding (the common case) and should support resuming.
16314 workInProgress.actualDuration = 0;
16315 workInProgress.actualStartTime = -1;
16316 }
16317 }
16318
16319 workInProgress.childExpirationTime = current.childExpirationTime;
16320 workInProgress.expirationTime = current.expirationTime;
16321 workInProgress.child = current.child;
16322 workInProgress.memoizedProps = current.memoizedProps;
16323 workInProgress.memoizedState = current.memoizedState;
16324 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
16325 // it cannot be shared with the current fiber.
16326
16327 var currentDependencies = current.dependencies;
16328 workInProgress.dependencies = currentDependencies === null ? null : {
16329 expirationTime: currentDependencies.expirationTime,
16330 firstContext: currentDependencies.firstContext,
16331 responders: currentDependencies.responders
16332 }; // These will be overridden during the parent's reconciliation
16333
16334 workInProgress.sibling = current.sibling;
16335 workInProgress.index = current.index;
16336 workInProgress.ref = current.ref;
16337
16338 if (enableProfilerTimer) {
16339 workInProgress.selfBaseDuration = current.selfBaseDuration;
16340 workInProgress.treeBaseDuration = current.treeBaseDuration;
16341 }
16342
16343 {
16344 workInProgress._debugNeedsRemount = current._debugNeedsRemount;
16345
16346 switch (workInProgress.tag) {
16347 case IndeterminateComponent:
16348 case FunctionComponent:
16349 case SimpleMemoComponent:
16350 workInProgress.type = resolveFunctionForHotReloading(current.type);
16351 break;
16352
16353 case ClassComponent:
16354 workInProgress.type = resolveClassForHotReloading(current.type);
16355 break;
16356
16357 case ForwardRef:
16358 workInProgress.type = resolveForwardRefForHotReloading(current.type);
16359 break;
16360
16361 default:
16362 break;
16363 }
16364 }
16365
16366 return workInProgress;
16367} // Used to reuse a Fiber for a second pass.
16368
16369function resetWorkInProgress(workInProgress, renderExpirationTime) {
16370 // This resets the Fiber to what createFiber or createWorkInProgress would
16371 // have set the values to before during the first pass. Ideally this wouldn't
16372 // be necessary but unfortunately many code paths reads from the workInProgress
16373 // when they should be reading from current and writing to workInProgress.
16374 // We assume pendingProps, index, key, ref, return are still untouched to
16375 // avoid doing another reconciliation.
16376 // Reset the effect tag but keep any Placement tags, since that's something
16377 // that child fiber is setting, not the reconciliation.
16378 workInProgress.effectTag &= Placement; // The effect list is no longer valid.
16379
16380 workInProgress.nextEffect = null;
16381 workInProgress.firstEffect = null;
16382 workInProgress.lastEffect = null;
16383 var current = workInProgress.alternate;
16384
16385 if (current === null) {
16386 // Reset to createFiber's initial values.
16387 workInProgress.childExpirationTime = NoWork;
16388 workInProgress.expirationTime = renderExpirationTime;
16389 workInProgress.child = null;
16390 workInProgress.memoizedProps = null;
16391 workInProgress.memoizedState = null;
16392 workInProgress.updateQueue = null;
16393 workInProgress.dependencies = null;
16394
16395 if (enableProfilerTimer) {
16396 // Note: We don't reset the actualTime counts. It's useful to accumulate
16397 // actual time across multiple render passes.
16398 workInProgress.selfBaseDuration = 0;
16399 workInProgress.treeBaseDuration = 0;
16400 }
16401 } else {
16402 // Reset to the cloned values that createWorkInProgress would've.
16403 workInProgress.childExpirationTime = current.childExpirationTime;
16404 workInProgress.expirationTime = current.expirationTime;
16405 workInProgress.child = current.child;
16406 workInProgress.memoizedProps = current.memoizedProps;
16407 workInProgress.memoizedState = current.memoizedState;
16408 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
16409 // it cannot be shared with the current fiber.
16410
16411 var currentDependencies = current.dependencies;
16412 workInProgress.dependencies = currentDependencies === null ? null : {
16413 expirationTime: currentDependencies.expirationTime,
16414 firstContext: currentDependencies.firstContext,
16415 responders: currentDependencies.responders
16416 };
16417
16418 if (enableProfilerTimer) {
16419 // Note: We don't reset the actualTime counts. It's useful to accumulate
16420 // actual time across multiple render passes.
16421 workInProgress.selfBaseDuration = current.selfBaseDuration;
16422 workInProgress.treeBaseDuration = current.treeBaseDuration;
16423 }
16424 }
16425
16426 return workInProgress;
16427}
16428function createHostRootFiber(tag) {
16429 var mode;
16430
16431 if (tag === ConcurrentRoot) {
16432 mode = ConcurrentMode | BatchedMode | StrictMode;
16433 } else if (tag === BatchedRoot) {
16434 mode = BatchedMode | StrictMode;
16435 } else {
16436 mode = NoMode;
16437 }
16438
16439 if (enableProfilerTimer && isDevToolsPresent) {
16440 // Always collect profile timings when DevTools are present.
16441 // This enables DevTools to start capturing timing at any point–
16442 // Without some nodes in the tree having empty base times.
16443 mode |= ProfileMode;
16444 }
16445
16446 return createFiber(HostRoot, null, null, mode);
16447}
16448function createFiberFromTypeAndProps(type, // React$ElementType
16449key, pendingProps, owner, mode, expirationTime) {
16450 var fiber;
16451 var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
16452
16453 var resolvedType = type;
16454
16455 if (typeof type === 'function') {
16456 if (shouldConstruct(type)) {
16457 fiberTag = ClassComponent;
16458
16459 {
16460 resolvedType = resolveClassForHotReloading(resolvedType);
16461 }
16462 } else {
16463 {
16464 resolvedType = resolveFunctionForHotReloading(resolvedType);
16465 }
16466 }
16467 } else if (typeof type === 'string') {
16468 fiberTag = HostComponent;
16469 } else {
16470 getTag: switch (type) {
16471 case REACT_FRAGMENT_TYPE:
16472 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
16473
16474 case REACT_CONCURRENT_MODE_TYPE:
16475 fiberTag = Mode;
16476 mode |= ConcurrentMode | BatchedMode | StrictMode;
16477 break;
16478
16479 case REACT_STRICT_MODE_TYPE:
16480 fiberTag = Mode;
16481 mode |= StrictMode;
16482 break;
16483
16484 case REACT_PROFILER_TYPE:
16485 return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
16486
16487 case REACT_SUSPENSE_TYPE:
16488 return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
16489
16490 case REACT_SUSPENSE_LIST_TYPE:
16491 return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
16492
16493 default:
16494 {
16495 if (typeof type === 'object' && type !== null) {
16496 switch (type.$$typeof) {
16497 case REACT_PROVIDER_TYPE:
16498 fiberTag = ContextProvider;
16499 break getTag;
16500
16501 case REACT_CONTEXT_TYPE:
16502 // This is a consumer
16503 fiberTag = ContextConsumer;
16504 break getTag;
16505
16506 case REACT_FORWARD_REF_TYPE:
16507 fiberTag = ForwardRef;
16508
16509 {
16510 resolvedType = resolveForwardRefForHotReloading(resolvedType);
16511 }
16512
16513 break getTag;
16514
16515 case REACT_MEMO_TYPE:
16516 fiberTag = MemoComponent;
16517 break getTag;
16518
16519 case REACT_LAZY_TYPE:
16520 fiberTag = LazyComponent;
16521 resolvedType = null;
16522 break getTag;
16523
16524 case REACT_FUNDAMENTAL_TYPE:
16525 if (enableFundamentalAPI) {
16526 return createFiberFromFundamental(type, pendingProps, mode, expirationTime, key);
16527 }
16528
16529 break;
16530
16531 case REACT_SCOPE_TYPE:
16532 if (enableScopeAPI) {
16533 return createFiberFromScope(type, pendingProps, mode, expirationTime, key);
16534 }
16535
16536 }
16537 }
16538
16539 var info = '';
16540
16541 {
16542 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
16543 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.';
16544 }
16545
16546 var ownerName = owner ? getComponentName(owner.type) : null;
16547
16548 if (ownerName) {
16549 info += '\n\nCheck the render method of `' + ownerName + '`.';
16550 }
16551 }
16552
16553 (function () {
16554 {
16555 {
16556 throw ReactError(Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info));
16557 }
16558 }
16559 })();
16560 }
16561 }
16562 }
16563
16564 fiber = createFiber(fiberTag, pendingProps, key, mode);
16565 fiber.elementType = type;
16566 fiber.type = resolvedType;
16567 fiber.expirationTime = expirationTime;
16568 return fiber;
16569}
16570function createFiberFromElement(element, mode, expirationTime) {
16571 var owner = null;
16572
16573 {
16574 owner = element._owner;
16575 }
16576
16577 var type = element.type;
16578 var key = element.key;
16579 var pendingProps = element.props;
16580 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
16581
16582 {
16583 fiber._debugSource = element._source;
16584 fiber._debugOwner = element._owner;
16585 }
16586
16587 return fiber;
16588}
16589function createFiberFromFragment(elements, mode, expirationTime, key) {
16590 var fiber = createFiber(Fragment, elements, key, mode);
16591 fiber.expirationTime = expirationTime;
16592 return fiber;
16593}
16594function createFiberFromFundamental(fundamentalComponent, pendingProps, mode, expirationTime, key) {
16595 var fiber = createFiber(FundamentalComponent, pendingProps, key, mode);
16596 fiber.elementType = fundamentalComponent;
16597 fiber.type = fundamentalComponent;
16598 fiber.expirationTime = expirationTime;
16599 return fiber;
16600}
16601
16602function createFiberFromScope(scope, pendingProps, mode, expirationTime, key) {
16603 var fiber = createFiber(ScopeComponent, pendingProps, key, mode);
16604 fiber.type = scope;
16605 fiber.elementType = scope;
16606 fiber.expirationTime = expirationTime;
16607 return fiber;
16608}
16609
16610function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
16611 {
16612 if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
16613 warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
16614 }
16615 }
16616
16617 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag.
16618
16619 fiber.elementType = REACT_PROFILER_TYPE;
16620 fiber.type = REACT_PROFILER_TYPE;
16621 fiber.expirationTime = expirationTime;
16622 return fiber;
16623}
16624
16625function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
16626 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
16627 // This needs to be fixed in getComponentName so that it relies on the tag
16628 // instead.
16629
16630 fiber.type = REACT_SUSPENSE_TYPE;
16631 fiber.elementType = REACT_SUSPENSE_TYPE;
16632 fiber.expirationTime = expirationTime;
16633 return fiber;
16634}
16635function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
16636 var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
16637
16638 {
16639 // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
16640 // This needs to be fixed in getComponentName so that it relies on the tag
16641 // instead.
16642 fiber.type = REACT_SUSPENSE_LIST_TYPE;
16643 }
16644
16645 fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
16646 fiber.expirationTime = expirationTime;
16647 return fiber;
16648}
16649function createFiberFromText(content, mode, expirationTime) {
16650 var fiber = createFiber(HostText, content, null, mode);
16651 fiber.expirationTime = expirationTime;
16652 return fiber;
16653}
16654function createFiberFromHostInstanceForDeletion() {
16655 var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type.
16656
16657 fiber.elementType = 'DELETED';
16658 fiber.type = 'DELETED';
16659 return fiber;
16660}
16661function createFiberFromDehydratedFragment(dehydratedNode) {
16662 var fiber = createFiber(DehydratedFragment, null, null, NoMode);
16663 fiber.stateNode = dehydratedNode;
16664 return fiber;
16665}
16666function createFiberFromPortal(portal, mode, expirationTime) {
16667 var pendingProps = portal.children !== null ? portal.children : [];
16668 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
16669 fiber.expirationTime = expirationTime;
16670 fiber.stateNode = {
16671 containerInfo: portal.containerInfo,
16672 pendingChildren: null,
16673 // Used by persistent updates
16674 implementation: portal.implementation
16675 };
16676 return fiber;
16677} // Used for stashing WIP properties to replay failed work in DEV.
16678
16679function assignFiberPropertiesInDEV(target, source) {
16680 if (target === null) {
16681 // This Fiber's initial properties will always be overwritten.
16682 // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
16683 target = createFiber(IndeterminateComponent, null, null, NoMode);
16684 } // This is intentionally written as a list of all properties.
16685 // We tried to use Object.assign() instead but this is called in
16686 // the hottest path, and Object.assign() was too slow:
16687 // https://github.com/facebook/react/issues/12502
16688 // This code is DEV-only so size is not a concern.
16689
16690
16691 target.tag = source.tag;
16692 target.key = source.key;
16693 target.elementType = source.elementType;
16694 target.type = source.type;
16695 target.stateNode = source.stateNode;
16696 target.return = source.return;
16697 target.child = source.child;
16698 target.sibling = source.sibling;
16699 target.index = source.index;
16700 target.ref = source.ref;
16701 target.pendingProps = source.pendingProps;
16702 target.memoizedProps = source.memoizedProps;
16703 target.updateQueue = source.updateQueue;
16704 target.memoizedState = source.memoizedState;
16705 target.dependencies = source.dependencies;
16706 target.mode = source.mode;
16707 target.effectTag = source.effectTag;
16708 target.nextEffect = source.nextEffect;
16709 target.firstEffect = source.firstEffect;
16710 target.lastEffect = source.lastEffect;
16711 target.expirationTime = source.expirationTime;
16712 target.childExpirationTime = source.childExpirationTime;
16713 target.alternate = source.alternate;
16714
16715 if (enableProfilerTimer) {
16716 target.actualDuration = source.actualDuration;
16717 target.actualStartTime = source.actualStartTime;
16718 target.selfBaseDuration = source.selfBaseDuration;
16719 target.treeBaseDuration = source.treeBaseDuration;
16720 }
16721
16722 target._debugID = source._debugID;
16723 target._debugSource = source._debugSource;
16724 target._debugOwner = source._debugOwner;
16725 target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
16726 target._debugNeedsRemount = source._debugNeedsRemount;
16727 target._debugHookTypes = source._debugHookTypes;
16728 return target;
16729}
16730
16731function FiberRootNode(containerInfo, tag, hydrate) {
16732 this.tag = tag;
16733 this.current = null;
16734 this.containerInfo = containerInfo;
16735 this.pendingChildren = null;
16736 this.pingCache = null;
16737 this.finishedExpirationTime = NoWork;
16738 this.finishedWork = null;
16739 this.timeoutHandle = noTimeout;
16740 this.context = null;
16741 this.pendingContext = null;
16742 this.hydrate = hydrate;
16743 this.firstBatch = null;
16744 this.callbackNode = null;
16745 this.callbackPriority = NoPriority;
16746 this.firstPendingTime = NoWork;
16747 this.firstSuspendedTime = NoWork;
16748 this.lastSuspendedTime = NoWork;
16749 this.nextKnownPendingLevel = NoWork;
16750 this.lastPingedTime = NoWork;
16751 this.lastExpiredTime = NoWork;
16752
16753 if (enableSchedulerTracing) {
16754 this.interactionThreadID = tracing.unstable_getThreadID();
16755 this.memoizedInteractions = new Set();
16756 this.pendingInteractionMap = new Map();
16757 }
16758
16759 if (enableSuspenseCallback) {
16760 this.hydrationCallbacks = null;
16761 }
16762}
16763
16764function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
16765 var root = new FiberRootNode(containerInfo, tag, hydrate);
16766
16767 if (enableSuspenseCallback) {
16768 root.hydrationCallbacks = hydrationCallbacks;
16769 } // Cyclic construction. This cheats the type system right now because
16770 // stateNode is any.
16771
16772
16773 var uninitializedFiber = createHostRootFiber(tag);
16774 root.current = uninitializedFiber;
16775 uninitializedFiber.stateNode = root;
16776 return root;
16777}
16778function isRootSuspendedAtTime(root, expirationTime) {
16779 var firstSuspendedTime = root.firstSuspendedTime;
16780 var lastSuspendedTime = root.lastSuspendedTime;
16781 return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime;
16782}
16783function markRootSuspendedAtTime(root, expirationTime) {
16784 var firstSuspendedTime = root.firstSuspendedTime;
16785 var lastSuspendedTime = root.lastSuspendedTime;
16786
16787 if (firstSuspendedTime < expirationTime) {
16788 root.firstSuspendedTime = expirationTime;
16789 }
16790
16791 if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
16792 root.lastSuspendedTime = expirationTime;
16793 }
16794
16795 if (expirationTime <= root.lastPingedTime) {
16796 root.lastPingedTime = NoWork;
16797 }
16798
16799 if (expirationTime <= root.lastExpiredTime) {
16800 root.lastExpiredTime = NoWork;
16801 }
16802}
16803function markRootUpdatedAtTime(root, expirationTime) {
16804 // Update the range of pending times
16805 var firstPendingTime = root.firstPendingTime;
16806
16807 if (expirationTime > firstPendingTime) {
16808 root.firstPendingTime = expirationTime;
16809 } // Update the range of suspended times. Treat everything lower priority or
16810 // equal to this update as unsuspended.
16811
16812
16813 var firstSuspendedTime = root.firstSuspendedTime;
16814
16815 if (firstSuspendedTime !== NoWork) {
16816 if (expirationTime >= firstSuspendedTime) {
16817 // The entire suspended range is now unsuspended.
16818 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
16819 } else if (expirationTime >= root.lastSuspendedTime) {
16820 root.lastSuspendedTime = expirationTime + 1;
16821 } // This is a pending level. Check if it's higher priority than the next
16822 // known pending level.
16823
16824
16825 if (expirationTime > root.nextKnownPendingLevel) {
16826 root.nextKnownPendingLevel = expirationTime;
16827 }
16828 }
16829}
16830function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) {
16831 // Update the range of pending times
16832 root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or
16833 // equal to this update as unsuspended.
16834
16835 if (finishedExpirationTime <= root.lastSuspendedTime) {
16836 // The entire suspended range is now unsuspended.
16837 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
16838 } else if (finishedExpirationTime <= root.firstSuspendedTime) {
16839 // Part of the suspended range is now unsuspended. Narrow the range to
16840 // include everything between the unsuspended time (non-inclusive) and the
16841 // last suspended time.
16842 root.firstSuspendedTime = finishedExpirationTime - 1;
16843 }
16844
16845 if (finishedExpirationTime <= root.lastPingedTime) {
16846 // Clear the pinged time
16847 root.lastPingedTime = NoWork;
16848 }
16849
16850 if (finishedExpirationTime <= root.lastExpiredTime) {
16851 // Clear the expired time
16852 root.lastExpiredTime = NoWork;
16853 }
16854}
16855function markRootExpiredAtTime(root, expirationTime) {
16856 var lastExpiredTime = root.lastExpiredTime;
16857
16858 if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
16859 root.lastExpiredTime = expirationTime;
16860 }
16861}
16862
16863// This lets us hook into Fiber to debug what it's doing.
16864// See https://github.com/facebook/react/pull/8033.
16865// This is not part of the public API, not even for React DevTools.
16866// You may only inject a debugTool if you work on React Fiber itself.
16867var ReactFiberInstrumentation = {
16868 debugTool: null
16869};
16870var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
16871
16872var didWarnAboutNestedUpdates;
16873var didWarnAboutFindNodeInStrictMode;
16874
16875{
16876 didWarnAboutNestedUpdates = false;
16877 didWarnAboutFindNodeInStrictMode = {};
16878}
16879
16880function getContextForSubtree(parentComponent) {
16881 if (!parentComponent) {
16882 return emptyContextObject;
16883 }
16884
16885 var fiber = get(parentComponent);
16886 var parentContext = findCurrentUnmaskedContext(fiber);
16887
16888 if (fiber.tag === ClassComponent) {
16889 var Component = fiber.type;
16890
16891 if (isContextProvider(Component)) {
16892 return processChildContext(fiber, Component, parentContext);
16893 }
16894 }
16895
16896 return parentContext;
16897}
16898
16899function scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback) {
16900 {
16901 if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
16902 didWarnAboutNestedUpdates = true;
16903 warningWithoutStack$1(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current.type) || 'Unknown');
16904 }
16905 }
16906
16907 var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property
16908 // being called "element".
16909
16910 update.payload = {
16911 element: element
16912 };
16913 callback = callback === undefined ? null : callback;
16914
16915 if (callback !== null) {
16916 !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
16917 update.callback = callback;
16918 }
16919
16920 enqueueUpdate(current$$1, update);
16921 scheduleWork(current$$1, expirationTime);
16922 return expirationTime;
16923}
16924
16925function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback) {
16926 // TODO: If this is a nested container, this won't be the root.
16927 var current$$1 = container.current;
16928
16929 {
16930 if (ReactFiberInstrumentation_1.debugTool) {
16931 if (current$$1.alternate === null) {
16932 ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
16933 } else if (element === null) {
16934 ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
16935 } else {
16936 ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
16937 }
16938 }
16939 }
16940
16941 var context = getContextForSubtree(parentComponent);
16942
16943 if (container.context === null) {
16944 container.context = context;
16945 } else {
16946 container.pendingContext = context;
16947 }
16948
16949 return scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback);
16950}
16951
16952function findHostInstance(component) {
16953 var fiber = get(component);
16954
16955 if (fiber === undefined) {
16956 if (typeof component.render === 'function') {
16957 (function () {
16958 {
16959 {
16960 throw ReactError(Error("Unable to find node on an unmounted component."));
16961 }
16962 }
16963 })();
16964 } else {
16965 (function () {
16966 {
16967 {
16968 throw ReactError(Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component)));
16969 }
16970 }
16971 })();
16972 }
16973 }
16974
16975 var hostFiber = findCurrentHostFiber(fiber);
16976
16977 if (hostFiber === null) {
16978 return null;
16979 }
16980
16981 return hostFiber.stateNode;
16982}
16983
16984function findHostInstanceWithWarning(component, methodName) {
16985 {
16986 var fiber = get(component);
16987
16988 if (fiber === undefined) {
16989 if (typeof component.render === 'function') {
16990 (function () {
16991 {
16992 {
16993 throw ReactError(Error("Unable to find node on an unmounted component."));
16994 }
16995 }
16996 })();
16997 } else {
16998 (function () {
16999 {
17000 {
17001 throw ReactError(Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component)));
17002 }
17003 }
17004 })();
17005 }
17006 }
17007
17008 var hostFiber = findCurrentHostFiber(fiber);
17009
17010 if (hostFiber === null) {
17011 return null;
17012 }
17013
17014 if (hostFiber.mode & StrictMode) {
17015 var componentName = getComponentName(fiber.type) || 'Component';
17016
17017 if (!didWarnAboutFindNodeInStrictMode[componentName]) {
17018 didWarnAboutFindNodeInStrictMode[componentName] = true;
17019
17020 if (fiber.mode & StrictMode) {
17021 warningWithoutStack$1(false, '%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
17022 } else {
17023 warningWithoutStack$1(false, '%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
17024 }
17025 }
17026 }
17027
17028 return hostFiber.stateNode;
17029 }
17030
17031 return findHostInstance(component);
17032}
17033
17034function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
17035 return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks);
17036}
17037function updateContainer(element, container, parentComponent, callback) {
17038 var current$$1 = container.current;
17039 var currentTime = requestCurrentTime();
17040
17041 {
17042 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
17043 if ('undefined' !== typeof jest) {
17044 warnIfUnmockedScheduler(current$$1);
17045 warnIfNotScopedWithMatchingAct(current$$1);
17046 }
17047 }
17048
17049 var suspenseConfig = requestCurrentSuspenseConfig();
17050 var expirationTime = computeExpirationForFiber(currentTime, current$$1, suspenseConfig);
17051 return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback);
17052}
17053function getPublicRootInstance(container) {
17054 var containerFiber = container.current;
17055
17056 if (!containerFiber.child) {
17057 return null;
17058 }
17059
17060 switch (containerFiber.child.tag) {
17061 case HostComponent:
17062 return getPublicInstance(containerFiber.child.stateNode);
17063
17064 default:
17065 return containerFiber.child.stateNode;
17066 }
17067}
17068function attemptSynchronousHydration(fiber) {
17069 switch (fiber.tag) {
17070 case HostRoot:
17071 var root = fiber.stateNode;
17072
17073 if (root.hydrate) {
17074 // Flush the first scheduled "update".
17075 flushRoot(root, root.firstPendingTime);
17076 }
17077
17078 break;
17079
17080 case SuspenseComponent:
17081 flushSync(function () {
17082 return scheduleWork(fiber, Sync);
17083 });
17084 break;
17085 }
17086}
17087function findHostInstanceWithNoPortals(fiber) {
17088 var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
17089
17090 if (hostFiber === null) {
17091 return null;
17092 }
17093
17094 if (hostFiber.tag === FundamentalComponent) {
17095 return hostFiber.stateNode.instance;
17096 }
17097
17098 return hostFiber.stateNode;
17099}
17100
17101var shouldSuspendImpl = function (fiber) {
17102 return false;
17103};
17104
17105function shouldSuspend(fiber) {
17106 return shouldSuspendImpl(fiber);
17107}
17108var overrideHookState = null;
17109var overrideProps = null;
17110var scheduleUpdate = null;
17111var setSuspenseHandler = null;
17112
17113{
17114 var copyWithSetImpl = function (obj, path, idx, value) {
17115 if (idx >= path.length) {
17116 return value;
17117 }
17118
17119 var key = path[idx];
17120 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here
17121
17122 updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
17123 return updated;
17124 };
17125
17126 var copyWithSet = function (obj, path, value) {
17127 return copyWithSetImpl(obj, path, 0, value);
17128 }; // Support DevTools editable values for useState and useReducer.
17129
17130
17131 overrideHookState = function (fiber, id, path, value) {
17132 // For now, the "id" of stateful hooks is just the stateful hook index.
17133 // This may change in the future with e.g. nested hooks.
17134 var currentHook = fiber.memoizedState;
17135
17136 while (currentHook !== null && id > 0) {
17137 currentHook = currentHook.next;
17138 id--;
17139 }
17140
17141 if (currentHook !== null) {
17142 var newState = copyWithSet(currentHook.memoizedState, path, value);
17143 currentHook.memoizedState = newState;
17144 currentHook.baseState = newState; // We aren't actually adding an update to the queue,
17145 // because there is no update we can add for useReducer hooks that won't trigger an error.
17146 // (There's no appropriate action type for DevTools overrides.)
17147 // As a result though, React will see the scheduled update as a noop and bailout.
17148 // Shallow cloning props works as a workaround for now to bypass the bailout check.
17149
17150 fiber.memoizedProps = _assign({}, fiber.memoizedProps);
17151 scheduleWork(fiber, Sync);
17152 }
17153 }; // Support DevTools props for function components, forwardRef, memo, host components, etc.
17154
17155
17156 overrideProps = function (fiber, path, value) {
17157 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
17158
17159 if (fiber.alternate) {
17160 fiber.alternate.pendingProps = fiber.pendingProps;
17161 }
17162
17163 scheduleWork(fiber, Sync);
17164 };
17165
17166 scheduleUpdate = function (fiber) {
17167 scheduleWork(fiber, Sync);
17168 };
17169
17170 setSuspenseHandler = function (newShouldSuspendImpl) {
17171 shouldSuspendImpl = newShouldSuspendImpl;
17172 };
17173}
17174
17175function injectIntoDevTools(devToolsConfig) {
17176 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
17177 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
17178 return injectInternals(_assign({}, devToolsConfig, {
17179 overrideHookState: overrideHookState,
17180 overrideProps: overrideProps,
17181 setSuspenseHandler: setSuspenseHandler,
17182 scheduleUpdate: scheduleUpdate,
17183 currentDispatcherRef: ReactCurrentDispatcher,
17184 findHostInstanceByFiber: function (fiber) {
17185 var hostFiber = findCurrentHostFiber(fiber);
17186
17187 if (hostFiber === null) {
17188 return null;
17189 }
17190
17191 return hostFiber.stateNode;
17192 },
17193 findFiberByHostInstance: function (instance) {
17194 if (!findFiberByHostInstance) {
17195 // Might not be implemented by the renderer.
17196 return null;
17197 }
17198
17199 return findFiberByHostInstance(instance);
17200 },
17201 // React Refresh
17202 findHostInstancesForRefresh: findHostInstancesForRefresh,
17203 scheduleRefresh: scheduleRefresh,
17204 scheduleRoot: scheduleRoot,
17205 setRefreshHandler: setRefreshHandler,
17206 // Enables DevTools to append owner stacks to error messages in DEV mode.
17207 getCurrentFiber: function () {
17208 return current;
17209 }
17210 }));
17211}
17212
17213var ReactFiberReconciler = Object.freeze({
17214 updateContainerAtExpirationTime: updateContainerAtExpirationTime,
17215 createContainer: createContainer,
17216 updateContainer: updateContainer,
17217 flushRoot: flushRoot,
17218 computeUniqueAsyncExpiration: computeUniqueAsyncExpiration,
17219 batchedEventUpdates: batchedEventUpdates,
17220 batchedUpdates: batchedUpdates,
17221 unbatchedUpdates: unbatchedUpdates,
17222 deferredUpdates: deferredUpdates,
17223 syncUpdates: syncUpdates,
17224 discreteUpdates: discreteUpdates,
17225 flushDiscreteUpdates: flushDiscreteUpdates,
17226 flushControlled: flushControlled,
17227 flushSync: flushSync,
17228 flushPassiveEffects: flushPassiveEffects,
17229 IsThisRendererActing: IsThisRendererActing,
17230 getPublicRootInstance: getPublicRootInstance,
17231 attemptSynchronousHydration: attemptSynchronousHydration,
17232 findHostInstance: findHostInstance,
17233 findHostInstanceWithWarning: findHostInstanceWithWarning,
17234 findHostInstanceWithNoPortals: findHostInstanceWithNoPortals,
17235 shouldSuspend: shouldSuspend,
17236 injectIntoDevTools: injectIntoDevTools
17237});
17238
17239// This is the same export as in index.js,
17240// with persistent reconciler flags turned on.
17241
17242 // TODO: decide on the top-level export form.
17243// This is hacky but makes it work with both Rollup and Jest.
17244
17245
17246var persistent = ReactFiberReconciler.default || ReactFiberReconciler;
17247
17248module.exports = persistent;
17249 var $$$renderer = module.exports;
17250 module.exports = $$$reconciler;
17251 return $$$renderer;
17252 };
17253}