react-test-renderer 16.5.2 → 16.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** @license React v16.5.2
1
+ /** @license React v16.6.0
2
2
  * react-test-renderer.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -18,7 +18,7 @@ if (process.env.NODE_ENV !== "production") {
18
18
  var _assign = require('object-assign');
19
19
  var React = require('react');
20
20
  var checkPropTypes = require('prop-types/checkPropTypes');
21
- var tracing = require('schedule/tracing');
21
+ var tracing = require('scheduler/tracing');
22
22
 
23
23
  /**
24
24
  * Use invariant() to assert state which your program assumes to be true.
@@ -194,9 +194,11 @@ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeac
194
194
  var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
195
195
  var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
196
196
  var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
197
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
197
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
198
198
  var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
199
- var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
199
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
200
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
201
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
200
202
 
201
203
  var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
202
204
  var FAUX_ITERATOR_SYMBOL = '@@iterator';
@@ -216,12 +218,13 @@ var Pending = 0;
216
218
  var Resolved = 1;
217
219
  var Rejected = 2;
218
220
 
219
- function getResultFromResolvedThenable(thenable) {
220
- return thenable._reactResult;
221
+ function refineResolvedLazyComponent(lazyComponent) {
222
+ return lazyComponent._status === Resolved ? lazyComponent._result : null;
221
223
  }
222
224
 
223
- function refineResolvedThenable(thenable) {
224
- return thenable._reactStatus === Resolved ? thenable._reactResult : null;
225
+ function getWrappedName(outerType, innerType, wrapperName) {
226
+ var functionName = innerType.displayName || innerType.name || '';
227
+ return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
225
228
  }
226
229
 
227
230
  function getComponentName(type) {
@@ -241,8 +244,8 @@ function getComponentName(type) {
241
244
  return type;
242
245
  }
243
246
  switch (type) {
244
- case REACT_ASYNC_MODE_TYPE:
245
- return 'AsyncMode';
247
+ case REACT_CONCURRENT_MODE_TYPE:
248
+ return 'ConcurrentMode';
246
249
  case REACT_FRAGMENT_TYPE:
247
250
  return 'Fragment';
248
251
  case REACT_PORTAL_TYPE:
@@ -251,8 +254,8 @@ function getComponentName(type) {
251
254
  return 'Profiler';
252
255
  case REACT_STRICT_MODE_TYPE:
253
256
  return 'StrictMode';
254
- case REACT_PLACEHOLDER_TYPE:
255
- return 'Placeholder';
257
+ case REACT_SUSPENSE_TYPE:
258
+ return 'Suspense';
256
259
  }
257
260
  if (typeof type === 'object') {
258
261
  switch (type.$$typeof) {
@@ -261,38 +264,40 @@ function getComponentName(type) {
261
264
  case REACT_PROVIDER_TYPE:
262
265
  return 'Context.Provider';
263
266
  case REACT_FORWARD_REF_TYPE:
264
- var renderFn = type.render;
265
- var functionName = renderFn.displayName || renderFn.name || '';
266
- return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
267
- }
268
- if (typeof type.then === 'function') {
269
- var thenable = type;
270
- var resolvedThenable = refineResolvedThenable(thenable);
271
- if (resolvedThenable) {
272
- return getComponentName(resolvedThenable);
273
- }
267
+ return getWrappedName(type, type.render, 'ForwardRef');
268
+ case REACT_MEMO_TYPE:
269
+ return getComponentName(type.type);
270
+ case REACT_LAZY_TYPE:
271
+ {
272
+ var thenable = type;
273
+ var resolvedThenable = refineResolvedLazyComponent(thenable);
274
+ if (resolvedThenable) {
275
+ return getComponentName(resolvedThenable);
276
+ }
277
+ }
274
278
  }
275
279
  }
276
280
  return null;
277
281
  }
278
282
 
279
- var FunctionalComponent = 0;
280
- var FunctionalComponentLazy = 1;
281
- var ClassComponent = 2;
282
- var ClassComponentLazy = 3;
283
- var IndeterminateComponent = 4; // Before we know whether it is functional or class
284
- var HostRoot = 5; // Root of a host tree. Could be nested inside another node.
285
- var HostPortal = 6; // A subtree. Could be an entry point to a different renderer.
286
- var HostComponent = 7;
287
- var HostText = 8;
288
- var Fragment = 9;
289
- var Mode = 10;
290
- var ContextConsumer = 11;
291
- var ContextProvider = 12;
292
- var ForwardRef = 13;
293
- var ForwardRefLazy = 14;
294
- var Profiler = 15;
295
- var PlaceholderComponent = 16;
283
+ var FunctionComponent = 0;
284
+ var ClassComponent = 1;
285
+ var IndeterminateComponent = 2; // Before we know whether it is function or class
286
+ var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
287
+ var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
288
+ var HostComponent = 5;
289
+ var HostText = 6;
290
+ var Fragment = 7;
291
+ var Mode = 8;
292
+ var ContextConsumer = 9;
293
+ var ContextProvider = 10;
294
+ var ForwardRef = 11;
295
+ var Profiler = 12;
296
+ var SuspenseComponent = 13;
297
+ var MemoComponent = 14;
298
+ var SimpleMemoComponent = 15;
299
+ var LazyComponent = 16;
300
+ var IncompleteClassComponent = 17;
296
301
 
297
302
  // Don't change these two values. They're used by React Dev Tools.
298
303
  var NoEffect = /* */0;
@@ -360,7 +365,7 @@ function isFiberMounted(fiber) {
360
365
  function isMounted(component) {
361
366
  {
362
367
  var owner = ReactCurrentOwner.current;
363
- if (owner !== null && (owner.tag === ClassComponent || owner.tag === ClassComponentLazy)) {
368
+ if (owner !== null && owner.tag === ClassComponent) {
364
369
  var ownerFiber = owner;
365
370
  var instance = ownerFiber.stateNode;
366
371
  !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component') : void 0;
@@ -590,7 +595,9 @@ function flushAll() {
590
595
  didTimeout: false
591
596
  });
592
597
  }
593
- return yieldedValues;
598
+ var values = yieldedValues;
599
+ yieldedValues = [];
600
+ return values;
594
601
  }
595
602
 
596
603
  function flushNumberOfYields(count) {
@@ -616,7 +623,9 @@ function flushNumberOfYields(count) {
616
623
  didTimeout: false
617
624
  });
618
625
  }
619
- return yieldedValues;
626
+ var values = yieldedValues;
627
+ yieldedValues = [];
628
+ return values;
620
629
  }
621
630
 
622
631
  function yieldValue(value) {
@@ -643,6 +652,9 @@ var createContainerChildSet = shim;
643
652
  var appendChildToContainerChildSet = shim;
644
653
  var finalizeContainerChildren = shim;
645
654
  var replaceContainerChildren = shim;
655
+ var cloneHiddenInstance = shim;
656
+ var cloneUnhiddenInstance = shim;
657
+ var createHiddenTextInstance = shim;
646
658
 
647
659
  // Renderers that don't support hydration
648
660
  // can re-export everything from this module.
@@ -733,6 +745,7 @@ function createInstance(type, props, rootContainerInstance, hostContext, interna
733
745
  return {
734
746
  type: type,
735
747
  props: props,
748
+ isHidden: false,
736
749
  children: [],
737
750
  rootContainerInstance: rootContainerInstance,
738
751
  tag: 'INSTANCE'
@@ -766,6 +779,7 @@ function shouldDeprioritizeSubtree(type, props) {
766
779
  function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
767
780
  return {
768
781
  text: text,
782
+ isHidden: false,
769
783
  tag: 'TEXT'
770
784
  };
771
785
  }
@@ -808,6 +822,22 @@ var appendChildToContainer = appendChild;
808
822
  var insertInContainerBefore = insertBefore;
809
823
  var removeChildFromContainer = removeChild;
810
824
 
825
+ function hideInstance(instance) {
826
+ instance.isHidden = true;
827
+ }
828
+
829
+ function hideTextInstance(textInstance) {
830
+ textInstance.isHidden = true;
831
+ }
832
+
833
+ function unhideInstance(instance, props) {
834
+ instance.isHidden = false;
835
+ }
836
+
837
+ function unhideTextInstance(textInstance, text) {
838
+ textInstance.isHidden = false;
839
+ }
840
+
811
841
  var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
812
842
 
813
843
  var describeComponentFrame = function (name, source, ownerName) {
@@ -841,10 +871,9 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
841
871
  function describeFiber(fiber) {
842
872
  switch (fiber.tag) {
843
873
  case IndeterminateComponent:
844
- case FunctionalComponent:
845
- case FunctionalComponentLazy:
874
+ case LazyComponent:
875
+ case FunctionComponent:
846
876
  case ClassComponent:
847
- case ClassComponentLazy:
848
877
  case HostComponent:
849
878
  case Mode:
850
879
  var owner = fiber._debugOwner;
@@ -923,10 +952,7 @@ function setCurrentPhase(lifeCyclePhase) {
923
952
  var debugRenderPhaseSideEffects = false;
924
953
  var debugRenderPhaseSideEffectsForStrictMode = false;
925
954
  var enableUserTimingAPI = true;
926
- var enableGetDerivedStateFromCatch = false;
927
- var enableSuspense = false;
928
955
  var warnAboutDeprecatedLifecycles = false;
929
- var warnAboutLegacyContextAPI = false;
930
956
  var replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
931
957
  var enableProfilerTimer = false;
932
958
  var enableSchedulerTracing = false;
@@ -1190,7 +1216,7 @@ function stopFailedWorkTimer(fiber) {
1190
1216
  return;
1191
1217
  }
1192
1218
  fiber._debugIsCurrentlyTiming = false;
1193
- var warning = 'An error was thrown inside this error boundary';
1219
+ var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1194
1220
  endFiberMark(fiber, null, warning);
1195
1221
  }
1196
1222
  }
@@ -1612,7 +1638,7 @@ function invalidateContextProvider(workInProgress, type, didChange) {
1612
1638
  function findCurrentUnmaskedContext(fiber) {
1613
1639
  // Currently this is only used with renderSubtreeIntoContainer; not sure if it
1614
1640
  // makes sense elsewhere
1615
- !(isFiberMounted(fiber) && (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy)) ? invariant(false, 'Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.') : void 0;
1641
+ !(isFiberMounted(fiber) && fiber.tag === ClassComponent) ? invariant(false, 'Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.') : void 0;
1616
1642
 
1617
1643
  var node = fiber;
1618
1644
  do {
@@ -1627,14 +1653,6 @@ function findCurrentUnmaskedContext(fiber) {
1627
1653
  }
1628
1654
  break;
1629
1655
  }
1630
- case ClassComponentLazy:
1631
- {
1632
- var _Component = getResultFromResolvedThenable(node.type);
1633
- if (isContextProvider(_Component)) {
1634
- return node.stateNode.__reactInternalMemoizedMergedChildContext;
1635
- }
1636
- break;
1637
- }
1638
1656
  }
1639
1657
  node = node.return;
1640
1658
  } while (node !== null);
@@ -1766,7 +1784,7 @@ function computeInteractiveExpiration(currentTime) {
1766
1784
  }
1767
1785
 
1768
1786
  var NoContext = 0;
1769
- var AsyncMode = 1;
1787
+ var ConcurrentMode = 1;
1770
1788
  var StrictMode = 2;
1771
1789
  var ProfileMode = 4;
1772
1790
 
@@ -1803,6 +1821,7 @@ function FiberNode(tag, pendingProps, key, mode) {
1803
1821
  // Instance
1804
1822
  this.tag = tag;
1805
1823
  this.key = key;
1824
+ this.elementType = null;
1806
1825
  this.type = null;
1807
1826
  this.stateNode = null;
1808
1827
 
@@ -1875,11 +1894,21 @@ function shouldConstruct(Component) {
1875
1894
  return !!(prototype && prototype.isReactComponent);
1876
1895
  }
1877
1896
 
1878
- function resolveLazyComponentTag(fiber, Component) {
1897
+ function isSimpleFunctionComponent(type) {
1898
+ return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
1899
+ }
1900
+
1901
+ function resolveLazyComponentTag(Component) {
1879
1902
  if (typeof Component === 'function') {
1880
- return shouldConstruct(Component) ? ClassComponentLazy : FunctionalComponentLazy;
1881
- } else if (Component !== undefined && Component !== null && Component.$$typeof) {
1882
- return ForwardRefLazy;
1903
+ return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
1904
+ } else if (Component !== undefined && Component !== null) {
1905
+ var $$typeof = Component.$$typeof;
1906
+ if ($$typeof === REACT_FORWARD_REF_TYPE) {
1907
+ return ForwardRef;
1908
+ }
1909
+ if ($$typeof === REACT_MEMO_TYPE) {
1910
+ return MemoComponent;
1911
+ }
1883
1912
  }
1884
1913
  return IndeterminateComponent;
1885
1914
  }
@@ -1894,6 +1923,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
1894
1923
  // extra objects for things that are never updated. It also allow us to
1895
1924
  // reclaim the extra memory if needed.
1896
1925
  workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
1926
+ workInProgress.elementType = current.elementType;
1897
1927
  workInProgress.type = current.type;
1898
1928
  workInProgress.stateNode = current.stateNode;
1899
1929
 
@@ -1928,15 +1958,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
1928
1958
  }
1929
1959
  }
1930
1960
 
1931
- // Don't touching the subtree's expiration time, which has not changed.
1932
1961
  workInProgress.childExpirationTime = current.childExpirationTime;
1933
- if (pendingProps !== current.pendingProps) {
1934
- // This fiber has new props.
1935
- workInProgress.expirationTime = expirationTime;
1936
- } else {
1937
- // This fiber's props have not changed.
1938
- workInProgress.expirationTime = current.expirationTime;
1939
- }
1962
+ workInProgress.expirationTime = current.expirationTime;
1940
1963
 
1941
1964
  workInProgress.child = current.child;
1942
1965
  workInProgress.memoizedProps = current.memoizedProps;
@@ -1957,8 +1980,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
1957
1980
  return workInProgress;
1958
1981
  }
1959
1982
 
1960
- function createHostRootFiber(isAsync) {
1961
- var mode = isAsync ? AsyncMode | StrictMode : NoContext;
1983
+ function createHostRootFiber(isConcurrent) {
1984
+ var mode = isConcurrent ? ConcurrentMode | StrictMode : NoContext;
1962
1985
 
1963
1986
  if (enableProfilerTimer && isDevToolsPresent) {
1964
1987
  // Always collect profile timings when DevTools are present.
@@ -1970,39 +1993,31 @@ function createHostRootFiber(isAsync) {
1970
1993
  return createFiber(HostRoot, null, null, mode);
1971
1994
  }
1972
1995
 
1973
- function createFiberFromElement(element, mode, expirationTime) {
1974
- var owner = null;
1975
- {
1976
- owner = element._owner;
1977
- }
1978
-
1996
+ function createFiberFromTypeAndProps(type, // React$ElementType
1997
+ key, pendingProps, owner, mode, expirationTime) {
1979
1998
  var fiber = void 0;
1980
- var type = element.type;
1981
- var key = element.key;
1982
- var pendingProps = element.props;
1983
1999
 
1984
- var fiberTag = void 0;
2000
+ var fiberTag = IndeterminateComponent;
2001
+ // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
2002
+ var resolvedType = type;
1985
2003
  if (typeof type === 'function') {
1986
- fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
2004
+ if (shouldConstruct(type)) {
2005
+ fiberTag = ClassComponent;
2006
+ }
1987
2007
  } else if (typeof type === 'string') {
1988
2008
  fiberTag = HostComponent;
1989
2009
  } else {
1990
2010
  getTag: switch (type) {
1991
2011
  case REACT_FRAGMENT_TYPE:
1992
2012
  return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
1993
- case REACT_ASYNC_MODE_TYPE:
1994
- fiberTag = Mode;
1995
- mode |= AsyncMode | StrictMode;
1996
- break;
2013
+ case REACT_CONCURRENT_MODE_TYPE:
2014
+ return createFiberFromMode(pendingProps, mode | ConcurrentMode | StrictMode, expirationTime, key);
1997
2015
  case REACT_STRICT_MODE_TYPE:
1998
- fiberTag = Mode;
1999
- mode |= StrictMode;
2000
- break;
2016
+ return createFiberFromMode(pendingProps, mode | StrictMode, expirationTime, key);
2001
2017
  case REACT_PROFILER_TYPE:
2002
2018
  return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
2003
- case REACT_PLACEHOLDER_TYPE:
2004
- fiberTag = PlaceholderComponent;
2005
- break;
2019
+ case REACT_SUSPENSE_TYPE:
2020
+ return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
2006
2021
  default:
2007
2022
  {
2008
2023
  if (typeof type === 'object' && type !== null) {
@@ -2017,13 +2032,13 @@ function createFiberFromElement(element, mode, expirationTime) {
2017
2032
  case REACT_FORWARD_REF_TYPE:
2018
2033
  fiberTag = ForwardRef;
2019
2034
  break getTag;
2020
- default:
2021
- {
2022
- if (typeof type.then === 'function') {
2023
- fiberTag = IndeterminateComponent;
2024
- break getTag;
2025
- }
2026
- }
2035
+ case REACT_MEMO_TYPE:
2036
+ fiberTag = MemoComponent;
2037
+ break getTag;
2038
+ case REACT_LAZY_TYPE:
2039
+ fiberTag = LazyComponent;
2040
+ resolvedType = null;
2041
+ break getTag;
2027
2042
  }
2028
2043
  }
2029
2044
  var info = '';
@@ -2042,14 +2057,26 @@ function createFiberFromElement(element, mode, expirationTime) {
2042
2057
  }
2043
2058
 
2044
2059
  fiber = createFiber(fiberTag, pendingProps, key, mode);
2045
- fiber.type = type;
2060
+ fiber.elementType = type;
2061
+ fiber.type = resolvedType;
2046
2062
  fiber.expirationTime = expirationTime;
2047
2063
 
2064
+ return fiber;
2065
+ }
2066
+
2067
+ function createFiberFromElement(element, mode, expirationTime) {
2068
+ var owner = null;
2069
+ {
2070
+ owner = element._owner;
2071
+ }
2072
+ var type = element.type;
2073
+ var key = element.key;
2074
+ var pendingProps = element.props;
2075
+ var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
2048
2076
  {
2049
2077
  fiber._debugSource = element._source;
2050
2078
  fiber._debugOwner = element._owner;
2051
2079
  }
2052
-
2053
2080
  return fiber;
2054
2081
  }
2055
2082
 
@@ -2067,12 +2094,38 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
2067
2094
  }
2068
2095
 
2069
2096
  var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
2097
+ // TODO: The Profiler fiber shouldn't have a type. It has a tag.
2098
+ fiber.elementType = REACT_PROFILER_TYPE;
2070
2099
  fiber.type = REACT_PROFILER_TYPE;
2071
2100
  fiber.expirationTime = expirationTime;
2072
2101
 
2073
2102
  return fiber;
2074
2103
  }
2075
2104
 
2105
+ function createFiberFromMode(pendingProps, mode, expirationTime, key) {
2106
+ var fiber = createFiber(Mode, pendingProps, key, mode);
2107
+
2108
+ // TODO: The Mode fiber shouldn't have a type. It has a tag.
2109
+ var type = (mode & ConcurrentMode) === NoContext ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE;
2110
+ fiber.elementType = type;
2111
+ fiber.type = type;
2112
+
2113
+ fiber.expirationTime = expirationTime;
2114
+ return fiber;
2115
+ }
2116
+
2117
+ function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
2118
+ var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
2119
+
2120
+ // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
2121
+ var type = REACT_SUSPENSE_TYPE;
2122
+ fiber.elementType = type;
2123
+ fiber.type = type;
2124
+
2125
+ fiber.expirationTime = expirationTime;
2126
+ return fiber;
2127
+ }
2128
+
2076
2129
  function createFiberFromText(content, mode, expirationTime) {
2077
2130
  var fiber = createFiber(HostText, content, null, mode);
2078
2131
  fiber.expirationTime = expirationTime;
@@ -2081,6 +2134,8 @@ function createFiberFromText(content, mode, expirationTime) {
2081
2134
 
2082
2135
  function createFiberFromHostInstanceForDeletion() {
2083
2136
  var fiber = createFiber(HostComponent, null, null, NoContext);
2137
+ // TODO: These should not need a type.
2138
+ fiber.elementType = 'DELETED';
2084
2139
  fiber.type = 'DELETED';
2085
2140
  return fiber;
2086
2141
  }
@@ -2113,6 +2168,7 @@ function assignFiberPropertiesInDEV(target, source) {
2113
2168
 
2114
2169
  target.tag = source.tag;
2115
2170
  target.key = source.key;
2171
+ target.elementType = source.elementType;
2116
2172
  target.type = source.type;
2117
2173
  target.stateNode = source.stateNode;
2118
2174
  target.return = source.return;
@@ -2146,7 +2202,6 @@ function assignFiberPropertiesInDEV(target, source) {
2146
2202
  return target;
2147
2203
  }
2148
2204
 
2149
- /* eslint-disable no-use-before-define */
2150
2205
  // TODO: This should be lifted into the renderer.
2151
2206
 
2152
2207
 
@@ -2162,12 +2217,11 @@ function assignFiberPropertiesInDEV(target, source) {
2162
2217
  // The types are defined separately within this file to ensure they stay in sync.
2163
2218
  // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
2164
2219
 
2165
- /* eslint-enable no-use-before-define */
2166
2220
 
2167
- function createFiberRoot(containerInfo, isAsync, hydrate) {
2221
+ function createFiberRoot(containerInfo, isConcurrent, hydrate) {
2168
2222
  // Cyclic construction. This cheats the type system right now because
2169
2223
  // stateNode is any.
2170
- var uninitializedFiber = createHostRootFiber(isAsync);
2224
+ var uninitializedFiber = createHostRootFiber(isConcurrent);
2171
2225
 
2172
2226
  var root = void 0;
2173
2227
  if (enableSchedulerTracing) {
@@ -2290,6 +2344,10 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
2290
2344
  // browsers that support it.
2291
2345
  var windowEvent = window.event;
2292
2346
 
2347
+ // Keeps track of the descriptor of window.event to restore it after event
2348
+ // dispatching: https://github.com/facebook/react/issues/13688
2349
+ var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
2350
+
2293
2351
  // Create an event handler for our fake event. We will synchronously
2294
2352
  // dispatch our fake event using `dispatchEvent`. Inside the handler, we
2295
2353
  // call the user-provided callback.
@@ -2361,6 +2419,10 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
2361
2419
  evt.initEvent(evtType, false, false);
2362
2420
  fakeNode.dispatchEvent(evt);
2363
2421
 
2422
+ if (windowEventDescriptor) {
2423
+ Object.defineProperty(window, 'event', windowEventDescriptor);
2424
+ }
2425
+
2364
2426
  if (didError) {
2365
2427
  if (!didSetError) {
2366
2428
  // The callback errored, but the error event never fired.
@@ -3184,7 +3246,7 @@ function enqueueUpdate(fiber, update) {
3184
3246
  }
3185
3247
 
3186
3248
  {
3187
- if ((fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
3249
+ if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
3188
3250
  warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
3189
3251
  didWarnUpdateInsideUpdate = true;
3190
3252
  }
@@ -3557,7 +3619,7 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
3557
3619
  if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
3558
3620
  // Match! Schedule an update on this fiber.
3559
3621
 
3560
- if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) {
3622
+ if (fiber.tag === ClassComponent) {
3561
3623
  // Schedule a force update on the work-in-progress.
3562
3624
  var update = createUpdate(renderExpirationTime);
3563
3625
  update.tag = ForceUpdate;
@@ -3664,7 +3726,7 @@ function readContext(context, observedBits) {
3664
3726
  };
3665
3727
 
3666
3728
  if (lastContextDependency === null) {
3667
- !(currentlyRenderingFiber !== null) ? invariant(false, 'Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0;
3729
+ !(currentlyRenderingFiber !== null) ? invariant(false, 'Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0;
3668
3730
  // This is the first dependency in the list
3669
3731
  currentlyRenderingFiber.firstContextDependency = lastContextDependency = contextItem;
3670
3732
  } else {
@@ -3849,8 +3911,15 @@ function shallowEqual(objA, objB) {
3849
3911
  return true;
3850
3912
  }
3851
3913
 
3914
+ var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
3915
+
3916
+ function readContext$1(contextType) {
3917
+ var dispatcher = ReactCurrentOwner$3.currentDispatcher;
3918
+ return dispatcher.readContext(contextType);
3919
+ }
3920
+
3852
3921
  var fakeInternalInstance = {};
3853
- var isArray = Array.isArray;
3922
+ var isArray$1 = Array.isArray;
3854
3923
 
3855
3924
  // React.Component uses a shared frozen object by default.
3856
3925
  // We'll use it to determine whether we need to initialize legacy refs.
@@ -3864,6 +3933,8 @@ var didWarnAboutUndefinedDerivedState = void 0;
3864
3933
  var warnOnUndefinedDerivedState = void 0;
3865
3934
  var warnOnInvalidCallback = void 0;
3866
3935
  var didWarnAboutDirectlyAssigningPropsToState = void 0;
3936
+ var didWarnAboutContextTypeAndContextTypes = void 0;
3937
+ var didWarnAboutInvalidateContextType = void 0;
3867
3938
 
3868
3939
  {
3869
3940
  didWarnAboutStateAssignmentForComponent = new Set();
@@ -3872,6 +3943,8 @@ var didWarnAboutDirectlyAssigningPropsToState = void 0;
3872
3943
  didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
3873
3944
  didWarnAboutDirectlyAssigningPropsToState = new Set();
3874
3945
  didWarnAboutUndefinedDerivedState = new Set();
3946
+ didWarnAboutContextTypeAndContextTypes = new Set();
3947
+ didWarnAboutInvalidateContextType = new Set();
3875
3948
 
3876
3949
  var didWarnOnInvalidCallback = new Set();
3877
3950
 
@@ -3995,11 +4068,11 @@ var classComponentUpdater = {
3995
4068
  }
3996
4069
  };
3997
4070
 
3998
- function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextLegacyContext) {
4071
+ function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
3999
4072
  var instance = workInProgress.stateNode;
4000
4073
  if (typeof instance.shouldComponentUpdate === 'function') {
4001
4074
  startPhaseTimer(workInProgress, 'shouldComponentUpdate');
4002
- var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextLegacyContext);
4075
+ var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
4003
4076
  stopPhaseTimer();
4004
4077
 
4005
4078
  {
@@ -4036,8 +4109,16 @@ function checkClassInstance(workInProgress, ctor, newProps) {
4036
4109
  !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
4037
4110
  var noInstancePropTypes = !instance.propTypes;
4038
4111
  !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
4112
+ var noInstanceContextType = !instance.contextType;
4113
+ !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
4039
4114
  var noInstanceContextTypes = !instance.contextTypes;
4040
4115
  !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
4116
+
4117
+ if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
4118
+ didWarnAboutContextTypeAndContextTypes.add(ctor);
4119
+ warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
4120
+ }
4121
+
4041
4122
  var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
4042
4123
  !noComponentShouldUpdate ? warningWithoutStack$1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
4043
4124
  if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
@@ -4063,12 +4144,12 @@ function checkClassInstance(workInProgress, ctor, newProps) {
4063
4144
 
4064
4145
  var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
4065
4146
  !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
4066
- var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromCatch !== 'function';
4067
- !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromCatch() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
4147
+ var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
4148
+ !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
4068
4149
  var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
4069
4150
  !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
4070
4151
  var _state = instance.state;
4071
- if (_state && (typeof _state !== 'object' || isArray(_state))) {
4152
+ if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
4072
4153
  warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
4073
4154
  }
4074
4155
  if (typeof instance.getChildContext === 'function') {
@@ -4088,10 +4169,25 @@ function adoptClassInstance(workInProgress, instance) {
4088
4169
  }
4089
4170
 
4090
4171
  function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
4091
- var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4092
- var contextTypes = ctor.contextTypes;
4093
- var isContextConsumer = contextTypes !== null && contextTypes !== undefined;
4094
- var context = isContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
4172
+ var isLegacyContextConsumer = false;
4173
+ var unmaskedContext = emptyContextObject;
4174
+ var context = null;
4175
+ var contextType = ctor.contextType;
4176
+ if (typeof contextType === 'object' && contextType !== null) {
4177
+ {
4178
+ if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
4179
+ didWarnAboutInvalidateContextType.add(ctor);
4180
+ warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext(). ' + 'Did you accidentally pass the Context.Provider instead?', getComponentName(ctor) || 'Component');
4181
+ }
4182
+ }
4183
+
4184
+ context = readContext$1(contextType);
4185
+ } else {
4186
+ unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4187
+ var contextTypes = ctor.contextTypes;
4188
+ isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
4189
+ context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
4190
+ }
4095
4191
 
4096
4192
  // Instantiate twice to help detect side-effects.
4097
4193
  {
@@ -4148,7 +4244,7 @@ function constructClassInstance(workInProgress, ctor, props, renderExpirationTim
4148
4244
 
4149
4245
  // Cache unmasked context so we can avoid recreating masked context unless necessary.
4150
4246
  // ReactFiberContext usually updates this cache but can't for newly-created instances.
4151
- if (isContextConsumer) {
4247
+ if (isLegacyContextConsumer) {
4152
4248
  cacheContext(workInProgress, unmaskedContext, context);
4153
4249
  }
4154
4250
 
@@ -4176,14 +4272,14 @@ function callComponentWillMount(workInProgress, instance) {
4176
4272
  }
4177
4273
  }
4178
4274
 
4179
- function callComponentWillReceiveProps(workInProgress, instance, newProps, nextLegacyContext) {
4275
+ function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
4180
4276
  var oldState = instance.state;
4181
4277
  startPhaseTimer(workInProgress, 'componentWillReceiveProps');
4182
4278
  if (typeof instance.componentWillReceiveProps === 'function') {
4183
- instance.componentWillReceiveProps(newProps, nextLegacyContext);
4279
+ instance.componentWillReceiveProps(newProps, nextContext);
4184
4280
  }
4185
4281
  if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4186
- instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext);
4282
+ instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
4187
4283
  }
4188
4284
  stopPhaseTimer();
4189
4285
 
@@ -4206,12 +4302,17 @@ function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime
4206
4302
  }
4207
4303
 
4208
4304
  var instance = workInProgress.stateNode;
4209
- var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4210
-
4211
4305
  instance.props = newProps;
4212
4306
  instance.state = workInProgress.memoizedState;
4213
4307
  instance.refs = emptyRefsObject;
4214
- instance.context = getMaskedContext(workInProgress, unmaskedContext);
4308
+
4309
+ var contextType = ctor.contextType;
4310
+ if (typeof contextType === 'object' && contextType !== null) {
4311
+ instance.context = readContext$1(contextType);
4312
+ } else {
4313
+ var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4314
+ instance.context = getMaskedContext(workInProgress, unmaskedContext);
4315
+ }
4215
4316
 
4216
4317
  {
4217
4318
  if (instance.state === newProps) {
@@ -4270,8 +4371,14 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4270
4371
  instance.props = oldProps;
4271
4372
 
4272
4373
  var oldContext = instance.context;
4273
- var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4274
- var nextLegacyContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4374
+ var contextType = ctor.contextType;
4375
+ var nextContext = void 0;
4376
+ if (typeof contextType === 'object' && contextType !== null) {
4377
+ nextContext = readContext$1(contextType);
4378
+ } else {
4379
+ var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4380
+ nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4381
+ }
4275
4382
 
4276
4383
  var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4277
4384
  var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
@@ -4283,8 +4390,8 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4283
4390
  // In order to support react-lifecycles-compat polyfilled components,
4284
4391
  // Unsafe lifecycles should not be invoked for components using the new APIs.
4285
4392
  if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4286
- if (oldProps !== newProps || oldContext !== nextLegacyContext) {
4287
- callComponentWillReceiveProps(workInProgress, instance, newProps, nextLegacyContext);
4393
+ if (oldProps !== newProps || oldContext !== nextContext) {
4394
+ callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4288
4395
  }
4289
4396
  }
4290
4397
 
@@ -4311,7 +4418,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4311
4418
  newState = workInProgress.memoizedState;
4312
4419
  }
4313
4420
 
4314
- var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextLegacyContext);
4421
+ var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4315
4422
 
4316
4423
  if (shouldUpdate) {
4317
4424
  // In order to support react-lifecycles-compat polyfilled components,
@@ -4346,7 +4453,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4346
4453
  // if shouldComponentUpdate returns false.
4347
4454
  instance.props = newProps;
4348
4455
  instance.state = newState;
4349
- instance.context = nextLegacyContext;
4456
+ instance.context = nextContext;
4350
4457
 
4351
4458
  return shouldUpdate;
4352
4459
  }
@@ -4359,8 +4466,14 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4359
4466
  instance.props = oldProps;
4360
4467
 
4361
4468
  var oldContext = instance.context;
4362
- var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4363
- var nextLegacyContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4469
+ var contextType = ctor.contextType;
4470
+ var nextContext = void 0;
4471
+ if (typeof contextType === 'object' && contextType !== null) {
4472
+ nextContext = readContext$1(contextType);
4473
+ } else {
4474
+ var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4475
+ nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
4476
+ }
4364
4477
 
4365
4478
  var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4366
4479
  var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
@@ -4372,8 +4485,8 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4372
4485
  // In order to support react-lifecycles-compat polyfilled components,
4373
4486
  // Unsafe lifecycles should not be invoked for components using the new APIs.
4374
4487
  if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4375
- if (oldProps !== newProps || oldContext !== nextLegacyContext) {
4376
- callComponentWillReceiveProps(workInProgress, instance, newProps, nextLegacyContext);
4488
+ if (oldProps !== newProps || oldContext !== nextContext) {
4489
+ callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4377
4490
  }
4378
4491
  }
4379
4492
 
@@ -4408,7 +4521,7 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4408
4521
  newState = workInProgress.memoizedState;
4409
4522
  }
4410
4523
 
4411
- var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextLegacyContext);
4524
+ var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4412
4525
 
4413
4526
  if (shouldUpdate) {
4414
4527
  // In order to support react-lifecycles-compat polyfilled components,
@@ -4416,10 +4529,10 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4416
4529
  if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
4417
4530
  startPhaseTimer(workInProgress, 'componentWillUpdate');
4418
4531
  if (typeof instance.componentWillUpdate === 'function') {
4419
- instance.componentWillUpdate(newProps, newState, nextLegacyContext);
4532
+ instance.componentWillUpdate(newProps, newState, nextContext);
4420
4533
  }
4421
4534
  if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4422
- instance.UNSAFE_componentWillUpdate(newProps, newState, nextLegacyContext);
4535
+ instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
4423
4536
  }
4424
4537
  stopPhaseTimer();
4425
4538
  }
@@ -4453,7 +4566,7 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4453
4566
  // if shouldComponentUpdate returns false.
4454
4567
  instance.props = newProps;
4455
4568
  instance.state = newState;
4456
- instance.context = nextLegacyContext;
4569
+ instance.context = nextContext;
4457
4570
 
4458
4571
  return shouldUpdate;
4459
4572
  }
@@ -4498,7 +4611,7 @@ var warnForMissingKey = function (child) {};
4498
4611
  };
4499
4612
  }
4500
4613
 
4501
- var isArray$1 = Array.isArray;
4614
+ var isArray = Array.isArray;
4502
4615
 
4503
4616
  function coerceRef(returnFiber, current$$1, element) {
4504
4617
  var mixedRef = element.ref;
@@ -4518,7 +4631,7 @@ function coerceRef(returnFiber, current$$1, element) {
4518
4631
  var inst = void 0;
4519
4632
  if (owner) {
4520
4633
  var ownerFiber = owner;
4521
- !(ownerFiber.tag === ClassComponent || ownerFiber.tag === ClassComponentLazy) ? invariant(false, 'Stateless function components cannot have refs.') : void 0;
4634
+ !(ownerFiber.tag === ClassComponent) ? invariant(false, 'Function components cannot have refs.') : void 0;
4522
4635
  inst = ownerFiber.stateNode;
4523
4636
  }
4524
4637
  !inst ? invariant(false, 'Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.', mixedRef) : void 0;
@@ -4543,7 +4656,7 @@ function coerceRef(returnFiber, current$$1, element) {
4543
4656
  return ref;
4544
4657
  } else {
4545
4658
  !(typeof mixedRef === 'string') ? invariant(false, 'Expected ref to be a function, a string, an object returned by React.createRef(), or null.') : void 0;
4546
- !element._owner ? invariant(false, 'Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional 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.', mixedRef) : void 0;
4659
+ !element._owner ? invariant(false, 'Element ref was specified as a string (%s) 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.', mixedRef) : void 0;
4547
4660
  }
4548
4661
  }
4549
4662
  return mixedRef;
@@ -4686,7 +4799,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4686
4799
  }
4687
4800
 
4688
4801
  function updateElement(returnFiber, current$$1, element, expirationTime) {
4689
- if (current$$1 !== null && current$$1.type === element.type) {
4802
+ if (current$$1 !== null && current$$1.elementType === element.type) {
4690
4803
  // Move based on index
4691
4804
  var existing = useFiber(current$$1, element.props, expirationTime);
4692
4805
  existing.ref = coerceRef(returnFiber, current$$1, element);
@@ -4760,7 +4873,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4760
4873
  }
4761
4874
  }
4762
4875
 
4763
- if (isArray$1(newChild) || getIteratorFn(newChild)) {
4876
+ if (isArray(newChild) || getIteratorFn(newChild)) {
4764
4877
  var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
4765
4878
  _created3.return = returnFiber;
4766
4879
  return _created3;
@@ -4816,7 +4929,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4816
4929
  }
4817
4930
  }
4818
4931
 
4819
- if (isArray$1(newChild) || getIteratorFn(newChild)) {
4932
+ if (isArray(newChild) || getIteratorFn(newChild)) {
4820
4933
  if (key !== null) {
4821
4934
  return null;
4822
4935
  }
@@ -4861,7 +4974,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4861
4974
  }
4862
4975
  }
4863
4976
 
4864
- if (isArray$1(newChild) || getIteratorFn(newChild)) {
4977
+ if (isArray(newChild) || getIteratorFn(newChild)) {
4865
4978
  var _matchedFiber3 = existingChildren.get(newIdx) || null;
4866
4979
  return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
4867
4980
  }
@@ -5228,7 +5341,7 @@ function ChildReconciler(shouldTrackSideEffects) {
5228
5341
  // TODO: If key === null and child.key === null, then this only applies to
5229
5342
  // the first item in the list.
5230
5343
  if (child.key === key) {
5231
- if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {
5344
+ if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {
5232
5345
  deleteRemainingChildren(returnFiber, child.sibling);
5233
5346
  var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
5234
5347
  existing.ref = coerceRef(returnFiber, child, element);
@@ -5320,7 +5433,7 @@ function ChildReconciler(shouldTrackSideEffects) {
5320
5433
  return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
5321
5434
  }
5322
5435
 
5323
- if (isArray$1(newChild)) {
5436
+ if (isArray(newChild)) {
5324
5437
  return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
5325
5438
  }
5326
5439
 
@@ -5343,7 +5456,6 @@ function ChildReconciler(shouldTrackSideEffects) {
5343
5456
  // we already threw above.
5344
5457
  switch (returnFiber.tag) {
5345
5458
  case ClassComponent:
5346
- case ClassComponentLazy:
5347
5459
  {
5348
5460
  {
5349
5461
  var instance = returnFiber.stateNode;
@@ -5356,7 +5468,7 @@ function ChildReconciler(shouldTrackSideEffects) {
5356
5468
  // Intentionally fall through to the next case, which handles both
5357
5469
  // functions and classes
5358
5470
  // eslint-disable-next-lined no-fallthrough
5359
- case FunctionalComponent:
5471
+ case FunctionComponent:
5360
5472
  {
5361
5473
  var Component = returnFiber.type;
5362
5474
  invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');
@@ -5658,40 +5770,49 @@ function resetHydrationState() {
5658
5770
  isHydrating = false;
5659
5771
  }
5660
5772
 
5661
- function readLazyComponentType(thenable) {
5662
- var status = thenable._reactStatus;
5773
+ function readLazyComponentType(lazyComponent) {
5774
+ var status = lazyComponent._status;
5775
+ var result = lazyComponent._result;
5663
5776
  switch (status) {
5664
5777
  case Resolved:
5665
- var Component = thenable._reactResult;
5666
- return Component;
5778
+ {
5779
+ var Component = result;
5780
+ return Component;
5781
+ }
5667
5782
  case Rejected:
5668
- throw thenable._reactResult;
5783
+ {
5784
+ var error = result;
5785
+ throw error;
5786
+ }
5669
5787
  case Pending:
5670
- throw thenable;
5788
+ {
5789
+ var thenable = result;
5790
+ throw thenable;
5791
+ }
5671
5792
  default:
5672
5793
  {
5673
- thenable._reactStatus = Pending;
5674
- thenable.then(function (resolvedValue) {
5675
- if (thenable._reactStatus === Pending) {
5676
- thenable._reactStatus = Resolved;
5677
- if (typeof resolvedValue === 'object' && resolvedValue !== null) {
5678
- // If the `default` property is not empty, assume it's the result
5679
- // of an async import() and use that. Otherwise, use the
5680
- // resolved value itself.
5681
- var defaultExport = resolvedValue.default;
5682
- resolvedValue = defaultExport !== undefined && defaultExport !== null ? defaultExport : resolvedValue;
5683
- } else {
5684
- resolvedValue = resolvedValue;
5794
+ lazyComponent._status = Pending;
5795
+ var ctor = lazyComponent._ctor;
5796
+ var _thenable = ctor();
5797
+ _thenable.then(function (moduleObject) {
5798
+ if (lazyComponent._status === Pending) {
5799
+ var defaultExport = moduleObject.default;
5800
+ {
5801
+ if (defaultExport === undefined) {
5802
+ warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
5803
+ }
5685
5804
  }
5686
- thenable._reactResult = resolvedValue;
5805
+ lazyComponent._status = Resolved;
5806
+ lazyComponent._result = defaultExport;
5687
5807
  }
5688
5808
  }, function (error) {
5689
- if (thenable._reactStatus === Pending) {
5690
- thenable._reactStatus = Rejected;
5691
- thenable._reactResult = error;
5809
+ if (lazyComponent._status === Pending) {
5810
+ lazyComponent._status = Rejected;
5811
+ lazyComponent._result = error;
5692
5812
  }
5693
5813
  });
5694
- throw thenable;
5814
+ lazyComponent._result = _thenable;
5815
+ throw _thenable;
5695
5816
  }
5696
5817
  }
5697
5818
  }
@@ -5699,13 +5820,15 @@ function readLazyComponentType(thenable) {
5699
5820
  var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
5700
5821
 
5701
5822
  var didWarnAboutBadClass = void 0;
5702
- var didWarnAboutGetDerivedStateOnFunctionalComponent = void 0;
5703
- var didWarnAboutStatelessRefs = void 0;
5823
+ var didWarnAboutContextTypeOnFunctionComponent = void 0;
5824
+ var didWarnAboutGetDerivedStateOnFunctionComponent = void 0;
5825
+ var didWarnAboutFunctionRefs = void 0;
5704
5826
 
5705
5827
  {
5706
5828
  didWarnAboutBadClass = {};
5707
- didWarnAboutGetDerivedStateOnFunctionalComponent = {};
5708
- didWarnAboutStatelessRefs = {};
5829
+ didWarnAboutContextTypeOnFunctionComponent = {};
5830
+ didWarnAboutGetDerivedStateOnFunctionComponent = {};
5831
+ didWarnAboutFunctionRefs = {};
5709
5832
  }
5710
5833
 
5711
5834
  function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
@@ -5726,6 +5849,23 @@ function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpir
5726
5849
  }
5727
5850
  }
5728
5851
 
5852
+ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
5853
+ // This function is fork of reconcileChildren. It's used in cases where we
5854
+ // want to reconcile without matching against the existing set. This has the
5855
+ // effect of all current children being unmounted; even if the type and key
5856
+ // are the same, the old child is unmounted and a new child is created.
5857
+ //
5858
+ // To do this, we're going to go through the reconcile algorithm twice. In
5859
+ // the first pass, we schedule a deletion for all the current children by
5860
+ // passing null.
5861
+ workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
5862
+ // In the second pass, we mount the new children. The trick here is that we
5863
+ // pass null in place of where we usually pass the current child set. This has
5864
+ // the effect of remounting all children regardless of whether their their
5865
+ // identity matches.
5866
+ workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
5867
+ }
5868
+
5729
5869
  function updateForwardRef(current$$1, workInProgress, type, nextProps, renderExpirationTime) {
5730
5870
  var render = type.render;
5731
5871
  var ref = workInProgress.ref;
@@ -5748,21 +5888,64 @@ function updateForwardRef(current$$1, workInProgress, type, nextProps, renderExp
5748
5888
  }
5749
5889
 
5750
5890
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5751
- memoizeProps(workInProgress, nextProps);
5752
5891
  return workInProgress.child;
5753
5892
  }
5754
5893
 
5894
+ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
5895
+ if (current$$1 === null) {
5896
+ var type = Component.type;
5897
+ if (isSimpleFunctionComponent(type) && Component.compare === null) {
5898
+ // If this is a plain function component without default props,
5899
+ // and with only the default shallow comparison, we upgrade it
5900
+ // to a SimpleMemoComponent to allow fast path updates.
5901
+ workInProgress.tag = SimpleMemoComponent;
5902
+ workInProgress.type = type;
5903
+ return updateSimpleMemoComponent(current$$1, workInProgress, type, nextProps, updateExpirationTime, renderExpirationTime);
5904
+ }
5905
+ var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
5906
+ child.ref = workInProgress.ref;
5907
+ child.return = workInProgress;
5908
+ workInProgress.child = child;
5909
+ return child;
5910
+ }
5911
+ var currentChild = current$$1.child; // This is always exactly one child
5912
+ if (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime) {
5913
+ // This will be the props with resolved defaultProps,
5914
+ // unlike current.memoizedProps which will be the unresolved ones.
5915
+ var prevProps = currentChild.memoizedProps;
5916
+ // Default to shallow comparison
5917
+ var compare = Component.compare;
5918
+ compare = compare !== null ? compare : shallowEqual;
5919
+ if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
5920
+ return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
5921
+ }
5922
+ }
5923
+ var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
5924
+ newChild.ref = workInProgress.ref;
5925
+ newChild.return = workInProgress;
5926
+ workInProgress.child = newChild;
5927
+ return newChild;
5928
+ }
5929
+
5930
+ function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
5931
+ if (current$$1 !== null && (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime)) {
5932
+ var prevProps = current$$1.memoizedProps;
5933
+ if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
5934
+ return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
5935
+ }
5936
+ }
5937
+ return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
5938
+ }
5939
+
5755
5940
  function updateFragment(current$$1, workInProgress, renderExpirationTime) {
5756
5941
  var nextChildren = workInProgress.pendingProps;
5757
5942
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5758
- memoizeProps(workInProgress, nextChildren);
5759
5943
  return workInProgress.child;
5760
5944
  }
5761
5945
 
5762
5946
  function updateMode(current$$1, workInProgress, renderExpirationTime) {
5763
5947
  var nextChildren = workInProgress.pendingProps.children;
5764
5948
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5765
- memoizeProps(workInProgress, nextChildren);
5766
5949
  return workInProgress.child;
5767
5950
  }
5768
5951
 
@@ -5773,7 +5956,6 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
5773
5956
  var nextProps = workInProgress.pendingProps;
5774
5957
  var nextChildren = nextProps.children;
5775
5958
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5776
- memoizeProps(workInProgress, nextProps);
5777
5959
  return workInProgress.child;
5778
5960
  }
5779
5961
 
@@ -5785,7 +5967,7 @@ function markRef(current$$1, workInProgress) {
5785
5967
  }
5786
5968
  }
5787
5969
 
5788
- function updateFunctionalComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
5970
+ function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
5789
5971
  var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
5790
5972
  var context = getMaskedContext(workInProgress, unmaskedContext);
5791
5973
 
@@ -5801,7 +5983,6 @@ function updateFunctionalComponent(current$$1, workInProgress, Component, nextPr
5801
5983
  // React DevTools reads this flag.
5802
5984
  workInProgress.effectTag |= PerformedWork;
5803
5985
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5804
- memoizeProps(workInProgress, nextProps);
5805
5986
  return workInProgress.child;
5806
5987
  }
5807
5988
 
@@ -5818,17 +5999,26 @@ function updateClassComponent(current$$1, workInProgress, Component, nextProps,
5818
5999
  }
5819
6000
  prepareToReadContext(workInProgress, renderExpirationTime);
5820
6001
 
6002
+ var instance = workInProgress.stateNode;
5821
6003
  var shouldUpdate = void 0;
5822
- if (current$$1 === null) {
5823
- if (workInProgress.stateNode === null) {
5824
- // In the initial pass we might need to construct the instance.
5825
- constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5826
- mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5827
- shouldUpdate = true;
5828
- } else {
5829
- // In a resume, we'll already have an instance we can reuse.
5830
- shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5831
- }
6004
+ if (instance === null) {
6005
+ if (current$$1 !== null) {
6006
+ // An class component without an instance only mounts if it suspended
6007
+ // inside a non- concurrent tree, in an inconsistent state. We want to
6008
+ // tree it like a new mount, even though an empty version of it already
6009
+ // committed. Disconnect the alternate pointers.
6010
+ current$$1.alternate = null;
6011
+ workInProgress.alternate = null;
6012
+ // Since this is conceptually a new fiber, schedule a Placement effect
6013
+ workInProgress.effectTag |= Placement;
6014
+ }
6015
+ // In the initial pass we might need to construct the instance.
6016
+ constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6017
+ mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6018
+ shouldUpdate = true;
6019
+ } else if (current$$1 === null) {
6020
+ // In a resume, we'll already have an instance we can reuse.
6021
+ shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5832
6022
  } else {
5833
6023
  shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
5834
6024
  }
@@ -5855,7 +6045,7 @@ function finishClassComponent(current$$1, workInProgress, Component, shouldUpdat
5855
6045
  // Rerender
5856
6046
  ReactCurrentOwner$2.current = workInProgress;
5857
6047
  var nextChildren = void 0;
5858
- if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof Component.getDerivedStateFromCatch !== 'function')) {
6048
+ if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
5859
6049
  // If we captured an error, but getDerivedStateFrom catch is not defined,
5860
6050
  // unmount all the children. componentDidCatch will schedule an update to
5861
6051
  // re-render a fallback. This is temporary until we migrate everyone to
@@ -5880,19 +6070,18 @@ function finishClassComponent(current$$1, workInProgress, Component, shouldUpdat
5880
6070
  // React DevTools reads this flag.
5881
6071
  workInProgress.effectTag |= PerformedWork;
5882
6072
  if (current$$1 !== null && didCaptureError) {
5883
- // If we're recovering from an error, reconcile twice: first to delete
5884
- // all the existing children.
5885
- reconcileChildren(current$$1, workInProgress, null, renderExpirationTime);
5886
- workInProgress.child = null;
5887
- // Now we can continue reconciling like normal. This has the effect of
5888
- // remounting all children regardless of whether their their
5889
- // identity matches.
6073
+ // If we're recovering from an error, reconcile without reusing any of
6074
+ // the existing children. Conceptually, the normal children and the children
6075
+ // that are shown on error are two different sets, so we shouldn't reuse
6076
+ // normal children even if their identities match.
6077
+ forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
6078
+ } else {
6079
+ reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5890
6080
  }
5891
- reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5892
- // Memoize props and state using the values we just used to render.
6081
+
6082
+ // Memoize state using the values we just used to render.
5893
6083
  // TODO: Restructure so we never read values from the instance.
5894
- memoizeState(workInProgress, instance.state);
5895
- memoizeProps(workInProgress, instance.props);
6084
+ workInProgress.memoizedState = instance.state;
5896
6085
 
5897
6086
  // The context might have changed so we need to recalculate it.
5898
6087
  if (hasContext) {
@@ -5986,15 +6175,13 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
5986
6175
  markRef(current$$1, workInProgress);
5987
6176
 
5988
6177
  // Check the host config to see if the children are offscreen/hidden.
5989
- if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
6178
+ if (renderExpirationTime !== Never && workInProgress.mode & ConcurrentMode && shouldDeprioritizeSubtree(type, nextProps)) {
5990
6179
  // Schedule this fiber to re-render at offscreen priority. Then bailout.
5991
6180
  workInProgress.expirationTime = Never;
5992
- workInProgress.memoizedProps = nextProps;
5993
6181
  return null;
5994
6182
  }
5995
6183
 
5996
6184
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5997
- memoizeProps(workInProgress, nextProps);
5998
6185
  return workInProgress.child;
5999
6186
  }
6000
6187
 
@@ -6002,8 +6189,6 @@ function updateHostText(current$$1, workInProgress) {
6002
6189
  if (current$$1 === null) {
6003
6190
  tryToClaimNextHydratableInstance(workInProgress);
6004
6191
  }
6005
- var nextProps = workInProgress.pendingProps;
6006
- memoizeProps(workInProgress, nextProps);
6007
6192
  // Nothing to do here. This is terminal. We'll do the completion step
6008
6193
  // immediately after.
6009
6194
  return null;
@@ -6024,36 +6209,110 @@ function resolveDefaultProps(Component, baseProps) {
6024
6209
  return baseProps;
6025
6210
  }
6026
6211
 
6027
- function mountIndeterminateComponent(current$$1, workInProgress, Component, renderExpirationTime) {
6028
- !(current$$1 === null) ? invariant(false, 'An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue.') : void 0;
6212
+ function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
6213
+ if (_current !== null) {
6214
+ // An lazy component only mounts if it suspended inside a non-
6215
+ // concurrent tree, in an inconsistent state. We want to tree it like
6216
+ // a new mount, even though an empty version of it already committed.
6217
+ // Disconnect the alternate pointers.
6218
+ _current.alternate = null;
6219
+ workInProgress.alternate = null;
6220
+ // Since this is conceptually a new fiber, schedule a Placement effect
6221
+ workInProgress.effectTag |= Placement;
6222
+ }
6029
6223
 
6030
6224
  var props = workInProgress.pendingProps;
6031
- if (typeof Component === 'object' && Component !== null && typeof Component.then === 'function') {
6032
- Component = readLazyComponentType(Component);
6033
- var resolvedTag = workInProgress.tag = resolveLazyComponentTag(workInProgress, Component);
6034
- var resolvedProps = resolveDefaultProps(Component, props);
6035
- switch (resolvedTag) {
6036
- case FunctionalComponentLazy:
6037
- {
6038
- return updateFunctionalComponent(current$$1, workInProgress, Component, resolvedProps, renderExpirationTime);
6039
- }
6040
- case ClassComponentLazy:
6041
- {
6042
- return updateClassComponent(current$$1, workInProgress, Component, resolvedProps, renderExpirationTime);
6043
- }
6044
- case ForwardRefLazy:
6045
- {
6046
- return updateForwardRef(current$$1, workInProgress, Component, resolvedProps, renderExpirationTime);
6047
- }
6048
- default:
6049
- {
6050
- // This message intentionally doesn't metion ForwardRef because the
6051
- // fact that it's a separate type of work is an implementation detail.
6052
- invariant(false, 'Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.', Component);
6053
- }
6054
- }
6225
+ // We can't start a User Timing measurement with correct label yet.
6226
+ // Cancel and resume right after we know the tag.
6227
+ cancelWorkTimer(workInProgress);
6228
+ var Component = readLazyComponentType(elementType);
6229
+ // Store the unwrapped component in the type.
6230
+ workInProgress.type = Component;
6231
+ var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
6232
+ startWorkTimer(workInProgress);
6233
+ var resolvedProps = resolveDefaultProps(Component, props);
6234
+ var child = void 0;
6235
+ switch (resolvedTag) {
6236
+ case FunctionComponent:
6237
+ {
6238
+ child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
6239
+ break;
6240
+ }
6241
+ case ClassComponent:
6242
+ {
6243
+ child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
6244
+ break;
6245
+ }
6246
+ case ForwardRef:
6247
+ {
6248
+ child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
6249
+ break;
6250
+ }
6251
+ case MemoComponent:
6252
+ {
6253
+ child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
6254
+ updateExpirationTime, renderExpirationTime);
6255
+ break;
6256
+ }
6257
+ default:
6258
+ {
6259
+ // This message intentionally doesn't metion ForwardRef or MemoComponent
6260
+ // because the fact that it's a separate type of work is an
6261
+ // implementation detail.
6262
+ invariant(false, 'Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.', Component);
6263
+ }
6264
+ }
6265
+ return child;
6266
+ }
6267
+
6268
+ function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
6269
+ if (_current !== null) {
6270
+ // An incomplete component only mounts if it suspended inside a non-
6271
+ // concurrent tree, in an inconsistent state. We want to tree it like
6272
+ // a new mount, even though an empty version of it already committed.
6273
+ // Disconnect the alternate pointers.
6274
+ _current.alternate = null;
6275
+ workInProgress.alternate = null;
6276
+ // Since this is conceptually a new fiber, schedule a Placement effect
6277
+ workInProgress.effectTag |= Placement;
6278
+ }
6279
+
6280
+ // Promote the fiber to a class and try rendering again.
6281
+ workInProgress.tag = ClassComponent;
6282
+
6283
+ // The rest of this function is a fork of `updateClassComponent`
6284
+
6285
+ // Push context providers early to prevent context stack mismatches.
6286
+ // During mounting we don't know the child context yet as the instance doesn't exist.
6287
+ // We will invalidate the child context in finishClassComponent() right after rendering.
6288
+ var hasContext = void 0;
6289
+ if (isContextProvider(Component)) {
6290
+ hasContext = true;
6291
+ pushContextProvider(workInProgress);
6292
+ } else {
6293
+ hasContext = false;
6294
+ }
6295
+ prepareToReadContext(workInProgress, renderExpirationTime);
6296
+
6297
+ constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6298
+ mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6299
+
6300
+ return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
6301
+ }
6302
+
6303
+ function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
6304
+ if (_current !== null) {
6305
+ // An indeterminate component only mounts if it suspended inside a non-
6306
+ // concurrent tree, in an inconsistent state. We want to tree it like
6307
+ // a new mount, even though an empty version of it already committed.
6308
+ // Disconnect the alternate pointers.
6309
+ _current.alternate = null;
6310
+ workInProgress.alternate = null;
6311
+ // Since this is conceptually a new fiber, schedule a Placement effect
6312
+ workInProgress.effectTag |= Placement;
6055
6313
  }
6056
6314
 
6315
+ var props = workInProgress.pendingProps;
6057
6316
  var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
6058
6317
  var context = getMaskedContext(workInProgress, unmaskedContext);
6059
6318
 
@@ -6105,13 +6364,13 @@ function mountIndeterminateComponent(current$$1, workInProgress, Component, rend
6105
6364
 
6106
6365
  adoptClassInstance(workInProgress, value);
6107
6366
  mountClassInstance(workInProgress, Component, props, renderExpirationTime);
6108
- return finishClassComponent(current$$1, workInProgress, Component, true, hasContext, renderExpirationTime);
6367
+ return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
6109
6368
  } else {
6110
- // Proceed under the assumption that this is a functional component
6111
- workInProgress.tag = FunctionalComponent;
6369
+ // Proceed under the assumption that this is a function component
6370
+ workInProgress.tag = FunctionComponent;
6112
6371
  {
6113
6372
  if (Component) {
6114
- !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component') : void 0;
6373
+ !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
6115
6374
  }
6116
6375
  if (workInProgress.ref !== null) {
6117
6376
  var info = '';
@@ -6125,81 +6384,190 @@ function mountIndeterminateComponent(current$$1, workInProgress, Component, rend
6125
6384
  if (debugSource) {
6126
6385
  warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
6127
6386
  }
6128
- if (!didWarnAboutStatelessRefs[warningKey]) {
6129
- didWarnAboutStatelessRefs[warningKey] = true;
6130
- warning$1(false, 'Stateless function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s', info);
6387
+ if (!didWarnAboutFunctionRefs[warningKey]) {
6388
+ didWarnAboutFunctionRefs[warningKey] = true;
6389
+ warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s', info);
6131
6390
  }
6132
6391
  }
6133
6392
 
6134
6393
  if (typeof Component.getDerivedStateFromProps === 'function') {
6135
6394
  var _componentName = getComponentName(Component) || 'Unknown';
6136
6395
 
6137
- if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) {
6138
- warningWithoutStack$1(false, '%s: Stateless functional components do not support getDerivedStateFromProps.', _componentName);
6139
- didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName] = true;
6396
+ if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName]) {
6397
+ warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName);
6398
+ didWarnAboutGetDerivedStateOnFunctionComponent[_componentName] = true;
6399
+ }
6400
+ }
6401
+
6402
+ if (typeof Component.contextType === 'object' && Component.contextType !== null) {
6403
+ var _componentName2 = getComponentName(Component) || 'Unknown';
6404
+
6405
+ if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) {
6406
+ warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName2);
6407
+ didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true;
6140
6408
  }
6141
6409
  }
6142
6410
  }
6143
- reconcileChildren(current$$1, workInProgress, value, renderExpirationTime);
6144
- memoizeProps(workInProgress, props);
6411
+ reconcileChildren(null, workInProgress, value, renderExpirationTime);
6145
6412
  return workInProgress.child;
6146
6413
  }
6147
6414
  }
6148
6415
 
6149
- function updatePlaceholderComponent(current$$1, workInProgress, renderExpirationTime) {
6150
- if (enableSuspense) {
6151
- var nextProps = workInProgress.pendingProps;
6152
-
6153
- // Check if we already attempted to render the normal state. If we did,
6154
- // and we timed out, render the placeholder state.
6155
- var alreadyCaptured = (workInProgress.effectTag & DidCapture) === NoEffect;
6156
-
6157
- var nextDidTimeout = void 0;
6158
- if (current$$1 !== null && workInProgress.updateQueue !== null) {
6159
- // We're outside strict mode. Something inside this Placeholder boundary
6160
- // suspended during the last commit. Switch to the placholder.
6161
- workInProgress.updateQueue = null;
6162
- nextDidTimeout = true;
6163
- // If we're recovering from an error, reconcile twice: first to delete
6164
- // all the existing children.
6165
- reconcileChildren(current$$1, workInProgress, null, renderExpirationTime);
6166
- current$$1.child = null;
6167
- // Now we can continue reconciling like normal. This has the effect of
6168
- // remounting all children regardless of whether their their
6169
- // identity matches.
6170
- } else {
6171
- nextDidTimeout = !alreadyCaptured;
6172
- }
6416
+ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
6417
+ var mode = workInProgress.mode;
6418
+ var nextProps = workInProgress.pendingProps;
6173
6419
 
6174
- if ((workInProgress.mode & StrictMode) !== NoEffect) {
6175
- if (nextDidTimeout) {
6176
- // If the timed-out view commits, schedule an update effect to record
6177
- // the committed time.
6178
- workInProgress.effectTag |= Update;
6420
+ // We should attempt to render the primary children unless this boundary
6421
+ // already suspended during this render (`alreadyCaptured` is true).
6422
+ var nextState = workInProgress.memoizedState;
6423
+ if (nextState === null) {
6424
+ // An empty suspense state means this boundary has not yet timed out.
6425
+ } else {
6426
+ if (!nextState.alreadyCaptured) {
6427
+ // Since we haven't already suspended during this commit, clear the
6428
+ // existing suspense state. We'll try rendering again.
6429
+ nextState = null;
6430
+ } else {
6431
+ // Something in this boundary's subtree already suspended. Switch to
6432
+ // rendering the fallback children. Set `alreadyCaptured` to true.
6433
+ if (current$$1 !== null && nextState === current$$1.memoizedState) {
6434
+ // Create a new suspense state to avoid mutating the current tree's.
6435
+ nextState = {
6436
+ alreadyCaptured: true,
6437
+ didTimeout: true,
6438
+ timedOutAt: nextState.timedOutAt
6439
+ };
6179
6440
  } else {
6180
- // The state node points to the time at which placeholder timed out.
6181
- // We can clear it once we switch back to the normal children.
6182
- workInProgress.stateNode = null;
6441
+ // Already have a clone, so it's safe to mutate.
6442
+ nextState.alreadyCaptured = true;
6443
+ nextState.didTimeout = true;
6183
6444
  }
6184
6445
  }
6446
+ }
6447
+ var nextDidTimeout = nextState !== null && nextState.didTimeout;
6185
6448
 
6186
- // If the `children` prop is a function, treat it like a render prop.
6187
- // TODO: This is temporary until we finalize a lower level API.
6188
- var children = nextProps.children;
6189
- var nextChildren = void 0;
6190
- if (typeof children === 'function') {
6191
- nextChildren = children(nextDidTimeout);
6449
+ // This next part is a bit confusing. If the children timeout, we switch to
6450
+ // showing the fallback children in place of the "primary" children.
6451
+ // However, we don't want to delete the primary children because then their
6452
+ // state will be lost (both the React state and the host state, e.g.
6453
+ // uncontrolled form inputs). Instead we keep them mounted and hide them.
6454
+ // Both the fallback children AND the primary children are rendered at the
6455
+ // same time. Once the primary children are un-suspended, we can delete
6456
+ // the fallback children — don't need to preserve their state.
6457
+ //
6458
+ // The two sets of children are siblings in the host environment, but
6459
+ // semantically, for purposes of reconciliation, they are two separate sets.
6460
+ // So we store them using two fragment fibers.
6461
+ //
6462
+ // However, we want to avoid allocating extra fibers for every placeholder.
6463
+ // They're only necessary when the children time out, because that's the
6464
+ // only time when both sets are mounted.
6465
+ //
6466
+ // So, the extra fragment fibers are only used if the children time out.
6467
+ // Otherwise, we render the primary children directly. This requires some
6468
+ // custom reconciliation logic to preserve the state of the primary
6469
+ // children. It's essentially a very basic form of re-parenting.
6470
+
6471
+ // `child` points to the child fiber. In the normal case, this is the first
6472
+ // fiber of the primary children set. In the timed-out case, it's a
6473
+ // a fragment fiber containing the primary children.
6474
+ var child = void 0;
6475
+ // `next` points to the next fiber React should render. In the normal case,
6476
+ // it's the same as `child`: the first fiber of the primary children set.
6477
+ // In the timed-out case, it's a fragment fiber containing the *fallback*
6478
+ // children -- we skip over the primary children entirely.
6479
+ var next = void 0;
6480
+ if (current$$1 === null) {
6481
+ // This is the initial mount. This branch is pretty simple because there's
6482
+ // no previous state that needs to be preserved.
6483
+ if (nextDidTimeout) {
6484
+ // Mount separate fragments for primary and fallback children.
6485
+ var nextFallbackChildren = nextProps.fallback;
6486
+ var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
6487
+ var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
6488
+ primaryChildFragment.sibling = fallbackChildFragment;
6489
+ child = primaryChildFragment;
6490
+ // Skip the primary children, and continue working on the
6491
+ // fallback children.
6492
+ next = fallbackChildFragment;
6493
+ child.return = next.return = workInProgress;
6192
6494
  } else {
6193
- nextChildren = nextDidTimeout ? nextProps.fallback : children;
6495
+ // Mount the primary children without an intermediate fragment fiber.
6496
+ var nextPrimaryChildren = nextProps.children;
6497
+ child = next = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
6194
6498
  }
6195
-
6196
- workInProgress.memoizedProps = nextProps;
6197
- workInProgress.memoizedState = nextDidTimeout;
6198
- reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
6199
- return workInProgress.child;
6200
6499
  } else {
6201
- return null;
6500
+ // This is an update. This branch is more complicated because we need to
6501
+ // ensure the state of the primary children is preserved.
6502
+ var prevState = current$$1.memoizedState;
6503
+ var prevDidTimeout = prevState !== null && prevState.didTimeout;
6504
+ if (prevDidTimeout) {
6505
+ // The current tree already timed out. That means each child set is
6506
+ var currentPrimaryChildFragment = current$$1.child;
6507
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
6508
+ if (nextDidTimeout) {
6509
+ // Still timed out. Reuse the current primary children by cloning
6510
+ // its fragment. We're going to skip over these entirely.
6511
+ var _nextFallbackChildren = nextProps.fallback;
6512
+ var _primaryChildFragment = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
6513
+ _primaryChildFragment.effectTag |= Placement;
6514
+ // Clone the fallback child fragment, too. These we'll continue
6515
+ // working on.
6516
+ var _fallbackChildFragment = _primaryChildFragment.sibling = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren, currentFallbackChildFragment.expirationTime);
6517
+ _fallbackChildFragment.effectTag |= Placement;
6518
+ child = _primaryChildFragment;
6519
+ _primaryChildFragment.childExpirationTime = NoWork;
6520
+ // Skip the primary children, and continue working on the
6521
+ // fallback children.
6522
+ next = _fallbackChildFragment;
6523
+ child.return = next.return = workInProgress;
6524
+ } else {
6525
+ // No longer suspended. Switch back to showing the primary children,
6526
+ // and remove the intermediate fragment fiber.
6527
+ var _nextPrimaryChildren = nextProps.children;
6528
+ var currentPrimaryChild = currentPrimaryChildFragment.child;
6529
+ var currentFallbackChild = currentFallbackChildFragment.child;
6530
+ var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
6531
+ // Delete the fallback children.
6532
+ reconcileChildFibers(workInProgress, currentFallbackChild, null, renderExpirationTime);
6533
+ // Continue rendering the children, like we normally do.
6534
+ child = next = primaryChild;
6535
+ }
6536
+ } else {
6537
+ // The current tree has not already timed out. That means the primary
6538
+ var _currentPrimaryChild = current$$1.child;
6539
+ if (nextDidTimeout) {
6540
+ // Timed out. Wrap the children in a fragment fiber to keep them
6541
+ // separate from the fallback children.
6542
+ var _nextFallbackChildren2 = nextProps.fallback;
6543
+ var _primaryChildFragment2 = createFiberFromFragment(
6544
+ // It shouldn't matter what the pending props are because we aren't
6545
+ // going to render this fragment.
6546
+ null, mode, NoWork, null);
6547
+ _primaryChildFragment2.effectTag |= Placement;
6548
+ _primaryChildFragment2.child = _currentPrimaryChild;
6549
+ _currentPrimaryChild.return = _primaryChildFragment2;
6550
+ // Create a fragment from the fallback children, too.
6551
+ var _fallbackChildFragment2 = _primaryChildFragment2.sibling = createFiberFromFragment(_nextFallbackChildren2, mode, renderExpirationTime, null);
6552
+ _fallbackChildFragment2.effectTag |= Placement;
6553
+ child = _primaryChildFragment2;
6554
+ _primaryChildFragment2.childExpirationTime = NoWork;
6555
+ // Skip the primary children, and continue working on the
6556
+ // fallback children.
6557
+ next = _fallbackChildFragment2;
6558
+ child.return = next.return = workInProgress;
6559
+ } else {
6560
+ // Still haven't timed out. Continue rendering the children, like we
6561
+ // normally do.
6562
+ var _nextPrimaryChildren2 = nextProps.children;
6563
+ next = child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
6564
+ }
6565
+ }
6202
6566
  }
6567
+
6568
+ workInProgress.memoizedState = nextState;
6569
+ workInProgress.child = child;
6570
+ return next;
6203
6571
  }
6204
6572
 
6205
6573
  function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
@@ -6212,10 +6580,8 @@ function updatePortalComponent(current$$1, workInProgress, renderExpirationTime)
6212
6580
  // the root always starts with a "current" with a null child.
6213
6581
  // TODO: Consider unifying this with how the root works.
6214
6582
  workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
6215
- memoizeProps(workInProgress, nextChildren);
6216
6583
  } else {
6217
6584
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
6218
- memoizeProps(workInProgress, nextChildren);
6219
6585
  }
6220
6586
  return workInProgress.child;
6221
6587
  }
@@ -6228,7 +6594,6 @@ function updateContextProvider(current$$1, workInProgress, renderExpirationTime)
6228
6594
  var oldProps = workInProgress.memoizedProps;
6229
6595
 
6230
6596
  var newValue = newProps.value;
6231
- workInProgress.memoizedProps = newProps;
6232
6597
 
6233
6598
  {
6234
6599
  var providerPropTypes = workInProgress.type.propTypes;
@@ -6260,8 +6625,32 @@ function updateContextProvider(current$$1, workInProgress, renderExpirationTime)
6260
6625
  return workInProgress.child;
6261
6626
  }
6262
6627
 
6628
+ var hasWarnedAboutUsingContextAsConsumer = false;
6629
+
6263
6630
  function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
6264
6631
  var context = workInProgress.type;
6632
+ // The logic below for Context differs depending on PROD or DEV mode. In
6633
+ // DEV mode, we create a separate object for Context.Consumer that acts
6634
+ // like a proxy to Context. This proxy object adds unnecessary code in PROD
6635
+ // so we use the old behaviour (Context.Consumer references Context) to
6636
+ // reduce size and overhead. The separate object references context via
6637
+ // a property called "_context", which also gives us the ability to check
6638
+ // in DEV mode if this property exists or not and warn if it does not.
6639
+ {
6640
+ if (context._context === undefined) {
6641
+ // This may be because it's a Context (rather than a Consumer).
6642
+ // Or it may be because it's older React where they're the same thing.
6643
+ // We only want to warn if we're sure it's a new React.
6644
+ if (context !== context.Consumer) {
6645
+ if (!hasWarnedAboutUsingContextAsConsumer) {
6646
+ hasWarnedAboutUsingContextAsConsumer = true;
6647
+ warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
6648
+ }
6649
+ }
6650
+ } else {
6651
+ context = context._context;
6652
+ }
6653
+ }
6265
6654
  var newProps = workInProgress.pendingProps;
6266
6655
  var render = newProps.children;
6267
6656
 
@@ -6282,7 +6671,6 @@ function updateContextConsumer(current$$1, workInProgress, renderExpirationTime)
6282
6671
  // React DevTools reads this flag.
6283
6672
  workInProgress.effectTag |= PerformedWork;
6284
6673
  reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
6285
- workInProgress.memoizedProps = newProps;
6286
6674
  return workInProgress.child;
6287
6675
  }
6288
6676
 
@@ -6333,64 +6721,78 @@ function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirati
6333
6721
  }
6334
6722
  }
6335
6723
 
6336
- // TODO: Delete memoizeProps/State and move to reconcile/bailout instead
6337
- function memoizeProps(workInProgress, nextProps) {
6338
- workInProgress.memoizedProps = nextProps;
6339
- }
6340
-
6341
- function memoizeState(workInProgress, nextState) {
6342
- workInProgress.memoizedState = nextState;
6343
- // Don't reset the updateQueue, in case there are pending updates. Resetting
6344
- // is handled by processUpdateQueue.
6345
- }
6346
-
6347
6724
  function beginWork(current$$1, workInProgress, renderExpirationTime) {
6348
6725
  var updateExpirationTime = workInProgress.expirationTime;
6349
- if (!hasContextChanged() && (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime)) {
6350
- // This fiber does not have any pending work. Bailout without entering
6351
- // the begin phase. There's still some bookkeeping we that needs to be done
6352
- // in this optimized path, mostly pushing stuff onto the stack.
6353
- switch (workInProgress.tag) {
6354
- case HostRoot:
6355
- pushHostRootContext(workInProgress);
6356
- resetHydrationState();
6357
- break;
6358
- case HostComponent:
6359
- pushHostContext(workInProgress);
6360
- break;
6361
- case ClassComponent:
6362
- {
6363
- var Component = workInProgress.type;
6364
- if (isContextProvider(Component)) {
6365
- pushContextProvider(workInProgress);
6366
- }
6726
+
6727
+ if (current$$1 !== null) {
6728
+ var oldProps = current$$1.memoizedProps;
6729
+ var newProps = workInProgress.pendingProps;
6730
+ if (oldProps === newProps && !hasContextChanged() && (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime)) {
6731
+ // This fiber does not have any pending work. Bailout without entering
6732
+ // the begin phase. There's still some bookkeeping we that needs to be done
6733
+ // in this optimized path, mostly pushing stuff onto the stack.
6734
+ switch (workInProgress.tag) {
6735
+ case HostRoot:
6736
+ pushHostRootContext(workInProgress);
6737
+ resetHydrationState();
6367
6738
  break;
6368
- }
6369
- case ClassComponentLazy:
6370
- {
6371
- var thenable = workInProgress.type;
6372
- var _Component = getResultFromResolvedThenable(thenable);
6373
- if (isContextProvider(_Component)) {
6374
- pushContextProvider(workInProgress);
6375
- }
6739
+ case HostComponent:
6740
+ pushHostContext(workInProgress);
6376
6741
  break;
6377
- }
6378
- case HostPortal:
6379
- pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
6380
- break;
6381
- case ContextProvider:
6382
- {
6383
- var newValue = workInProgress.memoizedProps.value;
6384
- pushProvider(workInProgress, newValue);
6742
+ case ClassComponent:
6743
+ {
6744
+ var Component = workInProgress.type;
6745
+ if (isContextProvider(Component)) {
6746
+ pushContextProvider(workInProgress);
6747
+ }
6748
+ break;
6749
+ }
6750
+ case HostPortal:
6751
+ pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
6385
6752
  break;
6386
- }
6387
- case Profiler:
6388
- if (enableProfilerTimer) {
6389
- workInProgress.effectTag |= Update;
6390
- }
6391
- break;
6753
+ case ContextProvider:
6754
+ {
6755
+ var newValue = workInProgress.memoizedProps.value;
6756
+ pushProvider(workInProgress, newValue);
6757
+ break;
6758
+ }
6759
+ case Profiler:
6760
+ if (enableProfilerTimer) {
6761
+ workInProgress.effectTag |= Update;
6762
+ }
6763
+ break;
6764
+ case SuspenseComponent:
6765
+ {
6766
+ var state = workInProgress.memoizedState;
6767
+ var didTimeout = state !== null && state.didTimeout;
6768
+ if (didTimeout) {
6769
+ // If this boundary is currently timed out, we need to decide
6770
+ // whether to retry the primary children, or to skip over it and
6771
+ // go straight to the fallback. Check the priority of the primary
6772
+ var primaryChildFragment = workInProgress.child;
6773
+ var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
6774
+ if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime <= renderExpirationTime) {
6775
+ // The primary children have pending work. Use the normal path
6776
+ // to attempt to render the primary children again.
6777
+ return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
6778
+ } else {
6779
+ // The primary children do not have pending work with sufficient
6780
+ // priority. Bailout.
6781
+ var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6782
+ if (child !== null) {
6783
+ // The fallback children have pending work. Skip over the
6784
+ // primary children and work on the fallback.
6785
+ return child.sibling;
6786
+ } else {
6787
+ return null;
6788
+ }
6789
+ }
6790
+ }
6791
+ break;
6792
+ }
6793
+ }
6794
+ return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6392
6795
  }
6393
- return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6394
6796
  }
6395
6797
 
6396
6798
  // Before entering the begin phase, clear the expiration time.
@@ -6399,38 +6801,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
6399
6801
  switch (workInProgress.tag) {
6400
6802
  case IndeterminateComponent:
6401
6803
  {
6402
- var _Component3 = workInProgress.type;
6403
- return mountIndeterminateComponent(current$$1, workInProgress, _Component3, renderExpirationTime);
6804
+ var elementType = workInProgress.elementType;
6805
+ return mountIndeterminateComponent(current$$1, workInProgress, elementType, renderExpirationTime);
6404
6806
  }
6405
- case FunctionalComponent:
6807
+ case LazyComponent:
6406
6808
  {
6407
- var _Component4 = workInProgress.type;
6408
- var _unresolvedProps = workInProgress.pendingProps;
6409
- return updateFunctionalComponent(current$$1, workInProgress, _Component4, _unresolvedProps, renderExpirationTime);
6809
+ var _elementType = workInProgress.elementType;
6810
+ return mountLazyComponent(current$$1, workInProgress, _elementType, updateExpirationTime, renderExpirationTime);
6410
6811
  }
6411
- case FunctionalComponentLazy:
6812
+ case FunctionComponent:
6412
6813
  {
6413
- var _thenable2 = workInProgress.type;
6414
- var _Component5 = getResultFromResolvedThenable(_thenable2);
6415
- var _unresolvedProps2 = workInProgress.pendingProps;
6416
- var _child = updateFunctionalComponent(current$$1, workInProgress, _Component5, resolveDefaultProps(_Component5, _unresolvedProps2), renderExpirationTime);
6417
- workInProgress.memoizedProps = _unresolvedProps2;
6418
- return _child;
6814
+ var _Component = workInProgress.type;
6815
+ var unresolvedProps = workInProgress.pendingProps;
6816
+ var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
6817
+ return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
6419
6818
  }
6420
6819
  case ClassComponent:
6421
6820
  {
6422
- var _Component6 = workInProgress.type;
6423
- var _unresolvedProps3 = workInProgress.pendingProps;
6424
- return updateClassComponent(current$$1, workInProgress, _Component6, _unresolvedProps3, renderExpirationTime);
6425
- }
6426
- case ClassComponentLazy:
6427
- {
6428
- var _thenable3 = workInProgress.type;
6429
- var _Component7 = getResultFromResolvedThenable(_thenable3);
6430
- var _unresolvedProps4 = workInProgress.pendingProps;
6431
- var _child2 = updateClassComponent(current$$1, workInProgress, _Component7, resolveDefaultProps(_Component7, _unresolvedProps4), renderExpirationTime);
6432
- workInProgress.memoizedProps = _unresolvedProps4;
6433
- return _child2;
6821
+ var _Component2 = workInProgress.type;
6822
+ var _unresolvedProps = workInProgress.pendingProps;
6823
+ var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
6824
+ return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
6434
6825
  }
6435
6826
  case HostRoot:
6436
6827
  return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
@@ -6438,22 +6829,17 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
6438
6829
  return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
6439
6830
  case HostText:
6440
6831
  return updateHostText(current$$1, workInProgress);
6441
- case PlaceholderComponent:
6442
- return updatePlaceholderComponent(current$$1, workInProgress, renderExpirationTime);
6832
+ case SuspenseComponent:
6833
+ return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
6443
6834
  case HostPortal:
6444
6835
  return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
6445
6836
  case ForwardRef:
6446
6837
  {
6447
6838
  var type = workInProgress.type;
6448
- return updateForwardRef(current$$1, workInProgress, type, workInProgress.pendingProps, renderExpirationTime);
6449
- }
6450
- case ForwardRefLazy:
6451
- var _thenable = workInProgress.type;
6452
- var _Component2 = getResultFromResolvedThenable(_thenable);
6453
- var unresolvedProps = workInProgress.pendingProps;
6454
- var child = updateForwardRef(current$$1, workInProgress, _Component2, resolveDefaultProps(_Component2, unresolvedProps), renderExpirationTime);
6455
- workInProgress.memoizedProps = unresolvedProps;
6456
- return child;
6839
+ var _unresolvedProps2 = workInProgress.pendingProps;
6840
+ var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
6841
+ return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
6842
+ }
6457
6843
  case Fragment:
6458
6844
  return updateFragment(current$$1, workInProgress, renderExpirationTime);
6459
6845
  case Mode:
@@ -6464,6 +6850,24 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
6464
6850
  return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
6465
6851
  case ContextConsumer:
6466
6852
  return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
6853
+ case MemoComponent:
6854
+ {
6855
+ var _type = workInProgress.type;
6856
+ var _unresolvedProps3 = workInProgress.pendingProps;
6857
+ var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3);
6858
+ return updateMemoComponent(current$$1, workInProgress, _type, _resolvedProps3, updateExpirationTime, renderExpirationTime);
6859
+ }
6860
+ case SimpleMemoComponent:
6861
+ {
6862
+ return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
6863
+ }
6864
+ case IncompleteClassComponent:
6865
+ {
6866
+ var _Component3 = workInProgress.type;
6867
+ var _unresolvedProps4 = workInProgress.pendingProps;
6868
+ var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
6869
+ return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
6870
+ }
6467
6871
  default:
6468
6872
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
6469
6873
  }
@@ -6479,42 +6883,43 @@ function markRef$1(workInProgress) {
6479
6883
  workInProgress.effectTag |= Ref;
6480
6884
  }
6481
6885
 
6482
- function appendAllChildren(parent, workInProgress) {
6483
- // We only have the top Fiber that was created but we need recurse down its
6484
- // children to find all the terminal nodes.
6485
- var node = workInProgress.child;
6486
- while (node !== null) {
6487
- if (node.tag === HostComponent || node.tag === HostText) {
6488
- appendInitialChild(parent, node.stateNode);
6489
- } else if (node.tag === HostPortal) {
6490
- // If we have a portal child, then we don't want to traverse
6491
- // down its children. Instead, we'll get insertions from each child in
6492
- // the portal directly.
6493
- } else if (node.child !== null) {
6494
- node.child.return = node;
6495
- node = node.child;
6496
- continue;
6497
- }
6498
- if (node === workInProgress) {
6499
- return;
6500
- }
6501
- while (node.sibling === null) {
6502
- if (node.return === null || node.return === workInProgress) {
6503
- return;
6504
- }
6505
- node = node.return;
6506
- }
6507
- node.sibling.return = node.return;
6508
- node = node.sibling;
6509
- }
6510
- }
6511
-
6886
+ var appendAllChildren = void 0;
6512
6887
  var updateHostContainer = void 0;
6513
6888
  var updateHostComponent$1 = void 0;
6514
6889
  var updateHostText$1 = void 0;
6515
6890
  if (supportsMutation) {
6516
6891
  // Mutation mode
6517
6892
 
6893
+ appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
6894
+ // We only have the top Fiber that was created but we need recurse down its
6895
+ // children to find all the terminal nodes.
6896
+ var node = workInProgress.child;
6897
+ while (node !== null) {
6898
+ if (node.tag === HostComponent || node.tag === HostText) {
6899
+ appendInitialChild(parent, node.stateNode);
6900
+ } else if (node.tag === HostPortal) {
6901
+ // If we have a portal child, then we don't want to traverse
6902
+ // down its children. Instead, we'll get insertions from each child in
6903
+ // the portal directly.
6904
+ } else if (node.child !== null) {
6905
+ node.child.return = node;
6906
+ node = node.child;
6907
+ continue;
6908
+ }
6909
+ if (node === workInProgress) {
6910
+ return;
6911
+ }
6912
+ while (node.sibling === null) {
6913
+ if (node.return === null || node.return === workInProgress) {
6914
+ return;
6915
+ }
6916
+ node = node.return;
6917
+ }
6918
+ node.sibling.return = node.return;
6919
+ node = node.sibling;
6920
+ }
6921
+ };
6922
+
6518
6923
  updateHostContainer = function (workInProgress) {
6519
6924
  // Noop
6520
6925
  };
@@ -6555,23 +6960,167 @@ if (supportsMutation) {
6555
6960
  } else if (supportsPersistence) {
6556
6961
  // Persistent host tree mode
6557
6962
 
6963
+ appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
6964
+ // We only have the top Fiber that was created but we need recurse down its
6965
+ // children to find all the terminal nodes.
6966
+ var node = workInProgress.child;
6967
+ while (node !== null) {
6968
+ // eslint-disable-next-line no-labels
6969
+ branches: if (node.tag === HostComponent) {
6970
+ var instance = node.stateNode;
6971
+ if (needsVisibilityToggle) {
6972
+ var props = node.memoizedProps;
6973
+ var type = node.type;
6974
+ if (isHidden) {
6975
+ // This child is inside a timed out tree. Hide it.
6976
+ instance = cloneHiddenInstance(instance, type, props, node);
6977
+ } else {
6978
+ // This child was previously inside a timed out tree. If it was not
6979
+ // updated during this render, it may need to be unhidden. Clone
6980
+ // again to be sure.
6981
+ instance = cloneUnhiddenInstance(instance, type, props, node);
6982
+ }
6983
+ node.stateNode = instance;
6984
+ }
6985
+ appendInitialChild(parent, instance);
6986
+ } else if (node.tag === HostText) {
6987
+ var _instance = node.stateNode;
6988
+ if (needsVisibilityToggle) {
6989
+ var text = node.memoizedProps;
6990
+ var rootContainerInstance = getRootHostContainer();
6991
+ var currentHostContext = getHostContext();
6992
+ if (isHidden) {
6993
+ _instance = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
6994
+ } else {
6995
+ _instance = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
6996
+ }
6997
+ node.stateNode = _instance;
6998
+ }
6999
+ appendInitialChild(parent, _instance);
7000
+ } else if (node.tag === HostPortal) {
7001
+ // If we have a portal child, then we don't want to traverse
7002
+ // down its children. Instead, we'll get insertions from each child in
7003
+ // the portal directly.
7004
+ } else if (node.tag === SuspenseComponent) {
7005
+ var current = node.alternate;
7006
+ if (current !== null) {
7007
+ var oldState = current.memoizedState;
7008
+ var newState = node.memoizedState;
7009
+ var oldIsHidden = oldState !== null && oldState.didTimeout;
7010
+ var newIsHidden = newState !== null && newState.didTimeout;
7011
+ if (oldIsHidden !== newIsHidden) {
7012
+ // The placeholder either just timed out or switched back to the normal
7013
+ // children after having previously timed out. Toggle the visibility of
7014
+ // the direct host children.
7015
+ var primaryChildParent = newIsHidden ? node.child : node;
7016
+ if (primaryChildParent !== null) {
7017
+ appendAllChildren(parent, primaryChildParent, true, newIsHidden);
7018
+ }
7019
+ // eslint-disable-next-line no-labels
7020
+ break branches;
7021
+ }
7022
+ }
7023
+ if (node.child !== null) {
7024
+ // Continue traversing like normal
7025
+ node.child.return = node;
7026
+ node = node.child;
7027
+ continue;
7028
+ }
7029
+ } else if (node.child !== null) {
7030
+ node.child.return = node;
7031
+ node = node.child;
7032
+ continue;
7033
+ }
7034
+ // $FlowFixMe This is correct but Flow is confused by the labeled break.
7035
+ node = node;
7036
+ if (node === workInProgress) {
7037
+ return;
7038
+ }
7039
+ while (node.sibling === null) {
7040
+ if (node.return === null || node.return === workInProgress) {
7041
+ return;
7042
+ }
7043
+ node = node.return;
7044
+ }
7045
+ node.sibling.return = node.return;
7046
+ node = node.sibling;
7047
+ }
7048
+ };
7049
+
6558
7050
  // An unfortunate fork of appendAllChildren because we have two different parent types.
6559
- var appendAllChildrenToContainer = function (containerChildSet, workInProgress) {
7051
+ var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
6560
7052
  // We only have the top Fiber that was created but we need recurse down its
6561
7053
  // children to find all the terminal nodes.
6562
7054
  var node = workInProgress.child;
6563
7055
  while (node !== null) {
6564
- if (node.tag === HostComponent || node.tag === HostText) {
6565
- appendChildToContainerChildSet(containerChildSet, node.stateNode);
7056
+ // eslint-disable-next-line no-labels
7057
+ branches: if (node.tag === HostComponent) {
7058
+ var instance = node.stateNode;
7059
+ if (needsVisibilityToggle) {
7060
+ var props = node.memoizedProps;
7061
+ var type = node.type;
7062
+ if (isHidden) {
7063
+ // This child is inside a timed out tree. Hide it.
7064
+ instance = cloneHiddenInstance(instance, type, props, node);
7065
+ } else {
7066
+ // This child was previously inside a timed out tree. If it was not
7067
+ // updated during this render, it may need to be unhidden. Clone
7068
+ // again to be sure.
7069
+ instance = cloneUnhiddenInstance(instance, type, props, node);
7070
+ }
7071
+ node.stateNode = instance;
7072
+ }
7073
+ appendChildToContainerChildSet(containerChildSet, instance);
7074
+ } else if (node.tag === HostText) {
7075
+ var _instance2 = node.stateNode;
7076
+ if (needsVisibilityToggle) {
7077
+ var text = node.memoizedProps;
7078
+ var rootContainerInstance = getRootHostContainer();
7079
+ var currentHostContext = getHostContext();
7080
+ if (isHidden) {
7081
+ _instance2 = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
7082
+ } else {
7083
+ _instance2 = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
7084
+ }
7085
+ node.stateNode = _instance2;
7086
+ }
7087
+ appendChildToContainerChildSet(containerChildSet, _instance2);
6566
7088
  } else if (node.tag === HostPortal) {
6567
7089
  // If we have a portal child, then we don't want to traverse
6568
7090
  // down its children. Instead, we'll get insertions from each child in
6569
7091
  // the portal directly.
7092
+ } else if (node.tag === SuspenseComponent) {
7093
+ var current = node.alternate;
7094
+ if (current !== null) {
7095
+ var oldState = current.memoizedState;
7096
+ var newState = node.memoizedState;
7097
+ var oldIsHidden = oldState !== null && oldState.didTimeout;
7098
+ var newIsHidden = newState !== null && newState.didTimeout;
7099
+ if (oldIsHidden !== newIsHidden) {
7100
+ // The placeholder either just timed out or switched back to the normal
7101
+ // children after having previously timed out. Toggle the visibility of
7102
+ // the direct host children.
7103
+ var primaryChildParent = newIsHidden ? node.child : node;
7104
+ if (primaryChildParent !== null) {
7105
+ appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
7106
+ }
7107
+ // eslint-disable-next-line no-labels
7108
+ break branches;
7109
+ }
7110
+ }
7111
+ if (node.child !== null) {
7112
+ // Continue traversing like normal
7113
+ node.child.return = node;
7114
+ node = node.child;
7115
+ continue;
7116
+ }
6570
7117
  } else if (node.child !== null) {
6571
7118
  node.child.return = node;
6572
7119
  node = node.child;
6573
7120
  continue;
6574
7121
  }
7122
+ // $FlowFixMe This is correct but Flow is confused by the labeled break.
7123
+ node = node;
6575
7124
  if (node === workInProgress) {
6576
7125
  return;
6577
7126
  }
@@ -6594,7 +7143,7 @@ if (supportsMutation) {
6594
7143
  var container = portalOrRoot.containerInfo;
6595
7144
  var newChildSet = createContainerChildSet(container);
6596
7145
  // If children might have changed, we have to add them all to the set.
6597
- appendAllChildrenToContainer(newChildSet, workInProgress);
7146
+ appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
6598
7147
  portalOrRoot.pendingChildren = newChildSet;
6599
7148
  // Schedule an update on the container to swap out the container.
6600
7149
  markUpdate(workInProgress);
@@ -6637,7 +7186,7 @@ if (supportsMutation) {
6637
7186
  markUpdate(workInProgress);
6638
7187
  } else {
6639
7188
  // If children might have changed, we have to add them all to the set.
6640
- appendAllChildren(newInstance, workInProgress);
7189
+ appendAllChildren(newInstance, workInProgress, false, false);
6641
7190
  }
6642
7191
  };
6643
7192
  updateHostText$1 = function (current, workInProgress, oldText, newText) {
@@ -6668,8 +7217,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6668
7217
  var newProps = workInProgress.pendingProps;
6669
7218
 
6670
7219
  switch (workInProgress.tag) {
6671
- case FunctionalComponent:
6672
- case FunctionalComponentLazy:
7220
+ case IndeterminateComponent:
7221
+ break;
7222
+ case LazyComponent:
7223
+ break;
7224
+ case SimpleMemoComponent:
7225
+ case FunctionComponent:
6673
7226
  break;
6674
7227
  case ClassComponent:
6675
7228
  {
@@ -6679,14 +7232,6 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6679
7232
  }
6680
7233
  break;
6681
7234
  }
6682
- case ClassComponentLazy:
6683
- {
6684
- var _Component = getResultFromResolvedThenable(workInProgress.type);
6685
- if (isContextProvider(_Component)) {
6686
- popContext(workInProgress);
6687
- }
6688
- break;
6689
- }
6690
7235
  case HostRoot:
6691
7236
  {
6692
7237
  popHostContainer(workInProgress);
@@ -6742,7 +7287,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6742
7287
  } else {
6743
7288
  var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
6744
7289
 
6745
- appendAllChildren(instance, workInProgress);
7290
+ appendAllChildren(instance, workInProgress, false, false);
6746
7291
 
6747
7292
  // Certain renderers require commit-time effects for initial mount.
6748
7293
  // (eg DOM renderer supports auto-focus for certain elements).
@@ -6787,10 +7332,20 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6787
7332
  break;
6788
7333
  }
6789
7334
  case ForwardRef:
6790
- case ForwardRefLazy:
6791
- break;
6792
- case PlaceholderComponent:
6793
7335
  break;
7336
+ case SuspenseComponent:
7337
+ {
7338
+ var nextState = workInProgress.memoizedState;
7339
+ var prevState = current !== null ? current.memoizedState : null;
7340
+ var nextDidTimeout = nextState !== null && nextState.didTimeout;
7341
+ var prevDidTimeout = prevState !== null && prevState.didTimeout;
7342
+ if (nextDidTimeout !== prevDidTimeout) {
7343
+ // If this render commits, and it switches between the normal state
7344
+ // and the timed-out state, schedule an effect.
7345
+ workInProgress.effectTag |= Update;
7346
+ }
7347
+ break;
7348
+ }
6794
7349
  case Fragment:
6795
7350
  break;
6796
7351
  case Mode:
@@ -6807,10 +7362,18 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6807
7362
  break;
6808
7363
  case ContextConsumer:
6809
7364
  break;
6810
- // Error cases
6811
- case IndeterminateComponent:
6812
- invariant(false, 'An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue.');
6813
- // eslint-disable-next-line no-fallthrough
7365
+ case MemoComponent:
7366
+ break;
7367
+ case IncompleteClassComponent:
7368
+ {
7369
+ // Same as class component case. I put it down here so that the tags are
7370
+ // sequential to ensure this switch is compiled to a jump table.
7371
+ var _Component = workInProgress.type;
7372
+ if (isContextProvider(_Component)) {
7373
+ popContext(workInProgress);
7374
+ }
7375
+ break;
7376
+ }
6814
7377
  default:
6815
7378
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
6816
7379
  }
@@ -6818,6 +7381,17 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6818
7381
  return null;
6819
7382
  }
6820
7383
 
7384
+ function shouldCaptureSuspense(current, workInProgress) {
7385
+ // In order to capture, the Suspense component must have a fallback prop.
7386
+ if (workInProgress.memoizedProps.fallback === undefined) {
7387
+ return false;
7388
+ }
7389
+ // If it was the primary children that just suspended, capture and render the
7390
+ // fallback. Otherwise, don't capture and bubble to the next boundary.
7391
+ var nextState = workInProgress.memoizedState;
7392
+ return nextState === null || !nextState.didTimeout;
7393
+ }
7394
+
6821
7395
  // This module is forked in different environments.
6822
7396
  // By default, return `true` to log errors to the console.
6823
7397
  // Forks can return `false` if this isn't desirable.
@@ -6885,8 +7459,6 @@ function logCapturedError(capturedError) {
6885
7459
  }
6886
7460
  }
6887
7461
 
6888
- var emptyObject = {};
6889
-
6890
7462
  var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
6891
7463
  {
6892
7464
  didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
@@ -6968,7 +7540,6 @@ function safelyDetachRef(current$$1) {
6968
7540
  function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
6969
7541
  switch (finishedWork.tag) {
6970
7542
  case ClassComponent:
6971
- case ClassComponentLazy:
6972
7543
  {
6973
7544
  if (finishedWork.effectTag & Snapshot) {
6974
7545
  if (current$$1 !== null) {
@@ -6996,6 +7567,7 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
6996
7567
  case HostComponent:
6997
7568
  case HostText:
6998
7569
  case HostPortal:
7570
+ case IncompleteClassComponent:
6999
7571
  // Nothing to do for these component types
7000
7572
  return;
7001
7573
  default:
@@ -7008,7 +7580,6 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
7008
7580
  function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
7009
7581
  switch (finishedWork.tag) {
7010
7582
  case ClassComponent:
7011
- case ClassComponentLazy:
7012
7583
  {
7013
7584
  var instance = finishedWork.stateNode;
7014
7585
  if (finishedWork.effectTag & Update) {
@@ -7047,7 +7618,6 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
7047
7618
  _instance = getPublicInstance(finishedWork.child.stateNode);
7048
7619
  break;
7049
7620
  case ClassComponent:
7050
- case ClassComponentLazy:
7051
7621
  _instance = finishedWork.child.stateNode;
7052
7622
  break;
7053
7623
  }
@@ -7095,26 +7665,50 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
7095
7665
  }
7096
7666
  return;
7097
7667
  }
7098
- case PlaceholderComponent:
7668
+ case SuspenseComponent:
7099
7669
  {
7100
- if (enableSuspense) {
7101
- if ((finishedWork.mode & StrictMode) === NoEffect) {
7102
- // In loose mode, a placeholder times out by scheduling a synchronous
7103
- // update in the commit phase. Use `updateQueue` field to signal that
7104
- // the Timeout needs to switch to the placeholder. We don't need an
7105
- // entire queue. Any non-null value works.
7106
- // $FlowFixMe - Intentionally using a value other than an UpdateQueue.
7107
- finishedWork.updateQueue = emptyObject;
7108
- scheduleWork(finishedWork, Sync);
7109
- } else {
7110
- // In strict mode, the Update effect is used to record the time at
7111
- // which the placeholder timed out.
7112
- var currentTime = requestCurrentTime();
7113
- finishedWork.stateNode = { timedOutAt: currentTime };
7670
+ if (finishedWork.effectTag & Callback) {
7671
+ // In non-strict mode, a suspense boundary times out by commiting
7672
+ // twice: first, by committing the children in an inconsistent state,
7673
+ // then hiding them and showing the fallback children in a subsequent
7674
+ var _newState = {
7675
+ alreadyCaptured: true,
7676
+ didTimeout: false,
7677
+ timedOutAt: NoWork
7678
+ };
7679
+ finishedWork.memoizedState = _newState;
7680
+ scheduleWork(finishedWork, Sync);
7681
+ return;
7682
+ }
7683
+ var oldState = current$$1 !== null ? current$$1.memoizedState : null;
7684
+ var newState = finishedWork.memoizedState;
7685
+ var oldDidTimeout = oldState !== null ? oldState.didTimeout : false;
7686
+
7687
+ var newDidTimeout = void 0;
7688
+ var primaryChildParent = finishedWork;
7689
+ if (newState === null) {
7690
+ newDidTimeout = false;
7691
+ } else {
7692
+ newDidTimeout = newState.didTimeout;
7693
+ if (newDidTimeout) {
7694
+ primaryChildParent = finishedWork.child;
7695
+ newState.alreadyCaptured = false;
7696
+ if (newState.timedOutAt === NoWork) {
7697
+ // If the children had not already timed out, record the time.
7698
+ // This is used to compute the elapsed time during subsequent
7699
+ // attempts to render the children.
7700
+ newState.timedOutAt = requestCurrentTime();
7701
+ }
7114
7702
  }
7115
7703
  }
7704
+
7705
+ if (newDidTimeout !== oldDidTimeout && primaryChildParent !== null) {
7706
+ hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
7707
+ }
7116
7708
  return;
7117
7709
  }
7710
+ case IncompleteClassComponent:
7711
+ break;
7118
7712
  default:
7119
7713
  {
7120
7714
  invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
@@ -7122,6 +7716,45 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
7122
7716
  }
7123
7717
  }
7124
7718
 
7719
+ function hideOrUnhideAllChildren(finishedWork, isHidden) {
7720
+ if (supportsMutation) {
7721
+ // We only have the top Fiber that was inserted but we need recurse down its
7722
+ var node = finishedWork;
7723
+ while (true) {
7724
+ if (node.tag === HostComponent) {
7725
+ var instance = node.stateNode;
7726
+ if (isHidden) {
7727
+ hideInstance(instance);
7728
+ } else {
7729
+ unhideInstance(node.stateNode, node.memoizedProps);
7730
+ }
7731
+ } else if (node.tag === HostText) {
7732
+ var _instance3 = node.stateNode;
7733
+ if (isHidden) {
7734
+ hideTextInstance(_instance3);
7735
+ } else {
7736
+ unhideTextInstance(_instance3, node.memoizedProps);
7737
+ }
7738
+ } else if (node.child !== null) {
7739
+ node.child.return = node;
7740
+ node = node.child;
7741
+ continue;
7742
+ }
7743
+ if (node === finishedWork) {
7744
+ return;
7745
+ }
7746
+ while (node.sibling === null) {
7747
+ if (node.return === null || node.return === finishedWork) {
7748
+ return;
7749
+ }
7750
+ node = node.return;
7751
+ }
7752
+ node.sibling.return = node.return;
7753
+ node = node.sibling;
7754
+ }
7755
+ }
7756
+ }
7757
+
7125
7758
  function commitAttachRef(finishedWork) {
7126
7759
  var ref = finishedWork.ref;
7127
7760
  if (ref !== null) {
@@ -7167,7 +7800,6 @@ function commitUnmount(current$$1) {
7167
7800
 
7168
7801
  switch (current$$1.tag) {
7169
7802
  case ClassComponent:
7170
- case ClassComponentLazy:
7171
7803
  {
7172
7804
  safelyDetachRef(current$$1);
7173
7805
  var instance = current$$1.stateNode;
@@ -7261,7 +7893,6 @@ function commitContainer(finishedWork) {
7261
7893
 
7262
7894
  switch (finishedWork.tag) {
7263
7895
  case ClassComponent:
7264
- case ClassComponentLazy:
7265
7896
  {
7266
7897
  return;
7267
7898
  }
@@ -7526,7 +8157,6 @@ function commitWork(current$$1, finishedWork) {
7526
8157
 
7527
8158
  switch (finishedWork.tag) {
7528
8159
  case ClassComponent:
7529
- case ClassComponentLazy:
7530
8160
  {
7531
8161
  return;
7532
8162
  }
@@ -7570,7 +8200,11 @@ function commitWork(current$$1, finishedWork) {
7570
8200
  {
7571
8201
  return;
7572
8202
  }
7573
- case PlaceholderComponent:
8203
+ case SuspenseComponent:
8204
+ {
8205
+ return;
8206
+ }
8207
+ case IncompleteClassComponent:
7574
8208
  {
7575
8209
  return;
7576
8210
  }
@@ -7588,10 +8222,6 @@ function commitResetTextContent(current$$1) {
7588
8222
  resetTextContent(current$$1.stateNode);
7589
8223
  }
7590
8224
 
7591
- function NoopComponent() {
7592
- return null;
7593
- }
7594
-
7595
8225
  function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
7596
8226
  var update = createUpdate(expirationTime);
7597
8227
  // Unmount the root by rendering null.
@@ -7610,22 +8240,22 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
7610
8240
  function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
7611
8241
  var update = createUpdate(expirationTime);
7612
8242
  update.tag = CaptureUpdate;
7613
- var getDerivedStateFromCatch = fiber.type.getDerivedStateFromCatch;
7614
- if (enableGetDerivedStateFromCatch && typeof getDerivedStateFromCatch === 'function') {
8243
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
8244
+ if (typeof getDerivedStateFromError === 'function') {
7615
8245
  var error = errorInfo.value;
7616
8246
  update.payload = function () {
7617
- return getDerivedStateFromCatch(error);
8247
+ return getDerivedStateFromError(error);
7618
8248
  };
7619
8249
  }
7620
8250
 
7621
8251
  var inst = fiber.stateNode;
7622
8252
  if (inst !== null && typeof inst.componentDidCatch === 'function') {
7623
8253
  update.callback = function callback() {
7624
- if (!enableGetDerivedStateFromCatch || getDerivedStateFromCatch !== 'function') {
8254
+ if (typeof getDerivedStateFromError !== 'function') {
7625
8255
  // To preserve the preexisting retry behavior of error boundaries,
7626
8256
  // we keep track of which ones already failed during this batch.
7627
8257
  // This gets reset before we yield back to the browser.
7628
- // TODO: Warn in strict mode if getDerivedStateFromCatch is
8258
+ // TODO: Warn in strict mode if getDerivedStateFromError is
7629
8259
  // not defined.
7630
8260
  markLegacyErrorBoundaryAsFailed(this);
7631
8261
  }
@@ -7635,6 +8265,14 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
7635
8265
  this.componentDidCatch(error, {
7636
8266
  componentStack: stack !== null ? stack : ''
7637
8267
  });
8268
+ {
8269
+ if (typeof getDerivedStateFromError !== 'function') {
8270
+ // If componentDidCatch is the only error boundary method defined,
8271
+ // then it needs to call setState to recover from errors.
8272
+ // If no state update is scheduled then the boundary will swallow the error.
8273
+ !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown') : void 0;
8274
+ }
8275
+ }
7638
8276
  };
7639
8277
  }
7640
8278
  return update;
@@ -7646,7 +8284,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7646
8284
  // Its effect list is no longer valid.
7647
8285
  sourceFiber.firstEffect = sourceFiber.lastEffect = null;
7648
8286
 
7649
- if (enableSuspense && value !== null && typeof value === 'object' && typeof value.then === 'function') {
8287
+ if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
7650
8288
  // This is a thenable.
7651
8289
  var thenable = value;
7652
8290
 
@@ -7659,21 +8297,20 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7659
8297
  var earliestTimeoutMs = -1;
7660
8298
  var startTimeMs = -1;
7661
8299
  do {
7662
- if (_workInProgress.tag === PlaceholderComponent) {
8300
+ if (_workInProgress.tag === SuspenseComponent) {
7663
8301
  var current = _workInProgress.alternate;
7664
- if (current !== null && current.memoizedState === true && current.stateNode !== null) {
7665
- // Reached a placeholder that already timed out. Each timed out
7666
- // placeholder acts as the root of a new suspense boundary.
7667
-
7668
- // Use the time at which the placeholder timed out as the start time
7669
- // for the current render.
7670
- var timedOutAt = current.stateNode.timedOutAt;
7671
- startTimeMs = expirationTimeToMs(timedOutAt);
7672
-
7673
- // Do not search any further.
7674
- break;
8302
+ if (current !== null) {
8303
+ var currentState = current.memoizedState;
8304
+ if (currentState !== null && currentState.didTimeout) {
8305
+ // Reached a boundary that already timed out. Do not search
8306
+ // any further.
8307
+ var timedOutAt = currentState.timedOutAt;
8308
+ startTimeMs = expirationTimeToMs(timedOutAt);
8309
+ // Do not search any further.
8310
+ break;
8311
+ }
7675
8312
  }
7676
- var timeoutPropMs = _workInProgress.pendingProps.delayMs;
8313
+ var timeoutPropMs = _workInProgress.pendingProps.maxDuration;
7677
8314
  if (typeof timeoutPropMs === 'number') {
7678
8315
  if (timeoutPropMs <= 0) {
7679
8316
  earliestTimeoutMs = 0;
@@ -7685,103 +8322,96 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7685
8322
  _workInProgress = _workInProgress.return;
7686
8323
  } while (_workInProgress !== null);
7687
8324
 
7688
- // Schedule the nearest Placeholder to re-render the timed out view.
8325
+ // Schedule the nearest Suspense to re-render the timed out view.
7689
8326
  _workInProgress = returnFiber;
7690
8327
  do {
7691
- if (_workInProgress.tag === PlaceholderComponent) {
7692
- var didTimeout = _workInProgress.memoizedState;
7693
- if (!didTimeout) {
7694
- // Found the nearest boundary.
7695
-
7696
- // If the boundary is not in async mode, we should not suspend, and
7697
- // likewise, when the promise resolves, we should ping synchronously.
7698
- var pingTime = (_workInProgress.mode & AsyncMode) === NoEffect ? Sync : renderExpirationTime;
7699
-
7700
- // Attach a listener to the promise to "ping" the root and retry.
7701
- var onResolveOrReject = retrySuspendedRoot.bind(null, root, _workInProgress, pingTime);
7702
- thenable.then(onResolveOrReject, onResolveOrReject);
7703
-
7704
- // If the boundary is outside of strict mode, we should *not* suspend
7705
- // the commit. Pretend as if the suspended component rendered null and
7706
- // keep rendering. In the commit phase, we'll schedule a subsequent
7707
- // synchronous update to re-render the Placeholder.
7708
- //
7709
- // Note: It doesn't matter whether the component that suspended was
7710
- // inside a strict mode tree. If the Placeholder is outside of it, we
7711
- // should *not* suspend the commit.
7712
- if ((_workInProgress.mode & StrictMode) === NoEffect) {
7713
- _workInProgress.effectTag |= Update;
7714
-
7715
- // Unmount the source fiber's children
7716
- var nextChildren = null;
7717
- reconcileChildren(sourceFiber.alternate, sourceFiber, nextChildren, renderExpirationTime);
7718
- sourceFiber.effectTag &= ~Incomplete;
7719
- if (sourceFiber.tag === IndeterminateComponent) {
7720
- // Let's just assume it's a functional component. This fiber will
7721
- // be unmounted in the immediate next commit, anyway.
7722
- sourceFiber.tag = FunctionalComponent;
7723
- }
7724
-
7725
- if (sourceFiber.tag === ClassComponent || sourceFiber.tag === ClassComponentLazy) {
7726
- // We're going to commit this fiber even though it didn't
7727
- // complete. But we shouldn't call any lifecycle methods or
7728
- // callbacks. Remove all lifecycle effect tags.
7729
- sourceFiber.effectTag &= ~LifecycleEffectMask;
7730
- if (sourceFiber.alternate === null) {
7731
- // We're about to mount a class component that doesn't have an
7732
- // instance. Turn this into a dummy functional component instead,
7733
- // to prevent type errors. This is a bit weird but it's an edge
7734
- // case and we're about to synchronously delete this
7735
- // component, anyway.
7736
- sourceFiber.tag = FunctionalComponent;
7737
- sourceFiber.type = NoopComponent;
7738
- }
8328
+ if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress.alternate, _workInProgress)) {
8329
+ // Found the nearest boundary.
8330
+
8331
+ // If the boundary is not in concurrent mode, we should not suspend, and
8332
+ // likewise, when the promise resolves, we should ping synchronously.
8333
+ var pingTime = (_workInProgress.mode & ConcurrentMode) === NoEffect ? Sync : renderExpirationTime;
8334
+
8335
+ // Attach a listener to the promise to "ping" the root and retry.
8336
+ var onResolveOrReject = retrySuspendedRoot.bind(null, root, _workInProgress, sourceFiber, pingTime);
8337
+ if (enableSchedulerTracing) {
8338
+ onResolveOrReject = tracing.unstable_wrap(onResolveOrReject);
8339
+ }
8340
+ thenable.then(onResolveOrReject, onResolveOrReject);
8341
+
8342
+ // If the boundary is outside of concurrent mode, we should *not*
8343
+ // suspend the commit. Pretend as if the suspended component rendered
8344
+ // null and keep rendering. In the commit phase, we'll schedule a
8345
+ // subsequent synchronous update to re-render the Suspense.
8346
+ //
8347
+ // Note: It doesn't matter whether the component that suspended was
8348
+ // inside a concurrent mode tree. If the Suspense is outside of it, we
8349
+ // should *not* suspend the commit.
8350
+ if ((_workInProgress.mode & ConcurrentMode) === NoEffect) {
8351
+ _workInProgress.effectTag |= Callback;
8352
+
8353
+ // Unmount the source fiber's children
8354
+ var nextChildren = null;
8355
+ reconcileChildren(sourceFiber.alternate, sourceFiber, nextChildren, renderExpirationTime);
8356
+ sourceFiber.effectTag &= ~Incomplete;
8357
+
8358
+ if (sourceFiber.tag === ClassComponent) {
8359
+ // We're going to commit this fiber even though it didn't complete.
8360
+ // But we shouldn't call any lifecycle methods or callbacks. Remove
8361
+ // all lifecycle effect tags.
8362
+ sourceFiber.effectTag &= ~LifecycleEffectMask;
8363
+ var _current = sourceFiber.alternate;
8364
+ if (_current === null) {
8365
+ // This is a new mount. Change the tag so it's not mistaken for a
8366
+ // completed component. For example, we should not call
8367
+ // componentWillUnmount if it is deleted.
8368
+ sourceFiber.tag = IncompleteClassComponent;
7739
8369
  }
7740
-
7741
- // Exit without suspending.
7742
- return;
7743
8370
  }
7744
8371
 
7745
- // Confirmed that the boundary is in a strict mode tree. Continue with
7746
- // the normal suspend path.
8372
+ // Exit without suspending.
8373
+ return;
8374
+ }
7747
8375
 
7748
- var absoluteTimeoutMs = void 0;
7749
- if (earliestTimeoutMs === -1) {
7750
- // If no explicit threshold is given, default to an abitrarily large
7751
- // value. The actual size doesn't matter because the threshold for the
7752
- // whole tree will be clamped to the expiration time.
7753
- absoluteTimeoutMs = maxSigned31BitInt;
7754
- } else {
7755
- if (startTimeMs === -1) {
7756
- // This suspend happened outside of any already timed-out
7757
- // placeholders. We don't know exactly when the update was scheduled,
7758
- // but we can infer an approximate start time from the expiration
7759
- // time. First, find the earliest uncommitted expiration time in the
7760
- // tree, including work that is suspended. Then subtract the offset
7761
- // used to compute an async update's expiration time. This will cause
7762
- // high priority (interactive) work to expire earlier than necessary,
7763
- // but we can account for this by adjusting for the Just Noticeable
7764
- // Difference.
7765
- var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, renderExpirationTime);
7766
- var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
7767
- startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
7768
- }
7769
- absoluteTimeoutMs = startTimeMs + earliestTimeoutMs;
8376
+ // Confirmed that the boundary is in a concurrent mode tree. Continue
8377
+ // with the normal suspend path.
8378
+
8379
+ var absoluteTimeoutMs = void 0;
8380
+ if (earliestTimeoutMs === -1) {
8381
+ // If no explicit threshold is given, default to an abitrarily large
8382
+ // value. The actual size doesn't matter because the threshold for the
8383
+ // whole tree will be clamped to the expiration time.
8384
+ absoluteTimeoutMs = maxSigned31BitInt;
8385
+ } else {
8386
+ if (startTimeMs === -1) {
8387
+ // This suspend happened outside of any already timed-out
8388
+ // placeholders. We don't know exactly when the update was
8389
+ // scheduled, but we can infer an approximate start time from the
8390
+ // expiration time. First, find the earliest uncommitted expiration
8391
+ // time in the tree, including work that is suspended. Then subtract
8392
+ // the offset used to compute an async update's expiration time.
8393
+ // This will cause high priority (interactive) work to expire
8394
+ // earlier than necessary, but we can account for this by adjusting
8395
+ // for the Just Noticeable Difference.
8396
+ var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, renderExpirationTime);
8397
+ var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
8398
+ startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
7770
8399
  }
8400
+ absoluteTimeoutMs = startTimeMs + earliestTimeoutMs;
8401
+ }
7771
8402
 
7772
- // Mark the earliest timeout in the suspended fiber's ancestor path.
7773
- // After completing the root, we'll take the largest of all the
7774
- // suspended fiber's timeouts and use it to compute a timeout for the
7775
- // whole tree.
7776
- renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
8403
+ // Mark the earliest timeout in the suspended fiber's ancestor path.
8404
+ // After completing the root, we'll take the largest of all the
8405
+ // suspended fiber's timeouts and use it to compute a timeout for the
8406
+ // whole tree.
8407
+ renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
7777
8408
 
7778
- _workInProgress.effectTag |= ShouldCapture;
7779
- _workInProgress.expirationTime = renderExpirationTime;
7780
- return;
7781
- }
7782
- // This boundary already captured during this render. Continue to the
7783
- // next boundary.
8409
+ _workInProgress.effectTag |= ShouldCapture;
8410
+ _workInProgress.expirationTime = renderExpirationTime;
8411
+ return;
7784
8412
  }
8413
+ // This boundary already captured during this render. Continue to the next
8414
+ // boundary.
7785
8415
  _workInProgress = _workInProgress.return;
7786
8416
  } while (_workInProgress !== null);
7787
8417
  // No boundary was found. Fallthrough to error mode.
@@ -7806,12 +8436,11 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7806
8436
  return;
7807
8437
  }
7808
8438
  case ClassComponent:
7809
- case ClassComponentLazy:
7810
8439
  // Capture and retry
7811
8440
  var errorInfo = value;
7812
8441
  var ctor = workInProgress.type;
7813
8442
  var instance = workInProgress.stateNode;
7814
- if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromCatch === 'function' && enableGetDerivedStateFromCatch || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
8443
+ if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
7815
8444
  workInProgress.effectTag |= ShouldCapture;
7816
8445
  workInProgress.expirationTime = renderExpirationTime;
7817
8446
  // Schedule the error boundary to re-render using updated state
@@ -7842,26 +8471,13 @@ function unwindWork(workInProgress, renderExpirationTime) {
7842
8471
  }
7843
8472
  return null;
7844
8473
  }
7845
- case ClassComponentLazy:
7846
- {
7847
- var _Component = workInProgress.type._reactResult;
7848
- if (isContextProvider(_Component)) {
7849
- popContext(workInProgress);
7850
- }
7851
- var _effectTag = workInProgress.effectTag;
7852
- if (_effectTag & ShouldCapture) {
7853
- workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
7854
- return workInProgress;
7855
- }
7856
- return null;
7857
- }
7858
8474
  case HostRoot:
7859
8475
  {
7860
8476
  popHostContainer(workInProgress);
7861
8477
  popTopLevelContextObject(workInProgress);
7862
- var _effectTag2 = workInProgress.effectTag;
7863
- !((_effectTag2 & DidCapture) === NoEffect) ? invariant(false, 'The root failed to unmount after an error. This is likely a bug in React. Please file an issue.') : void 0;
7864
- workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
8478
+ var _effectTag = workInProgress.effectTag;
8479
+ !((_effectTag & DidCapture) === NoEffect) ? invariant(false, 'The root failed to unmount after an error. This is likely a bug in React. Please file an issue.') : void 0;
8480
+ workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
7865
8481
  return workInProgress;
7866
8482
  }
7867
8483
  case HostComponent:
@@ -7869,11 +8485,37 @@ function unwindWork(workInProgress, renderExpirationTime) {
7869
8485
  popHostContext(workInProgress);
7870
8486
  return null;
7871
8487
  }
7872
- case PlaceholderComponent:
8488
+ case SuspenseComponent:
7873
8489
  {
7874
- var _effectTag3 = workInProgress.effectTag;
7875
- if (_effectTag3 & ShouldCapture) {
7876
- workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
8490
+ var _effectTag2 = workInProgress.effectTag;
8491
+ if (_effectTag2 & ShouldCapture) {
8492
+ workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
8493
+ // Captured a suspense effect. Set the boundary's `alreadyCaptured`
8494
+ // state to true so we know to render the fallback.
8495
+ var current = workInProgress.alternate;
8496
+ var currentState = current !== null ? current.memoizedState : null;
8497
+ var nextState = workInProgress.memoizedState;
8498
+ if (nextState === null) {
8499
+ // No existing state. Create a new object.
8500
+ nextState = {
8501
+ alreadyCaptured: true,
8502
+ didTimeout: false,
8503
+ timedOutAt: NoWork
8504
+ };
8505
+ } else if (currentState === nextState) {
8506
+ // There is an existing state but it's the same as the current tree's.
8507
+ // Clone the object.
8508
+ nextState = {
8509
+ alreadyCaptured: true,
8510
+ didTimeout: nextState.didTimeout,
8511
+ timedOutAt: nextState.timedOutAt
8512
+ };
8513
+ } else {
8514
+ // Already have a clone, so it's safe to mutate.
8515
+ nextState.alreadyCaptured = true;
8516
+ }
8517
+ workInProgress.memoizedState = nextState;
8518
+ // Re-render the boundary.
7877
8519
  return workInProgress;
7878
8520
  }
7879
8521
  return null;
@@ -7899,14 +8541,6 @@ function unwindInterruptedWork(interruptedWork) {
7899
8541
  }
7900
8542
  break;
7901
8543
  }
7902
- case ClassComponentLazy:
7903
- {
7904
- var _childContextTypes = interruptedWork.type._reactResult.childContextTypes;
7905
- if (_childContextTypes !== null && _childContextTypes !== undefined) {
7906
- popContext(interruptedWork);
7907
- }
7908
- break;
7909
- }
7910
8544
  case HostRoot:
7911
8545
  {
7912
8546
  popHostContainer(interruptedWork);
@@ -8008,10 +8642,6 @@ var legacyErrorBoundariesThatAlreadyFailed = null;
8008
8642
  // Used for performance tracking.
8009
8643
  var interruptedBy = null;
8010
8644
 
8011
- // Do not decrement interaction counts in the event of suspense timeouts.
8012
- // This would lead to prematurely calling the interaction-complete hook.
8013
- var suspenseDidTimeout = false;
8014
-
8015
8645
  var stashedWorkInProgressProperties = void 0;
8016
8646
  var replayUnitOfWork = void 0;
8017
8647
  var isReplayingFailedUnitOfWork = void 0;
@@ -8053,14 +8683,6 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
8053
8683
  }
8054
8684
  break;
8055
8685
  }
8056
- case ClassComponentLazy:
8057
- {
8058
- var _Component = getResultFromResolvedThenable(failedUnitOfWork.type);
8059
- if (isContextProvider(_Component)) {
8060
- popContext(failedUnitOfWork);
8061
- }
8062
- break;
8063
- }
8064
8686
  case HostPortal:
8065
8687
  popHostContainer(failedUnitOfWork);
8066
8688
  break;
@@ -8216,14 +8838,11 @@ function commitBeforeMutationLifecycles() {
8216
8838
  function commitAllLifeCycles(finishedRoot, committedExpirationTime) {
8217
8839
  {
8218
8840
  ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
8841
+ ReactStrictModeWarnings.flushLegacyContextWarning();
8219
8842
 
8220
8843
  if (warnAboutDeprecatedLifecycles) {
8221
8844
  ReactStrictModeWarnings.flushPendingDeprecationWarnings();
8222
8845
  }
8223
-
8224
- if (warnAboutLegacyContextAPI) {
8225
- ReactStrictModeWarnings.flushLegacyContextWarning();
8226
- }
8227
8846
  }
8228
8847
  while (nextEffect !== null) {
8229
8848
  var effectTag = nextEffect.effectTag;
@@ -8282,27 +8901,11 @@ function commitRoot(root, finishedWork) {
8282
8901
  markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
8283
8902
 
8284
8903
  var prevInteractions = null;
8285
- var committedInteractions = enableSchedulerTracing ? [] : null;
8286
8904
  if (enableSchedulerTracing) {
8287
8905
  // Restore any pending interactions at this point,
8288
8906
  // So that cascading work triggered during the render phase will be accounted for.
8289
8907
  prevInteractions = tracing.__interactionsRef.current;
8290
8908
  tracing.__interactionsRef.current = root.memoizedInteractions;
8291
-
8292
- // We are potentially finished with the current batch of interactions.
8293
- // So we should clear them out of the pending interaction map.
8294
- // We do this at the start of commit in case cascading work is scheduled by commit phase lifecycles.
8295
- // In that event, interaction data may be added back into the pending map for a future commit.
8296
- // We also store the interactions we are about to commit so that we can notify subscribers after we're done.
8297
- // These are stored as an Array rather than a Set,
8298
- // Because the same interaction may be pending for multiple expiration times,
8299
- // In which case it's important that we decrement the count the right number of times after finishing.
8300
- root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
8301
- if (scheduledExpirationTime <= committedExpirationTime) {
8302
- committedInteractions.push.apply(committedInteractions, Array.from(scheduledInteractions));
8303
- root.pendingInteractionMap.delete(scheduledExpirationTime);
8304
- }
8305
- });
8306
8909
  }
8307
8910
 
8308
8911
  // Reset this to null before calling lifecycles
@@ -8454,28 +9057,35 @@ function commitRoot(root, finishedWork) {
8454
9057
  unhandledError = error;
8455
9058
  }
8456
9059
  } finally {
8457
- // Don't update interaction counts if we're frozen due to suspense.
8458
- // In this case, we can skip the completed-work check entirely.
8459
- if (!suspenseDidTimeout) {
8460
- // Now that we're done, check the completed batch of interactions.
8461
- // If no more work is outstanding for a given interaction,
8462
- // We need to notify the subscribers that it's finished.
8463
- committedInteractions.forEach(function (interaction) {
8464
- interaction.__count--;
8465
- if (subscriber !== null && interaction.__count === 0) {
8466
- try {
8467
- subscriber.onInteractionScheduledWorkCompleted(interaction);
8468
- } catch (error) {
8469
- // It's not safe for commitRoot() to throw.
8470
- // Store the error for now and we'll re-throw in finishRendering().
8471
- if (!hasUnhandledError) {
8472
- hasUnhandledError = true;
8473
- unhandledError = error;
9060
+ // Clear completed interactions from the pending Map.
9061
+ // Unless the render was suspended or cascading work was scheduled,
9062
+ // In which case– leave pending interactions until the subsequent render.
9063
+ var pendingInteractionMap = root.pendingInteractionMap;
9064
+ pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
9065
+ // Only decrement the pending interaction count if we're done.
9066
+ // If there's still work at the current priority,
9067
+ // That indicates that we are waiting for suspense data.
9068
+ if (earliestRemainingTimeAfterCommit === NoWork || scheduledExpirationTime < earliestRemainingTimeAfterCommit) {
9069
+ pendingInteractionMap.delete(scheduledExpirationTime);
9070
+
9071
+ scheduledInteractions.forEach(function (interaction) {
9072
+ interaction.__count--;
9073
+
9074
+ if (subscriber !== null && interaction.__count === 0) {
9075
+ try {
9076
+ subscriber.onInteractionScheduledWorkCompleted(interaction);
9077
+ } catch (error) {
9078
+ // It's not safe for commitRoot() to throw.
9079
+ // Store the error for now and we'll re-throw in finishRendering().
9080
+ if (!hasUnhandledError) {
9081
+ hasUnhandledError = true;
9082
+ unhandledError = error;
9083
+ }
8474
9084
  }
8475
9085
  }
8476
- }
8477
- });
8478
- }
9086
+ });
9087
+ }
9088
+ });
8479
9089
  }
8480
9090
  }
8481
9091
  }
@@ -8574,23 +9184,12 @@ function completeUnitOfWork(workInProgress) {
8574
9184
  } else {
8575
9185
  nextUnitOfWork = completeWork(current$$1, workInProgress, nextRenderExpirationTime);
8576
9186
  }
8577
- var next = nextUnitOfWork;
8578
9187
  stopWorkTimer(workInProgress);
8579
9188
  resetChildExpirationTime(workInProgress, nextRenderExpirationTime);
8580
9189
  {
8581
9190
  resetCurrentFiber();
8582
9191
  }
8583
9192
 
8584
- if (next !== null) {
8585
- stopWorkTimer(workInProgress);
8586
- if (true && ReactFiberInstrumentation_1.debugTool) {
8587
- ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
8588
- }
8589
- // If completing this work spawned new work, do that next. We'll come
8590
- // back here again.
8591
- return next;
8592
- }
8593
-
8594
9193
  if (returnFiber !== null &&
8595
9194
  // Do not append effects to parents if a sibling failed to complete
8596
9195
  (returnFiber.effectTag & Incomplete) === NoEffect) {
@@ -8650,7 +9249,7 @@ function completeUnitOfWork(workInProgress) {
8650
9249
  // This fiber did not complete because something threw. Pop values off
8651
9250
  // the stack without entering the complete phase. If this is a boundary,
8652
9251
  // capture values if possible.
8653
- var _next = unwindWork(workInProgress, nextRenderExpirationTime);
9252
+ var next = unwindWork(workInProgress, nextRenderExpirationTime);
8654
9253
  // Because this fiber did not complete, don't reset its expiration time.
8655
9254
  if (workInProgress.effectTag & DidCapture) {
8656
9255
  // Restarting an error boundary
@@ -8663,7 +9262,7 @@ function completeUnitOfWork(workInProgress) {
8663
9262
  resetCurrentFiber();
8664
9263
  }
8665
9264
 
8666
- if (_next !== null) {
9265
+ if (next !== null) {
8667
9266
  stopWorkTimer(workInProgress);
8668
9267
  if (true && ReactFiberInstrumentation_1.debugTool) {
8669
9268
  ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
@@ -8671,14 +9270,14 @@ function completeUnitOfWork(workInProgress) {
8671
9270
 
8672
9271
  if (enableProfilerTimer) {
8673
9272
  // Include the time spent working on failed children before continuing.
8674
- if (_next.mode & ProfileMode) {
8675
- var actualDuration = _next.actualDuration;
8676
- var child = _next.child;
9273
+ if (next.mode & ProfileMode) {
9274
+ var actualDuration = next.actualDuration;
9275
+ var child = next.child;
8677
9276
  while (child !== null) {
8678
9277
  actualDuration += child.actualDuration;
8679
9278
  child = child.sibling;
8680
9279
  }
8681
- _next.actualDuration = actualDuration;
9280
+ next.actualDuration = actualDuration;
8682
9281
  }
8683
9282
  }
8684
9283
 
@@ -8686,8 +9285,8 @@ function completeUnitOfWork(workInProgress) {
8686
9285
  // back here again.
8687
9286
  // Since we're restarting, remove anything that is not a host effect
8688
9287
  // from the effect tag.
8689
- _next.effectTag &= HostEffectMask;
8690
- return _next;
9288
+ next.effectTag &= HostEffectMask;
9289
+ return next;
8691
9290
  }
8692
9291
 
8693
9292
  if (returnFiber !== null) {
@@ -8743,6 +9342,7 @@ function performUnitOfWork(workInProgress) {
8743
9342
  }
8744
9343
 
8745
9344
  next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
9345
+ workInProgress.memoizedProps = workInProgress.pendingProps;
8746
9346
 
8747
9347
  if (workInProgress.mode & ProfileMode) {
8748
9348
  // Record the render duration assuming we didn't bailout (or error).
@@ -8750,6 +9350,7 @@ function performUnitOfWork(workInProgress) {
8750
9350
  }
8751
9351
  } else {
8752
9352
  next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
9353
+ workInProgress.memoizedProps = workInProgress.pendingProps;
8753
9354
  }
8754
9355
 
8755
9356
  {
@@ -8797,14 +9398,6 @@ function renderRoot(root, isYieldy, isExpired) {
8797
9398
 
8798
9399
  var expirationTime = root.nextExpirationTimeToWorkOn;
8799
9400
 
8800
- var prevInteractions = null;
8801
- if (enableSchedulerTracing) {
8802
- // We're about to start new traced work.
8803
- // Restore pending interactions so cascading work triggered during the render phase will be accounted for.
8804
- prevInteractions = tracing.__interactionsRef.current;
8805
- tracing.__interactionsRef.current = root.memoizedInteractions;
8806
- }
8807
-
8808
9401
  // Check if we're starting from a fresh stack, or if we're resuming from
8809
9402
  // previously yielded work.
8810
9403
  if (expirationTime !== nextRenderExpirationTime || root !== nextRoot || nextUnitOfWork === null) {
@@ -8853,6 +9446,14 @@ function renderRoot(root, isYieldy, isExpired) {
8853
9446
  }
8854
9447
  }
8855
9448
 
9449
+ var prevInteractions = null;
9450
+ if (enableSchedulerTracing) {
9451
+ // We're about to start new traced work.
9452
+ // Restore pending interactions so cascading work triggered during the render phase will be accounted for.
9453
+ prevInteractions = tracing.__interactionsRef.current;
9454
+ tracing.__interactionsRef.current = root.memoizedInteractions;
9455
+ }
9456
+
8856
9457
  var didFatal = false;
8857
9458
 
8858
9459
  startWorkLoopTimer(nextUnitOfWork);
@@ -8983,7 +9584,7 @@ function renderRoot(root, isYieldy, isExpired) {
8983
9584
  }
8984
9585
  }
8985
9586
 
8986
- if (enableSuspense && !isExpired && nextLatestAbsoluteTimeoutMs !== -1) {
9587
+ if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) {
8987
9588
  // The tree was suspended.
8988
9589
  var _suspendedExpirationTime2 = expirationTime;
8989
9590
  markSuspendedPriorityLevel(root, _suspendedExpirationTime2);
@@ -9023,10 +9624,9 @@ function dispatch(sourceFiber, value, expirationTime) {
9023
9624
  while (fiber !== null) {
9024
9625
  switch (fiber.tag) {
9025
9626
  case ClassComponent:
9026
- case ClassComponentLazy:
9027
9627
  var ctor = fiber.type;
9028
9628
  var instance = fiber.stateNode;
9029
- if (typeof ctor.getDerivedStateFromCatch === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
9629
+ if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
9030
9630
  var errorInfo = createCapturedValue(value, sourceFiber);
9031
9631
  var update = createClassErrorUpdate(fiber, errorInfo, expirationTime);
9032
9632
  enqueueUpdate(fiber, update);
@@ -9084,7 +9684,7 @@ function computeExpirationForFiber(currentTime, fiber) {
9084
9684
  } else {
9085
9685
  // No explicit expiration context was set, and we're not currently
9086
9686
  // performing work. Calculate a new expiration time.
9087
- if (fiber.mode & AsyncMode) {
9687
+ if (fiber.mode & ConcurrentMode) {
9088
9688
  if (isBatchingInteractiveUpdates) {
9089
9689
  // This is an interactive update
9090
9690
  expirationTime = computeInteractiveExpiration(currentTime);
@@ -9116,41 +9716,69 @@ function renderDidError() {
9116
9716
  nextRenderDidError = true;
9117
9717
  }
9118
9718
 
9119
- function retrySuspendedRoot(root, fiber, suspendedTime) {
9120
- if (enableSuspense) {
9121
- var retryTime = void 0;
9719
+ function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) {
9720
+ var retryTime = void 0;
9122
9721
 
9123
- if (isPriorityLevelSuspended(root, suspendedTime)) {
9124
- // Ping at the original level
9125
- retryTime = suspendedTime;
9126
- markPingedPriorityLevel(root, retryTime);
9127
- } else {
9128
- // Placeholder already timed out. Compute a new expiration time
9129
- var currentTime = requestCurrentTime();
9130
- retryTime = computeExpirationForFiber(currentTime, fiber);
9131
- markPendingPriorityLevel(root, retryTime);
9722
+ if (isPriorityLevelSuspended(root, suspendedTime)) {
9723
+ // Ping at the original level
9724
+ retryTime = suspendedTime;
9725
+
9726
+ markPingedPriorityLevel(root, retryTime);
9727
+ } else {
9728
+ // Suspense already timed out. Compute a new expiration time
9729
+ var currentTime = requestCurrentTime();
9730
+ retryTime = computeExpirationForFiber(currentTime, boundaryFiber);
9731
+ markPendingPriorityLevel(root, retryTime);
9732
+ }
9733
+
9734
+ // TODO: If the suspense fiber has already rendered the primary children
9735
+ // without suspending (that is, all of the promises have already resolved),
9736
+ // we should not trigger another update here. One case this happens is when
9737
+ // we are in sync mode and a single promise is thrown both on initial render
9738
+ // and on update; we attach two .then(retrySuspendedRoot) callbacks and each
9739
+ // one performs Sync work, rerendering the Suspense.
9740
+
9741
+ if ((boundaryFiber.mode & ConcurrentMode) !== NoContext) {
9742
+ if (root === nextRoot && nextRenderExpirationTime === suspendedTime) {
9743
+ // Received a ping at the same priority level at which we're currently
9744
+ // rendering. Restart from the root.
9745
+ nextRoot = null;
9132
9746
  }
9747
+ }
9133
9748
 
9134
- scheduleWorkToRoot(fiber, retryTime);
9135
- var rootExpirationTime = root.expirationTime;
9136
- if (rootExpirationTime !== NoWork) {
9137
- if (enableSchedulerTracing) {
9138
- // Restore previous interactions so that new work is associated with them.
9139
- var prevInteractions = tracing.__interactionsRef.current;
9140
- tracing.__interactionsRef.current = root.memoizedInteractions;
9141
- // Because suspense timeouts do not decrement the interaction count,
9142
- // Continued suspense work should also not increment the count.
9143
- storeInteractionsForExpirationTime(root, rootExpirationTime, false);
9144
- requestWork(root, rootExpirationTime);
9145
- tracing.__interactionsRef.current = prevInteractions;
9146
- } else {
9147
- requestWork(root, rootExpirationTime);
9148
- }
9749
+ scheduleWorkToRoot(boundaryFiber, retryTime);
9750
+ if ((boundaryFiber.mode & ConcurrentMode) === NoContext) {
9751
+ // Outside of concurrent mode, we must schedule an update on the source
9752
+ // fiber, too, since it already committed in an inconsistent state and
9753
+ // therefore does not have any pending work.
9754
+ scheduleWorkToRoot(sourceFiber, retryTime);
9755
+ var sourceTag = sourceFiber.tag;
9756
+ if (sourceTag === ClassComponent && sourceFiber.stateNode !== null) {
9757
+ // When we try rendering again, we should not reuse the current fiber,
9758
+ // since it's known to be in an inconsistent state. Use a force updte to
9759
+ // prevent a bail out.
9760
+ var update = createUpdate(retryTime);
9761
+ update.tag = ForceUpdate;
9762
+ enqueueUpdate(sourceFiber, update);
9149
9763
  }
9150
9764
  }
9765
+
9766
+ var rootExpirationTime = root.expirationTime;
9767
+ if (rootExpirationTime !== NoWork) {
9768
+ requestWork(root, rootExpirationTime);
9769
+ }
9151
9770
  }
9152
9771
 
9153
9772
  function scheduleWorkToRoot(fiber, expirationTime) {
9773
+ recordScheduleUpdate();
9774
+
9775
+ {
9776
+ if (fiber.tag === ClassComponent) {
9777
+ var instance = fiber.stateNode;
9778
+ warnAboutInvalidUpdates(instance);
9779
+ }
9780
+ }
9781
+
9154
9782
  // Update the source fiber's expiration time
9155
9783
  if (fiber.expirationTime === NoWork || fiber.expirationTime > expirationTime) {
9156
9784
  fiber.expirationTime = expirationTime;
@@ -9161,85 +9789,75 @@ function scheduleWorkToRoot(fiber, expirationTime) {
9161
9789
  }
9162
9790
  // Walk the parent path to the root and update the child expiration time.
9163
9791
  var node = fiber.return;
9792
+ var root = null;
9164
9793
  if (node === null && fiber.tag === HostRoot) {
9165
- return fiber.stateNode;
9166
- }
9167
- while (node !== null) {
9168
- alternate = node.alternate;
9169
- if (node.childExpirationTime === NoWork || node.childExpirationTime > expirationTime) {
9170
- node.childExpirationTime = expirationTime;
9171
- if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9794
+ root = fiber.stateNode;
9795
+ } else {
9796
+ while (node !== null) {
9797
+ alternate = node.alternate;
9798
+ if (node.childExpirationTime === NoWork || node.childExpirationTime > expirationTime) {
9799
+ node.childExpirationTime = expirationTime;
9800
+ if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9801
+ alternate.childExpirationTime = expirationTime;
9802
+ }
9803
+ } else if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9172
9804
  alternate.childExpirationTime = expirationTime;
9173
9805
  }
9174
- } else if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9175
- alternate.childExpirationTime = expirationTime;
9176
- }
9177
- if (node.return === null && node.tag === HostRoot) {
9178
- return node.stateNode;
9806
+ if (node.return === null && node.tag === HostRoot) {
9807
+ root = node.stateNode;
9808
+ break;
9809
+ }
9810
+ node = node.return;
9179
9811
  }
9180
- node = node.return;
9181
9812
  }
9182
- return null;
9183
- }
9184
9813
 
9185
- function storeInteractionsForExpirationTime(root, expirationTime, updateInteractionCounts) {
9186
- if (!enableSchedulerTracing) {
9187
- return;
9814
+ if (root === null) {
9815
+ if (true && fiber.tag === ClassComponent) {
9816
+ warnAboutUpdateOnUnmounted(fiber);
9817
+ }
9818
+ return null;
9188
9819
  }
9189
9820
 
9190
- var interactions = tracing.__interactionsRef.current;
9191
- if (interactions.size > 0) {
9192
- var pendingInteractions = root.pendingInteractionMap.get(expirationTime);
9193
- if (pendingInteractions != null) {
9194
- interactions.forEach(function (interaction) {
9195
- if (updateInteractionCounts && !pendingInteractions.has(interaction)) {
9196
- // Update the pending async work count for previously unscheduled interaction.
9197
- interaction.__count++;
9198
- }
9821
+ if (enableSchedulerTracing) {
9822
+ var interactions = tracing.__interactionsRef.current;
9823
+ if (interactions.size > 0) {
9824
+ var pendingInteractionMap = root.pendingInteractionMap;
9825
+ var pendingInteractions = pendingInteractionMap.get(expirationTime);
9826
+ if (pendingInteractions != null) {
9827
+ interactions.forEach(function (interaction) {
9828
+ if (!pendingInteractions.has(interaction)) {
9829
+ // Update the pending async work count for previously unscheduled interaction.
9830
+ interaction.__count++;
9831
+ }
9199
9832
 
9200
- pendingInteractions.add(interaction);
9201
- });
9202
- } else {
9203
- root.pendingInteractionMap.set(expirationTime, new Set(interactions));
9833
+ pendingInteractions.add(interaction);
9834
+ });
9835
+ } else {
9836
+ pendingInteractionMap.set(expirationTime, new Set(interactions));
9204
9837
 
9205
- // Update the pending async work count for the current interactions.
9206
- if (updateInteractionCounts) {
9838
+ // Update the pending async work count for the current interactions.
9207
9839
  interactions.forEach(function (interaction) {
9208
9840
  interaction.__count++;
9209
9841
  });
9210
9842
  }
9211
- }
9212
9843
 
9213
- var subscriber = tracing.__subscriberRef.current;
9214
- if (subscriber !== null) {
9215
- var threadID = computeThreadID(expirationTime, root.interactionThreadID);
9216
- subscriber.onWorkScheduled(interactions, threadID);
9844
+ var subscriber = tracing.__subscriberRef.current;
9845
+ if (subscriber !== null) {
9846
+ var threadID = computeThreadID(expirationTime, root.interactionThreadID);
9847
+ subscriber.onWorkScheduled(interactions, threadID);
9848
+ }
9217
9849
  }
9218
9850
  }
9851
+
9852
+ return root;
9219
9853
  }
9220
9854
 
9221
9855
  function scheduleWork(fiber, expirationTime) {
9222
- recordScheduleUpdate();
9223
-
9224
- {
9225
- if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) {
9226
- var instance = fiber.stateNode;
9227
- warnAboutInvalidUpdates(instance);
9228
- }
9229
- }
9230
-
9231
9856
  var root = scheduleWorkToRoot(fiber, expirationTime);
9232
9857
  if (root === null) {
9233
- if (true && (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy)) {
9234
- warnAboutUpdateOnUnmounted(fiber);
9235
- }
9236
9858
  return;
9237
9859
  }
9238
9860
 
9239
- if (enableSchedulerTracing) {
9240
- storeInteractionsForExpirationTime(root, expirationTime, true);
9241
- }
9242
-
9243
9861
  if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime < nextRenderExpirationTime) {
9244
9862
  // This is an interruption. (Used for performance tracking.)
9245
9863
  interruptedBy = fiber;
@@ -9351,7 +9969,7 @@ function onComplete(root, finishedWork, expirationTime) {
9351
9969
 
9352
9970
  function onSuspend(root, finishedWork, suspendedExpirationTime, rootExpirationTime, msUntilTimeout) {
9353
9971
  root.expirationTime = rootExpirationTime;
9354
- if (enableSuspense && msUntilTimeout === 0 && !shouldYield()) {
9972
+ if (msUntilTimeout === 0 && !shouldYield()) {
9355
9973
  // Don't wait an additional tick. Commit the tree immediately.
9356
9974
  root.pendingCommitExpirationTime = suspendedExpirationTime;
9357
9975
  root.finishedWork = finishedWork;
@@ -9366,26 +9984,15 @@ function onYield(root) {
9366
9984
  }
9367
9985
 
9368
9986
  function onTimeout(root, finishedWork, suspendedExpirationTime) {
9369
- if (enableSuspense) {
9370
- // The root timed out. Commit it.
9371
- root.pendingCommitExpirationTime = suspendedExpirationTime;
9372
- root.finishedWork = finishedWork;
9373
- // Read the current time before entering the commit phase. We can be
9374
- // certain this won't cause tearing related to batching of event updates
9375
- // because we're at the top of a timer event.
9376
- recomputeCurrentRendererTime();
9377
- currentSchedulerTime = currentRendererTime;
9378
-
9379
- if (enableSchedulerTracing) {
9380
- // Don't update pending interaction counts for suspense timeouts,
9381
- // Because we know we still need to do more work in this case.
9382
- suspenseDidTimeout = true;
9383
- flushRoot(root, suspendedExpirationTime);
9384
- suspenseDidTimeout = false;
9385
- } else {
9386
- flushRoot(root, suspendedExpirationTime);
9387
- }
9388
- }
9987
+ // The root timed out. Commit it.
9988
+ root.pendingCommitExpirationTime = suspendedExpirationTime;
9989
+ root.finishedWork = finishedWork;
9990
+ // Read the current time before entering the commit phase. We can be
9991
+ // certain this won't cause tearing related to batching of event updates
9992
+ // because we're at the top of a timer event.
9993
+ recomputeCurrentRendererTime();
9994
+ currentSchedulerTime = currentRendererTime;
9995
+ flushRoot(root, suspendedExpirationTime);
9389
9996
  }
9390
9997
 
9391
9998
  function onCommit(root, expirationTime) {
@@ -9684,7 +10291,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) {
9684
10291
  // If this root previously suspended, clear its existing timeout, since
9685
10292
  // we're about to try rendering again.
9686
10293
  var timeoutHandle = root.timeoutHandle;
9687
- if (enableSuspense && timeoutHandle !== noTimeout) {
10294
+ if (timeoutHandle !== noTimeout) {
9688
10295
  root.timeoutHandle = noTimeout;
9689
10296
  // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
9690
10297
  cancelTimeout(timeoutHandle);
@@ -9708,7 +10315,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) {
9708
10315
  // If this root previously suspended, clear its existing timeout, since
9709
10316
  // we're about to try rendering again.
9710
10317
  var _timeoutHandle = root.timeoutHandle;
9711
- if (enableSuspense && _timeoutHandle !== noTimeout) {
10318
+ if (_timeoutHandle !== noTimeout) {
9712
10319
  root.timeoutHandle = noTimeout;
9713
10320
  // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
9714
10321
  cancelTimeout(_timeoutHandle);
@@ -9814,9 +10421,9 @@ function flushSync(fn, a) {
9814
10421
 
9815
10422
 
9816
10423
  var didWarnAboutNestedUpdates = void 0;
9817
-
9818
10424
  {
9819
10425
  didWarnAboutNestedUpdates = false;
10426
+
9820
10427
  }
9821
10428
 
9822
10429
  function getContextForSubtree(parentComponent) {
@@ -9832,11 +10439,6 @@ function getContextForSubtree(parentComponent) {
9832
10439
  if (isContextProvider(Component)) {
9833
10440
  return processChildContext(fiber, Component, parentContext);
9834
10441
  }
9835
- } else if (fiber.tag === ClassComponentLazy) {
9836
- var _Component = getResultFromResolvedThenable(fiber.type);
9837
- if (isContextProvider(_Component)) {
9838
- return processChildContext(fiber, _Component, parentContext);
9839
- }
9840
10442
  }
9841
10443
 
9842
10444
  return parentContext;
@@ -9892,8 +10494,8 @@ function updateContainerAtExpirationTime(element, container, parentComponent, ex
9892
10494
  return scheduleRootUpdate(current$$1, element, expirationTime, callback);
9893
10495
  }
9894
10496
 
9895
- function createContainer(containerInfo, isAsync, hydrate) {
9896
- return createFiberRoot(containerInfo, isAsync, hydrate);
10497
+ function createContainer(containerInfo, isConcurrent, hydrate) {
10498
+ return createFiberRoot(containerInfo, isConcurrent, hydrate);
9897
10499
  }
9898
10500
 
9899
10501
  function updateContainer(element, container, parentComponent, callback) {
@@ -10063,7 +10665,7 @@ function batchedUpdates$1(fn, bookkeeping) {
10063
10665
 
10064
10666
  // TODO: this is special because it gets imported during build.
10065
10667
 
10066
- var ReactVersion = '16.5.2';
10668
+ var ReactVersion = '16.6.0';
10067
10669
 
10068
10670
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10069
10671
 
@@ -10071,10 +10673,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
10071
10673
 
10072
10674
  function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
10073
10675
 
10074
- /* eslint-disable no-use-before-define */
10075
-
10076
- /* eslint-enable no-use-before-define */
10077
-
10078
10676
  var defaultTestOptions = {
10079
10677
  createNodeMock: function () {
10080
10678
  return null;
@@ -10082,32 +10680,49 @@ var defaultTestOptions = {
10082
10680
  };
10083
10681
 
10084
10682
  function toJSON(inst) {
10683
+ if (inst.isHidden) {
10684
+ // Omit timed out children from output entirely. This seems like the least
10685
+ // surprising behavior. We could perhaps add a separate API that includes
10686
+ // them, if it turns out people need it.
10687
+ return null;
10688
+ }
10085
10689
  switch (inst.tag) {
10086
10690
  case 'TEXT':
10087
10691
  return inst.text;
10088
10692
  case 'INSTANCE':
10089
- /* eslint-disable no-unused-vars */
10090
- // We don't include the `children` prop in JSON.
10091
- // Instead, we will include the actual rendered children.
10092
- var _inst$props = inst.props,
10093
- _children = _inst$props.children,
10094
- _props = _objectWithoutProperties(_inst$props, ['children']);
10095
- /* eslint-enable */
10096
-
10097
-
10098
- var renderedChildren = null;
10099
- if (inst.children && inst.children.length) {
10100
- renderedChildren = inst.children.map(toJSON);
10693
+ {
10694
+ /* eslint-disable no-unused-vars */
10695
+ // We don't include the `children` prop in JSON.
10696
+ // Instead, we will include the actual rendered children.
10697
+ var _inst$props = inst.props,
10698
+ _children = _inst$props.children,
10699
+ _props = _objectWithoutProperties(_inst$props, ['children']);
10700
+ /* eslint-enable */
10701
+
10702
+
10703
+ var renderedChildren = null;
10704
+ if (inst.children && inst.children.length) {
10705
+ for (var i = 0; i < inst.children.length; i++) {
10706
+ var renderedChild = toJSON(inst.children[i]);
10707
+ if (renderedChild !== null) {
10708
+ if (renderedChildren === null) {
10709
+ renderedChildren = [renderedChild];
10710
+ } else {
10711
+ renderedChildren.push(renderedChild);
10712
+ }
10713
+ }
10714
+ }
10715
+ }
10716
+ var json = {
10717
+ type: inst.type,
10718
+ props: _props,
10719
+ children: renderedChildren
10720
+ };
10721
+ Object.defineProperty(json, '$$typeof', {
10722
+ value: Symbol.for('react.test.json')
10723
+ });
10724
+ return json;
10101
10725
  }
10102
- var json = {
10103
- type: inst.type,
10104
- props: _props,
10105
- children: renderedChildren
10106
- };
10107
- Object.defineProperty(json, '$$typeof', {
10108
- value: Symbol.for('react.test.json')
10109
- });
10110
- return json;
10111
10726
  default:
10112
10727
  throw new Error('Unexpected node type in toJSON: ' + inst.tag);
10113
10728
  }
@@ -10172,19 +10787,8 @@ function toTree(node) {
10172
10787
  instance: node.stateNode,
10173
10788
  rendered: childrenToTree(node.child)
10174
10789
  };
10175
- case ClassComponentLazy:
10176
- {
10177
- var thenable = node.type;
10178
- var _type = thenable._reactResult;
10179
- return {
10180
- nodeType: 'component',
10181
- type: _type,
10182
- props: _assign({}, node.memoizedProps),
10183
- instance: node.stateNode,
10184
- rendered: childrenToTree(node.child)
10185
- };
10186
- }
10187
- case FunctionalComponent:
10790
+ case FunctionComponent:
10791
+ case SimpleMemoComponent:
10188
10792
  return {
10189
10793
  nodeType: 'component',
10190
10794
  type: node.type,
@@ -10192,18 +10796,6 @@ function toTree(node) {
10192
10796
  instance: null,
10193
10797
  rendered: childrenToTree(node.child)
10194
10798
  };
10195
- case FunctionalComponentLazy:
10196
- {
10197
- var _thenable = node.type;
10198
- var _type2 = _thenable._reactResult;
10199
- return {
10200
- nodeType: 'component',
10201
- type: _type2,
10202
- props: _assign({}, node.memoizedProps),
10203
- instance: node.stateNode,
10204
- rendered: childrenToTree(node.child)
10205
- };
10206
- }
10207
10799
  case HostComponent:
10208
10800
  {
10209
10801
  return {
@@ -10222,14 +10814,15 @@ function toTree(node) {
10222
10814
  case Mode:
10223
10815
  case Profiler:
10224
10816
  case ForwardRef:
10225
- case ForwardRefLazy:
10817
+ case MemoComponent:
10818
+ case IncompleteClassComponent:
10226
10819
  return childrenToTree(node.child);
10227
10820
  default:
10228
10821
  invariant(false, 'toTree() does not yet know how to handle nodes with tag=%s', node.tag);
10229
10822
  }
10230
10823
  }
10231
10824
 
10232
- var validWrapperTypes = new Set([FunctionalComponent, FunctionalComponentLazy, ClassComponent, ClassComponentLazy, HostComponent, ForwardRef, ForwardRefLazy,
10825
+ var validWrapperTypes = new Set([FunctionComponent, ClassComponent, HostComponent, ForwardRef, MemoComponent,
10233
10826
  // Normally skipped, but used when there's more than one root child.
10234
10827
  HostRoot]);
10235
10828
 
@@ -10409,13 +11002,13 @@ function propsMatch(props, filter) {
10409
11002
  var ReactTestRendererFiber = {
10410
11003
  create: function (element, options) {
10411
11004
  var createNodeMock = defaultTestOptions.createNodeMock;
10412
- var isAsync = false;
11005
+ var isConcurrent = false;
10413
11006
  if (typeof options === 'object' && options !== null) {
10414
11007
  if (typeof options.createNodeMock === 'function') {
10415
11008
  createNodeMock = options.createNodeMock;
10416
11009
  }
10417
- if (options.unstable_isAsync === true) {
10418
- isAsync = true;
11010
+ if (options.unstable_isConcurrent === true) {
11011
+ isConcurrent = true;
10419
11012
  }
10420
11013
  }
10421
11014
  var container = {
@@ -10423,7 +11016,7 @@ var ReactTestRendererFiber = {
10423
11016
  createNodeMock: createNodeMock,
10424
11017
  tag: 'CONTAINER'
10425
11018
  };
10426
- var root = createContainer(container, isAsync, false);
11019
+ var root = createContainer(container, isConcurrent, false);
10427
11020
  !(root != null) ? invariant(false, 'something went wrong') : void 0;
10428
11021
  updateContainer(element, root, null, null);
10429
11022
 
@@ -10440,7 +11033,21 @@ var ReactTestRendererFiber = {
10440
11033
  if (container.children.length === 1) {
10441
11034
  return toJSON(container.children[0]);
10442
11035
  }
10443
- return container.children.map(toJSON);
11036
+
11037
+ var renderedChildren = null;
11038
+ if (container.children && container.children.length) {
11039
+ for (var i = 0; i < container.children.length; i++) {
11040
+ var renderedChild = toJSON(container.children[i]);
11041
+ if (renderedChild !== null) {
11042
+ if (renderedChildren === null) {
11043
+ renderedChildren = [renderedChild];
11044
+ } else {
11045
+ renderedChildren.push(renderedChild);
11046
+ }
11047
+ }
11048
+ }
11049
+ }
11050
+ return renderedChildren;
10444
11051
  },
10445
11052
  toTree: function () {
10446
11053
  if (root == null || root.current == null) {