1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | (function (global, factory) {
|
13 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('scheduler/unstable_mock'), require('scheduler')) :
|
14 | typeof define === 'function' && define.amd ? define(['react', 'scheduler/unstable_mock', 'scheduler'], factory) :
|
15 | (global = global || self, global.ReactTestRenderer = factory(global.React, global.SchedulerMock, global.Scheduler));
|
16 | }(this, (function (React, Scheduler, Scheduler$1) { 'use strict';
|
17 |
|
18 | function _defineProperties(target, props) {
|
19 | for (var i = 0; i < props.length; i++) {
|
20 | var descriptor = props[i];
|
21 | descriptor.enumerable = descriptor.enumerable || false;
|
22 | descriptor.configurable = true;
|
23 | if ("value" in descriptor) descriptor.writable = true;
|
24 | Object.defineProperty(target, descriptor.key, descriptor);
|
25 | }
|
26 | }
|
27 |
|
28 | function _createClass(Constructor, protoProps, staticProps) {
|
29 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
30 | if (staticProps) _defineProperties(Constructor, staticProps);
|
31 | return Constructor;
|
32 | }
|
33 |
|
34 | function _objectWithoutPropertiesLoose(source, excluded) {
|
35 | if (source == null) return {};
|
36 | var target = {};
|
37 | var sourceKeys = Object.keys(source);
|
38 | var key, i;
|
39 |
|
40 | for (i = 0; i < sourceKeys.length; i++) {
|
41 | key = sourceKeys[i];
|
42 | if (excluded.indexOf(key) >= 0) continue;
|
43 | target[key] = source[key];
|
44 | }
|
45 |
|
46 | return target;
|
47 | }
|
48 |
|
49 | var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
50 | var _assign = ReactInternals.assign;
|
51 |
|
52 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
53 |
|
54 |
|
55 |
|
56 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
57 | ReactSharedInternals.ReactCurrentDispatcher = {
|
58 | current: null
|
59 | };
|
60 | }
|
61 |
|
62 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
63 | ReactSharedInternals.ReactCurrentBatchConfig = {
|
64 | suspense: null
|
65 | };
|
66 | }
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | function warn(format) {
|
74 | {
|
75 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
76 | args[_key - 1] = arguments[_key];
|
77 | }
|
78 |
|
79 | printWarning('warn', format, args);
|
80 | }
|
81 | }
|
82 | function error(format) {
|
83 | {
|
84 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
85 | args[_key2 - 1] = arguments[_key2];
|
86 | }
|
87 |
|
88 | printWarning('error', format, args);
|
89 | }
|
90 | }
|
91 |
|
92 | function printWarning(level, format, args) {
|
93 |
|
94 |
|
95 | {
|
96 | var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
|
97 |
|
98 | if (!hasExistingStack) {
|
99 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
100 | var stack = ReactDebugCurrentFrame.getStackAddendum();
|
101 |
|
102 | if (stack !== '') {
|
103 | format += '%s';
|
104 | args = args.concat([stack]);
|
105 | }
|
106 | }
|
107 |
|
108 | var argsWithFormat = args.map(function (item) {
|
109 | return '' + item;
|
110 | });
|
111 |
|
112 | argsWithFormat.unshift('Warning: ' + format);
|
113 |
|
114 |
|
115 |
|
116 | Function.prototype.apply.call(console[level], console, argsWithFormat);
|
117 |
|
118 | try {
|
119 |
|
120 |
|
121 |
|
122 | var argIndex = 0;
|
123 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
124 | return args[argIndex++];
|
125 | });
|
126 | throw new Error(message);
|
127 | } catch (x) {}
|
128 | }
|
129 | }
|
130 |
|
131 | var FunctionComponent = 0;
|
132 | var ClassComponent = 1;
|
133 | var IndeterminateComponent = 2;
|
134 |
|
135 | var HostRoot = 3;
|
136 |
|
137 | var HostPortal = 4;
|
138 |
|
139 | var HostComponent = 5;
|
140 | var HostText = 6;
|
141 | var Fragment = 7;
|
142 | var Mode = 8;
|
143 | var ContextConsumer = 9;
|
144 | var ContextProvider = 10;
|
145 | var ForwardRef = 11;
|
146 | var Profiler = 12;
|
147 | var SuspenseComponent = 13;
|
148 | var MemoComponent = 14;
|
149 | var SimpleMemoComponent = 15;
|
150 | var LazyComponent = 16;
|
151 | var IncompleteClassComponent = 17;
|
152 | var DehydratedFragment = 18;
|
153 | var SuspenseListComponent = 19;
|
154 | var FundamentalComponent = 20;
|
155 | var ScopeComponent = 21;
|
156 | var Block = 22;
|
157 |
|
158 | |
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | function get(key) {
|
168 | return key._reactInternalFiber;
|
169 | }
|
170 | function set(key, value) {
|
171 | key._reactInternalFiber = value;
|
172 | }
|
173 |
|
174 |
|
175 |
|
176 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
177 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
178 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
179 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
180 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
181 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
182 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
183 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
184 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
185 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
186 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
187 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
188 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
189 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
190 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
191 | var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
192 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
193 | function getIteratorFn(maybeIterable) {
|
194 | if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
195 | return null;
|
196 | }
|
197 |
|
198 | var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
199 |
|
200 | if (typeof maybeIterator === 'function') {
|
201 | return maybeIterator;
|
202 | }
|
203 |
|
204 | return null;
|
205 | }
|
206 |
|
207 | var Uninitialized = -1;
|
208 | var Pending = 0;
|
209 | var Resolved = 1;
|
210 | var Rejected = 2;
|
211 | function refineResolvedLazyComponent(lazyComponent) {
|
212 | return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
213 | }
|
214 | function initializeLazyComponentType(lazyComponent) {
|
215 | if (lazyComponent._status === Uninitialized) {
|
216 | lazyComponent._status = Pending;
|
217 | var ctor = lazyComponent._ctor;
|
218 | var thenable = ctor();
|
219 | lazyComponent._result = thenable;
|
220 | thenable.then(function (moduleObject) {
|
221 | if (lazyComponent._status === Pending) {
|
222 | var defaultExport = moduleObject.default;
|
223 |
|
224 | {
|
225 | if (defaultExport === undefined) {
|
226 | error('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);
|
227 | }
|
228 | }
|
229 |
|
230 | lazyComponent._status = Resolved;
|
231 | lazyComponent._result = defaultExport;
|
232 | }
|
233 | }, function (error) {
|
234 | if (lazyComponent._status === Pending) {
|
235 | lazyComponent._status = Rejected;
|
236 | lazyComponent._result = error;
|
237 | }
|
238 | });
|
239 | }
|
240 | }
|
241 |
|
242 | function getWrappedName(outerType, innerType, wrapperName) {
|
243 | var functionName = innerType.displayName || innerType.name || '';
|
244 | return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
245 | }
|
246 |
|
247 | function getComponentName(type) {
|
248 | if (type == null) {
|
249 |
|
250 | return null;
|
251 | }
|
252 |
|
253 | {
|
254 | if (typeof type.tag === 'number') {
|
255 | error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
256 | }
|
257 | }
|
258 |
|
259 | if (typeof type === 'function') {
|
260 | return type.displayName || type.name || null;
|
261 | }
|
262 |
|
263 | if (typeof type === 'string') {
|
264 | return type;
|
265 | }
|
266 |
|
267 | switch (type) {
|
268 | case REACT_FRAGMENT_TYPE:
|
269 | return 'Fragment';
|
270 |
|
271 | case REACT_PORTAL_TYPE:
|
272 | return 'Portal';
|
273 |
|
274 | case REACT_PROFILER_TYPE:
|
275 | return "Profiler";
|
276 |
|
277 | case REACT_STRICT_MODE_TYPE:
|
278 | return 'StrictMode';
|
279 |
|
280 | case REACT_SUSPENSE_TYPE:
|
281 | return 'Suspense';
|
282 |
|
283 | case REACT_SUSPENSE_LIST_TYPE:
|
284 | return 'SuspenseList';
|
285 | }
|
286 |
|
287 | if (typeof type === 'object') {
|
288 | switch (type.$$typeof) {
|
289 | case REACT_CONTEXT_TYPE:
|
290 | return 'Context.Consumer';
|
291 |
|
292 | case REACT_PROVIDER_TYPE:
|
293 | return 'Context.Provider';
|
294 |
|
295 | case REACT_FORWARD_REF_TYPE:
|
296 | return getWrappedName(type, type.render, 'ForwardRef');
|
297 |
|
298 | case REACT_MEMO_TYPE:
|
299 | return getComponentName(type.type);
|
300 |
|
301 | case REACT_BLOCK_TYPE:
|
302 | return getComponentName(type.render);
|
303 |
|
304 | case REACT_LAZY_TYPE:
|
305 | {
|
306 | var thenable = type;
|
307 | var resolvedThenable = refineResolvedLazyComponent(thenable);
|
308 |
|
309 | if (resolvedThenable) {
|
310 | return getComponentName(resolvedThenable);
|
311 | }
|
312 |
|
313 | break;
|
314 | }
|
315 | }
|
316 | }
|
317 |
|
318 | return null;
|
319 | }
|
320 |
|
321 |
|
322 | var NoEffect =
|
323 |
|
324 | 0;
|
325 | var PerformedWork =
|
326 |
|
327 | 1;
|
328 |
|
329 | var Placement =
|
330 |
|
331 | 2;
|
332 | var Update =
|
333 |
|
334 | 4;
|
335 | var PlacementAndUpdate =
|
336 |
|
337 | 6;
|
338 | var Deletion =
|
339 |
|
340 | 8;
|
341 | var ContentReset =
|
342 |
|
343 | 16;
|
344 | var Callback =
|
345 |
|
346 | 32;
|
347 | var DidCapture =
|
348 |
|
349 | 64;
|
350 | var Ref =
|
351 |
|
352 | 128;
|
353 | var Snapshot =
|
354 |
|
355 | 256;
|
356 | var Passive =
|
357 |
|
358 | 512;
|
359 | var Hydrating =
|
360 |
|
361 | 1024;
|
362 | var HydratingAndUpdate =
|
363 |
|
364 | 1028;
|
365 |
|
366 | var LifecycleEffectMask =
|
367 |
|
368 | 932;
|
369 |
|
370 | var HostEffectMask =
|
371 |
|
372 | 2047;
|
373 | var Incomplete =
|
374 |
|
375 | 2048;
|
376 | var ShouldCapture =
|
377 |
|
378 | 4096;
|
379 |
|
380 | var enableProfilerTimer = true;
|
381 | var enableFundamentalAPI = false;
|
382 | var warnAboutStringRefs = false;
|
383 |
|
384 | var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
385 | function getNearestMountedFiber(fiber) {
|
386 | var node = fiber;
|
387 | var nearestMounted = fiber;
|
388 |
|
389 | if (!fiber.alternate) {
|
390 |
|
391 |
|
392 | var nextNode = node;
|
393 |
|
394 | do {
|
395 | node = nextNode;
|
396 |
|
397 | if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
|
398 |
|
399 |
|
400 |
|
401 | nearestMounted = node.return;
|
402 | }
|
403 |
|
404 | nextNode = node.return;
|
405 | } while (nextNode);
|
406 | } else {
|
407 | while (node.return) {
|
408 | node = node.return;
|
409 | }
|
410 | }
|
411 |
|
412 | if (node.tag === HostRoot) {
|
413 |
|
414 |
|
415 | return nearestMounted;
|
416 | }
|
417 |
|
418 |
|
419 |
|
420 | return null;
|
421 | }
|
422 | function isFiberMounted(fiber) {
|
423 | return getNearestMountedFiber(fiber) === fiber;
|
424 | }
|
425 | function isMounted(component) {
|
426 | {
|
427 | var owner = ReactCurrentOwner.current;
|
428 |
|
429 | if (owner !== null && owner.tag === ClassComponent) {
|
430 | var ownerFiber = owner;
|
431 | var instance = ownerFiber.stateNode;
|
432 |
|
433 | if (!instance._warnedAboutRefsInRender) {
|
434 | error('%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');
|
435 | }
|
436 |
|
437 | instance._warnedAboutRefsInRender = true;
|
438 | }
|
439 | }
|
440 |
|
441 | var fiber = get(component);
|
442 |
|
443 | if (!fiber) {
|
444 | return false;
|
445 | }
|
446 |
|
447 | return getNearestMountedFiber(fiber) === fiber;
|
448 | }
|
449 |
|
450 | function assertIsMounted(fiber) {
|
451 | if (!(getNearestMountedFiber(fiber) === fiber)) {
|
452 | {
|
453 | throw Error( "Unable to find node on an unmounted component." );
|
454 | }
|
455 | }
|
456 | }
|
457 |
|
458 | function findCurrentFiberUsingSlowPath(fiber) {
|
459 | var alternate = fiber.alternate;
|
460 |
|
461 | if (!alternate) {
|
462 |
|
463 | var nearestMounted = getNearestMountedFiber(fiber);
|
464 |
|
465 | if (!(nearestMounted !== null)) {
|
466 | {
|
467 | throw Error( "Unable to find node on an unmounted component." );
|
468 | }
|
469 | }
|
470 |
|
471 | if (nearestMounted !== fiber) {
|
472 | return null;
|
473 | }
|
474 |
|
475 | return fiber;
|
476 | }
|
477 |
|
478 |
|
479 |
|
480 |
|
481 | var a = fiber;
|
482 | var b = alternate;
|
483 |
|
484 | while (true) {
|
485 | var parentA = a.return;
|
486 |
|
487 | if (parentA === null) {
|
488 |
|
489 | break;
|
490 | }
|
491 |
|
492 | var parentB = parentA.alternate;
|
493 |
|
494 | if (parentB === null) {
|
495 |
|
496 |
|
497 |
|
498 |
|
499 | var nextParent = parentA.return;
|
500 |
|
501 | if (nextParent !== null) {
|
502 | a = b = nextParent;
|
503 | continue;
|
504 | }
|
505 |
|
506 |
|
507 | break;
|
508 | }
|
509 |
|
510 |
|
511 |
|
512 |
|
513 | if (parentA.child === parentB.child) {
|
514 | var child = parentA.child;
|
515 |
|
516 | while (child) {
|
517 | if (child === a) {
|
518 |
|
519 | assertIsMounted(parentA);
|
520 | return fiber;
|
521 | }
|
522 |
|
523 | if (child === b) {
|
524 |
|
525 | assertIsMounted(parentA);
|
526 | return alternate;
|
527 | }
|
528 |
|
529 | child = child.sibling;
|
530 | }
|
531 |
|
532 |
|
533 |
|
534 | {
|
535 | {
|
536 | throw Error( "Unable to find node on an unmounted component." );
|
537 | }
|
538 | }
|
539 | }
|
540 |
|
541 | if (a.return !== b.return) {
|
542 |
|
543 |
|
544 |
|
545 |
|
546 | a = parentA;
|
547 | b = parentB;
|
548 | } else {
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 | var didFindChild = false;
|
555 | var _child = parentA.child;
|
556 |
|
557 | while (_child) {
|
558 | if (_child === a) {
|
559 | didFindChild = true;
|
560 | a = parentA;
|
561 | b = parentB;
|
562 | break;
|
563 | }
|
564 |
|
565 | if (_child === b) {
|
566 | didFindChild = true;
|
567 | b = parentA;
|
568 | a = parentB;
|
569 | break;
|
570 | }
|
571 |
|
572 | _child = _child.sibling;
|
573 | }
|
574 |
|
575 | if (!didFindChild) {
|
576 |
|
577 | _child = parentB.child;
|
578 |
|
579 | while (_child) {
|
580 | if (_child === a) {
|
581 | didFindChild = true;
|
582 | a = parentB;
|
583 | b = parentA;
|
584 | break;
|
585 | }
|
586 |
|
587 | if (_child === b) {
|
588 | didFindChild = true;
|
589 | b = parentB;
|
590 | a = parentA;
|
591 | break;
|
592 | }
|
593 |
|
594 | _child = _child.sibling;
|
595 | }
|
596 |
|
597 | if (!didFindChild) {
|
598 | {
|
599 | throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." );
|
600 | }
|
601 | }
|
602 | }
|
603 | }
|
604 |
|
605 | if (!(a.alternate === b)) {
|
606 | {
|
607 | throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." );
|
608 | }
|
609 | }
|
610 | }
|
611 |
|
612 |
|
613 |
|
614 | if (!(a.tag === HostRoot)) {
|
615 | {
|
616 | throw Error( "Unable to find node on an unmounted component." );
|
617 | }
|
618 | }
|
619 |
|
620 | if (a.stateNode.current === a) {
|
621 |
|
622 | return fiber;
|
623 | }
|
624 |
|
625 |
|
626 | return alternate;
|
627 | }
|
628 | function findCurrentHostFiber(parent) {
|
629 | var currentParent = findCurrentFiberUsingSlowPath(parent);
|
630 |
|
631 | if (!currentParent) {
|
632 | return null;
|
633 | }
|
634 |
|
635 |
|
636 | var node = currentParent;
|
637 |
|
638 | while (true) {
|
639 | if (node.tag === HostComponent || node.tag === HostText) {
|
640 | return node;
|
641 | } else if (node.child) {
|
642 | node.child.return = node;
|
643 | node = node.child;
|
644 | continue;
|
645 | }
|
646 |
|
647 | if (node === currentParent) {
|
648 | return null;
|
649 | }
|
650 |
|
651 | while (!node.sibling) {
|
652 | if (!node.return || node.return === currentParent) {
|
653 | return null;
|
654 | }
|
655 |
|
656 | node = node.return;
|
657 | }
|
658 |
|
659 | node.sibling.return = node.return;
|
660 | node = node.sibling;
|
661 | }
|
662 |
|
663 |
|
664 |
|
665 | return null;
|
666 | }
|
667 |
|
668 |
|
669 |
|
670 | function shim() {
|
671 | {
|
672 | {
|
673 | throw Error( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." );
|
674 | }
|
675 | }
|
676 | }
|
677 | var isSuspenseInstancePending = shim;
|
678 | var isSuspenseInstanceFallback = shim;
|
679 | var hydrateTextInstance = shim;
|
680 |
|
681 | var NO_CONTEXT = {};
|
682 | var UPDATE_SIGNAL = {};
|
683 | var nodeToInstanceMap = new WeakMap();
|
684 |
|
685 | {
|
686 | Object.freeze(NO_CONTEXT);
|
687 | Object.freeze(UPDATE_SIGNAL);
|
688 | }
|
689 |
|
690 | function getPublicInstance(inst) {
|
691 | switch (inst.tag) {
|
692 | case 'INSTANCE':
|
693 | var createNodeMock = inst.rootContainerInstance.createNodeMock;
|
694 | var mockNode = createNodeMock({
|
695 | type: inst.type,
|
696 | props: inst.props
|
697 | });
|
698 |
|
699 | if (typeof mockNode === 'object' && mockNode !== null) {
|
700 | nodeToInstanceMap.set(mockNode, inst);
|
701 | }
|
702 |
|
703 | return mockNode;
|
704 |
|
705 | default:
|
706 | return inst;
|
707 | }
|
708 | }
|
709 | function appendChild(parentInstance, child) {
|
710 | {
|
711 | if (!Array.isArray(parentInstance.children)) {
|
712 | error('An invalid container has been provided. ' + 'This may indicate that another renderer is being used in addition to the test renderer. ' + '(For example, ReactDOM.createPortal inside of a ReactTestRenderer tree.) ' + 'This is not supported.');
|
713 | }
|
714 | }
|
715 |
|
716 | var index = parentInstance.children.indexOf(child);
|
717 |
|
718 | if (index !== -1) {
|
719 | parentInstance.children.splice(index, 1);
|
720 | }
|
721 |
|
722 | parentInstance.children.push(child);
|
723 | }
|
724 | function insertBefore(parentInstance, child, beforeChild) {
|
725 | var index = parentInstance.children.indexOf(child);
|
726 |
|
727 | if (index !== -1) {
|
728 | parentInstance.children.splice(index, 1);
|
729 | }
|
730 |
|
731 | var beforeIndex = parentInstance.children.indexOf(beforeChild);
|
732 | parentInstance.children.splice(beforeIndex, 0, child);
|
733 | }
|
734 | function removeChild(parentInstance, child) {
|
735 | var index = parentInstance.children.indexOf(child);
|
736 | parentInstance.children.splice(index, 1);
|
737 | }
|
738 | function getRootHostContext(rootContainerInstance) {
|
739 | return NO_CONTEXT;
|
740 | }
|
741 | function getChildHostContext(parentHostContext, type, rootContainerInstance) {
|
742 | return NO_CONTEXT;
|
743 | }
|
744 | function prepareForCommit(containerInfo) {
|
745 | }
|
746 | function resetAfterCommit(containerInfo) {
|
747 | }
|
748 | function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
|
749 | var propsToUse = props;
|
750 |
|
751 | return {
|
752 | type: type,
|
753 | props: propsToUse,
|
754 | isHidden: false,
|
755 | children: [],
|
756 | internalInstanceHandle: internalInstanceHandle,
|
757 | rootContainerInstance: rootContainerInstance,
|
758 | tag: 'INSTANCE'
|
759 | };
|
760 | }
|
761 | function appendInitialChild(parentInstance, child) {
|
762 | var index = parentInstance.children.indexOf(child);
|
763 |
|
764 | if (index !== -1) {
|
765 | parentInstance.children.splice(index, 1);
|
766 | }
|
767 |
|
768 | parentInstance.children.push(child);
|
769 | }
|
770 | function prepareUpdate(testElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
|
771 | return UPDATE_SIGNAL;
|
772 | }
|
773 | function shouldSetTextContent(type, props) {
|
774 | return false;
|
775 | }
|
776 | function shouldDeprioritizeSubtree(type, props) {
|
777 | return false;
|
778 | }
|
779 | function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
|
780 |
|
781 | return {
|
782 | text: text,
|
783 | isHidden: false,
|
784 | tag: 'TEXT'
|
785 | };
|
786 | }
|
787 | var scheduleTimeout = setTimeout;
|
788 | var cancelTimeout = clearTimeout;
|
789 | var noTimeout = -1;
|
790 | function commitUpdate(instance, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
|
791 | instance.type = type;
|
792 | instance.props = newProps;
|
793 | }
|
794 | function commitTextUpdate(textInstance, oldText, newText) {
|
795 | textInstance.text = newText;
|
796 | }
|
797 | function resetTextContent(testElement) {
|
798 | }
|
799 | var appendChildToContainer = appendChild;
|
800 | var insertInContainerBefore = insertBefore;
|
801 | var removeChildFromContainer = removeChild;
|
802 | function hideInstance(instance) {
|
803 | instance.isHidden = true;
|
804 | }
|
805 | function hideTextInstance(textInstance) {
|
806 | textInstance.isHidden = true;
|
807 | }
|
808 | function unhideInstance(instance, props) {
|
809 | instance.isHidden = false;
|
810 | }
|
811 | function unhideTextInstance(textInstance, text) {
|
812 | textInstance.isHidden = false;
|
813 | }
|
814 |
|
815 | |
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
823 |
|
824 | var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
825 |
|
826 | var printWarning$1 = function() {};
|
827 |
|
828 | {
|
829 | var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
830 | var loggedTypeFailures = {};
|
831 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
832 |
|
833 | printWarning$1 = function(text) {
|
834 | var message = 'Warning: ' + text;
|
835 | if (typeof console !== 'undefined') {
|
836 | console.error(message);
|
837 | }
|
838 | try {
|
839 |
|
840 |
|
841 |
|
842 | throw new Error(message);
|
843 | } catch (x) {}
|
844 | };
|
845 | }
|
846 |
|
847 | |
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
859 | {
|
860 | for (var typeSpecName in typeSpecs) {
|
861 | if (has(typeSpecs, typeSpecName)) {
|
862 | var error;
|
863 |
|
864 |
|
865 |
|
866 | try {
|
867 |
|
868 |
|
869 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
870 | var err = Error(
|
871 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
872 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
873 | );
|
874 | err.name = 'Invariant Violation';
|
875 | throw err;
|
876 | }
|
877 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
878 | } catch (ex) {
|
879 | error = ex;
|
880 | }
|
881 | if (error && !(error instanceof Error)) {
|
882 | printWarning$1(
|
883 | (componentName || 'React class') + ': type specification of ' +
|
884 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
885 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
886 | 'You may have forgotten to pass an argument to the type checker ' +
|
887 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
888 | 'shape all require an argument).'
|
889 | );
|
890 | }
|
891 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
892 |
|
893 |
|
894 | loggedTypeFailures[error.message] = true;
|
895 |
|
896 | var stack = getStack ? getStack() : '';
|
897 |
|
898 | printWarning$1(
|
899 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
900 | );
|
901 | }
|
902 | }
|
903 | }
|
904 | }
|
905 | }
|
906 |
|
907 | |
908 |
|
909 |
|
910 |
|
911 |
|
912 | checkPropTypes.resetWarningCache = function() {
|
913 | {
|
914 | loggedTypeFailures = {};
|
915 | }
|
916 | };
|
917 |
|
918 | var checkPropTypes_1 = checkPropTypes;
|
919 |
|
920 | var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
921 | function describeComponentFrame (name, source, ownerName) {
|
922 | var sourceInfo = '';
|
923 |
|
924 | if (source) {
|
925 | var path = source.fileName;
|
926 | var fileName = path.replace(BEFORE_SLASH_RE, '');
|
927 |
|
928 | {
|
929 |
|
930 |
|
931 | if (/^index\./.test(fileName)) {
|
932 | var match = path.match(BEFORE_SLASH_RE);
|
933 |
|
934 | if (match) {
|
935 | var pathBeforeSlash = match[1];
|
936 |
|
937 | if (pathBeforeSlash) {
|
938 | var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
939 | fileName = folderName + '/' + fileName;
|
940 | }
|
941 | }
|
942 | }
|
943 | }
|
944 |
|
945 | sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
946 | } else if (ownerName) {
|
947 | sourceInfo = ' (created by ' + ownerName + ')';
|
948 | }
|
949 |
|
950 | return '\n in ' + (name || 'Unknown') + sourceInfo;
|
951 | }
|
952 |
|
953 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
954 |
|
955 | function describeFiber(fiber) {
|
956 | switch (fiber.tag) {
|
957 | case HostRoot:
|
958 | case HostPortal:
|
959 | case HostText:
|
960 | case Fragment:
|
961 | case ContextProvider:
|
962 | case ContextConsumer:
|
963 | return '';
|
964 |
|
965 | default:
|
966 | var owner = fiber._debugOwner;
|
967 | var source = fiber._debugSource;
|
968 | var name = getComponentName(fiber.type);
|
969 | var ownerName = null;
|
970 |
|
971 | if (owner) {
|
972 | ownerName = getComponentName(owner.type);
|
973 | }
|
974 |
|
975 | return describeComponentFrame(name, source, ownerName);
|
976 | }
|
977 | }
|
978 |
|
979 | function getStackByFiberInDevAndProd(workInProgress) {
|
980 | var info = '';
|
981 | var node = workInProgress;
|
982 |
|
983 | do {
|
984 | info += describeFiber(node);
|
985 | node = node.return;
|
986 | } while (node);
|
987 |
|
988 | return info;
|
989 | }
|
990 | var current = null;
|
991 | var isRendering = false;
|
992 | function getCurrentFiberOwnerNameInDevOrNull() {
|
993 | {
|
994 | if (current === null) {
|
995 | return null;
|
996 | }
|
997 |
|
998 | var owner = current._debugOwner;
|
999 |
|
1000 | if (owner !== null && typeof owner !== 'undefined') {
|
1001 | return getComponentName(owner.type);
|
1002 | }
|
1003 | }
|
1004 |
|
1005 | return null;
|
1006 | }
|
1007 | function getCurrentFiberStackInDev() {
|
1008 | {
|
1009 | if (current === null) {
|
1010 | return '';
|
1011 | }
|
1012 |
|
1013 |
|
1014 |
|
1015 | return getStackByFiberInDevAndProd(current);
|
1016 | }
|
1017 | }
|
1018 | function resetCurrentFiber() {
|
1019 | {
|
1020 | ReactDebugCurrentFrame.getCurrentStack = null;
|
1021 | current = null;
|
1022 | isRendering = false;
|
1023 | }
|
1024 | }
|
1025 | function setCurrentFiber(fiber) {
|
1026 | {
|
1027 | ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
|
1028 | current = fiber;
|
1029 | isRendering = false;
|
1030 | }
|
1031 | }
|
1032 | function setIsRendering(rendering) {
|
1033 | {
|
1034 | isRendering = rendering;
|
1035 | }
|
1036 | }
|
1037 |
|
1038 |
|
1039 |
|
1040 | var reactEmoji = "\u269B";
|
1041 | var warningEmoji = "\u26D4";
|
1042 | var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
|
1043 |
|
1044 |
|
1045 | var currentFiber = null;
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 | var currentPhase = null;
|
1051 | var currentPhaseFiber = null;
|
1052 |
|
1053 |
|
1054 |
|
1055 | var isCommitting = false;
|
1056 | var hasScheduledUpdateInCurrentCommit = false;
|
1057 | var hasScheduledUpdateInCurrentPhase = false;
|
1058 | var commitCountInCurrentWorkLoop = 0;
|
1059 | var effectCountInCurrentCommit = 0;
|
1060 |
|
1061 |
|
1062 | var labelsInCurrentCommit = new Set();
|
1063 |
|
1064 | var formatMarkName = function (markName) {
|
1065 | return reactEmoji + " " + markName;
|
1066 | };
|
1067 |
|
1068 | var formatLabel = function (label, warning) {
|
1069 | var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
|
1070 | var suffix = warning ? " Warning: " + warning : '';
|
1071 | return "" + prefix + label + suffix;
|
1072 | };
|
1073 |
|
1074 | var beginMark = function (markName) {
|
1075 | performance.mark(formatMarkName(markName));
|
1076 | };
|
1077 |
|
1078 | var clearMark = function (markName) {
|
1079 | performance.clearMarks(formatMarkName(markName));
|
1080 | };
|
1081 |
|
1082 | var endMark = function (label, markName, warning) {
|
1083 | var formattedMarkName = formatMarkName(markName);
|
1084 | var formattedLabel = formatLabel(label, warning);
|
1085 |
|
1086 | try {
|
1087 | performance.measure(formattedLabel, formattedMarkName);
|
1088 | } catch (err) {}
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 | performance.clearMarks(formattedMarkName);
|
1095 | performance.clearMeasures(formattedLabel);
|
1096 | };
|
1097 |
|
1098 | var getFiberMarkName = function (label, debugID) {
|
1099 | return label + " (#" + debugID + ")";
|
1100 | };
|
1101 |
|
1102 | var getFiberLabel = function (componentName, isMounted, phase) {
|
1103 | if (phase === null) {
|
1104 |
|
1105 | return componentName + " [" + (isMounted ? 'update' : 'mount') + "]";
|
1106 | } else {
|
1107 |
|
1108 | return componentName + "." + phase;
|
1109 | }
|
1110 | };
|
1111 |
|
1112 | var beginFiberMark = function (fiber, phase) {
|
1113 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1114 | var debugID = fiber._debugID;
|
1115 | var isMounted = fiber.alternate !== null;
|
1116 | var label = getFiberLabel(componentName, isMounted, phase);
|
1117 |
|
1118 | if (isCommitting && labelsInCurrentCommit.has(label)) {
|
1119 |
|
1120 |
|
1121 |
|
1122 | return false;
|
1123 | }
|
1124 |
|
1125 | labelsInCurrentCommit.add(label);
|
1126 | var markName = getFiberMarkName(label, debugID);
|
1127 | beginMark(markName);
|
1128 | return true;
|
1129 | };
|
1130 |
|
1131 | var clearFiberMark = function (fiber, phase) {
|
1132 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1133 | var debugID = fiber._debugID;
|
1134 | var isMounted = fiber.alternate !== null;
|
1135 | var label = getFiberLabel(componentName, isMounted, phase);
|
1136 | var markName = getFiberMarkName(label, debugID);
|
1137 | clearMark(markName);
|
1138 | };
|
1139 |
|
1140 | var endFiberMark = function (fiber, phase, warning) {
|
1141 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1142 | var debugID = fiber._debugID;
|
1143 | var isMounted = fiber.alternate !== null;
|
1144 | var label = getFiberLabel(componentName, isMounted, phase);
|
1145 | var markName = getFiberMarkName(label, debugID);
|
1146 | endMark(label, markName, warning);
|
1147 | };
|
1148 |
|
1149 | var shouldIgnoreFiber = function (fiber) {
|
1150 |
|
1151 |
|
1152 | switch (fiber.tag) {
|
1153 | case HostRoot:
|
1154 | case HostComponent:
|
1155 | case HostText:
|
1156 | case HostPortal:
|
1157 | case Fragment:
|
1158 | case ContextProvider:
|
1159 | case ContextConsumer:
|
1160 | case Mode:
|
1161 | return true;
|
1162 |
|
1163 | default:
|
1164 | return false;
|
1165 | }
|
1166 | };
|
1167 |
|
1168 | var clearPendingPhaseMeasurement = function () {
|
1169 | if (currentPhase !== null && currentPhaseFiber !== null) {
|
1170 | clearFiberMark(currentPhaseFiber, currentPhase);
|
1171 | }
|
1172 |
|
1173 | currentPhaseFiber = null;
|
1174 | currentPhase = null;
|
1175 | hasScheduledUpdateInCurrentPhase = false;
|
1176 | };
|
1177 |
|
1178 | var pauseTimers = function () {
|
1179 |
|
1180 |
|
1181 | var fiber = currentFiber;
|
1182 |
|
1183 | while (fiber) {
|
1184 | if (fiber._debugIsCurrentlyTiming) {
|
1185 | endFiberMark(fiber, null, null);
|
1186 | }
|
1187 |
|
1188 | fiber = fiber.return;
|
1189 | }
|
1190 | };
|
1191 |
|
1192 | var resumeTimersRecursively = function (fiber) {
|
1193 | if (fiber.return !== null) {
|
1194 | resumeTimersRecursively(fiber.return);
|
1195 | }
|
1196 |
|
1197 | if (fiber._debugIsCurrentlyTiming) {
|
1198 | beginFiberMark(fiber, null);
|
1199 | }
|
1200 | };
|
1201 |
|
1202 | var resumeTimers = function () {
|
1203 |
|
1204 | if (currentFiber !== null) {
|
1205 | resumeTimersRecursively(currentFiber);
|
1206 | }
|
1207 | };
|
1208 |
|
1209 | function recordEffect() {
|
1210 | {
|
1211 | effectCountInCurrentCommit++;
|
1212 | }
|
1213 | }
|
1214 | function recordScheduleUpdate() {
|
1215 | {
|
1216 | if (isCommitting) {
|
1217 | hasScheduledUpdateInCurrentCommit = true;
|
1218 | }
|
1219 |
|
1220 | if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
|
1221 | hasScheduledUpdateInCurrentPhase = true;
|
1222 | }
|
1223 | }
|
1224 | }
|
1225 | function startWorkTimer(fiber) {
|
1226 | {
|
1227 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1228 | return;
|
1229 | }
|
1230 |
|
1231 |
|
1232 | currentFiber = fiber;
|
1233 |
|
1234 | if (!beginFiberMark(fiber, null)) {
|
1235 | return;
|
1236 | }
|
1237 |
|
1238 | fiber._debugIsCurrentlyTiming = true;
|
1239 | }
|
1240 | }
|
1241 | function cancelWorkTimer(fiber) {
|
1242 | {
|
1243 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1244 | return;
|
1245 | }
|
1246 |
|
1247 |
|
1248 |
|
1249 | fiber._debugIsCurrentlyTiming = false;
|
1250 | clearFiberMark(fiber, null);
|
1251 | }
|
1252 | }
|
1253 | function stopWorkTimer(fiber) {
|
1254 | {
|
1255 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1256 | return;
|
1257 | }
|
1258 |
|
1259 |
|
1260 | currentFiber = fiber.return;
|
1261 |
|
1262 | if (!fiber._debugIsCurrentlyTiming) {
|
1263 | return;
|
1264 | }
|
1265 |
|
1266 | fiber._debugIsCurrentlyTiming = false;
|
1267 | endFiberMark(fiber, null, null);
|
1268 | }
|
1269 | }
|
1270 | function stopFailedWorkTimer(fiber) {
|
1271 | {
|
1272 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1273 | return;
|
1274 | }
|
1275 |
|
1276 |
|
1277 | currentFiber = fiber.return;
|
1278 |
|
1279 | if (!fiber._debugIsCurrentlyTiming) {
|
1280 | return;
|
1281 | }
|
1282 |
|
1283 | fiber._debugIsCurrentlyTiming = false;
|
1284 | var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
|
1285 | endFiberMark(fiber, null, warning);
|
1286 | }
|
1287 | }
|
1288 | function startPhaseTimer(fiber, phase) {
|
1289 | {
|
1290 | if (!supportsUserTiming) {
|
1291 | return;
|
1292 | }
|
1293 |
|
1294 | clearPendingPhaseMeasurement();
|
1295 |
|
1296 | if (!beginFiberMark(fiber, phase)) {
|
1297 | return;
|
1298 | }
|
1299 |
|
1300 | currentPhaseFiber = fiber;
|
1301 | currentPhase = phase;
|
1302 | }
|
1303 | }
|
1304 | function stopPhaseTimer() {
|
1305 | {
|
1306 | if (!supportsUserTiming) {
|
1307 | return;
|
1308 | }
|
1309 |
|
1310 | if (currentPhase !== null && currentPhaseFiber !== null) {
|
1311 | var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
|
1312 | endFiberMark(currentPhaseFiber, currentPhase, warning);
|
1313 | }
|
1314 |
|
1315 | currentPhase = null;
|
1316 | currentPhaseFiber = null;
|
1317 | }
|
1318 | }
|
1319 | function startWorkLoopTimer(nextUnitOfWork) {
|
1320 | {
|
1321 | currentFiber = nextUnitOfWork;
|
1322 |
|
1323 | if (!supportsUserTiming) {
|
1324 | return;
|
1325 | }
|
1326 |
|
1327 | commitCountInCurrentWorkLoop = 0;
|
1328 |
|
1329 |
|
1330 | beginMark('(React Tree Reconciliation)');
|
1331 |
|
1332 | resumeTimers();
|
1333 | }
|
1334 | }
|
1335 | function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
|
1336 | {
|
1337 | if (!supportsUserTiming) {
|
1338 | return;
|
1339 | }
|
1340 |
|
1341 | var warning = null;
|
1342 |
|
1343 | if (interruptedBy !== null) {
|
1344 | if (interruptedBy.tag === HostRoot) {
|
1345 | warning = 'A top-level update interrupted the previous render';
|
1346 | } else {
|
1347 | var componentName = getComponentName(interruptedBy.type) || 'Unknown';
|
1348 | warning = "An update to " + componentName + " interrupted the previous render";
|
1349 | }
|
1350 | } else if (commitCountInCurrentWorkLoop > 1) {
|
1351 | warning = 'There were cascading updates';
|
1352 | }
|
1353 |
|
1354 | commitCountInCurrentWorkLoop = 0;
|
1355 | var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
|
1356 |
|
1357 | pauseTimers();
|
1358 | endMark(label, '(React Tree Reconciliation)', warning);
|
1359 | }
|
1360 | }
|
1361 | function startCommitTimer() {
|
1362 | {
|
1363 | if (!supportsUserTiming) {
|
1364 | return;
|
1365 | }
|
1366 |
|
1367 | isCommitting = true;
|
1368 | hasScheduledUpdateInCurrentCommit = false;
|
1369 | labelsInCurrentCommit.clear();
|
1370 | beginMark('(Committing Changes)');
|
1371 | }
|
1372 | }
|
1373 | function stopCommitTimer() {
|
1374 | {
|
1375 | if (!supportsUserTiming) {
|
1376 | return;
|
1377 | }
|
1378 |
|
1379 | var warning = null;
|
1380 |
|
1381 | if (hasScheduledUpdateInCurrentCommit) {
|
1382 | warning = 'Lifecycle hook scheduled a cascading update';
|
1383 | } else if (commitCountInCurrentWorkLoop > 0) {
|
1384 | warning = 'Caused by a cascading update in earlier commit';
|
1385 | }
|
1386 |
|
1387 | hasScheduledUpdateInCurrentCommit = false;
|
1388 | commitCountInCurrentWorkLoop++;
|
1389 | isCommitting = false;
|
1390 | labelsInCurrentCommit.clear();
|
1391 | endMark('(Committing Changes)', '(Committing Changes)', warning);
|
1392 | }
|
1393 | }
|
1394 | function startCommitSnapshotEffectsTimer() {
|
1395 | {
|
1396 | if (!supportsUserTiming) {
|
1397 | return;
|
1398 | }
|
1399 |
|
1400 | effectCountInCurrentCommit = 0;
|
1401 | beginMark('(Committing Snapshot Effects)');
|
1402 | }
|
1403 | }
|
1404 | function stopCommitSnapshotEffectsTimer() {
|
1405 | {
|
1406 | if (!supportsUserTiming) {
|
1407 | return;
|
1408 | }
|
1409 |
|
1410 | var count = effectCountInCurrentCommit;
|
1411 | effectCountInCurrentCommit = 0;
|
1412 | endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null);
|
1413 | }
|
1414 | }
|
1415 | function startCommitHostEffectsTimer() {
|
1416 | {
|
1417 | if (!supportsUserTiming) {
|
1418 | return;
|
1419 | }
|
1420 |
|
1421 | effectCountInCurrentCommit = 0;
|
1422 | beginMark('(Committing Host Effects)');
|
1423 | }
|
1424 | }
|
1425 | function stopCommitHostEffectsTimer() {
|
1426 | {
|
1427 | if (!supportsUserTiming) {
|
1428 | return;
|
1429 | }
|
1430 |
|
1431 | var count = effectCountInCurrentCommit;
|
1432 | effectCountInCurrentCommit = 0;
|
1433 | endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null);
|
1434 | }
|
1435 | }
|
1436 | function startCommitLifeCyclesTimer() {
|
1437 | {
|
1438 | if (!supportsUserTiming) {
|
1439 | return;
|
1440 | }
|
1441 |
|
1442 | effectCountInCurrentCommit = 0;
|
1443 | beginMark('(Calling Lifecycle Methods)');
|
1444 | }
|
1445 | }
|
1446 | function stopCommitLifeCyclesTimer() {
|
1447 | {
|
1448 | if (!supportsUserTiming) {
|
1449 | return;
|
1450 | }
|
1451 |
|
1452 | var count = effectCountInCurrentCommit;
|
1453 | effectCountInCurrentCommit = 0;
|
1454 | endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null);
|
1455 | }
|
1456 | }
|
1457 |
|
1458 | var valueStack = [];
|
1459 | var fiberStack;
|
1460 |
|
1461 | {
|
1462 | fiberStack = [];
|
1463 | }
|
1464 |
|
1465 | var index = -1;
|
1466 |
|
1467 | function createCursor(defaultValue) {
|
1468 | return {
|
1469 | current: defaultValue
|
1470 | };
|
1471 | }
|
1472 |
|
1473 | function pop(cursor, fiber) {
|
1474 | if (index < 0) {
|
1475 | {
|
1476 | error('Unexpected pop.');
|
1477 | }
|
1478 |
|
1479 | return;
|
1480 | }
|
1481 |
|
1482 | {
|
1483 | if (fiber !== fiberStack[index]) {
|
1484 | error('Unexpected Fiber popped.');
|
1485 | }
|
1486 | }
|
1487 |
|
1488 | cursor.current = valueStack[index];
|
1489 | valueStack[index] = null;
|
1490 |
|
1491 | {
|
1492 | fiberStack[index] = null;
|
1493 | }
|
1494 |
|
1495 | index--;
|
1496 | }
|
1497 |
|
1498 | function push(cursor, value, fiber) {
|
1499 | index++;
|
1500 | valueStack[index] = cursor.current;
|
1501 |
|
1502 | {
|
1503 | fiberStack[index] = fiber;
|
1504 | }
|
1505 |
|
1506 | cursor.current = value;
|
1507 | }
|
1508 |
|
1509 | var warnedAboutMissingGetChildContext;
|
1510 |
|
1511 | {
|
1512 | warnedAboutMissingGetChildContext = {};
|
1513 | }
|
1514 |
|
1515 | var emptyContextObject = {};
|
1516 |
|
1517 | {
|
1518 | Object.freeze(emptyContextObject);
|
1519 | }
|
1520 |
|
1521 |
|
1522 | var contextStackCursor = createCursor(emptyContextObject);
|
1523 |
|
1524 | var didPerformWorkStackCursor = createCursor(false);
|
1525 |
|
1526 |
|
1527 |
|
1528 | var previousContext = emptyContextObject;
|
1529 |
|
1530 | function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
|
1531 | {
|
1532 | if (didPushOwnContextIfProvider && isContextProvider(Component)) {
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 | return previousContext;
|
1538 | }
|
1539 |
|
1540 | return contextStackCursor.current;
|
1541 | }
|
1542 | }
|
1543 |
|
1544 | function cacheContext(workInProgress, unmaskedContext, maskedContext) {
|
1545 | {
|
1546 | var instance = workInProgress.stateNode;
|
1547 | instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
1548 | instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
1549 | }
|
1550 | }
|
1551 |
|
1552 | function getMaskedContext(workInProgress, unmaskedContext) {
|
1553 | {
|
1554 | var type = workInProgress.type;
|
1555 | var contextTypes = type.contextTypes;
|
1556 |
|
1557 | if (!contextTypes) {
|
1558 | return emptyContextObject;
|
1559 | }
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 | var instance = workInProgress.stateNode;
|
1565 |
|
1566 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
|
1567 | return instance.__reactInternalMemoizedMaskedChildContext;
|
1568 | }
|
1569 |
|
1570 | var context = {};
|
1571 |
|
1572 | for (var key in contextTypes) {
|
1573 | context[key] = unmaskedContext[key];
|
1574 | }
|
1575 |
|
1576 | {
|
1577 | var name = getComponentName(type) || 'Unknown';
|
1578 | checkPropTypes_1(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
|
1579 | }
|
1580 |
|
1581 |
|
1582 |
|
1583 | if (instance) {
|
1584 | cacheContext(workInProgress, unmaskedContext, context);
|
1585 | }
|
1586 |
|
1587 | return context;
|
1588 | }
|
1589 | }
|
1590 |
|
1591 | function hasContextChanged() {
|
1592 | {
|
1593 | return didPerformWorkStackCursor.current;
|
1594 | }
|
1595 | }
|
1596 |
|
1597 | function isContextProvider(type) {
|
1598 | {
|
1599 | var childContextTypes = type.childContextTypes;
|
1600 | return childContextTypes !== null && childContextTypes !== undefined;
|
1601 | }
|
1602 | }
|
1603 |
|
1604 | function popContext(fiber) {
|
1605 | {
|
1606 | pop(didPerformWorkStackCursor, fiber);
|
1607 | pop(contextStackCursor, fiber);
|
1608 | }
|
1609 | }
|
1610 |
|
1611 | function popTopLevelContextObject(fiber) {
|
1612 | {
|
1613 | pop(didPerformWorkStackCursor, fiber);
|
1614 | pop(contextStackCursor, fiber);
|
1615 | }
|
1616 | }
|
1617 |
|
1618 | function pushTopLevelContextObject(fiber, context, didChange) {
|
1619 | {
|
1620 | if (!(contextStackCursor.current === emptyContextObject)) {
|
1621 | {
|
1622 | throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." );
|
1623 | }
|
1624 | }
|
1625 |
|
1626 | push(contextStackCursor, context, fiber);
|
1627 | push(didPerformWorkStackCursor, didChange, fiber);
|
1628 | }
|
1629 | }
|
1630 |
|
1631 | function processChildContext(fiber, type, parentContext) {
|
1632 | {
|
1633 | var instance = fiber.stateNode;
|
1634 | var childContextTypes = type.childContextTypes;
|
1635 |
|
1636 |
|
1637 | if (typeof instance.getChildContext !== 'function') {
|
1638 | {
|
1639 | var componentName = getComponentName(type) || 'Unknown';
|
1640 |
|
1641 | if (!warnedAboutMissingGetChildContext[componentName]) {
|
1642 | warnedAboutMissingGetChildContext[componentName] = true;
|
1643 |
|
1644 | error('%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);
|
1645 | }
|
1646 | }
|
1647 |
|
1648 | return parentContext;
|
1649 | }
|
1650 |
|
1651 | var childContext;
|
1652 | startPhaseTimer(fiber, 'getChildContext');
|
1653 | childContext = instance.getChildContext();
|
1654 | stopPhaseTimer();
|
1655 |
|
1656 | for (var contextKey in childContext) {
|
1657 | if (!(contextKey in childContextTypes)) {
|
1658 | {
|
1659 | throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." );
|
1660 | }
|
1661 | }
|
1662 | }
|
1663 |
|
1664 | {
|
1665 | var name = getComponentName(type) || 'Unknown';
|
1666 | checkPropTypes_1(childContextTypes, childContext, 'child context', name,
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 | getCurrentFiberStackInDev);
|
1672 | }
|
1673 |
|
1674 | return _assign({}, parentContext, {}, childContext);
|
1675 | }
|
1676 | }
|
1677 |
|
1678 | function pushContextProvider(workInProgress) {
|
1679 | {
|
1680 | var instance = workInProgress.stateNode;
|
1681 |
|
1682 |
|
1683 |
|
1684 | var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
|
1685 |
|
1686 |
|
1687 | previousContext = contextStackCursor.current;
|
1688 | push(contextStackCursor, memoizedMergedChildContext, workInProgress);
|
1689 | push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
|
1690 | return true;
|
1691 | }
|
1692 | }
|
1693 |
|
1694 | function invalidateContextProvider(workInProgress, type, didChange) {
|
1695 | {
|
1696 | var instance = workInProgress.stateNode;
|
1697 |
|
1698 | if (!instance) {
|
1699 | {
|
1700 | throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." );
|
1701 | }
|
1702 | }
|
1703 |
|
1704 | if (didChange) {
|
1705 |
|
1706 |
|
1707 |
|
1708 | var mergedContext = processChildContext(workInProgress, type, previousContext);
|
1709 | instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
1710 |
|
1711 |
|
1712 | pop(didPerformWorkStackCursor, workInProgress);
|
1713 | pop(contextStackCursor, workInProgress);
|
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 |
|
1724 | function findCurrentUnmaskedContext(fiber) {
|
1725 | {
|
1726 |
|
1727 |
|
1728 | if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
|
1729 | {
|
1730 | throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." );
|
1731 | }
|
1732 | }
|
1733 |
|
1734 | var node = fiber;
|
1735 |
|
1736 | do {
|
1737 | switch (node.tag) {
|
1738 | case HostRoot:
|
1739 | return node.stateNode.context;
|
1740 |
|
1741 | case ClassComponent:
|
1742 | {
|
1743 | var Component = node.type;
|
1744 |
|
1745 | if (isContextProvider(Component)) {
|
1746 | return node.stateNode.__reactInternalMemoizedMergedChildContext;
|
1747 | }
|
1748 |
|
1749 | break;
|
1750 | }
|
1751 | }
|
1752 |
|
1753 | node = node.return;
|
1754 | } while (node !== null);
|
1755 |
|
1756 | {
|
1757 | {
|
1758 | throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." );
|
1759 | }
|
1760 | }
|
1761 | }
|
1762 | }
|
1763 |
|
1764 | var LegacyRoot = 0;
|
1765 | var BlockingRoot = 1;
|
1766 | var ConcurrentRoot = 2;
|
1767 |
|
1768 | var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
1769 | var _ReactInternals$Sched = ReactInternals$1.SchedulerTracing,
|
1770 | __interactionsRef = _ReactInternals$Sched.__interactionsRef,
|
1771 | __subscriberRef = _ReactInternals$Sched.__subscriberRef,
|
1772 | unstable_clear = _ReactInternals$Sched.unstable_clear,
|
1773 | unstable_getCurrent = _ReactInternals$Sched.unstable_getCurrent,
|
1774 | unstable_getThreadID = _ReactInternals$Sched.unstable_getThreadID,
|
1775 | unstable_subscribe = _ReactInternals$Sched.unstable_subscribe,
|
1776 | unstable_trace = _ReactInternals$Sched.unstable_trace,
|
1777 | unstable_unsubscribe = _ReactInternals$Sched.unstable_unsubscribe,
|
1778 | unstable_wrap = _ReactInternals$Sched.unstable_wrap;
|
1779 |
|
1780 | var Scheduler_runWithPriority = Scheduler$1.unstable_runWithPriority,
|
1781 | Scheduler_scheduleCallback = Scheduler$1.unstable_scheduleCallback,
|
1782 | Scheduler_cancelCallback = Scheduler$1.unstable_cancelCallback,
|
1783 | Scheduler_shouldYield = Scheduler$1.unstable_shouldYield,
|
1784 | Scheduler_requestPaint = Scheduler$1.unstable_requestPaint,
|
1785 | Scheduler_now = Scheduler$1.unstable_now,
|
1786 | Scheduler_getCurrentPriorityLevel = Scheduler$1.unstable_getCurrentPriorityLevel,
|
1787 | Scheduler_ImmediatePriority = Scheduler$1.unstable_ImmediatePriority,
|
1788 | Scheduler_UserBlockingPriority = Scheduler$1.unstable_UserBlockingPriority,
|
1789 | Scheduler_NormalPriority = Scheduler$1.unstable_NormalPriority,
|
1790 | Scheduler_LowPriority = Scheduler$1.unstable_LowPriority,
|
1791 | Scheduler_IdlePriority = Scheduler$1.unstable_IdlePriority;
|
1792 |
|
1793 | {
|
1794 |
|
1795 |
|
1796 |
|
1797 | if (!(__interactionsRef != null && __interactionsRef.current != null)) {
|
1798 | {
|
1799 | throw 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" );
|
1800 | }
|
1801 | }
|
1802 | }
|
1803 |
|
1804 | var fakeCallbackNode = {};
|
1805 |
|
1806 |
|
1807 |
|
1808 | var ImmediatePriority = 99;
|
1809 | var UserBlockingPriority = 98;
|
1810 | var NormalPriority = 97;
|
1811 | var LowPriority = 96;
|
1812 | var IdlePriority = 95;
|
1813 |
|
1814 | var NoPriority = 90;
|
1815 | var shouldYield = Scheduler_shouldYield;
|
1816 | var requestPaint =
|
1817 | Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
|
1818 | var syncQueue = null;
|
1819 | var immediateQueueCallbackNode = null;
|
1820 | var isFlushingSyncQueue = false;
|
1821 | var initialTimeMs = Scheduler_now();
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 | var now = initialTimeMs < 10000 ? Scheduler_now : function () {
|
1830 | return Scheduler_now() - initialTimeMs;
|
1831 | };
|
1832 | function getCurrentPriorityLevel() {
|
1833 | switch (Scheduler_getCurrentPriorityLevel()) {
|
1834 | case Scheduler_ImmediatePriority:
|
1835 | return ImmediatePriority;
|
1836 |
|
1837 | case Scheduler_UserBlockingPriority:
|
1838 | return UserBlockingPriority;
|
1839 |
|
1840 | case Scheduler_NormalPriority:
|
1841 | return NormalPriority;
|
1842 |
|
1843 | case Scheduler_LowPriority:
|
1844 | return LowPriority;
|
1845 |
|
1846 | case Scheduler_IdlePriority:
|
1847 | return IdlePriority;
|
1848 |
|
1849 | default:
|
1850 | {
|
1851 | {
|
1852 | throw Error( "Unknown priority level." );
|
1853 | }
|
1854 | }
|
1855 |
|
1856 | }
|
1857 | }
|
1858 |
|
1859 | function reactPriorityToSchedulerPriority(reactPriorityLevel) {
|
1860 | switch (reactPriorityLevel) {
|
1861 | case ImmediatePriority:
|
1862 | return Scheduler_ImmediatePriority;
|
1863 |
|
1864 | case UserBlockingPriority:
|
1865 | return Scheduler_UserBlockingPriority;
|
1866 |
|
1867 | case NormalPriority:
|
1868 | return Scheduler_NormalPriority;
|
1869 |
|
1870 | case LowPriority:
|
1871 | return Scheduler_LowPriority;
|
1872 |
|
1873 | case IdlePriority:
|
1874 | return Scheduler_IdlePriority;
|
1875 |
|
1876 | default:
|
1877 | {
|
1878 | {
|
1879 | throw Error( "Unknown priority level." );
|
1880 | }
|
1881 | }
|
1882 |
|
1883 | }
|
1884 | }
|
1885 |
|
1886 | function runWithPriority(reactPriorityLevel, fn) {
|
1887 | var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
|
1888 | return Scheduler_runWithPriority(priorityLevel, fn);
|
1889 | }
|
1890 | function scheduleCallback(reactPriorityLevel, callback, options) {
|
1891 | var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
|
1892 | return Scheduler_scheduleCallback(priorityLevel, callback, options);
|
1893 | }
|
1894 | function scheduleSyncCallback(callback) {
|
1895 |
|
1896 |
|
1897 | if (syncQueue === null) {
|
1898 | syncQueue = [callback];
|
1899 |
|
1900 | immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
|
1901 | } else {
|
1902 |
|
1903 |
|
1904 | syncQueue.push(callback);
|
1905 | }
|
1906 |
|
1907 | return fakeCallbackNode;
|
1908 | }
|
1909 | function cancelCallback(callbackNode) {
|
1910 | if (callbackNode !== fakeCallbackNode) {
|
1911 | Scheduler_cancelCallback(callbackNode);
|
1912 | }
|
1913 | }
|
1914 | function flushSyncCallbackQueue() {
|
1915 | if (immediateQueueCallbackNode !== null) {
|
1916 | var node = immediateQueueCallbackNode;
|
1917 | immediateQueueCallbackNode = null;
|
1918 | Scheduler_cancelCallback(node);
|
1919 | }
|
1920 |
|
1921 | flushSyncCallbackQueueImpl();
|
1922 | }
|
1923 |
|
1924 | function flushSyncCallbackQueueImpl() {
|
1925 | if (!isFlushingSyncQueue && syncQueue !== null) {
|
1926 |
|
1927 | isFlushingSyncQueue = true;
|
1928 | var i = 0;
|
1929 |
|
1930 | try {
|
1931 | var _isSync = true;
|
1932 | var queue = syncQueue;
|
1933 | runWithPriority(ImmediatePriority, function () {
|
1934 | for (; i < queue.length; i++) {
|
1935 | var callback = queue[i];
|
1936 |
|
1937 | do {
|
1938 | callback = callback(_isSync);
|
1939 | } while (callback !== null);
|
1940 | }
|
1941 | });
|
1942 | syncQueue = null;
|
1943 | } catch (error) {
|
1944 |
|
1945 | if (syncQueue !== null) {
|
1946 | syncQueue = syncQueue.slice(i + 1);
|
1947 | }
|
1948 |
|
1949 |
|
1950 | Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
|
1951 | throw error;
|
1952 | } finally {
|
1953 | isFlushingSyncQueue = false;
|
1954 | }
|
1955 | }
|
1956 | }
|
1957 |
|
1958 | var NoMode = 0;
|
1959 | var StrictMode = 1;
|
1960 |
|
1961 |
|
1962 | var BlockingMode = 2;
|
1963 | var ConcurrentMode = 4;
|
1964 | var ProfileMode = 8;
|
1965 |
|
1966 |
|
1967 |
|
1968 |
|
1969 | var MAX_SIGNED_31_BIT_INT = 1073741823;
|
1970 |
|
1971 | var NoWork = 0;
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 |
|
1979 | var Never = 1;
|
1980 |
|
1981 |
|
1982 | var Idle = 2;
|
1983 | var Sync = MAX_SIGNED_31_BIT_INT;
|
1984 | var Batched = Sync - 1;
|
1985 | var UNIT_SIZE = 10;
|
1986 | var MAGIC_NUMBER_OFFSET = Batched - 1;
|
1987 |
|
1988 | function msToExpirationTime(ms) {
|
1989 |
|
1990 | return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
|
1991 | }
|
1992 | function expirationTimeToMs(expirationTime) {
|
1993 | return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
|
1994 | }
|
1995 |
|
1996 | function ceiling(num, precision) {
|
1997 | return ((num / precision | 0) + 1) * precision;
|
1998 | }
|
1999 |
|
2000 | function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
|
2001 | return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
|
2002 | }
|
2003 |
|
2004 |
|
2005 |
|
2006 | var LOW_PRIORITY_EXPIRATION = 5000;
|
2007 | var LOW_PRIORITY_BATCH_SIZE = 250;
|
2008 | function computeAsyncExpiration(currentTime) {
|
2009 | return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
|
2010 | }
|
2011 | function computeSuspenseExpiration(currentTime, timeoutMs) {
|
2012 |
|
2013 | return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
|
2014 | }
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 | var HIGH_PRIORITY_EXPIRATION = 500 ;
|
2027 | var HIGH_PRIORITY_BATCH_SIZE = 100;
|
2028 | function computeInteractiveExpiration(currentTime) {
|
2029 | return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
|
2030 | }
|
2031 | function inferPriorityFromExpirationTime(currentTime, expirationTime) {
|
2032 | if (expirationTime === Sync) {
|
2033 | return ImmediatePriority;
|
2034 | }
|
2035 |
|
2036 | if (expirationTime === Never || expirationTime === Idle) {
|
2037 | return IdlePriority;
|
2038 | }
|
2039 |
|
2040 | var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
|
2041 |
|
2042 | if (msUntil <= 0) {
|
2043 | return ImmediatePriority;
|
2044 | }
|
2045 |
|
2046 | if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
|
2047 | return UserBlockingPriority;
|
2048 | }
|
2049 |
|
2050 | if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
|
2051 | return NormalPriority;
|
2052 | }
|
2053 |
|
2054 |
|
2055 |
|
2056 | return IdlePriority;
|
2057 | }
|
2058 |
|
2059 | |
2060 |
|
2061 |
|
2062 |
|
2063 | function is(x, y) {
|
2064 | return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y
|
2065 | ;
|
2066 | }
|
2067 |
|
2068 | var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
2069 |
|
2070 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
2071 | |
2072 |
|
2073 |
|
2074 |
|
2075 |
|
2076 |
|
2077 | function shallowEqual(objA, objB) {
|
2078 | if (objectIs(objA, objB)) {
|
2079 | return true;
|
2080 | }
|
2081 |
|
2082 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
2083 | return false;
|
2084 | }
|
2085 |
|
2086 | var keysA = Object.keys(objA);
|
2087 | var keysB = Object.keys(objB);
|
2088 |
|
2089 | if (keysA.length !== keysB.length) {
|
2090 | return false;
|
2091 | }
|
2092 |
|
2093 |
|
2094 | for (var i = 0; i < keysA.length; i++) {
|
2095 | if (!hasOwnProperty.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) {
|
2096 | return false;
|
2097 | }
|
2098 | }
|
2099 |
|
2100 | return true;
|
2101 | }
|
2102 |
|
2103 | var ReactStrictModeWarnings = {
|
2104 | recordUnsafeLifecycleWarnings: function (fiber, instance) {},
|
2105 | flushPendingUnsafeLifecycleWarnings: function () {},
|
2106 | recordLegacyContextWarning: function (fiber, instance) {},
|
2107 | flushLegacyContextWarning: function () {},
|
2108 | discardPendingWarnings: function () {}
|
2109 | };
|
2110 |
|
2111 | {
|
2112 | var findStrictRoot = function (fiber) {
|
2113 | var maybeStrictRoot = null;
|
2114 | var node = fiber;
|
2115 |
|
2116 | while (node !== null) {
|
2117 | if (node.mode & StrictMode) {
|
2118 | maybeStrictRoot = node;
|
2119 | }
|
2120 |
|
2121 | node = node.return;
|
2122 | }
|
2123 |
|
2124 | return maybeStrictRoot;
|
2125 | };
|
2126 |
|
2127 | var setToSortedString = function (set) {
|
2128 | var array = [];
|
2129 | set.forEach(function (value) {
|
2130 | array.push(value);
|
2131 | });
|
2132 | return array.sort().join(', ');
|
2133 | };
|
2134 |
|
2135 | var pendingComponentWillMountWarnings = [];
|
2136 | var pendingUNSAFE_ComponentWillMountWarnings = [];
|
2137 | var pendingComponentWillReceivePropsWarnings = [];
|
2138 | var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
2139 | var pendingComponentWillUpdateWarnings = [];
|
2140 | var pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
2141 |
|
2142 | var didWarnAboutUnsafeLifecycles = new Set();
|
2143 |
|
2144 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
|
2145 |
|
2146 | if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
|
2147 | return;
|
2148 | }
|
2149 |
|
2150 | if (typeof instance.componentWillMount === 'function' &&
|
2151 | instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
2152 | pendingComponentWillMountWarnings.push(fiber);
|
2153 | }
|
2154 |
|
2155 | if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
|
2156 | pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
|
2157 | }
|
2158 |
|
2159 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
2160 | pendingComponentWillReceivePropsWarnings.push(fiber);
|
2161 | }
|
2162 |
|
2163 | if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
2164 | pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
|
2165 | }
|
2166 |
|
2167 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
2168 | pendingComponentWillUpdateWarnings.push(fiber);
|
2169 | }
|
2170 |
|
2171 | if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
2172 | pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
|
2173 | }
|
2174 | };
|
2175 |
|
2176 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
|
2177 |
|
2178 | var componentWillMountUniqueNames = new Set();
|
2179 |
|
2180 | if (pendingComponentWillMountWarnings.length > 0) {
|
2181 | pendingComponentWillMountWarnings.forEach(function (fiber) {
|
2182 | componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2183 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2184 | });
|
2185 | pendingComponentWillMountWarnings = [];
|
2186 | }
|
2187 |
|
2188 | var UNSAFE_componentWillMountUniqueNames = new Set();
|
2189 |
|
2190 | if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
|
2191 | pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
|
2192 | UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2193 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2194 | });
|
2195 | pendingUNSAFE_ComponentWillMountWarnings = [];
|
2196 | }
|
2197 |
|
2198 | var componentWillReceivePropsUniqueNames = new Set();
|
2199 |
|
2200 | if (pendingComponentWillReceivePropsWarnings.length > 0) {
|
2201 | pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
|
2202 | componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2203 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2204 | });
|
2205 | pendingComponentWillReceivePropsWarnings = [];
|
2206 | }
|
2207 |
|
2208 | var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
|
2209 |
|
2210 | if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
|
2211 | pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
|
2212 | UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2213 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2214 | });
|
2215 | pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
2216 | }
|
2217 |
|
2218 | var componentWillUpdateUniqueNames = new Set();
|
2219 |
|
2220 | if (pendingComponentWillUpdateWarnings.length > 0) {
|
2221 | pendingComponentWillUpdateWarnings.forEach(function (fiber) {
|
2222 | componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2223 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2224 | });
|
2225 | pendingComponentWillUpdateWarnings = [];
|
2226 | }
|
2227 |
|
2228 | var UNSAFE_componentWillUpdateUniqueNames = new Set();
|
2229 |
|
2230 | if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
|
2231 | pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
|
2232 | UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2233 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2234 | });
|
2235 | pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
2236 | }
|
2237 |
|
2238 |
|
2239 |
|
2240 | if (UNSAFE_componentWillMountUniqueNames.size > 0) {
|
2241 | var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
|
2242 |
|
2243 | error('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);
|
2244 | }
|
2245 |
|
2246 | if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
|
2247 | var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
|
2248 |
|
2249 | error('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);
|
2250 | }
|
2251 |
|
2252 | if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
|
2253 | var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
|
2254 |
|
2255 | error('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);
|
2256 | }
|
2257 |
|
2258 | if (componentWillMountUniqueNames.size > 0) {
|
2259 | var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
|
2260 |
|
2261 | warn('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);
|
2262 | }
|
2263 |
|
2264 | if (componentWillReceivePropsUniqueNames.size > 0) {
|
2265 | var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
|
2266 |
|
2267 | warn('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);
|
2268 | }
|
2269 |
|
2270 | if (componentWillUpdateUniqueNames.size > 0) {
|
2271 | var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
|
2272 |
|
2273 | warn('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);
|
2274 | }
|
2275 | };
|
2276 |
|
2277 | var pendingLegacyContextWarning = new Map();
|
2278 |
|
2279 | var didWarnAboutLegacyContext = new Set();
|
2280 |
|
2281 | ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
|
2282 | var strictRoot = findStrictRoot(fiber);
|
2283 |
|
2284 | if (strictRoot === null) {
|
2285 | error('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.');
|
2286 |
|
2287 | return;
|
2288 | }
|
2289 |
|
2290 |
|
2291 | if (didWarnAboutLegacyContext.has(fiber.type)) {
|
2292 | return;
|
2293 | }
|
2294 |
|
2295 | var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
|
2296 |
|
2297 | if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
|
2298 | if (warningsForRoot === undefined) {
|
2299 | warningsForRoot = [];
|
2300 | pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
|
2301 | }
|
2302 |
|
2303 | warningsForRoot.push(fiber);
|
2304 | }
|
2305 | };
|
2306 |
|
2307 | ReactStrictModeWarnings.flushLegacyContextWarning = function () {
|
2308 | pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
|
2309 | if (fiberArray.length === 0) {
|
2310 | return;
|
2311 | }
|
2312 |
|
2313 | var firstFiber = fiberArray[0];
|
2314 | var uniqueNames = new Set();
|
2315 | fiberArray.forEach(function (fiber) {
|
2316 | uniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2317 | didWarnAboutLegacyContext.add(fiber.type);
|
2318 | });
|
2319 | var sortedNames = setToSortedString(uniqueNames);
|
2320 | var firstComponentStack = getStackByFiberInDevAndProd(firstFiber);
|
2321 |
|
2322 | error('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, firstComponentStack);
|
2323 | });
|
2324 | };
|
2325 |
|
2326 | ReactStrictModeWarnings.discardPendingWarnings = function () {
|
2327 | pendingComponentWillMountWarnings = [];
|
2328 | pendingUNSAFE_ComponentWillMountWarnings = [];
|
2329 | pendingComponentWillReceivePropsWarnings = [];
|
2330 | pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
2331 | pendingComponentWillUpdateWarnings = [];
|
2332 | pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
2333 | pendingLegacyContextWarning = new Map();
|
2334 | };
|
2335 | }
|
2336 |
|
2337 | var resolveFamily = null;
|
2338 |
|
2339 | var failedBoundaries = null;
|
2340 | var setRefreshHandler = function (handler) {
|
2341 | {
|
2342 | resolveFamily = handler;
|
2343 | }
|
2344 | };
|
2345 | function resolveFunctionForHotReloading(type) {
|
2346 | {
|
2347 | if (resolveFamily === null) {
|
2348 |
|
2349 | return type;
|
2350 | }
|
2351 |
|
2352 | var family = resolveFamily(type);
|
2353 |
|
2354 | if (family === undefined) {
|
2355 | return type;
|
2356 | }
|
2357 |
|
2358 |
|
2359 | return family.current;
|
2360 | }
|
2361 | }
|
2362 | function resolveClassForHotReloading(type) {
|
2363 |
|
2364 | return resolveFunctionForHotReloading(type);
|
2365 | }
|
2366 | function resolveForwardRefForHotReloading(type) {
|
2367 | {
|
2368 | if (resolveFamily === null) {
|
2369 |
|
2370 | return type;
|
2371 | }
|
2372 |
|
2373 | var family = resolveFamily(type);
|
2374 |
|
2375 | if (family === undefined) {
|
2376 |
|
2377 | if (type !== null && type !== undefined && typeof type.render === 'function') {
|
2378 |
|
2379 |
|
2380 |
|
2381 | var currentRender = resolveFunctionForHotReloading(type.render);
|
2382 |
|
2383 | if (type.render !== currentRender) {
|
2384 | var syntheticType = {
|
2385 | $$typeof: REACT_FORWARD_REF_TYPE,
|
2386 | render: currentRender
|
2387 | };
|
2388 |
|
2389 | if (type.displayName !== undefined) {
|
2390 | syntheticType.displayName = type.displayName;
|
2391 | }
|
2392 |
|
2393 | return syntheticType;
|
2394 | }
|
2395 | }
|
2396 |
|
2397 | return type;
|
2398 | }
|
2399 |
|
2400 |
|
2401 | return family.current;
|
2402 | }
|
2403 | }
|
2404 | function isCompatibleFamilyForHotReloading(fiber, element) {
|
2405 | {
|
2406 | if (resolveFamily === null) {
|
2407 |
|
2408 | return false;
|
2409 | }
|
2410 |
|
2411 | var prevType = fiber.elementType;
|
2412 | var nextType = element.type;
|
2413 |
|
2414 | var needsCompareFamilies = false;
|
2415 | var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
|
2416 |
|
2417 | switch (fiber.tag) {
|
2418 | case ClassComponent:
|
2419 | {
|
2420 | if (typeof nextType === 'function') {
|
2421 | needsCompareFamilies = true;
|
2422 | }
|
2423 |
|
2424 | break;
|
2425 | }
|
2426 |
|
2427 | case FunctionComponent:
|
2428 | {
|
2429 | if (typeof nextType === 'function') {
|
2430 | needsCompareFamilies = true;
|
2431 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
2432 |
|
2433 |
|
2434 |
|
2435 |
|
2436 | needsCompareFamilies = true;
|
2437 | }
|
2438 |
|
2439 | break;
|
2440 | }
|
2441 |
|
2442 | case ForwardRef:
|
2443 | {
|
2444 | if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
|
2445 | needsCompareFamilies = true;
|
2446 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
2447 | needsCompareFamilies = true;
|
2448 | }
|
2449 |
|
2450 | break;
|
2451 | }
|
2452 |
|
2453 | case MemoComponent:
|
2454 | case SimpleMemoComponent:
|
2455 | {
|
2456 | if ($$typeofNextType === REACT_MEMO_TYPE) {
|
2457 |
|
2458 |
|
2459 | needsCompareFamilies = true;
|
2460 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
2461 | needsCompareFamilies = true;
|
2462 | }
|
2463 |
|
2464 | break;
|
2465 | }
|
2466 |
|
2467 | default:
|
2468 | return false;
|
2469 | }
|
2470 |
|
2471 |
|
2472 | if (needsCompareFamilies) {
|
2473 |
|
2474 |
|
2475 |
|
2476 |
|
2477 |
|
2478 | var prevFamily = resolveFamily(prevType);
|
2479 |
|
2480 | if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
|
2481 | return true;
|
2482 | }
|
2483 | }
|
2484 |
|
2485 | return false;
|
2486 | }
|
2487 | }
|
2488 | function markFailedErrorBoundaryForHotReloading(fiber) {
|
2489 | {
|
2490 | if (resolveFamily === null) {
|
2491 |
|
2492 | return;
|
2493 | }
|
2494 |
|
2495 | if (typeof WeakSet !== 'function') {
|
2496 | return;
|
2497 | }
|
2498 |
|
2499 | if (failedBoundaries === null) {
|
2500 | failedBoundaries = new WeakSet();
|
2501 | }
|
2502 |
|
2503 | failedBoundaries.add(fiber);
|
2504 | }
|
2505 | }
|
2506 | var scheduleRefresh = function (root, update) {
|
2507 | {
|
2508 | if (resolveFamily === null) {
|
2509 |
|
2510 | return;
|
2511 | }
|
2512 |
|
2513 | var staleFamilies = update.staleFamilies,
|
2514 | updatedFamilies = update.updatedFamilies;
|
2515 | flushPassiveEffects();
|
2516 | flushSync(function () {
|
2517 | scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
|
2518 | });
|
2519 | }
|
2520 | };
|
2521 | var scheduleRoot = function (root, element) {
|
2522 | {
|
2523 | if (root.context !== emptyContextObject) {
|
2524 |
|
2525 |
|
2526 |
|
2527 | return;
|
2528 | }
|
2529 |
|
2530 | flushPassiveEffects();
|
2531 | syncUpdates(function () {
|
2532 | updateContainer(element, root, null, null);
|
2533 | });
|
2534 | }
|
2535 | };
|
2536 |
|
2537 | function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
|
2538 | {
|
2539 | var alternate = fiber.alternate,
|
2540 | child = fiber.child,
|
2541 | sibling = fiber.sibling,
|
2542 | tag = fiber.tag,
|
2543 | type = fiber.type;
|
2544 | var candidateType = null;
|
2545 |
|
2546 | switch (tag) {
|
2547 | case FunctionComponent:
|
2548 | case SimpleMemoComponent:
|
2549 | case ClassComponent:
|
2550 | candidateType = type;
|
2551 | break;
|
2552 |
|
2553 | case ForwardRef:
|
2554 | candidateType = type.render;
|
2555 | break;
|
2556 | }
|
2557 |
|
2558 | if (resolveFamily === null) {
|
2559 | throw new Error('Expected resolveFamily to be set during hot reload.');
|
2560 | }
|
2561 |
|
2562 | var needsRender = false;
|
2563 | var needsRemount = false;
|
2564 |
|
2565 | if (candidateType !== null) {
|
2566 | var family = resolveFamily(candidateType);
|
2567 |
|
2568 | if (family !== undefined) {
|
2569 | if (staleFamilies.has(family)) {
|
2570 | needsRemount = true;
|
2571 | } else if (updatedFamilies.has(family)) {
|
2572 | if (tag === ClassComponent) {
|
2573 | needsRemount = true;
|
2574 | } else {
|
2575 | needsRender = true;
|
2576 | }
|
2577 | }
|
2578 | }
|
2579 | }
|
2580 |
|
2581 | if (failedBoundaries !== null) {
|
2582 | if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
|
2583 | needsRemount = true;
|
2584 | }
|
2585 | }
|
2586 |
|
2587 | if (needsRemount) {
|
2588 | fiber._debugNeedsRemount = true;
|
2589 | }
|
2590 |
|
2591 | if (needsRemount || needsRender) {
|
2592 | scheduleWork(fiber, Sync);
|
2593 | }
|
2594 |
|
2595 | if (child !== null && !needsRemount) {
|
2596 | scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
|
2597 | }
|
2598 |
|
2599 | if (sibling !== null) {
|
2600 | scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
|
2601 | }
|
2602 | }
|
2603 | }
|
2604 |
|
2605 | var findHostInstancesForRefresh = function (root, families) {
|
2606 | {
|
2607 | var hostInstances = new Set();
|
2608 | var types = new Set(families.map(function (family) {
|
2609 | return family.current;
|
2610 | }));
|
2611 | findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
|
2612 | return hostInstances;
|
2613 | }
|
2614 | };
|
2615 |
|
2616 | function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
|
2617 | {
|
2618 | var child = fiber.child,
|
2619 | sibling = fiber.sibling,
|
2620 | tag = fiber.tag,
|
2621 | type = fiber.type;
|
2622 | var candidateType = null;
|
2623 |
|
2624 | switch (tag) {
|
2625 | case FunctionComponent:
|
2626 | case SimpleMemoComponent:
|
2627 | case ClassComponent:
|
2628 | candidateType = type;
|
2629 | break;
|
2630 |
|
2631 | case ForwardRef:
|
2632 | candidateType = type.render;
|
2633 | break;
|
2634 | }
|
2635 |
|
2636 | var didMatch = false;
|
2637 |
|
2638 | if (candidateType !== null) {
|
2639 | if (types.has(candidateType)) {
|
2640 | didMatch = true;
|
2641 | }
|
2642 | }
|
2643 |
|
2644 | if (didMatch) {
|
2645 |
|
2646 |
|
2647 |
|
2648 | findHostInstancesForFiberShallowly(fiber, hostInstances);
|
2649 | } else {
|
2650 |
|
2651 | if (child !== null) {
|
2652 | findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
|
2653 | }
|
2654 | }
|
2655 |
|
2656 | if (sibling !== null) {
|
2657 | findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
|
2658 | }
|
2659 | }
|
2660 | }
|
2661 |
|
2662 | function findHostInstancesForFiberShallowly(fiber, hostInstances) {
|
2663 | {
|
2664 | var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
|
2665 |
|
2666 | if (foundHostInstances) {
|
2667 | return;
|
2668 | }
|
2669 |
|
2670 |
|
2671 | var node = fiber;
|
2672 |
|
2673 | while (true) {
|
2674 | switch (node.tag) {
|
2675 | case HostComponent:
|
2676 | hostInstances.add(node.stateNode);
|
2677 | return;
|
2678 |
|
2679 | case HostPortal:
|
2680 | hostInstances.add(node.stateNode.containerInfo);
|
2681 | return;
|
2682 |
|
2683 | case HostRoot:
|
2684 | hostInstances.add(node.stateNode.containerInfo);
|
2685 | return;
|
2686 | }
|
2687 |
|
2688 | if (node.return === null) {
|
2689 | throw new Error('Expected to reach root first.');
|
2690 | }
|
2691 |
|
2692 | node = node.return;
|
2693 | }
|
2694 | }
|
2695 | }
|
2696 |
|
2697 | function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
|
2698 | {
|
2699 | var node = fiber;
|
2700 | var foundHostInstances = false;
|
2701 |
|
2702 | while (true) {
|
2703 | if (node.tag === HostComponent) {
|
2704 |
|
2705 | foundHostInstances = true;
|
2706 | hostInstances.add(node.stateNode);
|
2707 | } else if (node.child !== null) {
|
2708 | node.child.return = node;
|
2709 | node = node.child;
|
2710 | continue;
|
2711 | }
|
2712 |
|
2713 | if (node === fiber) {
|
2714 | return foundHostInstances;
|
2715 | }
|
2716 |
|
2717 | while (node.sibling === null) {
|
2718 | if (node.return === null || node.return === fiber) {
|
2719 | return foundHostInstances;
|
2720 | }
|
2721 |
|
2722 | node = node.return;
|
2723 | }
|
2724 |
|
2725 | node.sibling.return = node.return;
|
2726 | node = node.sibling;
|
2727 | }
|
2728 | }
|
2729 |
|
2730 | return false;
|
2731 | }
|
2732 |
|
2733 | function resolveDefaultProps(Component, baseProps) {
|
2734 | if (Component && Component.defaultProps) {
|
2735 |
|
2736 | var props = _assign({}, baseProps);
|
2737 |
|
2738 | var defaultProps = Component.defaultProps;
|
2739 |
|
2740 | for (var propName in defaultProps) {
|
2741 | if (props[propName] === undefined) {
|
2742 | props[propName] = defaultProps[propName];
|
2743 | }
|
2744 | }
|
2745 |
|
2746 | return props;
|
2747 | }
|
2748 |
|
2749 | return baseProps;
|
2750 | }
|
2751 | function readLazyComponentType(lazyComponent) {
|
2752 | initializeLazyComponentType(lazyComponent);
|
2753 |
|
2754 | if (lazyComponent._status !== Resolved) {
|
2755 | throw lazyComponent._result;
|
2756 | }
|
2757 |
|
2758 | return lazyComponent._result;
|
2759 | }
|
2760 |
|
2761 | var valueCursor = createCursor(null);
|
2762 | var rendererSigil;
|
2763 |
|
2764 | {
|
2765 |
|
2766 | rendererSigil = {};
|
2767 | }
|
2768 |
|
2769 | var currentlyRenderingFiber = null;
|
2770 | var lastContextDependency = null;
|
2771 | var lastContextWithAllBitsObserved = null;
|
2772 | var isDisallowedContextReadInDEV = false;
|
2773 | function resetContextDependencies() {
|
2774 |
|
2775 |
|
2776 | currentlyRenderingFiber = null;
|
2777 | lastContextDependency = null;
|
2778 | lastContextWithAllBitsObserved = null;
|
2779 |
|
2780 | {
|
2781 | isDisallowedContextReadInDEV = false;
|
2782 | }
|
2783 | }
|
2784 | function enterDisallowedContextReadInDEV() {
|
2785 | {
|
2786 | isDisallowedContextReadInDEV = true;
|
2787 | }
|
2788 | }
|
2789 | function exitDisallowedContextReadInDEV() {
|
2790 | {
|
2791 | isDisallowedContextReadInDEV = false;
|
2792 | }
|
2793 | }
|
2794 | function pushProvider(providerFiber, nextValue) {
|
2795 | var context = providerFiber.type._context;
|
2796 |
|
2797 | {
|
2798 | push(valueCursor, context._currentValue2, providerFiber);
|
2799 | context._currentValue2 = nextValue;
|
2800 |
|
2801 | {
|
2802 | if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) {
|
2803 | error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
|
2804 | }
|
2805 |
|
2806 | context._currentRenderer2 = rendererSigil;
|
2807 | }
|
2808 | }
|
2809 | }
|
2810 | function popProvider(providerFiber) {
|
2811 | var currentValue = valueCursor.current;
|
2812 | pop(valueCursor, providerFiber);
|
2813 | var context = providerFiber.type._context;
|
2814 |
|
2815 | {
|
2816 | context._currentValue2 = currentValue;
|
2817 | }
|
2818 | }
|
2819 | function calculateChangedBits(context, newValue, oldValue) {
|
2820 | if (objectIs(oldValue, newValue)) {
|
2821 |
|
2822 | return 0;
|
2823 | } else {
|
2824 | var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
|
2825 |
|
2826 | {
|
2827 | if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) {
|
2828 | error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
|
2829 | }
|
2830 | }
|
2831 |
|
2832 | return changedBits | 0;
|
2833 | }
|
2834 | }
|
2835 | function scheduleWorkOnParentPath(parent, renderExpirationTime) {
|
2836 |
|
2837 |
|
2838 | var node = parent;
|
2839 |
|
2840 | while (node !== null) {
|
2841 | var alternate = node.alternate;
|
2842 |
|
2843 | if (node.childExpirationTime < renderExpirationTime) {
|
2844 | node.childExpirationTime = renderExpirationTime;
|
2845 |
|
2846 | if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
2847 | alternate.childExpirationTime = renderExpirationTime;
|
2848 | }
|
2849 | } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
2850 | alternate.childExpirationTime = renderExpirationTime;
|
2851 | } else {
|
2852 |
|
2853 |
|
2854 | break;
|
2855 | }
|
2856 |
|
2857 | node = node.return;
|
2858 | }
|
2859 | }
|
2860 | function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
|
2861 | var fiber = workInProgress.child;
|
2862 |
|
2863 | if (fiber !== null) {
|
2864 |
|
2865 | fiber.return = workInProgress;
|
2866 | }
|
2867 |
|
2868 | while (fiber !== null) {
|
2869 | var nextFiber = void 0;
|
2870 |
|
2871 | var list = fiber.dependencies;
|
2872 |
|
2873 | if (list !== null) {
|
2874 | nextFiber = fiber.child;
|
2875 | var dependency = list.firstContext;
|
2876 |
|
2877 | while (dependency !== null) {
|
2878 |
|
2879 | if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
|
2880 |
|
2881 | if (fiber.tag === ClassComponent) {
|
2882 |
|
2883 | var update = createUpdate(renderExpirationTime, null);
|
2884 | update.tag = ForceUpdate;
|
2885 |
|
2886 |
|
2887 |
|
2888 |
|
2889 | enqueueUpdate(fiber, update);
|
2890 | }
|
2891 |
|
2892 | if (fiber.expirationTime < renderExpirationTime) {
|
2893 | fiber.expirationTime = renderExpirationTime;
|
2894 | }
|
2895 |
|
2896 | var alternate = fiber.alternate;
|
2897 |
|
2898 | if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
|
2899 | alternate.expirationTime = renderExpirationTime;
|
2900 | }
|
2901 |
|
2902 | scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
|
2903 |
|
2904 | if (list.expirationTime < renderExpirationTime) {
|
2905 | list.expirationTime = renderExpirationTime;
|
2906 | }
|
2907 |
|
2908 |
|
2909 |
|
2910 | break;
|
2911 | }
|
2912 |
|
2913 | dependency = dependency.next;
|
2914 | }
|
2915 | } else if (fiber.tag === ContextProvider) {
|
2916 |
|
2917 | nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
|
2918 | } else {
|
2919 |
|
2920 | nextFiber = fiber.child;
|
2921 | }
|
2922 |
|
2923 | if (nextFiber !== null) {
|
2924 |
|
2925 | nextFiber.return = fiber;
|
2926 | } else {
|
2927 |
|
2928 | nextFiber = fiber;
|
2929 |
|
2930 | while (nextFiber !== null) {
|
2931 | if (nextFiber === workInProgress) {
|
2932 |
|
2933 | nextFiber = null;
|
2934 | break;
|
2935 | }
|
2936 |
|
2937 | var sibling = nextFiber.sibling;
|
2938 |
|
2939 | if (sibling !== null) {
|
2940 |
|
2941 | sibling.return = nextFiber.return;
|
2942 | nextFiber = sibling;
|
2943 | break;
|
2944 | }
|
2945 |
|
2946 |
|
2947 | nextFiber = nextFiber.return;
|
2948 | }
|
2949 | }
|
2950 |
|
2951 | fiber = nextFiber;
|
2952 | }
|
2953 | }
|
2954 | function prepareToReadContext(workInProgress, renderExpirationTime) {
|
2955 | currentlyRenderingFiber = workInProgress;
|
2956 | lastContextDependency = null;
|
2957 | lastContextWithAllBitsObserved = null;
|
2958 | var dependencies = workInProgress.dependencies;
|
2959 |
|
2960 | if (dependencies !== null) {
|
2961 | var firstContext = dependencies.firstContext;
|
2962 |
|
2963 | if (firstContext !== null) {
|
2964 | if (dependencies.expirationTime >= renderExpirationTime) {
|
2965 |
|
2966 | markWorkInProgressReceivedUpdate();
|
2967 | }
|
2968 |
|
2969 |
|
2970 | dependencies.firstContext = null;
|
2971 | }
|
2972 | }
|
2973 | }
|
2974 | function readContext(context, observedBits) {
|
2975 | {
|
2976 |
|
2977 |
|
2978 | if (isDisallowedContextReadInDEV) {
|
2979 | 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().');
|
2980 | }
|
2981 | }
|
2982 |
|
2983 | if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else {
|
2984 | var resolvedObservedBits;
|
2985 |
|
2986 | if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
|
2987 |
|
2988 | lastContextWithAllBitsObserved = context;
|
2989 | resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
|
2990 | } else {
|
2991 | resolvedObservedBits = observedBits;
|
2992 | }
|
2993 |
|
2994 | var contextItem = {
|
2995 | context: context,
|
2996 | observedBits: resolvedObservedBits,
|
2997 | next: null
|
2998 | };
|
2999 |
|
3000 | if (lastContextDependency === null) {
|
3001 | if (!(currentlyRenderingFiber !== null)) {
|
3002 | {
|
3003 | throw 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()." );
|
3004 | }
|
3005 | }
|
3006 |
|
3007 |
|
3008 | lastContextDependency = contextItem;
|
3009 | currentlyRenderingFiber.dependencies = {
|
3010 | expirationTime: NoWork,
|
3011 | firstContext: contextItem,
|
3012 | responders: null
|
3013 | };
|
3014 | } else {
|
3015 |
|
3016 | lastContextDependency = lastContextDependency.next = contextItem;
|
3017 | }
|
3018 | }
|
3019 |
|
3020 | return context._currentValue2;
|
3021 | }
|
3022 |
|
3023 | var UpdateState = 0;
|
3024 | var ReplaceState = 1;
|
3025 | var ForceUpdate = 2;
|
3026 | var CaptureUpdate = 3;
|
3027 |
|
3028 |
|
3029 |
|
3030 | var hasForceUpdate = false;
|
3031 | var didWarnUpdateInsideUpdate;
|
3032 | var currentlyProcessingQueue;
|
3033 |
|
3034 | {
|
3035 | didWarnUpdateInsideUpdate = false;
|
3036 | currentlyProcessingQueue = null;
|
3037 | }
|
3038 |
|
3039 | function initializeUpdateQueue(fiber) {
|
3040 | var queue = {
|
3041 | baseState: fiber.memoizedState,
|
3042 | baseQueue: null,
|
3043 | shared: {
|
3044 | pending: null
|
3045 | },
|
3046 | effects: null
|
3047 | };
|
3048 | fiber.updateQueue = queue;
|
3049 | }
|
3050 | function cloneUpdateQueue(current, workInProgress) {
|
3051 |
|
3052 | var queue = workInProgress.updateQueue;
|
3053 | var currentQueue = current.updateQueue;
|
3054 |
|
3055 | if (queue === currentQueue) {
|
3056 | var clone = {
|
3057 | baseState: currentQueue.baseState,
|
3058 | baseQueue: currentQueue.baseQueue,
|
3059 | shared: currentQueue.shared,
|
3060 | effects: currentQueue.effects
|
3061 | };
|
3062 | workInProgress.updateQueue = clone;
|
3063 | }
|
3064 | }
|
3065 | function createUpdate(expirationTime, suspenseConfig) {
|
3066 | var update = {
|
3067 | expirationTime: expirationTime,
|
3068 | suspenseConfig: suspenseConfig,
|
3069 | tag: UpdateState,
|
3070 | payload: null,
|
3071 | callback: null,
|
3072 | next: null
|
3073 | };
|
3074 | update.next = update;
|
3075 |
|
3076 | {
|
3077 | update.priority = getCurrentPriorityLevel();
|
3078 | }
|
3079 |
|
3080 | return update;
|
3081 | }
|
3082 | function enqueueUpdate(fiber, update) {
|
3083 | var updateQueue = fiber.updateQueue;
|
3084 |
|
3085 | if (updateQueue === null) {
|
3086 |
|
3087 | return;
|
3088 | }
|
3089 |
|
3090 | var sharedQueue = updateQueue.shared;
|
3091 | var pending = sharedQueue.pending;
|
3092 |
|
3093 | if (pending === null) {
|
3094 |
|
3095 | update.next = update;
|
3096 | } else {
|
3097 | update.next = pending.next;
|
3098 | pending.next = update;
|
3099 | }
|
3100 |
|
3101 | sharedQueue.pending = update;
|
3102 |
|
3103 | {
|
3104 | if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) {
|
3105 | error('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.');
|
3106 |
|
3107 | didWarnUpdateInsideUpdate = true;
|
3108 | }
|
3109 | }
|
3110 | }
|
3111 | function enqueueCapturedUpdate(workInProgress, update) {
|
3112 | var current = workInProgress.alternate;
|
3113 |
|
3114 | if (current !== null) {
|
3115 |
|
3116 | cloneUpdateQueue(current, workInProgress);
|
3117 | }
|
3118 |
|
3119 |
|
3120 | var queue = workInProgress.updateQueue;
|
3121 |
|
3122 | var last = queue.baseQueue;
|
3123 |
|
3124 | if (last === null) {
|
3125 | queue.baseQueue = update.next = update;
|
3126 | update.next = update;
|
3127 | } else {
|
3128 | update.next = last.next;
|
3129 | last.next = update;
|
3130 | }
|
3131 | }
|
3132 |
|
3133 | function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
|
3134 | switch (update.tag) {
|
3135 | case ReplaceState:
|
3136 | {
|
3137 | var payload = update.payload;
|
3138 |
|
3139 | if (typeof payload === 'function') {
|
3140 |
|
3141 | {
|
3142 | enterDisallowedContextReadInDEV();
|
3143 | }
|
3144 |
|
3145 | var nextState = payload.call(instance, prevState, nextProps);
|
3146 |
|
3147 | {
|
3148 | exitDisallowedContextReadInDEV();
|
3149 | }
|
3150 |
|
3151 | return nextState;
|
3152 | }
|
3153 |
|
3154 |
|
3155 | return payload;
|
3156 | }
|
3157 |
|
3158 | case CaptureUpdate:
|
3159 | {
|
3160 | workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
|
3161 | }
|
3162 |
|
3163 |
|
3164 | case UpdateState:
|
3165 | {
|
3166 | var _payload = update.payload;
|
3167 | var partialState;
|
3168 |
|
3169 | if (typeof _payload === 'function') {
|
3170 |
|
3171 | {
|
3172 | enterDisallowedContextReadInDEV();
|
3173 | }
|
3174 |
|
3175 | partialState = _payload.call(instance, prevState, nextProps);
|
3176 |
|
3177 | {
|
3178 | exitDisallowedContextReadInDEV();
|
3179 | }
|
3180 | } else {
|
3181 |
|
3182 | partialState = _payload;
|
3183 | }
|
3184 |
|
3185 | if (partialState === null || partialState === undefined) {
|
3186 |
|
3187 | return prevState;
|
3188 | }
|
3189 |
|
3190 |
|
3191 | return _assign({}, prevState, partialState);
|
3192 | }
|
3193 |
|
3194 | case ForceUpdate:
|
3195 | {
|
3196 | hasForceUpdate = true;
|
3197 | return prevState;
|
3198 | }
|
3199 | }
|
3200 |
|
3201 | return prevState;
|
3202 | }
|
3203 |
|
3204 | function processUpdateQueue(workInProgress, props, instance, renderExpirationTime) {
|
3205 |
|
3206 | var queue = workInProgress.updateQueue;
|
3207 | hasForceUpdate = false;
|
3208 |
|
3209 | {
|
3210 | currentlyProcessingQueue = queue.shared;
|
3211 | }
|
3212 |
|
3213 |
|
3214 | var baseQueue = queue.baseQueue;
|
3215 |
|
3216 | var pendingQueue = queue.shared.pending;
|
3217 |
|
3218 | if (pendingQueue !== null) {
|
3219 |
|
3220 |
|
3221 | if (baseQueue !== null) {
|
3222 |
|
3223 | var baseFirst = baseQueue.next;
|
3224 | var pendingFirst = pendingQueue.next;
|
3225 | baseQueue.next = pendingFirst;
|
3226 | pendingQueue.next = baseFirst;
|
3227 | }
|
3228 |
|
3229 | baseQueue = pendingQueue;
|
3230 | queue.shared.pending = null;
|
3231 |
|
3232 | var current = workInProgress.alternate;
|
3233 |
|
3234 | if (current !== null) {
|
3235 | var currentQueue = current.updateQueue;
|
3236 |
|
3237 | if (currentQueue !== null) {
|
3238 | currentQueue.baseQueue = pendingQueue;
|
3239 | }
|
3240 | }
|
3241 | }
|
3242 |
|
3243 |
|
3244 | if (baseQueue !== null) {
|
3245 | var first = baseQueue.next;
|
3246 |
|
3247 | var newState = queue.baseState;
|
3248 | var newExpirationTime = NoWork;
|
3249 | var newBaseState = null;
|
3250 | var newBaseQueueFirst = null;
|
3251 | var newBaseQueueLast = null;
|
3252 |
|
3253 | if (first !== null) {
|
3254 | var update = first;
|
3255 |
|
3256 | do {
|
3257 | var updateExpirationTime = update.expirationTime;
|
3258 |
|
3259 | if (updateExpirationTime < renderExpirationTime) {
|
3260 |
|
3261 |
|
3262 |
|
3263 | var clone = {
|
3264 | expirationTime: update.expirationTime,
|
3265 | suspenseConfig: update.suspenseConfig,
|
3266 | tag: update.tag,
|
3267 | payload: update.payload,
|
3268 | callback: update.callback,
|
3269 | next: null
|
3270 | };
|
3271 |
|
3272 | if (newBaseQueueLast === null) {
|
3273 | newBaseQueueFirst = newBaseQueueLast = clone;
|
3274 | newBaseState = newState;
|
3275 | } else {
|
3276 | newBaseQueueLast = newBaseQueueLast.next = clone;
|
3277 | }
|
3278 |
|
3279 |
|
3280 | if (updateExpirationTime > newExpirationTime) {
|
3281 | newExpirationTime = updateExpirationTime;
|
3282 | }
|
3283 | } else {
|
3284 |
|
3285 | if (newBaseQueueLast !== null) {
|
3286 | var _clone = {
|
3287 | expirationTime: Sync,
|
3288 |
|
3289 | suspenseConfig: update.suspenseConfig,
|
3290 | tag: update.tag,
|
3291 | payload: update.payload,
|
3292 | callback: update.callback,
|
3293 | next: null
|
3294 | };
|
3295 | newBaseQueueLast = newBaseQueueLast.next = _clone;
|
3296 | }
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 |
|
3302 |
|
3303 |
|
3304 | markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig);
|
3305 |
|
3306 | newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance);
|
3307 | var callback = update.callback;
|
3308 |
|
3309 | if (callback !== null) {
|
3310 | workInProgress.effectTag |= Callback;
|
3311 | var effects = queue.effects;
|
3312 |
|
3313 | if (effects === null) {
|
3314 | queue.effects = [update];
|
3315 | } else {
|
3316 | effects.push(update);
|
3317 | }
|
3318 | }
|
3319 | }
|
3320 |
|
3321 | update = update.next;
|
3322 |
|
3323 | if (update === null || update === first) {
|
3324 | pendingQueue = queue.shared.pending;
|
3325 |
|
3326 | if (pendingQueue === null) {
|
3327 | break;
|
3328 | } else {
|
3329 |
|
3330 |
|
3331 | update = baseQueue.next = pendingQueue.next;
|
3332 | pendingQueue.next = first;
|
3333 | queue.baseQueue = baseQueue = pendingQueue;
|
3334 | queue.shared.pending = null;
|
3335 | }
|
3336 | }
|
3337 | } while (true);
|
3338 | }
|
3339 |
|
3340 | if (newBaseQueueLast === null) {
|
3341 | newBaseState = newState;
|
3342 | } else {
|
3343 | newBaseQueueLast.next = newBaseQueueFirst;
|
3344 | }
|
3345 |
|
3346 | queue.baseState = newBaseState;
|
3347 | queue.baseQueue = newBaseQueueLast;
|
3348 |
|
3349 |
|
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 |
|
3355 | markUnprocessedUpdateTime(newExpirationTime);
|
3356 | workInProgress.expirationTime = newExpirationTime;
|
3357 | workInProgress.memoizedState = newState;
|
3358 | }
|
3359 |
|
3360 | {
|
3361 | currentlyProcessingQueue = null;
|
3362 | }
|
3363 | }
|
3364 |
|
3365 | function callCallback(callback, context) {
|
3366 | if (!(typeof callback === 'function')) {
|
3367 | {
|
3368 | throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback );
|
3369 | }
|
3370 | }
|
3371 |
|
3372 | callback.call(context);
|
3373 | }
|
3374 |
|
3375 | function resetHasForceUpdateBeforeProcessing() {
|
3376 | hasForceUpdate = false;
|
3377 | }
|
3378 | function checkHasForceUpdateAfterProcessing() {
|
3379 | return hasForceUpdate;
|
3380 | }
|
3381 | function commitUpdateQueue(finishedWork, finishedQueue, instance) {
|
3382 |
|
3383 | var effects = finishedQueue.effects;
|
3384 | finishedQueue.effects = null;
|
3385 |
|
3386 | if (effects !== null) {
|
3387 | for (var i = 0; i < effects.length; i++) {
|
3388 | var effect = effects[i];
|
3389 | var callback = effect.callback;
|
3390 |
|
3391 | if (callback !== null) {
|
3392 | effect.callback = null;
|
3393 | callCallback(callback, instance);
|
3394 | }
|
3395 | }
|
3396 | }
|
3397 | }
|
3398 |
|
3399 | var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
|
3400 | function requestCurrentSuspenseConfig() {
|
3401 | return ReactCurrentBatchConfig.suspense;
|
3402 | }
|
3403 |
|
3404 | var fakeInternalInstance = {};
|
3405 | var isArray = Array.isArray;
|
3406 |
|
3407 |
|
3408 | var emptyRefsObject = new React.Component().refs;
|
3409 | var didWarnAboutStateAssignmentForComponent;
|
3410 | var didWarnAboutUninitializedState;
|
3411 | var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
|
3412 | var didWarnAboutLegacyLifecyclesAndDerivedState;
|
3413 | var didWarnAboutUndefinedDerivedState;
|
3414 | var warnOnUndefinedDerivedState;
|
3415 | var warnOnInvalidCallback;
|
3416 | var didWarnAboutDirectlyAssigningPropsToState;
|
3417 | var didWarnAboutContextTypeAndContextTypes;
|
3418 | var didWarnAboutInvalidateContextType;
|
3419 |
|
3420 | {
|
3421 | didWarnAboutStateAssignmentForComponent = new Set();
|
3422 | didWarnAboutUninitializedState = new Set();
|
3423 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
|
3424 | didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
|
3425 | didWarnAboutDirectlyAssigningPropsToState = new Set();
|
3426 | didWarnAboutUndefinedDerivedState = new Set();
|
3427 | didWarnAboutContextTypeAndContextTypes = new Set();
|
3428 | didWarnAboutInvalidateContextType = new Set();
|
3429 | var didWarnOnInvalidCallback = new Set();
|
3430 |
|
3431 | warnOnInvalidCallback = function (callback, callerName) {
|
3432 | if (callback === null || typeof callback === 'function') {
|
3433 | return;
|
3434 | }
|
3435 |
|
3436 | var key = callerName + "_" + callback;
|
3437 |
|
3438 | if (!didWarnOnInvalidCallback.has(key)) {
|
3439 | didWarnOnInvalidCallback.add(key);
|
3440 |
|
3441 | error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
|
3442 | }
|
3443 | };
|
3444 |
|
3445 | warnOnUndefinedDerivedState = function (type, partialState) {
|
3446 | if (partialState === undefined) {
|
3447 | var componentName = getComponentName(type) || 'Component';
|
3448 |
|
3449 | if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
|
3450 | didWarnAboutUndefinedDerivedState.add(componentName);
|
3451 |
|
3452 | error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
|
3453 | }
|
3454 | }
|
3455 | };
|
3456 |
|
3457 |
|
3458 |
|
3459 |
|
3460 |
|
3461 |
|
3462 | Object.defineProperty(fakeInternalInstance, '_processChildContext', {
|
3463 | enumerable: false,
|
3464 | value: function () {
|
3465 | {
|
3466 | {
|
3467 | throw 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)." );
|
3468 | }
|
3469 | }
|
3470 | }
|
3471 | });
|
3472 | Object.freeze(fakeInternalInstance);
|
3473 | }
|
3474 |
|
3475 | function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
|
3476 | var prevState = workInProgress.memoizedState;
|
3477 |
|
3478 | var partialState = getDerivedStateFromProps(nextProps, prevState);
|
3479 |
|
3480 | {
|
3481 | warnOnUndefinedDerivedState(ctor, partialState);
|
3482 | }
|
3483 |
|
3484 |
|
3485 | var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
|
3486 | workInProgress.memoizedState = memoizedState;
|
3487 |
|
3488 |
|
3489 | if (workInProgress.expirationTime === NoWork) {
|
3490 |
|
3491 | var updateQueue = workInProgress.updateQueue;
|
3492 | updateQueue.baseState = memoizedState;
|
3493 | }
|
3494 | }
|
3495 | var classComponentUpdater = {
|
3496 | isMounted: isMounted,
|
3497 | enqueueSetState: function (inst, payload, callback) {
|
3498 | var fiber = get(inst);
|
3499 | var currentTime = requestCurrentTimeForUpdate();
|
3500 | var suspenseConfig = requestCurrentSuspenseConfig();
|
3501 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
3502 | var update = createUpdate(expirationTime, suspenseConfig);
|
3503 | update.payload = payload;
|
3504 |
|
3505 | if (callback !== undefined && callback !== null) {
|
3506 | {
|
3507 | warnOnInvalidCallback(callback, 'setState');
|
3508 | }
|
3509 |
|
3510 | update.callback = callback;
|
3511 | }
|
3512 |
|
3513 | enqueueUpdate(fiber, update);
|
3514 | scheduleWork(fiber, expirationTime);
|
3515 | },
|
3516 | enqueueReplaceState: function (inst, payload, callback) {
|
3517 | var fiber = get(inst);
|
3518 | var currentTime = requestCurrentTimeForUpdate();
|
3519 | var suspenseConfig = requestCurrentSuspenseConfig();
|
3520 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
3521 | var update = createUpdate(expirationTime, suspenseConfig);
|
3522 | update.tag = ReplaceState;
|
3523 | update.payload = payload;
|
3524 |
|
3525 | if (callback !== undefined && callback !== null) {
|
3526 | {
|
3527 | warnOnInvalidCallback(callback, 'replaceState');
|
3528 | }
|
3529 |
|
3530 | update.callback = callback;
|
3531 | }
|
3532 |
|
3533 | enqueueUpdate(fiber, update);
|
3534 | scheduleWork(fiber, expirationTime);
|
3535 | },
|
3536 | enqueueForceUpdate: function (inst, callback) {
|
3537 | var fiber = get(inst);
|
3538 | var currentTime = requestCurrentTimeForUpdate();
|
3539 | var suspenseConfig = requestCurrentSuspenseConfig();
|
3540 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
3541 | var update = createUpdate(expirationTime, suspenseConfig);
|
3542 | update.tag = ForceUpdate;
|
3543 |
|
3544 | if (callback !== undefined && callback !== null) {
|
3545 | {
|
3546 | warnOnInvalidCallback(callback, 'forceUpdate');
|
3547 | }
|
3548 |
|
3549 | update.callback = callback;
|
3550 | }
|
3551 |
|
3552 | enqueueUpdate(fiber, update);
|
3553 | scheduleWork(fiber, expirationTime);
|
3554 | }
|
3555 | };
|
3556 |
|
3557 | function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
|
3558 | var instance = workInProgress.stateNode;
|
3559 |
|
3560 | if (typeof instance.shouldComponentUpdate === 'function') {
|
3561 |
|
3562 | startPhaseTimer(workInProgress, 'shouldComponentUpdate');
|
3563 | var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
3564 | stopPhaseTimer();
|
3565 |
|
3566 | {
|
3567 | if (shouldUpdate === undefined) {
|
3568 | error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component');
|
3569 | }
|
3570 | }
|
3571 |
|
3572 | return shouldUpdate;
|
3573 | }
|
3574 |
|
3575 | if (ctor.prototype && ctor.prototype.isPureReactComponent) {
|
3576 | return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
|
3577 | }
|
3578 |
|
3579 | return true;
|
3580 | }
|
3581 |
|
3582 | function checkClassInstance(workInProgress, ctor, newProps) {
|
3583 | var instance = workInProgress.stateNode;
|
3584 |
|
3585 | {
|
3586 | var name = getComponentName(ctor) || 'Component';
|
3587 | var renderPresent = instance.render;
|
3588 |
|
3589 | if (!renderPresent) {
|
3590 | if (ctor.prototype && typeof ctor.prototype.render === 'function') {
|
3591 | error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
|
3592 | } else {
|
3593 | error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
|
3594 | }
|
3595 | }
|
3596 |
|
3597 | if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
|
3598 | error('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);
|
3599 | }
|
3600 |
|
3601 | if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
|
3602 | error('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);
|
3603 | }
|
3604 |
|
3605 | if (instance.propTypes) {
|
3606 | error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
|
3607 | }
|
3608 |
|
3609 | if (instance.contextType) {
|
3610 | error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
|
3611 | }
|
3612 |
|
3613 | {
|
3614 | if (instance.contextTypes) {
|
3615 | error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
|
3616 | }
|
3617 |
|
3618 | if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
|
3619 | didWarnAboutContextTypeAndContextTypes.add(ctor);
|
3620 |
|
3621 | error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
|
3622 | }
|
3623 | }
|
3624 |
|
3625 | if (typeof instance.componentShouldUpdate === 'function') {
|
3626 | error('%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);
|
3627 | }
|
3628 |
|
3629 | if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
|
3630 | error('%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');
|
3631 | }
|
3632 |
|
3633 | if (typeof instance.componentDidUnmount === 'function') {
|
3634 | error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
|
3635 | }
|
3636 |
|
3637 | if (typeof instance.componentDidReceiveProps === 'function') {
|
3638 | error('%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);
|
3639 | }
|
3640 |
|
3641 | if (typeof instance.componentWillRecieveProps === 'function') {
|
3642 | error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
|
3643 | }
|
3644 |
|
3645 | if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') {
|
3646 | error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
|
3647 | }
|
3648 |
|
3649 | var hasMutatedProps = instance.props !== newProps;
|
3650 |
|
3651 | if (instance.props !== undefined && hasMutatedProps) {
|
3652 | error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
|
3653 | }
|
3654 |
|
3655 | if (instance.defaultProps) {
|
3656 | error('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);
|
3657 | }
|
3658 |
|
3659 | if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
|
3660 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
|
3661 |
|
3662 | error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
|
3663 | }
|
3664 |
|
3665 | if (typeof instance.getDerivedStateFromProps === 'function') {
|
3666 | error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
|
3667 | }
|
3668 |
|
3669 | if (typeof instance.getDerivedStateFromError === 'function') {
|
3670 | error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
|
3671 | }
|
3672 |
|
3673 | if (typeof ctor.getSnapshotBeforeUpdate === 'function') {
|
3674 | error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name);
|
3675 | }
|
3676 |
|
3677 | var _state = instance.state;
|
3678 |
|
3679 | if (_state && (typeof _state !== 'object' || isArray(_state))) {
|
3680 | error('%s.state: must be set to an object or null', name);
|
3681 | }
|
3682 |
|
3683 | if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') {
|
3684 | error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
|
3685 | }
|
3686 | }
|
3687 | }
|
3688 |
|
3689 | function adoptClassInstance(workInProgress, instance) {
|
3690 | instance.updater = classComponentUpdater;
|
3691 | workInProgress.stateNode = instance;
|
3692 |
|
3693 | set(instance, workInProgress);
|
3694 |
|
3695 | {
|
3696 | instance._reactInternalInstance = fakeInternalInstance;
|
3697 | }
|
3698 | }
|
3699 |
|
3700 | function constructClassInstance(workInProgress, ctor, props) {
|
3701 | var isLegacyContextConsumer = false;
|
3702 | var unmaskedContext = emptyContextObject;
|
3703 | var context = emptyContextObject;
|
3704 | var contextType = ctor.contextType;
|
3705 |
|
3706 | {
|
3707 | if ('contextType' in ctor) {
|
3708 | var isValid =
|
3709 | contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined;
|
3710 |
|
3711 | if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
|
3712 | didWarnAboutInvalidateContextType.add(ctor);
|
3713 | var addendum = '';
|
3714 |
|
3715 | if (contextType === undefined) {
|
3716 | 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.';
|
3717 | } else if (typeof contextType !== 'object') {
|
3718 | addendum = ' However, it is set to a ' + typeof contextType + '.';
|
3719 | } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
|
3720 | addendum = ' Did you accidentally pass the Context.Provider instead?';
|
3721 | } else if (contextType._context !== undefined) {
|
3722 |
|
3723 | addendum = ' Did you accidentally pass the Context.Consumer instead?';
|
3724 | } else {
|
3725 | addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
|
3726 | }
|
3727 |
|
3728 | error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
|
3729 | }
|
3730 | }
|
3731 | }
|
3732 |
|
3733 | if (typeof contextType === 'object' && contextType !== null) {
|
3734 | context = readContext(contextType);
|
3735 | } else {
|
3736 | unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
3737 | var contextTypes = ctor.contextTypes;
|
3738 | isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
|
3739 | context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
|
3740 | }
|
3741 |
|
3742 | var instance = new ctor(props, context);
|
3743 | var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
|
3744 | adoptClassInstance(workInProgress, instance);
|
3745 |
|
3746 | {
|
3747 | if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
|
3748 | var componentName = getComponentName(ctor) || 'Component';
|
3749 |
|
3750 | if (!didWarnAboutUninitializedState.has(componentName)) {
|
3751 | didWarnAboutUninitializedState.add(componentName);
|
3752 |
|
3753 | error('`%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);
|
3754 | }
|
3755 | }
|
3756 |
|
3757 |
|
3758 |
|
3759 |
|
3760 | if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
|
3761 | var foundWillMountName = null;
|
3762 | var foundWillReceivePropsName = null;
|
3763 | var foundWillUpdateName = null;
|
3764 |
|
3765 | if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
3766 | foundWillMountName = 'componentWillMount';
|
3767 | } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
3768 | foundWillMountName = 'UNSAFE_componentWillMount';
|
3769 | }
|
3770 |
|
3771 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
3772 | foundWillReceivePropsName = 'componentWillReceiveProps';
|
3773 | } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
3774 | foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
|
3775 | }
|
3776 |
|
3777 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
3778 | foundWillUpdateName = 'componentWillUpdate';
|
3779 | } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
3780 | foundWillUpdateName = 'UNSAFE_componentWillUpdate';
|
3781 | }
|
3782 |
|
3783 | if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
|
3784 | var _componentName = getComponentName(ctor) || 'Component';
|
3785 |
|
3786 | var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
|
3787 |
|
3788 | if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
|
3789 | didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
|
3790 |
|
3791 | error('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 : '');
|
3792 | }
|
3793 | }
|
3794 | }
|
3795 | }
|
3796 |
|
3797 |
|
3798 |
|
3799 | if (isLegacyContextConsumer) {
|
3800 | cacheContext(workInProgress, unmaskedContext, context);
|
3801 | }
|
3802 |
|
3803 | return instance;
|
3804 | }
|
3805 |
|
3806 | function callComponentWillMount(workInProgress, instance) {
|
3807 | startPhaseTimer(workInProgress, 'componentWillMount');
|
3808 | var oldState = instance.state;
|
3809 |
|
3810 | if (typeof instance.componentWillMount === 'function') {
|
3811 | instance.componentWillMount();
|
3812 | }
|
3813 |
|
3814 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
3815 | instance.UNSAFE_componentWillMount();
|
3816 | }
|
3817 |
|
3818 | stopPhaseTimer();
|
3819 |
|
3820 | if (oldState !== instance.state) {
|
3821 | {
|
3822 | error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
|
3823 | }
|
3824 |
|
3825 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
3826 | }
|
3827 | }
|
3828 |
|
3829 | function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
|
3830 | var oldState = instance.state;
|
3831 | startPhaseTimer(workInProgress, 'componentWillReceiveProps');
|
3832 |
|
3833 | if (typeof instance.componentWillReceiveProps === 'function') {
|
3834 | instance.componentWillReceiveProps(newProps, nextContext);
|
3835 | }
|
3836 |
|
3837 | if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
3838 | instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
|
3839 | }
|
3840 |
|
3841 | stopPhaseTimer();
|
3842 |
|
3843 | if (instance.state !== oldState) {
|
3844 | {
|
3845 | var componentName = getComponentName(workInProgress.type) || 'Component';
|
3846 |
|
3847 | if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
|
3848 | didWarnAboutStateAssignmentForComponent.add(componentName);
|
3849 |
|
3850 | error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
|
3851 | }
|
3852 | }
|
3853 |
|
3854 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
3855 | }
|
3856 | }
|
3857 |
|
3858 |
|
3859 | function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
|
3860 | {
|
3861 | checkClassInstance(workInProgress, ctor, newProps);
|
3862 | }
|
3863 |
|
3864 | var instance = workInProgress.stateNode;
|
3865 | instance.props = newProps;
|
3866 | instance.state = workInProgress.memoizedState;
|
3867 | instance.refs = emptyRefsObject;
|
3868 | initializeUpdateQueue(workInProgress);
|
3869 | var contextType = ctor.contextType;
|
3870 |
|
3871 | if (typeof contextType === 'object' && contextType !== null) {
|
3872 | instance.context = readContext(contextType);
|
3873 | } else {
|
3874 | var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
3875 | instance.context = getMaskedContext(workInProgress, unmaskedContext);
|
3876 | }
|
3877 |
|
3878 | {
|
3879 | if (instance.state === newProps) {
|
3880 | var componentName = getComponentName(ctor) || 'Component';
|
3881 |
|
3882 | if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
|
3883 | didWarnAboutDirectlyAssigningPropsToState.add(componentName);
|
3884 |
|
3885 | error('%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);
|
3886 | }
|
3887 | }
|
3888 |
|
3889 | if (workInProgress.mode & StrictMode) {
|
3890 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
|
3891 | }
|
3892 |
|
3893 | {
|
3894 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
|
3895 | }
|
3896 | }
|
3897 |
|
3898 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
|
3899 | instance.state = workInProgress.memoizedState;
|
3900 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
3901 |
|
3902 | if (typeof getDerivedStateFromProps === 'function') {
|
3903 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
3904 | instance.state = workInProgress.memoizedState;
|
3905 | }
|
3906 |
|
3907 |
|
3908 |
|
3909 | if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
3910 | callComponentWillMount(workInProgress, instance);
|
3911 |
|
3912 |
|
3913 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
|
3914 | instance.state = workInProgress.memoizedState;
|
3915 | }
|
3916 |
|
3917 | if (typeof instance.componentDidMount === 'function') {
|
3918 | workInProgress.effectTag |= Update;
|
3919 | }
|
3920 | }
|
3921 |
|
3922 | function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
|
3923 | var instance = workInProgress.stateNode;
|
3924 | var oldProps = workInProgress.memoizedProps;
|
3925 | instance.props = oldProps;
|
3926 | var oldContext = instance.context;
|
3927 | var contextType = ctor.contextType;
|
3928 | var nextContext = emptyContextObject;
|
3929 |
|
3930 | if (typeof contextType === 'object' && contextType !== null) {
|
3931 | nextContext = readContext(contextType);
|
3932 | } else {
|
3933 | var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
3934 | nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
|
3935 | }
|
3936 |
|
3937 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
3938 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
3939 |
|
3940 |
|
3941 |
|
3942 |
|
3943 |
|
3944 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
3945 | if (oldProps !== newProps || oldContext !== nextContext) {
|
3946 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
3947 | }
|
3948 | }
|
3949 |
|
3950 | resetHasForceUpdateBeforeProcessing();
|
3951 | var oldState = workInProgress.memoizedState;
|
3952 | var newState = instance.state = oldState;
|
3953 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
|
3954 | newState = workInProgress.memoizedState;
|
3955 |
|
3956 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
3957 |
|
3958 |
|
3959 | if (typeof instance.componentDidMount === 'function') {
|
3960 | workInProgress.effectTag |= Update;
|
3961 | }
|
3962 |
|
3963 | return false;
|
3964 | }
|
3965 |
|
3966 | if (typeof getDerivedStateFromProps === 'function') {
|
3967 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
3968 | newState = workInProgress.memoizedState;
|
3969 | }
|
3970 |
|
3971 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
|
3972 |
|
3973 | if (shouldUpdate) {
|
3974 |
|
3975 |
|
3976 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
3977 | startPhaseTimer(workInProgress, 'componentWillMount');
|
3978 |
|
3979 | if (typeof instance.componentWillMount === 'function') {
|
3980 | instance.componentWillMount();
|
3981 | }
|
3982 |
|
3983 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
3984 | instance.UNSAFE_componentWillMount();
|
3985 | }
|
3986 |
|
3987 | stopPhaseTimer();
|
3988 | }
|
3989 |
|
3990 | if (typeof instance.componentDidMount === 'function') {
|
3991 | workInProgress.effectTag |= Update;
|
3992 | }
|
3993 | } else {
|
3994 |
|
3995 |
|
3996 | if (typeof instance.componentDidMount === 'function') {
|
3997 | workInProgress.effectTag |= Update;
|
3998 | }
|
3999 |
|
4000 |
|
4001 |
|
4002 | workInProgress.memoizedProps = newProps;
|
4003 | workInProgress.memoizedState = newState;
|
4004 | }
|
4005 |
|
4006 |
|
4007 |
|
4008 | instance.props = newProps;
|
4009 | instance.state = newState;
|
4010 | instance.context = nextContext;
|
4011 | return shouldUpdate;
|
4012 | }
|
4013 |
|
4014 |
|
4015 | function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
|
4016 | var instance = workInProgress.stateNode;
|
4017 | cloneUpdateQueue(current, workInProgress);
|
4018 | var oldProps = workInProgress.memoizedProps;
|
4019 | instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
|
4020 | var oldContext = instance.context;
|
4021 | var contextType = ctor.contextType;
|
4022 | var nextContext = emptyContextObject;
|
4023 |
|
4024 | if (typeof contextType === 'object' && contextType !== null) {
|
4025 | nextContext = readContext(contextType);
|
4026 | } else {
|
4027 | var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4028 | nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
|
4029 | }
|
4030 |
|
4031 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
4032 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
4033 |
|
4034 |
|
4035 |
|
4036 |
|
4037 |
|
4038 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
4039 | if (oldProps !== newProps || oldContext !== nextContext) {
|
4040 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
4041 | }
|
4042 | }
|
4043 |
|
4044 | resetHasForceUpdateBeforeProcessing();
|
4045 | var oldState = workInProgress.memoizedState;
|
4046 | var newState = instance.state = oldState;
|
4047 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
|
4048 | newState = workInProgress.memoizedState;
|
4049 |
|
4050 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
4051 |
|
4052 |
|
4053 | if (typeof instance.componentDidUpdate === 'function') {
|
4054 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4055 | workInProgress.effectTag |= Update;
|
4056 | }
|
4057 | }
|
4058 |
|
4059 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4060 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4061 | workInProgress.effectTag |= Snapshot;
|
4062 | }
|
4063 | }
|
4064 |
|
4065 | return false;
|
4066 | }
|
4067 |
|
4068 | if (typeof getDerivedStateFromProps === 'function') {
|
4069 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
4070 | newState = workInProgress.memoizedState;
|
4071 | }
|
4072 |
|
4073 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
|
4074 |
|
4075 | if (shouldUpdate) {
|
4076 |
|
4077 |
|
4078 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
|
4079 | startPhaseTimer(workInProgress, 'componentWillUpdate');
|
4080 |
|
4081 | if (typeof instance.componentWillUpdate === 'function') {
|
4082 | instance.componentWillUpdate(newProps, newState, nextContext);
|
4083 | }
|
4084 |
|
4085 | if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
4086 | instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
|
4087 | }
|
4088 |
|
4089 | stopPhaseTimer();
|
4090 | }
|
4091 |
|
4092 | if (typeof instance.componentDidUpdate === 'function') {
|
4093 | workInProgress.effectTag |= Update;
|
4094 | }
|
4095 |
|
4096 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4097 | workInProgress.effectTag |= Snapshot;
|
4098 | }
|
4099 | } else {
|
4100 |
|
4101 |
|
4102 | if (typeof instance.componentDidUpdate === 'function') {
|
4103 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4104 | workInProgress.effectTag |= Update;
|
4105 | }
|
4106 | }
|
4107 |
|
4108 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4109 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4110 | workInProgress.effectTag |= Snapshot;
|
4111 | }
|
4112 | }
|
4113 |
|
4114 |
|
4115 |
|
4116 | workInProgress.memoizedProps = newProps;
|
4117 | workInProgress.memoizedState = newState;
|
4118 | }
|
4119 |
|
4120 |
|
4121 |
|
4122 | instance.props = newProps;
|
4123 | instance.state = newState;
|
4124 | instance.context = nextContext;
|
4125 | return shouldUpdate;
|
4126 | }
|
4127 |
|
4128 | var didWarnAboutMaps;
|
4129 | var didWarnAboutGenerators;
|
4130 | var didWarnAboutStringRefs;
|
4131 | var ownerHasKeyUseWarning;
|
4132 | var ownerHasFunctionTypeWarning;
|
4133 |
|
4134 | var warnForMissingKey = function (child) {};
|
4135 |
|
4136 | {
|
4137 | didWarnAboutMaps = false;
|
4138 | didWarnAboutGenerators = false;
|
4139 | didWarnAboutStringRefs = {};
|
4140 | |
4141 |
|
4142 |
|
4143 |
|
4144 |
|
4145 |
|
4146 | ownerHasKeyUseWarning = {};
|
4147 | ownerHasFunctionTypeWarning = {};
|
4148 |
|
4149 | warnForMissingKey = function (child) {
|
4150 | if (child === null || typeof child !== 'object') {
|
4151 | return;
|
4152 | }
|
4153 |
|
4154 | if (!child._store || child._store.validated || child.key != null) {
|
4155 | return;
|
4156 | }
|
4157 |
|
4158 | if (!(typeof child._store === 'object')) {
|
4159 | {
|
4160 | throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." );
|
4161 | }
|
4162 | }
|
4163 |
|
4164 | child._store.validated = true;
|
4165 | var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
|
4166 |
|
4167 | if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
4168 | return;
|
4169 | }
|
4170 |
|
4171 | ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
4172 |
|
4173 | error('Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
|
4174 | };
|
4175 | }
|
4176 |
|
4177 | var isArray$1 = Array.isArray;
|
4178 |
|
4179 | function coerceRef(returnFiber, current, element) {
|
4180 | var mixedRef = element.ref;
|
4181 |
|
4182 | if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
|
4183 | {
|
4184 |
|
4185 |
|
4186 | if ((returnFiber.mode & StrictMode || warnAboutStringRefs) &&
|
4187 |
|
4188 |
|
4189 | !(element._owner && element._self && element._owner.stateNode !== element._self)) {
|
4190 | var componentName = getComponentName(returnFiber.type) || 'Component';
|
4191 |
|
4192 | if (!didWarnAboutStringRefs[componentName]) {
|
4193 | {
|
4194 | error('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));
|
4195 | }
|
4196 |
|
4197 | didWarnAboutStringRefs[componentName] = true;
|
4198 | }
|
4199 | }
|
4200 | }
|
4201 |
|
4202 | if (element._owner) {
|
4203 | var owner = element._owner;
|
4204 | var inst;
|
4205 |
|
4206 | if (owner) {
|
4207 | var ownerFiber = owner;
|
4208 |
|
4209 | if (!(ownerFiber.tag === ClassComponent)) {
|
4210 | {
|
4211 | throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" );
|
4212 | }
|
4213 | }
|
4214 |
|
4215 | inst = ownerFiber.stateNode;
|
4216 | }
|
4217 |
|
4218 | if (!inst) {
|
4219 | {
|
4220 | throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." );
|
4221 | }
|
4222 | }
|
4223 |
|
4224 | var stringRef = '' + mixedRef;
|
4225 |
|
4226 | if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) {
|
4227 | return current.ref;
|
4228 | }
|
4229 |
|
4230 | var ref = function (value) {
|
4231 | var refs = inst.refs;
|
4232 |
|
4233 | if (refs === emptyRefsObject) {
|
4234 |
|
4235 | refs = inst.refs = {};
|
4236 | }
|
4237 |
|
4238 | if (value === null) {
|
4239 | delete refs[stringRef];
|
4240 | } else {
|
4241 | refs[stringRef] = value;
|
4242 | }
|
4243 | };
|
4244 |
|
4245 | ref._stringRef = stringRef;
|
4246 | return ref;
|
4247 | } else {
|
4248 | if (!(typeof mixedRef === 'string')) {
|
4249 | {
|
4250 | throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." );
|
4251 | }
|
4252 | }
|
4253 |
|
4254 | if (!element._owner) {
|
4255 | {
|
4256 | throw 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." );
|
4257 | }
|
4258 | }
|
4259 | }
|
4260 | }
|
4261 |
|
4262 | return mixedRef;
|
4263 | }
|
4264 |
|
4265 | function throwOnInvalidObjectType(returnFiber, newChild) {
|
4266 | if (returnFiber.type !== 'textarea') {
|
4267 | var addendum = '';
|
4268 |
|
4269 | {
|
4270 | addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
|
4271 | }
|
4272 |
|
4273 | {
|
4274 | {
|
4275 | throw 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 );
|
4276 | }
|
4277 | }
|
4278 | }
|
4279 | }
|
4280 |
|
4281 | function warnOnFunctionType() {
|
4282 | {
|
4283 | 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();
|
4284 |
|
4285 | if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
|
4286 | return;
|
4287 | }
|
4288 |
|
4289 | ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
|
4290 |
|
4291 | error('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.');
|
4292 | }
|
4293 | }
|
4294 |
|
4295 |
|
4296 |
|
4297 |
|
4298 |
|
4299 | function ChildReconciler(shouldTrackSideEffects) {
|
4300 | function deleteChild(returnFiber, childToDelete) {
|
4301 | if (!shouldTrackSideEffects) {
|
4302 |
|
4303 | return;
|
4304 | }
|
4305 |
|
4306 |
|
4307 |
|
4308 |
|
4309 |
|
4310 |
|
4311 | var last = returnFiber.lastEffect;
|
4312 |
|
4313 | if (last !== null) {
|
4314 | last.nextEffect = childToDelete;
|
4315 | returnFiber.lastEffect = childToDelete;
|
4316 | } else {
|
4317 | returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
4318 | }
|
4319 |
|
4320 | childToDelete.nextEffect = null;
|
4321 | childToDelete.effectTag = Deletion;
|
4322 | }
|
4323 |
|
4324 | function deleteRemainingChildren(returnFiber, currentFirstChild) {
|
4325 | if (!shouldTrackSideEffects) {
|
4326 |
|
4327 | return null;
|
4328 | }
|
4329 |
|
4330 |
|
4331 |
|
4332 | var childToDelete = currentFirstChild;
|
4333 |
|
4334 | while (childToDelete !== null) {
|
4335 | deleteChild(returnFiber, childToDelete);
|
4336 | childToDelete = childToDelete.sibling;
|
4337 | }
|
4338 |
|
4339 | return null;
|
4340 | }
|
4341 |
|
4342 | function mapRemainingChildren(returnFiber, currentFirstChild) {
|
4343 |
|
4344 |
|
4345 |
|
4346 | var existingChildren = new Map();
|
4347 | var existingChild = currentFirstChild;
|
4348 |
|
4349 | while (existingChild !== null) {
|
4350 | if (existingChild.key !== null) {
|
4351 | existingChildren.set(existingChild.key, existingChild);
|
4352 | } else {
|
4353 | existingChildren.set(existingChild.index, existingChild);
|
4354 | }
|
4355 |
|
4356 | existingChild = existingChild.sibling;
|
4357 | }
|
4358 |
|
4359 | return existingChildren;
|
4360 | }
|
4361 |
|
4362 | function useFiber(fiber, pendingProps) {
|
4363 |
|
4364 |
|
4365 | var clone = createWorkInProgress(fiber, pendingProps);
|
4366 | clone.index = 0;
|
4367 | clone.sibling = null;
|
4368 | return clone;
|
4369 | }
|
4370 |
|
4371 | function placeChild(newFiber, lastPlacedIndex, newIndex) {
|
4372 | newFiber.index = newIndex;
|
4373 |
|
4374 | if (!shouldTrackSideEffects) {
|
4375 |
|
4376 | return lastPlacedIndex;
|
4377 | }
|
4378 |
|
4379 | var current = newFiber.alternate;
|
4380 |
|
4381 | if (current !== null) {
|
4382 | var oldIndex = current.index;
|
4383 |
|
4384 | if (oldIndex < lastPlacedIndex) {
|
4385 |
|
4386 | newFiber.effectTag = Placement;
|
4387 | return lastPlacedIndex;
|
4388 | } else {
|
4389 |
|
4390 | return oldIndex;
|
4391 | }
|
4392 | } else {
|
4393 |
|
4394 | newFiber.effectTag = Placement;
|
4395 | return lastPlacedIndex;
|
4396 | }
|
4397 | }
|
4398 |
|
4399 | function placeSingleChild(newFiber) {
|
4400 |
|
4401 |
|
4402 | if (shouldTrackSideEffects && newFiber.alternate === null) {
|
4403 | newFiber.effectTag = Placement;
|
4404 | }
|
4405 |
|
4406 | return newFiber;
|
4407 | }
|
4408 |
|
4409 | function updateTextNode(returnFiber, current, textContent, expirationTime) {
|
4410 | if (current === null || current.tag !== HostText) {
|
4411 |
|
4412 | var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
|
4413 | created.return = returnFiber;
|
4414 | return created;
|
4415 | } else {
|
4416 |
|
4417 | var existing = useFiber(current, textContent);
|
4418 | existing.return = returnFiber;
|
4419 | return existing;
|
4420 | }
|
4421 | }
|
4422 |
|
4423 | function updateElement(returnFiber, current, element, expirationTime) {
|
4424 | if (current !== null) {
|
4425 | if (current.elementType === element.type || (
|
4426 | isCompatibleFamilyForHotReloading(current, element) )) {
|
4427 |
|
4428 | var existing = useFiber(current, element.props);
|
4429 | existing.ref = coerceRef(returnFiber, current, element);
|
4430 | existing.return = returnFiber;
|
4431 |
|
4432 | {
|
4433 | existing._debugSource = element._source;
|
4434 | existing._debugOwner = element._owner;
|
4435 | }
|
4436 |
|
4437 | return existing;
|
4438 | }
|
4439 | }
|
4440 |
|
4441 |
|
4442 | var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
|
4443 | created.ref = coerceRef(returnFiber, current, element);
|
4444 | created.return = returnFiber;
|
4445 | return created;
|
4446 | }
|
4447 |
|
4448 | function updatePortal(returnFiber, current, portal, expirationTime) {
|
4449 | if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {
|
4450 |
|
4451 | var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
|
4452 | created.return = returnFiber;
|
4453 | return created;
|
4454 | } else {
|
4455 |
|
4456 | var existing = useFiber(current, portal.children || []);
|
4457 | existing.return = returnFiber;
|
4458 | return existing;
|
4459 | }
|
4460 | }
|
4461 |
|
4462 | function updateFragment(returnFiber, current, fragment, expirationTime, key) {
|
4463 | if (current === null || current.tag !== Fragment) {
|
4464 |
|
4465 | var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
|
4466 | created.return = returnFiber;
|
4467 | return created;
|
4468 | } else {
|
4469 |
|
4470 | var existing = useFiber(current, fragment);
|
4471 | existing.return = returnFiber;
|
4472 | return existing;
|
4473 | }
|
4474 | }
|
4475 |
|
4476 | function createChild(returnFiber, newChild, expirationTime) {
|
4477 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
4478 |
|
4479 |
|
4480 |
|
4481 | var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
|
4482 | created.return = returnFiber;
|
4483 | return created;
|
4484 | }
|
4485 |
|
4486 | if (typeof newChild === 'object' && newChild !== null) {
|
4487 | switch (newChild.$$typeof) {
|
4488 | case REACT_ELEMENT_TYPE:
|
4489 | {
|
4490 | var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
|
4491 |
|
4492 | _created.ref = coerceRef(returnFiber, null, newChild);
|
4493 | _created.return = returnFiber;
|
4494 | return _created;
|
4495 | }
|
4496 |
|
4497 | case REACT_PORTAL_TYPE:
|
4498 | {
|
4499 | var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
|
4500 |
|
4501 | _created2.return = returnFiber;
|
4502 | return _created2;
|
4503 | }
|
4504 | }
|
4505 |
|
4506 | if (isArray$1(newChild) || getIteratorFn(newChild)) {
|
4507 | var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
|
4508 |
|
4509 | _created3.return = returnFiber;
|
4510 | return _created3;
|
4511 | }
|
4512 |
|
4513 | throwOnInvalidObjectType(returnFiber, newChild);
|
4514 | }
|
4515 |
|
4516 | {
|
4517 | if (typeof newChild === 'function') {
|
4518 | warnOnFunctionType();
|
4519 | }
|
4520 | }
|
4521 |
|
4522 | return null;
|
4523 | }
|
4524 |
|
4525 | function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
|
4526 |
|
4527 | var key = oldFiber !== null ? oldFiber.key : null;
|
4528 |
|
4529 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
4530 |
|
4531 |
|
4532 |
|
4533 | if (key !== null) {
|
4534 | return null;
|
4535 | }
|
4536 |
|
4537 | return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
|
4538 | }
|
4539 |
|
4540 | if (typeof newChild === 'object' && newChild !== null) {
|
4541 | switch (newChild.$$typeof) {
|
4542 | case REACT_ELEMENT_TYPE:
|
4543 | {
|
4544 | if (newChild.key === key) {
|
4545 | if (newChild.type === REACT_FRAGMENT_TYPE) {
|
4546 | return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
|
4547 | }
|
4548 |
|
4549 | return updateElement(returnFiber, oldFiber, newChild, expirationTime);
|
4550 | } else {
|
4551 | return null;
|
4552 | }
|
4553 | }
|
4554 |
|
4555 | case REACT_PORTAL_TYPE:
|
4556 | {
|
4557 | if (newChild.key === key) {
|
4558 | return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
|
4559 | } else {
|
4560 | return null;
|
4561 | }
|
4562 | }
|
4563 | }
|
4564 |
|
4565 | if (isArray$1(newChild) || getIteratorFn(newChild)) {
|
4566 | if (key !== null) {
|
4567 | return null;
|
4568 | }
|
4569 |
|
4570 | return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
|
4571 | }
|
4572 |
|
4573 | throwOnInvalidObjectType(returnFiber, newChild);
|
4574 | }
|
4575 |
|
4576 | {
|
4577 | if (typeof newChild === 'function') {
|
4578 | warnOnFunctionType();
|
4579 | }
|
4580 | }
|
4581 |
|
4582 | return null;
|
4583 | }
|
4584 |
|
4585 | function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
|
4586 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
4587 |
|
4588 |
|
4589 | var matchedFiber = existingChildren.get(newIdx) || null;
|
4590 | return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
|
4591 | }
|
4592 |
|
4593 | if (typeof newChild === 'object' && newChild !== null) {
|
4594 | switch (newChild.$$typeof) {
|
4595 | case REACT_ELEMENT_TYPE:
|
4596 | {
|
4597 | var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
4598 |
|
4599 | if (newChild.type === REACT_FRAGMENT_TYPE) {
|
4600 | return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
|
4601 | }
|
4602 |
|
4603 | return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
|
4604 | }
|
4605 |
|
4606 | case REACT_PORTAL_TYPE:
|
4607 | {
|
4608 | var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
4609 |
|
4610 | return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
|
4611 | }
|
4612 | }
|
4613 |
|
4614 | if (isArray$1(newChild) || getIteratorFn(newChild)) {
|
4615 | var _matchedFiber3 = existingChildren.get(newIdx) || null;
|
4616 |
|
4617 | return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
|
4618 | }
|
4619 |
|
4620 | throwOnInvalidObjectType(returnFiber, newChild);
|
4621 | }
|
4622 |
|
4623 | {
|
4624 | if (typeof newChild === 'function') {
|
4625 | warnOnFunctionType();
|
4626 | }
|
4627 | }
|
4628 |
|
4629 | return null;
|
4630 | }
|
4631 | |
4632 |
|
4633 |
|
4634 |
|
4635 |
|
4636 | function warnOnInvalidKey(child, knownKeys) {
|
4637 | {
|
4638 | if (typeof child !== 'object' || child === null) {
|
4639 | return knownKeys;
|
4640 | }
|
4641 |
|
4642 | switch (child.$$typeof) {
|
4643 | case REACT_ELEMENT_TYPE:
|
4644 | case REACT_PORTAL_TYPE:
|
4645 | warnForMissingKey(child);
|
4646 | var key = child.key;
|
4647 |
|
4648 | if (typeof key !== 'string') {
|
4649 | break;
|
4650 | }
|
4651 |
|
4652 | if (knownKeys === null) {
|
4653 | knownKeys = new Set();
|
4654 | knownKeys.add(key);
|
4655 | break;
|
4656 | }
|
4657 |
|
4658 | if (!knownKeys.has(key)) {
|
4659 | knownKeys.add(key);
|
4660 | break;
|
4661 | }
|
4662 |
|
4663 | error('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);
|
4664 |
|
4665 | break;
|
4666 | }
|
4667 | }
|
4668 |
|
4669 | return knownKeys;
|
4670 | }
|
4671 |
|
4672 | function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
|
4673 |
|
4674 |
|
4675 |
|
4676 |
|
4677 |
|
4678 |
|
4679 |
|
4680 |
|
4681 |
|
4682 |
|
4683 |
|
4684 |
|
4685 |
|
4686 |
|
4687 |
|
4688 | {
|
4689 |
|
4690 | var knownKeys = null;
|
4691 |
|
4692 | for (var i = 0; i < newChildren.length; i++) {
|
4693 | var child = newChildren[i];
|
4694 | knownKeys = warnOnInvalidKey(child, knownKeys);
|
4695 | }
|
4696 | }
|
4697 |
|
4698 | var resultingFirstChild = null;
|
4699 | var previousNewFiber = null;
|
4700 | var oldFiber = currentFirstChild;
|
4701 | var lastPlacedIndex = 0;
|
4702 | var newIdx = 0;
|
4703 | var nextOldFiber = null;
|
4704 |
|
4705 | for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
|
4706 | if (oldFiber.index > newIdx) {
|
4707 | nextOldFiber = oldFiber;
|
4708 | oldFiber = null;
|
4709 | } else {
|
4710 | nextOldFiber = oldFiber.sibling;
|
4711 | }
|
4712 |
|
4713 | var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
|
4714 |
|
4715 | if (newFiber === null) {
|
4716 |
|
4717 |
|
4718 |
|
4719 |
|
4720 | if (oldFiber === null) {
|
4721 | oldFiber = nextOldFiber;
|
4722 | }
|
4723 |
|
4724 | break;
|
4725 | }
|
4726 |
|
4727 | if (shouldTrackSideEffects) {
|
4728 | if (oldFiber && newFiber.alternate === null) {
|
4729 |
|
4730 |
|
4731 | deleteChild(returnFiber, oldFiber);
|
4732 | }
|
4733 | }
|
4734 |
|
4735 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
4736 |
|
4737 | if (previousNewFiber === null) {
|
4738 |
|
4739 | resultingFirstChild = newFiber;
|
4740 | } else {
|
4741 |
|
4742 |
|
4743 |
|
4744 |
|
4745 | previousNewFiber.sibling = newFiber;
|
4746 | }
|
4747 |
|
4748 | previousNewFiber = newFiber;
|
4749 | oldFiber = nextOldFiber;
|
4750 | }
|
4751 |
|
4752 | if (newIdx === newChildren.length) {
|
4753 |
|
4754 | deleteRemainingChildren(returnFiber, oldFiber);
|
4755 | return resultingFirstChild;
|
4756 | }
|
4757 |
|
4758 | if (oldFiber === null) {
|
4759 |
|
4760 |
|
4761 | for (; newIdx < newChildren.length; newIdx++) {
|
4762 | var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
|
4763 |
|
4764 | if (_newFiber === null) {
|
4765 | continue;
|
4766 | }
|
4767 |
|
4768 | lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
|
4769 |
|
4770 | if (previousNewFiber === null) {
|
4771 |
|
4772 | resultingFirstChild = _newFiber;
|
4773 | } else {
|
4774 | previousNewFiber.sibling = _newFiber;
|
4775 | }
|
4776 |
|
4777 | previousNewFiber = _newFiber;
|
4778 | }
|
4779 |
|
4780 | return resultingFirstChild;
|
4781 | }
|
4782 |
|
4783 |
|
4784 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
4785 |
|
4786 | for (; newIdx < newChildren.length; newIdx++) {
|
4787 | var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
|
4788 |
|
4789 | if (_newFiber2 !== null) {
|
4790 | if (shouldTrackSideEffects) {
|
4791 | if (_newFiber2.alternate !== null) {
|
4792 |
|
4793 |
|
4794 |
|
4795 |
|
4796 | existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
|
4797 | }
|
4798 | }
|
4799 |
|
4800 | lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
|
4801 |
|
4802 | if (previousNewFiber === null) {
|
4803 | resultingFirstChild = _newFiber2;
|
4804 | } else {
|
4805 | previousNewFiber.sibling = _newFiber2;
|
4806 | }
|
4807 |
|
4808 | previousNewFiber = _newFiber2;
|
4809 | }
|
4810 | }
|
4811 |
|
4812 | if (shouldTrackSideEffects) {
|
4813 |
|
4814 |
|
4815 | existingChildren.forEach(function (child) {
|
4816 | return deleteChild(returnFiber, child);
|
4817 | });
|
4818 | }
|
4819 |
|
4820 | return resultingFirstChild;
|
4821 | }
|
4822 |
|
4823 | function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
|
4824 |
|
4825 |
|
4826 | var iteratorFn = getIteratorFn(newChildrenIterable);
|
4827 |
|
4828 | if (!(typeof iteratorFn === 'function')) {
|
4829 | {
|
4830 | throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." );
|
4831 | }
|
4832 | }
|
4833 |
|
4834 | {
|
4835 |
|
4836 |
|
4837 | if (typeof Symbol === 'function' &&
|
4838 | newChildrenIterable[Symbol.toStringTag] === 'Generator') {
|
4839 | if (!didWarnAboutGenerators) {
|
4840 | error('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.');
|
4841 | }
|
4842 |
|
4843 | didWarnAboutGenerators = true;
|
4844 | }
|
4845 |
|
4846 |
|
4847 | if (newChildrenIterable.entries === iteratorFn) {
|
4848 | if (!didWarnAboutMaps) {
|
4849 | error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');
|
4850 | }
|
4851 |
|
4852 | didWarnAboutMaps = true;
|
4853 | }
|
4854 |
|
4855 |
|
4856 |
|
4857 | var _newChildren = iteratorFn.call(newChildrenIterable);
|
4858 |
|
4859 | if (_newChildren) {
|
4860 | var knownKeys = null;
|
4861 |
|
4862 | var _step = _newChildren.next();
|
4863 |
|
4864 | for (; !_step.done; _step = _newChildren.next()) {
|
4865 | var child = _step.value;
|
4866 | knownKeys = warnOnInvalidKey(child, knownKeys);
|
4867 | }
|
4868 | }
|
4869 | }
|
4870 |
|
4871 | var newChildren = iteratorFn.call(newChildrenIterable);
|
4872 |
|
4873 | if (!(newChildren != null)) {
|
4874 | {
|
4875 | throw Error( "An iterable object provided no iterator." );
|
4876 | }
|
4877 | }
|
4878 |
|
4879 | var resultingFirstChild = null;
|
4880 | var previousNewFiber = null;
|
4881 | var oldFiber = currentFirstChild;
|
4882 | var lastPlacedIndex = 0;
|
4883 | var newIdx = 0;
|
4884 | var nextOldFiber = null;
|
4885 | var step = newChildren.next();
|
4886 |
|
4887 | for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
|
4888 | if (oldFiber.index > newIdx) {
|
4889 | nextOldFiber = oldFiber;
|
4890 | oldFiber = null;
|
4891 | } else {
|
4892 | nextOldFiber = oldFiber.sibling;
|
4893 | }
|
4894 |
|
4895 | var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
|
4896 |
|
4897 | if (newFiber === null) {
|
4898 |
|
4899 |
|
4900 |
|
4901 |
|
4902 | if (oldFiber === null) {
|
4903 | oldFiber = nextOldFiber;
|
4904 | }
|
4905 |
|
4906 | break;
|
4907 | }
|
4908 |
|
4909 | if (shouldTrackSideEffects) {
|
4910 | if (oldFiber && newFiber.alternate === null) {
|
4911 |
|
4912 |
|
4913 | deleteChild(returnFiber, oldFiber);
|
4914 | }
|
4915 | }
|
4916 |
|
4917 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
4918 |
|
4919 | if (previousNewFiber === null) {
|
4920 |
|
4921 | resultingFirstChild = newFiber;
|
4922 | } else {
|
4923 |
|
4924 |
|
4925 |
|
4926 |
|
4927 | previousNewFiber.sibling = newFiber;
|
4928 | }
|
4929 |
|
4930 | previousNewFiber = newFiber;
|
4931 | oldFiber = nextOldFiber;
|
4932 | }
|
4933 |
|
4934 | if (step.done) {
|
4935 |
|
4936 | deleteRemainingChildren(returnFiber, oldFiber);
|
4937 | return resultingFirstChild;
|
4938 | }
|
4939 |
|
4940 | if (oldFiber === null) {
|
4941 |
|
4942 |
|
4943 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
4944 | var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
|
4945 |
|
4946 | if (_newFiber3 === null) {
|
4947 | continue;
|
4948 | }
|
4949 |
|
4950 | lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
|
4951 |
|
4952 | if (previousNewFiber === null) {
|
4953 |
|
4954 | resultingFirstChild = _newFiber3;
|
4955 | } else {
|
4956 | previousNewFiber.sibling = _newFiber3;
|
4957 | }
|
4958 |
|
4959 | previousNewFiber = _newFiber3;
|
4960 | }
|
4961 |
|
4962 | return resultingFirstChild;
|
4963 | }
|
4964 |
|
4965 |
|
4966 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
4967 |
|
4968 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
4969 | var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
|
4970 |
|
4971 | if (_newFiber4 !== null) {
|
4972 | if (shouldTrackSideEffects) {
|
4973 | if (_newFiber4.alternate !== null) {
|
4974 |
|
4975 |
|
4976 |
|
4977 |
|
4978 | existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
|
4979 | }
|
4980 | }
|
4981 |
|
4982 | lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
|
4983 |
|
4984 | if (previousNewFiber === null) {
|
4985 | resultingFirstChild = _newFiber4;
|
4986 | } else {
|
4987 | previousNewFiber.sibling = _newFiber4;
|
4988 | }
|
4989 |
|
4990 | previousNewFiber = _newFiber4;
|
4991 | }
|
4992 | }
|
4993 |
|
4994 | if (shouldTrackSideEffects) {
|
4995 |
|
4996 |
|
4997 | existingChildren.forEach(function (child) {
|
4998 | return deleteChild(returnFiber, child);
|
4999 | });
|
5000 | }
|
5001 |
|
5002 | return resultingFirstChild;
|
5003 | }
|
5004 |
|
5005 | function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
|
5006 |
|
5007 |
|
5008 | if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
|
5009 |
|
5010 |
|
5011 | deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
|
5012 | var existing = useFiber(currentFirstChild, textContent);
|
5013 | existing.return = returnFiber;
|
5014 | return existing;
|
5015 | }
|
5016 |
|
5017 |
|
5018 |
|
5019 | deleteRemainingChildren(returnFiber, currentFirstChild);
|
5020 | var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
|
5021 | created.return = returnFiber;
|
5022 | return created;
|
5023 | }
|
5024 |
|
5025 | function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
|
5026 | var key = element.key;
|
5027 | var child = currentFirstChild;
|
5028 |
|
5029 | while (child !== null) {
|
5030 |
|
5031 |
|
5032 | if (child.key === key) {
|
5033 | switch (child.tag) {
|
5034 | case Fragment:
|
5035 | {
|
5036 | if (element.type === REACT_FRAGMENT_TYPE) {
|
5037 | deleteRemainingChildren(returnFiber, child.sibling);
|
5038 | var existing = useFiber(child, element.props.children);
|
5039 | existing.return = returnFiber;
|
5040 |
|
5041 | {
|
5042 | existing._debugSource = element._source;
|
5043 | existing._debugOwner = element._owner;
|
5044 | }
|
5045 |
|
5046 | return existing;
|
5047 | }
|
5048 |
|
5049 | break;
|
5050 | }
|
5051 |
|
5052 | case Block:
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 | default:
|
5058 | {
|
5059 | if (child.elementType === element.type || (
|
5060 | isCompatibleFamilyForHotReloading(child, element) )) {
|
5061 | deleteRemainingChildren(returnFiber, child.sibling);
|
5062 |
|
5063 | var _existing3 = useFiber(child, element.props);
|
5064 |
|
5065 | _existing3.ref = coerceRef(returnFiber, child, element);
|
5066 | _existing3.return = returnFiber;
|
5067 |
|
5068 | {
|
5069 | _existing3._debugSource = element._source;
|
5070 | _existing3._debugOwner = element._owner;
|
5071 | }
|
5072 |
|
5073 | return _existing3;
|
5074 | }
|
5075 |
|
5076 | break;
|
5077 | }
|
5078 | }
|
5079 |
|
5080 |
|
5081 | deleteRemainingChildren(returnFiber, child);
|
5082 | break;
|
5083 | } else {
|
5084 | deleteChild(returnFiber, child);
|
5085 | }
|
5086 |
|
5087 | child = child.sibling;
|
5088 | }
|
5089 |
|
5090 | if (element.type === REACT_FRAGMENT_TYPE) {
|
5091 | var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
|
5092 | created.return = returnFiber;
|
5093 | return created;
|
5094 | } else {
|
5095 | var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
|
5096 |
|
5097 | _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
|
5098 | _created4.return = returnFiber;
|
5099 | return _created4;
|
5100 | }
|
5101 | }
|
5102 |
|
5103 | function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
|
5104 | var key = portal.key;
|
5105 | var child = currentFirstChild;
|
5106 |
|
5107 | while (child !== null) {
|
5108 |
|
5109 |
|
5110 | if (child.key === key) {
|
5111 | if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
|
5112 | deleteRemainingChildren(returnFiber, child.sibling);
|
5113 | var existing = useFiber(child, portal.children || []);
|
5114 | existing.return = returnFiber;
|
5115 | return existing;
|
5116 | } else {
|
5117 | deleteRemainingChildren(returnFiber, child);
|
5118 | break;
|
5119 | }
|
5120 | } else {
|
5121 | deleteChild(returnFiber, child);
|
5122 | }
|
5123 |
|
5124 | child = child.sibling;
|
5125 | }
|
5126 |
|
5127 | var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
|
5128 | created.return = returnFiber;
|
5129 | return created;
|
5130 | }
|
5131 |
|
5132 |
|
5133 |
|
5134 |
|
5135 | function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
|
5136 |
|
5137 |
|
5138 |
|
5139 |
|
5140 |
|
5141 |
|
5142 |
|
5143 | var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
5144 |
|
5145 | if (isUnkeyedTopLevelFragment) {
|
5146 | newChild = newChild.props.children;
|
5147 | }
|
5148 |
|
5149 |
|
5150 | var isObject = typeof newChild === 'object' && newChild !== null;
|
5151 |
|
5152 | if (isObject) {
|
5153 | switch (newChild.$$typeof) {
|
5154 | case REACT_ELEMENT_TYPE:
|
5155 | return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
|
5156 |
|
5157 | case REACT_PORTAL_TYPE:
|
5158 | return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
|
5159 | }
|
5160 | }
|
5161 |
|
5162 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
5163 | return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
|
5164 | }
|
5165 |
|
5166 | if (isArray$1(newChild)) {
|
5167 | return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
|
5168 | }
|
5169 |
|
5170 | if (getIteratorFn(newChild)) {
|
5171 | return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
|
5172 | }
|
5173 |
|
5174 | if (isObject) {
|
5175 | throwOnInvalidObjectType(returnFiber, newChild);
|
5176 | }
|
5177 |
|
5178 | {
|
5179 | if (typeof newChild === 'function') {
|
5180 | warnOnFunctionType();
|
5181 | }
|
5182 | }
|
5183 |
|
5184 | if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
|
5185 |
|
5186 |
|
5187 |
|
5188 | switch (returnFiber.tag) {
|
5189 | case ClassComponent:
|
5190 | {
|
5191 | {
|
5192 | var instance = returnFiber.stateNode;
|
5193 |
|
5194 | if (instance.render._isMockFunction) {
|
5195 |
|
5196 | break;
|
5197 | }
|
5198 | }
|
5199 | }
|
5200 |
|
5201 |
|
5202 |
|
5203 |
|
5204 | case FunctionComponent:
|
5205 | {
|
5206 | var Component = returnFiber.type;
|
5207 |
|
5208 | {
|
5209 | {
|
5210 | throw 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." );
|
5211 | }
|
5212 | }
|
5213 | }
|
5214 | }
|
5215 | }
|
5216 |
|
5217 |
|
5218 | return deleteRemainingChildren(returnFiber, currentFirstChild);
|
5219 | }
|
5220 |
|
5221 | return reconcileChildFibers;
|
5222 | }
|
5223 |
|
5224 | var reconcileChildFibers = ChildReconciler(true);
|
5225 | var mountChildFibers = ChildReconciler(false);
|
5226 | function cloneChildFibers(current, workInProgress) {
|
5227 | if (!(current === null || workInProgress.child === current.child)) {
|
5228 | {
|
5229 | throw Error( "Resuming work not yet implemented." );
|
5230 | }
|
5231 | }
|
5232 |
|
5233 | if (workInProgress.child === null) {
|
5234 | return;
|
5235 | }
|
5236 |
|
5237 | var currentChild = workInProgress.child;
|
5238 | var newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
|
5239 | workInProgress.child = newChild;
|
5240 | newChild.return = workInProgress;
|
5241 |
|
5242 | while (currentChild.sibling !== null) {
|
5243 | currentChild = currentChild.sibling;
|
5244 | newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps);
|
5245 | newChild.return = workInProgress;
|
5246 | }
|
5247 |
|
5248 | newChild.sibling = null;
|
5249 | }
|
5250 |
|
5251 | function resetChildFibers(workInProgress, renderExpirationTime) {
|
5252 | var child = workInProgress.child;
|
5253 |
|
5254 | while (child !== null) {
|
5255 | resetWorkInProgress(child, renderExpirationTime);
|
5256 | child = child.sibling;
|
5257 | }
|
5258 | }
|
5259 |
|
5260 | var NO_CONTEXT$1 = {};
|
5261 | var contextStackCursor$1 = createCursor(NO_CONTEXT$1);
|
5262 | var contextFiberStackCursor = createCursor(NO_CONTEXT$1);
|
5263 | var rootInstanceStackCursor = createCursor(NO_CONTEXT$1);
|
5264 |
|
5265 | function requiredContext(c) {
|
5266 | if (!(c !== NO_CONTEXT$1)) {
|
5267 | {
|
5268 | throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." );
|
5269 | }
|
5270 | }
|
5271 |
|
5272 | return c;
|
5273 | }
|
5274 |
|
5275 | function getRootHostContainer() {
|
5276 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
5277 | return rootInstance;
|
5278 | }
|
5279 |
|
5280 | function pushHostContainer(fiber, nextRootInstance) {
|
5281 |
|
5282 |
|
5283 | push(rootInstanceStackCursor, nextRootInstance, fiber);
|
5284 |
|
5285 |
|
5286 | push(contextFiberStackCursor, fiber, fiber);
|
5287 |
|
5288 |
|
5289 |
|
5290 |
|
5291 |
|
5292 | push(contextStackCursor$1, NO_CONTEXT$1, fiber);
|
5293 | var nextRootContext = getRootHostContext();
|
5294 |
|
5295 | pop(contextStackCursor$1, fiber);
|
5296 | push(contextStackCursor$1, nextRootContext, fiber);
|
5297 | }
|
5298 |
|
5299 | function popHostContainer(fiber) {
|
5300 | pop(contextStackCursor$1, fiber);
|
5301 | pop(contextFiberStackCursor, fiber);
|
5302 | pop(rootInstanceStackCursor, fiber);
|
5303 | }
|
5304 |
|
5305 | function getHostContext() {
|
5306 | var context = requiredContext(contextStackCursor$1.current);
|
5307 | return context;
|
5308 | }
|
5309 |
|
5310 | function pushHostContext(fiber) {
|
5311 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
5312 | var context = requiredContext(contextStackCursor$1.current);
|
5313 | var nextContext = getChildHostContext(context, fiber.type);
|
5314 |
|
5315 | if (context === nextContext) {
|
5316 | return;
|
5317 | }
|
5318 |
|
5319 |
|
5320 |
|
5321 | push(contextFiberStackCursor, fiber, fiber);
|
5322 | push(contextStackCursor$1, nextContext, fiber);
|
5323 | }
|
5324 |
|
5325 | function popHostContext(fiber) {
|
5326 |
|
5327 |
|
5328 | if (contextFiberStackCursor.current !== fiber) {
|
5329 | return;
|
5330 | }
|
5331 |
|
5332 | pop(contextStackCursor$1, fiber);
|
5333 | pop(contextFiberStackCursor, fiber);
|
5334 | }
|
5335 |
|
5336 | var DefaultSuspenseContext = 0;
|
5337 |
|
5338 |
|
5339 |
|
5340 |
|
5341 | var SubtreeSuspenseContextMask = 1;
|
5342 |
|
5343 |
|
5344 |
|
5345 |
|
5346 |
|
5347 |
|
5348 |
|
5349 | var InvisibleParentSuspenseContext = 1;
|
5350 |
|
5351 |
|
5352 |
|
5353 | var ForceSuspenseFallback = 2;
|
5354 | var suspenseStackCursor = createCursor(DefaultSuspenseContext);
|
5355 | function hasSuspenseContext(parentContext, flag) {
|
5356 | return (parentContext & flag) !== 0;
|
5357 | }
|
5358 | function setDefaultShallowSuspenseContext(parentContext) {
|
5359 | return parentContext & SubtreeSuspenseContextMask;
|
5360 | }
|
5361 | function setShallowSuspenseContext(parentContext, shallowContext) {
|
5362 | return parentContext & SubtreeSuspenseContextMask | shallowContext;
|
5363 | }
|
5364 | function addSubtreeSuspenseContext(parentContext, subtreeContext) {
|
5365 | return parentContext | subtreeContext;
|
5366 | }
|
5367 | function pushSuspenseContext(fiber, newContext) {
|
5368 | push(suspenseStackCursor, newContext, fiber);
|
5369 | }
|
5370 | function popSuspenseContext(fiber) {
|
5371 | pop(suspenseStackCursor, fiber);
|
5372 | }
|
5373 |
|
5374 | function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
|
5375 |
|
5376 |
|
5377 | var nextState = workInProgress.memoizedState;
|
5378 |
|
5379 | if (nextState !== null) {
|
5380 | if (nextState.dehydrated !== null) {
|
5381 |
|
5382 | return true;
|
5383 | }
|
5384 |
|
5385 | return false;
|
5386 | }
|
5387 |
|
5388 | var props = workInProgress.memoizedProps;
|
5389 |
|
5390 | if (props.fallback === undefined) {
|
5391 | return false;
|
5392 | }
|
5393 |
|
5394 |
|
5395 | if (props.unstable_avoidThisFallback !== true) {
|
5396 | return true;
|
5397 | }
|
5398 |
|
5399 |
|
5400 |
|
5401 | if (hasInvisibleParent) {
|
5402 | return false;
|
5403 | }
|
5404 |
|
5405 |
|
5406 | return true;
|
5407 | }
|
5408 | function findFirstSuspended(row) {
|
5409 | var node = row;
|
5410 |
|
5411 | while (node !== null) {
|
5412 | if (node.tag === SuspenseComponent) {
|
5413 | var state = node.memoizedState;
|
5414 |
|
5415 | if (state !== null) {
|
5416 | var dehydrated = state.dehydrated;
|
5417 |
|
5418 | if (dehydrated === null || isSuspenseInstancePending() || isSuspenseInstanceFallback()) {
|
5419 | return node;
|
5420 | }
|
5421 | }
|
5422 | } else if (node.tag === SuspenseListComponent &&
|
5423 |
|
5424 | node.memoizedProps.revealOrder !== undefined) {
|
5425 | var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
|
5426 |
|
5427 | if (didSuspend) {
|
5428 | return node;
|
5429 | }
|
5430 | } else if (node.child !== null) {
|
5431 | node.child.return = node;
|
5432 | node = node.child;
|
5433 | continue;
|
5434 | }
|
5435 |
|
5436 | if (node === row) {
|
5437 | return null;
|
5438 | }
|
5439 |
|
5440 | while (node.sibling === null) {
|
5441 | if (node.return === null || node.return === row) {
|
5442 | return null;
|
5443 | }
|
5444 |
|
5445 | node = node.return;
|
5446 | }
|
5447 |
|
5448 | node.sibling.return = node.return;
|
5449 | node = node.sibling;
|
5450 | }
|
5451 |
|
5452 | return null;
|
5453 | }
|
5454 |
|
5455 | function createDeprecatedResponderListener(responder, props) {
|
5456 | var eventResponderListener = {
|
5457 | responder: responder,
|
5458 | props: props
|
5459 | };
|
5460 |
|
5461 | {
|
5462 | Object.freeze(eventResponderListener);
|
5463 | }
|
5464 |
|
5465 | return eventResponderListener;
|
5466 | }
|
5467 |
|
5468 | var HasEffect =
|
5469 |
|
5470 | 1;
|
5471 |
|
5472 | var Layout =
|
5473 |
|
5474 | 2;
|
5475 | var Passive$1 =
|
5476 |
|
5477 | 4;
|
5478 |
|
5479 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
|
5480 | ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
|
5481 | var didWarnAboutMismatchedHooksForComponent;
|
5482 |
|
5483 | {
|
5484 | didWarnAboutMismatchedHooksForComponent = new Set();
|
5485 | }
|
5486 |
|
5487 |
|
5488 | var renderExpirationTime = NoWork;
|
5489 |
|
5490 |
|
5491 | var currentlyRenderingFiber$1 = null;
|
5492 |
|
5493 |
|
5494 |
|
5495 |
|
5496 | var currentHook = null;
|
5497 | var workInProgressHook = null;
|
5498 |
|
5499 |
|
5500 |
|
5501 |
|
5502 | var didScheduleRenderPhaseUpdate = false;
|
5503 | var RE_RENDER_LIMIT = 25;
|
5504 |
|
5505 | var currentHookNameInDev = null;
|
5506 |
|
5507 |
|
5508 |
|
5509 | var hookTypesDev = null;
|
5510 | var hookTypesUpdateIndexDev = -1;
|
5511 |
|
5512 |
|
5513 |
|
5514 | var ignorePreviousDependencies = false;
|
5515 |
|
5516 | function mountHookTypesDev() {
|
5517 | {
|
5518 | var hookName = currentHookNameInDev;
|
5519 |
|
5520 | if (hookTypesDev === null) {
|
5521 | hookTypesDev = [hookName];
|
5522 | } else {
|
5523 | hookTypesDev.push(hookName);
|
5524 | }
|
5525 | }
|
5526 | }
|
5527 |
|
5528 | function updateHookTypesDev() {
|
5529 | {
|
5530 | var hookName = currentHookNameInDev;
|
5531 |
|
5532 | if (hookTypesDev !== null) {
|
5533 | hookTypesUpdateIndexDev++;
|
5534 |
|
5535 | if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
|
5536 | warnOnHookMismatchInDev(hookName);
|
5537 | }
|
5538 | }
|
5539 | }
|
5540 | }
|
5541 |
|
5542 | function checkDepsAreArrayDev(deps) {
|
5543 | {
|
5544 | if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
|
5545 |
|
5546 |
|
5547 | error('%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);
|
5548 | }
|
5549 | }
|
5550 | }
|
5551 |
|
5552 | function warnOnHookMismatchInDev(currentHookName) {
|
5553 | {
|
5554 | var componentName = getComponentName(currentlyRenderingFiber$1.type);
|
5555 |
|
5556 | if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
|
5557 | didWarnAboutMismatchedHooksForComponent.add(componentName);
|
5558 |
|
5559 | if (hookTypesDev !== null) {
|
5560 | var table = '';
|
5561 | var secondColumnStart = 30;
|
5562 |
|
5563 | for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
|
5564 | var oldHookName = hookTypesDev[i];
|
5565 | var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
|
5566 | var row = i + 1 + ". " + oldHookName;
|
5567 |
|
5568 |
|
5569 | while (row.length < secondColumnStart) {
|
5570 | row += ' ';
|
5571 | }
|
5572 |
|
5573 | row += newHookName + '\n';
|
5574 | table += row;
|
5575 | }
|
5576 |
|
5577 | error('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);
|
5578 | }
|
5579 | }
|
5580 | }
|
5581 | }
|
5582 |
|
5583 | function throwInvalidHookError() {
|
5584 | {
|
5585 | {
|
5586 | throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." );
|
5587 | }
|
5588 | }
|
5589 | }
|
5590 |
|
5591 | function areHookInputsEqual(nextDeps, prevDeps) {
|
5592 | {
|
5593 | if (ignorePreviousDependencies) {
|
5594 |
|
5595 | return false;
|
5596 | }
|
5597 | }
|
5598 |
|
5599 | if (prevDeps === null) {
|
5600 | {
|
5601 | error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
|
5602 | }
|
5603 |
|
5604 | return false;
|
5605 | }
|
5606 |
|
5607 | {
|
5608 |
|
5609 |
|
5610 | if (nextDeps.length !== prevDeps.length) {
|
5611 | error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]");
|
5612 | }
|
5613 | }
|
5614 |
|
5615 | for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
5616 | if (objectIs(nextDeps[i], prevDeps[i])) {
|
5617 | continue;
|
5618 | }
|
5619 |
|
5620 | return false;
|
5621 | }
|
5622 |
|
5623 | return true;
|
5624 | }
|
5625 |
|
5626 | function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderExpirationTime) {
|
5627 | renderExpirationTime = nextRenderExpirationTime;
|
5628 | currentlyRenderingFiber$1 = workInProgress;
|
5629 |
|
5630 | {
|
5631 | hookTypesDev = current !== null ? current._debugHookTypes : null;
|
5632 | hookTypesUpdateIndexDev = -1;
|
5633 |
|
5634 | ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
|
5635 | }
|
5636 |
|
5637 | workInProgress.memoizedState = null;
|
5638 | workInProgress.updateQueue = null;
|
5639 | workInProgress.expirationTime = NoWork;
|
5640 |
|
5641 |
|
5642 |
|
5643 |
|
5644 |
|
5645 |
|
5646 |
|
5647 |
|
5648 |
|
5649 |
|
5650 | {
|
5651 | if (current !== null && current.memoizedState !== null) {
|
5652 | ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV;
|
5653 | } else if (hookTypesDev !== null) {
|
5654 |
|
5655 |
|
5656 |
|
5657 |
|
5658 |
|
5659 | ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV;
|
5660 | } else {
|
5661 | ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV;
|
5662 | }
|
5663 | }
|
5664 |
|
5665 | var children = Component(props, secondArg);
|
5666 |
|
5667 | if (workInProgress.expirationTime === renderExpirationTime) {
|
5668 |
|
5669 |
|
5670 | var numberOfReRenders = 0;
|
5671 |
|
5672 | do {
|
5673 | workInProgress.expirationTime = NoWork;
|
5674 |
|
5675 | if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
|
5676 | {
|
5677 | throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." );
|
5678 | }
|
5679 | }
|
5680 |
|
5681 | numberOfReRenders += 1;
|
5682 |
|
5683 | {
|
5684 |
|
5685 |
|
5686 | ignorePreviousDependencies = false;
|
5687 | }
|
5688 |
|
5689 |
|
5690 | currentHook = null;
|
5691 | workInProgressHook = null;
|
5692 | workInProgress.updateQueue = null;
|
5693 |
|
5694 | {
|
5695 |
|
5696 | hookTypesUpdateIndexDev = -1;
|
5697 | }
|
5698 |
|
5699 | ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV ;
|
5700 | children = Component(props, secondArg);
|
5701 | } while (workInProgress.expirationTime === renderExpirationTime);
|
5702 | }
|
5703 |
|
5704 |
|
5705 |
|
5706 | ReactCurrentDispatcher.current = ContextOnlyDispatcher;
|
5707 |
|
5708 | {
|
5709 | workInProgress._debugHookTypes = hookTypesDev;
|
5710 | }
|
5711 |
|
5712 |
|
5713 |
|
5714 | var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
|
5715 | renderExpirationTime = NoWork;
|
5716 | currentlyRenderingFiber$1 = null;
|
5717 | currentHook = null;
|
5718 | workInProgressHook = null;
|
5719 |
|
5720 | {
|
5721 | currentHookNameInDev = null;
|
5722 | hookTypesDev = null;
|
5723 | hookTypesUpdateIndexDev = -1;
|
5724 | }
|
5725 |
|
5726 | didScheduleRenderPhaseUpdate = false;
|
5727 |
|
5728 | if (!!didRenderTooFewHooks) {
|
5729 | {
|
5730 | throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." );
|
5731 | }
|
5732 | }
|
5733 |
|
5734 | return children;
|
5735 | }
|
5736 | function bailoutHooks(current, workInProgress, expirationTime) {
|
5737 | workInProgress.updateQueue = current.updateQueue;
|
5738 | workInProgress.effectTag &= ~(Passive | Update);
|
5739 |
|
5740 | if (current.expirationTime <= expirationTime) {
|
5741 | current.expirationTime = NoWork;
|
5742 | }
|
5743 | }
|
5744 | function resetHooksAfterThrow() {
|
5745 |
|
5746 |
|
5747 | ReactCurrentDispatcher.current = ContextOnlyDispatcher;
|
5748 |
|
5749 | if (didScheduleRenderPhaseUpdate) {
|
5750 |
|
5751 |
|
5752 |
|
5753 |
|
5754 |
|
5755 |
|
5756 |
|
5757 |
|
5758 | var hook = currentlyRenderingFiber$1.memoizedState;
|
5759 |
|
5760 | while (hook !== null) {
|
5761 | var queue = hook.queue;
|
5762 |
|
5763 | if (queue !== null) {
|
5764 | queue.pending = null;
|
5765 | }
|
5766 |
|
5767 | hook = hook.next;
|
5768 | }
|
5769 | }
|
5770 |
|
5771 | renderExpirationTime = NoWork;
|
5772 | currentlyRenderingFiber$1 = null;
|
5773 | currentHook = null;
|
5774 | workInProgressHook = null;
|
5775 |
|
5776 | {
|
5777 | hookTypesDev = null;
|
5778 | hookTypesUpdateIndexDev = -1;
|
5779 | currentHookNameInDev = null;
|
5780 | }
|
5781 |
|
5782 | didScheduleRenderPhaseUpdate = false;
|
5783 | }
|
5784 |
|
5785 | function mountWorkInProgressHook() {
|
5786 | var hook = {
|
5787 | memoizedState: null,
|
5788 | baseState: null,
|
5789 | baseQueue: null,
|
5790 | queue: null,
|
5791 | next: null
|
5792 | };
|
5793 |
|
5794 | if (workInProgressHook === null) {
|
5795 |
|
5796 | currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook;
|
5797 | } else {
|
5798 |
|
5799 | workInProgressHook = workInProgressHook.next = hook;
|
5800 | }
|
5801 |
|
5802 | return workInProgressHook;
|
5803 | }
|
5804 |
|
5805 | function updateWorkInProgressHook() {
|
5806 |
|
5807 |
|
5808 |
|
5809 |
|
5810 |
|
5811 | var nextCurrentHook;
|
5812 |
|
5813 | if (currentHook === null) {
|
5814 | var current = currentlyRenderingFiber$1.alternate;
|
5815 |
|
5816 | if (current !== null) {
|
5817 | nextCurrentHook = current.memoizedState;
|
5818 | } else {
|
5819 | nextCurrentHook = null;
|
5820 | }
|
5821 | } else {
|
5822 | nextCurrentHook = currentHook.next;
|
5823 | }
|
5824 |
|
5825 | var nextWorkInProgressHook;
|
5826 |
|
5827 | if (workInProgressHook === null) {
|
5828 | nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState;
|
5829 | } else {
|
5830 | nextWorkInProgressHook = workInProgressHook.next;
|
5831 | }
|
5832 |
|
5833 | if (nextWorkInProgressHook !== null) {
|
5834 |
|
5835 | workInProgressHook = nextWorkInProgressHook;
|
5836 | nextWorkInProgressHook = workInProgressHook.next;
|
5837 | currentHook = nextCurrentHook;
|
5838 | } else {
|
5839 |
|
5840 | if (!(nextCurrentHook !== null)) {
|
5841 | {
|
5842 | throw Error( "Rendered more hooks than during the previous render." );
|
5843 | }
|
5844 | }
|
5845 |
|
5846 | currentHook = nextCurrentHook;
|
5847 | var newHook = {
|
5848 | memoizedState: currentHook.memoizedState,
|
5849 | baseState: currentHook.baseState,
|
5850 | baseQueue: currentHook.baseQueue,
|
5851 | queue: currentHook.queue,
|
5852 | next: null
|
5853 | };
|
5854 |
|
5855 | if (workInProgressHook === null) {
|
5856 |
|
5857 | currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook;
|
5858 | } else {
|
5859 |
|
5860 | workInProgressHook = workInProgressHook.next = newHook;
|
5861 | }
|
5862 | }
|
5863 |
|
5864 | return workInProgressHook;
|
5865 | }
|
5866 |
|
5867 | function createFunctionComponentUpdateQueue() {
|
5868 | return {
|
5869 | lastEffect: null
|
5870 | };
|
5871 | }
|
5872 |
|
5873 | function basicStateReducer(state, action) {
|
5874 |
|
5875 | return typeof action === 'function' ? action(state) : action;
|
5876 | }
|
5877 |
|
5878 | function mountReducer(reducer, initialArg, init) {
|
5879 | var hook = mountWorkInProgressHook();
|
5880 | var initialState;
|
5881 |
|
5882 | if (init !== undefined) {
|
5883 | initialState = init(initialArg);
|
5884 | } else {
|
5885 | initialState = initialArg;
|
5886 | }
|
5887 |
|
5888 | hook.memoizedState = hook.baseState = initialState;
|
5889 | var queue = hook.queue = {
|
5890 | pending: null,
|
5891 | dispatch: null,
|
5892 | lastRenderedReducer: reducer,
|
5893 | lastRenderedState: initialState
|
5894 | };
|
5895 | var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
|
5896 | return [hook.memoizedState, dispatch];
|
5897 | }
|
5898 |
|
5899 | function updateReducer(reducer, initialArg, init) {
|
5900 | var hook = updateWorkInProgressHook();
|
5901 | var queue = hook.queue;
|
5902 |
|
5903 | if (!(queue !== null)) {
|
5904 | {
|
5905 | throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." );
|
5906 | }
|
5907 | }
|
5908 |
|
5909 | queue.lastRenderedReducer = reducer;
|
5910 | var current = currentHook;
|
5911 |
|
5912 | var baseQueue = current.baseQueue;
|
5913 |
|
5914 | var pendingQueue = queue.pending;
|
5915 |
|
5916 | if (pendingQueue !== null) {
|
5917 |
|
5918 |
|
5919 | if (baseQueue !== null) {
|
5920 |
|
5921 | var baseFirst = baseQueue.next;
|
5922 | var pendingFirst = pendingQueue.next;
|
5923 | baseQueue.next = pendingFirst;
|
5924 | pendingQueue.next = baseFirst;
|
5925 | }
|
5926 |
|
5927 | current.baseQueue = baseQueue = pendingQueue;
|
5928 | queue.pending = null;
|
5929 | }
|
5930 |
|
5931 | if (baseQueue !== null) {
|
5932 |
|
5933 | var first = baseQueue.next;
|
5934 | var newState = current.baseState;
|
5935 | var newBaseState = null;
|
5936 | var newBaseQueueFirst = null;
|
5937 | var newBaseQueueLast = null;
|
5938 | var update = first;
|
5939 |
|
5940 | do {
|
5941 | var updateExpirationTime = update.expirationTime;
|
5942 |
|
5943 | if (updateExpirationTime < renderExpirationTime) {
|
5944 |
|
5945 |
|
5946 |
|
5947 | var clone = {
|
5948 | expirationTime: update.expirationTime,
|
5949 | suspenseConfig: update.suspenseConfig,
|
5950 | action: update.action,
|
5951 | eagerReducer: update.eagerReducer,
|
5952 | eagerState: update.eagerState,
|
5953 | next: null
|
5954 | };
|
5955 |
|
5956 | if (newBaseQueueLast === null) {
|
5957 | newBaseQueueFirst = newBaseQueueLast = clone;
|
5958 | newBaseState = newState;
|
5959 | } else {
|
5960 | newBaseQueueLast = newBaseQueueLast.next = clone;
|
5961 | }
|
5962 |
|
5963 |
|
5964 | if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) {
|
5965 | currentlyRenderingFiber$1.expirationTime = updateExpirationTime;
|
5966 | markUnprocessedUpdateTime(updateExpirationTime);
|
5967 | }
|
5968 | } else {
|
5969 |
|
5970 | if (newBaseQueueLast !== null) {
|
5971 | var _clone = {
|
5972 | expirationTime: Sync,
|
5973 |
|
5974 | suspenseConfig: update.suspenseConfig,
|
5975 | action: update.action,
|
5976 | eagerReducer: update.eagerReducer,
|
5977 | eagerState: update.eagerState,
|
5978 | next: null
|
5979 | };
|
5980 | newBaseQueueLast = newBaseQueueLast.next = _clone;
|
5981 | }
|
5982 |
|
5983 |
|
5984 |
|
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 | markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig);
|
5990 |
|
5991 | if (update.eagerReducer === reducer) {
|
5992 |
|
5993 |
|
5994 | newState = update.eagerState;
|
5995 | } else {
|
5996 | var action = update.action;
|
5997 | newState = reducer(newState, action);
|
5998 | }
|
5999 | }
|
6000 |
|
6001 | update = update.next;
|
6002 | } while (update !== null && update !== first);
|
6003 |
|
6004 | if (newBaseQueueLast === null) {
|
6005 | newBaseState = newState;
|
6006 | } else {
|
6007 | newBaseQueueLast.next = newBaseQueueFirst;
|
6008 | }
|
6009 |
|
6010 |
|
6011 |
|
6012 | if (!objectIs(newState, hook.memoizedState)) {
|
6013 | markWorkInProgressReceivedUpdate();
|
6014 | }
|
6015 |
|
6016 | hook.memoizedState = newState;
|
6017 | hook.baseState = newBaseState;
|
6018 | hook.baseQueue = newBaseQueueLast;
|
6019 | queue.lastRenderedState = newState;
|
6020 | }
|
6021 |
|
6022 | var dispatch = queue.dispatch;
|
6023 | return [hook.memoizedState, dispatch];
|
6024 | }
|
6025 |
|
6026 | function rerenderReducer(reducer, initialArg, init) {
|
6027 | var hook = updateWorkInProgressHook();
|
6028 | var queue = hook.queue;
|
6029 |
|
6030 | if (!(queue !== null)) {
|
6031 | {
|
6032 | throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." );
|
6033 | }
|
6034 | }
|
6035 |
|
6036 | queue.lastRenderedReducer = reducer;
|
6037 |
|
6038 |
|
6039 | var dispatch = queue.dispatch;
|
6040 | var lastRenderPhaseUpdate = queue.pending;
|
6041 | var newState = hook.memoizedState;
|
6042 |
|
6043 | if (lastRenderPhaseUpdate !== null) {
|
6044 |
|
6045 | queue.pending = null;
|
6046 | var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
6047 | var update = firstRenderPhaseUpdate;
|
6048 |
|
6049 | do {
|
6050 |
|
6051 |
|
6052 |
|
6053 | var action = update.action;
|
6054 | newState = reducer(newState, action);
|
6055 | update = update.next;
|
6056 | } while (update !== firstRenderPhaseUpdate);
|
6057 |
|
6058 |
|
6059 |
|
6060 | if (!objectIs(newState, hook.memoizedState)) {
|
6061 | markWorkInProgressReceivedUpdate();
|
6062 | }
|
6063 |
|
6064 | hook.memoizedState = newState;
|
6065 |
|
6066 |
|
6067 |
|
6068 |
|
6069 | if (hook.baseQueue === null) {
|
6070 | hook.baseState = newState;
|
6071 | }
|
6072 |
|
6073 | queue.lastRenderedState = newState;
|
6074 | }
|
6075 |
|
6076 | return [newState, dispatch];
|
6077 | }
|
6078 |
|
6079 | function mountState(initialState) {
|
6080 | var hook = mountWorkInProgressHook();
|
6081 |
|
6082 | if (typeof initialState === 'function') {
|
6083 |
|
6084 | initialState = initialState();
|
6085 | }
|
6086 |
|
6087 | hook.memoizedState = hook.baseState = initialState;
|
6088 | var queue = hook.queue = {
|
6089 | pending: null,
|
6090 | dispatch: null,
|
6091 | lastRenderedReducer: basicStateReducer,
|
6092 | lastRenderedState: initialState
|
6093 | };
|
6094 | var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
|
6095 | return [hook.memoizedState, dispatch];
|
6096 | }
|
6097 |
|
6098 | function updateState(initialState) {
|
6099 | return updateReducer(basicStateReducer);
|
6100 | }
|
6101 |
|
6102 | function rerenderState(initialState) {
|
6103 | return rerenderReducer(basicStateReducer);
|
6104 | }
|
6105 |
|
6106 | function pushEffect(tag, create, destroy, deps) {
|
6107 | var effect = {
|
6108 | tag: tag,
|
6109 | create: create,
|
6110 | destroy: destroy,
|
6111 | deps: deps,
|
6112 |
|
6113 | next: null
|
6114 | };
|
6115 | var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
|
6116 |
|
6117 | if (componentUpdateQueue === null) {
|
6118 | componentUpdateQueue = createFunctionComponentUpdateQueue();
|
6119 | currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
|
6120 | componentUpdateQueue.lastEffect = effect.next = effect;
|
6121 | } else {
|
6122 | var lastEffect = componentUpdateQueue.lastEffect;
|
6123 |
|
6124 | if (lastEffect === null) {
|
6125 | componentUpdateQueue.lastEffect = effect.next = effect;
|
6126 | } else {
|
6127 | var firstEffect = lastEffect.next;
|
6128 | lastEffect.next = effect;
|
6129 | effect.next = firstEffect;
|
6130 | componentUpdateQueue.lastEffect = effect;
|
6131 | }
|
6132 | }
|
6133 |
|
6134 | return effect;
|
6135 | }
|
6136 |
|
6137 | function mountRef(initialValue) {
|
6138 | var hook = mountWorkInProgressHook();
|
6139 | var ref = {
|
6140 | current: initialValue
|
6141 | };
|
6142 |
|
6143 | {
|
6144 | Object.seal(ref);
|
6145 | }
|
6146 |
|
6147 | hook.memoizedState = ref;
|
6148 | return ref;
|
6149 | }
|
6150 |
|
6151 | function updateRef(initialValue) {
|
6152 | var hook = updateWorkInProgressHook();
|
6153 | return hook.memoizedState;
|
6154 | }
|
6155 |
|
6156 | function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
|
6157 | var hook = mountWorkInProgressHook();
|
6158 | var nextDeps = deps === undefined ? null : deps;
|
6159 | currentlyRenderingFiber$1.effectTag |= fiberEffectTag;
|
6160 | hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, undefined, nextDeps);
|
6161 | }
|
6162 |
|
6163 | function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
|
6164 | var hook = updateWorkInProgressHook();
|
6165 | var nextDeps = deps === undefined ? null : deps;
|
6166 | var destroy = undefined;
|
6167 |
|
6168 | if (currentHook !== null) {
|
6169 | var prevEffect = currentHook.memoizedState;
|
6170 | destroy = prevEffect.destroy;
|
6171 |
|
6172 | if (nextDeps !== null) {
|
6173 | var prevDeps = prevEffect.deps;
|
6174 |
|
6175 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
6176 | pushEffect(hookEffectTag, create, destroy, nextDeps);
|
6177 | return;
|
6178 | }
|
6179 | }
|
6180 | }
|
6181 |
|
6182 | currentlyRenderingFiber$1.effectTag |= fiberEffectTag;
|
6183 | hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, destroy, nextDeps);
|
6184 | }
|
6185 |
|
6186 | function mountEffect(create, deps) {
|
6187 | {
|
6188 |
|
6189 | if ('undefined' !== typeof jest) {
|
6190 | warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
|
6191 | }
|
6192 | }
|
6193 |
|
6194 | return mountEffectImpl(Update | Passive, Passive$1, create, deps);
|
6195 | }
|
6196 |
|
6197 | function updateEffect(create, deps) {
|
6198 | {
|
6199 |
|
6200 | if ('undefined' !== typeof jest) {
|
6201 | warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
|
6202 | }
|
6203 | }
|
6204 |
|
6205 | return updateEffectImpl(Update | Passive, Passive$1, create, deps);
|
6206 | }
|
6207 |
|
6208 | function mountLayoutEffect(create, deps) {
|
6209 | return mountEffectImpl(Update, Layout, create, deps);
|
6210 | }
|
6211 |
|
6212 | function updateLayoutEffect(create, deps) {
|
6213 | return updateEffectImpl(Update, Layout, create, deps);
|
6214 | }
|
6215 |
|
6216 | function imperativeHandleEffect(create, ref) {
|
6217 | if (typeof ref === 'function') {
|
6218 | var refCallback = ref;
|
6219 |
|
6220 | var _inst = create();
|
6221 |
|
6222 | refCallback(_inst);
|
6223 | return function () {
|
6224 | refCallback(null);
|
6225 | };
|
6226 | } else if (ref !== null && ref !== undefined) {
|
6227 | var refObject = ref;
|
6228 |
|
6229 | {
|
6230 | if (!refObject.hasOwnProperty('current')) {
|
6231 | error('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(', ') + '}');
|
6232 | }
|
6233 | }
|
6234 |
|
6235 | var _inst2 = create();
|
6236 |
|
6237 | refObject.current = _inst2;
|
6238 | return function () {
|
6239 | refObject.current = null;
|
6240 | };
|
6241 | }
|
6242 | }
|
6243 |
|
6244 | function mountImperativeHandle(ref, create, deps) {
|
6245 | {
|
6246 | if (typeof create !== 'function') {
|
6247 | error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
|
6248 | }
|
6249 | }
|
6250 |
|
6251 |
|
6252 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
6253 | return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
6254 | }
|
6255 |
|
6256 | function updateImperativeHandle(ref, create, deps) {
|
6257 | {
|
6258 | if (typeof create !== 'function') {
|
6259 | error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
|
6260 | }
|
6261 | }
|
6262 |
|
6263 |
|
6264 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
6265 | return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
6266 | }
|
6267 |
|
6268 | function mountDebugValue(value, formatterFn) {
|
6269 |
|
6270 |
|
6271 | }
|
6272 |
|
6273 | var updateDebugValue = mountDebugValue;
|
6274 |
|
6275 | function mountCallback(callback, deps) {
|
6276 | var hook = mountWorkInProgressHook();
|
6277 | var nextDeps = deps === undefined ? null : deps;
|
6278 | hook.memoizedState = [callback, nextDeps];
|
6279 | return callback;
|
6280 | }
|
6281 |
|
6282 | function updateCallback(callback, deps) {
|
6283 | var hook = updateWorkInProgressHook();
|
6284 | var nextDeps = deps === undefined ? null : deps;
|
6285 | var prevState = hook.memoizedState;
|
6286 |
|
6287 | if (prevState !== null) {
|
6288 | if (nextDeps !== null) {
|
6289 | var prevDeps = prevState[1];
|
6290 |
|
6291 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
6292 | return prevState[0];
|
6293 | }
|
6294 | }
|
6295 | }
|
6296 |
|
6297 | hook.memoizedState = [callback, nextDeps];
|
6298 | return callback;
|
6299 | }
|
6300 |
|
6301 | function mountMemo(nextCreate, deps) {
|
6302 | var hook = mountWorkInProgressHook();
|
6303 | var nextDeps = deps === undefined ? null : deps;
|
6304 | var nextValue = nextCreate();
|
6305 | hook.memoizedState = [nextValue, nextDeps];
|
6306 | return nextValue;
|
6307 | }
|
6308 |
|
6309 | function updateMemo(nextCreate, deps) {
|
6310 | var hook = updateWorkInProgressHook();
|
6311 | var nextDeps = deps === undefined ? null : deps;
|
6312 | var prevState = hook.memoizedState;
|
6313 |
|
6314 | if (prevState !== null) {
|
6315 |
|
6316 | if (nextDeps !== null) {
|
6317 | var prevDeps = prevState[1];
|
6318 |
|
6319 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
6320 | return prevState[0];
|
6321 | }
|
6322 | }
|
6323 | }
|
6324 |
|
6325 | var nextValue = nextCreate();
|
6326 | hook.memoizedState = [nextValue, nextDeps];
|
6327 | return nextValue;
|
6328 | }
|
6329 |
|
6330 | function mountDeferredValue(value, config) {
|
6331 | var _mountState = mountState(value),
|
6332 | prevValue = _mountState[0],
|
6333 | setValue = _mountState[1];
|
6334 |
|
6335 | mountEffect(function () {
|
6336 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
6337 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
6338 |
|
6339 | try {
|
6340 | setValue(value);
|
6341 | } finally {
|
6342 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
6343 | }
|
6344 | }, [value, config]);
|
6345 | return prevValue;
|
6346 | }
|
6347 |
|
6348 | function updateDeferredValue(value, config) {
|
6349 | var _updateState = updateState(),
|
6350 | prevValue = _updateState[0],
|
6351 | setValue = _updateState[1];
|
6352 |
|
6353 | updateEffect(function () {
|
6354 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
6355 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
6356 |
|
6357 | try {
|
6358 | setValue(value);
|
6359 | } finally {
|
6360 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
6361 | }
|
6362 | }, [value, config]);
|
6363 | return prevValue;
|
6364 | }
|
6365 |
|
6366 | function rerenderDeferredValue(value, config) {
|
6367 | var _rerenderState = rerenderState(),
|
6368 | prevValue = _rerenderState[0],
|
6369 | setValue = _rerenderState[1];
|
6370 |
|
6371 | updateEffect(function () {
|
6372 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
6373 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
6374 |
|
6375 | try {
|
6376 | setValue(value);
|
6377 | } finally {
|
6378 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
6379 | }
|
6380 | }, [value, config]);
|
6381 | return prevValue;
|
6382 | }
|
6383 |
|
6384 | function startTransition(setPending, config, callback) {
|
6385 | var priorityLevel = getCurrentPriorityLevel();
|
6386 | runWithPriority(priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, function () {
|
6387 | setPending(true);
|
6388 | });
|
6389 | runWithPriority(priorityLevel > NormalPriority ? NormalPriority : priorityLevel, function () {
|
6390 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
6391 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
6392 |
|
6393 | try {
|
6394 | setPending(false);
|
6395 | callback();
|
6396 | } finally {
|
6397 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
6398 | }
|
6399 | });
|
6400 | }
|
6401 |
|
6402 | function mountTransition(config) {
|
6403 | var _mountState2 = mountState(false),
|
6404 | isPending = _mountState2[0],
|
6405 | setPending = _mountState2[1];
|
6406 |
|
6407 | var start = mountCallback(startTransition.bind(null, setPending, config), [setPending, config]);
|
6408 | return [start, isPending];
|
6409 | }
|
6410 |
|
6411 | function updateTransition(config) {
|
6412 | var _updateState2 = updateState(),
|
6413 | isPending = _updateState2[0],
|
6414 | setPending = _updateState2[1];
|
6415 |
|
6416 | var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]);
|
6417 | return [start, isPending];
|
6418 | }
|
6419 |
|
6420 | function rerenderTransition(config) {
|
6421 | var _rerenderState2 = rerenderState(),
|
6422 | isPending = _rerenderState2[0],
|
6423 | setPending = _rerenderState2[1];
|
6424 |
|
6425 | var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]);
|
6426 | return [start, isPending];
|
6427 | }
|
6428 |
|
6429 | function dispatchAction(fiber, queue, action) {
|
6430 | {
|
6431 | if (typeof arguments[3] === 'function') {
|
6432 | error("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().');
|
6433 | }
|
6434 | }
|
6435 |
|
6436 | var currentTime = requestCurrentTimeForUpdate();
|
6437 | var suspenseConfig = requestCurrentSuspenseConfig();
|
6438 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
6439 | var update = {
|
6440 | expirationTime: expirationTime,
|
6441 | suspenseConfig: suspenseConfig,
|
6442 | action: action,
|
6443 | eagerReducer: null,
|
6444 | eagerState: null,
|
6445 | next: null
|
6446 | };
|
6447 |
|
6448 | {
|
6449 | update.priority = getCurrentPriorityLevel();
|
6450 | }
|
6451 |
|
6452 |
|
6453 | var pending = queue.pending;
|
6454 |
|
6455 | if (pending === null) {
|
6456 |
|
6457 | update.next = update;
|
6458 | } else {
|
6459 | update.next = pending.next;
|
6460 | pending.next = update;
|
6461 | }
|
6462 |
|
6463 | queue.pending = update;
|
6464 | var alternate = fiber.alternate;
|
6465 |
|
6466 | if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
|
6467 |
|
6468 |
|
6469 |
|
6470 | didScheduleRenderPhaseUpdate = true;
|
6471 | update.expirationTime = renderExpirationTime;
|
6472 | currentlyRenderingFiber$1.expirationTime = renderExpirationTime;
|
6473 | } else {
|
6474 | if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
|
6475 |
|
6476 |
|
6477 |
|
6478 | var lastRenderedReducer = queue.lastRenderedReducer;
|
6479 |
|
6480 | if (lastRenderedReducer !== null) {
|
6481 | var prevDispatcher;
|
6482 |
|
6483 | {
|
6484 | prevDispatcher = ReactCurrentDispatcher.current;
|
6485 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6486 | }
|
6487 |
|
6488 | try {
|
6489 | var currentState = queue.lastRenderedState;
|
6490 | var eagerState = lastRenderedReducer(currentState, action);
|
6491 |
|
6492 |
|
6493 |
|
6494 |
|
6495 | update.eagerReducer = lastRenderedReducer;
|
6496 | update.eagerState = eagerState;
|
6497 |
|
6498 | if (objectIs(eagerState, currentState)) {
|
6499 |
|
6500 |
|
6501 |
|
6502 |
|
6503 | return;
|
6504 | }
|
6505 | } catch (error) {
|
6506 | } finally {
|
6507 | {
|
6508 | ReactCurrentDispatcher.current = prevDispatcher;
|
6509 | }
|
6510 | }
|
6511 | }
|
6512 | }
|
6513 |
|
6514 | {
|
6515 |
|
6516 | if ('undefined' !== typeof jest) {
|
6517 | warnIfNotScopedWithMatchingAct(fiber);
|
6518 | warnIfNotCurrentlyActingUpdatesInDev(fiber);
|
6519 | }
|
6520 | }
|
6521 |
|
6522 | scheduleWork(fiber, expirationTime);
|
6523 | }
|
6524 | }
|
6525 |
|
6526 | var ContextOnlyDispatcher = {
|
6527 | readContext: readContext,
|
6528 | useCallback: throwInvalidHookError,
|
6529 | useContext: throwInvalidHookError,
|
6530 | useEffect: throwInvalidHookError,
|
6531 | useImperativeHandle: throwInvalidHookError,
|
6532 | useLayoutEffect: throwInvalidHookError,
|
6533 | useMemo: throwInvalidHookError,
|
6534 | useReducer: throwInvalidHookError,
|
6535 | useRef: throwInvalidHookError,
|
6536 | useState: throwInvalidHookError,
|
6537 | useDebugValue: throwInvalidHookError,
|
6538 | useResponder: throwInvalidHookError,
|
6539 | useDeferredValue: throwInvalidHookError,
|
6540 | useTransition: throwInvalidHookError
|
6541 | };
|
6542 | var HooksDispatcherOnMountInDEV = null;
|
6543 | var HooksDispatcherOnMountWithHookTypesInDEV = null;
|
6544 | var HooksDispatcherOnUpdateInDEV = null;
|
6545 | var HooksDispatcherOnRerenderInDEV = null;
|
6546 | var InvalidNestedHooksDispatcherOnMountInDEV = null;
|
6547 | var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
6548 | var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
|
6549 |
|
6550 | {
|
6551 | var warnInvalidContextAccess = function () {
|
6552 | 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().');
|
6553 | };
|
6554 |
|
6555 | var warnInvalidHookAccess = function () {
|
6556 | error('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');
|
6557 | };
|
6558 |
|
6559 | HooksDispatcherOnMountInDEV = {
|
6560 | readContext: function (context, observedBits) {
|
6561 | return readContext(context, observedBits);
|
6562 | },
|
6563 | useCallback: function (callback, deps) {
|
6564 | currentHookNameInDev = 'useCallback';
|
6565 | mountHookTypesDev();
|
6566 | checkDepsAreArrayDev(deps);
|
6567 | return mountCallback(callback, deps);
|
6568 | },
|
6569 | useContext: function (context, observedBits) {
|
6570 | currentHookNameInDev = 'useContext';
|
6571 | mountHookTypesDev();
|
6572 | return readContext(context, observedBits);
|
6573 | },
|
6574 | useEffect: function (create, deps) {
|
6575 | currentHookNameInDev = 'useEffect';
|
6576 | mountHookTypesDev();
|
6577 | checkDepsAreArrayDev(deps);
|
6578 | return mountEffect(create, deps);
|
6579 | },
|
6580 | useImperativeHandle: function (ref, create, deps) {
|
6581 | currentHookNameInDev = 'useImperativeHandle';
|
6582 | mountHookTypesDev();
|
6583 | checkDepsAreArrayDev(deps);
|
6584 | return mountImperativeHandle(ref, create, deps);
|
6585 | },
|
6586 | useLayoutEffect: function (create, deps) {
|
6587 | currentHookNameInDev = 'useLayoutEffect';
|
6588 | mountHookTypesDev();
|
6589 | checkDepsAreArrayDev(deps);
|
6590 | return mountLayoutEffect(create, deps);
|
6591 | },
|
6592 | useMemo: function (create, deps) {
|
6593 | currentHookNameInDev = 'useMemo';
|
6594 | mountHookTypesDev();
|
6595 | checkDepsAreArrayDev(deps);
|
6596 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6597 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6598 |
|
6599 | try {
|
6600 | return mountMemo(create, deps);
|
6601 | } finally {
|
6602 | ReactCurrentDispatcher.current = prevDispatcher;
|
6603 | }
|
6604 | },
|
6605 | useReducer: function (reducer, initialArg, init) {
|
6606 | currentHookNameInDev = 'useReducer';
|
6607 | mountHookTypesDev();
|
6608 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6609 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6610 |
|
6611 | try {
|
6612 | return mountReducer(reducer, initialArg, init);
|
6613 | } finally {
|
6614 | ReactCurrentDispatcher.current = prevDispatcher;
|
6615 | }
|
6616 | },
|
6617 | useRef: function (initialValue) {
|
6618 | currentHookNameInDev = 'useRef';
|
6619 | mountHookTypesDev();
|
6620 | return mountRef(initialValue);
|
6621 | },
|
6622 | useState: function (initialState) {
|
6623 | currentHookNameInDev = 'useState';
|
6624 | mountHookTypesDev();
|
6625 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6626 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6627 |
|
6628 | try {
|
6629 | return mountState(initialState);
|
6630 | } finally {
|
6631 | ReactCurrentDispatcher.current = prevDispatcher;
|
6632 | }
|
6633 | },
|
6634 | useDebugValue: function (value, formatterFn) {
|
6635 | currentHookNameInDev = 'useDebugValue';
|
6636 | mountHookTypesDev();
|
6637 | return mountDebugValue();
|
6638 | },
|
6639 | useResponder: function (responder, props) {
|
6640 | currentHookNameInDev = 'useResponder';
|
6641 | mountHookTypesDev();
|
6642 | return createDeprecatedResponderListener(responder, props);
|
6643 | },
|
6644 | useDeferredValue: function (value, config) {
|
6645 | currentHookNameInDev = 'useDeferredValue';
|
6646 | mountHookTypesDev();
|
6647 | return mountDeferredValue(value, config);
|
6648 | },
|
6649 | useTransition: function (config) {
|
6650 | currentHookNameInDev = 'useTransition';
|
6651 | mountHookTypesDev();
|
6652 | return mountTransition(config);
|
6653 | }
|
6654 | };
|
6655 | HooksDispatcherOnMountWithHookTypesInDEV = {
|
6656 | readContext: function (context, observedBits) {
|
6657 | return readContext(context, observedBits);
|
6658 | },
|
6659 | useCallback: function (callback, deps) {
|
6660 | currentHookNameInDev = 'useCallback';
|
6661 | updateHookTypesDev();
|
6662 | return mountCallback(callback, deps);
|
6663 | },
|
6664 | useContext: function (context, observedBits) {
|
6665 | currentHookNameInDev = 'useContext';
|
6666 | updateHookTypesDev();
|
6667 | return readContext(context, observedBits);
|
6668 | },
|
6669 | useEffect: function (create, deps) {
|
6670 | currentHookNameInDev = 'useEffect';
|
6671 | updateHookTypesDev();
|
6672 | return mountEffect(create, deps);
|
6673 | },
|
6674 | useImperativeHandle: function (ref, create, deps) {
|
6675 | currentHookNameInDev = 'useImperativeHandle';
|
6676 | updateHookTypesDev();
|
6677 | return mountImperativeHandle(ref, create, deps);
|
6678 | },
|
6679 | useLayoutEffect: function (create, deps) {
|
6680 | currentHookNameInDev = 'useLayoutEffect';
|
6681 | updateHookTypesDev();
|
6682 | return mountLayoutEffect(create, deps);
|
6683 | },
|
6684 | useMemo: function (create, deps) {
|
6685 | currentHookNameInDev = 'useMemo';
|
6686 | updateHookTypesDev();
|
6687 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6688 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6689 |
|
6690 | try {
|
6691 | return mountMemo(create, deps);
|
6692 | } finally {
|
6693 | ReactCurrentDispatcher.current = prevDispatcher;
|
6694 | }
|
6695 | },
|
6696 | useReducer: function (reducer, initialArg, init) {
|
6697 | currentHookNameInDev = 'useReducer';
|
6698 | updateHookTypesDev();
|
6699 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6700 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6701 |
|
6702 | try {
|
6703 | return mountReducer(reducer, initialArg, init);
|
6704 | } finally {
|
6705 | ReactCurrentDispatcher.current = prevDispatcher;
|
6706 | }
|
6707 | },
|
6708 | useRef: function (initialValue) {
|
6709 | currentHookNameInDev = 'useRef';
|
6710 | updateHookTypesDev();
|
6711 | return mountRef(initialValue);
|
6712 | },
|
6713 | useState: function (initialState) {
|
6714 | currentHookNameInDev = 'useState';
|
6715 | updateHookTypesDev();
|
6716 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6717 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6718 |
|
6719 | try {
|
6720 | return mountState(initialState);
|
6721 | } finally {
|
6722 | ReactCurrentDispatcher.current = prevDispatcher;
|
6723 | }
|
6724 | },
|
6725 | useDebugValue: function (value, formatterFn) {
|
6726 | currentHookNameInDev = 'useDebugValue';
|
6727 | updateHookTypesDev();
|
6728 | return mountDebugValue();
|
6729 | },
|
6730 | useResponder: function (responder, props) {
|
6731 | currentHookNameInDev = 'useResponder';
|
6732 | updateHookTypesDev();
|
6733 | return createDeprecatedResponderListener(responder, props);
|
6734 | },
|
6735 | useDeferredValue: function (value, config) {
|
6736 | currentHookNameInDev = 'useDeferredValue';
|
6737 | updateHookTypesDev();
|
6738 | return mountDeferredValue(value, config);
|
6739 | },
|
6740 | useTransition: function (config) {
|
6741 | currentHookNameInDev = 'useTransition';
|
6742 | updateHookTypesDev();
|
6743 | return mountTransition(config);
|
6744 | }
|
6745 | };
|
6746 | HooksDispatcherOnUpdateInDEV = {
|
6747 | readContext: function (context, observedBits) {
|
6748 | return readContext(context, observedBits);
|
6749 | },
|
6750 | useCallback: function (callback, deps) {
|
6751 | currentHookNameInDev = 'useCallback';
|
6752 | updateHookTypesDev();
|
6753 | return updateCallback(callback, deps);
|
6754 | },
|
6755 | useContext: function (context, observedBits) {
|
6756 | currentHookNameInDev = 'useContext';
|
6757 | updateHookTypesDev();
|
6758 | return readContext(context, observedBits);
|
6759 | },
|
6760 | useEffect: function (create, deps) {
|
6761 | currentHookNameInDev = 'useEffect';
|
6762 | updateHookTypesDev();
|
6763 | return updateEffect(create, deps);
|
6764 | },
|
6765 | useImperativeHandle: function (ref, create, deps) {
|
6766 | currentHookNameInDev = 'useImperativeHandle';
|
6767 | updateHookTypesDev();
|
6768 | return updateImperativeHandle(ref, create, deps);
|
6769 | },
|
6770 | useLayoutEffect: function (create, deps) {
|
6771 | currentHookNameInDev = 'useLayoutEffect';
|
6772 | updateHookTypesDev();
|
6773 | return updateLayoutEffect(create, deps);
|
6774 | },
|
6775 | useMemo: function (create, deps) {
|
6776 | currentHookNameInDev = 'useMemo';
|
6777 | updateHookTypesDev();
|
6778 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6779 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6780 |
|
6781 | try {
|
6782 | return updateMemo(create, deps);
|
6783 | } finally {
|
6784 | ReactCurrentDispatcher.current = prevDispatcher;
|
6785 | }
|
6786 | },
|
6787 | useReducer: function (reducer, initialArg, init) {
|
6788 | currentHookNameInDev = 'useReducer';
|
6789 | updateHookTypesDev();
|
6790 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6791 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6792 |
|
6793 | try {
|
6794 | return updateReducer(reducer, initialArg, init);
|
6795 | } finally {
|
6796 | ReactCurrentDispatcher.current = prevDispatcher;
|
6797 | }
|
6798 | },
|
6799 | useRef: function (initialValue) {
|
6800 | currentHookNameInDev = 'useRef';
|
6801 | updateHookTypesDev();
|
6802 | return updateRef();
|
6803 | },
|
6804 | useState: function (initialState) {
|
6805 | currentHookNameInDev = 'useState';
|
6806 | updateHookTypesDev();
|
6807 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6808 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6809 |
|
6810 | try {
|
6811 | return updateState(initialState);
|
6812 | } finally {
|
6813 | ReactCurrentDispatcher.current = prevDispatcher;
|
6814 | }
|
6815 | },
|
6816 | useDebugValue: function (value, formatterFn) {
|
6817 | currentHookNameInDev = 'useDebugValue';
|
6818 | updateHookTypesDev();
|
6819 | return updateDebugValue();
|
6820 | },
|
6821 | useResponder: function (responder, props) {
|
6822 | currentHookNameInDev = 'useResponder';
|
6823 | updateHookTypesDev();
|
6824 | return createDeprecatedResponderListener(responder, props);
|
6825 | },
|
6826 | useDeferredValue: function (value, config) {
|
6827 | currentHookNameInDev = 'useDeferredValue';
|
6828 | updateHookTypesDev();
|
6829 | return updateDeferredValue(value, config);
|
6830 | },
|
6831 | useTransition: function (config) {
|
6832 | currentHookNameInDev = 'useTransition';
|
6833 | updateHookTypesDev();
|
6834 | return updateTransition(config);
|
6835 | }
|
6836 | };
|
6837 | HooksDispatcherOnRerenderInDEV = {
|
6838 | readContext: function (context, observedBits) {
|
6839 | return readContext(context, observedBits);
|
6840 | },
|
6841 | useCallback: function (callback, deps) {
|
6842 | currentHookNameInDev = 'useCallback';
|
6843 | updateHookTypesDev();
|
6844 | return updateCallback(callback, deps);
|
6845 | },
|
6846 | useContext: function (context, observedBits) {
|
6847 | currentHookNameInDev = 'useContext';
|
6848 | updateHookTypesDev();
|
6849 | return readContext(context, observedBits);
|
6850 | },
|
6851 | useEffect: function (create, deps) {
|
6852 | currentHookNameInDev = 'useEffect';
|
6853 | updateHookTypesDev();
|
6854 | return updateEffect(create, deps);
|
6855 | },
|
6856 | useImperativeHandle: function (ref, create, deps) {
|
6857 | currentHookNameInDev = 'useImperativeHandle';
|
6858 | updateHookTypesDev();
|
6859 | return updateImperativeHandle(ref, create, deps);
|
6860 | },
|
6861 | useLayoutEffect: function (create, deps) {
|
6862 | currentHookNameInDev = 'useLayoutEffect';
|
6863 | updateHookTypesDev();
|
6864 | return updateLayoutEffect(create, deps);
|
6865 | },
|
6866 | useMemo: function (create, deps) {
|
6867 | currentHookNameInDev = 'useMemo';
|
6868 | updateHookTypesDev();
|
6869 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6870 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
6871 |
|
6872 | try {
|
6873 | return updateMemo(create, deps);
|
6874 | } finally {
|
6875 | ReactCurrentDispatcher.current = prevDispatcher;
|
6876 | }
|
6877 | },
|
6878 | useReducer: function (reducer, initialArg, init) {
|
6879 | currentHookNameInDev = 'useReducer';
|
6880 | updateHookTypesDev();
|
6881 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6882 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
6883 |
|
6884 | try {
|
6885 | return rerenderReducer(reducer, initialArg, init);
|
6886 | } finally {
|
6887 | ReactCurrentDispatcher.current = prevDispatcher;
|
6888 | }
|
6889 | },
|
6890 | useRef: function (initialValue) {
|
6891 | currentHookNameInDev = 'useRef';
|
6892 | updateHookTypesDev();
|
6893 | return updateRef();
|
6894 | },
|
6895 | useState: function (initialState) {
|
6896 | currentHookNameInDev = 'useState';
|
6897 | updateHookTypesDev();
|
6898 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6899 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
6900 |
|
6901 | try {
|
6902 | return rerenderState(initialState);
|
6903 | } finally {
|
6904 | ReactCurrentDispatcher.current = prevDispatcher;
|
6905 | }
|
6906 | },
|
6907 | useDebugValue: function (value, formatterFn) {
|
6908 | currentHookNameInDev = 'useDebugValue';
|
6909 | updateHookTypesDev();
|
6910 | return updateDebugValue();
|
6911 | },
|
6912 | useResponder: function (responder, props) {
|
6913 | currentHookNameInDev = 'useResponder';
|
6914 | updateHookTypesDev();
|
6915 | return createDeprecatedResponderListener(responder, props);
|
6916 | },
|
6917 | useDeferredValue: function (value, config) {
|
6918 | currentHookNameInDev = 'useDeferredValue';
|
6919 | updateHookTypesDev();
|
6920 | return rerenderDeferredValue(value, config);
|
6921 | },
|
6922 | useTransition: function (config) {
|
6923 | currentHookNameInDev = 'useTransition';
|
6924 | updateHookTypesDev();
|
6925 | return rerenderTransition(config);
|
6926 | }
|
6927 | };
|
6928 | InvalidNestedHooksDispatcherOnMountInDEV = {
|
6929 | readContext: function (context, observedBits) {
|
6930 | warnInvalidContextAccess();
|
6931 | return readContext(context, observedBits);
|
6932 | },
|
6933 | useCallback: function (callback, deps) {
|
6934 | currentHookNameInDev = 'useCallback';
|
6935 | warnInvalidHookAccess();
|
6936 | mountHookTypesDev();
|
6937 | return mountCallback(callback, deps);
|
6938 | },
|
6939 | useContext: function (context, observedBits) {
|
6940 | currentHookNameInDev = 'useContext';
|
6941 | warnInvalidHookAccess();
|
6942 | mountHookTypesDev();
|
6943 | return readContext(context, observedBits);
|
6944 | },
|
6945 | useEffect: function (create, deps) {
|
6946 | currentHookNameInDev = 'useEffect';
|
6947 | warnInvalidHookAccess();
|
6948 | mountHookTypesDev();
|
6949 | return mountEffect(create, deps);
|
6950 | },
|
6951 | useImperativeHandle: function (ref, create, deps) {
|
6952 | currentHookNameInDev = 'useImperativeHandle';
|
6953 | warnInvalidHookAccess();
|
6954 | mountHookTypesDev();
|
6955 | return mountImperativeHandle(ref, create, deps);
|
6956 | },
|
6957 | useLayoutEffect: function (create, deps) {
|
6958 | currentHookNameInDev = 'useLayoutEffect';
|
6959 | warnInvalidHookAccess();
|
6960 | mountHookTypesDev();
|
6961 | return mountLayoutEffect(create, deps);
|
6962 | },
|
6963 | useMemo: function (create, deps) {
|
6964 | currentHookNameInDev = 'useMemo';
|
6965 | warnInvalidHookAccess();
|
6966 | mountHookTypesDev();
|
6967 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6968 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6969 |
|
6970 | try {
|
6971 | return mountMemo(create, deps);
|
6972 | } finally {
|
6973 | ReactCurrentDispatcher.current = prevDispatcher;
|
6974 | }
|
6975 | },
|
6976 | useReducer: function (reducer, initialArg, init) {
|
6977 | currentHookNameInDev = 'useReducer';
|
6978 | warnInvalidHookAccess();
|
6979 | mountHookTypesDev();
|
6980 | var prevDispatcher = ReactCurrentDispatcher.current;
|
6981 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6982 |
|
6983 | try {
|
6984 | return mountReducer(reducer, initialArg, init);
|
6985 | } finally {
|
6986 | ReactCurrentDispatcher.current = prevDispatcher;
|
6987 | }
|
6988 | },
|
6989 | useRef: function (initialValue) {
|
6990 | currentHookNameInDev = 'useRef';
|
6991 | warnInvalidHookAccess();
|
6992 | mountHookTypesDev();
|
6993 | return mountRef(initialValue);
|
6994 | },
|
6995 | useState: function (initialState) {
|
6996 | currentHookNameInDev = 'useState';
|
6997 | warnInvalidHookAccess();
|
6998 | mountHookTypesDev();
|
6999 | var prevDispatcher = ReactCurrentDispatcher.current;
|
7000 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7001 |
|
7002 | try {
|
7003 | return mountState(initialState);
|
7004 | } finally {
|
7005 | ReactCurrentDispatcher.current = prevDispatcher;
|
7006 | }
|
7007 | },
|
7008 | useDebugValue: function (value, formatterFn) {
|
7009 | currentHookNameInDev = 'useDebugValue';
|
7010 | warnInvalidHookAccess();
|
7011 | mountHookTypesDev();
|
7012 | return mountDebugValue();
|
7013 | },
|
7014 | useResponder: function (responder, props) {
|
7015 | currentHookNameInDev = 'useResponder';
|
7016 | warnInvalidHookAccess();
|
7017 | mountHookTypesDev();
|
7018 | return createDeprecatedResponderListener(responder, props);
|
7019 | },
|
7020 | useDeferredValue: function (value, config) {
|
7021 | currentHookNameInDev = 'useDeferredValue';
|
7022 | warnInvalidHookAccess();
|
7023 | mountHookTypesDev();
|
7024 | return mountDeferredValue(value, config);
|
7025 | },
|
7026 | useTransition: function (config) {
|
7027 | currentHookNameInDev = 'useTransition';
|
7028 | warnInvalidHookAccess();
|
7029 | mountHookTypesDev();
|
7030 | return mountTransition(config);
|
7031 | }
|
7032 | };
|
7033 | InvalidNestedHooksDispatcherOnUpdateInDEV = {
|
7034 | readContext: function (context, observedBits) {
|
7035 | warnInvalidContextAccess();
|
7036 | return readContext(context, observedBits);
|
7037 | },
|
7038 | useCallback: function (callback, deps) {
|
7039 | currentHookNameInDev = 'useCallback';
|
7040 | warnInvalidHookAccess();
|
7041 | updateHookTypesDev();
|
7042 | return updateCallback(callback, deps);
|
7043 | },
|
7044 | useContext: function (context, observedBits) {
|
7045 | currentHookNameInDev = 'useContext';
|
7046 | warnInvalidHookAccess();
|
7047 | updateHookTypesDev();
|
7048 | return readContext(context, observedBits);
|
7049 | },
|
7050 | useEffect: function (create, deps) {
|
7051 | currentHookNameInDev = 'useEffect';
|
7052 | warnInvalidHookAccess();
|
7053 | updateHookTypesDev();
|
7054 | return updateEffect(create, deps);
|
7055 | },
|
7056 | useImperativeHandle: function (ref, create, deps) {
|
7057 | currentHookNameInDev = 'useImperativeHandle';
|
7058 | warnInvalidHookAccess();
|
7059 | updateHookTypesDev();
|
7060 | return updateImperativeHandle(ref, create, deps);
|
7061 | },
|
7062 | useLayoutEffect: function (create, deps) {
|
7063 | currentHookNameInDev = 'useLayoutEffect';
|
7064 | warnInvalidHookAccess();
|
7065 | updateHookTypesDev();
|
7066 | return updateLayoutEffect(create, deps);
|
7067 | },
|
7068 | useMemo: function (create, deps) {
|
7069 | currentHookNameInDev = 'useMemo';
|
7070 | warnInvalidHookAccess();
|
7071 | updateHookTypesDev();
|
7072 | var prevDispatcher = ReactCurrentDispatcher.current;
|
7073 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7074 |
|
7075 | try {
|
7076 | return updateMemo(create, deps);
|
7077 | } finally {
|
7078 | ReactCurrentDispatcher.current = prevDispatcher;
|
7079 | }
|
7080 | },
|
7081 | useReducer: function (reducer, initialArg, init) {
|
7082 | currentHookNameInDev = 'useReducer';
|
7083 | warnInvalidHookAccess();
|
7084 | updateHookTypesDev();
|
7085 | var prevDispatcher = ReactCurrentDispatcher.current;
|
7086 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7087 |
|
7088 | try {
|
7089 | return updateReducer(reducer, initialArg, init);
|
7090 | } finally {
|
7091 | ReactCurrentDispatcher.current = prevDispatcher;
|
7092 | }
|
7093 | },
|
7094 | useRef: function (initialValue) {
|
7095 | currentHookNameInDev = 'useRef';
|
7096 | warnInvalidHookAccess();
|
7097 | updateHookTypesDev();
|
7098 | return updateRef();
|
7099 | },
|
7100 | useState: function (initialState) {
|
7101 | currentHookNameInDev = 'useState';
|
7102 | warnInvalidHookAccess();
|
7103 | updateHookTypesDev();
|
7104 | var prevDispatcher = ReactCurrentDispatcher.current;
|
7105 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7106 |
|
7107 | try {
|
7108 | return updateState(initialState);
|
7109 | } finally {
|
7110 | ReactCurrentDispatcher.current = prevDispatcher;
|
7111 | }
|
7112 | },
|
7113 | useDebugValue: function (value, formatterFn) {
|
7114 | currentHookNameInDev = 'useDebugValue';
|
7115 | warnInvalidHookAccess();
|
7116 | updateHookTypesDev();
|
7117 | return updateDebugValue();
|
7118 | },
|
7119 | useResponder: function (responder, props) {
|
7120 | currentHookNameInDev = 'useResponder';
|
7121 | warnInvalidHookAccess();
|
7122 | updateHookTypesDev();
|
7123 | return createDeprecatedResponderListener(responder, props);
|
7124 | },
|
7125 | useDeferredValue: function (value, config) {
|
7126 | currentHookNameInDev = 'useDeferredValue';
|
7127 | warnInvalidHookAccess();
|
7128 | updateHookTypesDev();
|
7129 | return updateDeferredValue(value, config);
|
7130 | },
|
7131 | useTransition: function (config) {
|
7132 | currentHookNameInDev = 'useTransition';
|
7133 | warnInvalidHookAccess();
|
7134 | updateHookTypesDev();
|
7135 | return updateTransition(config);
|
7136 | }
|
7137 | };
|
7138 | InvalidNestedHooksDispatcherOnRerenderInDEV = {
|
7139 | readContext: function (context, observedBits) {
|
7140 | warnInvalidContextAccess();
|
7141 | return readContext(context, observedBits);
|
7142 | },
|
7143 | useCallback: function (callback, deps) {
|
7144 | currentHookNameInDev = 'useCallback';
|
7145 | warnInvalidHookAccess();
|
7146 | updateHookTypesDev();
|
7147 | return updateCallback(callback, deps);
|
7148 | },
|
7149 | useContext: function (context, observedBits) {
|
7150 | currentHookNameInDev = 'useContext';
|
7151 | warnInvalidHookAccess();
|
7152 | updateHookTypesDev();
|
7153 | return readContext(context, observedBits);
|
7154 | },
|
7155 | useEffect: function (create, deps) {
|
7156 | currentHookNameInDev = 'useEffect';
|
7157 | warnInvalidHookAccess();
|
7158 | updateHookTypesDev();
|
7159 | return updateEffect(create, deps);
|
7160 | },
|
7161 | useImperativeHandle: function (ref, create, deps) {
|
7162 | currentHookNameInDev = 'useImperativeHandle';
|
7163 | warnInvalidHookAccess();
|
7164 | updateHookTypesDev();
|
7165 | return updateImperativeHandle(ref, create, deps);
|
7166 | },
|
7167 | useLayoutEffect: function (create, deps) {
|
7168 | currentHookNameInDev = 'useLayoutEffect';
|
7169 | warnInvalidHookAccess();
|
7170 | updateHookTypesDev();
|
7171 | return updateLayoutEffect(create, deps);
|
7172 | },
|
7173 | useMemo: function (create, deps) {
|
7174 | currentHookNameInDev = 'useMemo';
|
7175 | warnInvalidHookAccess();
|
7176 | updateHookTypesDev();
|
7177 | var prevDispatcher = ReactCurrentDispatcher.current;
|
7178 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7179 |
|
7180 | try {
|
7181 | return updateMemo(create, deps);
|
7182 | } finally {
|
7183 | ReactCurrentDispatcher.current = prevDispatcher;
|
7184 | }
|
7185 | },
|
7186 | useReducer: function (reducer, initialArg, init) {
|
7187 | currentHookNameInDev = 'useReducer';
|
7188 | warnInvalidHookAccess();
|
7189 | updateHookTypesDev();
|
7190 | var prevDispatcher = ReactCurrentDispatcher.current;
|
7191 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7192 |
|
7193 | try {
|
7194 | return rerenderReducer(reducer, initialArg, init);
|
7195 | } finally {
|
7196 | ReactCurrentDispatcher.current = prevDispatcher;
|
7197 | }
|
7198 | },
|
7199 | useRef: function (initialValue) {
|
7200 | currentHookNameInDev = 'useRef';
|
7201 | warnInvalidHookAccess();
|
7202 | updateHookTypesDev();
|
7203 | return updateRef();
|
7204 | },
|
7205 | useState: function (initialState) {
|
7206 | currentHookNameInDev = 'useState';
|
7207 | warnInvalidHookAccess();
|
7208 | updateHookTypesDev();
|
7209 | var prevDispatcher = ReactCurrentDispatcher.current;
|
7210 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7211 |
|
7212 | try {
|
7213 | return rerenderState(initialState);
|
7214 | } finally {
|
7215 | ReactCurrentDispatcher.current = prevDispatcher;
|
7216 | }
|
7217 | },
|
7218 | useDebugValue: function (value, formatterFn) {
|
7219 | currentHookNameInDev = 'useDebugValue';
|
7220 | warnInvalidHookAccess();
|
7221 | updateHookTypesDev();
|
7222 | return updateDebugValue();
|
7223 | },
|
7224 | useResponder: function (responder, props) {
|
7225 | currentHookNameInDev = 'useResponder';
|
7226 | warnInvalidHookAccess();
|
7227 | updateHookTypesDev();
|
7228 | return createDeprecatedResponderListener(responder, props);
|
7229 | },
|
7230 | useDeferredValue: function (value, config) {
|
7231 | currentHookNameInDev = 'useDeferredValue';
|
7232 | warnInvalidHookAccess();
|
7233 | updateHookTypesDev();
|
7234 | return rerenderDeferredValue(value, config);
|
7235 | },
|
7236 | useTransition: function (config) {
|
7237 | currentHookNameInDev = 'useTransition';
|
7238 | warnInvalidHookAccess();
|
7239 | updateHookTypesDev();
|
7240 | return rerenderTransition(config);
|
7241 | }
|
7242 | };
|
7243 | }
|
7244 |
|
7245 | var now$1 = Scheduler$1.unstable_now;
|
7246 | var commitTime = 0;
|
7247 | var profilerStartTime = -1;
|
7248 |
|
7249 | function getCommitTime() {
|
7250 | return commitTime;
|
7251 | }
|
7252 |
|
7253 | function recordCommitTime() {
|
7254 |
|
7255 | commitTime = now$1();
|
7256 | }
|
7257 |
|
7258 | function startProfilerTimer(fiber) {
|
7259 |
|
7260 | profilerStartTime = now$1();
|
7261 |
|
7262 | if (fiber.actualStartTime < 0) {
|
7263 | fiber.actualStartTime = now$1();
|
7264 | }
|
7265 | }
|
7266 |
|
7267 | function stopProfilerTimerIfRunning(fiber) {
|
7268 |
|
7269 | profilerStartTime = -1;
|
7270 | }
|
7271 |
|
7272 | function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
|
7273 |
|
7274 | if (profilerStartTime >= 0) {
|
7275 | var elapsedTime = now$1() - profilerStartTime;
|
7276 | fiber.actualDuration += elapsedTime;
|
7277 |
|
7278 | if (overrideBaseTime) {
|
7279 | fiber.selfBaseDuration = elapsedTime;
|
7280 | }
|
7281 |
|
7282 | profilerStartTime = -1;
|
7283 | }
|
7284 | }
|
7285 |
|
7286 | function enterHydrationState(fiber) {
|
7287 | {
|
7288 | return false;
|
7289 | }
|
7290 | }
|
7291 |
|
7292 | function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
|
7293 | {
|
7294 | {
|
7295 | {
|
7296 | throw Error( "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." );
|
7297 | }
|
7298 | }
|
7299 | }
|
7300 | }
|
7301 |
|
7302 | function prepareToHydrateHostTextInstance(fiber) {
|
7303 | {
|
7304 | {
|
7305 | {
|
7306 | throw Error( "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." );
|
7307 | }
|
7308 | }
|
7309 | }
|
7310 | var shouldUpdate = hydrateTextInstance();
|
7311 | }
|
7312 |
|
7313 | function popHydrationState(fiber) {
|
7314 | {
|
7315 | return false;
|
7316 | }
|
7317 | }
|
7318 |
|
7319 | var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
7320 | var didReceiveUpdate = false;
|
7321 | var didWarnAboutBadClass;
|
7322 | var didWarnAboutModulePatternComponent;
|
7323 | var didWarnAboutContextTypeOnFunctionComponent;
|
7324 | var didWarnAboutGetDerivedStateOnFunctionComponent;
|
7325 | var didWarnAboutFunctionRefs;
|
7326 | var didWarnAboutReassigningProps;
|
7327 | var didWarnAboutRevealOrder;
|
7328 | var didWarnAboutTailOptions;
|
7329 |
|
7330 | {
|
7331 | didWarnAboutBadClass = {};
|
7332 | didWarnAboutModulePatternComponent = {};
|
7333 | didWarnAboutContextTypeOnFunctionComponent = {};
|
7334 | didWarnAboutGetDerivedStateOnFunctionComponent = {};
|
7335 | didWarnAboutFunctionRefs = {};
|
7336 | didWarnAboutReassigningProps = false;
|
7337 | didWarnAboutRevealOrder = {};
|
7338 | didWarnAboutTailOptions = {};
|
7339 | }
|
7340 |
|
7341 | function reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime) {
|
7342 | if (current === null) {
|
7343 |
|
7344 |
|
7345 |
|
7346 |
|
7347 | workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
7348 | } else {
|
7349 |
|
7350 |
|
7351 |
|
7352 |
|
7353 |
|
7354 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime);
|
7355 | }
|
7356 | }
|
7357 |
|
7358 | function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime) {
|
7359 |
|
7360 |
|
7361 |
|
7362 |
|
7363 |
|
7364 |
|
7365 |
|
7366 |
|
7367 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderExpirationTime);
|
7368 |
|
7369 |
|
7370 |
|
7371 |
|
7372 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
7373 | }
|
7374 |
|
7375 | function updateForwardRef(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7376 |
|
7377 |
|
7378 |
|
7379 | {
|
7380 | if (workInProgress.type !== workInProgress.elementType) {
|
7381 |
|
7382 |
|
7383 | var innerPropTypes = Component.propTypes;
|
7384 |
|
7385 | if (innerPropTypes) {
|
7386 | checkPropTypes_1(innerPropTypes, nextProps,
|
7387 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7388 | }
|
7389 | }
|
7390 | }
|
7391 |
|
7392 | var render = Component.render;
|
7393 | var ref = workInProgress.ref;
|
7394 |
|
7395 | var nextChildren;
|
7396 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7397 |
|
7398 | {
|
7399 | ReactCurrentOwner$1.current = workInProgress;
|
7400 | setIsRendering(true);
|
7401 | nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime);
|
7402 |
|
7403 | setIsRendering(false);
|
7404 | }
|
7405 |
|
7406 | if (current !== null && !didReceiveUpdate) {
|
7407 | bailoutHooks(current, workInProgress, renderExpirationTime);
|
7408 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7409 | }
|
7410 |
|
7411 |
|
7412 | workInProgress.effectTag |= PerformedWork;
|
7413 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7414 | return workInProgress.child;
|
7415 | }
|
7416 |
|
7417 | function updateMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
|
7418 | if (current === null) {
|
7419 | var type = Component.type;
|
7420 |
|
7421 | if (isSimpleFunctionComponent(type) && Component.compare === null &&
|
7422 | Component.defaultProps === undefined) {
|
7423 | var resolvedType = type;
|
7424 |
|
7425 | {
|
7426 | resolvedType = resolveFunctionForHotReloading(type);
|
7427 | }
|
7428 |
|
7429 |
|
7430 |
|
7431 |
|
7432 | workInProgress.tag = SimpleMemoComponent;
|
7433 | workInProgress.type = resolvedType;
|
7434 |
|
7435 | {
|
7436 | validateFunctionComponentInDev(workInProgress, type);
|
7437 | }
|
7438 |
|
7439 | return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
|
7440 | }
|
7441 |
|
7442 | {
|
7443 | var innerPropTypes = type.propTypes;
|
7444 |
|
7445 | if (innerPropTypes) {
|
7446 |
|
7447 |
|
7448 | checkPropTypes_1(innerPropTypes, nextProps,
|
7449 | 'prop', getComponentName(type), getCurrentFiberStackInDev);
|
7450 | }
|
7451 | }
|
7452 |
|
7453 | var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
|
7454 | child.ref = workInProgress.ref;
|
7455 | child.return = workInProgress;
|
7456 | workInProgress.child = child;
|
7457 | return child;
|
7458 | }
|
7459 |
|
7460 | {
|
7461 | var _type = Component.type;
|
7462 | var _innerPropTypes = _type.propTypes;
|
7463 |
|
7464 | if (_innerPropTypes) {
|
7465 |
|
7466 |
|
7467 | checkPropTypes_1(_innerPropTypes, nextProps,
|
7468 | 'prop', getComponentName(_type), getCurrentFiberStackInDev);
|
7469 | }
|
7470 | }
|
7471 |
|
7472 | var currentChild = current.child;
|
7473 |
|
7474 | if (updateExpirationTime < renderExpirationTime) {
|
7475 |
|
7476 |
|
7477 | var prevProps = currentChild.memoizedProps;
|
7478 |
|
7479 | var compare = Component.compare;
|
7480 | compare = compare !== null ? compare : shallowEqual;
|
7481 |
|
7482 | if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
|
7483 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7484 | }
|
7485 | }
|
7486 |
|
7487 |
|
7488 | workInProgress.effectTag |= PerformedWork;
|
7489 | var newChild = createWorkInProgress(currentChild, nextProps);
|
7490 | newChild.ref = workInProgress.ref;
|
7491 | newChild.return = workInProgress;
|
7492 | workInProgress.child = newChild;
|
7493 | return newChild;
|
7494 | }
|
7495 |
|
7496 | function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
|
7497 |
|
7498 |
|
7499 |
|
7500 | {
|
7501 | if (workInProgress.type !== workInProgress.elementType) {
|
7502 |
|
7503 |
|
7504 | var outerMemoType = workInProgress.elementType;
|
7505 |
|
7506 | if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
|
7507 |
|
7508 |
|
7509 |
|
7510 | outerMemoType = refineResolvedLazyComponent(outerMemoType);
|
7511 | }
|
7512 |
|
7513 | var outerPropTypes = outerMemoType && outerMemoType.propTypes;
|
7514 |
|
7515 | if (outerPropTypes) {
|
7516 | checkPropTypes_1(outerPropTypes, nextProps,
|
7517 | 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
|
7518 | }
|
7519 |
|
7520 | }
|
7521 | }
|
7522 |
|
7523 | if (current !== null) {
|
7524 | var prevProps = current.memoizedProps;
|
7525 |
|
7526 | if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && (
|
7527 | workInProgress.type === current.type )) {
|
7528 | didReceiveUpdate = false;
|
7529 |
|
7530 | if (updateExpirationTime < renderExpirationTime) {
|
7531 |
|
7532 |
|
7533 |
|
7534 |
|
7535 |
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 |
|
7541 |
|
7542 |
|
7543 |
|
7544 | workInProgress.expirationTime = current.expirationTime;
|
7545 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7546 | }
|
7547 | }
|
7548 | }
|
7549 |
|
7550 | return updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime);
|
7551 | }
|
7552 |
|
7553 | function updateFragment(current, workInProgress, renderExpirationTime) {
|
7554 | var nextChildren = workInProgress.pendingProps;
|
7555 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7556 | return workInProgress.child;
|
7557 | }
|
7558 |
|
7559 | function updateMode(current, workInProgress, renderExpirationTime) {
|
7560 | var nextChildren = workInProgress.pendingProps.children;
|
7561 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7562 | return workInProgress.child;
|
7563 | }
|
7564 |
|
7565 | function updateProfiler(current, workInProgress, renderExpirationTime) {
|
7566 | {
|
7567 | workInProgress.effectTag |= Update;
|
7568 | }
|
7569 |
|
7570 | var nextProps = workInProgress.pendingProps;
|
7571 | var nextChildren = nextProps.children;
|
7572 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7573 | return workInProgress.child;
|
7574 | }
|
7575 |
|
7576 | function markRef(current, workInProgress) {
|
7577 | var ref = workInProgress.ref;
|
7578 |
|
7579 | if (current === null && ref !== null || current !== null && current.ref !== ref) {
|
7580 |
|
7581 | workInProgress.effectTag |= Ref;
|
7582 | }
|
7583 | }
|
7584 |
|
7585 | function updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7586 | {
|
7587 | if (workInProgress.type !== workInProgress.elementType) {
|
7588 |
|
7589 |
|
7590 | var innerPropTypes = Component.propTypes;
|
7591 |
|
7592 | if (innerPropTypes) {
|
7593 | checkPropTypes_1(innerPropTypes, nextProps,
|
7594 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7595 | }
|
7596 | }
|
7597 | }
|
7598 |
|
7599 | var context;
|
7600 |
|
7601 | {
|
7602 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
|
7603 | context = getMaskedContext(workInProgress, unmaskedContext);
|
7604 | }
|
7605 |
|
7606 | var nextChildren;
|
7607 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7608 |
|
7609 | {
|
7610 | ReactCurrentOwner$1.current = workInProgress;
|
7611 | setIsRendering(true);
|
7612 | nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime);
|
7613 |
|
7614 | setIsRendering(false);
|
7615 | }
|
7616 |
|
7617 | if (current !== null && !didReceiveUpdate) {
|
7618 | bailoutHooks(current, workInProgress, renderExpirationTime);
|
7619 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7620 | }
|
7621 |
|
7622 |
|
7623 | workInProgress.effectTag |= PerformedWork;
|
7624 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7625 | return workInProgress.child;
|
7626 | }
|
7627 |
|
7628 | function updateClassComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7629 | {
|
7630 | if (workInProgress.type !== workInProgress.elementType) {
|
7631 |
|
7632 |
|
7633 | var innerPropTypes = Component.propTypes;
|
7634 |
|
7635 | if (innerPropTypes) {
|
7636 | checkPropTypes_1(innerPropTypes, nextProps,
|
7637 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7638 | }
|
7639 | }
|
7640 | }
|
7641 |
|
7642 |
|
7643 |
|
7644 |
|
7645 | var hasContext;
|
7646 |
|
7647 | if (isContextProvider(Component)) {
|
7648 | hasContext = true;
|
7649 | pushContextProvider(workInProgress);
|
7650 | } else {
|
7651 | hasContext = false;
|
7652 | }
|
7653 |
|
7654 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7655 | var instance = workInProgress.stateNode;
|
7656 | var shouldUpdate;
|
7657 |
|
7658 | if (instance === null) {
|
7659 | if (current !== null) {
|
7660 |
|
7661 |
|
7662 |
|
7663 |
|
7664 | current.alternate = null;
|
7665 | workInProgress.alternate = null;
|
7666 |
|
7667 | workInProgress.effectTag |= Placement;
|
7668 | }
|
7669 |
|
7670 |
|
7671 | constructClassInstance(workInProgress, Component, nextProps);
|
7672 | mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7673 | shouldUpdate = true;
|
7674 | } else if (current === null) {
|
7675 |
|
7676 | shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7677 | } else {
|
7678 | shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderExpirationTime);
|
7679 | }
|
7680 |
|
7681 | var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
|
7682 |
|
7683 | {
|
7684 | var inst = workInProgress.stateNode;
|
7685 |
|
7686 | if (inst.props !== nextProps) {
|
7687 | if (!didWarnAboutReassigningProps) {
|
7688 | error('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');
|
7689 | }
|
7690 |
|
7691 | didWarnAboutReassigningProps = true;
|
7692 | }
|
7693 | }
|
7694 |
|
7695 | return nextUnitOfWork;
|
7696 | }
|
7697 |
|
7698 | function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
|
7699 |
|
7700 | markRef(current, workInProgress);
|
7701 | var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
|
7702 |
|
7703 | if (!shouldUpdate && !didCaptureError) {
|
7704 |
|
7705 | if (hasContext) {
|
7706 | invalidateContextProvider(workInProgress, Component, false);
|
7707 | }
|
7708 |
|
7709 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7710 | }
|
7711 |
|
7712 | var instance = workInProgress.stateNode;
|
7713 |
|
7714 | ReactCurrentOwner$1.current = workInProgress;
|
7715 | var nextChildren;
|
7716 |
|
7717 | if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
|
7718 |
|
7719 |
|
7720 |
|
7721 |
|
7722 |
|
7723 | nextChildren = null;
|
7724 |
|
7725 | {
|
7726 | stopProfilerTimerIfRunning();
|
7727 | }
|
7728 | } else {
|
7729 | {
|
7730 | setIsRendering(true);
|
7731 | nextChildren = instance.render();
|
7732 |
|
7733 | setIsRendering(false);
|
7734 | }
|
7735 | }
|
7736 |
|
7737 |
|
7738 | workInProgress.effectTag |= PerformedWork;
|
7739 |
|
7740 | if (current !== null && didCaptureError) {
|
7741 |
|
7742 |
|
7743 |
|
7744 |
|
7745 | forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime);
|
7746 | } else {
|
7747 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7748 | }
|
7749 |
|
7750 |
|
7751 |
|
7752 | workInProgress.memoizedState = instance.state;
|
7753 |
|
7754 | if (hasContext) {
|
7755 | invalidateContextProvider(workInProgress, Component, true);
|
7756 | }
|
7757 |
|
7758 | return workInProgress.child;
|
7759 | }
|
7760 |
|
7761 | function pushHostRootContext(workInProgress) {
|
7762 | var root = workInProgress.stateNode;
|
7763 |
|
7764 | if (root.pendingContext) {
|
7765 | pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
|
7766 | } else if (root.context) {
|
7767 |
|
7768 | pushTopLevelContextObject(workInProgress, root.context, false);
|
7769 | }
|
7770 |
|
7771 | pushHostContainer(workInProgress, root.containerInfo);
|
7772 | }
|
7773 |
|
7774 | function updateHostRoot(current, workInProgress, renderExpirationTime) {
|
7775 | pushHostRootContext(workInProgress);
|
7776 | var updateQueue = workInProgress.updateQueue;
|
7777 |
|
7778 | if (!(current !== null && updateQueue !== null)) {
|
7779 | {
|
7780 | throw 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." );
|
7781 | }
|
7782 | }
|
7783 |
|
7784 | var nextProps = workInProgress.pendingProps;
|
7785 | var prevState = workInProgress.memoizedState;
|
7786 | var prevChildren = prevState !== null ? prevState.element : null;
|
7787 | cloneUpdateQueue(current, workInProgress);
|
7788 | processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime);
|
7789 | var nextState = workInProgress.memoizedState;
|
7790 |
|
7791 |
|
7792 | var nextChildren = nextState.element;
|
7793 |
|
7794 | if (nextChildren === prevChildren) {
|
7795 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7796 | }
|
7797 |
|
7798 | var root = workInProgress.stateNode;
|
7799 |
|
7800 | if (root.hydrate && enterHydrationState()) {
|
7801 |
|
7802 |
|
7803 |
|
7804 |
|
7805 | var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
7806 | workInProgress.child = child;
|
7807 | var node = child;
|
7808 |
|
7809 | while (node) {
|
7810 |
|
7811 |
|
7812 |
|
7813 |
|
7814 |
|
7815 |
|
7816 | node.effectTag = node.effectTag & ~Placement | Hydrating;
|
7817 | node = node.sibling;
|
7818 | }
|
7819 | } else {
|
7820 |
|
7821 |
|
7822 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7823 | }
|
7824 |
|
7825 | return workInProgress.child;
|
7826 | }
|
7827 |
|
7828 | function updateHostComponent(current, workInProgress, renderExpirationTime) {
|
7829 | pushHostContext(workInProgress);
|
7830 |
|
7831 | var type = workInProgress.type;
|
7832 | var nextProps = workInProgress.pendingProps;
|
7833 | var prevProps = current !== null ? current.memoizedProps : null;
|
7834 | var nextChildren = nextProps.children;
|
7835 |
|
7836 | if (prevProps !== null && shouldSetTextContent()) {
|
7837 |
|
7838 |
|
7839 | workInProgress.effectTag |= ContentReset;
|
7840 | }
|
7841 |
|
7842 | markRef(current, workInProgress);
|
7843 |
|
7844 | if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree()) {
|
7845 | {
|
7846 | markSpawnedWork(Never);
|
7847 | }
|
7848 |
|
7849 |
|
7850 | workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
|
7851 | return null;
|
7852 | }
|
7853 |
|
7854 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7855 | return workInProgress.child;
|
7856 | }
|
7857 |
|
7858 | function updateHostText(current, workInProgress) {
|
7859 |
|
7860 |
|
7861 |
|
7862 | return null;
|
7863 | }
|
7864 |
|
7865 | function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
|
7866 | if (_current !== null) {
|
7867 |
|
7868 |
|
7869 |
|
7870 |
|
7871 | _current.alternate = null;
|
7872 | workInProgress.alternate = null;
|
7873 |
|
7874 | workInProgress.effectTag |= Placement;
|
7875 | }
|
7876 |
|
7877 | var props = workInProgress.pendingProps;
|
7878 |
|
7879 |
|
7880 | cancelWorkTimer(workInProgress);
|
7881 | var Component = readLazyComponentType(elementType);
|
7882 |
|
7883 | workInProgress.type = Component;
|
7884 | var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
|
7885 | startWorkTimer(workInProgress);
|
7886 | var resolvedProps = resolveDefaultProps(Component, props);
|
7887 | var child;
|
7888 |
|
7889 | switch (resolvedTag) {
|
7890 | case FunctionComponent:
|
7891 | {
|
7892 | {
|
7893 | validateFunctionComponentInDev(workInProgress, Component);
|
7894 | workInProgress.type = Component = resolveFunctionForHotReloading(Component);
|
7895 | }
|
7896 |
|
7897 | child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
7898 | return child;
|
7899 | }
|
7900 |
|
7901 | case ClassComponent:
|
7902 | {
|
7903 | {
|
7904 | workInProgress.type = Component = resolveClassForHotReloading(Component);
|
7905 | }
|
7906 |
|
7907 | child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
7908 | return child;
|
7909 | }
|
7910 |
|
7911 | case ForwardRef:
|
7912 | {
|
7913 | {
|
7914 | workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
|
7915 | }
|
7916 |
|
7917 | child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
7918 | return child;
|
7919 | }
|
7920 |
|
7921 | case MemoComponent:
|
7922 | {
|
7923 | {
|
7924 | if (workInProgress.type !== workInProgress.elementType) {
|
7925 | var outerPropTypes = Component.propTypes;
|
7926 |
|
7927 | if (outerPropTypes) {
|
7928 | checkPropTypes_1(outerPropTypes, resolvedProps,
|
7929 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7930 | }
|
7931 | }
|
7932 | }
|
7933 |
|
7934 | child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps),
|
7935 | updateExpirationTime, renderExpirationTime);
|
7936 | return child;
|
7937 | }
|
7938 | }
|
7939 |
|
7940 | var hint = '';
|
7941 |
|
7942 | {
|
7943 | if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
|
7944 | hint = ' Did you wrap a component in React.lazy() more than once?';
|
7945 | }
|
7946 | }
|
7947 |
|
7948 |
|
7949 |
|
7950 |
|
7951 | {
|
7952 | {
|
7953 | throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint );
|
7954 | }
|
7955 | }
|
7956 | }
|
7957 |
|
7958 | function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7959 | if (_current !== null) {
|
7960 |
|
7961 |
|
7962 |
|
7963 |
|
7964 | _current.alternate = null;
|
7965 | workInProgress.alternate = null;
|
7966 |
|
7967 | workInProgress.effectTag |= Placement;
|
7968 | }
|
7969 |
|
7970 |
|
7971 | workInProgress.tag = ClassComponent;
|
7972 |
|
7973 |
|
7974 |
|
7975 |
|
7976 | var hasContext;
|
7977 |
|
7978 | if (isContextProvider(Component)) {
|
7979 | hasContext = true;
|
7980 | pushContextProvider(workInProgress);
|
7981 | } else {
|
7982 | hasContext = false;
|
7983 | }
|
7984 |
|
7985 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7986 | constructClassInstance(workInProgress, Component, nextProps);
|
7987 | mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7988 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
|
7989 | }
|
7990 |
|
7991 | function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
|
7992 | if (_current !== null) {
|
7993 |
|
7994 |
|
7995 |
|
7996 |
|
7997 | _current.alternate = null;
|
7998 | workInProgress.alternate = null;
|
7999 |
|
8000 | workInProgress.effectTag |= Placement;
|
8001 | }
|
8002 |
|
8003 | var props = workInProgress.pendingProps;
|
8004 | var context;
|
8005 |
|
8006 | {
|
8007 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
|
8008 | context = getMaskedContext(workInProgress, unmaskedContext);
|
8009 | }
|
8010 |
|
8011 | prepareToReadContext(workInProgress, renderExpirationTime);
|
8012 | var value;
|
8013 |
|
8014 | {
|
8015 | if (Component.prototype && typeof Component.prototype.render === 'function') {
|
8016 | var componentName = getComponentName(Component) || 'Unknown';
|
8017 |
|
8018 | if (!didWarnAboutBadClass[componentName]) {
|
8019 | error("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);
|
8020 |
|
8021 | didWarnAboutBadClass[componentName] = true;
|
8022 | }
|
8023 | }
|
8024 |
|
8025 | if (workInProgress.mode & StrictMode) {
|
8026 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
|
8027 | }
|
8028 |
|
8029 | setIsRendering(true);
|
8030 | ReactCurrentOwner$1.current = workInProgress;
|
8031 | value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
|
8032 | setIsRendering(false);
|
8033 | }
|
8034 |
|
8035 |
|
8036 | workInProgress.effectTag |= PerformedWork;
|
8037 |
|
8038 | if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
|
8039 | {
|
8040 | var _componentName = getComponentName(Component) || 'Unknown';
|
8041 |
|
8042 | if (!didWarnAboutModulePatternComponent[_componentName]) {
|
8043 | error('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);
|
8044 |
|
8045 | didWarnAboutModulePatternComponent[_componentName] = true;
|
8046 | }
|
8047 | }
|
8048 |
|
8049 |
|
8050 | workInProgress.tag = ClassComponent;
|
8051 |
|
8052 | workInProgress.memoizedState = null;
|
8053 | workInProgress.updateQueue = null;
|
8054 |
|
8055 |
|
8056 |
|
8057 | var hasContext = false;
|
8058 |
|
8059 | if (isContextProvider(Component)) {
|
8060 | hasContext = true;
|
8061 | pushContextProvider(workInProgress);
|
8062 | } else {
|
8063 | hasContext = false;
|
8064 | }
|
8065 |
|
8066 | workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
|
8067 | initializeUpdateQueue(workInProgress);
|
8068 | var getDerivedStateFromProps = Component.getDerivedStateFromProps;
|
8069 |
|
8070 | if (typeof getDerivedStateFromProps === 'function') {
|
8071 | applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
|
8072 | }
|
8073 |
|
8074 | adoptClassInstance(workInProgress, value);
|
8075 | mountClassInstance(workInProgress, Component, props, renderExpirationTime);
|
8076 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
|
8077 | } else {
|
8078 |
|
8079 | workInProgress.tag = FunctionComponent;
|
8080 |
|
8081 | reconcileChildren(null, workInProgress, value, renderExpirationTime);
|
8082 |
|
8083 | {
|
8084 | validateFunctionComponentInDev(workInProgress, Component);
|
8085 | }
|
8086 |
|
8087 | return workInProgress.child;
|
8088 | }
|
8089 | }
|
8090 |
|
8091 | function validateFunctionComponentInDev(workInProgress, Component) {
|
8092 | {
|
8093 | if (Component) {
|
8094 | if (Component.childContextTypes) {
|
8095 | error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
|
8096 | }
|
8097 | }
|
8098 |
|
8099 | if (workInProgress.ref !== null) {
|
8100 | var info = '';
|
8101 | var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
8102 |
|
8103 | if (ownerName) {
|
8104 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
8105 | }
|
8106 |
|
8107 | var warningKey = ownerName || workInProgress._debugID || '';
|
8108 | var debugSource = workInProgress._debugSource;
|
8109 |
|
8110 | if (debugSource) {
|
8111 | warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
|
8112 | }
|
8113 |
|
8114 | if (!didWarnAboutFunctionRefs[warningKey]) {
|
8115 | didWarnAboutFunctionRefs[warningKey] = true;
|
8116 |
|
8117 | error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
|
8118 | }
|
8119 | }
|
8120 |
|
8121 | if (typeof Component.getDerivedStateFromProps === 'function') {
|
8122 | var _componentName2 = getComponentName(Component) || 'Unknown';
|
8123 |
|
8124 | if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
|
8125 | error('%s: Function components do not support getDerivedStateFromProps.', _componentName2);
|
8126 |
|
8127 | didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
|
8128 | }
|
8129 | }
|
8130 |
|
8131 | if (typeof Component.contextType === 'object' && Component.contextType !== null) {
|
8132 | var _componentName3 = getComponentName(Component) || 'Unknown';
|
8133 |
|
8134 | if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
|
8135 | error('%s: Function components do not support contextType.', _componentName3);
|
8136 |
|
8137 | didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
|
8138 | }
|
8139 | }
|
8140 | }
|
8141 | }
|
8142 |
|
8143 | var SUSPENDED_MARKER = {
|
8144 | dehydrated: null,
|
8145 | retryTime: NoWork
|
8146 | };
|
8147 |
|
8148 | function shouldRemainOnFallback(suspenseContext, current, workInProgress) {
|
8149 |
|
8150 |
|
8151 | return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current === null || current.memoizedState !== null);
|
8152 | }
|
8153 |
|
8154 | function updateSuspenseComponent(current, workInProgress, renderExpirationTime) {
|
8155 | var mode = workInProgress.mode;
|
8156 | var nextProps = workInProgress.pendingProps;
|
8157 |
|
8158 | {
|
8159 | if (shouldSuspend(workInProgress)) {
|
8160 | workInProgress.effectTag |= DidCapture;
|
8161 | }
|
8162 | }
|
8163 |
|
8164 | var suspenseContext = suspenseStackCursor.current;
|
8165 | var nextDidTimeout = false;
|
8166 | var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
|
8167 |
|
8168 | if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
|
8169 |
|
8170 |
|
8171 | nextDidTimeout = true;
|
8172 | workInProgress.effectTag &= ~DidCapture;
|
8173 | } else {
|
8174 |
|
8175 | if (current === null || current.memoizedState !== null) {
|
8176 |
|
8177 |
|
8178 |
|
8179 |
|
8180 |
|
8181 | if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
|
8182 | suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
|
8183 | }
|
8184 | }
|
8185 | }
|
8186 |
|
8187 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
8188 | pushSuspenseContext(workInProgress, suspenseContext);
|
8189 |
|
8190 |
|
8191 |
|
8192 |
|
8193 |
|
8194 |
|
8195 |
|
8196 |
|
8197 |
|
8198 |
|
8199 |
|
8200 |
|
8201 |
|
8202 |
|
8203 |
|
8204 |
|
8205 |
|
8206 |
|
8207 |
|
8208 |
|
8209 |
|
8210 | if (current === null) {
|
8211 |
|
8212 |
|
8213 | if (nextProps.fallback !== undefined) ;
|
8214 |
|
8215 |
|
8216 |
|
8217 | if (nextDidTimeout) {
|
8218 |
|
8219 | var nextFallbackChildren = nextProps.fallback;
|
8220 | var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
|
8221 | primaryChildFragment.return = workInProgress;
|
8222 |
|
8223 | if ((workInProgress.mode & BlockingMode) === NoMode) {
|
8224 |
|
8225 |
|
8226 | var progressedState = workInProgress.memoizedState;
|
8227 | var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
|
8228 | primaryChildFragment.child = progressedPrimaryChild;
|
8229 | var progressedChild = progressedPrimaryChild;
|
8230 |
|
8231 | while (progressedChild !== null) {
|
8232 | progressedChild.return = primaryChildFragment;
|
8233 | progressedChild = progressedChild.sibling;
|
8234 | }
|
8235 | }
|
8236 |
|
8237 | var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
|
8238 | fallbackChildFragment.return = workInProgress;
|
8239 | primaryChildFragment.sibling = fallbackChildFragment;
|
8240 |
|
8241 |
|
8242 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
8243 | workInProgress.child = primaryChildFragment;
|
8244 | return fallbackChildFragment;
|
8245 | } else {
|
8246 |
|
8247 | var nextPrimaryChildren = nextProps.children;
|
8248 | workInProgress.memoizedState = null;
|
8249 | return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
|
8250 | }
|
8251 | } else {
|
8252 |
|
8253 |
|
8254 | var prevState = current.memoizedState;
|
8255 |
|
8256 | if (prevState !== null) {
|
8257 |
|
8258 |
|
8259 |
|
8260 | var currentPrimaryChildFragment = current.child;
|
8261 | var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
8262 |
|
8263 | if (nextDidTimeout) {
|
8264 |
|
8265 |
|
8266 | var _nextFallbackChildren2 = nextProps.fallback;
|
8267 |
|
8268 | var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps);
|
8269 |
|
8270 | _primaryChildFragment2.return = workInProgress;
|
8271 |
|
8272 | if ((workInProgress.mode & BlockingMode) === NoMode) {
|
8273 |
|
8274 |
|
8275 | var _progressedState = workInProgress.memoizedState;
|
8276 |
|
8277 | var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
|
8278 |
|
8279 | if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
|
8280 | _primaryChildFragment2.child = _progressedPrimaryChild;
|
8281 | var _progressedChild2 = _progressedPrimaryChild;
|
8282 |
|
8283 | while (_progressedChild2 !== null) {
|
8284 | _progressedChild2.return = _primaryChildFragment2;
|
8285 | _progressedChild2 = _progressedChild2.sibling;
|
8286 | }
|
8287 | }
|
8288 | }
|
8289 |
|
8290 |
|
8291 |
|
8292 | if ( workInProgress.mode & ProfileMode) {
|
8293 |
|
8294 | var _treeBaseDuration = 0;
|
8295 | var _hiddenChild = _primaryChildFragment2.child;
|
8296 |
|
8297 | while (_hiddenChild !== null) {
|
8298 | _treeBaseDuration += _hiddenChild.treeBaseDuration;
|
8299 | _hiddenChild = _hiddenChild.sibling;
|
8300 | }
|
8301 |
|
8302 | _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
|
8303 | }
|
8304 |
|
8305 |
|
8306 |
|
8307 | var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2);
|
8308 |
|
8309 | _fallbackChildFragment2.return = workInProgress;
|
8310 | _primaryChildFragment2.sibling = _fallbackChildFragment2;
|
8311 | _primaryChildFragment2.childExpirationTime = NoWork;
|
8312 |
|
8313 |
|
8314 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
8315 | workInProgress.child = _primaryChildFragment2;
|
8316 | return _fallbackChildFragment2;
|
8317 | } else {
|
8318 |
|
8319 |
|
8320 | var _nextPrimaryChildren = nextProps.children;
|
8321 | var currentPrimaryChild = currentPrimaryChildFragment.child;
|
8322 | var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
|
8323 |
|
8324 |
|
8325 |
|
8326 |
|
8327 |
|
8328 |
|
8329 | workInProgress.memoizedState = null;
|
8330 | return workInProgress.child = primaryChild;
|
8331 | }
|
8332 | } else {
|
8333 |
|
8334 |
|
8335 | var _currentPrimaryChild = current.child;
|
8336 |
|
8337 | if (nextDidTimeout) {
|
8338 |
|
8339 |
|
8340 | var _nextFallbackChildren3 = nextProps.fallback;
|
8341 |
|
8342 | var _primaryChildFragment3 = createFiberFromFragment(
|
8343 |
|
8344 | null, mode, NoWork, null);
|
8345 |
|
8346 | _primaryChildFragment3.return = workInProgress;
|
8347 | _primaryChildFragment3.child = _currentPrimaryChild;
|
8348 |
|
8349 | if (_currentPrimaryChild !== null) {
|
8350 | _currentPrimaryChild.return = _primaryChildFragment3;
|
8351 | }
|
8352 |
|
8353 |
|
8354 |
|
8355 |
|
8356 |
|
8357 | if ((workInProgress.mode & BlockingMode) === NoMode) {
|
8358 |
|
8359 |
|
8360 | var _progressedState2 = workInProgress.memoizedState;
|
8361 |
|
8362 | var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
|
8363 |
|
8364 | _primaryChildFragment3.child = _progressedPrimaryChild2;
|
8365 | var _progressedChild3 = _progressedPrimaryChild2;
|
8366 |
|
8367 | while (_progressedChild3 !== null) {
|
8368 | _progressedChild3.return = _primaryChildFragment3;
|
8369 | _progressedChild3 = _progressedChild3.sibling;
|
8370 | }
|
8371 | }
|
8372 |
|
8373 |
|
8374 |
|
8375 | if ( workInProgress.mode & ProfileMode) {
|
8376 |
|
8377 | var _treeBaseDuration2 = 0;
|
8378 | var _hiddenChild2 = _primaryChildFragment3.child;
|
8379 |
|
8380 | while (_hiddenChild2 !== null) {
|
8381 | _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
|
8382 | _hiddenChild2 = _hiddenChild2.sibling;
|
8383 | }
|
8384 |
|
8385 | _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
|
8386 | }
|
8387 |
|
8388 |
|
8389 | var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null);
|
8390 |
|
8391 | _fallbackChildFragment3.return = workInProgress;
|
8392 | _primaryChildFragment3.sibling = _fallbackChildFragment3;
|
8393 | _fallbackChildFragment3.effectTag |= Placement;
|
8394 | _primaryChildFragment3.childExpirationTime = NoWork;
|
8395 |
|
8396 |
|
8397 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
8398 | workInProgress.child = _primaryChildFragment3;
|
8399 | return _fallbackChildFragment3;
|
8400 | } else {
|
8401 |
|
8402 |
|
8403 | workInProgress.memoizedState = null;
|
8404 | var _nextPrimaryChildren2 = nextProps.children;
|
8405 | return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
|
8406 | }
|
8407 | }
|
8408 | }
|
8409 | }
|
8410 |
|
8411 | function scheduleWorkOnFiber(fiber, renderExpirationTime) {
|
8412 | if (fiber.expirationTime < renderExpirationTime) {
|
8413 | fiber.expirationTime = renderExpirationTime;
|
8414 | }
|
8415 |
|
8416 | var alternate = fiber.alternate;
|
8417 |
|
8418 | if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
|
8419 | alternate.expirationTime = renderExpirationTime;
|
8420 | }
|
8421 |
|
8422 | scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
|
8423 | }
|
8424 |
|
8425 | function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
|
8426 |
|
8427 |
|
8428 |
|
8429 | var node = firstChild;
|
8430 |
|
8431 | while (node !== null) {
|
8432 | if (node.tag === SuspenseComponent) {
|
8433 | var state = node.memoizedState;
|
8434 |
|
8435 | if (state !== null) {
|
8436 | scheduleWorkOnFiber(node, renderExpirationTime);
|
8437 | }
|
8438 | } else if (node.tag === SuspenseListComponent) {
|
8439 |
|
8440 |
|
8441 |
|
8442 |
|
8443 |
|
8444 | scheduleWorkOnFiber(node, renderExpirationTime);
|
8445 | } else if (node.child !== null) {
|
8446 | node.child.return = node;
|
8447 | node = node.child;
|
8448 | continue;
|
8449 | }
|
8450 |
|
8451 | if (node === workInProgress) {
|
8452 | return;
|
8453 | }
|
8454 |
|
8455 | while (node.sibling === null) {
|
8456 | if (node.return === null || node.return === workInProgress) {
|
8457 | return;
|
8458 | }
|
8459 |
|
8460 | node = node.return;
|
8461 | }
|
8462 |
|
8463 | node.sibling.return = node.return;
|
8464 | node = node.sibling;
|
8465 | }
|
8466 | }
|
8467 |
|
8468 | function findLastContentRow(firstChild) {
|
8469 |
|
8470 |
|
8471 |
|
8472 |
|
8473 |
|
8474 |
|
8475 |
|
8476 | var row = firstChild;
|
8477 | var lastContentRow = null;
|
8478 |
|
8479 | while (row !== null) {
|
8480 | var currentRow = row.alternate;
|
8481 |
|
8482 | if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
8483 | lastContentRow = row;
|
8484 | }
|
8485 |
|
8486 | row = row.sibling;
|
8487 | }
|
8488 |
|
8489 | return lastContentRow;
|
8490 | }
|
8491 |
|
8492 | function validateRevealOrder(revealOrder) {
|
8493 | {
|
8494 | if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
|
8495 | didWarnAboutRevealOrder[revealOrder] = true;
|
8496 |
|
8497 | if (typeof revealOrder === 'string') {
|
8498 | switch (revealOrder.toLowerCase()) {
|
8499 | case 'together':
|
8500 | case 'forwards':
|
8501 | case 'backwards':
|
8502 | {
|
8503 | error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
|
8504 |
|
8505 | break;
|
8506 | }
|
8507 |
|
8508 | case 'forward':
|
8509 | case 'backward':
|
8510 | {
|
8511 | error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
|
8512 |
|
8513 | break;
|
8514 | }
|
8515 |
|
8516 | default:
|
8517 | error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
8518 |
|
8519 | break;
|
8520 | }
|
8521 | } else {
|
8522 | error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
8523 | }
|
8524 | }
|
8525 | }
|
8526 | }
|
8527 |
|
8528 | function validateTailOptions(tailMode, revealOrder) {
|
8529 | {
|
8530 | if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
|
8531 | if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
|
8532 | didWarnAboutTailOptions[tailMode] = true;
|
8533 |
|
8534 | error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
|
8535 | } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
|
8536 | didWarnAboutTailOptions[tailMode] = true;
|
8537 |
|
8538 | error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
|
8539 | }
|
8540 | }
|
8541 | }
|
8542 | }
|
8543 |
|
8544 | function validateSuspenseListNestedChild(childSlot, index) {
|
8545 | {
|
8546 | var isArray = Array.isArray(childSlot);
|
8547 | var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
|
8548 |
|
8549 | if (isArray || isIterable) {
|
8550 | var type = isArray ? 'array' : 'iterable';
|
8551 |
|
8552 | error('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);
|
8553 |
|
8554 | return false;
|
8555 | }
|
8556 | }
|
8557 |
|
8558 | return true;
|
8559 | }
|
8560 |
|
8561 | function validateSuspenseListChildren(children, revealOrder) {
|
8562 | {
|
8563 | if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
|
8564 | if (Array.isArray(children)) {
|
8565 | for (var i = 0; i < children.length; i++) {
|
8566 | if (!validateSuspenseListNestedChild(children[i], i)) {
|
8567 | return;
|
8568 | }
|
8569 | }
|
8570 | } else {
|
8571 | var iteratorFn = getIteratorFn(children);
|
8572 |
|
8573 | if (typeof iteratorFn === 'function') {
|
8574 | var childrenIterator = iteratorFn.call(children);
|
8575 |
|
8576 | if (childrenIterator) {
|
8577 | var step = childrenIterator.next();
|
8578 | var _i = 0;
|
8579 |
|
8580 | for (; !step.done; step = childrenIterator.next()) {
|
8581 | if (!validateSuspenseListNestedChild(step.value, _i)) {
|
8582 | return;
|
8583 | }
|
8584 |
|
8585 | _i++;
|
8586 | }
|
8587 | }
|
8588 | } else {
|
8589 | error('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);
|
8590 | }
|
8591 | }
|
8592 | }
|
8593 | }
|
8594 | }
|
8595 |
|
8596 | function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) {
|
8597 | var renderState = workInProgress.memoizedState;
|
8598 |
|
8599 | if (renderState === null) {
|
8600 | workInProgress.memoizedState = {
|
8601 | isBackwards: isBackwards,
|
8602 | rendering: null,
|
8603 | renderingStartTime: 0,
|
8604 | last: lastContentRow,
|
8605 | tail: tail,
|
8606 | tailExpiration: 0,
|
8607 | tailMode: tailMode,
|
8608 | lastEffect: lastEffectBeforeRendering
|
8609 | };
|
8610 | } else {
|
8611 |
|
8612 | renderState.isBackwards = isBackwards;
|
8613 | renderState.rendering = null;
|
8614 | renderState.renderingStartTime = 0;
|
8615 | renderState.last = lastContentRow;
|
8616 | renderState.tail = tail;
|
8617 | renderState.tailExpiration = 0;
|
8618 | renderState.tailMode = tailMode;
|
8619 | renderState.lastEffect = lastEffectBeforeRendering;
|
8620 | }
|
8621 | }
|
8622 |
|
8623 |
|
8624 |
|
8625 |
|
8626 |
|
8627 |
|
8628 |
|
8629 |
|
8630 | function updateSuspenseListComponent(current, workInProgress, renderExpirationTime) {
|
8631 | var nextProps = workInProgress.pendingProps;
|
8632 | var revealOrder = nextProps.revealOrder;
|
8633 | var tailMode = nextProps.tail;
|
8634 | var newChildren = nextProps.children;
|
8635 | validateRevealOrder(revealOrder);
|
8636 | validateTailOptions(tailMode, revealOrder);
|
8637 | validateSuspenseListChildren(newChildren, revealOrder);
|
8638 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
8639 | var suspenseContext = suspenseStackCursor.current;
|
8640 | var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
8641 |
|
8642 | if (shouldForceFallback) {
|
8643 | suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
8644 | workInProgress.effectTag |= DidCapture;
|
8645 | } else {
|
8646 | var didSuspendBefore = current !== null && (current.effectTag & DidCapture) !== NoEffect;
|
8647 |
|
8648 | if (didSuspendBefore) {
|
8649 |
|
8650 |
|
8651 |
|
8652 | propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
|
8653 | }
|
8654 |
|
8655 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
8656 | }
|
8657 |
|
8658 | pushSuspenseContext(workInProgress, suspenseContext);
|
8659 |
|
8660 | if ((workInProgress.mode & BlockingMode) === NoMode) {
|
8661 |
|
8662 |
|
8663 | workInProgress.memoizedState = null;
|
8664 | } else {
|
8665 | switch (revealOrder) {
|
8666 | case 'forwards':
|
8667 | {
|
8668 | var lastContentRow = findLastContentRow(workInProgress.child);
|
8669 | var tail;
|
8670 |
|
8671 | if (lastContentRow === null) {
|
8672 |
|
8673 |
|
8674 | tail = workInProgress.child;
|
8675 | workInProgress.child = null;
|
8676 | } else {
|
8677 |
|
8678 |
|
8679 | tail = lastContentRow.sibling;
|
8680 | lastContentRow.sibling = null;
|
8681 | }
|
8682 |
|
8683 | initSuspenseListRenderState(workInProgress, false,
|
8684 | tail, lastContentRow, tailMode, workInProgress.lastEffect);
|
8685 | break;
|
8686 | }
|
8687 |
|
8688 | case 'backwards':
|
8689 | {
|
8690 |
|
8691 |
|
8692 |
|
8693 |
|
8694 | var _tail = null;
|
8695 | var row = workInProgress.child;
|
8696 | workInProgress.child = null;
|
8697 |
|
8698 | while (row !== null) {
|
8699 | var currentRow = row.alternate;
|
8700 |
|
8701 | if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
8702 |
|
8703 | workInProgress.child = row;
|
8704 | break;
|
8705 | }
|
8706 |
|
8707 | var nextRow = row.sibling;
|
8708 | row.sibling = _tail;
|
8709 | _tail = row;
|
8710 | row = nextRow;
|
8711 | }
|
8712 |
|
8713 |
|
8714 | initSuspenseListRenderState(workInProgress, true,
|
8715 | _tail, null,
|
8716 | tailMode, workInProgress.lastEffect);
|
8717 | break;
|
8718 | }
|
8719 |
|
8720 | case 'together':
|
8721 | {
|
8722 | initSuspenseListRenderState(workInProgress, false,
|
8723 | null,
|
8724 | null,
|
8725 | undefined, workInProgress.lastEffect);
|
8726 | break;
|
8727 | }
|
8728 |
|
8729 | default:
|
8730 | {
|
8731 |
|
8732 |
|
8733 | workInProgress.memoizedState = null;
|
8734 | }
|
8735 | }
|
8736 | }
|
8737 |
|
8738 | return workInProgress.child;
|
8739 | }
|
8740 |
|
8741 | function updatePortalComponent(current, workInProgress, renderExpirationTime) {
|
8742 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
8743 | var nextChildren = workInProgress.pendingProps;
|
8744 |
|
8745 | if (current === null) {
|
8746 |
|
8747 |
|
8748 |
|
8749 |
|
8750 |
|
8751 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
8752 | } else {
|
8753 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
8754 | }
|
8755 |
|
8756 | return workInProgress.child;
|
8757 | }
|
8758 |
|
8759 | function updateContextProvider(current, workInProgress, renderExpirationTime) {
|
8760 | var providerType = workInProgress.type;
|
8761 | var context = providerType._context;
|
8762 | var newProps = workInProgress.pendingProps;
|
8763 | var oldProps = workInProgress.memoizedProps;
|
8764 | var newValue = newProps.value;
|
8765 |
|
8766 | {
|
8767 | var providerPropTypes = workInProgress.type.propTypes;
|
8768 |
|
8769 | if (providerPropTypes) {
|
8770 | checkPropTypes_1(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
|
8771 | }
|
8772 | }
|
8773 |
|
8774 | pushProvider(workInProgress, newValue);
|
8775 |
|
8776 | if (oldProps !== null) {
|
8777 | var oldValue = oldProps.value;
|
8778 | var changedBits = calculateChangedBits(context, newValue, oldValue);
|
8779 |
|
8780 | if (changedBits === 0) {
|
8781 |
|
8782 | if (oldProps.children === newProps.children && !hasContextChanged()) {
|
8783 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8784 | }
|
8785 | } else {
|
8786 |
|
8787 |
|
8788 | propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
|
8789 | }
|
8790 | }
|
8791 |
|
8792 | var newChildren = newProps.children;
|
8793 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
8794 | return workInProgress.child;
|
8795 | }
|
8796 |
|
8797 | var hasWarnedAboutUsingContextAsConsumer = false;
|
8798 |
|
8799 | function updateContextConsumer(current, workInProgress, renderExpirationTime) {
|
8800 | var context = workInProgress.type;
|
8801 |
|
8802 |
|
8803 |
|
8804 |
|
8805 |
|
8806 |
|
8807 |
|
8808 | {
|
8809 | if (context._context === undefined) {
|
8810 |
|
8811 |
|
8812 |
|
8813 | if (context !== context.Consumer) {
|
8814 | if (!hasWarnedAboutUsingContextAsConsumer) {
|
8815 | hasWarnedAboutUsingContextAsConsumer = true;
|
8816 |
|
8817 | error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
|
8818 | }
|
8819 | }
|
8820 | } else {
|
8821 | context = context._context;
|
8822 | }
|
8823 | }
|
8824 |
|
8825 | var newProps = workInProgress.pendingProps;
|
8826 | var render = newProps.children;
|
8827 |
|
8828 | {
|
8829 | if (typeof render !== 'function') {
|
8830 | error('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.');
|
8831 | }
|
8832 | }
|
8833 |
|
8834 | prepareToReadContext(workInProgress, renderExpirationTime);
|
8835 | var newValue = readContext(context, newProps.unstable_observedBits);
|
8836 | var newChildren;
|
8837 |
|
8838 | {
|
8839 | ReactCurrentOwner$1.current = workInProgress;
|
8840 | setIsRendering(true);
|
8841 | newChildren = render(newValue);
|
8842 | setIsRendering(false);
|
8843 | }
|
8844 |
|
8845 |
|
8846 | workInProgress.effectTag |= PerformedWork;
|
8847 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
8848 | return workInProgress.child;
|
8849 | }
|
8850 |
|
8851 | function markWorkInProgressReceivedUpdate() {
|
8852 | didReceiveUpdate = true;
|
8853 | }
|
8854 |
|
8855 | function bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime) {
|
8856 | cancelWorkTimer(workInProgress);
|
8857 |
|
8858 | if (current !== null) {
|
8859 |
|
8860 | workInProgress.dependencies = current.dependencies;
|
8861 | }
|
8862 |
|
8863 | {
|
8864 |
|
8865 | stopProfilerTimerIfRunning();
|
8866 | }
|
8867 |
|
8868 | var updateExpirationTime = workInProgress.expirationTime;
|
8869 |
|
8870 | if (updateExpirationTime !== NoWork) {
|
8871 | markUnprocessedUpdateTime(updateExpirationTime);
|
8872 | }
|
8873 |
|
8874 |
|
8875 | var childExpirationTime = workInProgress.childExpirationTime;
|
8876 |
|
8877 | if (childExpirationTime < renderExpirationTime) {
|
8878 |
|
8879 |
|
8880 |
|
8881 | return null;
|
8882 | } else {
|
8883 |
|
8884 |
|
8885 | cloneChildFibers(current, workInProgress);
|
8886 | return workInProgress.child;
|
8887 | }
|
8888 | }
|
8889 |
|
8890 | function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
|
8891 | {
|
8892 | var returnFiber = oldWorkInProgress.return;
|
8893 |
|
8894 | if (returnFiber === null) {
|
8895 | throw new Error('Cannot swap the root fiber.');
|
8896 | }
|
8897 |
|
8898 |
|
8899 |
|
8900 | current.alternate = null;
|
8901 | oldWorkInProgress.alternate = null;
|
8902 |
|
8903 | newWorkInProgress.index = oldWorkInProgress.index;
|
8904 | newWorkInProgress.sibling = oldWorkInProgress.sibling;
|
8905 | newWorkInProgress.return = oldWorkInProgress.return;
|
8906 | newWorkInProgress.ref = oldWorkInProgress.ref;
|
8907 |
|
8908 | if (oldWorkInProgress === returnFiber.child) {
|
8909 | returnFiber.child = newWorkInProgress;
|
8910 | } else {
|
8911 | var prevSibling = returnFiber.child;
|
8912 |
|
8913 | if (prevSibling === null) {
|
8914 | throw new Error('Expected parent to have a child.');
|
8915 | }
|
8916 |
|
8917 | while (prevSibling.sibling !== oldWorkInProgress) {
|
8918 | prevSibling = prevSibling.sibling;
|
8919 |
|
8920 | if (prevSibling === null) {
|
8921 | throw new Error('Expected to find the previous sibling.');
|
8922 | }
|
8923 | }
|
8924 |
|
8925 | prevSibling.sibling = newWorkInProgress;
|
8926 | }
|
8927 |
|
8928 |
|
8929 |
|
8930 | var last = returnFiber.lastEffect;
|
8931 |
|
8932 | if (last !== null) {
|
8933 | last.nextEffect = current;
|
8934 | returnFiber.lastEffect = current;
|
8935 | } else {
|
8936 | returnFiber.firstEffect = returnFiber.lastEffect = current;
|
8937 | }
|
8938 |
|
8939 | current.nextEffect = null;
|
8940 | current.effectTag = Deletion;
|
8941 | newWorkInProgress.effectTag |= Placement;
|
8942 |
|
8943 | return newWorkInProgress;
|
8944 | }
|
8945 | }
|
8946 |
|
8947 | function beginWork(current, workInProgress, renderExpirationTime) {
|
8948 | var updateExpirationTime = workInProgress.expirationTime;
|
8949 |
|
8950 | {
|
8951 | if (workInProgress._debugNeedsRemount && current !== null) {
|
8952 |
|
8953 | return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
|
8954 | }
|
8955 | }
|
8956 |
|
8957 | if (current !== null) {
|
8958 | var oldProps = current.memoizedProps;
|
8959 | var newProps = workInProgress.pendingProps;
|
8960 |
|
8961 | if (oldProps !== newProps || hasContextChanged() || (
|
8962 | workInProgress.type !== current.type )) {
|
8963 |
|
8964 |
|
8965 | didReceiveUpdate = true;
|
8966 | } else if (updateExpirationTime < renderExpirationTime) {
|
8967 | didReceiveUpdate = false;
|
8968 |
|
8969 |
|
8970 |
|
8971 | switch (workInProgress.tag) {
|
8972 | case HostRoot:
|
8973 | pushHostRootContext(workInProgress);
|
8974 | break;
|
8975 |
|
8976 | case HostComponent:
|
8977 | pushHostContext(workInProgress);
|
8978 |
|
8979 | if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type)) {
|
8980 | {
|
8981 | markSpawnedWork(Never);
|
8982 | }
|
8983 |
|
8984 |
|
8985 | workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
|
8986 | return null;
|
8987 | }
|
8988 |
|
8989 | break;
|
8990 |
|
8991 | case ClassComponent:
|
8992 | {
|
8993 | var Component = workInProgress.type;
|
8994 |
|
8995 | if (isContextProvider(Component)) {
|
8996 | pushContextProvider(workInProgress);
|
8997 | }
|
8998 |
|
8999 | break;
|
9000 | }
|
9001 |
|
9002 | case HostPortal:
|
9003 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
9004 | break;
|
9005 |
|
9006 | case ContextProvider:
|
9007 | {
|
9008 | var newValue = workInProgress.memoizedProps.value;
|
9009 | pushProvider(workInProgress, newValue);
|
9010 | break;
|
9011 | }
|
9012 |
|
9013 | case Profiler:
|
9014 | {
|
9015 |
|
9016 | var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
|
9017 |
|
9018 | if (hasChildWork) {
|
9019 | workInProgress.effectTag |= Update;
|
9020 | }
|
9021 | }
|
9022 |
|
9023 | break;
|
9024 |
|
9025 | case SuspenseComponent:
|
9026 | {
|
9027 | var state = workInProgress.memoizedState;
|
9028 |
|
9029 | if (state !== null) {
|
9030 |
|
9031 |
|
9032 |
|
9033 |
|
9034 |
|
9035 | var primaryChildFragment = workInProgress.child;
|
9036 | var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
|
9037 |
|
9038 | if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
|
9039 |
|
9040 |
|
9041 | return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
|
9042 | } else {
|
9043 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
9044 |
|
9045 |
|
9046 | var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
9047 |
|
9048 | if (child !== null) {
|
9049 |
|
9050 |
|
9051 | return child.sibling;
|
9052 | } else {
|
9053 | return null;
|
9054 | }
|
9055 | }
|
9056 | } else {
|
9057 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
9058 | }
|
9059 |
|
9060 | break;
|
9061 | }
|
9062 |
|
9063 | case SuspenseListComponent:
|
9064 | {
|
9065 | var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect;
|
9066 |
|
9067 | var _hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
|
9068 |
|
9069 | if (didSuspendBefore) {
|
9070 | if (_hasChildWork) {
|
9071 |
|
9072 |
|
9073 |
|
9074 |
|
9075 |
|
9076 | return updateSuspenseListComponent(current, workInProgress, renderExpirationTime);
|
9077 | }
|
9078 |
|
9079 |
|
9080 |
|
9081 |
|
9082 | workInProgress.effectTag |= DidCapture;
|
9083 | }
|
9084 |
|
9085 |
|
9086 |
|
9087 |
|
9088 | var renderState = workInProgress.memoizedState;
|
9089 |
|
9090 | if (renderState !== null) {
|
9091 |
|
9092 |
|
9093 | renderState.rendering = null;
|
9094 | renderState.tail = null;
|
9095 | }
|
9096 |
|
9097 | pushSuspenseContext(workInProgress, suspenseStackCursor.current);
|
9098 |
|
9099 | if (_hasChildWork) {
|
9100 | break;
|
9101 | } else {
|
9102 |
|
9103 |
|
9104 |
|
9105 | return null;
|
9106 | }
|
9107 | }
|
9108 | }
|
9109 |
|
9110 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
9111 | } else {
|
9112 |
|
9113 |
|
9114 |
|
9115 |
|
9116 | didReceiveUpdate = false;
|
9117 | }
|
9118 | } else {
|
9119 | didReceiveUpdate = false;
|
9120 | }
|
9121 |
|
9122 |
|
9123 |
|
9124 |
|
9125 |
|
9126 |
|
9127 | workInProgress.expirationTime = NoWork;
|
9128 |
|
9129 | switch (workInProgress.tag) {
|
9130 | case IndeterminateComponent:
|
9131 | {
|
9132 | return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderExpirationTime);
|
9133 | }
|
9134 |
|
9135 | case LazyComponent:
|
9136 | {
|
9137 | var elementType = workInProgress.elementType;
|
9138 | return mountLazyComponent(current, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
|
9139 | }
|
9140 |
|
9141 | case FunctionComponent:
|
9142 | {
|
9143 | var _Component = workInProgress.type;
|
9144 | var unresolvedProps = workInProgress.pendingProps;
|
9145 | var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
|
9146 | return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderExpirationTime);
|
9147 | }
|
9148 |
|
9149 | case ClassComponent:
|
9150 | {
|
9151 | var _Component2 = workInProgress.type;
|
9152 | var _unresolvedProps = workInProgress.pendingProps;
|
9153 |
|
9154 | var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
|
9155 |
|
9156 | return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
|
9157 | }
|
9158 |
|
9159 | case HostRoot:
|
9160 | return updateHostRoot(current, workInProgress, renderExpirationTime);
|
9161 |
|
9162 | case HostComponent:
|
9163 | return updateHostComponent(current, workInProgress, renderExpirationTime);
|
9164 |
|
9165 | case HostText:
|
9166 | return updateHostText();
|
9167 |
|
9168 | case SuspenseComponent:
|
9169 | return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
|
9170 |
|
9171 | case HostPortal:
|
9172 | return updatePortalComponent(current, workInProgress, renderExpirationTime);
|
9173 |
|
9174 | case ForwardRef:
|
9175 | {
|
9176 | var type = workInProgress.type;
|
9177 | var _unresolvedProps2 = workInProgress.pendingProps;
|
9178 |
|
9179 | var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
9180 |
|
9181 | return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderExpirationTime);
|
9182 | }
|
9183 |
|
9184 | case Fragment:
|
9185 | return updateFragment(current, workInProgress, renderExpirationTime);
|
9186 |
|
9187 | case Mode:
|
9188 | return updateMode(current, workInProgress, renderExpirationTime);
|
9189 |
|
9190 | case Profiler:
|
9191 | return updateProfiler(current, workInProgress, renderExpirationTime);
|
9192 |
|
9193 | case ContextProvider:
|
9194 | return updateContextProvider(current, workInProgress, renderExpirationTime);
|
9195 |
|
9196 | case ContextConsumer:
|
9197 | return updateContextConsumer(current, workInProgress, renderExpirationTime);
|
9198 |
|
9199 | case MemoComponent:
|
9200 | {
|
9201 | var _type2 = workInProgress.type;
|
9202 | var _unresolvedProps3 = workInProgress.pendingProps;
|
9203 |
|
9204 | var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
|
9205 |
|
9206 | {
|
9207 | if (workInProgress.type !== workInProgress.elementType) {
|
9208 | var outerPropTypes = _type2.propTypes;
|
9209 |
|
9210 | if (outerPropTypes) {
|
9211 | checkPropTypes_1(outerPropTypes, _resolvedProps3,
|
9212 | 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
|
9213 | }
|
9214 | }
|
9215 | }
|
9216 |
|
9217 | _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
|
9218 | return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
|
9219 | }
|
9220 |
|
9221 | case SimpleMemoComponent:
|
9222 | {
|
9223 | return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
|
9224 | }
|
9225 |
|
9226 | case IncompleteClassComponent:
|
9227 | {
|
9228 | var _Component3 = workInProgress.type;
|
9229 | var _unresolvedProps4 = workInProgress.pendingProps;
|
9230 |
|
9231 | var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
|
9232 |
|
9233 | return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
|
9234 | }
|
9235 |
|
9236 | case SuspenseListComponent:
|
9237 | {
|
9238 | return updateSuspenseListComponent(current, workInProgress, renderExpirationTime);
|
9239 | }
|
9240 | }
|
9241 |
|
9242 | {
|
9243 | {
|
9244 | throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." );
|
9245 | }
|
9246 | }
|
9247 | }
|
9248 |
|
9249 | function markUpdate(workInProgress) {
|
9250 |
|
9251 |
|
9252 | workInProgress.effectTag |= Update;
|
9253 | }
|
9254 |
|
9255 | function markRef$1(workInProgress) {
|
9256 | workInProgress.effectTag |= Ref;
|
9257 | }
|
9258 |
|
9259 | var appendAllChildren;
|
9260 | var updateHostContainer;
|
9261 | var updateHostComponent$1;
|
9262 | var updateHostText$1;
|
9263 |
|
9264 | {
|
9265 |
|
9266 | appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
|
9267 |
|
9268 |
|
9269 | var node = workInProgress.child;
|
9270 |
|
9271 | while (node !== null) {
|
9272 | if (node.tag === HostComponent || node.tag === HostText) {
|
9273 | appendInitialChild(parent, node.stateNode);
|
9274 | } else if (node.tag === HostPortal) ; else if (node.child !== null) {
|
9275 | node.child.return = node;
|
9276 | node = node.child;
|
9277 | continue;
|
9278 | }
|
9279 |
|
9280 | if (node === workInProgress) {
|
9281 | return;
|
9282 | }
|
9283 |
|
9284 | while (node.sibling === null) {
|
9285 | if (node.return === null || node.return === workInProgress) {
|
9286 | return;
|
9287 | }
|
9288 |
|
9289 | node = node.return;
|
9290 | }
|
9291 |
|
9292 | node.sibling.return = node.return;
|
9293 | node = node.sibling;
|
9294 | }
|
9295 | };
|
9296 |
|
9297 | updateHostContainer = function (workInProgress) {
|
9298 | };
|
9299 |
|
9300 | updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
9301 |
|
9302 |
|
9303 | var oldProps = current.memoizedProps;
|
9304 |
|
9305 | if (oldProps === newProps) {
|
9306 |
|
9307 |
|
9308 | return;
|
9309 | }
|
9310 |
|
9311 |
|
9312 |
|
9313 |
|
9314 |
|
9315 | var instance = workInProgress.stateNode;
|
9316 | var currentHostContext = getHostContext();
|
9317 |
|
9318 |
|
9319 |
|
9320 | var updatePayload = prepareUpdate();
|
9321 |
|
9322 | workInProgress.updateQueue = updatePayload;
|
9323 |
|
9324 |
|
9325 | if (updatePayload) {
|
9326 | markUpdate(workInProgress);
|
9327 | }
|
9328 | };
|
9329 |
|
9330 | updateHostText$1 = function (current, workInProgress, oldText, newText) {
|
9331 |
|
9332 | if (oldText !== newText) {
|
9333 | markUpdate(workInProgress);
|
9334 | }
|
9335 | };
|
9336 | }
|
9337 |
|
9338 | function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
|
9339 | switch (renderState.tailMode) {
|
9340 | case 'hidden':
|
9341 | {
|
9342 |
|
9343 |
|
9344 |
|
9345 |
|
9346 |
|
9347 | var tailNode = renderState.tail;
|
9348 | var lastTailNode = null;
|
9349 |
|
9350 | while (tailNode !== null) {
|
9351 | if (tailNode.alternate !== null) {
|
9352 | lastTailNode = tailNode;
|
9353 | }
|
9354 |
|
9355 | tailNode = tailNode.sibling;
|
9356 | }
|
9357 |
|
9358 |
|
9359 |
|
9360 | if (lastTailNode === null) {
|
9361 |
|
9362 | renderState.tail = null;
|
9363 | } else {
|
9364 |
|
9365 |
|
9366 | lastTailNode.sibling = null;
|
9367 | }
|
9368 |
|
9369 | break;
|
9370 | }
|
9371 |
|
9372 | case 'collapsed':
|
9373 | {
|
9374 |
|
9375 |
|
9376 |
|
9377 |
|
9378 |
|
9379 | var _tailNode = renderState.tail;
|
9380 | var _lastTailNode = null;
|
9381 |
|
9382 | while (_tailNode !== null) {
|
9383 | if (_tailNode.alternate !== null) {
|
9384 | _lastTailNode = _tailNode;
|
9385 | }
|
9386 |
|
9387 | _tailNode = _tailNode.sibling;
|
9388 | }
|
9389 |
|
9390 |
|
9391 |
|
9392 | if (_lastTailNode === null) {
|
9393 |
|
9394 | if (!hasRenderedATailFallback && renderState.tail !== null) {
|
9395 |
|
9396 |
|
9397 | renderState.tail.sibling = null;
|
9398 | } else {
|
9399 | renderState.tail = null;
|
9400 | }
|
9401 | } else {
|
9402 |
|
9403 |
|
9404 | _lastTailNode.sibling = null;
|
9405 | }
|
9406 |
|
9407 | break;
|
9408 | }
|
9409 | }
|
9410 | }
|
9411 |
|
9412 | function completeWork(current, workInProgress, renderExpirationTime) {
|
9413 | var newProps = workInProgress.pendingProps;
|
9414 |
|
9415 | switch (workInProgress.tag) {
|
9416 | case IndeterminateComponent:
|
9417 | case LazyComponent:
|
9418 | case SimpleMemoComponent:
|
9419 | case FunctionComponent:
|
9420 | case ForwardRef:
|
9421 | case Fragment:
|
9422 | case Mode:
|
9423 | case Profiler:
|
9424 | case ContextConsumer:
|
9425 | case MemoComponent:
|
9426 | return null;
|
9427 |
|
9428 | case ClassComponent:
|
9429 | {
|
9430 | var Component = workInProgress.type;
|
9431 |
|
9432 | if (isContextProvider(Component)) {
|
9433 | popContext(workInProgress);
|
9434 | }
|
9435 |
|
9436 | return null;
|
9437 | }
|
9438 |
|
9439 | case HostRoot:
|
9440 | {
|
9441 | popHostContainer(workInProgress);
|
9442 | popTopLevelContextObject(workInProgress);
|
9443 | var fiberRoot = workInProgress.stateNode;
|
9444 |
|
9445 | if (fiberRoot.pendingContext) {
|
9446 | fiberRoot.context = fiberRoot.pendingContext;
|
9447 | fiberRoot.pendingContext = null;
|
9448 | }
|
9449 |
|
9450 | if (current === null || current.child === null) {
|
9451 |
|
9452 |
|
9453 | var wasHydrated = popHydrationState();
|
9454 |
|
9455 | if (wasHydrated) {
|
9456 |
|
9457 |
|
9458 | markUpdate(workInProgress);
|
9459 | }
|
9460 | }
|
9461 |
|
9462 | updateHostContainer(workInProgress);
|
9463 | return null;
|
9464 | }
|
9465 |
|
9466 | case HostComponent:
|
9467 | {
|
9468 | popHostContext(workInProgress);
|
9469 | var rootContainerInstance = getRootHostContainer();
|
9470 | var type = workInProgress.type;
|
9471 |
|
9472 | if (current !== null && workInProgress.stateNode != null) {
|
9473 | updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
|
9474 |
|
9475 | if (current.ref !== workInProgress.ref) {
|
9476 | markRef$1(workInProgress);
|
9477 | }
|
9478 | } else {
|
9479 | if (!newProps) {
|
9480 | if (!(workInProgress.stateNode !== null)) {
|
9481 | {
|
9482 | throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." );
|
9483 | }
|
9484 | }
|
9485 |
|
9486 |
|
9487 | return null;
|
9488 | }
|
9489 |
|
9490 | var currentHostContext = getHostContext();
|
9491 |
|
9492 |
|
9493 |
|
9494 |
|
9495 | var _wasHydrated = popHydrationState();
|
9496 |
|
9497 | if (_wasHydrated) {
|
9498 |
|
9499 |
|
9500 | if (prepareToHydrateHostInstance()) {
|
9501 |
|
9502 |
|
9503 | markUpdate(workInProgress);
|
9504 | }
|
9505 | } else {
|
9506 | var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
|
9507 | appendAllChildren(instance, workInProgress, false, false);
|
9508 |
|
9509 | workInProgress.stateNode = instance;
|
9510 | }
|
9511 |
|
9512 | if (workInProgress.ref !== null) {
|
9513 |
|
9514 | markRef$1(workInProgress);
|
9515 | }
|
9516 | }
|
9517 |
|
9518 | return null;
|
9519 | }
|
9520 |
|
9521 | case HostText:
|
9522 | {
|
9523 | var newText = newProps;
|
9524 |
|
9525 | if (current && workInProgress.stateNode != null) {
|
9526 | var oldText = current.memoizedProps;
|
9527 |
|
9528 |
|
9529 | updateHostText$1(current, workInProgress, oldText, newText);
|
9530 | } else {
|
9531 | if (typeof newText !== 'string') {
|
9532 | if (!(workInProgress.stateNode !== null)) {
|
9533 | {
|
9534 | throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." );
|
9535 | }
|
9536 | }
|
9537 |
|
9538 | }
|
9539 |
|
9540 | var _rootContainerInstance = getRootHostContainer();
|
9541 |
|
9542 | var _currentHostContext = getHostContext();
|
9543 |
|
9544 | var _wasHydrated2 = popHydrationState();
|
9545 |
|
9546 | if (_wasHydrated2) {
|
9547 | if (prepareToHydrateHostTextInstance()) {
|
9548 | markUpdate(workInProgress);
|
9549 | }
|
9550 | } else {
|
9551 | workInProgress.stateNode = createTextInstance(newText);
|
9552 | }
|
9553 | }
|
9554 |
|
9555 | return null;
|
9556 | }
|
9557 |
|
9558 | case SuspenseComponent:
|
9559 | {
|
9560 | popSuspenseContext(workInProgress);
|
9561 | var nextState = workInProgress.memoizedState;
|
9562 |
|
9563 | if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
|
9564 |
|
9565 | workInProgress.expirationTime = renderExpirationTime;
|
9566 |
|
9567 | return workInProgress;
|
9568 | }
|
9569 |
|
9570 | var nextDidTimeout = nextState !== null;
|
9571 | var prevDidTimeout = false;
|
9572 |
|
9573 | if (current === null) {
|
9574 | if (workInProgress.memoizedProps.fallback !== undefined) ;
|
9575 | } else {
|
9576 | var prevState = current.memoizedState;
|
9577 | prevDidTimeout = prevState !== null;
|
9578 |
|
9579 | if (!nextDidTimeout && prevState !== null) {
|
9580 |
|
9581 |
|
9582 |
|
9583 |
|
9584 | var currentFallbackChild = current.child.sibling;
|
9585 |
|
9586 | if (currentFallbackChild !== null) {
|
9587 |
|
9588 | var first = workInProgress.firstEffect;
|
9589 |
|
9590 | if (first !== null) {
|
9591 | workInProgress.firstEffect = currentFallbackChild;
|
9592 | currentFallbackChild.nextEffect = first;
|
9593 | } else {
|
9594 | workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
|
9595 | currentFallbackChild.nextEffect = null;
|
9596 | }
|
9597 |
|
9598 | currentFallbackChild.effectTag = Deletion;
|
9599 | }
|
9600 | }
|
9601 | }
|
9602 |
|
9603 | if (nextDidTimeout && !prevDidTimeout) {
|
9604 |
|
9605 |
|
9606 |
|
9607 |
|
9608 |
|
9609 | if ((workInProgress.mode & BlockingMode) !== NoMode) {
|
9610 |
|
9611 |
|
9612 |
|
9613 |
|
9614 |
|
9615 |
|
9616 |
|
9617 | var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
|
9618 |
|
9619 | if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
|
9620 |
|
9621 |
|
9622 | renderDidSuspend();
|
9623 | } else {
|
9624 |
|
9625 |
|
9626 | renderDidSuspendDelayIfPossible();
|
9627 | }
|
9628 | }
|
9629 | }
|
9630 |
|
9631 | {
|
9632 |
|
9633 | if (nextDidTimeout || prevDidTimeout) {
|
9634 |
|
9635 |
|
9636 |
|
9637 |
|
9638 |
|
9639 | workInProgress.effectTag |= Update;
|
9640 | }
|
9641 | }
|
9642 |
|
9643 | return null;
|
9644 | }
|
9645 |
|
9646 | case HostPortal:
|
9647 | popHostContainer(workInProgress);
|
9648 | updateHostContainer(workInProgress);
|
9649 | return null;
|
9650 |
|
9651 | case ContextProvider:
|
9652 |
|
9653 | popProvider(workInProgress);
|
9654 | return null;
|
9655 |
|
9656 | case IncompleteClassComponent:
|
9657 | {
|
9658 |
|
9659 |
|
9660 | var _Component = workInProgress.type;
|
9661 |
|
9662 | if (isContextProvider(_Component)) {
|
9663 | popContext(workInProgress);
|
9664 | }
|
9665 |
|
9666 | return null;
|
9667 | }
|
9668 |
|
9669 | case SuspenseListComponent:
|
9670 | {
|
9671 | popSuspenseContext(workInProgress);
|
9672 | var renderState = workInProgress.memoizedState;
|
9673 |
|
9674 | if (renderState === null) {
|
9675 |
|
9676 |
|
9677 | return null;
|
9678 | }
|
9679 |
|
9680 | var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
|
9681 | var renderedTail = renderState.rendering;
|
9682 |
|
9683 | if (renderedTail === null) {
|
9684 |
|
9685 | if (!didSuspendAlready) {
|
9686 |
|
9687 |
|
9688 |
|
9689 |
|
9690 |
|
9691 |
|
9692 |
|
9693 |
|
9694 |
|
9695 | var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
|
9696 |
|
9697 | if (!cannotBeSuspended) {
|
9698 | var row = workInProgress.child;
|
9699 |
|
9700 | while (row !== null) {
|
9701 | var suspended = findFirstSuspended(row);
|
9702 |
|
9703 | if (suspended !== null) {
|
9704 | didSuspendAlready = true;
|
9705 | workInProgress.effectTag |= DidCapture;
|
9706 | cutOffTailIfNeeded(renderState, false);
|
9707 |
|
9708 |
|
9709 |
|
9710 |
|
9711 |
|
9712 |
|
9713 |
|
9714 |
|
9715 |
|
9716 |
|
9717 |
|
9718 |
|
9719 | var newThennables = suspended.updateQueue;
|
9720 |
|
9721 | if (newThennables !== null) {
|
9722 | workInProgress.updateQueue = newThennables;
|
9723 | workInProgress.effectTag |= Update;
|
9724 | }
|
9725 |
|
9726 |
|
9727 |
|
9728 |
|
9729 | if (renderState.lastEffect === null) {
|
9730 | workInProgress.firstEffect = null;
|
9731 | }
|
9732 |
|
9733 | workInProgress.lastEffect = renderState.lastEffect;
|
9734 |
|
9735 | resetChildFibers(workInProgress, renderExpirationTime);
|
9736 |
|
9737 |
|
9738 | pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
|
9739 | return workInProgress.child;
|
9740 | }
|
9741 |
|
9742 | row = row.sibling;
|
9743 | }
|
9744 | }
|
9745 | } else {
|
9746 | cutOffTailIfNeeded(renderState, false);
|
9747 | }
|
9748 |
|
9749 | } else {
|
9750 |
|
9751 | if (!didSuspendAlready) {
|
9752 | var _suspended = findFirstSuspended(renderedTail);
|
9753 |
|
9754 | if (_suspended !== null) {
|
9755 | workInProgress.effectTag |= DidCapture;
|
9756 | didSuspendAlready = true;
|
9757 |
|
9758 |
|
9759 | var _newThennables = _suspended.updateQueue;
|
9760 |
|
9761 | if (_newThennables !== null) {
|
9762 | workInProgress.updateQueue = _newThennables;
|
9763 | workInProgress.effectTag |= Update;
|
9764 | }
|
9765 |
|
9766 | cutOffTailIfNeeded(renderState, true);
|
9767 |
|
9768 | if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate) {
|
9769 |
|
9770 |
|
9771 |
|
9772 | var lastEffect = workInProgress.lastEffect = renderState.lastEffect;
|
9773 |
|
9774 | if (lastEffect !== null) {
|
9775 | lastEffect.nextEffect = null;
|
9776 | }
|
9777 |
|
9778 |
|
9779 | return null;
|
9780 | }
|
9781 | } else if (
|
9782 |
|
9783 | now() * 2 - renderState.renderingStartTime > renderState.tailExpiration && renderExpirationTime > Never) {
|
9784 |
|
9785 |
|
9786 |
|
9787 | workInProgress.effectTag |= DidCapture;
|
9788 | didSuspendAlready = true;
|
9789 | cutOffTailIfNeeded(renderState, false);
|
9790 |
|
9791 |
|
9792 |
|
9793 |
|
9794 |
|
9795 | var nextPriority = renderExpirationTime - 1;
|
9796 | workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
|
9797 |
|
9798 | {
|
9799 | markSpawnedWork(nextPriority);
|
9800 | }
|
9801 | }
|
9802 | }
|
9803 |
|
9804 | if (renderState.isBackwards) {
|
9805 |
|
9806 |
|
9807 |
|
9808 |
|
9809 |
|
9810 | renderedTail.sibling = workInProgress.child;
|
9811 | workInProgress.child = renderedTail;
|
9812 | } else {
|
9813 | var previousSibling = renderState.last;
|
9814 |
|
9815 | if (previousSibling !== null) {
|
9816 | previousSibling.sibling = renderedTail;
|
9817 | } else {
|
9818 | workInProgress.child = renderedTail;
|
9819 | }
|
9820 |
|
9821 | renderState.last = renderedTail;
|
9822 | }
|
9823 | }
|
9824 |
|
9825 | if (renderState.tail !== null) {
|
9826 |
|
9827 | if (renderState.tailExpiration === 0) {
|
9828 |
|
9829 |
|
9830 | var TAIL_EXPIRATION_TIMEOUT_MS = 500;
|
9831 | renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS;
|
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 | }
|
9838 |
|
9839 |
|
9840 | var next = renderState.tail;
|
9841 | renderState.rendering = next;
|
9842 | renderState.tail = next.sibling;
|
9843 | renderState.lastEffect = workInProgress.lastEffect;
|
9844 | renderState.renderingStartTime = now();
|
9845 | next.sibling = null;
|
9846 |
|
9847 |
|
9848 |
|
9849 | var suspenseContext = suspenseStackCursor.current;
|
9850 |
|
9851 | if (didSuspendAlready) {
|
9852 | suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
9853 | } else {
|
9854 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
9855 | }
|
9856 |
|
9857 | pushSuspenseContext(workInProgress, suspenseContext);
|
9858 |
|
9859 | return next;
|
9860 | }
|
9861 |
|
9862 | return null;
|
9863 | }
|
9864 | }
|
9865 |
|
9866 | {
|
9867 | {
|
9868 | throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." );
|
9869 | }
|
9870 | }
|
9871 | }
|
9872 |
|
9873 | function unwindWork(workInProgress, renderExpirationTime) {
|
9874 | switch (workInProgress.tag) {
|
9875 | case ClassComponent:
|
9876 | {
|
9877 | var Component = workInProgress.type;
|
9878 |
|
9879 | if (isContextProvider(Component)) {
|
9880 | popContext(workInProgress);
|
9881 | }
|
9882 |
|
9883 | var effectTag = workInProgress.effectTag;
|
9884 |
|
9885 | if (effectTag & ShouldCapture) {
|
9886 | workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
|
9887 | return workInProgress;
|
9888 | }
|
9889 |
|
9890 | return null;
|
9891 | }
|
9892 |
|
9893 | case HostRoot:
|
9894 | {
|
9895 | popHostContainer(workInProgress);
|
9896 | popTopLevelContextObject(workInProgress);
|
9897 | var _effectTag = workInProgress.effectTag;
|
9898 |
|
9899 | if (!((_effectTag & DidCapture) === NoEffect)) {
|
9900 | {
|
9901 | throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." );
|
9902 | }
|
9903 | }
|
9904 |
|
9905 | workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
|
9906 | return workInProgress;
|
9907 | }
|
9908 |
|
9909 | case HostComponent:
|
9910 | {
|
9911 |
|
9912 | popHostContext(workInProgress);
|
9913 | return null;
|
9914 | }
|
9915 |
|
9916 | case SuspenseComponent:
|
9917 | {
|
9918 | popSuspenseContext(workInProgress);
|
9919 |
|
9920 | var _effectTag2 = workInProgress.effectTag;
|
9921 |
|
9922 | if (_effectTag2 & ShouldCapture) {
|
9923 | workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
|
9924 |
|
9925 | return workInProgress;
|
9926 | }
|
9927 |
|
9928 | return null;
|
9929 | }
|
9930 |
|
9931 | case SuspenseListComponent:
|
9932 | {
|
9933 | popSuspenseContext(workInProgress);
|
9934 |
|
9935 |
|
9936 | return null;
|
9937 | }
|
9938 |
|
9939 | case HostPortal:
|
9940 | popHostContainer(workInProgress);
|
9941 | return null;
|
9942 |
|
9943 | case ContextProvider:
|
9944 | popProvider(workInProgress);
|
9945 | return null;
|
9946 |
|
9947 | default:
|
9948 | return null;
|
9949 | }
|
9950 | }
|
9951 |
|
9952 | function unwindInterruptedWork(interruptedWork) {
|
9953 | switch (interruptedWork.tag) {
|
9954 | case ClassComponent:
|
9955 | {
|
9956 | var childContextTypes = interruptedWork.type.childContextTypes;
|
9957 |
|
9958 | if (childContextTypes !== null && childContextTypes !== undefined) {
|
9959 | popContext(interruptedWork);
|
9960 | }
|
9961 |
|
9962 | break;
|
9963 | }
|
9964 |
|
9965 | case HostRoot:
|
9966 | {
|
9967 | popHostContainer(interruptedWork);
|
9968 | popTopLevelContextObject(interruptedWork);
|
9969 | break;
|
9970 | }
|
9971 |
|
9972 | case HostComponent:
|
9973 | {
|
9974 | popHostContext(interruptedWork);
|
9975 | break;
|
9976 | }
|
9977 |
|
9978 | case HostPortal:
|
9979 | popHostContainer(interruptedWork);
|
9980 | break;
|
9981 |
|
9982 | case SuspenseComponent:
|
9983 | popSuspenseContext(interruptedWork);
|
9984 | break;
|
9985 |
|
9986 | case SuspenseListComponent:
|
9987 | popSuspenseContext(interruptedWork);
|
9988 | break;
|
9989 |
|
9990 | case ContextProvider:
|
9991 | popProvider(interruptedWork);
|
9992 | break;
|
9993 | }
|
9994 | }
|
9995 |
|
9996 | function createCapturedValue(value, source) {
|
9997 |
|
9998 |
|
9999 | return {
|
10000 | value: value,
|
10001 | source: source,
|
10002 | stack: getStackByFiberInDevAndProd(source)
|
10003 | };
|
10004 | }
|
10005 |
|
10006 | var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
|
10007 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
10008 |
|
10009 | try {
|
10010 | func.apply(context, funcArgs);
|
10011 | } catch (error) {
|
10012 | this.onError(error);
|
10013 | }
|
10014 | };
|
10015 |
|
10016 | {
|
10017 |
|
10018 |
|
10019 |
|
10020 |
|
10021 |
|
10022 |
|
10023 |
|
10024 |
|
10025 |
|
10026 |
|
10027 |
|
10028 |
|
10029 |
|
10030 |
|
10031 |
|
10032 |
|
10033 |
|
10034 |
|
10035 |
|
10036 |
|
10037 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
10038 | var fakeNode = document.createElement('react');
|
10039 |
|
10040 | var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
|
10041 |
|
10042 |
|
10043 |
|
10044 |
|
10045 | if (!(typeof document !== 'undefined')) {
|
10046 | {
|
10047 | throw 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." );
|
10048 | }
|
10049 | }
|
10050 |
|
10051 | var evt = document.createEvent('Event');
|
10052 |
|
10053 |
|
10054 |
|
10055 |
|
10056 |
|
10057 |
|
10058 | var didError = true;
|
10059 |
|
10060 |
|
10061 |
|
10062 | var windowEvent = window.event;
|
10063 |
|
10064 |
|
10065 | var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
|
10066 |
|
10067 |
|
10068 |
|
10069 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
10070 |
|
10071 | function callCallback() {
|
10072 |
|
10073 |
|
10074 |
|
10075 |
|
10076 | fakeNode.removeEventListener(evtType, callCallback, false);
|
10077 |
|
10078 |
|
10079 |
|
10080 |
|
10081 | if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
|
10082 | window.event = windowEvent;
|
10083 | }
|
10084 |
|
10085 | func.apply(context, funcArgs);
|
10086 | didError = false;
|
10087 | }
|
10088 |
|
10089 |
|
10090 |
|
10091 |
|
10092 |
|
10093 |
|
10094 |
|
10095 |
|
10096 |
|
10097 |
|
10098 |
|
10099 |
|
10100 | var error;
|
10101 |
|
10102 | var didSetError = false;
|
10103 | var isCrossOriginError = false;
|
10104 |
|
10105 | function handleWindowError(event) {
|
10106 | error = event.error;
|
10107 | didSetError = true;
|
10108 |
|
10109 | if (error === null && event.colno === 0 && event.lineno === 0) {
|
10110 | isCrossOriginError = true;
|
10111 | }
|
10112 |
|
10113 | if (event.defaultPrevented) {
|
10114 |
|
10115 |
|
10116 |
|
10117 | if (error != null && typeof error === 'object') {
|
10118 | try {
|
10119 | error._suppressLogging = true;
|
10120 | } catch (inner) {
|
10121 | }
|
10122 | }
|
10123 | }
|
10124 | }
|
10125 |
|
10126 |
|
10127 | var evtType = "react-" + (name ? name : 'invokeguardedcallback');
|
10128 |
|
10129 | window.addEventListener('error', handleWindowError);
|
10130 | fakeNode.addEventListener(evtType, callCallback, false);
|
10131 |
|
10132 |
|
10133 | evt.initEvent(evtType, false, false);
|
10134 | fakeNode.dispatchEvent(evt);
|
10135 |
|
10136 | if (windowEventDescriptor) {
|
10137 | Object.defineProperty(window, 'event', windowEventDescriptor);
|
10138 | }
|
10139 |
|
10140 | if (didError) {
|
10141 | if (!didSetError) {
|
10142 |
|
10143 | 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.');
|
10144 | } else if (isCrossOriginError) {
|
10145 | 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.');
|
10146 | }
|
10147 |
|
10148 | this.onError(error);
|
10149 | }
|
10150 |
|
10151 |
|
10152 | window.removeEventListener('error', handleWindowError);
|
10153 | };
|
10154 |
|
10155 | invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
|
10156 | }
|
10157 | }
|
10158 |
|
10159 | var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
|
10160 |
|
10161 | var hasError = false;
|
10162 | var caughtError = null;
|
10163 | var reporter = {
|
10164 | onError: function (error) {
|
10165 | hasError = true;
|
10166 | caughtError = error;
|
10167 | }
|
10168 | };
|
10169 | |
10170 |
|
10171 |
|
10172 |
|
10173 |
|
10174 |
|
10175 |
|
10176 |
|
10177 |
|
10178 |
|
10179 |
|
10180 |
|
10181 |
|
10182 |
|
10183 | function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
|
10184 | hasError = false;
|
10185 | caughtError = null;
|
10186 | invokeGuardedCallbackImpl$1.apply(reporter, arguments);
|
10187 | }
|
10188 | function hasCaughtError() {
|
10189 | return hasError;
|
10190 | }
|
10191 | function clearCaughtError() {
|
10192 | if (hasError) {
|
10193 | var error = caughtError;
|
10194 | hasError = false;
|
10195 | caughtError = null;
|
10196 | return error;
|
10197 | } else {
|
10198 | {
|
10199 | {
|
10200 | throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." );
|
10201 | }
|
10202 | }
|
10203 | }
|
10204 | }
|
10205 |
|
10206 | function logCapturedError(capturedError) {
|
10207 |
|
10208 | var error = capturedError.error;
|
10209 |
|
10210 | {
|
10211 | var componentName = capturedError.componentName,
|
10212 | componentStack = capturedError.componentStack,
|
10213 | errorBoundaryName = capturedError.errorBoundaryName,
|
10214 | errorBoundaryFound = capturedError.errorBoundaryFound,
|
10215 | willRetry = capturedError.willRetry;
|
10216 |
|
10217 |
|
10218 |
|
10219 | if (error != null && error._suppressLogging) {
|
10220 | if (errorBoundaryFound && willRetry) {
|
10221 |
|
10222 |
|
10223 |
|
10224 | return;
|
10225 | }
|
10226 |
|
10227 |
|
10228 |
|
10229 |
|
10230 |
|
10231 | console['error'](error);
|
10232 |
|
10233 |
|
10234 | }
|
10235 |
|
10236 | var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
|
10237 | var errorBoundaryMessage;
|
10238 |
|
10239 | if (errorBoundaryFound && errorBoundaryName) {
|
10240 | if (willRetry) {
|
10241 | errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
|
10242 | } else {
|
10243 | errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
|
10244 | }
|
10245 | } else {
|
10246 | 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.';
|
10247 | }
|
10248 |
|
10249 | var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage);
|
10250 |
|
10251 |
|
10252 |
|
10253 |
|
10254 | console['error'](combinedMessage);
|
10255 | }
|
10256 | }
|
10257 |
|
10258 | var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
|
10259 |
|
10260 | {
|
10261 | didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
|
10262 | }
|
10263 |
|
10264 | var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
|
10265 | function logError(boundary, errorInfo) {
|
10266 | var source = errorInfo.source;
|
10267 | var stack = errorInfo.stack;
|
10268 |
|
10269 | if (stack === null && source !== null) {
|
10270 | stack = getStackByFiberInDevAndProd(source);
|
10271 | }
|
10272 |
|
10273 | var capturedError = {
|
10274 | componentName: source !== null ? getComponentName(source.type) : null,
|
10275 | componentStack: stack !== null ? stack : '',
|
10276 | error: errorInfo.value,
|
10277 | errorBoundary: null,
|
10278 | errorBoundaryName: null,
|
10279 | errorBoundaryFound: false,
|
10280 | willRetry: false
|
10281 | };
|
10282 |
|
10283 | if (boundary !== null && boundary.tag === ClassComponent) {
|
10284 | capturedError.errorBoundary = boundary.stateNode;
|
10285 | capturedError.errorBoundaryName = getComponentName(boundary.type);
|
10286 | capturedError.errorBoundaryFound = true;
|
10287 | capturedError.willRetry = true;
|
10288 | }
|
10289 |
|
10290 | try {
|
10291 | logCapturedError(capturedError);
|
10292 | } catch (e) {
|
10293 |
|
10294 |
|
10295 |
|
10296 |
|
10297 | setTimeout(function () {
|
10298 | throw e;
|
10299 | });
|
10300 | }
|
10301 | }
|
10302 |
|
10303 | var callComponentWillUnmountWithTimer = function (current, instance) {
|
10304 | startPhaseTimer(current, 'componentWillUnmount');
|
10305 | instance.props = current.memoizedProps;
|
10306 | instance.state = current.memoizedState;
|
10307 | instance.componentWillUnmount();
|
10308 | stopPhaseTimer();
|
10309 | };
|
10310 |
|
10311 |
|
10312 | function safelyCallComponentWillUnmount(current, instance) {
|
10313 | {
|
10314 | invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance);
|
10315 |
|
10316 | if (hasCaughtError()) {
|
10317 | var unmountError = clearCaughtError();
|
10318 | captureCommitPhaseError(current, unmountError);
|
10319 | }
|
10320 | }
|
10321 | }
|
10322 |
|
10323 | function safelyDetachRef(current) {
|
10324 | var ref = current.ref;
|
10325 |
|
10326 | if (ref !== null) {
|
10327 | if (typeof ref === 'function') {
|
10328 | {
|
10329 | invokeGuardedCallback(null, ref, null, null);
|
10330 |
|
10331 | if (hasCaughtError()) {
|
10332 | var refError = clearCaughtError();
|
10333 | captureCommitPhaseError(current, refError);
|
10334 | }
|
10335 | }
|
10336 | } else {
|
10337 | ref.current = null;
|
10338 | }
|
10339 | }
|
10340 | }
|
10341 |
|
10342 | function safelyCallDestroy(current, destroy) {
|
10343 | {
|
10344 | invokeGuardedCallback(null, destroy, null);
|
10345 |
|
10346 | if (hasCaughtError()) {
|
10347 | var error = clearCaughtError();
|
10348 | captureCommitPhaseError(current, error);
|
10349 | }
|
10350 | }
|
10351 | }
|
10352 |
|
10353 | function commitBeforeMutationLifeCycles(current, finishedWork) {
|
10354 | switch (finishedWork.tag) {
|
10355 | case FunctionComponent:
|
10356 | case ForwardRef:
|
10357 | case SimpleMemoComponent:
|
10358 | case Block:
|
10359 | {
|
10360 | return;
|
10361 | }
|
10362 |
|
10363 | case ClassComponent:
|
10364 | {
|
10365 | if (finishedWork.effectTag & Snapshot) {
|
10366 | if (current !== null) {
|
10367 | var prevProps = current.memoizedProps;
|
10368 | var prevState = current.memoizedState;
|
10369 | startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
|
10370 | var instance = finishedWork.stateNode;
|
10371 |
|
10372 |
|
10373 |
|
10374 | {
|
10375 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
10376 | if (instance.props !== finishedWork.memoizedProps) {
|
10377 | error('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');
|
10378 | }
|
10379 |
|
10380 | if (instance.state !== finishedWork.memoizedState) {
|
10381 | error('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');
|
10382 | }
|
10383 | }
|
10384 | }
|
10385 |
|
10386 | var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
|
10387 |
|
10388 | {
|
10389 | var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
|
10390 |
|
10391 | if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
|
10392 | didWarnSet.add(finishedWork.type);
|
10393 |
|
10394 | error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
|
10395 | }
|
10396 | }
|
10397 |
|
10398 | instance.__reactInternalSnapshotBeforeUpdate = snapshot;
|
10399 | stopPhaseTimer();
|
10400 | }
|
10401 | }
|
10402 |
|
10403 | return;
|
10404 | }
|
10405 |
|
10406 | case HostRoot:
|
10407 | case HostComponent:
|
10408 | case HostText:
|
10409 | case HostPortal:
|
10410 | case IncompleteClassComponent:
|
10411 |
|
10412 | return;
|
10413 | }
|
10414 |
|
10415 | {
|
10416 | {
|
10417 | throw 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." );
|
10418 | }
|
10419 | }
|
10420 | }
|
10421 |
|
10422 | function commitHookEffectListUnmount(tag, finishedWork) {
|
10423 | var updateQueue = finishedWork.updateQueue;
|
10424 | var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
10425 |
|
10426 | if (lastEffect !== null) {
|
10427 | var firstEffect = lastEffect.next;
|
10428 | var effect = firstEffect;
|
10429 |
|
10430 | do {
|
10431 | if ((effect.tag & tag) === tag) {
|
10432 |
|
10433 | var destroy = effect.destroy;
|
10434 | effect.destroy = undefined;
|
10435 |
|
10436 | if (destroy !== undefined) {
|
10437 | destroy();
|
10438 | }
|
10439 | }
|
10440 |
|
10441 | effect = effect.next;
|
10442 | } while (effect !== firstEffect);
|
10443 | }
|
10444 | }
|
10445 |
|
10446 | function commitHookEffectListMount(tag, finishedWork) {
|
10447 | var updateQueue = finishedWork.updateQueue;
|
10448 | var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
10449 |
|
10450 | if (lastEffect !== null) {
|
10451 | var firstEffect = lastEffect.next;
|
10452 | var effect = firstEffect;
|
10453 |
|
10454 | do {
|
10455 | if ((effect.tag & tag) === tag) {
|
10456 |
|
10457 | var create = effect.create;
|
10458 | effect.destroy = create();
|
10459 |
|
10460 | {
|
10461 | var destroy = effect.destroy;
|
10462 |
|
10463 | if (destroy !== undefined && typeof destroy !== 'function') {
|
10464 | var addendum = void 0;
|
10465 |
|
10466 | if (destroy === null) {
|
10467 | addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
|
10468 | } else if (typeof destroy.then === 'function') {
|
10469 | 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';
|
10470 | } else {
|
10471 | addendum = ' You returned: ' + destroy;
|
10472 | }
|
10473 |
|
10474 | error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
|
10475 | }
|
10476 | }
|
10477 | }
|
10478 |
|
10479 | effect = effect.next;
|
10480 | } while (effect !== firstEffect);
|
10481 | }
|
10482 | }
|
10483 |
|
10484 | function commitPassiveHookEffects(finishedWork) {
|
10485 | if ((finishedWork.effectTag & Passive) !== NoEffect) {
|
10486 | switch (finishedWork.tag) {
|
10487 | case FunctionComponent:
|
10488 | case ForwardRef:
|
10489 | case SimpleMemoComponent:
|
10490 | case Block:
|
10491 | {
|
10492 |
|
10493 |
|
10494 |
|
10495 | commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork);
|
10496 | commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
|
10497 | break;
|
10498 | }
|
10499 | }
|
10500 | }
|
10501 | }
|
10502 |
|
10503 | function commitLifeCycles(finishedRoot, current, finishedWork, committedExpirationTime) {
|
10504 | switch (finishedWork.tag) {
|
10505 | case FunctionComponent:
|
10506 | case ForwardRef:
|
10507 | case SimpleMemoComponent:
|
10508 | case Block:
|
10509 | {
|
10510 |
|
10511 |
|
10512 |
|
10513 |
|
10514 | commitHookEffectListMount(Layout | HasEffect, finishedWork);
|
10515 |
|
10516 | return;
|
10517 | }
|
10518 |
|
10519 | case ClassComponent:
|
10520 | {
|
10521 | var instance = finishedWork.stateNode;
|
10522 |
|
10523 | if (finishedWork.effectTag & Update) {
|
10524 | if (current === null) {
|
10525 | startPhaseTimer(finishedWork, 'componentDidMount');
|
10526 |
|
10527 |
|
10528 |
|
10529 | {
|
10530 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
10531 | if (instance.props !== finishedWork.memoizedProps) {
|
10532 | error('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');
|
10533 | }
|
10534 |
|
10535 | if (instance.state !== finishedWork.memoizedState) {
|
10536 | error('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');
|
10537 | }
|
10538 | }
|
10539 | }
|
10540 |
|
10541 | instance.componentDidMount();
|
10542 | stopPhaseTimer();
|
10543 | } else {
|
10544 | var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps);
|
10545 | var prevState = current.memoizedState;
|
10546 | startPhaseTimer(finishedWork, 'componentDidUpdate');
|
10547 |
|
10548 |
|
10549 |
|
10550 | {
|
10551 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
10552 | if (instance.props !== finishedWork.memoizedProps) {
|
10553 | error('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');
|
10554 | }
|
10555 |
|
10556 | if (instance.state !== finishedWork.memoizedState) {
|
10557 | error('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');
|
10558 | }
|
10559 | }
|
10560 | }
|
10561 |
|
10562 | instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
10563 | stopPhaseTimer();
|
10564 | }
|
10565 | }
|
10566 |
|
10567 | var updateQueue = finishedWork.updateQueue;
|
10568 |
|
10569 | if (updateQueue !== null) {
|
10570 | {
|
10571 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
10572 | if (instance.props !== finishedWork.memoizedProps) {
|
10573 | error('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');
|
10574 | }
|
10575 |
|
10576 | if (instance.state !== finishedWork.memoizedState) {
|
10577 | error('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');
|
10578 | }
|
10579 | }
|
10580 | }
|
10581 |
|
10582 |
|
10583 |
|
10584 |
|
10585 | commitUpdateQueue(finishedWork, updateQueue, instance);
|
10586 | }
|
10587 |
|
10588 | return;
|
10589 | }
|
10590 |
|
10591 | case HostRoot:
|
10592 | {
|
10593 | var _updateQueue = finishedWork.updateQueue;
|
10594 |
|
10595 | if (_updateQueue !== null) {
|
10596 | var _instance = null;
|
10597 |
|
10598 | if (finishedWork.child !== null) {
|
10599 | switch (finishedWork.child.tag) {
|
10600 | case HostComponent:
|
10601 | _instance = getPublicInstance(finishedWork.child.stateNode);
|
10602 | break;
|
10603 |
|
10604 | case ClassComponent:
|
10605 | _instance = finishedWork.child.stateNode;
|
10606 | break;
|
10607 | }
|
10608 | }
|
10609 |
|
10610 | commitUpdateQueue(finishedWork, _updateQueue, _instance);
|
10611 | }
|
10612 |
|
10613 | return;
|
10614 | }
|
10615 |
|
10616 | case HostComponent:
|
10617 | {
|
10618 | var _instance2 = finishedWork.stateNode;
|
10619 |
|
10620 |
|
10621 |
|
10622 |
|
10623 | if (current === null && finishedWork.effectTag & Update) {
|
10624 | var type = finishedWork.type;
|
10625 | var props = finishedWork.memoizedProps;
|
10626 | }
|
10627 |
|
10628 | return;
|
10629 | }
|
10630 |
|
10631 | case HostText:
|
10632 | {
|
10633 |
|
10634 | return;
|
10635 | }
|
10636 |
|
10637 | case HostPortal:
|
10638 | {
|
10639 |
|
10640 | return;
|
10641 | }
|
10642 |
|
10643 | case Profiler:
|
10644 | {
|
10645 | {
|
10646 | var onRender = finishedWork.memoizedProps.onRender;
|
10647 |
|
10648 | if (typeof onRender === 'function') {
|
10649 | {
|
10650 | onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
|
10651 | }
|
10652 | }
|
10653 | }
|
10654 |
|
10655 | return;
|
10656 | }
|
10657 |
|
10658 | case SuspenseComponent:
|
10659 | {
|
10660 | return;
|
10661 | }
|
10662 |
|
10663 | case SuspenseListComponent:
|
10664 | case IncompleteClassComponent:
|
10665 | case FundamentalComponent:
|
10666 | case ScopeComponent:
|
10667 | return;
|
10668 | }
|
10669 |
|
10670 | {
|
10671 | {
|
10672 | throw 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." );
|
10673 | }
|
10674 | }
|
10675 | }
|
10676 |
|
10677 | function hideOrUnhideAllChildren(finishedWork, isHidden) {
|
10678 | {
|
10679 |
|
10680 |
|
10681 | var node = finishedWork;
|
10682 |
|
10683 | while (true) {
|
10684 | if (node.tag === HostComponent) {
|
10685 | var instance = node.stateNode;
|
10686 |
|
10687 | if (isHidden) {
|
10688 | hideInstance(instance);
|
10689 | } else {
|
10690 | unhideInstance(node.stateNode, node.memoizedProps);
|
10691 | }
|
10692 | } else if (node.tag === HostText) {
|
10693 | var _instance3 = node.stateNode;
|
10694 |
|
10695 | if (isHidden) {
|
10696 | hideTextInstance(_instance3);
|
10697 | } else {
|
10698 | unhideTextInstance(_instance3, node.memoizedProps);
|
10699 | }
|
10700 | } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) {
|
10701 |
|
10702 |
|
10703 | var fallbackChildFragment = node.child.sibling;
|
10704 | fallbackChildFragment.return = node;
|
10705 | node = fallbackChildFragment;
|
10706 | continue;
|
10707 | } else if (node.child !== null) {
|
10708 | node.child.return = node;
|
10709 | node = node.child;
|
10710 | continue;
|
10711 | }
|
10712 |
|
10713 | if (node === finishedWork) {
|
10714 | return;
|
10715 | }
|
10716 |
|
10717 | while (node.sibling === null) {
|
10718 | if (node.return === null || node.return === finishedWork) {
|
10719 | return;
|
10720 | }
|
10721 |
|
10722 | node = node.return;
|
10723 | }
|
10724 |
|
10725 | node.sibling.return = node.return;
|
10726 | node = node.sibling;
|
10727 | }
|
10728 | }
|
10729 | }
|
10730 |
|
10731 | function commitAttachRef(finishedWork) {
|
10732 | var ref = finishedWork.ref;
|
10733 |
|
10734 | if (ref !== null) {
|
10735 | var instance = finishedWork.stateNode;
|
10736 | var instanceToUse;
|
10737 |
|
10738 | switch (finishedWork.tag) {
|
10739 | case HostComponent:
|
10740 | instanceToUse = getPublicInstance(instance);
|
10741 | break;
|
10742 |
|
10743 | default:
|
10744 | instanceToUse = instance;
|
10745 | }
|
10746 |
|
10747 | if (typeof ref === 'function') {
|
10748 | ref(instanceToUse);
|
10749 | } else {
|
10750 | {
|
10751 | if (!ref.hasOwnProperty('current')) {
|
10752 | error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
|
10753 | }
|
10754 | }
|
10755 |
|
10756 | ref.current = instanceToUse;
|
10757 | }
|
10758 | }
|
10759 | }
|
10760 |
|
10761 | function commitDetachRef(current) {
|
10762 | var currentRef = current.ref;
|
10763 |
|
10764 | if (currentRef !== null) {
|
10765 | if (typeof currentRef === 'function') {
|
10766 | currentRef(null);
|
10767 | } else {
|
10768 | currentRef.current = null;
|
10769 | }
|
10770 | }
|
10771 | }
|
10772 |
|
10773 |
|
10774 |
|
10775 |
|
10776 | function commitUnmount(finishedRoot, current, renderPriorityLevel) {
|
10777 | onCommitUnmount(current);
|
10778 |
|
10779 | switch (current.tag) {
|
10780 | case FunctionComponent:
|
10781 | case ForwardRef:
|
10782 | case MemoComponent:
|
10783 | case SimpleMemoComponent:
|
10784 | case Block:
|
10785 | {
|
10786 | var updateQueue = current.updateQueue;
|
10787 |
|
10788 | if (updateQueue !== null) {
|
10789 | var lastEffect = updateQueue.lastEffect;
|
10790 |
|
10791 | if (lastEffect !== null) {
|
10792 | var firstEffect = lastEffect.next;
|
10793 |
|
10794 | {
|
10795 |
|
10796 |
|
10797 |
|
10798 |
|
10799 |
|
10800 |
|
10801 |
|
10802 |
|
10803 |
|
10804 |
|
10805 |
|
10806 |
|
10807 | var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
|
10808 | runWithPriority(priorityLevel, function () {
|
10809 | var effect = firstEffect;
|
10810 |
|
10811 | do {
|
10812 | var _destroy = effect.destroy;
|
10813 |
|
10814 | if (_destroy !== undefined) {
|
10815 | safelyCallDestroy(current, _destroy);
|
10816 | }
|
10817 |
|
10818 | effect = effect.next;
|
10819 | } while (effect !== firstEffect);
|
10820 | });
|
10821 | }
|
10822 | }
|
10823 | }
|
10824 |
|
10825 | return;
|
10826 | }
|
10827 |
|
10828 | case ClassComponent:
|
10829 | {
|
10830 | safelyDetachRef(current);
|
10831 | var instance = current.stateNode;
|
10832 |
|
10833 | if (typeof instance.componentWillUnmount === 'function') {
|
10834 | safelyCallComponentWillUnmount(current, instance);
|
10835 | }
|
10836 |
|
10837 | return;
|
10838 | }
|
10839 |
|
10840 | case HostComponent:
|
10841 | {
|
10842 |
|
10843 | safelyDetachRef(current);
|
10844 | return;
|
10845 | }
|
10846 |
|
10847 | case HostPortal:
|
10848 | {
|
10849 |
|
10850 |
|
10851 |
|
10852 | {
|
10853 | unmountHostComponents(finishedRoot, current, renderPriorityLevel);
|
10854 | }
|
10855 |
|
10856 | return;
|
10857 | }
|
10858 |
|
10859 | case FundamentalComponent:
|
10860 | {
|
10861 |
|
10862 | return;
|
10863 | }
|
10864 |
|
10865 | case DehydratedFragment:
|
10866 | {
|
10867 |
|
10868 | return;
|
10869 | }
|
10870 |
|
10871 | case ScopeComponent:
|
10872 | {
|
10873 |
|
10874 | return;
|
10875 | }
|
10876 | }
|
10877 | }
|
10878 |
|
10879 | function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
|
10880 |
|
10881 |
|
10882 |
|
10883 |
|
10884 |
|
10885 | var node = root;
|
10886 |
|
10887 | while (true) {
|
10888 | commitUnmount(finishedRoot, node, renderPriorityLevel);
|
10889 |
|
10890 |
|
10891 | if (node.child !== null && (
|
10892 |
|
10893 | node.tag !== HostPortal)) {
|
10894 | node.child.return = node;
|
10895 | node = node.child;
|
10896 | continue;
|
10897 | }
|
10898 |
|
10899 | if (node === root) {
|
10900 | return;
|
10901 | }
|
10902 |
|
10903 | while (node.sibling === null) {
|
10904 | if (node.return === null || node.return === root) {
|
10905 | return;
|
10906 | }
|
10907 |
|
10908 | node = node.return;
|
10909 | }
|
10910 |
|
10911 | node.sibling.return = node.return;
|
10912 | node = node.sibling;
|
10913 | }
|
10914 | }
|
10915 |
|
10916 | function detachFiber(current) {
|
10917 | var alternate = current.alternate;
|
10918 |
|
10919 |
|
10920 |
|
10921 |
|
10922 |
|
10923 | current.return = null;
|
10924 | current.child = null;
|
10925 | current.memoizedState = null;
|
10926 | current.updateQueue = null;
|
10927 | current.dependencies = null;
|
10928 | current.alternate = null;
|
10929 | current.firstEffect = null;
|
10930 | current.lastEffect = null;
|
10931 | current.pendingProps = null;
|
10932 | current.memoizedProps = null;
|
10933 | current.stateNode = null;
|
10934 |
|
10935 | if (alternate !== null) {
|
10936 | detachFiber(alternate);
|
10937 | }
|
10938 | }
|
10939 |
|
10940 | function getHostParentFiber(fiber) {
|
10941 | var parent = fiber.return;
|
10942 |
|
10943 | while (parent !== null) {
|
10944 | if (isHostParent(parent)) {
|
10945 | return parent;
|
10946 | }
|
10947 |
|
10948 | parent = parent.return;
|
10949 | }
|
10950 |
|
10951 | {
|
10952 | {
|
10953 | throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." );
|
10954 | }
|
10955 | }
|
10956 | }
|
10957 |
|
10958 | function isHostParent(fiber) {
|
10959 | return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
|
10960 | }
|
10961 |
|
10962 | function getHostSibling(fiber) {
|
10963 |
|
10964 |
|
10965 |
|
10966 |
|
10967 | var node = fiber;
|
10968 |
|
10969 | siblings: while (true) {
|
10970 |
|
10971 | while (node.sibling === null) {
|
10972 | if (node.return === null || isHostParent(node.return)) {
|
10973 |
|
10974 |
|
10975 | return null;
|
10976 | }
|
10977 |
|
10978 | node = node.return;
|
10979 | }
|
10980 |
|
10981 | node.sibling.return = node.return;
|
10982 | node = node.sibling;
|
10983 |
|
10984 | while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
|
10985 |
|
10986 |
|
10987 | if (node.effectTag & Placement) {
|
10988 |
|
10989 | continue siblings;
|
10990 | }
|
10991 |
|
10992 |
|
10993 |
|
10994 | if (node.child === null || node.tag === HostPortal) {
|
10995 | continue siblings;
|
10996 | } else {
|
10997 | node.child.return = node;
|
10998 | node = node.child;
|
10999 | }
|
11000 | }
|
11001 |
|
11002 |
|
11003 | if (!(node.effectTag & Placement)) {
|
11004 |
|
11005 | return node.stateNode;
|
11006 | }
|
11007 | }
|
11008 | }
|
11009 |
|
11010 | function commitPlacement(finishedWork) {
|
11011 |
|
11012 |
|
11013 | var parentFiber = getHostParentFiber(finishedWork);
|
11014 |
|
11015 | var parent;
|
11016 | var isContainer;
|
11017 | var parentStateNode = parentFiber.stateNode;
|
11018 |
|
11019 | switch (parentFiber.tag) {
|
11020 | case HostComponent:
|
11021 | parent = parentStateNode;
|
11022 | isContainer = false;
|
11023 | break;
|
11024 |
|
11025 | case HostRoot:
|
11026 | parent = parentStateNode.containerInfo;
|
11027 | isContainer = true;
|
11028 | break;
|
11029 |
|
11030 | case HostPortal:
|
11031 | parent = parentStateNode.containerInfo;
|
11032 | isContainer = true;
|
11033 | break;
|
11034 |
|
11035 | case FundamentalComponent:
|
11036 |
|
11037 |
|
11038 |
|
11039 | default:
|
11040 | {
|
11041 | {
|
11042 | throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." );
|
11043 | }
|
11044 | }
|
11045 |
|
11046 | }
|
11047 |
|
11048 | if (parentFiber.effectTag & ContentReset) {
|
11049 |
|
11050 | parentFiber.effectTag &= ~ContentReset;
|
11051 | }
|
11052 |
|
11053 | var before = getHostSibling(finishedWork);
|
11054 |
|
11055 |
|
11056 | if (isContainer) {
|
11057 | insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent);
|
11058 | } else {
|
11059 | insertOrAppendPlacementNode(finishedWork, before, parent);
|
11060 | }
|
11061 | }
|
11062 |
|
11063 | function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
|
11064 | var tag = node.tag;
|
11065 | var isHost = tag === HostComponent || tag === HostText;
|
11066 |
|
11067 | if (isHost || enableFundamentalAPI ) {
|
11068 | var stateNode = isHost ? node.stateNode : node.stateNode.instance;
|
11069 |
|
11070 | if (before) {
|
11071 | insertInContainerBefore(parent, stateNode, before);
|
11072 | } else {
|
11073 | appendChildToContainer(parent, stateNode);
|
11074 | }
|
11075 | } else if (tag === HostPortal) ; else {
|
11076 | var child = node.child;
|
11077 |
|
11078 | if (child !== null) {
|
11079 | insertOrAppendPlacementNodeIntoContainer(child, before, parent);
|
11080 | var sibling = child.sibling;
|
11081 |
|
11082 | while (sibling !== null) {
|
11083 | insertOrAppendPlacementNodeIntoContainer(sibling, before, parent);
|
11084 | sibling = sibling.sibling;
|
11085 | }
|
11086 | }
|
11087 | }
|
11088 | }
|
11089 |
|
11090 | function insertOrAppendPlacementNode(node, before, parent) {
|
11091 | var tag = node.tag;
|
11092 | var isHost = tag === HostComponent || tag === HostText;
|
11093 |
|
11094 | if (isHost || enableFundamentalAPI ) {
|
11095 | var stateNode = isHost ? node.stateNode : node.stateNode.instance;
|
11096 |
|
11097 | if (before) {
|
11098 | insertBefore(parent, stateNode, before);
|
11099 | } else {
|
11100 | appendChild(parent, stateNode);
|
11101 | }
|
11102 | } else if (tag === HostPortal) ; else {
|
11103 | var child = node.child;
|
11104 |
|
11105 | if (child !== null) {
|
11106 | insertOrAppendPlacementNode(child, before, parent);
|
11107 | var sibling = child.sibling;
|
11108 |
|
11109 | while (sibling !== null) {
|
11110 | insertOrAppendPlacementNode(sibling, before, parent);
|
11111 | sibling = sibling.sibling;
|
11112 | }
|
11113 | }
|
11114 | }
|
11115 | }
|
11116 |
|
11117 | function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
|
11118 |
|
11119 |
|
11120 | var node = current;
|
11121 |
|
11122 |
|
11123 | var currentParentIsValid = false;
|
11124 |
|
11125 | var currentParent;
|
11126 | var currentParentIsContainer;
|
11127 |
|
11128 | while (true) {
|
11129 | if (!currentParentIsValid) {
|
11130 | var parent = node.return;
|
11131 |
|
11132 | findParent: while (true) {
|
11133 | if (!(parent !== null)) {
|
11134 | {
|
11135 | throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." );
|
11136 | }
|
11137 | }
|
11138 |
|
11139 | var parentStateNode = parent.stateNode;
|
11140 |
|
11141 | switch (parent.tag) {
|
11142 | case HostComponent:
|
11143 | currentParent = parentStateNode;
|
11144 | currentParentIsContainer = false;
|
11145 | break findParent;
|
11146 |
|
11147 | case HostRoot:
|
11148 | currentParent = parentStateNode.containerInfo;
|
11149 | currentParentIsContainer = true;
|
11150 | break findParent;
|
11151 |
|
11152 | case HostPortal:
|
11153 | currentParent = parentStateNode.containerInfo;
|
11154 | currentParentIsContainer = true;
|
11155 | break findParent;
|
11156 |
|
11157 | }
|
11158 |
|
11159 | parent = parent.return;
|
11160 | }
|
11161 |
|
11162 | currentParentIsValid = true;
|
11163 | }
|
11164 |
|
11165 | if (node.tag === HostComponent || node.tag === HostText) {
|
11166 | commitNestedUnmounts(finishedRoot, node, renderPriorityLevel);
|
11167 |
|
11168 |
|
11169 | if (currentParentIsContainer) {
|
11170 | removeChildFromContainer(currentParent, node.stateNode);
|
11171 | } else {
|
11172 | removeChild(currentParent, node.stateNode);
|
11173 | }
|
11174 |
|
11175 | } else if (node.tag === HostPortal) {
|
11176 | if (node.child !== null) {
|
11177 |
|
11178 |
|
11179 | currentParent = node.stateNode.containerInfo;
|
11180 | currentParentIsContainer = true;
|
11181 |
|
11182 | node.child.return = node;
|
11183 | node = node.child;
|
11184 | continue;
|
11185 | }
|
11186 | } else {
|
11187 | commitUnmount(finishedRoot, node, renderPriorityLevel);
|
11188 |
|
11189 | if (node.child !== null) {
|
11190 | node.child.return = node;
|
11191 | node = node.child;
|
11192 | continue;
|
11193 | }
|
11194 | }
|
11195 |
|
11196 | if (node === current) {
|
11197 | return;
|
11198 | }
|
11199 |
|
11200 | while (node.sibling === null) {
|
11201 | if (node.return === null || node.return === current) {
|
11202 | return;
|
11203 | }
|
11204 |
|
11205 | node = node.return;
|
11206 |
|
11207 | if (node.tag === HostPortal) {
|
11208 |
|
11209 |
|
11210 | currentParentIsValid = false;
|
11211 | }
|
11212 | }
|
11213 |
|
11214 | node.sibling.return = node.return;
|
11215 | node = node.sibling;
|
11216 | }
|
11217 | }
|
11218 |
|
11219 | function commitDeletion(finishedRoot, current, renderPriorityLevel) {
|
11220 | {
|
11221 |
|
11222 |
|
11223 | unmountHostComponents(finishedRoot, current, renderPriorityLevel);
|
11224 | }
|
11225 |
|
11226 | detachFiber(current);
|
11227 | }
|
11228 |
|
11229 | function commitWork(current, finishedWork) {
|
11230 |
|
11231 | switch (finishedWork.tag) {
|
11232 | case FunctionComponent:
|
11233 | case ForwardRef:
|
11234 | case MemoComponent:
|
11235 | case SimpleMemoComponent:
|
11236 | case Block:
|
11237 | {
|
11238 |
|
11239 |
|
11240 |
|
11241 |
|
11242 |
|
11243 | commitHookEffectListUnmount(Layout | HasEffect, finishedWork);
|
11244 | return;
|
11245 | }
|
11246 |
|
11247 | case ClassComponent:
|
11248 | {
|
11249 | return;
|
11250 | }
|
11251 |
|
11252 | case HostComponent:
|
11253 | {
|
11254 | var instance = finishedWork.stateNode;
|
11255 |
|
11256 | if (instance != null) {
|
11257 |
|
11258 | var newProps = finishedWork.memoizedProps;
|
11259 |
|
11260 |
|
11261 |
|
11262 | var oldProps = current !== null ? current.memoizedProps : newProps;
|
11263 | var type = finishedWork.type;
|
11264 |
|
11265 | var updatePayload = finishedWork.updateQueue;
|
11266 | finishedWork.updateQueue = null;
|
11267 |
|
11268 | if (updatePayload !== null) {
|
11269 | commitUpdate(instance, updatePayload, type, oldProps, newProps);
|
11270 | }
|
11271 | }
|
11272 |
|
11273 | return;
|
11274 | }
|
11275 |
|
11276 | case HostText:
|
11277 | {
|
11278 | if (!(finishedWork.stateNode !== null)) {
|
11279 | {
|
11280 | throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." );
|
11281 | }
|
11282 | }
|
11283 |
|
11284 | var textInstance = finishedWork.stateNode;
|
11285 | var newText = finishedWork.memoizedProps;
|
11286 |
|
11287 |
|
11288 |
|
11289 | var oldText = current !== null ? current.memoizedProps : newText;
|
11290 | commitTextUpdate(textInstance, oldText, newText);
|
11291 | return;
|
11292 | }
|
11293 |
|
11294 | case HostRoot:
|
11295 | {
|
11296 |
|
11297 | return;
|
11298 | }
|
11299 |
|
11300 | case Profiler:
|
11301 | {
|
11302 | return;
|
11303 | }
|
11304 |
|
11305 | case SuspenseComponent:
|
11306 | {
|
11307 | commitSuspenseComponent(finishedWork);
|
11308 | attachSuspenseRetryListeners(finishedWork);
|
11309 | return;
|
11310 | }
|
11311 |
|
11312 | case SuspenseListComponent:
|
11313 | {
|
11314 | attachSuspenseRetryListeners(finishedWork);
|
11315 | return;
|
11316 | }
|
11317 |
|
11318 | case IncompleteClassComponent:
|
11319 | {
|
11320 | return;
|
11321 | }
|
11322 | }
|
11323 |
|
11324 | {
|
11325 | {
|
11326 | throw 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." );
|
11327 | }
|
11328 | }
|
11329 | }
|
11330 |
|
11331 | function commitSuspenseComponent(finishedWork) {
|
11332 | var newState = finishedWork.memoizedState;
|
11333 | var newDidTimeout;
|
11334 | var primaryChildParent = finishedWork;
|
11335 |
|
11336 | if (newState === null) {
|
11337 | newDidTimeout = false;
|
11338 | } else {
|
11339 | newDidTimeout = true;
|
11340 | primaryChildParent = finishedWork.child;
|
11341 | markCommitTimeOfFallback();
|
11342 | }
|
11343 |
|
11344 | if ( primaryChildParent !== null) {
|
11345 | hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
|
11346 | }
|
11347 | }
|
11348 |
|
11349 | function attachSuspenseRetryListeners(finishedWork) {
|
11350 |
|
11351 |
|
11352 |
|
11353 | var thenables = finishedWork.updateQueue;
|
11354 |
|
11355 | if (thenables !== null) {
|
11356 | finishedWork.updateQueue = null;
|
11357 | var retryCache = finishedWork.stateNode;
|
11358 |
|
11359 | if (retryCache === null) {
|
11360 | retryCache = finishedWork.stateNode = new PossiblyWeakSet();
|
11361 | }
|
11362 |
|
11363 | thenables.forEach(function (thenable) {
|
11364 |
|
11365 | var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
|
11366 |
|
11367 | if (!retryCache.has(thenable)) {
|
11368 | {
|
11369 | if (thenable.__reactDoNotTraceInteractions !== true) {
|
11370 | retry = unstable_wrap(retry);
|
11371 | }
|
11372 | }
|
11373 |
|
11374 | retryCache.add(thenable);
|
11375 | thenable.then(retry, retry);
|
11376 | }
|
11377 | });
|
11378 | }
|
11379 | }
|
11380 |
|
11381 | function commitResetTextContent(current) {
|
11382 |
|
11383 | resetTextContent(current.stateNode);
|
11384 | }
|
11385 |
|
11386 | var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
11387 |
|
11388 | function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
|
11389 | var update = createUpdate(expirationTime, null);
|
11390 |
|
11391 | update.tag = CaptureUpdate;
|
11392 |
|
11393 |
|
11394 | update.payload = {
|
11395 | element: null
|
11396 | };
|
11397 | var error = errorInfo.value;
|
11398 |
|
11399 | update.callback = function () {
|
11400 | onUncaughtError(error);
|
11401 | logError(fiber, errorInfo);
|
11402 | };
|
11403 |
|
11404 | return update;
|
11405 | }
|
11406 |
|
11407 | function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
|
11408 | var update = createUpdate(expirationTime, null);
|
11409 | update.tag = CaptureUpdate;
|
11410 | var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
|
11411 |
|
11412 | if (typeof getDerivedStateFromError === 'function') {
|
11413 | var error$1 = errorInfo.value;
|
11414 |
|
11415 | update.payload = function () {
|
11416 | logError(fiber, errorInfo);
|
11417 | return getDerivedStateFromError(error$1);
|
11418 | };
|
11419 | }
|
11420 |
|
11421 | var inst = fiber.stateNode;
|
11422 |
|
11423 | if (inst !== null && typeof inst.componentDidCatch === 'function') {
|
11424 | update.callback = function callback() {
|
11425 | {
|
11426 | markFailedErrorBoundaryForHotReloading(fiber);
|
11427 | }
|
11428 |
|
11429 | if (typeof getDerivedStateFromError !== 'function') {
|
11430 |
|
11431 |
|
11432 |
|
11433 |
|
11434 |
|
11435 | markLegacyErrorBoundaryAsFailed(this);
|
11436 |
|
11437 | logError(fiber, errorInfo);
|
11438 | }
|
11439 |
|
11440 | var error$1 = errorInfo.value;
|
11441 | var stack = errorInfo.stack;
|
11442 | this.componentDidCatch(error$1, {
|
11443 | componentStack: stack !== null ? stack : ''
|
11444 | });
|
11445 |
|
11446 | {
|
11447 | if (typeof getDerivedStateFromError !== 'function') {
|
11448 |
|
11449 |
|
11450 |
|
11451 | if (fiber.expirationTime !== Sync) {
|
11452 | error('%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');
|
11453 | }
|
11454 | }
|
11455 | }
|
11456 | };
|
11457 | } else {
|
11458 | update.callback = function () {
|
11459 | markFailedErrorBoundaryForHotReloading(fiber);
|
11460 | };
|
11461 | }
|
11462 |
|
11463 | return update;
|
11464 | }
|
11465 |
|
11466 | function attachPingListener(root, renderExpirationTime, thenable) {
|
11467 |
|
11468 |
|
11469 |
|
11470 | var pingCache = root.pingCache;
|
11471 | var threadIDs;
|
11472 |
|
11473 | if (pingCache === null) {
|
11474 | pingCache = root.pingCache = new PossiblyWeakMap();
|
11475 | threadIDs = new Set();
|
11476 | pingCache.set(thenable, threadIDs);
|
11477 | } else {
|
11478 | threadIDs = pingCache.get(thenable);
|
11479 |
|
11480 | if (threadIDs === undefined) {
|
11481 | threadIDs = new Set();
|
11482 | pingCache.set(thenable, threadIDs);
|
11483 | }
|
11484 | }
|
11485 |
|
11486 | if (!threadIDs.has(renderExpirationTime)) {
|
11487 |
|
11488 | threadIDs.add(renderExpirationTime);
|
11489 | var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
|
11490 | thenable.then(ping, ping);
|
11491 | }
|
11492 | }
|
11493 |
|
11494 | function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
|
11495 |
|
11496 | sourceFiber.effectTag |= Incomplete;
|
11497 |
|
11498 | sourceFiber.firstEffect = sourceFiber.lastEffect = null;
|
11499 |
|
11500 | if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
|
11501 |
|
11502 | var thenable = value;
|
11503 |
|
11504 | if ((sourceFiber.mode & BlockingMode) === NoMode) {
|
11505 |
|
11506 |
|
11507 | var currentSource = sourceFiber.alternate;
|
11508 |
|
11509 | if (currentSource) {
|
11510 | sourceFiber.updateQueue = currentSource.updateQueue;
|
11511 | sourceFiber.memoizedState = currentSource.memoizedState;
|
11512 | sourceFiber.expirationTime = currentSource.expirationTime;
|
11513 | } else {
|
11514 | sourceFiber.updateQueue = null;
|
11515 | sourceFiber.memoizedState = null;
|
11516 | }
|
11517 | }
|
11518 |
|
11519 | var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext);
|
11520 |
|
11521 | var _workInProgress = returnFiber;
|
11522 |
|
11523 | do {
|
11524 | if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
|
11525 |
|
11526 |
|
11527 |
|
11528 | var thenables = _workInProgress.updateQueue;
|
11529 |
|
11530 | if (thenables === null) {
|
11531 | var updateQueue = new Set();
|
11532 | updateQueue.add(thenable);
|
11533 | _workInProgress.updateQueue = updateQueue;
|
11534 | } else {
|
11535 | thenables.add(thenable);
|
11536 | }
|
11537 |
|
11538 |
|
11539 |
|
11540 |
|
11541 |
|
11542 |
|
11543 |
|
11544 |
|
11545 |
|
11546 | if ((_workInProgress.mode & BlockingMode) === NoMode) {
|
11547 | _workInProgress.effectTag |= DidCapture;
|
11548 |
|
11549 |
|
11550 |
|
11551 | sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
|
11552 |
|
11553 | if (sourceFiber.tag === ClassComponent) {
|
11554 | var currentSourceFiber = sourceFiber.alternate;
|
11555 |
|
11556 | if (currentSourceFiber === null) {
|
11557 |
|
11558 |
|
11559 |
|
11560 | sourceFiber.tag = IncompleteClassComponent;
|
11561 | } else {
|
11562 |
|
11563 |
|
11564 |
|
11565 | var update = createUpdate(Sync, null);
|
11566 | update.tag = ForceUpdate;
|
11567 | enqueueUpdate(sourceFiber, update);
|
11568 | }
|
11569 | }
|
11570 |
|
11571 |
|
11572 |
|
11573 | sourceFiber.expirationTime = Sync;
|
11574 |
|
11575 | return;
|
11576 | }
|
11577 |
|
11578 |
|
11579 |
|
11580 |
|
11581 |
|
11582 |
|
11583 |
|
11584 |
|
11585 |
|
11586 |
|
11587 |
|
11588 |
|
11589 |
|
11590 |
|
11591 |
|
11592 |
|
11593 |
|
11594 |
|
11595 |
|
11596 |
|
11597 |
|
11598 |
|
11599 |
|
11600 |
|
11601 |
|
11602 |
|
11603 |
|
11604 |
|
11605 |
|
11606 |
|
11607 |
|
11608 |
|
11609 |
|
11610 |
|
11611 |
|
11612 |
|
11613 |
|
11614 |
|
11615 |
|
11616 |
|
11617 |
|
11618 | attachPingListener(root, renderExpirationTime, thenable);
|
11619 | _workInProgress.effectTag |= ShouldCapture;
|
11620 | _workInProgress.expirationTime = renderExpirationTime;
|
11621 | return;
|
11622 | }
|
11623 |
|
11624 |
|
11625 |
|
11626 | _workInProgress = _workInProgress.return;
|
11627 | } while (_workInProgress !== null);
|
11628 |
|
11629 |
|
11630 |
|
11631 | 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));
|
11632 | }
|
11633 |
|
11634 |
|
11635 |
|
11636 |
|
11637 | renderDidError();
|
11638 | value = createCapturedValue(value, sourceFiber);
|
11639 | var workInProgress = returnFiber;
|
11640 |
|
11641 | do {
|
11642 | switch (workInProgress.tag) {
|
11643 | case HostRoot:
|
11644 | {
|
11645 | var _errorInfo = value;
|
11646 | workInProgress.effectTag |= ShouldCapture;
|
11647 | workInProgress.expirationTime = renderExpirationTime;
|
11648 |
|
11649 | var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
|
11650 |
|
11651 | enqueueCapturedUpdate(workInProgress, _update);
|
11652 | return;
|
11653 | }
|
11654 |
|
11655 | case ClassComponent:
|
11656 |
|
11657 | var errorInfo = value;
|
11658 | var ctor = workInProgress.type;
|
11659 | var instance = workInProgress.stateNode;
|
11660 |
|
11661 | if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
|
11662 | workInProgress.effectTag |= ShouldCapture;
|
11663 | workInProgress.expirationTime = renderExpirationTime;
|
11664 |
|
11665 | var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
|
11666 |
|
11667 | enqueueCapturedUpdate(workInProgress, _update2);
|
11668 | return;
|
11669 | }
|
11670 |
|
11671 | break;
|
11672 | }
|
11673 |
|
11674 | workInProgress = workInProgress.return;
|
11675 | } while (workInProgress !== null);
|
11676 | }
|
11677 |
|
11678 | var ceil = Math.ceil;
|
11679 | var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
|
11680 | ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
|
11681 | IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
|
11682 | var NoContext =
|
11683 |
|
11684 | 0;
|
11685 | var BatchedContext =
|
11686 |
|
11687 | 1;
|
11688 | var DiscreteEventContext =
|
11689 |
|
11690 | 4;
|
11691 | var LegacyUnbatchedContext =
|
11692 |
|
11693 | 8;
|
11694 | var RenderContext =
|
11695 |
|
11696 | 16;
|
11697 | var CommitContext =
|
11698 |
|
11699 | 32;
|
11700 | var RootIncomplete = 0;
|
11701 | var RootFatalErrored = 1;
|
11702 | var RootErrored = 2;
|
11703 | var RootSuspended = 3;
|
11704 | var RootSuspendedWithDelay = 4;
|
11705 | var RootCompleted = 5;
|
11706 |
|
11707 | var executionContext = NoContext;
|
11708 |
|
11709 | var workInProgressRoot = null;
|
11710 |
|
11711 | var workInProgress = null;
|
11712 |
|
11713 | var renderExpirationTime$1 = NoWork;
|
11714 |
|
11715 | var workInProgressRootExitStatus = RootIncomplete;
|
11716 |
|
11717 | var workInProgressRootFatalError = null;
|
11718 |
|
11719 |
|
11720 |
|
11721 |
|
11722 | var workInProgressRootLatestProcessedExpirationTime = Sync;
|
11723 | var workInProgressRootLatestSuspenseTimeout = Sync;
|
11724 | var workInProgressRootCanSuspendUsingConfig = null;
|
11725 |
|
11726 |
|
11727 | var workInProgressRootNextUnprocessedUpdateTime = NoWork;
|
11728 |
|
11729 |
|
11730 |
|
11731 | var workInProgressRootHasPendingPing = false;
|
11732 |
|
11733 |
|
11734 | var globalMostRecentFallbackTime = 0;
|
11735 | var FALLBACK_THROTTLE_MS = 500;
|
11736 | var nextEffect = null;
|
11737 | var hasUncaughtError = false;
|
11738 | var firstUncaughtError = null;
|
11739 | var legacyErrorBoundariesThatAlreadyFailed = null;
|
11740 | var rootDoesHavePassiveEffects = false;
|
11741 | var rootWithPendingPassiveEffects = null;
|
11742 | var pendingPassiveEffectsRenderPriority = NoPriority;
|
11743 | var pendingPassiveEffectsExpirationTime = NoWork;
|
11744 | var rootsWithPendingDiscreteUpdates = null;
|
11745 |
|
11746 | var NESTED_UPDATE_LIMIT = 50;
|
11747 | var nestedUpdateCount = 0;
|
11748 | var rootWithNestedUpdates = null;
|
11749 | var NESTED_PASSIVE_UPDATE_LIMIT = 50;
|
11750 | var nestedPassiveUpdateCount = 0;
|
11751 | var interruptedBy = null;
|
11752 |
|
11753 |
|
11754 |
|
11755 |
|
11756 | var spawnedWorkDuringRender = null;
|
11757 |
|
11758 |
|
11759 |
|
11760 |
|
11761 |
|
11762 |
|
11763 |
|
11764 | var currentEventTime = NoWork;
|
11765 | function requestCurrentTimeForUpdate() {
|
11766 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
11767 |
|
11768 | return msToExpirationTime(now());
|
11769 | }
|
11770 |
|
11771 |
|
11772 | if (currentEventTime !== NoWork) {
|
11773 |
|
11774 | return currentEventTime;
|
11775 | }
|
11776 |
|
11777 |
|
11778 | currentEventTime = msToExpirationTime(now());
|
11779 | return currentEventTime;
|
11780 | }
|
11781 | function getCurrentTime() {
|
11782 | return msToExpirationTime(now());
|
11783 | }
|
11784 | function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
|
11785 | var mode = fiber.mode;
|
11786 |
|
11787 | if ((mode & BlockingMode) === NoMode) {
|
11788 | return Sync;
|
11789 | }
|
11790 |
|
11791 | var priorityLevel = getCurrentPriorityLevel();
|
11792 |
|
11793 | if ((mode & ConcurrentMode) === NoMode) {
|
11794 | return priorityLevel === ImmediatePriority ? Sync : Batched;
|
11795 | }
|
11796 |
|
11797 | if ((executionContext & RenderContext) !== NoContext) {
|
11798 |
|
11799 |
|
11800 | return renderExpirationTime$1;
|
11801 | }
|
11802 |
|
11803 | var expirationTime;
|
11804 |
|
11805 | if (suspenseConfig !== null) {
|
11806 |
|
11807 | expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
|
11808 | } else {
|
11809 |
|
11810 | switch (priorityLevel) {
|
11811 | case ImmediatePriority:
|
11812 | expirationTime = Sync;
|
11813 | break;
|
11814 |
|
11815 | case UserBlockingPriority:
|
11816 |
|
11817 | expirationTime = computeInteractiveExpiration(currentTime);
|
11818 | break;
|
11819 |
|
11820 | case NormalPriority:
|
11821 | case LowPriority:
|
11822 |
|
11823 |
|
11824 | expirationTime = computeAsyncExpiration(currentTime);
|
11825 | break;
|
11826 |
|
11827 | case IdlePriority:
|
11828 | expirationTime = Idle;
|
11829 | break;
|
11830 |
|
11831 | default:
|
11832 | {
|
11833 | {
|
11834 | throw Error( "Expected a valid priority level" );
|
11835 | }
|
11836 | }
|
11837 |
|
11838 | }
|
11839 | }
|
11840 |
|
11841 |
|
11842 |
|
11843 |
|
11844 |
|
11845 |
|
11846 | if (workInProgressRoot !== null && expirationTime === renderExpirationTime$1) {
|
11847 |
|
11848 | expirationTime -= 1;
|
11849 | }
|
11850 |
|
11851 | return expirationTime;
|
11852 | }
|
11853 | function scheduleUpdateOnFiber(fiber, expirationTime) {
|
11854 | checkForNestedUpdates();
|
11855 | warnAboutRenderPhaseUpdatesInDEV(fiber);
|
11856 | var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
|
11857 |
|
11858 | if (root === null) {
|
11859 | warnAboutUpdateOnUnmountedFiberInDEV(fiber);
|
11860 | return;
|
11861 | }
|
11862 |
|
11863 | checkForInterruption(fiber, expirationTime);
|
11864 | recordScheduleUpdate();
|
11865 |
|
11866 |
|
11867 | var priorityLevel = getCurrentPriorityLevel();
|
11868 |
|
11869 | if (expirationTime === Sync) {
|
11870 | if (
|
11871 | (executionContext & LegacyUnbatchedContext) !== NoContext &&
|
11872 | (executionContext & (RenderContext | CommitContext)) === NoContext) {
|
11873 |
|
11874 | schedulePendingInteractions(root, expirationTime);
|
11875 |
|
11876 |
|
11877 |
|
11878 | performSyncWorkOnRoot(root);
|
11879 | } else {
|
11880 | ensureRootIsScheduled(root);
|
11881 | schedulePendingInteractions(root, expirationTime);
|
11882 |
|
11883 | if (executionContext === NoContext) {
|
11884 |
|
11885 |
|
11886 |
|
11887 |
|
11888 |
|
11889 | flushSyncCallbackQueue();
|
11890 | }
|
11891 | }
|
11892 | } else {
|
11893 | ensureRootIsScheduled(root);
|
11894 | schedulePendingInteractions(root, expirationTime);
|
11895 | }
|
11896 |
|
11897 | if ((executionContext & DiscreteEventContext) !== NoContext && (
|
11898 |
|
11899 | priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority)) {
|
11900 |
|
11901 |
|
11902 | if (rootsWithPendingDiscreteUpdates === null) {
|
11903 | rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
|
11904 | } else {
|
11905 | var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
|
11906 |
|
11907 | if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
|
11908 | rootsWithPendingDiscreteUpdates.set(root, expirationTime);
|
11909 | }
|
11910 | }
|
11911 | }
|
11912 | }
|
11913 | var scheduleWork = scheduleUpdateOnFiber;
|
11914 |
|
11915 |
|
11916 |
|
11917 |
|
11918 | function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
|
11919 |
|
11920 | if (fiber.expirationTime < expirationTime) {
|
11921 | fiber.expirationTime = expirationTime;
|
11922 | }
|
11923 |
|
11924 | var alternate = fiber.alternate;
|
11925 |
|
11926 | if (alternate !== null && alternate.expirationTime < expirationTime) {
|
11927 | alternate.expirationTime = expirationTime;
|
11928 | }
|
11929 |
|
11930 |
|
11931 | var node = fiber.return;
|
11932 | var root = null;
|
11933 |
|
11934 | if (node === null && fiber.tag === HostRoot) {
|
11935 | root = fiber.stateNode;
|
11936 | } else {
|
11937 | while (node !== null) {
|
11938 | alternate = node.alternate;
|
11939 |
|
11940 | if (node.childExpirationTime < expirationTime) {
|
11941 | node.childExpirationTime = expirationTime;
|
11942 |
|
11943 | if (alternate !== null && alternate.childExpirationTime < expirationTime) {
|
11944 | alternate.childExpirationTime = expirationTime;
|
11945 | }
|
11946 | } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
|
11947 | alternate.childExpirationTime = expirationTime;
|
11948 | }
|
11949 |
|
11950 | if (node.return === null && node.tag === HostRoot) {
|
11951 | root = node.stateNode;
|
11952 | break;
|
11953 | }
|
11954 |
|
11955 | node = node.return;
|
11956 | }
|
11957 | }
|
11958 |
|
11959 | if (root !== null) {
|
11960 | if (workInProgressRoot === root) {
|
11961 |
|
11962 |
|
11963 | markUnprocessedUpdateTime(expirationTime);
|
11964 |
|
11965 | if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
|
11966 |
|
11967 |
|
11968 |
|
11969 |
|
11970 |
|
11971 |
|
11972 |
|
11973 |
|
11974 |
|
11975 |
|
11976 |
|
11977 |
|
11978 |
|
11979 | markRootSuspendedAtTime(root, renderExpirationTime$1);
|
11980 | }
|
11981 | }
|
11982 |
|
11983 |
|
11984 | markRootUpdatedAtTime(root, expirationTime);
|
11985 | }
|
11986 |
|
11987 | return root;
|
11988 | }
|
11989 |
|
11990 | function getNextRootExpirationTimeToWorkOn(root) {
|
11991 |
|
11992 |
|
11993 |
|
11994 | var lastExpiredTime = root.lastExpiredTime;
|
11995 |
|
11996 | if (lastExpiredTime !== NoWork) {
|
11997 | return lastExpiredTime;
|
11998 | }
|
11999 |
|
12000 |
|
12001 |
|
12002 | var firstPendingTime = root.firstPendingTime;
|
12003 |
|
12004 | if (!isRootSuspendedAtTime(root, firstPendingTime)) {
|
12005 |
|
12006 | return firstPendingTime;
|
12007 | }
|
12008 |
|
12009 |
|
12010 |
|
12011 |
|
12012 | var lastPingedTime = root.lastPingedTime;
|
12013 | var nextKnownPendingLevel = root.nextKnownPendingLevel;
|
12014 | var nextLevel = lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel;
|
12015 |
|
12016 | if ( nextLevel <= Idle && firstPendingTime !== nextLevel) {
|
12017 |
|
12018 | return NoWork;
|
12019 | }
|
12020 |
|
12021 | return nextLevel;
|
12022 | }
|
12023 |
|
12024 |
|
12025 |
|
12026 |
|
12027 |
|
12028 |
|
12029 | function ensureRootIsScheduled(root) {
|
12030 | var lastExpiredTime = root.lastExpiredTime;
|
12031 |
|
12032 | if (lastExpiredTime !== NoWork) {
|
12033 |
|
12034 | root.callbackExpirationTime = Sync;
|
12035 | root.callbackPriority = ImmediatePriority;
|
12036 | root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
|
12037 | return;
|
12038 | }
|
12039 |
|
12040 | var expirationTime = getNextRootExpirationTimeToWorkOn(root);
|
12041 | var existingCallbackNode = root.callbackNode;
|
12042 |
|
12043 | if (expirationTime === NoWork) {
|
12044 |
|
12045 | if (existingCallbackNode !== null) {
|
12046 | root.callbackNode = null;
|
12047 | root.callbackExpirationTime = NoWork;
|
12048 | root.callbackPriority = NoPriority;
|
12049 | }
|
12050 |
|
12051 | return;
|
12052 | }
|
12053 |
|
12054 |
|
12055 |
|
12056 | var currentTime = requestCurrentTimeForUpdate();
|
12057 | var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
|
12058 |
|
12059 |
|
12060 | if (existingCallbackNode !== null) {
|
12061 | var existingCallbackPriority = root.callbackPriority;
|
12062 | var existingCallbackExpirationTime = root.callbackExpirationTime;
|
12063 |
|
12064 | if (
|
12065 | existingCallbackExpirationTime === expirationTime &&
|
12066 | existingCallbackPriority >= priorityLevel) {
|
12067 |
|
12068 | return;
|
12069 | }
|
12070 |
|
12071 |
|
12072 |
|
12073 |
|
12074 | cancelCallback(existingCallbackNode);
|
12075 | }
|
12076 |
|
12077 | root.callbackExpirationTime = expirationTime;
|
12078 | root.callbackPriority = priorityLevel;
|
12079 | var callbackNode;
|
12080 |
|
12081 | if (expirationTime === Sync) {
|
12082 |
|
12083 | callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
|
12084 | } else {
|
12085 | callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root),
|
12086 |
|
12087 | {
|
12088 | timeout: expirationTimeToMs(expirationTime) - now()
|
12089 | });
|
12090 | }
|
12091 |
|
12092 | root.callbackNode = callbackNode;
|
12093 | }
|
12094 |
|
12095 |
|
12096 |
|
12097 | function performConcurrentWorkOnRoot(root, didTimeout) {
|
12098 |
|
12099 |
|
12100 | currentEventTime = NoWork;
|
12101 |
|
12102 | if (didTimeout) {
|
12103 |
|
12104 |
|
12105 | var currentTime = requestCurrentTimeForUpdate();
|
12106 | markRootExpiredAtTime(root, currentTime);
|
12107 |
|
12108 | ensureRootIsScheduled(root);
|
12109 | return null;
|
12110 | }
|
12111 |
|
12112 |
|
12113 |
|
12114 | var expirationTime = getNextRootExpirationTimeToWorkOn(root);
|
12115 |
|
12116 | if (expirationTime !== NoWork) {
|
12117 | var originalCallbackNode = root.callbackNode;
|
12118 |
|
12119 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
12120 | {
|
12121 | throw Error( "Should not already be working." );
|
12122 | }
|
12123 | }
|
12124 |
|
12125 | flushPassiveEffects();
|
12126 |
|
12127 |
|
12128 | if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) {
|
12129 | prepareFreshStack(root, expirationTime);
|
12130 | startWorkOnPendingInteractions(root, expirationTime);
|
12131 | }
|
12132 |
|
12133 |
|
12134 |
|
12135 | if (workInProgress !== null) {
|
12136 | var prevExecutionContext = executionContext;
|
12137 | executionContext |= RenderContext;
|
12138 | var prevDispatcher = pushDispatcher();
|
12139 | var prevInteractions = pushInteractions(root);
|
12140 | startWorkLoopTimer(workInProgress);
|
12141 |
|
12142 | do {
|
12143 | try {
|
12144 | workLoopConcurrent();
|
12145 | break;
|
12146 | } catch (thrownValue) {
|
12147 | handleError(root, thrownValue);
|
12148 | }
|
12149 | } while (true);
|
12150 |
|
12151 | resetContextDependencies();
|
12152 | executionContext = prevExecutionContext;
|
12153 | popDispatcher(prevDispatcher);
|
12154 |
|
12155 | {
|
12156 | popInteractions(prevInteractions);
|
12157 | }
|
12158 |
|
12159 | if (workInProgressRootExitStatus === RootFatalErrored) {
|
12160 | var fatalError = workInProgressRootFatalError;
|
12161 | stopInterruptedWorkLoopTimer();
|
12162 | prepareFreshStack(root, expirationTime);
|
12163 | markRootSuspendedAtTime(root, expirationTime);
|
12164 | ensureRootIsScheduled(root);
|
12165 | throw fatalError;
|
12166 | }
|
12167 |
|
12168 | if (workInProgress !== null) {
|
12169 |
|
12170 | stopInterruptedWorkLoopTimer();
|
12171 | } else {
|
12172 |
|
12173 |
|
12174 | stopFinishedWorkLoopTimer();
|
12175 | var finishedWork = root.finishedWork = root.current.alternate;
|
12176 | root.finishedExpirationTime = expirationTime;
|
12177 | finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime);
|
12178 | }
|
12179 |
|
12180 | ensureRootIsScheduled(root);
|
12181 |
|
12182 | if (root.callbackNode === originalCallbackNode) {
|
12183 |
|
12184 |
|
12185 | return performConcurrentWorkOnRoot.bind(null, root);
|
12186 | }
|
12187 | }
|
12188 | }
|
12189 |
|
12190 | return null;
|
12191 | }
|
12192 |
|
12193 | function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
|
12194 |
|
12195 | workInProgressRoot = null;
|
12196 |
|
12197 | switch (exitStatus) {
|
12198 | case RootIncomplete:
|
12199 | case RootFatalErrored:
|
12200 | {
|
12201 | {
|
12202 | {
|
12203 | throw Error( "Root did not complete. This is a bug in React." );
|
12204 | }
|
12205 | }
|
12206 | }
|
12207 |
|
12208 |
|
12209 |
|
12210 |
|
12211 | case RootErrored:
|
12212 | {
|
12213 |
|
12214 |
|
12215 |
|
12216 |
|
12217 |
|
12218 |
|
12219 |
|
12220 | markRootExpiredAtTime(root, expirationTime > Idle ? Idle : expirationTime);
|
12221 |
|
12222 |
|
12223 | break;
|
12224 | }
|
12225 |
|
12226 | case RootSuspended:
|
12227 | {
|
12228 | markRootSuspendedAtTime(root, expirationTime);
|
12229 | var lastSuspendedTime = root.lastSuspendedTime;
|
12230 |
|
12231 | if (expirationTime === lastSuspendedTime) {
|
12232 | root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
|
12233 | }
|
12234 |
|
12235 |
|
12236 |
|
12237 |
|
12238 |
|
12239 |
|
12240 | var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
|
12241 |
|
12242 | if (hasNotProcessedNewUpdates &&
|
12243 | !( IsThisRendererActing.current)) {
|
12244 |
|
12245 |
|
12246 |
|
12247 |
|
12248 |
|
12249 |
|
12250 | var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now();
|
12251 |
|
12252 | if (msUntilTimeout > 10) {
|
12253 | if (workInProgressRootHasPendingPing) {
|
12254 | var lastPingedTime = root.lastPingedTime;
|
12255 |
|
12256 | if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
|
12257 |
|
12258 |
|
12259 | root.lastPingedTime = expirationTime;
|
12260 | prepareFreshStack(root, expirationTime);
|
12261 | break;
|
12262 | }
|
12263 | }
|
12264 |
|
12265 | var nextTime = getNextRootExpirationTimeToWorkOn(root);
|
12266 |
|
12267 | if (nextTime !== NoWork && nextTime !== expirationTime) {
|
12268 |
|
12269 | break;
|
12270 | }
|
12271 |
|
12272 | if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) {
|
12273 |
|
12274 |
|
12275 |
|
12276 | root.lastPingedTime = lastSuspendedTime;
|
12277 | break;
|
12278 | }
|
12279 |
|
12280 |
|
12281 |
|
12282 |
|
12283 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
|
12284 | break;
|
12285 | }
|
12286 | }
|
12287 |
|
12288 |
|
12289 | commitRoot(root);
|
12290 | break;
|
12291 | }
|
12292 |
|
12293 | case RootSuspendedWithDelay:
|
12294 | {
|
12295 | markRootSuspendedAtTime(root, expirationTime);
|
12296 | var _lastSuspendedTime = root.lastSuspendedTime;
|
12297 |
|
12298 | if (expirationTime === _lastSuspendedTime) {
|
12299 | root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
|
12300 | }
|
12301 |
|
12302 | if (
|
12303 | !( IsThisRendererActing.current)) {
|
12304 |
|
12305 |
|
12306 | if (workInProgressRootHasPendingPing) {
|
12307 | var _lastPingedTime = root.lastPingedTime;
|
12308 |
|
12309 | if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
|
12310 |
|
12311 |
|
12312 | root.lastPingedTime = expirationTime;
|
12313 | prepareFreshStack(root, expirationTime);
|
12314 | break;
|
12315 | }
|
12316 | }
|
12317 |
|
12318 | var _nextTime = getNextRootExpirationTimeToWorkOn(root);
|
12319 |
|
12320 | if (_nextTime !== NoWork && _nextTime !== expirationTime) {
|
12321 |
|
12322 | break;
|
12323 | }
|
12324 |
|
12325 | if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) {
|
12326 |
|
12327 |
|
12328 |
|
12329 | root.lastPingedTime = _lastSuspendedTime;
|
12330 | break;
|
12331 | }
|
12332 |
|
12333 | var _msUntilTimeout;
|
12334 |
|
12335 | if (workInProgressRootLatestSuspenseTimeout !== Sync) {
|
12336 |
|
12337 |
|
12338 | _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
|
12339 | } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
|
12340 |
|
12341 |
|
12342 |
|
12343 | _msUntilTimeout = 0;
|
12344 | } else {
|
12345 |
|
12346 |
|
12347 | var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
|
12348 | var currentTimeMs = now();
|
12349 | var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
|
12350 | var timeElapsed = currentTimeMs - eventTimeMs;
|
12351 |
|
12352 | if (timeElapsed < 0) {
|
12353 |
|
12354 | timeElapsed = 0;
|
12355 | }
|
12356 |
|
12357 | _msUntilTimeout = jnd(timeElapsed) - timeElapsed;
|
12358 |
|
12359 |
|
12360 |
|
12361 | if (timeUntilExpirationMs < _msUntilTimeout) {
|
12362 | _msUntilTimeout = timeUntilExpirationMs;
|
12363 | }
|
12364 | }
|
12365 |
|
12366 |
|
12367 | if (_msUntilTimeout > 10) {
|
12368 |
|
12369 |
|
12370 |
|
12371 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
|
12372 | break;
|
12373 | }
|
12374 | }
|
12375 |
|
12376 |
|
12377 | commitRoot(root);
|
12378 | break;
|
12379 | }
|
12380 |
|
12381 | case RootCompleted:
|
12382 | {
|
12383 |
|
12384 | if (
|
12385 | !( IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
|
12386 |
|
12387 |
|
12388 |
|
12389 |
|
12390 | var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
|
12391 |
|
12392 | if (_msUntilTimeout2 > 10) {
|
12393 | markRootSuspendedAtTime(root, expirationTime);
|
12394 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
|
12395 | break;
|
12396 | }
|
12397 | }
|
12398 |
|
12399 | commitRoot(root);
|
12400 | break;
|
12401 | }
|
12402 |
|
12403 | default:
|
12404 | {
|
12405 | {
|
12406 | {
|
12407 | throw Error( "Unknown root exit status." );
|
12408 | }
|
12409 | }
|
12410 | }
|
12411 | }
|
12412 | }
|
12413 |
|
12414 |
|
12415 |
|
12416 | function performSyncWorkOnRoot(root) {
|
12417 |
|
12418 | var lastExpiredTime = root.lastExpiredTime;
|
12419 | var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync;
|
12420 |
|
12421 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
12422 | {
|
12423 | throw Error( "Should not already be working." );
|
12424 | }
|
12425 | }
|
12426 |
|
12427 | flushPassiveEffects();
|
12428 |
|
12429 |
|
12430 | if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) {
|
12431 | prepareFreshStack(root, expirationTime);
|
12432 | startWorkOnPendingInteractions(root, expirationTime);
|
12433 | }
|
12434 |
|
12435 |
|
12436 |
|
12437 | if (workInProgress !== null) {
|
12438 | var prevExecutionContext = executionContext;
|
12439 | executionContext |= RenderContext;
|
12440 | var prevDispatcher = pushDispatcher();
|
12441 | var prevInteractions = pushInteractions(root);
|
12442 | startWorkLoopTimer(workInProgress);
|
12443 |
|
12444 | do {
|
12445 | try {
|
12446 | workLoopSync();
|
12447 | break;
|
12448 | } catch (thrownValue) {
|
12449 | handleError(root, thrownValue);
|
12450 | }
|
12451 | } while (true);
|
12452 |
|
12453 | resetContextDependencies();
|
12454 | executionContext = prevExecutionContext;
|
12455 | popDispatcher(prevDispatcher);
|
12456 |
|
12457 | {
|
12458 | popInteractions(prevInteractions);
|
12459 | }
|
12460 |
|
12461 | if (workInProgressRootExitStatus === RootFatalErrored) {
|
12462 | var fatalError = workInProgressRootFatalError;
|
12463 | stopInterruptedWorkLoopTimer();
|
12464 | prepareFreshStack(root, expirationTime);
|
12465 | markRootSuspendedAtTime(root, expirationTime);
|
12466 | ensureRootIsScheduled(root);
|
12467 | throw fatalError;
|
12468 | }
|
12469 |
|
12470 | if (workInProgress !== null) {
|
12471 |
|
12472 | {
|
12473 | {
|
12474 | throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." );
|
12475 | }
|
12476 | }
|
12477 | } else {
|
12478 |
|
12479 |
|
12480 | stopFinishedWorkLoopTimer();
|
12481 | root.finishedWork = root.current.alternate;
|
12482 | root.finishedExpirationTime = expirationTime;
|
12483 | finishSyncRender(root);
|
12484 | }
|
12485 |
|
12486 |
|
12487 |
|
12488 | ensureRootIsScheduled(root);
|
12489 | }
|
12490 |
|
12491 | return null;
|
12492 | }
|
12493 |
|
12494 | function finishSyncRender(root) {
|
12495 |
|
12496 | workInProgressRoot = null;
|
12497 | commitRoot(root);
|
12498 | }
|
12499 | function syncUpdates(fn, a, b, c) {
|
12500 | return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c));
|
12501 | }
|
12502 |
|
12503 | function batchedUpdates(fn, a) {
|
12504 | var prevExecutionContext = executionContext;
|
12505 | executionContext |= BatchedContext;
|
12506 |
|
12507 | try {
|
12508 | return fn(a);
|
12509 | } finally {
|
12510 | executionContext = prevExecutionContext;
|
12511 |
|
12512 | if (executionContext === NoContext) {
|
12513 |
|
12514 | flushSyncCallbackQueue();
|
12515 | }
|
12516 | }
|
12517 | }
|
12518 | function flushSync(fn, a) {
|
12519 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
12520 | {
|
12521 | {
|
12522 | throw Error( "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." );
|
12523 | }
|
12524 | }
|
12525 | }
|
12526 |
|
12527 | var prevExecutionContext = executionContext;
|
12528 | executionContext |= BatchedContext;
|
12529 |
|
12530 | try {
|
12531 | return runWithPriority(ImmediatePriority, fn.bind(null, a));
|
12532 | } finally {
|
12533 | executionContext = prevExecutionContext;
|
12534 |
|
12535 |
|
12536 |
|
12537 | flushSyncCallbackQueue();
|
12538 | }
|
12539 | }
|
12540 |
|
12541 | function prepareFreshStack(root, expirationTime) {
|
12542 | root.finishedWork = null;
|
12543 | root.finishedExpirationTime = NoWork;
|
12544 | var timeoutHandle = root.timeoutHandle;
|
12545 |
|
12546 | if (timeoutHandle !== noTimeout) {
|
12547 |
|
12548 |
|
12549 | root.timeoutHandle = noTimeout;
|
12550 |
|
12551 | cancelTimeout(timeoutHandle);
|
12552 | }
|
12553 |
|
12554 | if (workInProgress !== null) {
|
12555 | var interruptedWork = workInProgress.return;
|
12556 |
|
12557 | while (interruptedWork !== null) {
|
12558 | unwindInterruptedWork(interruptedWork);
|
12559 | interruptedWork = interruptedWork.return;
|
12560 | }
|
12561 | }
|
12562 |
|
12563 | workInProgressRoot = root;
|
12564 | workInProgress = createWorkInProgress(root.current, null);
|
12565 | renderExpirationTime$1 = expirationTime;
|
12566 | workInProgressRootExitStatus = RootIncomplete;
|
12567 | workInProgressRootFatalError = null;
|
12568 | workInProgressRootLatestProcessedExpirationTime = Sync;
|
12569 | workInProgressRootLatestSuspenseTimeout = Sync;
|
12570 | workInProgressRootCanSuspendUsingConfig = null;
|
12571 | workInProgressRootNextUnprocessedUpdateTime = NoWork;
|
12572 | workInProgressRootHasPendingPing = false;
|
12573 |
|
12574 | {
|
12575 | spawnedWorkDuringRender = null;
|
12576 | }
|
12577 |
|
12578 | {
|
12579 | ReactStrictModeWarnings.discardPendingWarnings();
|
12580 | }
|
12581 | }
|
12582 |
|
12583 | function handleError(root, thrownValue) {
|
12584 | do {
|
12585 | try {
|
12586 |
|
12587 | resetContextDependencies();
|
12588 | resetHooksAfterThrow();
|
12589 | resetCurrentFiber();
|
12590 |
|
12591 | if (workInProgress === null || workInProgress.return === null) {
|
12592 |
|
12593 |
|
12594 |
|
12595 |
|
12596 | workInProgressRootExitStatus = RootFatalErrored;
|
12597 | workInProgressRootFatalError = thrownValue;
|
12598 |
|
12599 |
|
12600 |
|
12601 |
|
12602 |
|
12603 |
|
12604 | workInProgress = null;
|
12605 | return null;
|
12606 | }
|
12607 |
|
12608 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
12609 |
|
12610 |
|
12611 |
|
12612 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
|
12613 | }
|
12614 |
|
12615 | throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime$1);
|
12616 | workInProgress = completeUnitOfWork(workInProgress);
|
12617 | } catch (yetAnotherThrownValue) {
|
12618 |
|
12619 | thrownValue = yetAnotherThrownValue;
|
12620 | continue;
|
12621 | }
|
12622 |
|
12623 |
|
12624 | return;
|
12625 | } while (true);
|
12626 | }
|
12627 |
|
12628 | function pushDispatcher(root) {
|
12629 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
12630 | ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
12631 |
|
12632 | if (prevDispatcher === null) {
|
12633 |
|
12634 |
|
12635 |
|
12636 | return ContextOnlyDispatcher;
|
12637 | } else {
|
12638 | return prevDispatcher;
|
12639 | }
|
12640 | }
|
12641 |
|
12642 | function popDispatcher(prevDispatcher) {
|
12643 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
12644 | }
|
12645 |
|
12646 | function pushInteractions(root) {
|
12647 | {
|
12648 | var prevInteractions = __interactionsRef.current;
|
12649 | __interactionsRef.current = root.memoizedInteractions;
|
12650 | return prevInteractions;
|
12651 | }
|
12652 | }
|
12653 |
|
12654 | function popInteractions(prevInteractions) {
|
12655 | {
|
12656 | __interactionsRef.current = prevInteractions;
|
12657 | }
|
12658 | }
|
12659 |
|
12660 | function markCommitTimeOfFallback() {
|
12661 | globalMostRecentFallbackTime = now();
|
12662 | }
|
12663 | function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
|
12664 | if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) {
|
12665 | workInProgressRootLatestProcessedExpirationTime = expirationTime;
|
12666 | }
|
12667 |
|
12668 | if (suspenseConfig !== null) {
|
12669 | if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) {
|
12670 | workInProgressRootLatestSuspenseTimeout = expirationTime;
|
12671 |
|
12672 | workInProgressRootCanSuspendUsingConfig = suspenseConfig;
|
12673 | }
|
12674 | }
|
12675 | }
|
12676 | function markUnprocessedUpdateTime(expirationTime) {
|
12677 | if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
|
12678 | workInProgressRootNextUnprocessedUpdateTime = expirationTime;
|
12679 | }
|
12680 | }
|
12681 | function renderDidSuspend() {
|
12682 | if (workInProgressRootExitStatus === RootIncomplete) {
|
12683 | workInProgressRootExitStatus = RootSuspended;
|
12684 | }
|
12685 | }
|
12686 | function renderDidSuspendDelayIfPossible() {
|
12687 | if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
|
12688 | workInProgressRootExitStatus = RootSuspendedWithDelay;
|
12689 | }
|
12690 |
|
12691 |
|
12692 | if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) {
|
12693 |
|
12694 |
|
12695 |
|
12696 |
|
12697 | markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1);
|
12698 | markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime);
|
12699 | }
|
12700 | }
|
12701 | function renderDidError() {
|
12702 | if (workInProgressRootExitStatus !== RootCompleted) {
|
12703 | workInProgressRootExitStatus = RootErrored;
|
12704 | }
|
12705 | }
|
12706 |
|
12707 |
|
12708 | function renderHasNotSuspendedYet() {
|
12709 |
|
12710 |
|
12711 | return workInProgressRootExitStatus === RootIncomplete;
|
12712 | }
|
12713 |
|
12714 | function inferTimeFromExpirationTime(expirationTime) {
|
12715 |
|
12716 |
|
12717 | var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
|
12718 | return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
|
12719 | }
|
12720 |
|
12721 | function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
|
12722 |
|
12723 |
|
12724 |
|
12725 | var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
|
12726 | return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
|
12727 | }
|
12728 |
|
12729 |
|
12730 |
|
12731 |
|
12732 | function workLoopSync() {
|
12733 |
|
12734 | while (workInProgress !== null) {
|
12735 | workInProgress = performUnitOfWork(workInProgress);
|
12736 | }
|
12737 | }
|
12738 |
|
12739 |
|
12740 |
|
12741 | function workLoopConcurrent() {
|
12742 |
|
12743 | while (workInProgress !== null && !shouldYield()) {
|
12744 | workInProgress = performUnitOfWork(workInProgress);
|
12745 | }
|
12746 | }
|
12747 |
|
12748 | function performUnitOfWork(unitOfWork) {
|
12749 |
|
12750 |
|
12751 |
|
12752 | var current = unitOfWork.alternate;
|
12753 | startWorkTimer(unitOfWork);
|
12754 | setCurrentFiber(unitOfWork);
|
12755 | var next;
|
12756 |
|
12757 | if ( (unitOfWork.mode & ProfileMode) !== NoMode) {
|
12758 | startProfilerTimer(unitOfWork);
|
12759 | next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
|
12760 | stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
|
12761 | } else {
|
12762 | next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
|
12763 | }
|
12764 |
|
12765 | resetCurrentFiber();
|
12766 | unitOfWork.memoizedProps = unitOfWork.pendingProps;
|
12767 |
|
12768 | if (next === null) {
|
12769 |
|
12770 | next = completeUnitOfWork(unitOfWork);
|
12771 | }
|
12772 |
|
12773 | ReactCurrentOwner$2.current = null;
|
12774 | return next;
|
12775 | }
|
12776 |
|
12777 | function completeUnitOfWork(unitOfWork) {
|
12778 |
|
12779 |
|
12780 | workInProgress = unitOfWork;
|
12781 |
|
12782 | do {
|
12783 |
|
12784 |
|
12785 |
|
12786 | var current = workInProgress.alternate;
|
12787 | var returnFiber = workInProgress.return;
|
12788 |
|
12789 | if ((workInProgress.effectTag & Incomplete) === NoEffect) {
|
12790 | setCurrentFiber(workInProgress);
|
12791 | var next = void 0;
|
12792 |
|
12793 | if ( (workInProgress.mode & ProfileMode) === NoMode) {
|
12794 | next = completeWork(current, workInProgress, renderExpirationTime$1);
|
12795 | } else {
|
12796 | startProfilerTimer(workInProgress);
|
12797 | next = completeWork(current, workInProgress, renderExpirationTime$1);
|
12798 |
|
12799 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
|
12800 | }
|
12801 |
|
12802 | stopWorkTimer(workInProgress);
|
12803 | resetCurrentFiber();
|
12804 | resetChildExpirationTime(workInProgress);
|
12805 |
|
12806 | if (next !== null) {
|
12807 |
|
12808 | return next;
|
12809 | }
|
12810 |
|
12811 | if (returnFiber !== null &&
|
12812 | (returnFiber.effectTag & Incomplete) === NoEffect) {
|
12813 |
|
12814 |
|
12815 |
|
12816 | if (returnFiber.firstEffect === null) {
|
12817 | returnFiber.firstEffect = workInProgress.firstEffect;
|
12818 | }
|
12819 |
|
12820 | if (workInProgress.lastEffect !== null) {
|
12821 | if (returnFiber.lastEffect !== null) {
|
12822 | returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
|
12823 | }
|
12824 |
|
12825 | returnFiber.lastEffect = workInProgress.lastEffect;
|
12826 | }
|
12827 |
|
12828 |
|
12829 |
|
12830 |
|
12831 |
|
12832 |
|
12833 |
|
12834 | var effectTag = workInProgress.effectTag;
|
12835 |
|
12836 |
|
12837 |
|
12838 | if (effectTag > PerformedWork) {
|
12839 | if (returnFiber.lastEffect !== null) {
|
12840 | returnFiber.lastEffect.nextEffect = workInProgress;
|
12841 | } else {
|
12842 | returnFiber.firstEffect = workInProgress;
|
12843 | }
|
12844 |
|
12845 | returnFiber.lastEffect = workInProgress;
|
12846 | }
|
12847 | }
|
12848 | } else {
|
12849 |
|
12850 |
|
12851 |
|
12852 | var _next = unwindWork(workInProgress);
|
12853 |
|
12854 |
|
12855 | if ( (workInProgress.mode & ProfileMode) !== NoMode) {
|
12856 |
|
12857 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
|
12858 |
|
12859 | var actualDuration = workInProgress.actualDuration;
|
12860 | var child = workInProgress.child;
|
12861 |
|
12862 | while (child !== null) {
|
12863 | actualDuration += child.actualDuration;
|
12864 | child = child.sibling;
|
12865 | }
|
12866 |
|
12867 | workInProgress.actualDuration = actualDuration;
|
12868 | }
|
12869 |
|
12870 | if (_next !== null) {
|
12871 |
|
12872 |
|
12873 |
|
12874 |
|
12875 |
|
12876 |
|
12877 | stopFailedWorkTimer(workInProgress);
|
12878 | _next.effectTag &= HostEffectMask;
|
12879 | return _next;
|
12880 | }
|
12881 |
|
12882 | stopWorkTimer(workInProgress);
|
12883 |
|
12884 | if (returnFiber !== null) {
|
12885 |
|
12886 | returnFiber.firstEffect = returnFiber.lastEffect = null;
|
12887 | returnFiber.effectTag |= Incomplete;
|
12888 | }
|
12889 | }
|
12890 |
|
12891 | var siblingFiber = workInProgress.sibling;
|
12892 |
|
12893 | if (siblingFiber !== null) {
|
12894 |
|
12895 | return siblingFiber;
|
12896 | }
|
12897 |
|
12898 |
|
12899 | workInProgress = returnFiber;
|
12900 | } while (workInProgress !== null);
|
12901 |
|
12902 |
|
12903 | if (workInProgressRootExitStatus === RootIncomplete) {
|
12904 | workInProgressRootExitStatus = RootCompleted;
|
12905 | }
|
12906 |
|
12907 | return null;
|
12908 | }
|
12909 |
|
12910 | function getRemainingExpirationTime(fiber) {
|
12911 | var updateExpirationTime = fiber.expirationTime;
|
12912 | var childExpirationTime = fiber.childExpirationTime;
|
12913 | return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime;
|
12914 | }
|
12915 |
|
12916 | function resetChildExpirationTime(completedWork) {
|
12917 | if (renderExpirationTime$1 !== Never && completedWork.childExpirationTime === Never) {
|
12918 |
|
12919 |
|
12920 | return;
|
12921 | }
|
12922 |
|
12923 | var newChildExpirationTime = NoWork;
|
12924 |
|
12925 | if ( (completedWork.mode & ProfileMode) !== NoMode) {
|
12926 |
|
12927 |
|
12928 | var actualDuration = completedWork.actualDuration;
|
12929 | var treeBaseDuration = completedWork.selfBaseDuration;
|
12930 |
|
12931 |
|
12932 |
|
12933 |
|
12934 |
|
12935 |
|
12936 |
|
12937 | var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
|
12938 | var child = completedWork.child;
|
12939 |
|
12940 | while (child !== null) {
|
12941 | var childUpdateExpirationTime = child.expirationTime;
|
12942 | var childChildExpirationTime = child.childExpirationTime;
|
12943 |
|
12944 | if (childUpdateExpirationTime > newChildExpirationTime) {
|
12945 | newChildExpirationTime = childUpdateExpirationTime;
|
12946 | }
|
12947 |
|
12948 | if (childChildExpirationTime > newChildExpirationTime) {
|
12949 | newChildExpirationTime = childChildExpirationTime;
|
12950 | }
|
12951 |
|
12952 | if (shouldBubbleActualDurations) {
|
12953 | actualDuration += child.actualDuration;
|
12954 | }
|
12955 |
|
12956 | treeBaseDuration += child.treeBaseDuration;
|
12957 | child = child.sibling;
|
12958 | }
|
12959 |
|
12960 | completedWork.actualDuration = actualDuration;
|
12961 | completedWork.treeBaseDuration = treeBaseDuration;
|
12962 | } else {
|
12963 | var _child = completedWork.child;
|
12964 |
|
12965 | while (_child !== null) {
|
12966 | var _childUpdateExpirationTime = _child.expirationTime;
|
12967 | var _childChildExpirationTime = _child.childExpirationTime;
|
12968 |
|
12969 | if (_childUpdateExpirationTime > newChildExpirationTime) {
|
12970 | newChildExpirationTime = _childUpdateExpirationTime;
|
12971 | }
|
12972 |
|
12973 | if (_childChildExpirationTime > newChildExpirationTime) {
|
12974 | newChildExpirationTime = _childChildExpirationTime;
|
12975 | }
|
12976 |
|
12977 | _child = _child.sibling;
|
12978 | }
|
12979 | }
|
12980 |
|
12981 | completedWork.childExpirationTime = newChildExpirationTime;
|
12982 | }
|
12983 |
|
12984 | function commitRoot(root) {
|
12985 | var renderPriorityLevel = getCurrentPriorityLevel();
|
12986 | runWithPriority(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
|
12987 | return null;
|
12988 | }
|
12989 |
|
12990 | function commitRootImpl(root, renderPriorityLevel) {
|
12991 | do {
|
12992 |
|
12993 |
|
12994 |
|
12995 |
|
12996 |
|
12997 |
|
12998 | flushPassiveEffects();
|
12999 | } while (rootWithPendingPassiveEffects !== null);
|
13000 |
|
13001 | flushRenderPhaseStrictModeWarningsInDEV();
|
13002 |
|
13003 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
13004 | {
|
13005 | throw Error( "Should not already be working." );
|
13006 | }
|
13007 | }
|
13008 |
|
13009 | var finishedWork = root.finishedWork;
|
13010 | var expirationTime = root.finishedExpirationTime;
|
13011 |
|
13012 | if (finishedWork === null) {
|
13013 | return null;
|
13014 | }
|
13015 |
|
13016 | root.finishedWork = null;
|
13017 | root.finishedExpirationTime = NoWork;
|
13018 |
|
13019 | if (!(finishedWork !== root.current)) {
|
13020 | {
|
13021 | throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." );
|
13022 | }
|
13023 | }
|
13024 |
|
13025 |
|
13026 |
|
13027 | root.callbackNode = null;
|
13028 | root.callbackExpirationTime = NoWork;
|
13029 | root.callbackPriority = NoPriority;
|
13030 | root.nextKnownPendingLevel = NoWork;
|
13031 | startCommitTimer();
|
13032 |
|
13033 |
|
13034 | var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
|
13035 | markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
|
13036 |
|
13037 | if (root === workInProgressRoot) {
|
13038 |
|
13039 | workInProgressRoot = null;
|
13040 | workInProgress = null;
|
13041 | renderExpirationTime$1 = NoWork;
|
13042 | }
|
13043 |
|
13044 |
|
13045 |
|
13046 |
|
13047 |
|
13048 | var firstEffect;
|
13049 |
|
13050 | if (finishedWork.effectTag > PerformedWork) {
|
13051 |
|
13052 |
|
13053 |
|
13054 |
|
13055 | if (finishedWork.lastEffect !== null) {
|
13056 | finishedWork.lastEffect.nextEffect = finishedWork;
|
13057 | firstEffect = finishedWork.firstEffect;
|
13058 | } else {
|
13059 | firstEffect = finishedWork;
|
13060 | }
|
13061 | } else {
|
13062 |
|
13063 | firstEffect = finishedWork.firstEffect;
|
13064 | }
|
13065 |
|
13066 | if (firstEffect !== null) {
|
13067 | var prevExecutionContext = executionContext;
|
13068 | executionContext |= CommitContext;
|
13069 | var prevInteractions = pushInteractions(root);
|
13070 |
|
13071 | ReactCurrentOwner$2.current = null;
|
13072 |
|
13073 |
|
13074 |
|
13075 |
|
13076 |
|
13077 |
|
13078 | startCommitSnapshotEffectsTimer();
|
13079 | prepareForCommit(root.containerInfo);
|
13080 | nextEffect = firstEffect;
|
13081 |
|
13082 | do {
|
13083 | {
|
13084 | invokeGuardedCallback(null, commitBeforeMutationEffects, null);
|
13085 |
|
13086 | if (hasCaughtError()) {
|
13087 | if (!(nextEffect !== null)) {
|
13088 | {
|
13089 | throw Error( "Should be working on an effect." );
|
13090 | }
|
13091 | }
|
13092 |
|
13093 | var error = clearCaughtError();
|
13094 | captureCommitPhaseError(nextEffect, error);
|
13095 | nextEffect = nextEffect.nextEffect;
|
13096 | }
|
13097 | }
|
13098 | } while (nextEffect !== null);
|
13099 |
|
13100 | stopCommitSnapshotEffectsTimer();
|
13101 |
|
13102 | {
|
13103 |
|
13104 |
|
13105 | recordCommitTime();
|
13106 | }
|
13107 |
|
13108 |
|
13109 | startCommitHostEffectsTimer();
|
13110 | nextEffect = firstEffect;
|
13111 |
|
13112 | do {
|
13113 | {
|
13114 | invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
|
13115 |
|
13116 | if (hasCaughtError()) {
|
13117 | if (!(nextEffect !== null)) {
|
13118 | {
|
13119 | throw Error( "Should be working on an effect." );
|
13120 | }
|
13121 | }
|
13122 |
|
13123 | var _error = clearCaughtError();
|
13124 |
|
13125 | captureCommitPhaseError(nextEffect, _error);
|
13126 | nextEffect = nextEffect.nextEffect;
|
13127 | }
|
13128 | }
|
13129 | } while (nextEffect !== null);
|
13130 |
|
13131 | stopCommitHostEffectsTimer();
|
13132 | resetAfterCommit(root.containerInfo);
|
13133 |
|
13134 |
|
13135 |
|
13136 |
|
13137 | root.current = finishedWork;
|
13138 |
|
13139 |
|
13140 |
|
13141 | startCommitLifeCyclesTimer();
|
13142 | nextEffect = firstEffect;
|
13143 |
|
13144 | do {
|
13145 | {
|
13146 | invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
|
13147 |
|
13148 | if (hasCaughtError()) {
|
13149 | if (!(nextEffect !== null)) {
|
13150 | {
|
13151 | throw Error( "Should be working on an effect." );
|
13152 | }
|
13153 | }
|
13154 |
|
13155 | var _error2 = clearCaughtError();
|
13156 |
|
13157 | captureCommitPhaseError(nextEffect, _error2);
|
13158 | nextEffect = nextEffect.nextEffect;
|
13159 | }
|
13160 | }
|
13161 | } while (nextEffect !== null);
|
13162 |
|
13163 | stopCommitLifeCyclesTimer();
|
13164 | nextEffect = null;
|
13165 |
|
13166 |
|
13167 | requestPaint();
|
13168 |
|
13169 | {
|
13170 | popInteractions(prevInteractions);
|
13171 | }
|
13172 |
|
13173 | executionContext = prevExecutionContext;
|
13174 | } else {
|
13175 |
|
13176 | root.current = finishedWork;
|
13177 |
|
13178 |
|
13179 |
|
13180 | startCommitSnapshotEffectsTimer();
|
13181 | stopCommitSnapshotEffectsTimer();
|
13182 |
|
13183 | {
|
13184 | recordCommitTime();
|
13185 | }
|
13186 |
|
13187 | startCommitHostEffectsTimer();
|
13188 | stopCommitHostEffectsTimer();
|
13189 | startCommitLifeCyclesTimer();
|
13190 | stopCommitLifeCyclesTimer();
|
13191 | }
|
13192 |
|
13193 | stopCommitTimer();
|
13194 | var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
|
13195 |
|
13196 | if (rootDoesHavePassiveEffects) {
|
13197 |
|
13198 |
|
13199 | rootDoesHavePassiveEffects = false;
|
13200 | rootWithPendingPassiveEffects = root;
|
13201 | pendingPassiveEffectsExpirationTime = expirationTime;
|
13202 | pendingPassiveEffectsRenderPriority = renderPriorityLevel;
|
13203 | } else {
|
13204 |
|
13205 |
|
13206 |
|
13207 | nextEffect = firstEffect;
|
13208 |
|
13209 | while (nextEffect !== null) {
|
13210 | var nextNextEffect = nextEffect.nextEffect;
|
13211 | nextEffect.nextEffect = null;
|
13212 | nextEffect = nextNextEffect;
|
13213 | }
|
13214 | }
|
13215 |
|
13216 |
|
13217 | var remainingExpirationTime = root.firstPendingTime;
|
13218 |
|
13219 | if (remainingExpirationTime !== NoWork) {
|
13220 | {
|
13221 | if (spawnedWorkDuringRender !== null) {
|
13222 | var expirationTimes = spawnedWorkDuringRender;
|
13223 | spawnedWorkDuringRender = null;
|
13224 |
|
13225 | for (var i = 0; i < expirationTimes.length; i++) {
|
13226 | scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
|
13227 | }
|
13228 | }
|
13229 |
|
13230 | schedulePendingInteractions(root, remainingExpirationTime);
|
13231 | }
|
13232 | } else {
|
13233 |
|
13234 |
|
13235 | legacyErrorBoundariesThatAlreadyFailed = null;
|
13236 | }
|
13237 |
|
13238 | {
|
13239 | if (!rootDidHavePassiveEffects) {
|
13240 |
|
13241 |
|
13242 |
|
13243 |
|
13244 | finishPendingInteractions(root, expirationTime);
|
13245 | }
|
13246 | }
|
13247 |
|
13248 | if (remainingExpirationTime === Sync) {
|
13249 |
|
13250 |
|
13251 | if (root === rootWithNestedUpdates) {
|
13252 | nestedUpdateCount++;
|
13253 | } else {
|
13254 | nestedUpdateCount = 0;
|
13255 | rootWithNestedUpdates = root;
|
13256 | }
|
13257 | } else {
|
13258 | nestedUpdateCount = 0;
|
13259 | }
|
13260 |
|
13261 | onCommitRoot(finishedWork.stateNode, expirationTime);
|
13262 |
|
13263 |
|
13264 | ensureRootIsScheduled(root);
|
13265 |
|
13266 | if (hasUncaughtError) {
|
13267 | hasUncaughtError = false;
|
13268 | var _error3 = firstUncaughtError;
|
13269 | firstUncaughtError = null;
|
13270 | throw _error3;
|
13271 | }
|
13272 |
|
13273 | if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
|
13274 |
|
13275 |
|
13276 |
|
13277 |
|
13278 | return null;
|
13279 | }
|
13280 |
|
13281 |
|
13282 | flushSyncCallbackQueue();
|
13283 | return null;
|
13284 | }
|
13285 |
|
13286 | function commitBeforeMutationEffects() {
|
13287 | while (nextEffect !== null) {
|
13288 | var effectTag = nextEffect.effectTag;
|
13289 |
|
13290 | if ((effectTag & Snapshot) !== NoEffect) {
|
13291 | setCurrentFiber(nextEffect);
|
13292 | recordEffect();
|
13293 | var current = nextEffect.alternate;
|
13294 | commitBeforeMutationLifeCycles(current, nextEffect);
|
13295 | resetCurrentFiber();
|
13296 | }
|
13297 |
|
13298 | if ((effectTag & Passive) !== NoEffect) {
|
13299 |
|
13300 |
|
13301 | if (!rootDoesHavePassiveEffects) {
|
13302 | rootDoesHavePassiveEffects = true;
|
13303 | scheduleCallback(NormalPriority, function () {
|
13304 | flushPassiveEffects();
|
13305 | return null;
|
13306 | });
|
13307 | }
|
13308 | }
|
13309 |
|
13310 | nextEffect = nextEffect.nextEffect;
|
13311 | }
|
13312 | }
|
13313 |
|
13314 | function commitMutationEffects(root, renderPriorityLevel) {
|
13315 |
|
13316 | while (nextEffect !== null) {
|
13317 | setCurrentFiber(nextEffect);
|
13318 | var effectTag = nextEffect.effectTag;
|
13319 |
|
13320 | if (effectTag & ContentReset) {
|
13321 | commitResetTextContent(nextEffect);
|
13322 | }
|
13323 |
|
13324 | if (effectTag & Ref) {
|
13325 | var current = nextEffect.alternate;
|
13326 |
|
13327 | if (current !== null) {
|
13328 | commitDetachRef(current);
|
13329 | }
|
13330 | }
|
13331 |
|
13332 |
|
13333 |
|
13334 |
|
13335 |
|
13336 | var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating);
|
13337 |
|
13338 | switch (primaryEffectTag) {
|
13339 | case Placement:
|
13340 | {
|
13341 | commitPlacement(nextEffect);
|
13342 |
|
13343 |
|
13344 |
|
13345 |
|
13346 | nextEffect.effectTag &= ~Placement;
|
13347 | break;
|
13348 | }
|
13349 |
|
13350 | case PlacementAndUpdate:
|
13351 | {
|
13352 |
|
13353 | commitPlacement(nextEffect);
|
13354 |
|
13355 |
|
13356 | nextEffect.effectTag &= ~Placement;
|
13357 |
|
13358 | var _current = nextEffect.alternate;
|
13359 | commitWork(_current, nextEffect);
|
13360 | break;
|
13361 | }
|
13362 |
|
13363 | case Hydrating:
|
13364 | {
|
13365 | nextEffect.effectTag &= ~Hydrating;
|
13366 | break;
|
13367 | }
|
13368 |
|
13369 | case HydratingAndUpdate:
|
13370 | {
|
13371 | nextEffect.effectTag &= ~Hydrating;
|
13372 |
|
13373 | var _current2 = nextEffect.alternate;
|
13374 | commitWork(_current2, nextEffect);
|
13375 | break;
|
13376 | }
|
13377 |
|
13378 | case Update:
|
13379 | {
|
13380 | var _current3 = nextEffect.alternate;
|
13381 | commitWork(_current3, nextEffect);
|
13382 | break;
|
13383 | }
|
13384 |
|
13385 | case Deletion:
|
13386 | {
|
13387 | commitDeletion(root, nextEffect, renderPriorityLevel);
|
13388 | break;
|
13389 | }
|
13390 | }
|
13391 |
|
13392 |
|
13393 | recordEffect();
|
13394 | resetCurrentFiber();
|
13395 | nextEffect = nextEffect.nextEffect;
|
13396 | }
|
13397 | }
|
13398 |
|
13399 | function commitLayoutEffects(root, committedExpirationTime) {
|
13400 |
|
13401 | while (nextEffect !== null) {
|
13402 | setCurrentFiber(nextEffect);
|
13403 | var effectTag = nextEffect.effectTag;
|
13404 |
|
13405 | if (effectTag & (Update | Callback)) {
|
13406 | recordEffect();
|
13407 | var current = nextEffect.alternate;
|
13408 | commitLifeCycles(root, current, nextEffect);
|
13409 | }
|
13410 |
|
13411 | if (effectTag & Ref) {
|
13412 | recordEffect();
|
13413 | commitAttachRef(nextEffect);
|
13414 | }
|
13415 |
|
13416 | resetCurrentFiber();
|
13417 | nextEffect = nextEffect.nextEffect;
|
13418 | }
|
13419 | }
|
13420 |
|
13421 | function flushPassiveEffects() {
|
13422 | if (pendingPassiveEffectsRenderPriority !== NoPriority) {
|
13423 | var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority;
|
13424 | pendingPassiveEffectsRenderPriority = NoPriority;
|
13425 | return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
|
13426 | }
|
13427 | }
|
13428 |
|
13429 | function flushPassiveEffectsImpl() {
|
13430 | if (rootWithPendingPassiveEffects === null) {
|
13431 | return false;
|
13432 | }
|
13433 |
|
13434 | var root = rootWithPendingPassiveEffects;
|
13435 | var expirationTime = pendingPassiveEffectsExpirationTime;
|
13436 | rootWithPendingPassiveEffects = null;
|
13437 | pendingPassiveEffectsExpirationTime = NoWork;
|
13438 |
|
13439 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
13440 | {
|
13441 | throw Error( "Cannot flush passive effects while already rendering." );
|
13442 | }
|
13443 | }
|
13444 |
|
13445 | var prevExecutionContext = executionContext;
|
13446 | executionContext |= CommitContext;
|
13447 | var prevInteractions = pushInteractions(root);
|
13448 |
|
13449 | {
|
13450 |
|
13451 |
|
13452 |
|
13453 | var _effect2 = root.current.firstEffect;
|
13454 |
|
13455 | while (_effect2 !== null) {
|
13456 | {
|
13457 | setCurrentFiber(_effect2);
|
13458 | invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2);
|
13459 |
|
13460 | if (hasCaughtError()) {
|
13461 | if (!(_effect2 !== null)) {
|
13462 | {
|
13463 | throw Error( "Should be working on an effect." );
|
13464 | }
|
13465 | }
|
13466 |
|
13467 | var _error5 = clearCaughtError();
|
13468 |
|
13469 | captureCommitPhaseError(_effect2, _error5);
|
13470 | }
|
13471 |
|
13472 | resetCurrentFiber();
|
13473 | }
|
13474 |
|
13475 | var nextNextEffect = _effect2.nextEffect;
|
13476 |
|
13477 | _effect2.nextEffect = null;
|
13478 | _effect2 = nextNextEffect;
|
13479 | }
|
13480 | }
|
13481 |
|
13482 | {
|
13483 | popInteractions(prevInteractions);
|
13484 | finishPendingInteractions(root, expirationTime);
|
13485 | }
|
13486 |
|
13487 | executionContext = prevExecutionContext;
|
13488 | flushSyncCallbackQueue();
|
13489 |
|
13490 |
|
13491 | nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
|
13492 | return true;
|
13493 | }
|
13494 |
|
13495 | function isAlreadyFailedLegacyErrorBoundary(instance) {
|
13496 | return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
|
13497 | }
|
13498 | function markLegacyErrorBoundaryAsFailed(instance) {
|
13499 | if (legacyErrorBoundariesThatAlreadyFailed === null) {
|
13500 | legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
|
13501 | } else {
|
13502 | legacyErrorBoundariesThatAlreadyFailed.add(instance);
|
13503 | }
|
13504 | }
|
13505 |
|
13506 | function prepareToThrowUncaughtError(error) {
|
13507 | if (!hasUncaughtError) {
|
13508 | hasUncaughtError = true;
|
13509 | firstUncaughtError = error;
|
13510 | }
|
13511 | }
|
13512 |
|
13513 | var onUncaughtError = prepareToThrowUncaughtError;
|
13514 |
|
13515 | function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
|
13516 | var errorInfo = createCapturedValue(error, sourceFiber);
|
13517 | var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
|
13518 | enqueueUpdate(rootFiber, update);
|
13519 | var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
|
13520 |
|
13521 | if (root !== null) {
|
13522 | ensureRootIsScheduled(root);
|
13523 | schedulePendingInteractions(root, Sync);
|
13524 | }
|
13525 | }
|
13526 |
|
13527 | function captureCommitPhaseError(sourceFiber, error) {
|
13528 | if (sourceFiber.tag === HostRoot) {
|
13529 |
|
13530 |
|
13531 | captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
|
13532 | return;
|
13533 | }
|
13534 |
|
13535 | var fiber = sourceFiber.return;
|
13536 |
|
13537 | while (fiber !== null) {
|
13538 | if (fiber.tag === HostRoot) {
|
13539 | captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
|
13540 | return;
|
13541 | } else if (fiber.tag === ClassComponent) {
|
13542 | var ctor = fiber.type;
|
13543 | var instance = fiber.stateNode;
|
13544 |
|
13545 | if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
|
13546 | var errorInfo = createCapturedValue(error, sourceFiber);
|
13547 | var update = createClassErrorUpdate(fiber, errorInfo,
|
13548 | Sync);
|
13549 | enqueueUpdate(fiber, update);
|
13550 | var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
|
13551 |
|
13552 | if (root !== null) {
|
13553 | ensureRootIsScheduled(root);
|
13554 | schedulePendingInteractions(root, Sync);
|
13555 | }
|
13556 |
|
13557 | return;
|
13558 | }
|
13559 | }
|
13560 |
|
13561 | fiber = fiber.return;
|
13562 | }
|
13563 | }
|
13564 | function pingSuspendedRoot(root, thenable, suspendedTime) {
|
13565 | var pingCache = root.pingCache;
|
13566 |
|
13567 | if (pingCache !== null) {
|
13568 |
|
13569 |
|
13570 | pingCache.delete(thenable);
|
13571 | }
|
13572 |
|
13573 | if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) {
|
13574 |
|
13575 |
|
13576 |
|
13577 |
|
13578 |
|
13579 |
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 |
|
13585 | if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
|
13586 |
|
13587 |
|
13588 | prepareFreshStack(root, renderExpirationTime$1);
|
13589 | } else {
|
13590 |
|
13591 |
|
13592 | workInProgressRootHasPendingPing = true;
|
13593 | }
|
13594 |
|
13595 | return;
|
13596 | }
|
13597 |
|
13598 | if (!isRootSuspendedAtTime(root, suspendedTime)) {
|
13599 |
|
13600 | return;
|
13601 | }
|
13602 |
|
13603 | var lastPingedTime = root.lastPingedTime;
|
13604 |
|
13605 | if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
|
13606 |
|
13607 | return;
|
13608 | }
|
13609 |
|
13610 |
|
13611 | root.lastPingedTime = suspendedTime;
|
13612 |
|
13613 | ensureRootIsScheduled(root);
|
13614 | schedulePendingInteractions(root, suspendedTime);
|
13615 | }
|
13616 |
|
13617 | function retryTimedOutBoundary(boundaryFiber, retryTime) {
|
13618 |
|
13619 |
|
13620 |
|
13621 |
|
13622 | if (retryTime === NoWork) {
|
13623 | var suspenseConfig = null;
|
13624 |
|
13625 | var currentTime = requestCurrentTimeForUpdate();
|
13626 | retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
|
13627 | }
|
13628 |
|
13629 |
|
13630 | var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
|
13631 |
|
13632 | if (root !== null) {
|
13633 | ensureRootIsScheduled(root);
|
13634 | schedulePendingInteractions(root, retryTime);
|
13635 | }
|
13636 | }
|
13637 | function resolveRetryThenable(boundaryFiber, thenable) {
|
13638 | var retryTime = NoWork;
|
13639 |
|
13640 | var retryCache;
|
13641 |
|
13642 | {
|
13643 | retryCache = boundaryFiber.stateNode;
|
13644 | }
|
13645 |
|
13646 | if (retryCache !== null) {
|
13647 |
|
13648 |
|
13649 | retryCache.delete(thenable);
|
13650 | }
|
13651 |
|
13652 | retryTimedOutBoundary(boundaryFiber, retryTime);
|
13653 | }
|
13654 |
|
13655 |
|
13656 |
|
13657 |
|
13658 |
|
13659 |
|
13660 |
|
13661 |
|
13662 |
|
13663 | function jnd(timeElapsed) {
|
13664 | return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
|
13665 | }
|
13666 |
|
13667 | function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
|
13668 | var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
|
13669 |
|
13670 | if (busyMinDurationMs <= 0) {
|
13671 | return 0;
|
13672 | }
|
13673 |
|
13674 | var busyDelayMs = suspenseConfig.busyDelayMs | 0;
|
13675 |
|
13676 | var currentTimeMs = now();
|
13677 | var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
|
13678 | var timeElapsed = currentTimeMs - eventTimeMs;
|
13679 |
|
13680 | if (timeElapsed <= busyDelayMs) {
|
13681 |
|
13682 |
|
13683 | return 0;
|
13684 | }
|
13685 |
|
13686 | var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed;
|
13687 |
|
13688 | return msUntilTimeout;
|
13689 | }
|
13690 |
|
13691 | function checkForNestedUpdates() {
|
13692 | if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
|
13693 | nestedUpdateCount = 0;
|
13694 | rootWithNestedUpdates = null;
|
13695 |
|
13696 | {
|
13697 | {
|
13698 | throw 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." );
|
13699 | }
|
13700 | }
|
13701 | }
|
13702 |
|
13703 | {
|
13704 | if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
|
13705 | nestedPassiveUpdateCount = 0;
|
13706 |
|
13707 | error('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.');
|
13708 | }
|
13709 | }
|
13710 | }
|
13711 |
|
13712 | function flushRenderPhaseStrictModeWarningsInDEV() {
|
13713 | {
|
13714 | ReactStrictModeWarnings.flushLegacyContextWarning();
|
13715 |
|
13716 | {
|
13717 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
|
13718 | }
|
13719 | }
|
13720 | }
|
13721 |
|
13722 | function stopFinishedWorkLoopTimer() {
|
13723 | var didCompleteRoot = true;
|
13724 | stopWorkLoopTimer(interruptedBy, didCompleteRoot);
|
13725 | interruptedBy = null;
|
13726 | }
|
13727 |
|
13728 | function stopInterruptedWorkLoopTimer() {
|
13729 |
|
13730 | var didCompleteRoot = false;
|
13731 | stopWorkLoopTimer(interruptedBy, didCompleteRoot);
|
13732 | interruptedBy = null;
|
13733 | }
|
13734 |
|
13735 | function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
|
13736 | if ( workInProgressRoot !== null && updateExpirationTime > renderExpirationTime$1) {
|
13737 | interruptedBy = fiberThatReceivedUpdate;
|
13738 | }
|
13739 | }
|
13740 |
|
13741 | var didWarnStateUpdateForUnmountedComponent = null;
|
13742 |
|
13743 | function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
|
13744 | {
|
13745 | var tag = fiber.tag;
|
13746 |
|
13747 | if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) {
|
13748 |
|
13749 | return;
|
13750 | }
|
13751 |
|
13752 |
|
13753 |
|
13754 | var componentName = getComponentName(fiber.type) || 'ReactComponent';
|
13755 |
|
13756 | if (didWarnStateUpdateForUnmountedComponent !== null) {
|
13757 | if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
|
13758 | return;
|
13759 | }
|
13760 |
|
13761 | didWarnStateUpdateForUnmountedComponent.add(componentName);
|
13762 | } else {
|
13763 | didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
|
13764 | }
|
13765 |
|
13766 | error("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));
|
13767 | }
|
13768 | }
|
13769 |
|
13770 | var beginWork$1;
|
13771 |
|
13772 | {
|
13773 | beginWork$1 = beginWork;
|
13774 | }
|
13775 |
|
13776 | var didWarnAboutUpdateInRender = false;
|
13777 | var didWarnAboutUpdateInRenderForAnotherComponent;
|
13778 |
|
13779 | {
|
13780 | didWarnAboutUpdateInRenderForAnotherComponent = new Set();
|
13781 | }
|
13782 |
|
13783 | function warnAboutRenderPhaseUpdatesInDEV(fiber) {
|
13784 | {
|
13785 | if (isRendering && (executionContext & RenderContext) !== NoContext) {
|
13786 | switch (fiber.tag) {
|
13787 | case FunctionComponent:
|
13788 | case ForwardRef:
|
13789 | case SimpleMemoComponent:
|
13790 | {
|
13791 | var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown';
|
13792 |
|
13793 | var dedupeKey = renderingComponentName;
|
13794 |
|
13795 | if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
|
13796 | didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
|
13797 | var setStateComponentName = getComponentName(fiber.type) || 'Unknown';
|
13798 |
|
13799 | error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://fb.me/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName);
|
13800 | }
|
13801 |
|
13802 | break;
|
13803 | }
|
13804 |
|
13805 | case ClassComponent:
|
13806 | {
|
13807 | if (!didWarnAboutUpdateInRender) {
|
13808 | error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.');
|
13809 |
|
13810 | didWarnAboutUpdateInRender = true;
|
13811 | }
|
13812 |
|
13813 | break;
|
13814 | }
|
13815 | }
|
13816 | }
|
13817 | }
|
13818 | }
|
13819 |
|
13820 |
|
13821 | var IsThisRendererActing = {
|
13822 | current: false
|
13823 | };
|
13824 | function warnIfNotScopedWithMatchingAct(fiber) {
|
13825 | {
|
13826 | if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
|
13827 | error("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));
|
13828 | }
|
13829 | }
|
13830 | }
|
13831 | function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
|
13832 | {
|
13833 | if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
|
13834 | error('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));
|
13835 | }
|
13836 | }
|
13837 | }
|
13838 |
|
13839 | function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
|
13840 | {
|
13841 | if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
|
13842 | error('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));
|
13843 | }
|
13844 | }
|
13845 | }
|
13846 |
|
13847 | var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV;
|
13848 |
|
13849 | var didWarnAboutUnmockedScheduler = false;
|
13850 |
|
13851 |
|
13852 |
|
13853 |
|
13854 | function warnIfUnmockedScheduler(fiber) {
|
13855 | {
|
13856 | if (didWarnAboutUnmockedScheduler === false && Scheduler$1.unstable_flushAllWithoutAsserting === undefined) {
|
13857 | if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
|
13858 | didWarnAboutUnmockedScheduler = true;
|
13859 |
|
13860 | error('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');
|
13861 | }
|
13862 | }
|
13863 | }
|
13864 | }
|
13865 |
|
13866 | function computeThreadID(root, expirationTime) {
|
13867 |
|
13868 | return expirationTime * 1000 + root.interactionThreadID;
|
13869 | }
|
13870 |
|
13871 | function markSpawnedWork(expirationTime) {
|
13872 |
|
13873 | if (spawnedWorkDuringRender === null) {
|
13874 | spawnedWorkDuringRender = [expirationTime];
|
13875 | } else {
|
13876 | spawnedWorkDuringRender.push(expirationTime);
|
13877 | }
|
13878 | }
|
13879 |
|
13880 | function scheduleInteractions(root, expirationTime, interactions) {
|
13881 |
|
13882 | if (interactions.size > 0) {
|
13883 | var pendingInteractionMap = root.pendingInteractionMap;
|
13884 | var pendingInteractions = pendingInteractionMap.get(expirationTime);
|
13885 |
|
13886 | if (pendingInteractions != null) {
|
13887 | interactions.forEach(function (interaction) {
|
13888 | if (!pendingInteractions.has(interaction)) {
|
13889 |
|
13890 | interaction.__count++;
|
13891 | }
|
13892 |
|
13893 | pendingInteractions.add(interaction);
|
13894 | });
|
13895 | } else {
|
13896 | pendingInteractionMap.set(expirationTime, new Set(interactions));
|
13897 |
|
13898 | interactions.forEach(function (interaction) {
|
13899 | interaction.__count++;
|
13900 | });
|
13901 | }
|
13902 |
|
13903 | var subscriber = __subscriberRef.current;
|
13904 |
|
13905 | if (subscriber !== null) {
|
13906 | var threadID = computeThreadID(root, expirationTime);
|
13907 | subscriber.onWorkScheduled(interactions, threadID);
|
13908 | }
|
13909 | }
|
13910 | }
|
13911 |
|
13912 | function schedulePendingInteractions(root, expirationTime) {
|
13913 |
|
13914 | scheduleInteractions(root, expirationTime, __interactionsRef.current);
|
13915 | }
|
13916 |
|
13917 | function startWorkOnPendingInteractions(root, expirationTime) {
|
13918 |
|
13919 |
|
13920 |
|
13921 |
|
13922 | var interactions = new Set();
|
13923 | root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
|
13924 | if (scheduledExpirationTime >= expirationTime) {
|
13925 | scheduledInteractions.forEach(function (interaction) {
|
13926 | return interactions.add(interaction);
|
13927 | });
|
13928 | }
|
13929 | });
|
13930 |
|
13931 |
|
13932 |
|
13933 |
|
13934 |
|
13935 | root.memoizedInteractions = interactions;
|
13936 |
|
13937 | if (interactions.size > 0) {
|
13938 | var subscriber = __subscriberRef.current;
|
13939 |
|
13940 | if (subscriber !== null) {
|
13941 | var threadID = computeThreadID(root, expirationTime);
|
13942 |
|
13943 | try {
|
13944 | subscriber.onWorkStarted(interactions, threadID);
|
13945 | } catch (error) {
|
13946 |
|
13947 | scheduleCallback(ImmediatePriority, function () {
|
13948 | throw error;
|
13949 | });
|
13950 | }
|
13951 | }
|
13952 | }
|
13953 | }
|
13954 |
|
13955 | function finishPendingInteractions(root, committedExpirationTime) {
|
13956 |
|
13957 | var earliestRemainingTimeAfterCommit = root.firstPendingTime;
|
13958 | var subscriber;
|
13959 |
|
13960 | try {
|
13961 | subscriber = __subscriberRef.current;
|
13962 |
|
13963 | if (subscriber !== null && root.memoizedInteractions.size > 0) {
|
13964 | var threadID = computeThreadID(root, committedExpirationTime);
|
13965 | subscriber.onWorkStopped(root.memoizedInteractions, threadID);
|
13966 | }
|
13967 | } catch (error) {
|
13968 |
|
13969 | scheduleCallback(ImmediatePriority, function () {
|
13970 | throw error;
|
13971 | });
|
13972 | } finally {
|
13973 |
|
13974 |
|
13975 |
|
13976 | var pendingInteractionMap = root.pendingInteractionMap;
|
13977 | pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
|
13978 |
|
13979 |
|
13980 |
|
13981 | if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
|
13982 | pendingInteractionMap.delete(scheduledExpirationTime);
|
13983 | scheduledInteractions.forEach(function (interaction) {
|
13984 | interaction.__count--;
|
13985 |
|
13986 | if (subscriber !== null && interaction.__count === 0) {
|
13987 | try {
|
13988 | subscriber.onInteractionScheduledWorkCompleted(interaction);
|
13989 | } catch (error) {
|
13990 |
|
13991 | scheduleCallback(ImmediatePriority, function () {
|
13992 | throw error;
|
13993 | });
|
13994 | }
|
13995 | }
|
13996 | });
|
13997 | }
|
13998 | });
|
13999 | }
|
14000 | }
|
14001 |
|
14002 | var onScheduleFiberRoot = null;
|
14003 | var onCommitFiberRoot = null;
|
14004 | var onCommitFiberUnmount = null;
|
14005 | var hasLoggedError = false;
|
14006 | var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
|
14007 | function injectInternals(internals) {
|
14008 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
|
14009 |
|
14010 | return false;
|
14011 | }
|
14012 |
|
14013 | var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
14014 |
|
14015 | if (hook.isDisabled) {
|
14016 |
|
14017 |
|
14018 |
|
14019 | return true;
|
14020 | }
|
14021 |
|
14022 | if (!hook.supportsFiber) {
|
14023 | {
|
14024 | error('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');
|
14025 | }
|
14026 |
|
14027 |
|
14028 | return true;
|
14029 | }
|
14030 |
|
14031 | try {
|
14032 | var rendererID = hook.inject(internals);
|
14033 |
|
14034 | if (true) {
|
14035 |
|
14036 | if (typeof hook.onScheduleFiberRoot === 'function') {
|
14037 | onScheduleFiberRoot = function (root, children) {
|
14038 | try {
|
14039 | hook.onScheduleFiberRoot(rendererID, root, children);
|
14040 | } catch (err) {
|
14041 | if (true && !hasLoggedError) {
|
14042 | hasLoggedError = true;
|
14043 |
|
14044 | error('React instrumentation encountered an error: %s', err);
|
14045 | }
|
14046 | }
|
14047 | };
|
14048 | }
|
14049 | }
|
14050 |
|
14051 | onCommitFiberRoot = function (root, expirationTime) {
|
14052 | try {
|
14053 | var didError = (root.current.effectTag & DidCapture) === DidCapture;
|
14054 |
|
14055 | if (enableProfilerTimer) {
|
14056 | var currentTime = getCurrentTime();
|
14057 | var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
|
14058 | hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
|
14059 | } else {
|
14060 | hook.onCommitFiberRoot(rendererID, root, undefined, didError);
|
14061 | }
|
14062 | } catch (err) {
|
14063 | if (true) {
|
14064 | if (!hasLoggedError) {
|
14065 | hasLoggedError = true;
|
14066 |
|
14067 | error('React instrumentation encountered an error: %s', err);
|
14068 | }
|
14069 | }
|
14070 | }
|
14071 | };
|
14072 |
|
14073 | onCommitFiberUnmount = function (fiber) {
|
14074 | try {
|
14075 | hook.onCommitFiberUnmount(rendererID, fiber);
|
14076 | } catch (err) {
|
14077 | if (true) {
|
14078 | if (!hasLoggedError) {
|
14079 | hasLoggedError = true;
|
14080 |
|
14081 | error('React instrumentation encountered an error: %s', err);
|
14082 | }
|
14083 | }
|
14084 | }
|
14085 | };
|
14086 | } catch (err) {
|
14087 |
|
14088 | {
|
14089 | error('React instrumentation encountered an error: %s.', err);
|
14090 | }
|
14091 | }
|
14092 |
|
14093 |
|
14094 | return true;
|
14095 | }
|
14096 | function onScheduleRoot(root, children) {
|
14097 | if (typeof onScheduleFiberRoot === 'function') {
|
14098 | onScheduleFiberRoot(root, children);
|
14099 | }
|
14100 | }
|
14101 | function onCommitRoot(root, expirationTime) {
|
14102 | if (typeof onCommitFiberRoot === 'function') {
|
14103 | onCommitFiberRoot(root, expirationTime);
|
14104 | }
|
14105 | }
|
14106 | function onCommitUnmount(fiber) {
|
14107 | if (typeof onCommitFiberUnmount === 'function') {
|
14108 | onCommitFiberUnmount(fiber);
|
14109 | }
|
14110 | }
|
14111 |
|
14112 | var hasBadMapPolyfill;
|
14113 |
|
14114 | {
|
14115 | hasBadMapPolyfill = false;
|
14116 |
|
14117 | try {
|
14118 | var nonExtensibleObject = Object.preventExtensions({});
|
14119 | var testMap = new Map([[nonExtensibleObject, null]]);
|
14120 | var testSet = new Set([nonExtensibleObject]);
|
14121 |
|
14122 |
|
14123 |
|
14124 | testMap.set(0, 0);
|
14125 | testSet.add(0);
|
14126 | } catch (e) {
|
14127 |
|
14128 | hasBadMapPolyfill = true;
|
14129 | }
|
14130 | }
|
14131 |
|
14132 | var debugCounter = 1;
|
14133 |
|
14134 | function FiberNode(tag, pendingProps, key, mode) {
|
14135 |
|
14136 | this.tag = tag;
|
14137 | this.key = key;
|
14138 | this.elementType = null;
|
14139 | this.type = null;
|
14140 | this.stateNode = null;
|
14141 |
|
14142 | this.return = null;
|
14143 | this.child = null;
|
14144 | this.sibling = null;
|
14145 | this.index = 0;
|
14146 | this.ref = null;
|
14147 | this.pendingProps = pendingProps;
|
14148 | this.memoizedProps = null;
|
14149 | this.updateQueue = null;
|
14150 | this.memoizedState = null;
|
14151 | this.dependencies = null;
|
14152 | this.mode = mode;
|
14153 |
|
14154 | this.effectTag = NoEffect;
|
14155 | this.nextEffect = null;
|
14156 | this.firstEffect = null;
|
14157 | this.lastEffect = null;
|
14158 | this.expirationTime = NoWork;
|
14159 | this.childExpirationTime = NoWork;
|
14160 | this.alternate = null;
|
14161 |
|
14162 | {
|
14163 |
|
14164 |
|
14165 |
|
14166 |
|
14167 |
|
14168 |
|
14169 |
|
14170 |
|
14171 |
|
14172 |
|
14173 |
|
14174 |
|
14175 | this.actualDuration = Number.NaN;
|
14176 | this.actualStartTime = Number.NaN;
|
14177 | this.selfBaseDuration = Number.NaN;
|
14178 | this.treeBaseDuration = Number.NaN;
|
14179 |
|
14180 |
|
14181 |
|
14182 | this.actualDuration = 0;
|
14183 | this.actualStartTime = -1;
|
14184 | this.selfBaseDuration = 0;
|
14185 | this.treeBaseDuration = 0;
|
14186 | }
|
14187 |
|
14188 |
|
14189 |
|
14190 | {
|
14191 | this._debugID = debugCounter++;
|
14192 | this._debugIsCurrentlyTiming = false;
|
14193 | }
|
14194 |
|
14195 | {
|
14196 | this._debugSource = null;
|
14197 | this._debugOwner = null;
|
14198 | this._debugNeedsRemount = false;
|
14199 | this._debugHookTypes = null;
|
14200 |
|
14201 | if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
|
14202 | Object.preventExtensions(this);
|
14203 | }
|
14204 | }
|
14205 | }
|
14206 |
|
14207 |
|
14208 |
|
14209 |
|
14210 |
|
14211 |
|
14212 |
|
14213 |
|
14214 |
|
14215 |
|
14216 |
|
14217 |
|
14218 |
|
14219 |
|
14220 | var createFiber = function (tag, pendingProps, key, mode) {
|
14221 |
|
14222 | return new FiberNode(tag, pendingProps, key, mode);
|
14223 | };
|
14224 |
|
14225 | function shouldConstruct(Component) {
|
14226 | var prototype = Component.prototype;
|
14227 | return !!(prototype && prototype.isReactComponent);
|
14228 | }
|
14229 |
|
14230 | function isSimpleFunctionComponent(type) {
|
14231 | return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
|
14232 | }
|
14233 | function resolveLazyComponentTag(Component) {
|
14234 | if (typeof Component === 'function') {
|
14235 | return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
|
14236 | } else if (Component !== undefined && Component !== null) {
|
14237 | var $$typeof = Component.$$typeof;
|
14238 |
|
14239 | if ($$typeof === REACT_FORWARD_REF_TYPE) {
|
14240 | return ForwardRef;
|
14241 | }
|
14242 |
|
14243 | if ($$typeof === REACT_MEMO_TYPE) {
|
14244 | return MemoComponent;
|
14245 | }
|
14246 | }
|
14247 |
|
14248 | return IndeterminateComponent;
|
14249 | }
|
14250 |
|
14251 | function createWorkInProgress(current, pendingProps) {
|
14252 | var workInProgress = current.alternate;
|
14253 |
|
14254 | if (workInProgress === null) {
|
14255 |
|
14256 |
|
14257 |
|
14258 |
|
14259 |
|
14260 | workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
|
14261 | workInProgress.elementType = current.elementType;
|
14262 | workInProgress.type = current.type;
|
14263 | workInProgress.stateNode = current.stateNode;
|
14264 |
|
14265 | {
|
14266 |
|
14267 | {
|
14268 | workInProgress._debugID = current._debugID;
|
14269 | }
|
14270 |
|
14271 | workInProgress._debugSource = current._debugSource;
|
14272 | workInProgress._debugOwner = current._debugOwner;
|
14273 | workInProgress._debugHookTypes = current._debugHookTypes;
|
14274 | }
|
14275 |
|
14276 | workInProgress.alternate = current;
|
14277 | current.alternate = workInProgress;
|
14278 | } else {
|
14279 | workInProgress.pendingProps = pendingProps;
|
14280 |
|
14281 |
|
14282 | workInProgress.effectTag = NoEffect;
|
14283 |
|
14284 | workInProgress.nextEffect = null;
|
14285 | workInProgress.firstEffect = null;
|
14286 | workInProgress.lastEffect = null;
|
14287 |
|
14288 | {
|
14289 |
|
14290 |
|
14291 |
|
14292 |
|
14293 | workInProgress.actualDuration = 0;
|
14294 | workInProgress.actualStartTime = -1;
|
14295 | }
|
14296 | }
|
14297 |
|
14298 | workInProgress.childExpirationTime = current.childExpirationTime;
|
14299 | workInProgress.expirationTime = current.expirationTime;
|
14300 | workInProgress.child = current.child;
|
14301 | workInProgress.memoizedProps = current.memoizedProps;
|
14302 | workInProgress.memoizedState = current.memoizedState;
|
14303 | workInProgress.updateQueue = current.updateQueue;
|
14304 |
|
14305 |
|
14306 | var currentDependencies = current.dependencies;
|
14307 | workInProgress.dependencies = currentDependencies === null ? null : {
|
14308 | expirationTime: currentDependencies.expirationTime,
|
14309 | firstContext: currentDependencies.firstContext,
|
14310 | responders: currentDependencies.responders
|
14311 | };
|
14312 |
|
14313 | workInProgress.sibling = current.sibling;
|
14314 | workInProgress.index = current.index;
|
14315 | workInProgress.ref = current.ref;
|
14316 |
|
14317 | {
|
14318 | workInProgress.selfBaseDuration = current.selfBaseDuration;
|
14319 | workInProgress.treeBaseDuration = current.treeBaseDuration;
|
14320 | }
|
14321 |
|
14322 | {
|
14323 | workInProgress._debugNeedsRemount = current._debugNeedsRemount;
|
14324 |
|
14325 | switch (workInProgress.tag) {
|
14326 | case IndeterminateComponent:
|
14327 | case FunctionComponent:
|
14328 | case SimpleMemoComponent:
|
14329 | workInProgress.type = resolveFunctionForHotReloading(current.type);
|
14330 | break;
|
14331 |
|
14332 | case ClassComponent:
|
14333 | workInProgress.type = resolveClassForHotReloading(current.type);
|
14334 | break;
|
14335 |
|
14336 | case ForwardRef:
|
14337 | workInProgress.type = resolveForwardRefForHotReloading(current.type);
|
14338 | break;
|
14339 | }
|
14340 | }
|
14341 |
|
14342 | return workInProgress;
|
14343 | }
|
14344 |
|
14345 | function resetWorkInProgress(workInProgress, renderExpirationTime) {
|
14346 |
|
14347 |
|
14348 |
|
14349 |
|
14350 |
|
14351 |
|
14352 |
|
14353 |
|
14354 | workInProgress.effectTag &= Placement;
|
14355 |
|
14356 | workInProgress.nextEffect = null;
|
14357 | workInProgress.firstEffect = null;
|
14358 | workInProgress.lastEffect = null;
|
14359 | var current = workInProgress.alternate;
|
14360 |
|
14361 | if (current === null) {
|
14362 |
|
14363 | workInProgress.childExpirationTime = NoWork;
|
14364 | workInProgress.expirationTime = renderExpirationTime;
|
14365 | workInProgress.child = null;
|
14366 | workInProgress.memoizedProps = null;
|
14367 | workInProgress.memoizedState = null;
|
14368 | workInProgress.updateQueue = null;
|
14369 | workInProgress.dependencies = null;
|
14370 |
|
14371 | {
|
14372 |
|
14373 |
|
14374 | workInProgress.selfBaseDuration = 0;
|
14375 | workInProgress.treeBaseDuration = 0;
|
14376 | }
|
14377 | } else {
|
14378 |
|
14379 | workInProgress.childExpirationTime = current.childExpirationTime;
|
14380 | workInProgress.expirationTime = current.expirationTime;
|
14381 | workInProgress.child = current.child;
|
14382 | workInProgress.memoizedProps = current.memoizedProps;
|
14383 | workInProgress.memoizedState = current.memoizedState;
|
14384 | workInProgress.updateQueue = current.updateQueue;
|
14385 |
|
14386 |
|
14387 | var currentDependencies = current.dependencies;
|
14388 | workInProgress.dependencies = currentDependencies === null ? null : {
|
14389 | expirationTime: currentDependencies.expirationTime,
|
14390 | firstContext: currentDependencies.firstContext,
|
14391 | responders: currentDependencies.responders
|
14392 | };
|
14393 |
|
14394 | {
|
14395 |
|
14396 |
|
14397 | workInProgress.selfBaseDuration = current.selfBaseDuration;
|
14398 | workInProgress.treeBaseDuration = current.treeBaseDuration;
|
14399 | }
|
14400 | }
|
14401 |
|
14402 | return workInProgress;
|
14403 | }
|
14404 | function createHostRootFiber(tag) {
|
14405 | var mode;
|
14406 |
|
14407 | if (tag === ConcurrentRoot) {
|
14408 | mode = ConcurrentMode | BlockingMode | StrictMode;
|
14409 | } else if (tag === BlockingRoot) {
|
14410 | mode = BlockingMode | StrictMode;
|
14411 | } else {
|
14412 | mode = NoMode;
|
14413 | }
|
14414 |
|
14415 | if ( isDevToolsPresent) {
|
14416 |
|
14417 |
|
14418 |
|
14419 | mode |= ProfileMode;
|
14420 | }
|
14421 |
|
14422 | return createFiber(HostRoot, null, null, mode);
|
14423 | }
|
14424 | function createFiberFromTypeAndProps(type, // React$ElementType
|
14425 | key, pendingProps, owner, mode, expirationTime) {
|
14426 | var fiber;
|
14427 | var fiberTag = IndeterminateComponent;
|
14428 |
|
14429 | var resolvedType = type;
|
14430 |
|
14431 | if (typeof type === 'function') {
|
14432 | if (shouldConstruct(type)) {
|
14433 | fiberTag = ClassComponent;
|
14434 |
|
14435 | {
|
14436 | resolvedType = resolveClassForHotReloading(resolvedType);
|
14437 | }
|
14438 | } else {
|
14439 | {
|
14440 | resolvedType = resolveFunctionForHotReloading(resolvedType);
|
14441 | }
|
14442 | }
|
14443 | } else if (typeof type === 'string') {
|
14444 | fiberTag = HostComponent;
|
14445 | } else {
|
14446 | getTag: switch (type) {
|
14447 | case REACT_FRAGMENT_TYPE:
|
14448 | return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
|
14449 |
|
14450 | case REACT_CONCURRENT_MODE_TYPE:
|
14451 | fiberTag = Mode;
|
14452 | mode |= ConcurrentMode | BlockingMode | StrictMode;
|
14453 | break;
|
14454 |
|
14455 | case REACT_STRICT_MODE_TYPE:
|
14456 | fiberTag = Mode;
|
14457 | mode |= StrictMode;
|
14458 | break;
|
14459 |
|
14460 | case REACT_PROFILER_TYPE:
|
14461 | return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
|
14462 |
|
14463 | case REACT_SUSPENSE_TYPE:
|
14464 | return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
|
14465 |
|
14466 | case REACT_SUSPENSE_LIST_TYPE:
|
14467 | return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
|
14468 |
|
14469 | default:
|
14470 | {
|
14471 | if (typeof type === 'object' && type !== null) {
|
14472 | switch (type.$$typeof) {
|
14473 | case REACT_PROVIDER_TYPE:
|
14474 | fiberTag = ContextProvider;
|
14475 | break getTag;
|
14476 |
|
14477 | case REACT_CONTEXT_TYPE:
|
14478 |
|
14479 | fiberTag = ContextConsumer;
|
14480 | break getTag;
|
14481 |
|
14482 | case REACT_FORWARD_REF_TYPE:
|
14483 | fiberTag = ForwardRef;
|
14484 |
|
14485 | {
|
14486 | resolvedType = resolveForwardRefForHotReloading(resolvedType);
|
14487 | }
|
14488 |
|
14489 | break getTag;
|
14490 |
|
14491 | case REACT_MEMO_TYPE:
|
14492 | fiberTag = MemoComponent;
|
14493 | break getTag;
|
14494 |
|
14495 | case REACT_LAZY_TYPE:
|
14496 | fiberTag = LazyComponent;
|
14497 | resolvedType = null;
|
14498 | break getTag;
|
14499 |
|
14500 | case REACT_BLOCK_TYPE:
|
14501 | fiberTag = Block;
|
14502 | break getTag;
|
14503 |
|
14504 | }
|
14505 | }
|
14506 |
|
14507 | var info = '';
|
14508 |
|
14509 | {
|
14510 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
14511 | 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.';
|
14512 | }
|
14513 |
|
14514 | var ownerName = owner ? getComponentName(owner.type) : null;
|
14515 |
|
14516 | if (ownerName) {
|
14517 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
14518 | }
|
14519 | }
|
14520 |
|
14521 | {
|
14522 | {
|
14523 | throw 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 );
|
14524 | }
|
14525 | }
|
14526 | }
|
14527 | }
|
14528 | }
|
14529 |
|
14530 | fiber = createFiber(fiberTag, pendingProps, key, mode);
|
14531 | fiber.elementType = type;
|
14532 | fiber.type = resolvedType;
|
14533 | fiber.expirationTime = expirationTime;
|
14534 | return fiber;
|
14535 | }
|
14536 | function createFiberFromElement(element, mode, expirationTime) {
|
14537 | var owner = null;
|
14538 |
|
14539 | {
|
14540 | owner = element._owner;
|
14541 | }
|
14542 |
|
14543 | var type = element.type;
|
14544 | var key = element.key;
|
14545 | var pendingProps = element.props;
|
14546 | var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
|
14547 |
|
14548 | {
|
14549 | fiber._debugSource = element._source;
|
14550 | fiber._debugOwner = element._owner;
|
14551 | }
|
14552 |
|
14553 | return fiber;
|
14554 | }
|
14555 | function createFiberFromFragment(elements, mode, expirationTime, key) {
|
14556 | var fiber = createFiber(Fragment, elements, key, mode);
|
14557 | fiber.expirationTime = expirationTime;
|
14558 | return fiber;
|
14559 | }
|
14560 |
|
14561 | function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
|
14562 | {
|
14563 | if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
|
14564 | error('Profiler must specify an "id" string and "onRender" function as props');
|
14565 | }
|
14566 | }
|
14567 |
|
14568 | var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
14569 |
|
14570 | fiber.elementType = REACT_PROFILER_TYPE;
|
14571 | fiber.type = REACT_PROFILER_TYPE;
|
14572 | fiber.expirationTime = expirationTime;
|
14573 | return fiber;
|
14574 | }
|
14575 |
|
14576 | function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
|
14577 | var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
|
14578 |
|
14579 |
|
14580 |
|
14581 | fiber.type = REACT_SUSPENSE_TYPE;
|
14582 | fiber.elementType = REACT_SUSPENSE_TYPE;
|
14583 | fiber.expirationTime = expirationTime;
|
14584 | return fiber;
|
14585 | }
|
14586 | function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
|
14587 | var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
|
14588 |
|
14589 | {
|
14590 |
|
14591 |
|
14592 |
|
14593 | fiber.type = REACT_SUSPENSE_LIST_TYPE;
|
14594 | }
|
14595 |
|
14596 | fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
|
14597 | fiber.expirationTime = expirationTime;
|
14598 | return fiber;
|
14599 | }
|
14600 | function createFiberFromText(content, mode, expirationTime) {
|
14601 | var fiber = createFiber(HostText, content, null, mode);
|
14602 | fiber.expirationTime = expirationTime;
|
14603 | return fiber;
|
14604 | }
|
14605 | function createFiberFromPortal(portal, mode, expirationTime) {
|
14606 | var pendingProps = portal.children !== null ? portal.children : [];
|
14607 | var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
|
14608 | fiber.expirationTime = expirationTime;
|
14609 | fiber.stateNode = {
|
14610 | containerInfo: portal.containerInfo,
|
14611 | pendingChildren: null,
|
14612 |
|
14613 | implementation: portal.implementation
|
14614 | };
|
14615 | return fiber;
|
14616 | }
|
14617 |
|
14618 | function FiberRootNode(containerInfo, tag, hydrate) {
|
14619 | this.tag = tag;
|
14620 | this.current = null;
|
14621 | this.containerInfo = containerInfo;
|
14622 | this.pendingChildren = null;
|
14623 | this.pingCache = null;
|
14624 | this.finishedExpirationTime = NoWork;
|
14625 | this.finishedWork = null;
|
14626 | this.timeoutHandle = noTimeout;
|
14627 | this.context = null;
|
14628 | this.pendingContext = null;
|
14629 | this.hydrate = hydrate;
|
14630 | this.callbackNode = null;
|
14631 | this.callbackPriority = NoPriority;
|
14632 | this.firstPendingTime = NoWork;
|
14633 | this.firstSuspendedTime = NoWork;
|
14634 | this.lastSuspendedTime = NoWork;
|
14635 | this.nextKnownPendingLevel = NoWork;
|
14636 | this.lastPingedTime = NoWork;
|
14637 | this.lastExpiredTime = NoWork;
|
14638 |
|
14639 | {
|
14640 | this.interactionThreadID = unstable_getThreadID();
|
14641 | this.memoizedInteractions = new Set();
|
14642 | this.pendingInteractionMap = new Map();
|
14643 | }
|
14644 | }
|
14645 |
|
14646 | function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
|
14647 | var root = new FiberRootNode(containerInfo, tag, hydrate);
|
14648 |
|
14649 |
|
14650 |
|
14651 | var uninitializedFiber = createHostRootFiber(tag);
|
14652 | root.current = uninitializedFiber;
|
14653 | uninitializedFiber.stateNode = root;
|
14654 | initializeUpdateQueue(uninitializedFiber);
|
14655 | return root;
|
14656 | }
|
14657 | function isRootSuspendedAtTime(root, expirationTime) {
|
14658 | var firstSuspendedTime = root.firstSuspendedTime;
|
14659 | var lastSuspendedTime = root.lastSuspendedTime;
|
14660 | return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime;
|
14661 | }
|
14662 | function markRootSuspendedAtTime(root, expirationTime) {
|
14663 | var firstSuspendedTime = root.firstSuspendedTime;
|
14664 | var lastSuspendedTime = root.lastSuspendedTime;
|
14665 |
|
14666 | if (firstSuspendedTime < expirationTime) {
|
14667 | root.firstSuspendedTime = expirationTime;
|
14668 | }
|
14669 |
|
14670 | if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
|
14671 | root.lastSuspendedTime = expirationTime;
|
14672 | }
|
14673 |
|
14674 | if (expirationTime <= root.lastPingedTime) {
|
14675 | root.lastPingedTime = NoWork;
|
14676 | }
|
14677 |
|
14678 | if (expirationTime <= root.lastExpiredTime) {
|
14679 | root.lastExpiredTime = NoWork;
|
14680 | }
|
14681 | }
|
14682 | function markRootUpdatedAtTime(root, expirationTime) {
|
14683 |
|
14684 | var firstPendingTime = root.firstPendingTime;
|
14685 |
|
14686 | if (expirationTime > firstPendingTime) {
|
14687 | root.firstPendingTime = expirationTime;
|
14688 | }
|
14689 |
|
14690 |
|
14691 |
|
14692 | var firstSuspendedTime = root.firstSuspendedTime;
|
14693 |
|
14694 | if (firstSuspendedTime !== NoWork) {
|
14695 | if (expirationTime >= firstSuspendedTime) {
|
14696 |
|
14697 | root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
|
14698 | } else if (expirationTime >= root.lastSuspendedTime) {
|
14699 | root.lastSuspendedTime = expirationTime + 1;
|
14700 | }
|
14701 |
|
14702 |
|
14703 |
|
14704 | if (expirationTime > root.nextKnownPendingLevel) {
|
14705 | root.nextKnownPendingLevel = expirationTime;
|
14706 | }
|
14707 | }
|
14708 | }
|
14709 | function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) {
|
14710 |
|
14711 | root.firstPendingTime = remainingExpirationTime;
|
14712 |
|
14713 |
|
14714 | if (finishedExpirationTime <= root.lastSuspendedTime) {
|
14715 |
|
14716 | root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
|
14717 | } else if (finishedExpirationTime <= root.firstSuspendedTime) {
|
14718 |
|
14719 |
|
14720 |
|
14721 | root.firstSuspendedTime = finishedExpirationTime - 1;
|
14722 | }
|
14723 |
|
14724 | if (finishedExpirationTime <= root.lastPingedTime) {
|
14725 |
|
14726 | root.lastPingedTime = NoWork;
|
14727 | }
|
14728 |
|
14729 | if (finishedExpirationTime <= root.lastExpiredTime) {
|
14730 |
|
14731 | root.lastExpiredTime = NoWork;
|
14732 | }
|
14733 | }
|
14734 | function markRootExpiredAtTime(root, expirationTime) {
|
14735 | var lastExpiredTime = root.lastExpiredTime;
|
14736 |
|
14737 | if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
|
14738 | root.lastExpiredTime = expirationTime;
|
14739 | }
|
14740 | }
|
14741 |
|
14742 | var didWarnAboutMessageChannel = false;
|
14743 | var enqueueTaskImpl = null;
|
14744 | function enqueueTask(task) {
|
14745 | if (enqueueTaskImpl === null) {
|
14746 | try {
|
14747 |
|
14748 |
|
14749 | var requireString = ('require' + Math.random()).slice(0, 7);
|
14750 | var nodeRequire = module && module[requireString];
|
14751 |
|
14752 |
|
14753 | enqueueTaskImpl = nodeRequire('timers').setImmediate;
|
14754 | } catch (_err) {
|
14755 |
|
14756 |
|
14757 |
|
14758 | enqueueTaskImpl = function (callback) {
|
14759 | {
|
14760 | if (didWarnAboutMessageChannel === false) {
|
14761 | didWarnAboutMessageChannel = true;
|
14762 |
|
14763 | if (typeof MessageChannel === 'undefined') {
|
14764 | error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
|
14765 | }
|
14766 | }
|
14767 | }
|
14768 |
|
14769 | var channel = new MessageChannel();
|
14770 | channel.port1.onmessage = callback;
|
14771 | channel.port2.postMessage(undefined);
|
14772 | };
|
14773 | }
|
14774 | }
|
14775 |
|
14776 | return enqueueTaskImpl(task);
|
14777 | }
|
14778 |
|
14779 | var didWarnAboutNestedUpdates;
|
14780 |
|
14781 | {
|
14782 | didWarnAboutNestedUpdates = false;
|
14783 | }
|
14784 |
|
14785 | function getContextForSubtree(parentComponent) {
|
14786 | if (!parentComponent) {
|
14787 | return emptyContextObject;
|
14788 | }
|
14789 |
|
14790 | var fiber = get(parentComponent);
|
14791 | var parentContext = findCurrentUnmaskedContext(fiber);
|
14792 |
|
14793 | if (fiber.tag === ClassComponent) {
|
14794 | var Component = fiber.type;
|
14795 |
|
14796 | if (isContextProvider(Component)) {
|
14797 | return processChildContext(fiber, Component, parentContext);
|
14798 | }
|
14799 | }
|
14800 |
|
14801 | return parentContext;
|
14802 | }
|
14803 |
|
14804 | function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
|
14805 | return createFiberRoot(containerInfo, tag, hydrate);
|
14806 | }
|
14807 | function updateContainer(element, container, parentComponent, callback) {
|
14808 | {
|
14809 | onScheduleRoot(container, element);
|
14810 | }
|
14811 |
|
14812 | var current$1 = container.current;
|
14813 | var currentTime = requestCurrentTimeForUpdate();
|
14814 |
|
14815 | {
|
14816 |
|
14817 | if ('undefined' !== typeof jest) {
|
14818 | warnIfUnmockedScheduler(current$1);
|
14819 | warnIfNotScopedWithMatchingAct(current$1);
|
14820 | }
|
14821 | }
|
14822 |
|
14823 | var suspenseConfig = requestCurrentSuspenseConfig();
|
14824 | var expirationTime = computeExpirationForFiber(currentTime, current$1, suspenseConfig);
|
14825 | var context = getContextForSubtree(parentComponent);
|
14826 |
|
14827 | if (container.context === null) {
|
14828 | container.context = context;
|
14829 | } else {
|
14830 | container.pendingContext = context;
|
14831 | }
|
14832 |
|
14833 | {
|
14834 | if (isRendering && current !== null && !didWarnAboutNestedUpdates) {
|
14835 | didWarnAboutNestedUpdates = true;
|
14836 |
|
14837 | error('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');
|
14838 | }
|
14839 | }
|
14840 |
|
14841 | var update = createUpdate(expirationTime, suspenseConfig);
|
14842 |
|
14843 |
|
14844 | update.payload = {
|
14845 | element: element
|
14846 | };
|
14847 | callback = callback === undefined ? null : callback;
|
14848 |
|
14849 | if (callback !== null) {
|
14850 | {
|
14851 | if (typeof callback !== 'function') {
|
14852 | error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
|
14853 | }
|
14854 | }
|
14855 |
|
14856 | update.callback = callback;
|
14857 | }
|
14858 |
|
14859 | enqueueUpdate(current$1, update);
|
14860 | scheduleWork(current$1, expirationTime);
|
14861 | return expirationTime;
|
14862 | }
|
14863 | function getPublicRootInstance(container) {
|
14864 | var containerFiber = container.current;
|
14865 |
|
14866 | if (!containerFiber.child) {
|
14867 | return null;
|
14868 | }
|
14869 |
|
14870 | switch (containerFiber.child.tag) {
|
14871 | case HostComponent:
|
14872 | return getPublicInstance(containerFiber.child.stateNode);
|
14873 |
|
14874 | default:
|
14875 | return containerFiber.child.stateNode;
|
14876 | }
|
14877 | }
|
14878 |
|
14879 | var shouldSuspendImpl = function (fiber) {
|
14880 | return false;
|
14881 | };
|
14882 |
|
14883 | function shouldSuspend(fiber) {
|
14884 | return shouldSuspendImpl(fiber);
|
14885 | }
|
14886 | var overrideHookState = null;
|
14887 | var overrideProps = null;
|
14888 | var scheduleUpdate = null;
|
14889 | var setSuspenseHandler = null;
|
14890 |
|
14891 | {
|
14892 | var copyWithSetImpl = function (obj, path, idx, value) {
|
14893 | if (idx >= path.length) {
|
14894 | return value;
|
14895 | }
|
14896 |
|
14897 | var key = path[idx];
|
14898 | var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
|
14899 |
|
14900 | updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
|
14901 | return updated;
|
14902 | };
|
14903 |
|
14904 | var copyWithSet = function (obj, path, value) {
|
14905 | return copyWithSetImpl(obj, path, 0, value);
|
14906 | };
|
14907 |
|
14908 |
|
14909 | overrideHookState = function (fiber, id, path, value) {
|
14910 |
|
14911 |
|
14912 | var currentHook = fiber.memoizedState;
|
14913 |
|
14914 | while (currentHook !== null && id > 0) {
|
14915 | currentHook = currentHook.next;
|
14916 | id--;
|
14917 | }
|
14918 |
|
14919 | if (currentHook !== null) {
|
14920 | var newState = copyWithSet(currentHook.memoizedState, path, value);
|
14921 | currentHook.memoizedState = newState;
|
14922 | currentHook.baseState = newState;
|
14923 |
|
14924 |
|
14925 |
|
14926 |
|
14927 |
|
14928 | fiber.memoizedProps = _assign({}, fiber.memoizedProps);
|
14929 | scheduleWork(fiber, Sync);
|
14930 | }
|
14931 | };
|
14932 |
|
14933 |
|
14934 | overrideProps = function (fiber, path, value) {
|
14935 | fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
|
14936 |
|
14937 | if (fiber.alternate) {
|
14938 | fiber.alternate.pendingProps = fiber.pendingProps;
|
14939 | }
|
14940 |
|
14941 | scheduleWork(fiber, Sync);
|
14942 | };
|
14943 |
|
14944 | scheduleUpdate = function (fiber) {
|
14945 | scheduleWork(fiber, Sync);
|
14946 | };
|
14947 |
|
14948 | setSuspenseHandler = function (newShouldSuspendImpl) {
|
14949 | shouldSuspendImpl = newShouldSuspendImpl;
|
14950 | };
|
14951 | }
|
14952 |
|
14953 | function injectIntoDevTools(devToolsConfig) {
|
14954 | var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
|
14955 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
14956 | return injectInternals(_assign({}, devToolsConfig, {
|
14957 | overrideHookState: overrideHookState,
|
14958 | overrideProps: overrideProps,
|
14959 | setSuspenseHandler: setSuspenseHandler,
|
14960 | scheduleUpdate: scheduleUpdate,
|
14961 | currentDispatcherRef: ReactCurrentDispatcher,
|
14962 | findHostInstanceByFiber: function (fiber) {
|
14963 | var hostFiber = findCurrentHostFiber(fiber);
|
14964 |
|
14965 | if (hostFiber === null) {
|
14966 | return null;
|
14967 | }
|
14968 |
|
14969 | return hostFiber.stateNode;
|
14970 | },
|
14971 | findFiberByHostInstance: function (instance) {
|
14972 | if (!findFiberByHostInstance) {
|
14973 |
|
14974 | return null;
|
14975 | }
|
14976 |
|
14977 | return findFiberByHostInstance(instance);
|
14978 | },
|
14979 |
|
14980 | findHostInstancesForRefresh: findHostInstancesForRefresh ,
|
14981 | scheduleRefresh: scheduleRefresh ,
|
14982 | scheduleRoot: scheduleRoot ,
|
14983 | setRefreshHandler: setRefreshHandler ,
|
14984 |
|
14985 | getCurrentFiber: function () {
|
14986 | return current;
|
14987 | }
|
14988 | }));
|
14989 | }
|
14990 | var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing;
|
14991 | var isSchedulerMocked = typeof Scheduler$1.unstable_flushAllWithoutAsserting === 'function';
|
14992 |
|
14993 | var flushWork = Scheduler$1.unstable_flushAllWithoutAsserting || function () {
|
14994 | var didFlushWork = false;
|
14995 |
|
14996 | while (flushPassiveEffects()) {
|
14997 | didFlushWork = true;
|
14998 | }
|
14999 |
|
15000 | return didFlushWork;
|
15001 | };
|
15002 |
|
15003 | function flushWorkAndMicroTasks(onDone) {
|
15004 | try {
|
15005 | flushWork();
|
15006 | enqueueTask(function () {
|
15007 | if (flushWork()) {
|
15008 | flushWorkAndMicroTasks(onDone);
|
15009 | } else {
|
15010 | onDone();
|
15011 | }
|
15012 | });
|
15013 | } catch (err) {
|
15014 | onDone(err);
|
15015 | }
|
15016 | }
|
15017 |
|
15018 |
|
15019 |
|
15020 | var actingUpdatesScopeDepth = 0;
|
15021 |
|
15022 | function act(callback) {
|
15023 |
|
15024 | var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
|
15025 | var previousIsSomeRendererActing;
|
15026 | var previousIsThisRendererActing;
|
15027 | actingUpdatesScopeDepth++;
|
15028 | previousIsSomeRendererActing = IsSomeRendererActing$1.current;
|
15029 | previousIsThisRendererActing = IsThisRendererActing.current;
|
15030 | IsSomeRendererActing$1.current = true;
|
15031 | IsThisRendererActing.current = true;
|
15032 |
|
15033 | function onDone() {
|
15034 | actingUpdatesScopeDepth--;
|
15035 | IsSomeRendererActing$1.current = previousIsSomeRendererActing;
|
15036 | IsThisRendererActing.current = previousIsThisRendererActing;
|
15037 |
|
15038 | {
|
15039 | if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
|
15040 |
|
15041 | error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
|
15042 | }
|
15043 | }
|
15044 | }
|
15045 |
|
15046 | var result;
|
15047 |
|
15048 | try {
|
15049 | result = batchedUpdates(callback);
|
15050 | } catch (error) {
|
15051 |
|
15052 | onDone();
|
15053 | throw error;
|
15054 | }
|
15055 |
|
15056 | if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
|
15057 |
|
15058 |
|
15059 | var called = false;
|
15060 |
|
15061 | {
|
15062 | if (typeof Promise !== 'undefined') {
|
15063 |
|
15064 | Promise.resolve().then(function () {}).then(function () {
|
15065 | if (called === false) {
|
15066 | error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, interleaving multiple act ' + 'calls and mixing their scopes. You should - await act(async () => ...);');
|
15067 | }
|
15068 | });
|
15069 | }
|
15070 | }
|
15071 |
|
15072 |
|
15073 |
|
15074 |
|
15075 | return {
|
15076 | then: function (resolve, reject) {
|
15077 | called = true;
|
15078 | result.then(function () {
|
15079 | if (actingUpdatesScopeDepth > 1 || isSchedulerMocked === true && previousIsSomeRendererActing === true) {
|
15080 | onDone();
|
15081 | resolve();
|
15082 | return;
|
15083 | }
|
15084 |
|
15085 |
|
15086 |
|
15087 | flushWorkAndMicroTasks(function (err) {
|
15088 | onDone();
|
15089 |
|
15090 | if (err) {
|
15091 | reject(err);
|
15092 | } else {
|
15093 | resolve();
|
15094 | }
|
15095 | });
|
15096 | }, function (err) {
|
15097 | onDone();
|
15098 | reject(err);
|
15099 | });
|
15100 | }
|
15101 | };
|
15102 | } else {
|
15103 | {
|
15104 | if (result !== undefined) {
|
15105 | error('The callback passed to act(...) function ' + 'must return undefined, or a Promise. You returned %s', result);
|
15106 | }
|
15107 | }
|
15108 |
|
15109 |
|
15110 | try {
|
15111 | if (actingUpdatesScopeDepth === 1 && (isSchedulerMocked === false || previousIsSomeRendererActing === false)) {
|
15112 |
|
15113 |
|
15114 | flushWork();
|
15115 | }
|
15116 |
|
15117 | onDone();
|
15118 | } catch (err) {
|
15119 | onDone();
|
15120 | throw err;
|
15121 | }
|
15122 |
|
15123 |
|
15124 | return {
|
15125 | then: function (resolve) {
|
15126 | {
|
15127 | error('Do not await the result of calling act(...) with sync logic, it is not a Promise.');
|
15128 | }
|
15129 |
|
15130 | resolve();
|
15131 | }
|
15132 | };
|
15133 | }
|
15134 | }
|
15135 |
|
15136 | var ReactVersion = '16.13.1';
|
15137 |
|
15138 | var defaultTestOptions = {
|
15139 | createNodeMock: function () {
|
15140 | return null;
|
15141 | }
|
15142 | };
|
15143 |
|
15144 | function toJSON(inst) {
|
15145 | if (inst.isHidden) {
|
15146 |
|
15147 |
|
15148 |
|
15149 | return null;
|
15150 | }
|
15151 |
|
15152 | switch (inst.tag) {
|
15153 | case 'TEXT':
|
15154 | return inst.text;
|
15155 |
|
15156 | case 'INSTANCE':
|
15157 | {
|
15158 |
|
15159 |
|
15160 |
|
15161 | var _inst$props = inst.props,
|
15162 | children = _inst$props.children,
|
15163 | props = _objectWithoutPropertiesLoose(_inst$props, ["children"]);
|
15164 |
|
15165 |
|
15166 |
|
15167 | var renderedChildren = null;
|
15168 |
|
15169 | if (inst.children && inst.children.length) {
|
15170 | for (var i = 0; i < inst.children.length; i++) {
|
15171 | var renderedChild = toJSON(inst.children[i]);
|
15172 |
|
15173 | if (renderedChild !== null) {
|
15174 | if (renderedChildren === null) {
|
15175 | renderedChildren = [renderedChild];
|
15176 | } else {
|
15177 | renderedChildren.push(renderedChild);
|
15178 | }
|
15179 | }
|
15180 | }
|
15181 | }
|
15182 |
|
15183 | var json = {
|
15184 | type: inst.type,
|
15185 | props: props,
|
15186 | children: renderedChildren
|
15187 | };
|
15188 | Object.defineProperty(json, '$$typeof', {
|
15189 | value: Symbol.for('react.test.json')
|
15190 | });
|
15191 | return json;
|
15192 | }
|
15193 |
|
15194 | default:
|
15195 | throw new Error("Unexpected node type in toJSON: " + inst.tag);
|
15196 | }
|
15197 | }
|
15198 |
|
15199 | function childrenToTree(node) {
|
15200 | if (!node) {
|
15201 | return null;
|
15202 | }
|
15203 |
|
15204 | var children = nodeAndSiblingsArray(node);
|
15205 |
|
15206 | if (children.length === 0) {
|
15207 | return null;
|
15208 | } else if (children.length === 1) {
|
15209 | return toTree(children[0]);
|
15210 | }
|
15211 |
|
15212 | return flatten(children.map(toTree));
|
15213 | }
|
15214 |
|
15215 | function nodeAndSiblingsArray(nodeWithSibling) {
|
15216 | var array = [];
|
15217 | var node = nodeWithSibling;
|
15218 |
|
15219 | while (node != null) {
|
15220 | array.push(node);
|
15221 | node = node.sibling;
|
15222 | }
|
15223 |
|
15224 | return array;
|
15225 | }
|
15226 |
|
15227 | function flatten(arr) {
|
15228 | var result = [];
|
15229 | var stack = [{
|
15230 | i: 0,
|
15231 | array: arr
|
15232 | }];
|
15233 |
|
15234 | while (stack.length) {
|
15235 | var n = stack.pop();
|
15236 |
|
15237 | while (n.i < n.array.length) {
|
15238 | var el = n.array[n.i];
|
15239 | n.i += 1;
|
15240 |
|
15241 | if (Array.isArray(el)) {
|
15242 | stack.push(n);
|
15243 | stack.push({
|
15244 | i: 0,
|
15245 | array: el
|
15246 | });
|
15247 | break;
|
15248 | }
|
15249 |
|
15250 | result.push(el);
|
15251 | }
|
15252 | }
|
15253 |
|
15254 | return result;
|
15255 | }
|
15256 |
|
15257 | function toTree(node) {
|
15258 | if (node == null) {
|
15259 | return null;
|
15260 | }
|
15261 |
|
15262 | switch (node.tag) {
|
15263 | case HostRoot:
|
15264 | return childrenToTree(node.child);
|
15265 |
|
15266 | case HostPortal:
|
15267 | return childrenToTree(node.child);
|
15268 |
|
15269 | case ClassComponent:
|
15270 | return {
|
15271 | nodeType: 'component',
|
15272 | type: node.type,
|
15273 | props: _assign({}, node.memoizedProps),
|
15274 | instance: node.stateNode,
|
15275 | rendered: childrenToTree(node.child)
|
15276 | };
|
15277 |
|
15278 | case FunctionComponent:
|
15279 | case SimpleMemoComponent:
|
15280 | return {
|
15281 | nodeType: 'component',
|
15282 | type: node.type,
|
15283 | props: _assign({}, node.memoizedProps),
|
15284 | instance: null,
|
15285 | rendered: childrenToTree(node.child)
|
15286 | };
|
15287 |
|
15288 | case Block:
|
15289 | return {
|
15290 | nodeType: 'block',
|
15291 | type: node.type,
|
15292 | props: _assign({}, node.memoizedProps),
|
15293 | instance: null,
|
15294 | rendered: childrenToTree(node.child)
|
15295 | };
|
15296 |
|
15297 | case HostComponent:
|
15298 | {
|
15299 | return {
|
15300 | nodeType: 'host',
|
15301 | type: node.type,
|
15302 | props: _assign({}, node.memoizedProps),
|
15303 | instance: null,
|
15304 |
|
15305 | rendered: flatten(nodeAndSiblingsArray(node.child).map(toTree))
|
15306 | };
|
15307 | }
|
15308 |
|
15309 | case HostText:
|
15310 | return node.stateNode.text;
|
15311 |
|
15312 | case Fragment:
|
15313 | case ContextProvider:
|
15314 | case ContextConsumer:
|
15315 | case Mode:
|
15316 | case Profiler:
|
15317 | case ForwardRef:
|
15318 | case MemoComponent:
|
15319 | case IncompleteClassComponent:
|
15320 | case ScopeComponent:
|
15321 | return childrenToTree(node.child);
|
15322 |
|
15323 | default:
|
15324 | {
|
15325 | {
|
15326 | throw Error( "toTree() does not yet know how to handle nodes with tag=" + node.tag );
|
15327 | }
|
15328 | }
|
15329 |
|
15330 | }
|
15331 | }
|
15332 |
|
15333 | var validWrapperTypes = new Set([FunctionComponent, ClassComponent, HostComponent, ForwardRef, MemoComponent, SimpleMemoComponent, Block,
|
15334 | HostRoot]);
|
15335 |
|
15336 | function getChildren(parent) {
|
15337 | var children = [];
|
15338 | var startingNode = parent;
|
15339 | var node = startingNode;
|
15340 |
|
15341 | if (node.child === null) {
|
15342 | return children;
|
15343 | }
|
15344 |
|
15345 | node.child.return = node;
|
15346 | node = node.child;
|
15347 |
|
15348 | outer: while (true) {
|
15349 | var descend = false;
|
15350 |
|
15351 | if (validWrapperTypes.has(node.tag)) {
|
15352 | children.push(wrapFiber(node));
|
15353 | } else if (node.tag === HostText) {
|
15354 | children.push('' + node.memoizedProps);
|
15355 | } else {
|
15356 | descend = true;
|
15357 | }
|
15358 |
|
15359 | if (descend && node.child !== null) {
|
15360 | node.child.return = node;
|
15361 | node = node.child;
|
15362 | continue;
|
15363 | }
|
15364 |
|
15365 | while (node.sibling === null) {
|
15366 | if (node.return === startingNode) {
|
15367 | break outer;
|
15368 | }
|
15369 |
|
15370 | node = node.return;
|
15371 | }
|
15372 |
|
15373 | node.sibling.return = node.return;
|
15374 | node = node.sibling;
|
15375 | }
|
15376 |
|
15377 | return children;
|
15378 | }
|
15379 |
|
15380 | var ReactTestInstance =
|
15381 |
|
15382 | function () {
|
15383 | var _proto = ReactTestInstance.prototype;
|
15384 |
|
15385 | _proto._currentFiber = function _currentFiber() {
|
15386 |
|
15387 | var fiber = findCurrentFiberUsingSlowPath(this._fiber);
|
15388 |
|
15389 | if (!(fiber !== null)) {
|
15390 | {
|
15391 | throw Error( "Can't read from currently-mounting component. This error is likely caused by a bug in React. Please file an issue." );
|
15392 | }
|
15393 | }
|
15394 |
|
15395 | return fiber;
|
15396 | };
|
15397 |
|
15398 | function ReactTestInstance(fiber) {
|
15399 | if (!validWrapperTypes.has(fiber.tag)) {
|
15400 | {
|
15401 | throw Error( "Unexpected object passed to ReactTestInstance constructor (tag: " + fiber.tag + "). This is probably a bug in React." );
|
15402 | }
|
15403 | }
|
15404 |
|
15405 | this._fiber = fiber;
|
15406 | }
|
15407 |
|
15408 |
|
15409 | _proto.find = function find(predicate) {
|
15410 | return expectOne(this.findAll(predicate, {
|
15411 | deep: false
|
15412 | }), "matching custom predicate: " + predicate.toString());
|
15413 | };
|
15414 |
|
15415 | _proto.findByType = function findByType(type) {
|
15416 | return expectOne(this.findAllByType(type, {
|
15417 | deep: false
|
15418 | }), "with node type: \"" + (type.displayName || type.name) + "\"");
|
15419 | };
|
15420 |
|
15421 | _proto.findByProps = function findByProps(props) {
|
15422 | return expectOne(this.findAllByProps(props, {
|
15423 | deep: false
|
15424 | }), "with props: " + JSON.stringify(props));
|
15425 | };
|
15426 |
|
15427 | _proto.findAll = function findAll(predicate) {
|
15428 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
15429 | return _findAll(this, predicate, options);
|
15430 | };
|
15431 |
|
15432 | _proto.findAllByType = function findAllByType(type) {
|
15433 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
15434 | return _findAll(this, function (node) {
|
15435 | return node.type === type;
|
15436 | }, options);
|
15437 | };
|
15438 |
|
15439 | _proto.findAllByProps = function findAllByProps(props) {
|
15440 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
15441 | return _findAll(this, function (node) {
|
15442 | return node.props && propsMatch(node.props, props);
|
15443 | }, options);
|
15444 | };
|
15445 |
|
15446 | _createClass(ReactTestInstance, [{
|
15447 | key: "instance",
|
15448 | get: function () {
|
15449 | if (this._fiber.tag === HostComponent) {
|
15450 | return getPublicInstance(this._fiber.stateNode);
|
15451 | } else {
|
15452 | return this._fiber.stateNode;
|
15453 | }
|
15454 | }
|
15455 | }, {
|
15456 | key: "type",
|
15457 | get: function () {
|
15458 | return this._fiber.type;
|
15459 | }
|
15460 | }, {
|
15461 | key: "props",
|
15462 | get: function () {
|
15463 | return this._currentFiber().memoizedProps;
|
15464 | }
|
15465 | }, {
|
15466 | key: "parent",
|
15467 | get: function () {
|
15468 | var parent = this._fiber.return;
|
15469 |
|
15470 | while (parent !== null) {
|
15471 | if (validWrapperTypes.has(parent.tag)) {
|
15472 | if (parent.tag === HostRoot) {
|
15473 |
|
15474 |
|
15475 | if (getChildren(parent).length < 2) {
|
15476 | return null;
|
15477 | }
|
15478 | }
|
15479 |
|
15480 | return wrapFiber(parent);
|
15481 | }
|
15482 |
|
15483 | parent = parent.return;
|
15484 | }
|
15485 |
|
15486 | return null;
|
15487 | }
|
15488 | }, {
|
15489 | key: "children",
|
15490 | get: function () {
|
15491 | return getChildren(this._currentFiber());
|
15492 | }
|
15493 | }]);
|
15494 |
|
15495 | return ReactTestInstance;
|
15496 | }();
|
15497 |
|
15498 | function _findAll(root, predicate, options) {
|
15499 | var deep = options ? options.deep : true;
|
15500 | var results = [];
|
15501 |
|
15502 | if (predicate(root)) {
|
15503 | results.push(root);
|
15504 |
|
15505 | if (!deep) {
|
15506 | return results;
|
15507 | }
|
15508 | }
|
15509 |
|
15510 | root.children.forEach(function (child) {
|
15511 | if (typeof child === 'string') {
|
15512 | return;
|
15513 | }
|
15514 |
|
15515 | results.push.apply(results, _findAll(child, predicate, options));
|
15516 | });
|
15517 | return results;
|
15518 | }
|
15519 |
|
15520 | function expectOne(all, message) {
|
15521 | if (all.length === 1) {
|
15522 | return all[0];
|
15523 | }
|
15524 |
|
15525 | var prefix = all.length === 0 ? 'No instances found ' : "Expected 1 but found " + all.length + " instances ";
|
15526 | throw new Error(prefix + message);
|
15527 | }
|
15528 |
|
15529 | function propsMatch(props, filter) {
|
15530 | for (var key in filter) {
|
15531 | if (props[key] !== filter[key]) {
|
15532 | return false;
|
15533 | }
|
15534 | }
|
15535 |
|
15536 | return true;
|
15537 | }
|
15538 |
|
15539 | var ReactTestRendererFiber = {
|
15540 | _Scheduler: Scheduler,
|
15541 | create: function (element, options) {
|
15542 | var createNodeMock = defaultTestOptions.createNodeMock;
|
15543 | var isConcurrent = false;
|
15544 |
|
15545 | if (typeof options === 'object' && options !== null) {
|
15546 | if (typeof options.createNodeMock === 'function') {
|
15547 | createNodeMock = options.createNodeMock;
|
15548 | }
|
15549 |
|
15550 | if (options.unstable_isConcurrent === true) {
|
15551 | isConcurrent = true;
|
15552 | }
|
15553 | }
|
15554 |
|
15555 | var container = {
|
15556 | children: [],
|
15557 | createNodeMock: createNodeMock,
|
15558 | tag: 'CONTAINER'
|
15559 | };
|
15560 | var root = createContainer(container, isConcurrent ? ConcurrentRoot : LegacyRoot, false);
|
15561 |
|
15562 | if (!(root != null)) {
|
15563 | {
|
15564 | throw Error( "something went wrong" );
|
15565 | }
|
15566 | }
|
15567 |
|
15568 | updateContainer(element, root, null, null);
|
15569 | var entry = {
|
15570 | _Scheduler: Scheduler,
|
15571 | root: undefined,
|
15572 |
|
15573 |
|
15574 | toJSON: function () {
|
15575 | if (root == null || root.current == null || container == null) {
|
15576 | return null;
|
15577 | }
|
15578 |
|
15579 | if (container.children.length === 0) {
|
15580 | return null;
|
15581 | }
|
15582 |
|
15583 | if (container.children.length === 1) {
|
15584 | return toJSON(container.children[0]);
|
15585 | }
|
15586 |
|
15587 | if (container.children.length === 2 && container.children[0].isHidden === true && container.children[1].isHidden === false) {
|
15588 |
|
15589 |
|
15590 | return toJSON(container.children[1]);
|
15591 | }
|
15592 |
|
15593 | var renderedChildren = null;
|
15594 |
|
15595 | if (container.children && container.children.length) {
|
15596 | for (var i = 0; i < container.children.length; i++) {
|
15597 | var renderedChild = toJSON(container.children[i]);
|
15598 |
|
15599 | if (renderedChild !== null) {
|
15600 | if (renderedChildren === null) {
|
15601 | renderedChildren = [renderedChild];
|
15602 | } else {
|
15603 | renderedChildren.push(renderedChild);
|
15604 | }
|
15605 | }
|
15606 | }
|
15607 | }
|
15608 |
|
15609 | return renderedChildren;
|
15610 | },
|
15611 | toTree: function () {
|
15612 | if (root == null || root.current == null) {
|
15613 | return null;
|
15614 | }
|
15615 |
|
15616 | return toTree(root.current);
|
15617 | },
|
15618 | update: function (newElement) {
|
15619 | if (root == null || root.current == null) {
|
15620 | return;
|
15621 | }
|
15622 |
|
15623 | updateContainer(newElement, root, null, null);
|
15624 | },
|
15625 | unmount: function () {
|
15626 | if (root == null || root.current == null) {
|
15627 | return;
|
15628 | }
|
15629 |
|
15630 | updateContainer(null, root, null, null);
|
15631 | container = null;
|
15632 | root = null;
|
15633 | },
|
15634 | getInstance: function () {
|
15635 | if (root == null || root.current == null) {
|
15636 | return null;
|
15637 | }
|
15638 |
|
15639 | return getPublicRootInstance(root);
|
15640 | },
|
15641 | unstable_flushSync: function (fn) {
|
15642 | return flushSync(fn);
|
15643 | }
|
15644 | };
|
15645 | Object.defineProperty(entry, 'root', {
|
15646 | configurable: true,
|
15647 | enumerable: true,
|
15648 | get: function () {
|
15649 | if (root === null) {
|
15650 | throw new Error("Can't access .root on unmounted test renderer");
|
15651 | }
|
15652 |
|
15653 | var children = getChildren(root.current);
|
15654 |
|
15655 | if (children.length === 0) {
|
15656 | throw new Error("Can't access .root on unmounted test renderer");
|
15657 | } else if (children.length === 1) {
|
15658 |
|
15659 | return children[0];
|
15660 | } else {
|
15661 |
|
15662 |
|
15663 | return wrapFiber(root.current);
|
15664 | }
|
15665 | }
|
15666 | });
|
15667 | return entry;
|
15668 | },
|
15669 |
|
15670 |
|
15671 | unstable_batchedUpdates: batchedUpdates,
|
15672 | act: act
|
15673 | };
|
15674 | var fiberToWrapper = new WeakMap();
|
15675 |
|
15676 | function wrapFiber(fiber) {
|
15677 | var wrapper = fiberToWrapper.get(fiber);
|
15678 |
|
15679 | if (wrapper === undefined && fiber.alternate !== null) {
|
15680 | wrapper = fiberToWrapper.get(fiber.alternate);
|
15681 | }
|
15682 |
|
15683 | if (wrapper === undefined) {
|
15684 | wrapper = new ReactTestInstance(fiber);
|
15685 | fiberToWrapper.set(fiber, wrapper);
|
15686 | }
|
15687 |
|
15688 | return wrapper;
|
15689 | }
|
15690 |
|
15691 |
|
15692 | injectIntoDevTools({
|
15693 | findFiberByHostInstance: function () {
|
15694 | throw new Error('TestRenderer does not support findFiberByHostInstance()');
|
15695 | },
|
15696 | bundleType: 1 ,
|
15697 | version: ReactVersion,
|
15698 | rendererPackageName: 'react-test-renderer'
|
15699 | });
|
15700 |
|
15701 |
|
15702 |
|
15703 |
|
15704 |
|
15705 | var reactTestRenderer = ReactTestRendererFiber.default || ReactTestRendererFiber;
|
15706 |
|
15707 | return reactTestRenderer;
|
15708 |
|
15709 | })));
|