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.
@@ -193,9 +193,11 @@ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeac
193
193
  var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
194
194
  var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
195
195
  var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
196
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
196
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
197
197
  var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
198
- var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
198
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
199
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
200
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
199
201
 
200
202
  var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
201
203
  var FAUX_ITERATOR_SYMBOL = '@@iterator';
@@ -215,12 +217,13 @@ var Pending = 0;
215
217
  var Resolved = 1;
216
218
  var Rejected = 2;
217
219
 
218
- function getResultFromResolvedThenable(thenable) {
219
- return thenable._reactResult;
220
+ function refineResolvedLazyComponent(lazyComponent) {
221
+ return lazyComponent._status === Resolved ? lazyComponent._result : null;
220
222
  }
221
223
 
222
- function refineResolvedThenable(thenable) {
223
- return thenable._reactStatus === Resolved ? thenable._reactResult : null;
224
+ function getWrappedName(outerType, innerType, wrapperName) {
225
+ var functionName = innerType.displayName || innerType.name || '';
226
+ return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
224
227
  }
225
228
 
226
229
  function getComponentName(type) {
@@ -240,8 +243,8 @@ function getComponentName(type) {
240
243
  return type;
241
244
  }
242
245
  switch (type) {
243
- case REACT_ASYNC_MODE_TYPE:
244
- return 'AsyncMode';
246
+ case REACT_CONCURRENT_MODE_TYPE:
247
+ return 'ConcurrentMode';
245
248
  case REACT_FRAGMENT_TYPE:
246
249
  return 'Fragment';
247
250
  case REACT_PORTAL_TYPE:
@@ -250,8 +253,8 @@ function getComponentName(type) {
250
253
  return 'Profiler';
251
254
  case REACT_STRICT_MODE_TYPE:
252
255
  return 'StrictMode';
253
- case REACT_PLACEHOLDER_TYPE:
254
- return 'Placeholder';
256
+ case REACT_SUSPENSE_TYPE:
257
+ return 'Suspense';
255
258
  }
256
259
  if (typeof type === 'object') {
257
260
  switch (type.$$typeof) {
@@ -260,38 +263,40 @@ function getComponentName(type) {
260
263
  case REACT_PROVIDER_TYPE:
261
264
  return 'Context.Provider';
262
265
  case REACT_FORWARD_REF_TYPE:
263
- var renderFn = type.render;
264
- var functionName = renderFn.displayName || renderFn.name || '';
265
- return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
266
- }
267
- if (typeof type.then === 'function') {
268
- var thenable = type;
269
- var resolvedThenable = refineResolvedThenable(thenable);
270
- if (resolvedThenable) {
271
- return getComponentName(resolvedThenable);
272
- }
266
+ return getWrappedName(type, type.render, 'ForwardRef');
267
+ case REACT_MEMO_TYPE:
268
+ return getComponentName(type.type);
269
+ case REACT_LAZY_TYPE:
270
+ {
271
+ var thenable = type;
272
+ var resolvedThenable = refineResolvedLazyComponent(thenable);
273
+ if (resolvedThenable) {
274
+ return getComponentName(resolvedThenable);
275
+ }
276
+ }
273
277
  }
274
278
  }
275
279
  return null;
276
280
  }
277
281
 
278
- var FunctionalComponent = 0;
279
- var FunctionalComponentLazy = 1;
280
- var ClassComponent = 2;
281
- var ClassComponentLazy = 3;
282
- var IndeterminateComponent = 4; // Before we know whether it is functional or class
283
- var HostRoot = 5; // Root of a host tree. Could be nested inside another node.
284
- var HostPortal = 6; // A subtree. Could be an entry point to a different renderer.
285
- var HostComponent = 7;
286
- var HostText = 8;
287
- var Fragment = 9;
288
- var Mode = 10;
289
- var ContextConsumer = 11;
290
- var ContextProvider = 12;
291
- var ForwardRef = 13;
292
- var ForwardRefLazy = 14;
293
- var Profiler = 15;
294
- var PlaceholderComponent = 16;
282
+ var FunctionComponent = 0;
283
+ var ClassComponent = 1;
284
+ var IndeterminateComponent = 2; // Before we know whether it is function or class
285
+ var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
286
+ var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
287
+ var HostComponent = 5;
288
+ var HostText = 6;
289
+ var Fragment = 7;
290
+ var Mode = 8;
291
+ var ContextConsumer = 9;
292
+ var ContextProvider = 10;
293
+ var ForwardRef = 11;
294
+ var Profiler = 12;
295
+ var SuspenseComponent = 13;
296
+ var MemoComponent = 14;
297
+ var SimpleMemoComponent = 15;
298
+ var LazyComponent = 16;
299
+ var IncompleteClassComponent = 17;
295
300
 
296
301
  // Don't change these two values. They're used by React Dev Tools.
297
302
  var NoEffect = /* */0;
@@ -359,7 +364,7 @@ function isFiberMounted(fiber) {
359
364
  function isMounted(component) {
360
365
  {
361
366
  var owner = ReactCurrentOwner.current;
362
- if (owner !== null && (owner.tag === ClassComponent || owner.tag === ClassComponentLazy)) {
367
+ if (owner !== null && owner.tag === ClassComponent) {
363
368
  var ownerFiber = owner;
364
369
  var instance = ownerFiber.stateNode;
365
370
  !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;
@@ -589,7 +594,9 @@ function flushAll() {
589
594
  didTimeout: false
590
595
  });
591
596
  }
592
- return yieldedValues;
597
+ var values = yieldedValues;
598
+ yieldedValues = [];
599
+ return values;
593
600
  }
594
601
 
595
602
  function flushNumberOfYields(count) {
@@ -615,7 +622,9 @@ function flushNumberOfYields(count) {
615
622
  didTimeout: false
616
623
  });
617
624
  }
618
- return yieldedValues;
625
+ var values = yieldedValues;
626
+ yieldedValues = [];
627
+ return values;
619
628
  }
620
629
 
621
630
  function yieldValue(value) {
@@ -642,6 +651,9 @@ var createContainerChildSet = shim;
642
651
  var appendChildToContainerChildSet = shim;
643
652
  var finalizeContainerChildren = shim;
644
653
  var replaceContainerChildren = shim;
654
+ var cloneHiddenInstance = shim;
655
+ var cloneUnhiddenInstance = shim;
656
+ var createHiddenTextInstance = shim;
645
657
 
646
658
  // Renderers that don't support hydration
647
659
  // can re-export everything from this module.
@@ -732,6 +744,7 @@ function createInstance(type, props, rootContainerInstance, hostContext, interna
732
744
  return {
733
745
  type: type,
734
746
  props: props,
747
+ isHidden: false,
735
748
  children: [],
736
749
  rootContainerInstance: rootContainerInstance,
737
750
  tag: 'INSTANCE'
@@ -765,6 +778,7 @@ function shouldDeprioritizeSubtree(type, props) {
765
778
  function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
766
779
  return {
767
780
  text: text,
781
+ isHidden: false,
768
782
  tag: 'TEXT'
769
783
  };
770
784
  }
@@ -807,6 +821,22 @@ var appendChildToContainer = appendChild;
807
821
  var insertInContainerBefore = insertBefore;
808
822
  var removeChildFromContainer = removeChild;
809
823
 
824
+ function hideInstance(instance) {
825
+ instance.isHidden = true;
826
+ }
827
+
828
+ function hideTextInstance(textInstance) {
829
+ textInstance.isHidden = true;
830
+ }
831
+
832
+ function unhideInstance(instance, props) {
833
+ instance.isHidden = false;
834
+ }
835
+
836
+ function unhideTextInstance(textInstance, text) {
837
+ textInstance.isHidden = false;
838
+ }
839
+
810
840
  /**
811
841
  * Copyright (c) 2013-present, Facebook, Inc.
812
842
  *
@@ -945,10 +975,9 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
945
975
  function describeFiber(fiber) {
946
976
  switch (fiber.tag) {
947
977
  case IndeterminateComponent:
948
- case FunctionalComponent:
949
- case FunctionalComponentLazy:
978
+ case LazyComponent:
979
+ case FunctionComponent:
950
980
  case ClassComponent:
951
- case ClassComponentLazy:
952
981
  case HostComponent:
953
982
  case Mode:
954
983
  var owner = fiber._debugOwner;
@@ -1027,10 +1056,7 @@ function setCurrentPhase(lifeCyclePhase) {
1027
1056
  var debugRenderPhaseSideEffects = false;
1028
1057
  var debugRenderPhaseSideEffectsForStrictMode = false;
1029
1058
  var enableUserTimingAPI = true;
1030
- var enableGetDerivedStateFromCatch = false;
1031
- var enableSuspense = false;
1032
1059
  var warnAboutDeprecatedLifecycles = false;
1033
- var warnAboutLegacyContextAPI = false;
1034
1060
  var replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
1035
1061
  var enableProfilerTimer = false;
1036
1062
  var enableSchedulerTracing = false;
@@ -1294,7 +1320,7 @@ function stopFailedWorkTimer(fiber) {
1294
1320
  return;
1295
1321
  }
1296
1322
  fiber._debugIsCurrentlyTiming = false;
1297
- var warning = 'An error was thrown inside this error boundary';
1323
+ var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1298
1324
  endFiberMark(fiber, null, warning);
1299
1325
  }
1300
1326
  }
@@ -1716,7 +1742,7 @@ function invalidateContextProvider(workInProgress, type, didChange) {
1716
1742
  function findCurrentUnmaskedContext(fiber) {
1717
1743
  // Currently this is only used with renderSubtreeIntoContainer; not sure if it
1718
1744
  // makes sense elsewhere
1719
- !(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;
1745
+ !(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;
1720
1746
 
1721
1747
  var node = fiber;
1722
1748
  do {
@@ -1731,14 +1757,6 @@ function findCurrentUnmaskedContext(fiber) {
1731
1757
  }
1732
1758
  break;
1733
1759
  }
1734
- case ClassComponentLazy:
1735
- {
1736
- var _Component = getResultFromResolvedThenable(node.type);
1737
- if (isContextProvider(_Component)) {
1738
- return node.stateNode.__reactInternalMemoizedMergedChildContext;
1739
- }
1740
- break;
1741
- }
1742
1760
  }
1743
1761
  node = node.return;
1744
1762
  } while (node !== null);
@@ -1870,7 +1888,7 @@ function computeInteractiveExpiration(currentTime) {
1870
1888
  }
1871
1889
 
1872
1890
  var NoContext = 0;
1873
- var AsyncMode = 1;
1891
+ var ConcurrentMode = 1;
1874
1892
  var StrictMode = 2;
1875
1893
  var ProfileMode = 4;
1876
1894
 
@@ -1907,6 +1925,7 @@ function FiberNode(tag, pendingProps, key, mode) {
1907
1925
  // Instance
1908
1926
  this.tag = tag;
1909
1927
  this.key = key;
1928
+ this.elementType = null;
1910
1929
  this.type = null;
1911
1930
  this.stateNode = null;
1912
1931
 
@@ -1979,11 +1998,21 @@ function shouldConstruct(Component) {
1979
1998
  return !!(prototype && prototype.isReactComponent);
1980
1999
  }
1981
2000
 
1982
- function resolveLazyComponentTag(fiber, Component) {
2001
+ function isSimpleFunctionComponent(type) {
2002
+ return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
2003
+ }
2004
+
2005
+ function resolveLazyComponentTag(Component) {
1983
2006
  if (typeof Component === 'function') {
1984
- return shouldConstruct(Component) ? ClassComponentLazy : FunctionalComponentLazy;
1985
- } else if (Component !== undefined && Component !== null && Component.$$typeof) {
1986
- return ForwardRefLazy;
2007
+ return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
2008
+ } else if (Component !== undefined && Component !== null) {
2009
+ var $$typeof = Component.$$typeof;
2010
+ if ($$typeof === REACT_FORWARD_REF_TYPE) {
2011
+ return ForwardRef;
2012
+ }
2013
+ if ($$typeof === REACT_MEMO_TYPE) {
2014
+ return MemoComponent;
2015
+ }
1987
2016
  }
1988
2017
  return IndeterminateComponent;
1989
2018
  }
@@ -1998,6 +2027,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
1998
2027
  // extra objects for things that are never updated. It also allow us to
1999
2028
  // reclaim the extra memory if needed.
2000
2029
  workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
2030
+ workInProgress.elementType = current.elementType;
2001
2031
  workInProgress.type = current.type;
2002
2032
  workInProgress.stateNode = current.stateNode;
2003
2033
 
@@ -2032,15 +2062,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
2032
2062
  }
2033
2063
  }
2034
2064
 
2035
- // Don't touching the subtree's expiration time, which has not changed.
2036
2065
  workInProgress.childExpirationTime = current.childExpirationTime;
2037
- if (pendingProps !== current.pendingProps) {
2038
- // This fiber has new props.
2039
- workInProgress.expirationTime = expirationTime;
2040
- } else {
2041
- // This fiber's props have not changed.
2042
- workInProgress.expirationTime = current.expirationTime;
2043
- }
2066
+ workInProgress.expirationTime = current.expirationTime;
2044
2067
 
2045
2068
  workInProgress.child = current.child;
2046
2069
  workInProgress.memoizedProps = current.memoizedProps;
@@ -2061,8 +2084,8 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
2061
2084
  return workInProgress;
2062
2085
  }
2063
2086
 
2064
- function createHostRootFiber(isAsync) {
2065
- var mode = isAsync ? AsyncMode | StrictMode : NoContext;
2087
+ function createHostRootFiber(isConcurrent) {
2088
+ var mode = isConcurrent ? ConcurrentMode | StrictMode : NoContext;
2066
2089
 
2067
2090
  if (enableProfilerTimer && isDevToolsPresent) {
2068
2091
  // Always collect profile timings when DevTools are present.
@@ -2074,39 +2097,31 @@ function createHostRootFiber(isAsync) {
2074
2097
  return createFiber(HostRoot, null, null, mode);
2075
2098
  }
2076
2099
 
2077
- function createFiberFromElement(element, mode, expirationTime) {
2078
- var owner = null;
2079
- {
2080
- owner = element._owner;
2081
- }
2082
-
2100
+ function createFiberFromTypeAndProps(type, // React$ElementType
2101
+ key, pendingProps, owner, mode, expirationTime) {
2083
2102
  var fiber = void 0;
2084
- var type = element.type;
2085
- var key = element.key;
2086
- var pendingProps = element.props;
2087
2103
 
2088
- var fiberTag = void 0;
2104
+ var fiberTag = IndeterminateComponent;
2105
+ // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
2106
+ var resolvedType = type;
2089
2107
  if (typeof type === 'function') {
2090
- fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
2108
+ if (shouldConstruct(type)) {
2109
+ fiberTag = ClassComponent;
2110
+ }
2091
2111
  } else if (typeof type === 'string') {
2092
2112
  fiberTag = HostComponent;
2093
2113
  } else {
2094
2114
  getTag: switch (type) {
2095
2115
  case REACT_FRAGMENT_TYPE:
2096
2116
  return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
2097
- case REACT_ASYNC_MODE_TYPE:
2098
- fiberTag = Mode;
2099
- mode |= AsyncMode | StrictMode;
2100
- break;
2117
+ case REACT_CONCURRENT_MODE_TYPE:
2118
+ return createFiberFromMode(pendingProps, mode | ConcurrentMode | StrictMode, expirationTime, key);
2101
2119
  case REACT_STRICT_MODE_TYPE:
2102
- fiberTag = Mode;
2103
- mode |= StrictMode;
2104
- break;
2120
+ return createFiberFromMode(pendingProps, mode | StrictMode, expirationTime, key);
2105
2121
  case REACT_PROFILER_TYPE:
2106
2122
  return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
2107
- case REACT_PLACEHOLDER_TYPE:
2108
- fiberTag = PlaceholderComponent;
2109
- break;
2123
+ case REACT_SUSPENSE_TYPE:
2124
+ return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
2110
2125
  default:
2111
2126
  {
2112
2127
  if (typeof type === 'object' && type !== null) {
@@ -2121,13 +2136,13 @@ function createFiberFromElement(element, mode, expirationTime) {
2121
2136
  case REACT_FORWARD_REF_TYPE:
2122
2137
  fiberTag = ForwardRef;
2123
2138
  break getTag;
2124
- default:
2125
- {
2126
- if (typeof type.then === 'function') {
2127
- fiberTag = IndeterminateComponent;
2128
- break getTag;
2129
- }
2130
- }
2139
+ case REACT_MEMO_TYPE:
2140
+ fiberTag = MemoComponent;
2141
+ break getTag;
2142
+ case REACT_LAZY_TYPE:
2143
+ fiberTag = LazyComponent;
2144
+ resolvedType = null;
2145
+ break getTag;
2131
2146
  }
2132
2147
  }
2133
2148
  var info = '';
@@ -2146,14 +2161,26 @@ function createFiberFromElement(element, mode, expirationTime) {
2146
2161
  }
2147
2162
 
2148
2163
  fiber = createFiber(fiberTag, pendingProps, key, mode);
2149
- fiber.type = type;
2164
+ fiber.elementType = type;
2165
+ fiber.type = resolvedType;
2150
2166
  fiber.expirationTime = expirationTime;
2151
2167
 
2168
+ return fiber;
2169
+ }
2170
+
2171
+ function createFiberFromElement(element, mode, expirationTime) {
2172
+ var owner = null;
2173
+ {
2174
+ owner = element._owner;
2175
+ }
2176
+ var type = element.type;
2177
+ var key = element.key;
2178
+ var pendingProps = element.props;
2179
+ var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
2152
2180
  {
2153
2181
  fiber._debugSource = element._source;
2154
2182
  fiber._debugOwner = element._owner;
2155
2183
  }
2156
-
2157
2184
  return fiber;
2158
2185
  }
2159
2186
 
@@ -2171,12 +2198,38 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
2171
2198
  }
2172
2199
 
2173
2200
  var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
2201
+ // TODO: The Profiler fiber shouldn't have a type. It has a tag.
2202
+ fiber.elementType = REACT_PROFILER_TYPE;
2174
2203
  fiber.type = REACT_PROFILER_TYPE;
2175
2204
  fiber.expirationTime = expirationTime;
2176
2205
 
2177
2206
  return fiber;
2178
2207
  }
2179
2208
 
2209
+ function createFiberFromMode(pendingProps, mode, expirationTime, key) {
2210
+ var fiber = createFiber(Mode, pendingProps, key, mode);
2211
+
2212
+ // TODO: The Mode fiber shouldn't have a type. It has a tag.
2213
+ var type = (mode & ConcurrentMode) === NoContext ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE;
2214
+ fiber.elementType = type;
2215
+ fiber.type = type;
2216
+
2217
+ fiber.expirationTime = expirationTime;
2218
+ return fiber;
2219
+ }
2220
+
2221
+ function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
2222
+ var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
2223
+
2224
+ // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
2225
+ var type = REACT_SUSPENSE_TYPE;
2226
+ fiber.elementType = type;
2227
+ fiber.type = type;
2228
+
2229
+ fiber.expirationTime = expirationTime;
2230
+ return fiber;
2231
+ }
2232
+
2180
2233
  function createFiberFromText(content, mode, expirationTime) {
2181
2234
  var fiber = createFiber(HostText, content, null, mode);
2182
2235
  fiber.expirationTime = expirationTime;
@@ -2185,6 +2238,8 @@ function createFiberFromText(content, mode, expirationTime) {
2185
2238
 
2186
2239
  function createFiberFromHostInstanceForDeletion() {
2187
2240
  var fiber = createFiber(HostComponent, null, null, NoContext);
2241
+ // TODO: These should not need a type.
2242
+ fiber.elementType = 'DELETED';
2188
2243
  fiber.type = 'DELETED';
2189
2244
  return fiber;
2190
2245
  }
@@ -2217,6 +2272,7 @@ function assignFiberPropertiesInDEV(target, source) {
2217
2272
 
2218
2273
  target.tag = source.tag;
2219
2274
  target.key = source.key;
2275
+ target.elementType = source.elementType;
2220
2276
  target.type = source.type;
2221
2277
  target.stateNode = source.stateNode;
2222
2278
  target.return = source.return;
@@ -2252,7 +2308,7 @@ function assignFiberPropertiesInDEV(target, source) {
2252
2308
 
2253
2309
  var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2254
2310
 
2255
- var _ReactInternals$Sched = ReactInternals$1.ScheduleTracing;
2311
+ var _ReactInternals$Sched = ReactInternals$1.SchedulerTracing;
2256
2312
  var __interactionsRef = _ReactInternals$Sched.__interactionsRef;
2257
2313
  var __subscriberRef = _ReactInternals$Sched.__subscriberRef;
2258
2314
  var unstable_clear = _ReactInternals$Sched.unstable_clear;
@@ -2263,7 +2319,6 @@ var unstable_trace = _ReactInternals$Sched.unstable_trace;
2263
2319
  var unstable_unsubscribe = _ReactInternals$Sched.unstable_unsubscribe;
2264
2320
  var unstable_wrap = _ReactInternals$Sched.unstable_wrap;
2265
2321
 
2266
- /* eslint-disable no-use-before-define */
2267
2322
  // TODO: This should be lifted into the renderer.
2268
2323
 
2269
2324
 
@@ -2279,12 +2334,11 @@ var unstable_wrap = _ReactInternals$Sched.unstable_wrap;
2279
2334
  // The types are defined separately within this file to ensure they stay in sync.
2280
2335
  // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
2281
2336
 
2282
- /* eslint-enable no-use-before-define */
2283
2337
 
2284
- function createFiberRoot(containerInfo, isAsync, hydrate) {
2338
+ function createFiberRoot(containerInfo, isConcurrent, hydrate) {
2285
2339
  // Cyclic construction. This cheats the type system right now because
2286
2340
  // stateNode is any.
2287
- var uninitializedFiber = createHostRootFiber(isAsync);
2341
+ var uninitializedFiber = createHostRootFiber(isConcurrent);
2288
2342
 
2289
2343
  var root = void 0;
2290
2344
  if (enableSchedulerTracing) {
@@ -2407,6 +2461,10 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
2407
2461
  // browsers that support it.
2408
2462
  var windowEvent = window.event;
2409
2463
 
2464
+ // Keeps track of the descriptor of window.event to restore it after event
2465
+ // dispatching: https://github.com/facebook/react/issues/13688
2466
+ var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
2467
+
2410
2468
  // Create an event handler for our fake event. We will synchronously
2411
2469
  // dispatch our fake event using `dispatchEvent`. Inside the handler, we
2412
2470
  // call the user-provided callback.
@@ -2478,6 +2536,10 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
2478
2536
  evt.initEvent(evtType, false, false);
2479
2537
  fakeNode.dispatchEvent(evt);
2480
2538
 
2539
+ if (windowEventDescriptor) {
2540
+ Object.defineProperty(window, 'event', windowEventDescriptor);
2541
+ }
2542
+
2481
2543
  if (didError) {
2482
2544
  if (!didSetError) {
2483
2545
  // The callback errored, but the error event never fired.
@@ -3301,7 +3363,7 @@ function enqueueUpdate(fiber, update) {
3301
3363
  }
3302
3364
 
3303
3365
  {
3304
- if ((fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
3366
+ if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
3305
3367
  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.');
3306
3368
  didWarnUpdateInsideUpdate = true;
3307
3369
  }
@@ -3674,7 +3736,7 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
3674
3736
  if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
3675
3737
  // Match! Schedule an update on this fiber.
3676
3738
 
3677
- if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) {
3739
+ if (fiber.tag === ClassComponent) {
3678
3740
  // Schedule a force update on the work-in-progress.
3679
3741
  var update = createUpdate(renderExpirationTime);
3680
3742
  update.tag = ForceUpdate;
@@ -3781,7 +3843,7 @@ function readContext(context, observedBits) {
3781
3843
  };
3782
3844
 
3783
3845
  if (lastContextDependency === null) {
3784
- !(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;
3846
+ !(currentlyRenderingFiber !== null) ? invariant(false, 'Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0;
3785
3847
  // This is the first dependency in the list
3786
3848
  currentlyRenderingFiber.firstContextDependency = lastContextDependency = contextItem;
3787
3849
  } else {
@@ -3966,8 +4028,15 @@ function shallowEqual(objA, objB) {
3966
4028
  return true;
3967
4029
  }
3968
4030
 
4031
+ var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
4032
+
4033
+ function readContext$1(contextType) {
4034
+ var dispatcher = ReactCurrentOwner$3.currentDispatcher;
4035
+ return dispatcher.readContext(contextType);
4036
+ }
4037
+
3969
4038
  var fakeInternalInstance = {};
3970
- var isArray = Array.isArray;
4039
+ var isArray$1 = Array.isArray;
3971
4040
 
3972
4041
  // React.Component uses a shared frozen object by default.
3973
4042
  // We'll use it to determine whether we need to initialize legacy refs.
@@ -3981,6 +4050,8 @@ var didWarnAboutUndefinedDerivedState = void 0;
3981
4050
  var warnOnUndefinedDerivedState = void 0;
3982
4051
  var warnOnInvalidCallback = void 0;
3983
4052
  var didWarnAboutDirectlyAssigningPropsToState = void 0;
4053
+ var didWarnAboutContextTypeAndContextTypes = void 0;
4054
+ var didWarnAboutInvalidateContextType = void 0;
3984
4055
 
3985
4056
  {
3986
4057
  didWarnAboutStateAssignmentForComponent = new Set();
@@ -3989,6 +4060,8 @@ var didWarnAboutDirectlyAssigningPropsToState = void 0;
3989
4060
  didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
3990
4061
  didWarnAboutDirectlyAssigningPropsToState = new Set();
3991
4062
  didWarnAboutUndefinedDerivedState = new Set();
4063
+ didWarnAboutContextTypeAndContextTypes = new Set();
4064
+ didWarnAboutInvalidateContextType = new Set();
3992
4065
 
3993
4066
  var didWarnOnInvalidCallback = new Set();
3994
4067
 
@@ -4112,11 +4185,11 @@ var classComponentUpdater = {
4112
4185
  }
4113
4186
  };
4114
4187
 
4115
- function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextLegacyContext) {
4188
+ function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
4116
4189
  var instance = workInProgress.stateNode;
4117
4190
  if (typeof instance.shouldComponentUpdate === 'function') {
4118
4191
  startPhaseTimer(workInProgress, 'shouldComponentUpdate');
4119
- var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextLegacyContext);
4192
+ var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
4120
4193
  stopPhaseTimer();
4121
4194
 
4122
4195
  {
@@ -4153,8 +4226,16 @@ function checkClassInstance(workInProgress, ctor, newProps) {
4153
4226
  !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;
4154
4227
  var noInstancePropTypes = !instance.propTypes;
4155
4228
  !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
4229
+ var noInstanceContextType = !instance.contextType;
4230
+ !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
4156
4231
  var noInstanceContextTypes = !instance.contextTypes;
4157
4232
  !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
4233
+
4234
+ if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
4235
+ didWarnAboutContextTypeAndContextTypes.add(ctor);
4236
+ warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
4237
+ }
4238
+
4158
4239
  var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
4159
4240
  !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;
4160
4241
  if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
@@ -4180,12 +4261,12 @@ function checkClassInstance(workInProgress, ctor, newProps) {
4180
4261
 
4181
4262
  var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
4182
4263
  !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;
4183
- var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromCatch !== 'function';
4184
- !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;
4264
+ var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
4265
+ !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;
4185
4266
  var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
4186
4267
  !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;
4187
4268
  var _state = instance.state;
4188
- if (_state && (typeof _state !== 'object' || isArray(_state))) {
4269
+ if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
4189
4270
  warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
4190
4271
  }
4191
4272
  if (typeof instance.getChildContext === 'function') {
@@ -4205,10 +4286,25 @@ function adoptClassInstance(workInProgress, instance) {
4205
4286
  }
4206
4287
 
4207
4288
  function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
4208
- var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4209
- var contextTypes = ctor.contextTypes;
4210
- var isContextConsumer = contextTypes !== null && contextTypes !== undefined;
4211
- var context = isContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
4289
+ var isLegacyContextConsumer = false;
4290
+ var unmaskedContext = emptyContextObject;
4291
+ var context = null;
4292
+ var contextType = ctor.contextType;
4293
+ if (typeof contextType === 'object' && contextType !== null) {
4294
+ {
4295
+ if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
4296
+ didWarnAboutInvalidateContextType.add(ctor);
4297
+ 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');
4298
+ }
4299
+ }
4300
+
4301
+ context = readContext$1(contextType);
4302
+ } else {
4303
+ unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4304
+ var contextTypes = ctor.contextTypes;
4305
+ isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
4306
+ context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
4307
+ }
4212
4308
 
4213
4309
  // Instantiate twice to help detect side-effects.
4214
4310
  {
@@ -4265,7 +4361,7 @@ function constructClassInstance(workInProgress, ctor, props, renderExpirationTim
4265
4361
 
4266
4362
  // Cache unmasked context so we can avoid recreating masked context unless necessary.
4267
4363
  // ReactFiberContext usually updates this cache but can't for newly-created instances.
4268
- if (isContextConsumer) {
4364
+ if (isLegacyContextConsumer) {
4269
4365
  cacheContext(workInProgress, unmaskedContext, context);
4270
4366
  }
4271
4367
 
@@ -4293,14 +4389,14 @@ function callComponentWillMount(workInProgress, instance) {
4293
4389
  }
4294
4390
  }
4295
4391
 
4296
- function callComponentWillReceiveProps(workInProgress, instance, newProps, nextLegacyContext) {
4392
+ function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
4297
4393
  var oldState = instance.state;
4298
4394
  startPhaseTimer(workInProgress, 'componentWillReceiveProps');
4299
4395
  if (typeof instance.componentWillReceiveProps === 'function') {
4300
- instance.componentWillReceiveProps(newProps, nextLegacyContext);
4396
+ instance.componentWillReceiveProps(newProps, nextContext);
4301
4397
  }
4302
4398
  if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4303
- instance.UNSAFE_componentWillReceiveProps(newProps, nextLegacyContext);
4399
+ instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
4304
4400
  }
4305
4401
  stopPhaseTimer();
4306
4402
 
@@ -4323,12 +4419,17 @@ function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime
4323
4419
  }
4324
4420
 
4325
4421
  var instance = workInProgress.stateNode;
4326
- var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4327
-
4328
4422
  instance.props = newProps;
4329
4423
  instance.state = workInProgress.memoizedState;
4330
4424
  instance.refs = emptyRefsObject;
4331
- instance.context = getMaskedContext(workInProgress, unmaskedContext);
4425
+
4426
+ var contextType = ctor.contextType;
4427
+ if (typeof contextType === 'object' && contextType !== null) {
4428
+ instance.context = readContext$1(contextType);
4429
+ } else {
4430
+ var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4431
+ instance.context = getMaskedContext(workInProgress, unmaskedContext);
4432
+ }
4332
4433
 
4333
4434
  {
4334
4435
  if (instance.state === newProps) {
@@ -4387,8 +4488,14 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4387
4488
  instance.props = oldProps;
4388
4489
 
4389
4490
  var oldContext = instance.context;
4390
- var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4391
- var nextLegacyContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4491
+ var contextType = ctor.contextType;
4492
+ var nextContext = void 0;
4493
+ if (typeof contextType === 'object' && contextType !== null) {
4494
+ nextContext = readContext$1(contextType);
4495
+ } else {
4496
+ var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4497
+ nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4498
+ }
4392
4499
 
4393
4500
  var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4394
4501
  var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
@@ -4400,8 +4507,8 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4400
4507
  // In order to support react-lifecycles-compat polyfilled components,
4401
4508
  // Unsafe lifecycles should not be invoked for components using the new APIs.
4402
4509
  if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4403
- if (oldProps !== newProps || oldContext !== nextLegacyContext) {
4404
- callComponentWillReceiveProps(workInProgress, instance, newProps, nextLegacyContext);
4510
+ if (oldProps !== newProps || oldContext !== nextContext) {
4511
+ callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4405
4512
  }
4406
4513
  }
4407
4514
 
@@ -4428,7 +4535,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4428
4535
  newState = workInProgress.memoizedState;
4429
4536
  }
4430
4537
 
4431
- var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextLegacyContext);
4538
+ var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4432
4539
 
4433
4540
  if (shouldUpdate) {
4434
4541
  // In order to support react-lifecycles-compat polyfilled components,
@@ -4463,7 +4570,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirati
4463
4570
  // if shouldComponentUpdate returns false.
4464
4571
  instance.props = newProps;
4465
4572
  instance.state = newState;
4466
- instance.context = nextLegacyContext;
4573
+ instance.context = nextContext;
4467
4574
 
4468
4575
  return shouldUpdate;
4469
4576
  }
@@ -4476,8 +4583,14 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4476
4583
  instance.props = oldProps;
4477
4584
 
4478
4585
  var oldContext = instance.context;
4479
- var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4480
- var nextLegacyContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4586
+ var contextType = ctor.contextType;
4587
+ var nextContext = void 0;
4588
+ if (typeof contextType === 'object' && contextType !== null) {
4589
+ nextContext = readContext$1(contextType);
4590
+ } else {
4591
+ var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4592
+ nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
4593
+ }
4481
4594
 
4482
4595
  var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4483
4596
  var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
@@ -4489,8 +4602,8 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4489
4602
  // In order to support react-lifecycles-compat polyfilled components,
4490
4603
  // Unsafe lifecycles should not be invoked for components using the new APIs.
4491
4604
  if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4492
- if (oldProps !== newProps || oldContext !== nextLegacyContext) {
4493
- callComponentWillReceiveProps(workInProgress, instance, newProps, nextLegacyContext);
4605
+ if (oldProps !== newProps || oldContext !== nextContext) {
4606
+ callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4494
4607
  }
4495
4608
  }
4496
4609
 
@@ -4525,7 +4638,7 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4525
4638
  newState = workInProgress.memoizedState;
4526
4639
  }
4527
4640
 
4528
- var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextLegacyContext);
4641
+ var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4529
4642
 
4530
4643
  if (shouldUpdate) {
4531
4644
  // In order to support react-lifecycles-compat polyfilled components,
@@ -4533,10 +4646,10 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4533
4646
  if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
4534
4647
  startPhaseTimer(workInProgress, 'componentWillUpdate');
4535
4648
  if (typeof instance.componentWillUpdate === 'function') {
4536
- instance.componentWillUpdate(newProps, newState, nextLegacyContext);
4649
+ instance.componentWillUpdate(newProps, newState, nextContext);
4537
4650
  }
4538
4651
  if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4539
- instance.UNSAFE_componentWillUpdate(newProps, newState, nextLegacyContext);
4652
+ instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
4540
4653
  }
4541
4654
  stopPhaseTimer();
4542
4655
  }
@@ -4570,7 +4683,7 @@ function updateClassInstance(current, workInProgress, ctor, newProps, renderExpi
4570
4683
  // if shouldComponentUpdate returns false.
4571
4684
  instance.props = newProps;
4572
4685
  instance.state = newState;
4573
- instance.context = nextLegacyContext;
4686
+ instance.context = nextContext;
4574
4687
 
4575
4688
  return shouldUpdate;
4576
4689
  }
@@ -4615,7 +4728,7 @@ var warnForMissingKey = function (child) {};
4615
4728
  };
4616
4729
  }
4617
4730
 
4618
- var isArray$1 = Array.isArray;
4731
+ var isArray = Array.isArray;
4619
4732
 
4620
4733
  function coerceRef(returnFiber, current$$1, element) {
4621
4734
  var mixedRef = element.ref;
@@ -4635,7 +4748,7 @@ function coerceRef(returnFiber, current$$1, element) {
4635
4748
  var inst = void 0;
4636
4749
  if (owner) {
4637
4750
  var ownerFiber = owner;
4638
- !(ownerFiber.tag === ClassComponent || ownerFiber.tag === ClassComponentLazy) ? invariant(false, 'Stateless function components cannot have refs.') : void 0;
4751
+ !(ownerFiber.tag === ClassComponent) ? invariant(false, 'Function components cannot have refs.') : void 0;
4639
4752
  inst = ownerFiber.stateNode;
4640
4753
  }
4641
4754
  !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;
@@ -4660,7 +4773,7 @@ function coerceRef(returnFiber, current$$1, element) {
4660
4773
  return ref;
4661
4774
  } else {
4662
4775
  !(typeof mixedRef === 'string') ? invariant(false, 'Expected ref to be a function, a string, an object returned by React.createRef(), or null.') : void 0;
4663
- !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;
4776
+ !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;
4664
4777
  }
4665
4778
  }
4666
4779
  return mixedRef;
@@ -4803,7 +4916,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4803
4916
  }
4804
4917
 
4805
4918
  function updateElement(returnFiber, current$$1, element, expirationTime) {
4806
- if (current$$1 !== null && current$$1.type === element.type) {
4919
+ if (current$$1 !== null && current$$1.elementType === element.type) {
4807
4920
  // Move based on index
4808
4921
  var existing = useFiber(current$$1, element.props, expirationTime);
4809
4922
  existing.ref = coerceRef(returnFiber, current$$1, element);
@@ -4877,7 +4990,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4877
4990
  }
4878
4991
  }
4879
4992
 
4880
- if (isArray$1(newChild) || getIteratorFn(newChild)) {
4993
+ if (isArray(newChild) || getIteratorFn(newChild)) {
4881
4994
  var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
4882
4995
  _created3.return = returnFiber;
4883
4996
  return _created3;
@@ -4933,7 +5046,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4933
5046
  }
4934
5047
  }
4935
5048
 
4936
- if (isArray$1(newChild) || getIteratorFn(newChild)) {
5049
+ if (isArray(newChild) || getIteratorFn(newChild)) {
4937
5050
  if (key !== null) {
4938
5051
  return null;
4939
5052
  }
@@ -4978,7 +5091,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4978
5091
  }
4979
5092
  }
4980
5093
 
4981
- if (isArray$1(newChild) || getIteratorFn(newChild)) {
5094
+ if (isArray(newChild) || getIteratorFn(newChild)) {
4982
5095
  var _matchedFiber3 = existingChildren.get(newIdx) || null;
4983
5096
  return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
4984
5097
  }
@@ -5345,7 +5458,7 @@ function ChildReconciler(shouldTrackSideEffects) {
5345
5458
  // TODO: If key === null and child.key === null, then this only applies to
5346
5459
  // the first item in the list.
5347
5460
  if (child.key === key) {
5348
- if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {
5461
+ if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {
5349
5462
  deleteRemainingChildren(returnFiber, child.sibling);
5350
5463
  var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
5351
5464
  existing.ref = coerceRef(returnFiber, child, element);
@@ -5437,7 +5550,7 @@ function ChildReconciler(shouldTrackSideEffects) {
5437
5550
  return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
5438
5551
  }
5439
5552
 
5440
- if (isArray$1(newChild)) {
5553
+ if (isArray(newChild)) {
5441
5554
  return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
5442
5555
  }
5443
5556
 
@@ -5460,7 +5573,6 @@ function ChildReconciler(shouldTrackSideEffects) {
5460
5573
  // we already threw above.
5461
5574
  switch (returnFiber.tag) {
5462
5575
  case ClassComponent:
5463
- case ClassComponentLazy:
5464
5576
  {
5465
5577
  {
5466
5578
  var instance = returnFiber.stateNode;
@@ -5473,7 +5585,7 @@ function ChildReconciler(shouldTrackSideEffects) {
5473
5585
  // Intentionally fall through to the next case, which handles both
5474
5586
  // functions and classes
5475
5587
  // eslint-disable-next-lined no-fallthrough
5476
- case FunctionalComponent:
5588
+ case FunctionComponent:
5477
5589
  {
5478
5590
  var Component = returnFiber.type;
5479
5591
  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');
@@ -5775,40 +5887,49 @@ function resetHydrationState() {
5775
5887
  isHydrating = false;
5776
5888
  }
5777
5889
 
5778
- function readLazyComponentType(thenable) {
5779
- var status = thenable._reactStatus;
5890
+ function readLazyComponentType(lazyComponent) {
5891
+ var status = lazyComponent._status;
5892
+ var result = lazyComponent._result;
5780
5893
  switch (status) {
5781
5894
  case Resolved:
5782
- var Component = thenable._reactResult;
5783
- return Component;
5895
+ {
5896
+ var Component = result;
5897
+ return Component;
5898
+ }
5784
5899
  case Rejected:
5785
- throw thenable._reactResult;
5900
+ {
5901
+ var error = result;
5902
+ throw error;
5903
+ }
5786
5904
  case Pending:
5787
- throw thenable;
5905
+ {
5906
+ var thenable = result;
5907
+ throw thenable;
5908
+ }
5788
5909
  default:
5789
5910
  {
5790
- thenable._reactStatus = Pending;
5791
- thenable.then(function (resolvedValue) {
5792
- if (thenable._reactStatus === Pending) {
5793
- thenable._reactStatus = Resolved;
5794
- if (typeof resolvedValue === 'object' && resolvedValue !== null) {
5795
- // If the `default` property is not empty, assume it's the result
5796
- // of an async import() and use that. Otherwise, use the
5797
- // resolved value itself.
5798
- var defaultExport = resolvedValue.default;
5799
- resolvedValue = defaultExport !== undefined && defaultExport !== null ? defaultExport : resolvedValue;
5800
- } else {
5801
- resolvedValue = resolvedValue;
5911
+ lazyComponent._status = Pending;
5912
+ var ctor = lazyComponent._ctor;
5913
+ var _thenable = ctor();
5914
+ _thenable.then(function (moduleObject) {
5915
+ if (lazyComponent._status === Pending) {
5916
+ var defaultExport = moduleObject.default;
5917
+ {
5918
+ if (defaultExport === undefined) {
5919
+ 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);
5920
+ }
5802
5921
  }
5803
- thenable._reactResult = resolvedValue;
5922
+ lazyComponent._status = Resolved;
5923
+ lazyComponent._result = defaultExport;
5804
5924
  }
5805
5925
  }, function (error) {
5806
- if (thenable._reactStatus === Pending) {
5807
- thenable._reactStatus = Rejected;
5808
- thenable._reactResult = error;
5926
+ if (lazyComponent._status === Pending) {
5927
+ lazyComponent._status = Rejected;
5928
+ lazyComponent._result = error;
5809
5929
  }
5810
5930
  });
5811
- throw thenable;
5931
+ lazyComponent._result = _thenable;
5932
+ throw _thenable;
5812
5933
  }
5813
5934
  }
5814
5935
  }
@@ -5816,13 +5937,15 @@ function readLazyComponentType(thenable) {
5816
5937
  var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
5817
5938
 
5818
5939
  var didWarnAboutBadClass = void 0;
5819
- var didWarnAboutGetDerivedStateOnFunctionalComponent = void 0;
5820
- var didWarnAboutStatelessRefs = void 0;
5940
+ var didWarnAboutContextTypeOnFunctionComponent = void 0;
5941
+ var didWarnAboutGetDerivedStateOnFunctionComponent = void 0;
5942
+ var didWarnAboutFunctionRefs = void 0;
5821
5943
 
5822
5944
  {
5823
5945
  didWarnAboutBadClass = {};
5824
- didWarnAboutGetDerivedStateOnFunctionalComponent = {};
5825
- didWarnAboutStatelessRefs = {};
5946
+ didWarnAboutContextTypeOnFunctionComponent = {};
5947
+ didWarnAboutGetDerivedStateOnFunctionComponent = {};
5948
+ didWarnAboutFunctionRefs = {};
5826
5949
  }
5827
5950
 
5828
5951
  function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
@@ -5843,6 +5966,23 @@ function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpir
5843
5966
  }
5844
5967
  }
5845
5968
 
5969
+ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
5970
+ // This function is fork of reconcileChildren. It's used in cases where we
5971
+ // want to reconcile without matching against the existing set. This has the
5972
+ // effect of all current children being unmounted; even if the type and key
5973
+ // are the same, the old child is unmounted and a new child is created.
5974
+ //
5975
+ // To do this, we're going to go through the reconcile algorithm twice. In
5976
+ // the first pass, we schedule a deletion for all the current children by
5977
+ // passing null.
5978
+ workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
5979
+ // In the second pass, we mount the new children. The trick here is that we
5980
+ // pass null in place of where we usually pass the current child set. This has
5981
+ // the effect of remounting all children regardless of whether their their
5982
+ // identity matches.
5983
+ workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
5984
+ }
5985
+
5846
5986
  function updateForwardRef(current$$1, workInProgress, type, nextProps, renderExpirationTime) {
5847
5987
  var render = type.render;
5848
5988
  var ref = workInProgress.ref;
@@ -5865,21 +6005,64 @@ function updateForwardRef(current$$1, workInProgress, type, nextProps, renderExp
5865
6005
  }
5866
6006
 
5867
6007
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5868
- memoizeProps(workInProgress, nextProps);
5869
6008
  return workInProgress.child;
5870
6009
  }
5871
6010
 
6011
+ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
6012
+ if (current$$1 === null) {
6013
+ var type = Component.type;
6014
+ if (isSimpleFunctionComponent(type) && Component.compare === null) {
6015
+ // If this is a plain function component without default props,
6016
+ // and with only the default shallow comparison, we upgrade it
6017
+ // to a SimpleMemoComponent to allow fast path updates.
6018
+ workInProgress.tag = SimpleMemoComponent;
6019
+ workInProgress.type = type;
6020
+ return updateSimpleMemoComponent(current$$1, workInProgress, type, nextProps, updateExpirationTime, renderExpirationTime);
6021
+ }
6022
+ var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
6023
+ child.ref = workInProgress.ref;
6024
+ child.return = workInProgress;
6025
+ workInProgress.child = child;
6026
+ return child;
6027
+ }
6028
+ var currentChild = current$$1.child; // This is always exactly one child
6029
+ if (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime) {
6030
+ // This will be the props with resolved defaultProps,
6031
+ // unlike current.memoizedProps which will be the unresolved ones.
6032
+ var prevProps = currentChild.memoizedProps;
6033
+ // Default to shallow comparison
6034
+ var compare = Component.compare;
6035
+ compare = compare !== null ? compare : shallowEqual;
6036
+ if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
6037
+ return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6038
+ }
6039
+ }
6040
+ var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
6041
+ newChild.ref = workInProgress.ref;
6042
+ newChild.return = workInProgress;
6043
+ workInProgress.child = newChild;
6044
+ return newChild;
6045
+ }
6046
+
6047
+ function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
6048
+ if (current$$1 !== null && (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime)) {
6049
+ var prevProps = current$$1.memoizedProps;
6050
+ if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
6051
+ return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6052
+ }
6053
+ }
6054
+ return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
6055
+ }
6056
+
5872
6057
  function updateFragment(current$$1, workInProgress, renderExpirationTime) {
5873
6058
  var nextChildren = workInProgress.pendingProps;
5874
6059
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5875
- memoizeProps(workInProgress, nextChildren);
5876
6060
  return workInProgress.child;
5877
6061
  }
5878
6062
 
5879
6063
  function updateMode(current$$1, workInProgress, renderExpirationTime) {
5880
6064
  var nextChildren = workInProgress.pendingProps.children;
5881
6065
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5882
- memoizeProps(workInProgress, nextChildren);
5883
6066
  return workInProgress.child;
5884
6067
  }
5885
6068
 
@@ -5890,7 +6073,6 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
5890
6073
  var nextProps = workInProgress.pendingProps;
5891
6074
  var nextChildren = nextProps.children;
5892
6075
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5893
- memoizeProps(workInProgress, nextProps);
5894
6076
  return workInProgress.child;
5895
6077
  }
5896
6078
 
@@ -5902,7 +6084,7 @@ function markRef(current$$1, workInProgress) {
5902
6084
  }
5903
6085
  }
5904
6086
 
5905
- function updateFunctionalComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
6087
+ function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
5906
6088
  var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
5907
6089
  var context = getMaskedContext(workInProgress, unmaskedContext);
5908
6090
 
@@ -5918,7 +6100,6 @@ function updateFunctionalComponent(current$$1, workInProgress, Component, nextPr
5918
6100
  // React DevTools reads this flag.
5919
6101
  workInProgress.effectTag |= PerformedWork;
5920
6102
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
5921
- memoizeProps(workInProgress, nextProps);
5922
6103
  return workInProgress.child;
5923
6104
  }
5924
6105
 
@@ -5935,17 +6116,26 @@ function updateClassComponent(current$$1, workInProgress, Component, nextProps,
5935
6116
  }
5936
6117
  prepareToReadContext(workInProgress, renderExpirationTime);
5937
6118
 
6119
+ var instance = workInProgress.stateNode;
5938
6120
  var shouldUpdate = void 0;
5939
- if (current$$1 === null) {
5940
- if (workInProgress.stateNode === null) {
5941
- // In the initial pass we might need to construct the instance.
5942
- constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5943
- mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5944
- shouldUpdate = true;
5945
- } else {
5946
- // In a resume, we'll already have an instance we can reuse.
5947
- shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5948
- }
6121
+ if (instance === null) {
6122
+ if (current$$1 !== null) {
6123
+ // An class component without an instance only mounts if it suspended
6124
+ // inside a non- concurrent tree, in an inconsistent state. We want to
6125
+ // tree it like a new mount, even though an empty version of it already
6126
+ // committed. Disconnect the alternate pointers.
6127
+ current$$1.alternate = null;
6128
+ workInProgress.alternate = null;
6129
+ // Since this is conceptually a new fiber, schedule a Placement effect
6130
+ workInProgress.effectTag |= Placement;
6131
+ }
6132
+ // In the initial pass we might need to construct the instance.
6133
+ constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6134
+ mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6135
+ shouldUpdate = true;
6136
+ } else if (current$$1 === null) {
6137
+ // In a resume, we'll already have an instance we can reuse.
6138
+ shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
5949
6139
  } else {
5950
6140
  shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
5951
6141
  }
@@ -5972,7 +6162,7 @@ function finishClassComponent(current$$1, workInProgress, Component, shouldUpdat
5972
6162
  // Rerender
5973
6163
  ReactCurrentOwner$2.current = workInProgress;
5974
6164
  var nextChildren = void 0;
5975
- if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof Component.getDerivedStateFromCatch !== 'function')) {
6165
+ if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
5976
6166
  // If we captured an error, but getDerivedStateFrom catch is not defined,
5977
6167
  // unmount all the children. componentDidCatch will schedule an update to
5978
6168
  // re-render a fallback. This is temporary until we migrate everyone to
@@ -5997,19 +6187,18 @@ function finishClassComponent(current$$1, workInProgress, Component, shouldUpdat
5997
6187
  // React DevTools reads this flag.
5998
6188
  workInProgress.effectTag |= PerformedWork;
5999
6189
  if (current$$1 !== null && didCaptureError) {
6000
- // If we're recovering from an error, reconcile twice: first to delete
6001
- // all the existing children.
6002
- reconcileChildren(current$$1, workInProgress, null, renderExpirationTime);
6003
- workInProgress.child = null;
6004
- // Now we can continue reconciling like normal. This has the effect of
6005
- // remounting all children regardless of whether their their
6006
- // identity matches.
6190
+ // If we're recovering from an error, reconcile without reusing any of
6191
+ // the existing children. Conceptually, the normal children and the children
6192
+ // that are shown on error are two different sets, so we shouldn't reuse
6193
+ // normal children even if their identities match.
6194
+ forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
6195
+ } else {
6196
+ reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
6007
6197
  }
6008
- reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
6009
- // Memoize props and state using the values we just used to render.
6198
+
6199
+ // Memoize state using the values we just used to render.
6010
6200
  // TODO: Restructure so we never read values from the instance.
6011
- memoizeState(workInProgress, instance.state);
6012
- memoizeProps(workInProgress, instance.props);
6201
+ workInProgress.memoizedState = instance.state;
6013
6202
 
6014
6203
  // The context might have changed so we need to recalculate it.
6015
6204
  if (hasContext) {
@@ -6103,15 +6292,13 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
6103
6292
  markRef(current$$1, workInProgress);
6104
6293
 
6105
6294
  // Check the host config to see if the children are offscreen/hidden.
6106
- if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
6295
+ if (renderExpirationTime !== Never && workInProgress.mode & ConcurrentMode && shouldDeprioritizeSubtree(type, nextProps)) {
6107
6296
  // Schedule this fiber to re-render at offscreen priority. Then bailout.
6108
6297
  workInProgress.expirationTime = Never;
6109
- workInProgress.memoizedProps = nextProps;
6110
6298
  return null;
6111
6299
  }
6112
6300
 
6113
6301
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
6114
- memoizeProps(workInProgress, nextProps);
6115
6302
  return workInProgress.child;
6116
6303
  }
6117
6304
 
@@ -6119,8 +6306,6 @@ function updateHostText(current$$1, workInProgress) {
6119
6306
  if (current$$1 === null) {
6120
6307
  tryToClaimNextHydratableInstance(workInProgress);
6121
6308
  }
6122
- var nextProps = workInProgress.pendingProps;
6123
- memoizeProps(workInProgress, nextProps);
6124
6309
  // Nothing to do here. This is terminal. We'll do the completion step
6125
6310
  // immediately after.
6126
6311
  return null;
@@ -6141,36 +6326,110 @@ function resolveDefaultProps(Component, baseProps) {
6141
6326
  return baseProps;
6142
6327
  }
6143
6328
 
6144
- function mountIndeterminateComponent(current$$1, workInProgress, Component, renderExpirationTime) {
6145
- !(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;
6329
+ function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
6330
+ if (_current !== null) {
6331
+ // An lazy component only mounts if it suspended inside a non-
6332
+ // concurrent tree, in an inconsistent state. We want to tree it like
6333
+ // a new mount, even though an empty version of it already committed.
6334
+ // Disconnect the alternate pointers.
6335
+ _current.alternate = null;
6336
+ workInProgress.alternate = null;
6337
+ // Since this is conceptually a new fiber, schedule a Placement effect
6338
+ workInProgress.effectTag |= Placement;
6339
+ }
6146
6340
 
6147
6341
  var props = workInProgress.pendingProps;
6148
- if (typeof Component === 'object' && Component !== null && typeof Component.then === 'function') {
6149
- Component = readLazyComponentType(Component);
6150
- var resolvedTag = workInProgress.tag = resolveLazyComponentTag(workInProgress, Component);
6151
- var resolvedProps = resolveDefaultProps(Component, props);
6152
- switch (resolvedTag) {
6153
- case FunctionalComponentLazy:
6154
- {
6155
- return updateFunctionalComponent(current$$1, workInProgress, Component, resolvedProps, renderExpirationTime);
6156
- }
6157
- case ClassComponentLazy:
6158
- {
6159
- return updateClassComponent(current$$1, workInProgress, Component, resolvedProps, renderExpirationTime);
6160
- }
6161
- case ForwardRefLazy:
6162
- {
6163
- return updateForwardRef(current$$1, workInProgress, Component, resolvedProps, renderExpirationTime);
6164
- }
6165
- default:
6166
- {
6167
- // This message intentionally doesn't metion ForwardRef because the
6168
- // fact that it's a separate type of work is an implementation detail.
6169
- invariant(false, 'Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.', Component);
6170
- }
6171
- }
6342
+ // We can't start a User Timing measurement with correct label yet.
6343
+ // Cancel and resume right after we know the tag.
6344
+ cancelWorkTimer(workInProgress);
6345
+ var Component = readLazyComponentType(elementType);
6346
+ // Store the unwrapped component in the type.
6347
+ workInProgress.type = Component;
6348
+ var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
6349
+ startWorkTimer(workInProgress);
6350
+ var resolvedProps = resolveDefaultProps(Component, props);
6351
+ var child = void 0;
6352
+ switch (resolvedTag) {
6353
+ case FunctionComponent:
6354
+ {
6355
+ child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
6356
+ break;
6357
+ }
6358
+ case ClassComponent:
6359
+ {
6360
+ child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
6361
+ break;
6362
+ }
6363
+ case ForwardRef:
6364
+ {
6365
+ child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
6366
+ break;
6367
+ }
6368
+ case MemoComponent:
6369
+ {
6370
+ child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
6371
+ updateExpirationTime, renderExpirationTime);
6372
+ break;
6373
+ }
6374
+ default:
6375
+ {
6376
+ // This message intentionally doesn't metion ForwardRef or MemoComponent
6377
+ // because the fact that it's a separate type of work is an
6378
+ // implementation detail.
6379
+ invariant(false, 'Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.', Component);
6380
+ }
6381
+ }
6382
+ return child;
6383
+ }
6384
+
6385
+ function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
6386
+ if (_current !== null) {
6387
+ // An incomplete component only mounts if it suspended inside a non-
6388
+ // concurrent tree, in an inconsistent state. We want to tree it like
6389
+ // a new mount, even though an empty version of it already committed.
6390
+ // Disconnect the alternate pointers.
6391
+ _current.alternate = null;
6392
+ workInProgress.alternate = null;
6393
+ // Since this is conceptually a new fiber, schedule a Placement effect
6394
+ workInProgress.effectTag |= Placement;
6395
+ }
6396
+
6397
+ // Promote the fiber to a class and try rendering again.
6398
+ workInProgress.tag = ClassComponent;
6399
+
6400
+ // The rest of this function is a fork of `updateClassComponent`
6401
+
6402
+ // Push context providers early to prevent context stack mismatches.
6403
+ // During mounting we don't know the child context yet as the instance doesn't exist.
6404
+ // We will invalidate the child context in finishClassComponent() right after rendering.
6405
+ var hasContext = void 0;
6406
+ if (isContextProvider(Component)) {
6407
+ hasContext = true;
6408
+ pushContextProvider(workInProgress);
6409
+ } else {
6410
+ hasContext = false;
6411
+ }
6412
+ prepareToReadContext(workInProgress, renderExpirationTime);
6413
+
6414
+ constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6415
+ mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
6416
+
6417
+ return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
6418
+ }
6419
+
6420
+ function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
6421
+ if (_current !== null) {
6422
+ // An indeterminate component only mounts if it suspended inside a non-
6423
+ // concurrent tree, in an inconsistent state. We want to tree it like
6424
+ // a new mount, even though an empty version of it already committed.
6425
+ // Disconnect the alternate pointers.
6426
+ _current.alternate = null;
6427
+ workInProgress.alternate = null;
6428
+ // Since this is conceptually a new fiber, schedule a Placement effect
6429
+ workInProgress.effectTag |= Placement;
6172
6430
  }
6173
6431
 
6432
+ var props = workInProgress.pendingProps;
6174
6433
  var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
6175
6434
  var context = getMaskedContext(workInProgress, unmaskedContext);
6176
6435
 
@@ -6222,13 +6481,13 @@ function mountIndeterminateComponent(current$$1, workInProgress, Component, rend
6222
6481
 
6223
6482
  adoptClassInstance(workInProgress, value);
6224
6483
  mountClassInstance(workInProgress, Component, props, renderExpirationTime);
6225
- return finishClassComponent(current$$1, workInProgress, Component, true, hasContext, renderExpirationTime);
6484
+ return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
6226
6485
  } else {
6227
- // Proceed under the assumption that this is a functional component
6228
- workInProgress.tag = FunctionalComponent;
6486
+ // Proceed under the assumption that this is a function component
6487
+ workInProgress.tag = FunctionComponent;
6229
6488
  {
6230
6489
  if (Component) {
6231
- !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component') : void 0;
6490
+ !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
6232
6491
  }
6233
6492
  if (workInProgress.ref !== null) {
6234
6493
  var info = '';
@@ -6242,81 +6501,190 @@ function mountIndeterminateComponent(current$$1, workInProgress, Component, rend
6242
6501
  if (debugSource) {
6243
6502
  warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
6244
6503
  }
6245
- if (!didWarnAboutStatelessRefs[warningKey]) {
6246
- didWarnAboutStatelessRefs[warningKey] = true;
6247
- warning$1(false, 'Stateless function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s', info);
6504
+ if (!didWarnAboutFunctionRefs[warningKey]) {
6505
+ didWarnAboutFunctionRefs[warningKey] = true;
6506
+ warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s', info);
6248
6507
  }
6249
6508
  }
6250
6509
 
6251
6510
  if (typeof Component.getDerivedStateFromProps === 'function') {
6252
6511
  var _componentName = getComponentName(Component) || 'Unknown';
6253
6512
 
6254
- if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) {
6255
- warningWithoutStack$1(false, '%s: Stateless functional components do not support getDerivedStateFromProps.', _componentName);
6256
- didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName] = true;
6513
+ if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName]) {
6514
+ warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName);
6515
+ didWarnAboutGetDerivedStateOnFunctionComponent[_componentName] = true;
6516
+ }
6517
+ }
6518
+
6519
+ if (typeof Component.contextType === 'object' && Component.contextType !== null) {
6520
+ var _componentName2 = getComponentName(Component) || 'Unknown';
6521
+
6522
+ if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) {
6523
+ warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName2);
6524
+ didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true;
6257
6525
  }
6258
6526
  }
6259
6527
  }
6260
- reconcileChildren(current$$1, workInProgress, value, renderExpirationTime);
6261
- memoizeProps(workInProgress, props);
6528
+ reconcileChildren(null, workInProgress, value, renderExpirationTime);
6262
6529
  return workInProgress.child;
6263
6530
  }
6264
6531
  }
6265
6532
 
6266
- function updatePlaceholderComponent(current$$1, workInProgress, renderExpirationTime) {
6267
- if (enableSuspense) {
6268
- var nextProps = workInProgress.pendingProps;
6269
-
6270
- // Check if we already attempted to render the normal state. If we did,
6271
- // and we timed out, render the placeholder state.
6272
- var alreadyCaptured = (workInProgress.effectTag & DidCapture) === NoEffect;
6273
-
6274
- var nextDidTimeout = void 0;
6275
- if (current$$1 !== null && workInProgress.updateQueue !== null) {
6276
- // We're outside strict mode. Something inside this Placeholder boundary
6277
- // suspended during the last commit. Switch to the placholder.
6278
- workInProgress.updateQueue = null;
6279
- nextDidTimeout = true;
6280
- // If we're recovering from an error, reconcile twice: first to delete
6281
- // all the existing children.
6282
- reconcileChildren(current$$1, workInProgress, null, renderExpirationTime);
6283
- current$$1.child = null;
6284
- // Now we can continue reconciling like normal. This has the effect of
6285
- // remounting all children regardless of whether their their
6286
- // identity matches.
6287
- } else {
6288
- nextDidTimeout = !alreadyCaptured;
6289
- }
6533
+ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
6534
+ var mode = workInProgress.mode;
6535
+ var nextProps = workInProgress.pendingProps;
6290
6536
 
6291
- if ((workInProgress.mode & StrictMode) !== NoEffect) {
6292
- if (nextDidTimeout) {
6293
- // If the timed-out view commits, schedule an update effect to record
6294
- // the committed time.
6295
- workInProgress.effectTag |= Update;
6537
+ // We should attempt to render the primary children unless this boundary
6538
+ // already suspended during this render (`alreadyCaptured` is true).
6539
+ var nextState = workInProgress.memoizedState;
6540
+ if (nextState === null) {
6541
+ // An empty suspense state means this boundary has not yet timed out.
6542
+ } else {
6543
+ if (!nextState.alreadyCaptured) {
6544
+ // Since we haven't already suspended during this commit, clear the
6545
+ // existing suspense state. We'll try rendering again.
6546
+ nextState = null;
6547
+ } else {
6548
+ // Something in this boundary's subtree already suspended. Switch to
6549
+ // rendering the fallback children. Set `alreadyCaptured` to true.
6550
+ if (current$$1 !== null && nextState === current$$1.memoizedState) {
6551
+ // Create a new suspense state to avoid mutating the current tree's.
6552
+ nextState = {
6553
+ alreadyCaptured: true,
6554
+ didTimeout: true,
6555
+ timedOutAt: nextState.timedOutAt
6556
+ };
6296
6557
  } else {
6297
- // The state node points to the time at which placeholder timed out.
6298
- // We can clear it once we switch back to the normal children.
6299
- workInProgress.stateNode = null;
6558
+ // Already have a clone, so it's safe to mutate.
6559
+ nextState.alreadyCaptured = true;
6560
+ nextState.didTimeout = true;
6300
6561
  }
6301
6562
  }
6563
+ }
6564
+ var nextDidTimeout = nextState !== null && nextState.didTimeout;
6302
6565
 
6303
- // If the `children` prop is a function, treat it like a render prop.
6304
- // TODO: This is temporary until we finalize a lower level API.
6305
- var children = nextProps.children;
6306
- var nextChildren = void 0;
6307
- if (typeof children === 'function') {
6308
- nextChildren = children(nextDidTimeout);
6566
+ // This next part is a bit confusing. If the children timeout, we switch to
6567
+ // showing the fallback children in place of the "primary" children.
6568
+ // However, we don't want to delete the primary children because then their
6569
+ // state will be lost (both the React state and the host state, e.g.
6570
+ // uncontrolled form inputs). Instead we keep them mounted and hide them.
6571
+ // Both the fallback children AND the primary children are rendered at the
6572
+ // same time. Once the primary children are un-suspended, we can delete
6573
+ // the fallback children — don't need to preserve their state.
6574
+ //
6575
+ // The two sets of children are siblings in the host environment, but
6576
+ // semantically, for purposes of reconciliation, they are two separate sets.
6577
+ // So we store them using two fragment fibers.
6578
+ //
6579
+ // However, we want to avoid allocating extra fibers for every placeholder.
6580
+ // They're only necessary when the children time out, because that's the
6581
+ // only time when both sets are mounted.
6582
+ //
6583
+ // So, the extra fragment fibers are only used if the children time out.
6584
+ // Otherwise, we render the primary children directly. This requires some
6585
+ // custom reconciliation logic to preserve the state of the primary
6586
+ // children. It's essentially a very basic form of re-parenting.
6587
+
6588
+ // `child` points to the child fiber. In the normal case, this is the first
6589
+ // fiber of the primary children set. In the timed-out case, it's a
6590
+ // a fragment fiber containing the primary children.
6591
+ var child = void 0;
6592
+ // `next` points to the next fiber React should render. In the normal case,
6593
+ // it's the same as `child`: the first fiber of the primary children set.
6594
+ // In the timed-out case, it's a fragment fiber containing the *fallback*
6595
+ // children -- we skip over the primary children entirely.
6596
+ var next = void 0;
6597
+ if (current$$1 === null) {
6598
+ // This is the initial mount. This branch is pretty simple because there's
6599
+ // no previous state that needs to be preserved.
6600
+ if (nextDidTimeout) {
6601
+ // Mount separate fragments for primary and fallback children.
6602
+ var nextFallbackChildren = nextProps.fallback;
6603
+ var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
6604
+ var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
6605
+ primaryChildFragment.sibling = fallbackChildFragment;
6606
+ child = primaryChildFragment;
6607
+ // Skip the primary children, and continue working on the
6608
+ // fallback children.
6609
+ next = fallbackChildFragment;
6610
+ child.return = next.return = workInProgress;
6309
6611
  } else {
6310
- nextChildren = nextDidTimeout ? nextProps.fallback : children;
6612
+ // Mount the primary children without an intermediate fragment fiber.
6613
+ var nextPrimaryChildren = nextProps.children;
6614
+ child = next = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
6311
6615
  }
6312
-
6313
- workInProgress.memoizedProps = nextProps;
6314
- workInProgress.memoizedState = nextDidTimeout;
6315
- reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
6316
- return workInProgress.child;
6317
6616
  } else {
6318
- return null;
6617
+ // This is an update. This branch is more complicated because we need to
6618
+ // ensure the state of the primary children is preserved.
6619
+ var prevState = current$$1.memoizedState;
6620
+ var prevDidTimeout = prevState !== null && prevState.didTimeout;
6621
+ if (prevDidTimeout) {
6622
+ // The current tree already timed out. That means each child set is
6623
+ var currentPrimaryChildFragment = current$$1.child;
6624
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
6625
+ if (nextDidTimeout) {
6626
+ // Still timed out. Reuse the current primary children by cloning
6627
+ // its fragment. We're going to skip over these entirely.
6628
+ var _nextFallbackChildren = nextProps.fallback;
6629
+ var _primaryChildFragment = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
6630
+ _primaryChildFragment.effectTag |= Placement;
6631
+ // Clone the fallback child fragment, too. These we'll continue
6632
+ // working on.
6633
+ var _fallbackChildFragment = _primaryChildFragment.sibling = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren, currentFallbackChildFragment.expirationTime);
6634
+ _fallbackChildFragment.effectTag |= Placement;
6635
+ child = _primaryChildFragment;
6636
+ _primaryChildFragment.childExpirationTime = NoWork;
6637
+ // Skip the primary children, and continue working on the
6638
+ // fallback children.
6639
+ next = _fallbackChildFragment;
6640
+ child.return = next.return = workInProgress;
6641
+ } else {
6642
+ // No longer suspended. Switch back to showing the primary children,
6643
+ // and remove the intermediate fragment fiber.
6644
+ var _nextPrimaryChildren = nextProps.children;
6645
+ var currentPrimaryChild = currentPrimaryChildFragment.child;
6646
+ var currentFallbackChild = currentFallbackChildFragment.child;
6647
+ var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
6648
+ // Delete the fallback children.
6649
+ reconcileChildFibers(workInProgress, currentFallbackChild, null, renderExpirationTime);
6650
+ // Continue rendering the children, like we normally do.
6651
+ child = next = primaryChild;
6652
+ }
6653
+ } else {
6654
+ // The current tree has not already timed out. That means the primary
6655
+ var _currentPrimaryChild = current$$1.child;
6656
+ if (nextDidTimeout) {
6657
+ // Timed out. Wrap the children in a fragment fiber to keep them
6658
+ // separate from the fallback children.
6659
+ var _nextFallbackChildren2 = nextProps.fallback;
6660
+ var _primaryChildFragment2 = createFiberFromFragment(
6661
+ // It shouldn't matter what the pending props are because we aren't
6662
+ // going to render this fragment.
6663
+ null, mode, NoWork, null);
6664
+ _primaryChildFragment2.effectTag |= Placement;
6665
+ _primaryChildFragment2.child = _currentPrimaryChild;
6666
+ _currentPrimaryChild.return = _primaryChildFragment2;
6667
+ // Create a fragment from the fallback children, too.
6668
+ var _fallbackChildFragment2 = _primaryChildFragment2.sibling = createFiberFromFragment(_nextFallbackChildren2, mode, renderExpirationTime, null);
6669
+ _fallbackChildFragment2.effectTag |= Placement;
6670
+ child = _primaryChildFragment2;
6671
+ _primaryChildFragment2.childExpirationTime = NoWork;
6672
+ // Skip the primary children, and continue working on the
6673
+ // fallback children.
6674
+ next = _fallbackChildFragment2;
6675
+ child.return = next.return = workInProgress;
6676
+ } else {
6677
+ // Still haven't timed out. Continue rendering the children, like we
6678
+ // normally do.
6679
+ var _nextPrimaryChildren2 = nextProps.children;
6680
+ next = child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
6681
+ }
6682
+ }
6319
6683
  }
6684
+
6685
+ workInProgress.memoizedState = nextState;
6686
+ workInProgress.child = child;
6687
+ return next;
6320
6688
  }
6321
6689
 
6322
6690
  function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
@@ -6329,10 +6697,8 @@ function updatePortalComponent(current$$1, workInProgress, renderExpirationTime)
6329
6697
  // the root always starts with a "current" with a null child.
6330
6698
  // TODO: Consider unifying this with how the root works.
6331
6699
  workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
6332
- memoizeProps(workInProgress, nextChildren);
6333
6700
  } else {
6334
6701
  reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
6335
- memoizeProps(workInProgress, nextChildren);
6336
6702
  }
6337
6703
  return workInProgress.child;
6338
6704
  }
@@ -6345,7 +6711,6 @@ function updateContextProvider(current$$1, workInProgress, renderExpirationTime)
6345
6711
  var oldProps = workInProgress.memoizedProps;
6346
6712
 
6347
6713
  var newValue = newProps.value;
6348
- workInProgress.memoizedProps = newProps;
6349
6714
 
6350
6715
  {
6351
6716
  var providerPropTypes = workInProgress.type.propTypes;
@@ -6377,8 +6742,32 @@ function updateContextProvider(current$$1, workInProgress, renderExpirationTime)
6377
6742
  return workInProgress.child;
6378
6743
  }
6379
6744
 
6745
+ var hasWarnedAboutUsingContextAsConsumer = false;
6746
+
6380
6747
  function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
6381
6748
  var context = workInProgress.type;
6749
+ // The logic below for Context differs depending on PROD or DEV mode. In
6750
+ // DEV mode, we create a separate object for Context.Consumer that acts
6751
+ // like a proxy to Context. This proxy object adds unnecessary code in PROD
6752
+ // so we use the old behaviour (Context.Consumer references Context) to
6753
+ // reduce size and overhead. The separate object references context via
6754
+ // a property called "_context", which also gives us the ability to check
6755
+ // in DEV mode if this property exists or not and warn if it does not.
6756
+ {
6757
+ if (context._context === undefined) {
6758
+ // This may be because it's a Context (rather than a Consumer).
6759
+ // Or it may be because it's older React where they're the same thing.
6760
+ // We only want to warn if we're sure it's a new React.
6761
+ if (context !== context.Consumer) {
6762
+ if (!hasWarnedAboutUsingContextAsConsumer) {
6763
+ hasWarnedAboutUsingContextAsConsumer = true;
6764
+ 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?');
6765
+ }
6766
+ }
6767
+ } else {
6768
+ context = context._context;
6769
+ }
6770
+ }
6382
6771
  var newProps = workInProgress.pendingProps;
6383
6772
  var render = newProps.children;
6384
6773
 
@@ -6399,7 +6788,6 @@ function updateContextConsumer(current$$1, workInProgress, renderExpirationTime)
6399
6788
  // React DevTools reads this flag.
6400
6789
  workInProgress.effectTag |= PerformedWork;
6401
6790
  reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
6402
- workInProgress.memoizedProps = newProps;
6403
6791
  return workInProgress.child;
6404
6792
  }
6405
6793
 
@@ -6450,64 +6838,78 @@ function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirati
6450
6838
  }
6451
6839
  }
6452
6840
 
6453
- // TODO: Delete memoizeProps/State and move to reconcile/bailout instead
6454
- function memoizeProps(workInProgress, nextProps) {
6455
- workInProgress.memoizedProps = nextProps;
6456
- }
6457
-
6458
- function memoizeState(workInProgress, nextState) {
6459
- workInProgress.memoizedState = nextState;
6460
- // Don't reset the updateQueue, in case there are pending updates. Resetting
6461
- // is handled by processUpdateQueue.
6462
- }
6463
-
6464
6841
  function beginWork(current$$1, workInProgress, renderExpirationTime) {
6465
6842
  var updateExpirationTime = workInProgress.expirationTime;
6466
- if (!hasContextChanged() && (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime)) {
6467
- // This fiber does not have any pending work. Bailout without entering
6468
- // the begin phase. There's still some bookkeeping we that needs to be done
6469
- // in this optimized path, mostly pushing stuff onto the stack.
6470
- switch (workInProgress.tag) {
6471
- case HostRoot:
6472
- pushHostRootContext(workInProgress);
6473
- resetHydrationState();
6474
- break;
6475
- case HostComponent:
6476
- pushHostContext(workInProgress);
6477
- break;
6478
- case ClassComponent:
6479
- {
6480
- var Component = workInProgress.type;
6481
- if (isContextProvider(Component)) {
6482
- pushContextProvider(workInProgress);
6483
- }
6843
+
6844
+ if (current$$1 !== null) {
6845
+ var oldProps = current$$1.memoizedProps;
6846
+ var newProps = workInProgress.pendingProps;
6847
+ if (oldProps === newProps && !hasContextChanged() && (updateExpirationTime === NoWork || updateExpirationTime > renderExpirationTime)) {
6848
+ // This fiber does not have any pending work. Bailout without entering
6849
+ // the begin phase. There's still some bookkeeping we that needs to be done
6850
+ // in this optimized path, mostly pushing stuff onto the stack.
6851
+ switch (workInProgress.tag) {
6852
+ case HostRoot:
6853
+ pushHostRootContext(workInProgress);
6854
+ resetHydrationState();
6484
6855
  break;
6485
- }
6486
- case ClassComponentLazy:
6487
- {
6488
- var thenable = workInProgress.type;
6489
- var _Component = getResultFromResolvedThenable(thenable);
6490
- if (isContextProvider(_Component)) {
6491
- pushContextProvider(workInProgress);
6492
- }
6856
+ case HostComponent:
6857
+ pushHostContext(workInProgress);
6493
6858
  break;
6494
- }
6495
- case HostPortal:
6496
- pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
6497
- break;
6498
- case ContextProvider:
6499
- {
6500
- var newValue = workInProgress.memoizedProps.value;
6501
- pushProvider(workInProgress, newValue);
6859
+ case ClassComponent:
6860
+ {
6861
+ var Component = workInProgress.type;
6862
+ if (isContextProvider(Component)) {
6863
+ pushContextProvider(workInProgress);
6864
+ }
6865
+ break;
6866
+ }
6867
+ case HostPortal:
6868
+ pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
6502
6869
  break;
6503
- }
6504
- case Profiler:
6505
- if (enableProfilerTimer) {
6506
- workInProgress.effectTag |= Update;
6507
- }
6508
- break;
6870
+ case ContextProvider:
6871
+ {
6872
+ var newValue = workInProgress.memoizedProps.value;
6873
+ pushProvider(workInProgress, newValue);
6874
+ break;
6875
+ }
6876
+ case Profiler:
6877
+ if (enableProfilerTimer) {
6878
+ workInProgress.effectTag |= Update;
6879
+ }
6880
+ break;
6881
+ case SuspenseComponent:
6882
+ {
6883
+ var state = workInProgress.memoizedState;
6884
+ var didTimeout = state !== null && state.didTimeout;
6885
+ if (didTimeout) {
6886
+ // If this boundary is currently timed out, we need to decide
6887
+ // whether to retry the primary children, or to skip over it and
6888
+ // go straight to the fallback. Check the priority of the primary
6889
+ var primaryChildFragment = workInProgress.child;
6890
+ var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
6891
+ if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime <= renderExpirationTime) {
6892
+ // The primary children have pending work. Use the normal path
6893
+ // to attempt to render the primary children again.
6894
+ return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
6895
+ } else {
6896
+ // The primary children do not have pending work with sufficient
6897
+ // priority. Bailout.
6898
+ var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6899
+ if (child !== null) {
6900
+ // The fallback children have pending work. Skip over the
6901
+ // primary children and work on the fallback.
6902
+ return child.sibling;
6903
+ } else {
6904
+ return null;
6905
+ }
6906
+ }
6907
+ }
6908
+ break;
6909
+ }
6910
+ }
6911
+ return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6509
6912
  }
6510
- return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
6511
6913
  }
6512
6914
 
6513
6915
  // Before entering the begin phase, clear the expiration time.
@@ -6516,38 +6918,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
6516
6918
  switch (workInProgress.tag) {
6517
6919
  case IndeterminateComponent:
6518
6920
  {
6519
- var _Component3 = workInProgress.type;
6520
- return mountIndeterminateComponent(current$$1, workInProgress, _Component3, renderExpirationTime);
6921
+ var elementType = workInProgress.elementType;
6922
+ return mountIndeterminateComponent(current$$1, workInProgress, elementType, renderExpirationTime);
6521
6923
  }
6522
- case FunctionalComponent:
6924
+ case LazyComponent:
6523
6925
  {
6524
- var _Component4 = workInProgress.type;
6525
- var _unresolvedProps = workInProgress.pendingProps;
6526
- return updateFunctionalComponent(current$$1, workInProgress, _Component4, _unresolvedProps, renderExpirationTime);
6926
+ var _elementType = workInProgress.elementType;
6927
+ return mountLazyComponent(current$$1, workInProgress, _elementType, updateExpirationTime, renderExpirationTime);
6527
6928
  }
6528
- case FunctionalComponentLazy:
6929
+ case FunctionComponent:
6529
6930
  {
6530
- var _thenable2 = workInProgress.type;
6531
- var _Component5 = getResultFromResolvedThenable(_thenable2);
6532
- var _unresolvedProps2 = workInProgress.pendingProps;
6533
- var _child = updateFunctionalComponent(current$$1, workInProgress, _Component5, resolveDefaultProps(_Component5, _unresolvedProps2), renderExpirationTime);
6534
- workInProgress.memoizedProps = _unresolvedProps2;
6535
- return _child;
6931
+ var _Component = workInProgress.type;
6932
+ var unresolvedProps = workInProgress.pendingProps;
6933
+ var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
6934
+ return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
6536
6935
  }
6537
6936
  case ClassComponent:
6538
6937
  {
6539
- var _Component6 = workInProgress.type;
6540
- var _unresolvedProps3 = workInProgress.pendingProps;
6541
- return updateClassComponent(current$$1, workInProgress, _Component6, _unresolvedProps3, renderExpirationTime);
6542
- }
6543
- case ClassComponentLazy:
6544
- {
6545
- var _thenable3 = workInProgress.type;
6546
- var _Component7 = getResultFromResolvedThenable(_thenable3);
6547
- var _unresolvedProps4 = workInProgress.pendingProps;
6548
- var _child2 = updateClassComponent(current$$1, workInProgress, _Component7, resolveDefaultProps(_Component7, _unresolvedProps4), renderExpirationTime);
6549
- workInProgress.memoizedProps = _unresolvedProps4;
6550
- return _child2;
6938
+ var _Component2 = workInProgress.type;
6939
+ var _unresolvedProps = workInProgress.pendingProps;
6940
+ var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
6941
+ return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
6551
6942
  }
6552
6943
  case HostRoot:
6553
6944
  return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
@@ -6555,22 +6946,17 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
6555
6946
  return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
6556
6947
  case HostText:
6557
6948
  return updateHostText(current$$1, workInProgress);
6558
- case PlaceholderComponent:
6559
- return updatePlaceholderComponent(current$$1, workInProgress, renderExpirationTime);
6949
+ case SuspenseComponent:
6950
+ return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
6560
6951
  case HostPortal:
6561
6952
  return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
6562
6953
  case ForwardRef:
6563
6954
  {
6564
6955
  var type = workInProgress.type;
6565
- return updateForwardRef(current$$1, workInProgress, type, workInProgress.pendingProps, renderExpirationTime);
6566
- }
6567
- case ForwardRefLazy:
6568
- var _thenable = workInProgress.type;
6569
- var _Component2 = getResultFromResolvedThenable(_thenable);
6570
- var unresolvedProps = workInProgress.pendingProps;
6571
- var child = updateForwardRef(current$$1, workInProgress, _Component2, resolveDefaultProps(_Component2, unresolvedProps), renderExpirationTime);
6572
- workInProgress.memoizedProps = unresolvedProps;
6573
- return child;
6956
+ var _unresolvedProps2 = workInProgress.pendingProps;
6957
+ var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
6958
+ return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
6959
+ }
6574
6960
  case Fragment:
6575
6961
  return updateFragment(current$$1, workInProgress, renderExpirationTime);
6576
6962
  case Mode:
@@ -6581,6 +6967,24 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
6581
6967
  return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
6582
6968
  case ContextConsumer:
6583
6969
  return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
6970
+ case MemoComponent:
6971
+ {
6972
+ var _type = workInProgress.type;
6973
+ var _unresolvedProps3 = workInProgress.pendingProps;
6974
+ var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3);
6975
+ return updateMemoComponent(current$$1, workInProgress, _type, _resolvedProps3, updateExpirationTime, renderExpirationTime);
6976
+ }
6977
+ case SimpleMemoComponent:
6978
+ {
6979
+ return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
6980
+ }
6981
+ case IncompleteClassComponent:
6982
+ {
6983
+ var _Component3 = workInProgress.type;
6984
+ var _unresolvedProps4 = workInProgress.pendingProps;
6985
+ var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
6986
+ return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
6987
+ }
6584
6988
  default:
6585
6989
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
6586
6990
  }
@@ -6596,42 +7000,43 @@ function markRef$1(workInProgress) {
6596
7000
  workInProgress.effectTag |= Ref;
6597
7001
  }
6598
7002
 
6599
- function appendAllChildren(parent, workInProgress) {
6600
- // We only have the top Fiber that was created but we need recurse down its
6601
- // children to find all the terminal nodes.
6602
- var node = workInProgress.child;
6603
- while (node !== null) {
6604
- if (node.tag === HostComponent || node.tag === HostText) {
6605
- appendInitialChild(parent, node.stateNode);
6606
- } else if (node.tag === HostPortal) {
6607
- // If we have a portal child, then we don't want to traverse
6608
- // down its children. Instead, we'll get insertions from each child in
6609
- // the portal directly.
6610
- } else if (node.child !== null) {
6611
- node.child.return = node;
6612
- node = node.child;
6613
- continue;
6614
- }
6615
- if (node === workInProgress) {
6616
- return;
6617
- }
6618
- while (node.sibling === null) {
6619
- if (node.return === null || node.return === workInProgress) {
6620
- return;
6621
- }
6622
- node = node.return;
6623
- }
6624
- node.sibling.return = node.return;
6625
- node = node.sibling;
6626
- }
6627
- }
6628
-
7003
+ var appendAllChildren = void 0;
6629
7004
  var updateHostContainer = void 0;
6630
7005
  var updateHostComponent$1 = void 0;
6631
7006
  var updateHostText$1 = void 0;
6632
7007
  if (supportsMutation) {
6633
7008
  // Mutation mode
6634
7009
 
7010
+ appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
7011
+ // We only have the top Fiber that was created but we need recurse down its
7012
+ // children to find all the terminal nodes.
7013
+ var node = workInProgress.child;
7014
+ while (node !== null) {
7015
+ if (node.tag === HostComponent || node.tag === HostText) {
7016
+ appendInitialChild(parent, node.stateNode);
7017
+ } else if (node.tag === HostPortal) {
7018
+ // If we have a portal child, then we don't want to traverse
7019
+ // down its children. Instead, we'll get insertions from each child in
7020
+ // the portal directly.
7021
+ } else if (node.child !== null) {
7022
+ node.child.return = node;
7023
+ node = node.child;
7024
+ continue;
7025
+ }
7026
+ if (node === workInProgress) {
7027
+ return;
7028
+ }
7029
+ while (node.sibling === null) {
7030
+ if (node.return === null || node.return === workInProgress) {
7031
+ return;
7032
+ }
7033
+ node = node.return;
7034
+ }
7035
+ node.sibling.return = node.return;
7036
+ node = node.sibling;
7037
+ }
7038
+ };
7039
+
6635
7040
  updateHostContainer = function (workInProgress) {
6636
7041
  // Noop
6637
7042
  };
@@ -6672,23 +7077,167 @@ if (supportsMutation) {
6672
7077
  } else if (supportsPersistence) {
6673
7078
  // Persistent host tree mode
6674
7079
 
7080
+ appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
7081
+ // We only have the top Fiber that was created but we need recurse down its
7082
+ // children to find all the terminal nodes.
7083
+ var node = workInProgress.child;
7084
+ while (node !== null) {
7085
+ // eslint-disable-next-line no-labels
7086
+ branches: if (node.tag === HostComponent) {
7087
+ var instance = node.stateNode;
7088
+ if (needsVisibilityToggle) {
7089
+ var props = node.memoizedProps;
7090
+ var type = node.type;
7091
+ if (isHidden) {
7092
+ // This child is inside a timed out tree. Hide it.
7093
+ instance = cloneHiddenInstance(instance, type, props, node);
7094
+ } else {
7095
+ // This child was previously inside a timed out tree. If it was not
7096
+ // updated during this render, it may need to be unhidden. Clone
7097
+ // again to be sure.
7098
+ instance = cloneUnhiddenInstance(instance, type, props, node);
7099
+ }
7100
+ node.stateNode = instance;
7101
+ }
7102
+ appendInitialChild(parent, instance);
7103
+ } else if (node.tag === HostText) {
7104
+ var _instance = node.stateNode;
7105
+ if (needsVisibilityToggle) {
7106
+ var text = node.memoizedProps;
7107
+ var rootContainerInstance = getRootHostContainer();
7108
+ var currentHostContext = getHostContext();
7109
+ if (isHidden) {
7110
+ _instance = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
7111
+ } else {
7112
+ _instance = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
7113
+ }
7114
+ node.stateNode = _instance;
7115
+ }
7116
+ appendInitialChild(parent, _instance);
7117
+ } else if (node.tag === HostPortal) {
7118
+ // If we have a portal child, then we don't want to traverse
7119
+ // down its children. Instead, we'll get insertions from each child in
7120
+ // the portal directly.
7121
+ } else if (node.tag === SuspenseComponent) {
7122
+ var current = node.alternate;
7123
+ if (current !== null) {
7124
+ var oldState = current.memoizedState;
7125
+ var newState = node.memoizedState;
7126
+ var oldIsHidden = oldState !== null && oldState.didTimeout;
7127
+ var newIsHidden = newState !== null && newState.didTimeout;
7128
+ if (oldIsHidden !== newIsHidden) {
7129
+ // The placeholder either just timed out or switched back to the normal
7130
+ // children after having previously timed out. Toggle the visibility of
7131
+ // the direct host children.
7132
+ var primaryChildParent = newIsHidden ? node.child : node;
7133
+ if (primaryChildParent !== null) {
7134
+ appendAllChildren(parent, primaryChildParent, true, newIsHidden);
7135
+ }
7136
+ // eslint-disable-next-line no-labels
7137
+ break branches;
7138
+ }
7139
+ }
7140
+ if (node.child !== null) {
7141
+ // Continue traversing like normal
7142
+ node.child.return = node;
7143
+ node = node.child;
7144
+ continue;
7145
+ }
7146
+ } else if (node.child !== null) {
7147
+ node.child.return = node;
7148
+ node = node.child;
7149
+ continue;
7150
+ }
7151
+ // $FlowFixMe This is correct but Flow is confused by the labeled break.
7152
+ node = node;
7153
+ if (node === workInProgress) {
7154
+ return;
7155
+ }
7156
+ while (node.sibling === null) {
7157
+ if (node.return === null || node.return === workInProgress) {
7158
+ return;
7159
+ }
7160
+ node = node.return;
7161
+ }
7162
+ node.sibling.return = node.return;
7163
+ node = node.sibling;
7164
+ }
7165
+ };
7166
+
6675
7167
  // An unfortunate fork of appendAllChildren because we have two different parent types.
6676
- var appendAllChildrenToContainer = function (containerChildSet, workInProgress) {
7168
+ var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
6677
7169
  // We only have the top Fiber that was created but we need recurse down its
6678
7170
  // children to find all the terminal nodes.
6679
7171
  var node = workInProgress.child;
6680
7172
  while (node !== null) {
6681
- if (node.tag === HostComponent || node.tag === HostText) {
6682
- appendChildToContainerChildSet(containerChildSet, node.stateNode);
7173
+ // eslint-disable-next-line no-labels
7174
+ branches: if (node.tag === HostComponent) {
7175
+ var instance = node.stateNode;
7176
+ if (needsVisibilityToggle) {
7177
+ var props = node.memoizedProps;
7178
+ var type = node.type;
7179
+ if (isHidden) {
7180
+ // This child is inside a timed out tree. Hide it.
7181
+ instance = cloneHiddenInstance(instance, type, props, node);
7182
+ } else {
7183
+ // This child was previously inside a timed out tree. If it was not
7184
+ // updated during this render, it may need to be unhidden. Clone
7185
+ // again to be sure.
7186
+ instance = cloneUnhiddenInstance(instance, type, props, node);
7187
+ }
7188
+ node.stateNode = instance;
7189
+ }
7190
+ appendChildToContainerChildSet(containerChildSet, instance);
7191
+ } else if (node.tag === HostText) {
7192
+ var _instance2 = node.stateNode;
7193
+ if (needsVisibilityToggle) {
7194
+ var text = node.memoizedProps;
7195
+ var rootContainerInstance = getRootHostContainer();
7196
+ var currentHostContext = getHostContext();
7197
+ if (isHidden) {
7198
+ _instance2 = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
7199
+ } else {
7200
+ _instance2 = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
7201
+ }
7202
+ node.stateNode = _instance2;
7203
+ }
7204
+ appendChildToContainerChildSet(containerChildSet, _instance2);
6683
7205
  } else if (node.tag === HostPortal) {
6684
7206
  // If we have a portal child, then we don't want to traverse
6685
7207
  // down its children. Instead, we'll get insertions from each child in
6686
7208
  // the portal directly.
7209
+ } else if (node.tag === SuspenseComponent) {
7210
+ var current = node.alternate;
7211
+ if (current !== null) {
7212
+ var oldState = current.memoizedState;
7213
+ var newState = node.memoizedState;
7214
+ var oldIsHidden = oldState !== null && oldState.didTimeout;
7215
+ var newIsHidden = newState !== null && newState.didTimeout;
7216
+ if (oldIsHidden !== newIsHidden) {
7217
+ // The placeholder either just timed out or switched back to the normal
7218
+ // children after having previously timed out. Toggle the visibility of
7219
+ // the direct host children.
7220
+ var primaryChildParent = newIsHidden ? node.child : node;
7221
+ if (primaryChildParent !== null) {
7222
+ appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
7223
+ }
7224
+ // eslint-disable-next-line no-labels
7225
+ break branches;
7226
+ }
7227
+ }
7228
+ if (node.child !== null) {
7229
+ // Continue traversing like normal
7230
+ node.child.return = node;
7231
+ node = node.child;
7232
+ continue;
7233
+ }
6687
7234
  } else if (node.child !== null) {
6688
7235
  node.child.return = node;
6689
7236
  node = node.child;
6690
7237
  continue;
6691
7238
  }
7239
+ // $FlowFixMe This is correct but Flow is confused by the labeled break.
7240
+ node = node;
6692
7241
  if (node === workInProgress) {
6693
7242
  return;
6694
7243
  }
@@ -6711,7 +7260,7 @@ if (supportsMutation) {
6711
7260
  var container = portalOrRoot.containerInfo;
6712
7261
  var newChildSet = createContainerChildSet(container);
6713
7262
  // If children might have changed, we have to add them all to the set.
6714
- appendAllChildrenToContainer(newChildSet, workInProgress);
7263
+ appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
6715
7264
  portalOrRoot.pendingChildren = newChildSet;
6716
7265
  // Schedule an update on the container to swap out the container.
6717
7266
  markUpdate(workInProgress);
@@ -6754,7 +7303,7 @@ if (supportsMutation) {
6754
7303
  markUpdate(workInProgress);
6755
7304
  } else {
6756
7305
  // If children might have changed, we have to add them all to the set.
6757
- appendAllChildren(newInstance, workInProgress);
7306
+ appendAllChildren(newInstance, workInProgress, false, false);
6758
7307
  }
6759
7308
  };
6760
7309
  updateHostText$1 = function (current, workInProgress, oldText, newText) {
@@ -6785,8 +7334,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6785
7334
  var newProps = workInProgress.pendingProps;
6786
7335
 
6787
7336
  switch (workInProgress.tag) {
6788
- case FunctionalComponent:
6789
- case FunctionalComponentLazy:
7337
+ case IndeterminateComponent:
7338
+ break;
7339
+ case LazyComponent:
7340
+ break;
7341
+ case SimpleMemoComponent:
7342
+ case FunctionComponent:
6790
7343
  break;
6791
7344
  case ClassComponent:
6792
7345
  {
@@ -6796,14 +7349,6 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6796
7349
  }
6797
7350
  break;
6798
7351
  }
6799
- case ClassComponentLazy:
6800
- {
6801
- var _Component = getResultFromResolvedThenable(workInProgress.type);
6802
- if (isContextProvider(_Component)) {
6803
- popContext(workInProgress);
6804
- }
6805
- break;
6806
- }
6807
7352
  case HostRoot:
6808
7353
  {
6809
7354
  popHostContainer(workInProgress);
@@ -6859,7 +7404,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6859
7404
  } else {
6860
7405
  var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
6861
7406
 
6862
- appendAllChildren(instance, workInProgress);
7407
+ appendAllChildren(instance, workInProgress, false, false);
6863
7408
 
6864
7409
  // Certain renderers require commit-time effects for initial mount.
6865
7410
  // (eg DOM renderer supports auto-focus for certain elements).
@@ -6904,10 +7449,20 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6904
7449
  break;
6905
7450
  }
6906
7451
  case ForwardRef:
6907
- case ForwardRefLazy:
6908
- break;
6909
- case PlaceholderComponent:
6910
7452
  break;
7453
+ case SuspenseComponent:
7454
+ {
7455
+ var nextState = workInProgress.memoizedState;
7456
+ var prevState = current !== null ? current.memoizedState : null;
7457
+ var nextDidTimeout = nextState !== null && nextState.didTimeout;
7458
+ var prevDidTimeout = prevState !== null && prevState.didTimeout;
7459
+ if (nextDidTimeout !== prevDidTimeout) {
7460
+ // If this render commits, and it switches between the normal state
7461
+ // and the timed-out state, schedule an effect.
7462
+ workInProgress.effectTag |= Update;
7463
+ }
7464
+ break;
7465
+ }
6911
7466
  case Fragment:
6912
7467
  break;
6913
7468
  case Mode:
@@ -6924,10 +7479,18 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6924
7479
  break;
6925
7480
  case ContextConsumer:
6926
7481
  break;
6927
- // Error cases
6928
- case IndeterminateComponent:
6929
- 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.');
6930
- // eslint-disable-next-line no-fallthrough
7482
+ case MemoComponent:
7483
+ break;
7484
+ case IncompleteClassComponent:
7485
+ {
7486
+ // Same as class component case. I put it down here so that the tags are
7487
+ // sequential to ensure this switch is compiled to a jump table.
7488
+ var _Component = workInProgress.type;
7489
+ if (isContextProvider(_Component)) {
7490
+ popContext(workInProgress);
7491
+ }
7492
+ break;
7493
+ }
6931
7494
  default:
6932
7495
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
6933
7496
  }
@@ -6935,6 +7498,17 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6935
7498
  return null;
6936
7499
  }
6937
7500
 
7501
+ function shouldCaptureSuspense(current, workInProgress) {
7502
+ // In order to capture, the Suspense component must have a fallback prop.
7503
+ if (workInProgress.memoizedProps.fallback === undefined) {
7504
+ return false;
7505
+ }
7506
+ // If it was the primary children that just suspended, capture and render the
7507
+ // fallback. Otherwise, don't capture and bubble to the next boundary.
7508
+ var nextState = workInProgress.memoizedState;
7509
+ return nextState === null || !nextState.didTimeout;
7510
+ }
7511
+
6938
7512
  // This module is forked in different environments.
6939
7513
  // By default, return `true` to log errors to the console.
6940
7514
  // Forks can return `false` if this isn't desirable.
@@ -7002,8 +7576,6 @@ function logCapturedError(capturedError) {
7002
7576
  }
7003
7577
  }
7004
7578
 
7005
- var emptyObject = {};
7006
-
7007
7579
  var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
7008
7580
  {
7009
7581
  didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
@@ -7085,7 +7657,6 @@ function safelyDetachRef(current$$1) {
7085
7657
  function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
7086
7658
  switch (finishedWork.tag) {
7087
7659
  case ClassComponent:
7088
- case ClassComponentLazy:
7089
7660
  {
7090
7661
  if (finishedWork.effectTag & Snapshot) {
7091
7662
  if (current$$1 !== null) {
@@ -7113,6 +7684,7 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
7113
7684
  case HostComponent:
7114
7685
  case HostText:
7115
7686
  case HostPortal:
7687
+ case IncompleteClassComponent:
7116
7688
  // Nothing to do for these component types
7117
7689
  return;
7118
7690
  default:
@@ -7125,7 +7697,6 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
7125
7697
  function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
7126
7698
  switch (finishedWork.tag) {
7127
7699
  case ClassComponent:
7128
- case ClassComponentLazy:
7129
7700
  {
7130
7701
  var instance = finishedWork.stateNode;
7131
7702
  if (finishedWork.effectTag & Update) {
@@ -7164,7 +7735,6 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
7164
7735
  _instance = getPublicInstance(finishedWork.child.stateNode);
7165
7736
  break;
7166
7737
  case ClassComponent:
7167
- case ClassComponentLazy:
7168
7738
  _instance = finishedWork.child.stateNode;
7169
7739
  break;
7170
7740
  }
@@ -7212,26 +7782,50 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
7212
7782
  }
7213
7783
  return;
7214
7784
  }
7215
- case PlaceholderComponent:
7785
+ case SuspenseComponent:
7216
7786
  {
7217
- if (enableSuspense) {
7218
- if ((finishedWork.mode & StrictMode) === NoEffect) {
7219
- // In loose mode, a placeholder times out by scheduling a synchronous
7220
- // update in the commit phase. Use `updateQueue` field to signal that
7221
- // the Timeout needs to switch to the placeholder. We don't need an
7222
- // entire queue. Any non-null value works.
7223
- // $FlowFixMe - Intentionally using a value other than an UpdateQueue.
7224
- finishedWork.updateQueue = emptyObject;
7225
- scheduleWork(finishedWork, Sync);
7226
- } else {
7227
- // In strict mode, the Update effect is used to record the time at
7228
- // which the placeholder timed out.
7229
- var currentTime = requestCurrentTime();
7230
- finishedWork.stateNode = { timedOutAt: currentTime };
7787
+ if (finishedWork.effectTag & Callback) {
7788
+ // In non-strict mode, a suspense boundary times out by commiting
7789
+ // twice: first, by committing the children in an inconsistent state,
7790
+ // then hiding them and showing the fallback children in a subsequent
7791
+ var _newState = {
7792
+ alreadyCaptured: true,
7793
+ didTimeout: false,
7794
+ timedOutAt: NoWork
7795
+ };
7796
+ finishedWork.memoizedState = _newState;
7797
+ scheduleWork(finishedWork, Sync);
7798
+ return;
7799
+ }
7800
+ var oldState = current$$1 !== null ? current$$1.memoizedState : null;
7801
+ var newState = finishedWork.memoizedState;
7802
+ var oldDidTimeout = oldState !== null ? oldState.didTimeout : false;
7803
+
7804
+ var newDidTimeout = void 0;
7805
+ var primaryChildParent = finishedWork;
7806
+ if (newState === null) {
7807
+ newDidTimeout = false;
7808
+ } else {
7809
+ newDidTimeout = newState.didTimeout;
7810
+ if (newDidTimeout) {
7811
+ primaryChildParent = finishedWork.child;
7812
+ newState.alreadyCaptured = false;
7813
+ if (newState.timedOutAt === NoWork) {
7814
+ // If the children had not already timed out, record the time.
7815
+ // This is used to compute the elapsed time during subsequent
7816
+ // attempts to render the children.
7817
+ newState.timedOutAt = requestCurrentTime();
7818
+ }
7231
7819
  }
7232
7820
  }
7821
+
7822
+ if (newDidTimeout !== oldDidTimeout && primaryChildParent !== null) {
7823
+ hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
7824
+ }
7233
7825
  return;
7234
7826
  }
7827
+ case IncompleteClassComponent:
7828
+ break;
7235
7829
  default:
7236
7830
  {
7237
7831
  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.');
@@ -7239,6 +7833,45 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
7239
7833
  }
7240
7834
  }
7241
7835
 
7836
+ function hideOrUnhideAllChildren(finishedWork, isHidden) {
7837
+ if (supportsMutation) {
7838
+ // We only have the top Fiber that was inserted but we need recurse down its
7839
+ var node = finishedWork;
7840
+ while (true) {
7841
+ if (node.tag === HostComponent) {
7842
+ var instance = node.stateNode;
7843
+ if (isHidden) {
7844
+ hideInstance(instance);
7845
+ } else {
7846
+ unhideInstance(node.stateNode, node.memoizedProps);
7847
+ }
7848
+ } else if (node.tag === HostText) {
7849
+ var _instance3 = node.stateNode;
7850
+ if (isHidden) {
7851
+ hideTextInstance(_instance3);
7852
+ } else {
7853
+ unhideTextInstance(_instance3, node.memoizedProps);
7854
+ }
7855
+ } else if (node.child !== null) {
7856
+ node.child.return = node;
7857
+ node = node.child;
7858
+ continue;
7859
+ }
7860
+ if (node === finishedWork) {
7861
+ return;
7862
+ }
7863
+ while (node.sibling === null) {
7864
+ if (node.return === null || node.return === finishedWork) {
7865
+ return;
7866
+ }
7867
+ node = node.return;
7868
+ }
7869
+ node.sibling.return = node.return;
7870
+ node = node.sibling;
7871
+ }
7872
+ }
7873
+ }
7874
+
7242
7875
  function commitAttachRef(finishedWork) {
7243
7876
  var ref = finishedWork.ref;
7244
7877
  if (ref !== null) {
@@ -7284,7 +7917,6 @@ function commitUnmount(current$$1) {
7284
7917
 
7285
7918
  switch (current$$1.tag) {
7286
7919
  case ClassComponent:
7287
- case ClassComponentLazy:
7288
7920
  {
7289
7921
  safelyDetachRef(current$$1);
7290
7922
  var instance = current$$1.stateNode;
@@ -7378,7 +8010,6 @@ function commitContainer(finishedWork) {
7378
8010
 
7379
8011
  switch (finishedWork.tag) {
7380
8012
  case ClassComponent:
7381
- case ClassComponentLazy:
7382
8013
  {
7383
8014
  return;
7384
8015
  }
@@ -7643,7 +8274,6 @@ function commitWork(current$$1, finishedWork) {
7643
8274
 
7644
8275
  switch (finishedWork.tag) {
7645
8276
  case ClassComponent:
7646
- case ClassComponentLazy:
7647
8277
  {
7648
8278
  return;
7649
8279
  }
@@ -7687,7 +8317,11 @@ function commitWork(current$$1, finishedWork) {
7687
8317
  {
7688
8318
  return;
7689
8319
  }
7690
- case PlaceholderComponent:
8320
+ case SuspenseComponent:
8321
+ {
8322
+ return;
8323
+ }
8324
+ case IncompleteClassComponent:
7691
8325
  {
7692
8326
  return;
7693
8327
  }
@@ -7705,10 +8339,6 @@ function commitResetTextContent(current$$1) {
7705
8339
  resetTextContent(current$$1.stateNode);
7706
8340
  }
7707
8341
 
7708
- function NoopComponent() {
7709
- return null;
7710
- }
7711
-
7712
8342
  function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
7713
8343
  var update = createUpdate(expirationTime);
7714
8344
  // Unmount the root by rendering null.
@@ -7727,22 +8357,22 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
7727
8357
  function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
7728
8358
  var update = createUpdate(expirationTime);
7729
8359
  update.tag = CaptureUpdate;
7730
- var getDerivedStateFromCatch = fiber.type.getDerivedStateFromCatch;
7731
- if (enableGetDerivedStateFromCatch && typeof getDerivedStateFromCatch === 'function') {
8360
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
8361
+ if (typeof getDerivedStateFromError === 'function') {
7732
8362
  var error = errorInfo.value;
7733
8363
  update.payload = function () {
7734
- return getDerivedStateFromCatch(error);
8364
+ return getDerivedStateFromError(error);
7735
8365
  };
7736
8366
  }
7737
8367
 
7738
8368
  var inst = fiber.stateNode;
7739
8369
  if (inst !== null && typeof inst.componentDidCatch === 'function') {
7740
8370
  update.callback = function callback() {
7741
- if (!enableGetDerivedStateFromCatch || getDerivedStateFromCatch !== 'function') {
8371
+ if (typeof getDerivedStateFromError !== 'function') {
7742
8372
  // To preserve the preexisting retry behavior of error boundaries,
7743
8373
  // we keep track of which ones already failed during this batch.
7744
8374
  // This gets reset before we yield back to the browser.
7745
- // TODO: Warn in strict mode if getDerivedStateFromCatch is
8375
+ // TODO: Warn in strict mode if getDerivedStateFromError is
7746
8376
  // not defined.
7747
8377
  markLegacyErrorBoundaryAsFailed(this);
7748
8378
  }
@@ -7752,6 +8382,14 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
7752
8382
  this.componentDidCatch(error, {
7753
8383
  componentStack: stack !== null ? stack : ''
7754
8384
  });
8385
+ {
8386
+ if (typeof getDerivedStateFromError !== 'function') {
8387
+ // If componentDidCatch is the only error boundary method defined,
8388
+ // then it needs to call setState to recover from errors.
8389
+ // If no state update is scheduled then the boundary will swallow the error.
8390
+ !(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;
8391
+ }
8392
+ }
7755
8393
  };
7756
8394
  }
7757
8395
  return update;
@@ -7763,7 +8401,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7763
8401
  // Its effect list is no longer valid.
7764
8402
  sourceFiber.firstEffect = sourceFiber.lastEffect = null;
7765
8403
 
7766
- if (enableSuspense && value !== null && typeof value === 'object' && typeof value.then === 'function') {
8404
+ if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
7767
8405
  // This is a thenable.
7768
8406
  var thenable = value;
7769
8407
 
@@ -7776,21 +8414,20 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7776
8414
  var earliestTimeoutMs = -1;
7777
8415
  var startTimeMs = -1;
7778
8416
  do {
7779
- if (_workInProgress.tag === PlaceholderComponent) {
8417
+ if (_workInProgress.tag === SuspenseComponent) {
7780
8418
  var current = _workInProgress.alternate;
7781
- if (current !== null && current.memoizedState === true && current.stateNode !== null) {
7782
- // Reached a placeholder that already timed out. Each timed out
7783
- // placeholder acts as the root of a new suspense boundary.
7784
-
7785
- // Use the time at which the placeholder timed out as the start time
7786
- // for the current render.
7787
- var timedOutAt = current.stateNode.timedOutAt;
7788
- startTimeMs = expirationTimeToMs(timedOutAt);
7789
-
7790
- // Do not search any further.
7791
- break;
8419
+ if (current !== null) {
8420
+ var currentState = current.memoizedState;
8421
+ if (currentState !== null && currentState.didTimeout) {
8422
+ // Reached a boundary that already timed out. Do not search
8423
+ // any further.
8424
+ var timedOutAt = currentState.timedOutAt;
8425
+ startTimeMs = expirationTimeToMs(timedOutAt);
8426
+ // Do not search any further.
8427
+ break;
8428
+ }
7792
8429
  }
7793
- var timeoutPropMs = _workInProgress.pendingProps.delayMs;
8430
+ var timeoutPropMs = _workInProgress.pendingProps.maxDuration;
7794
8431
  if (typeof timeoutPropMs === 'number') {
7795
8432
  if (timeoutPropMs <= 0) {
7796
8433
  earliestTimeoutMs = 0;
@@ -7802,103 +8439,96 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7802
8439
  _workInProgress = _workInProgress.return;
7803
8440
  } while (_workInProgress !== null);
7804
8441
 
7805
- // Schedule the nearest Placeholder to re-render the timed out view.
8442
+ // Schedule the nearest Suspense to re-render the timed out view.
7806
8443
  _workInProgress = returnFiber;
7807
8444
  do {
7808
- if (_workInProgress.tag === PlaceholderComponent) {
7809
- var didTimeout = _workInProgress.memoizedState;
7810
- if (!didTimeout) {
7811
- // Found the nearest boundary.
7812
-
7813
- // If the boundary is not in async mode, we should not suspend, and
7814
- // likewise, when the promise resolves, we should ping synchronously.
7815
- var pingTime = (_workInProgress.mode & AsyncMode) === NoEffect ? Sync : renderExpirationTime;
7816
-
7817
- // Attach a listener to the promise to "ping" the root and retry.
7818
- var onResolveOrReject = retrySuspendedRoot.bind(null, root, _workInProgress, pingTime);
7819
- thenable.then(onResolveOrReject, onResolveOrReject);
7820
-
7821
- // If the boundary is outside of strict mode, we should *not* suspend
7822
- // the commit. Pretend as if the suspended component rendered null and
7823
- // keep rendering. In the commit phase, we'll schedule a subsequent
7824
- // synchronous update to re-render the Placeholder.
7825
- //
7826
- // Note: It doesn't matter whether the component that suspended was
7827
- // inside a strict mode tree. If the Placeholder is outside of it, we
7828
- // should *not* suspend the commit.
7829
- if ((_workInProgress.mode & StrictMode) === NoEffect) {
7830
- _workInProgress.effectTag |= Update;
7831
-
7832
- // Unmount the source fiber's children
7833
- var nextChildren = null;
7834
- reconcileChildren(sourceFiber.alternate, sourceFiber, nextChildren, renderExpirationTime);
7835
- sourceFiber.effectTag &= ~Incomplete;
7836
- if (sourceFiber.tag === IndeterminateComponent) {
7837
- // Let's just assume it's a functional component. This fiber will
7838
- // be unmounted in the immediate next commit, anyway.
7839
- sourceFiber.tag = FunctionalComponent;
7840
- }
7841
-
7842
- if (sourceFiber.tag === ClassComponent || sourceFiber.tag === ClassComponentLazy) {
7843
- // We're going to commit this fiber even though it didn't
7844
- // complete. But we shouldn't call any lifecycle methods or
7845
- // callbacks. Remove all lifecycle effect tags.
7846
- sourceFiber.effectTag &= ~LifecycleEffectMask;
7847
- if (sourceFiber.alternate === null) {
7848
- // We're about to mount a class component that doesn't have an
7849
- // instance. Turn this into a dummy functional component instead,
7850
- // to prevent type errors. This is a bit weird but it's an edge
7851
- // case and we're about to synchronously delete this
7852
- // component, anyway.
7853
- sourceFiber.tag = FunctionalComponent;
7854
- sourceFiber.type = NoopComponent;
7855
- }
8445
+ if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress.alternate, _workInProgress)) {
8446
+ // Found the nearest boundary.
8447
+
8448
+ // If the boundary is not in concurrent mode, we should not suspend, and
8449
+ // likewise, when the promise resolves, we should ping synchronously.
8450
+ var pingTime = (_workInProgress.mode & ConcurrentMode) === NoEffect ? Sync : renderExpirationTime;
8451
+
8452
+ // Attach a listener to the promise to "ping" the root and retry.
8453
+ var onResolveOrReject = retrySuspendedRoot.bind(null, root, _workInProgress, sourceFiber, pingTime);
8454
+ if (enableSchedulerTracing) {
8455
+ onResolveOrReject = unstable_wrap(onResolveOrReject);
8456
+ }
8457
+ thenable.then(onResolveOrReject, onResolveOrReject);
8458
+
8459
+ // If the boundary is outside of concurrent mode, we should *not*
8460
+ // suspend the commit. Pretend as if the suspended component rendered
8461
+ // null and keep rendering. In the commit phase, we'll schedule a
8462
+ // subsequent synchronous update to re-render the Suspense.
8463
+ //
8464
+ // Note: It doesn't matter whether the component that suspended was
8465
+ // inside a concurrent mode tree. If the Suspense is outside of it, we
8466
+ // should *not* suspend the commit.
8467
+ if ((_workInProgress.mode & ConcurrentMode) === NoEffect) {
8468
+ _workInProgress.effectTag |= Callback;
8469
+
8470
+ // Unmount the source fiber's children
8471
+ var nextChildren = null;
8472
+ reconcileChildren(sourceFiber.alternate, sourceFiber, nextChildren, renderExpirationTime);
8473
+ sourceFiber.effectTag &= ~Incomplete;
8474
+
8475
+ if (sourceFiber.tag === ClassComponent) {
8476
+ // We're going to commit this fiber even though it didn't complete.
8477
+ // But we shouldn't call any lifecycle methods or callbacks. Remove
8478
+ // all lifecycle effect tags.
8479
+ sourceFiber.effectTag &= ~LifecycleEffectMask;
8480
+ var _current = sourceFiber.alternate;
8481
+ if (_current === null) {
8482
+ // This is a new mount. Change the tag so it's not mistaken for a
8483
+ // completed component. For example, we should not call
8484
+ // componentWillUnmount if it is deleted.
8485
+ sourceFiber.tag = IncompleteClassComponent;
7856
8486
  }
7857
-
7858
- // Exit without suspending.
7859
- return;
7860
8487
  }
7861
8488
 
7862
- // Confirmed that the boundary is in a strict mode tree. Continue with
7863
- // the normal suspend path.
8489
+ // Exit without suspending.
8490
+ return;
8491
+ }
7864
8492
 
7865
- var absoluteTimeoutMs = void 0;
7866
- if (earliestTimeoutMs === -1) {
7867
- // If no explicit threshold is given, default to an abitrarily large
7868
- // value. The actual size doesn't matter because the threshold for the
7869
- // whole tree will be clamped to the expiration time.
7870
- absoluteTimeoutMs = maxSigned31BitInt;
7871
- } else {
7872
- if (startTimeMs === -1) {
7873
- // This suspend happened outside of any already timed-out
7874
- // placeholders. We don't know exactly when the update was scheduled,
7875
- // but we can infer an approximate start time from the expiration
7876
- // time. First, find the earliest uncommitted expiration time in the
7877
- // tree, including work that is suspended. Then subtract the offset
7878
- // used to compute an async update's expiration time. This will cause
7879
- // high priority (interactive) work to expire earlier than necessary,
7880
- // but we can account for this by adjusting for the Just Noticeable
7881
- // Difference.
7882
- var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, renderExpirationTime);
7883
- var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
7884
- startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
7885
- }
7886
- absoluteTimeoutMs = startTimeMs + earliestTimeoutMs;
8493
+ // Confirmed that the boundary is in a concurrent mode tree. Continue
8494
+ // with the normal suspend path.
8495
+
8496
+ var absoluteTimeoutMs = void 0;
8497
+ if (earliestTimeoutMs === -1) {
8498
+ // If no explicit threshold is given, default to an abitrarily large
8499
+ // value. The actual size doesn't matter because the threshold for the
8500
+ // whole tree will be clamped to the expiration time.
8501
+ absoluteTimeoutMs = maxSigned31BitInt;
8502
+ } else {
8503
+ if (startTimeMs === -1) {
8504
+ // This suspend happened outside of any already timed-out
8505
+ // placeholders. We don't know exactly when the update was
8506
+ // scheduled, but we can infer an approximate start time from the
8507
+ // expiration time. First, find the earliest uncommitted expiration
8508
+ // time in the tree, including work that is suspended. Then subtract
8509
+ // the offset used to compute an async update's expiration time.
8510
+ // This will cause high priority (interactive) work to expire
8511
+ // earlier than necessary, but we can account for this by adjusting
8512
+ // for the Just Noticeable Difference.
8513
+ var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, renderExpirationTime);
8514
+ var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
8515
+ startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
7887
8516
  }
8517
+ absoluteTimeoutMs = startTimeMs + earliestTimeoutMs;
8518
+ }
7888
8519
 
7889
- // Mark the earliest timeout in the suspended fiber's ancestor path.
7890
- // After completing the root, we'll take the largest of all the
7891
- // suspended fiber's timeouts and use it to compute a timeout for the
7892
- // whole tree.
7893
- renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
8520
+ // Mark the earliest timeout in the suspended fiber's ancestor path.
8521
+ // After completing the root, we'll take the largest of all the
8522
+ // suspended fiber's timeouts and use it to compute a timeout for the
8523
+ // whole tree.
8524
+ renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
7894
8525
 
7895
- _workInProgress.effectTag |= ShouldCapture;
7896
- _workInProgress.expirationTime = renderExpirationTime;
7897
- return;
7898
- }
7899
- // This boundary already captured during this render. Continue to the
7900
- // next boundary.
8526
+ _workInProgress.effectTag |= ShouldCapture;
8527
+ _workInProgress.expirationTime = renderExpirationTime;
8528
+ return;
7901
8529
  }
8530
+ // This boundary already captured during this render. Continue to the next
8531
+ // boundary.
7902
8532
  _workInProgress = _workInProgress.return;
7903
8533
  } while (_workInProgress !== null);
7904
8534
  // No boundary was found. Fallthrough to error mode.
@@ -7923,12 +8553,11 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
7923
8553
  return;
7924
8554
  }
7925
8555
  case ClassComponent:
7926
- case ClassComponentLazy:
7927
8556
  // Capture and retry
7928
8557
  var errorInfo = value;
7929
8558
  var ctor = workInProgress.type;
7930
8559
  var instance = workInProgress.stateNode;
7931
- if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromCatch === 'function' && enableGetDerivedStateFromCatch || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
8560
+ if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
7932
8561
  workInProgress.effectTag |= ShouldCapture;
7933
8562
  workInProgress.expirationTime = renderExpirationTime;
7934
8563
  // Schedule the error boundary to re-render using updated state
@@ -7959,26 +8588,13 @@ function unwindWork(workInProgress, renderExpirationTime) {
7959
8588
  }
7960
8589
  return null;
7961
8590
  }
7962
- case ClassComponentLazy:
7963
- {
7964
- var _Component = workInProgress.type._reactResult;
7965
- if (isContextProvider(_Component)) {
7966
- popContext(workInProgress);
7967
- }
7968
- var _effectTag = workInProgress.effectTag;
7969
- if (_effectTag & ShouldCapture) {
7970
- workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
7971
- return workInProgress;
7972
- }
7973
- return null;
7974
- }
7975
8591
  case HostRoot:
7976
8592
  {
7977
8593
  popHostContainer(workInProgress);
7978
8594
  popTopLevelContextObject(workInProgress);
7979
- var _effectTag2 = workInProgress.effectTag;
7980
- !((_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;
7981
- workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
8595
+ var _effectTag = workInProgress.effectTag;
8596
+ !((_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;
8597
+ workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
7982
8598
  return workInProgress;
7983
8599
  }
7984
8600
  case HostComponent:
@@ -7986,11 +8602,37 @@ function unwindWork(workInProgress, renderExpirationTime) {
7986
8602
  popHostContext(workInProgress);
7987
8603
  return null;
7988
8604
  }
7989
- case PlaceholderComponent:
8605
+ case SuspenseComponent:
7990
8606
  {
7991
- var _effectTag3 = workInProgress.effectTag;
7992
- if (_effectTag3 & ShouldCapture) {
7993
- workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
8607
+ var _effectTag2 = workInProgress.effectTag;
8608
+ if (_effectTag2 & ShouldCapture) {
8609
+ workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
8610
+ // Captured a suspense effect. Set the boundary's `alreadyCaptured`
8611
+ // state to true so we know to render the fallback.
8612
+ var current = workInProgress.alternate;
8613
+ var currentState = current !== null ? current.memoizedState : null;
8614
+ var nextState = workInProgress.memoizedState;
8615
+ if (nextState === null) {
8616
+ // No existing state. Create a new object.
8617
+ nextState = {
8618
+ alreadyCaptured: true,
8619
+ didTimeout: false,
8620
+ timedOutAt: NoWork
8621
+ };
8622
+ } else if (currentState === nextState) {
8623
+ // There is an existing state but it's the same as the current tree's.
8624
+ // Clone the object.
8625
+ nextState = {
8626
+ alreadyCaptured: true,
8627
+ didTimeout: nextState.didTimeout,
8628
+ timedOutAt: nextState.timedOutAt
8629
+ };
8630
+ } else {
8631
+ // Already have a clone, so it's safe to mutate.
8632
+ nextState.alreadyCaptured = true;
8633
+ }
8634
+ workInProgress.memoizedState = nextState;
8635
+ // Re-render the boundary.
7994
8636
  return workInProgress;
7995
8637
  }
7996
8638
  return null;
@@ -8016,14 +8658,6 @@ function unwindInterruptedWork(interruptedWork) {
8016
8658
  }
8017
8659
  break;
8018
8660
  }
8019
- case ClassComponentLazy:
8020
- {
8021
- var _childContextTypes = interruptedWork.type._reactResult.childContextTypes;
8022
- if (_childContextTypes !== null && _childContextTypes !== undefined) {
8023
- popContext(interruptedWork);
8024
- }
8025
- break;
8026
- }
8027
8661
  case HostRoot:
8028
8662
  {
8029
8663
  popHostContainer(interruptedWork);
@@ -8125,10 +8759,6 @@ var legacyErrorBoundariesThatAlreadyFailed = null;
8125
8759
  // Used for performance tracking.
8126
8760
  var interruptedBy = null;
8127
8761
 
8128
- // Do not decrement interaction counts in the event of suspense timeouts.
8129
- // This would lead to prematurely calling the interaction-complete hook.
8130
- var suspenseDidTimeout = false;
8131
-
8132
8762
  var stashedWorkInProgressProperties = void 0;
8133
8763
  var replayUnitOfWork = void 0;
8134
8764
  var isReplayingFailedUnitOfWork = void 0;
@@ -8170,14 +8800,6 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
8170
8800
  }
8171
8801
  break;
8172
8802
  }
8173
- case ClassComponentLazy:
8174
- {
8175
- var _Component = getResultFromResolvedThenable(failedUnitOfWork.type);
8176
- if (isContextProvider(_Component)) {
8177
- popContext(failedUnitOfWork);
8178
- }
8179
- break;
8180
- }
8181
8803
  case HostPortal:
8182
8804
  popHostContainer(failedUnitOfWork);
8183
8805
  break;
@@ -8333,14 +8955,11 @@ function commitBeforeMutationLifecycles() {
8333
8955
  function commitAllLifeCycles(finishedRoot, committedExpirationTime) {
8334
8956
  {
8335
8957
  ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
8958
+ ReactStrictModeWarnings.flushLegacyContextWarning();
8336
8959
 
8337
8960
  if (warnAboutDeprecatedLifecycles) {
8338
8961
  ReactStrictModeWarnings.flushPendingDeprecationWarnings();
8339
8962
  }
8340
-
8341
- if (warnAboutLegacyContextAPI) {
8342
- ReactStrictModeWarnings.flushLegacyContextWarning();
8343
- }
8344
8963
  }
8345
8964
  while (nextEffect !== null) {
8346
8965
  var effectTag = nextEffect.effectTag;
@@ -8399,27 +9018,11 @@ function commitRoot(root, finishedWork) {
8399
9018
  markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
8400
9019
 
8401
9020
  var prevInteractions = null;
8402
- var committedInteractions = enableSchedulerTracing ? [] : null;
8403
9021
  if (enableSchedulerTracing) {
8404
9022
  // Restore any pending interactions at this point,
8405
9023
  // So that cascading work triggered during the render phase will be accounted for.
8406
9024
  prevInteractions = __interactionsRef.current;
8407
9025
  __interactionsRef.current = root.memoizedInteractions;
8408
-
8409
- // We are potentially finished with the current batch of interactions.
8410
- // So we should clear them out of the pending interaction map.
8411
- // We do this at the start of commit in case cascading work is scheduled by commit phase lifecycles.
8412
- // In that event, interaction data may be added back into the pending map for a future commit.
8413
- // We also store the interactions we are about to commit so that we can notify subscribers after we're done.
8414
- // These are stored as an Array rather than a Set,
8415
- // Because the same interaction may be pending for multiple expiration times,
8416
- // In which case it's important that we decrement the count the right number of times after finishing.
8417
- root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
8418
- if (scheduledExpirationTime <= committedExpirationTime) {
8419
- committedInteractions.push.apply(committedInteractions, Array.from(scheduledInteractions));
8420
- root.pendingInteractionMap.delete(scheduledExpirationTime);
8421
- }
8422
- });
8423
9026
  }
8424
9027
 
8425
9028
  // Reset this to null before calling lifecycles
@@ -8571,28 +9174,35 @@ function commitRoot(root, finishedWork) {
8571
9174
  unhandledError = error;
8572
9175
  }
8573
9176
  } finally {
8574
- // Don't update interaction counts if we're frozen due to suspense.
8575
- // In this case, we can skip the completed-work check entirely.
8576
- if (!suspenseDidTimeout) {
8577
- // Now that we're done, check the completed batch of interactions.
8578
- // If no more work is outstanding for a given interaction,
8579
- // We need to notify the subscribers that it's finished.
8580
- committedInteractions.forEach(function (interaction) {
8581
- interaction.__count--;
8582
- if (subscriber !== null && interaction.__count === 0) {
8583
- try {
8584
- subscriber.onInteractionScheduledWorkCompleted(interaction);
8585
- } catch (error) {
8586
- // It's not safe for commitRoot() to throw.
8587
- // Store the error for now and we'll re-throw in finishRendering().
8588
- if (!hasUnhandledError) {
8589
- hasUnhandledError = true;
8590
- unhandledError = error;
9177
+ // Clear completed interactions from the pending Map.
9178
+ // Unless the render was suspended or cascading work was scheduled,
9179
+ // In which case– leave pending interactions until the subsequent render.
9180
+ var pendingInteractionMap = root.pendingInteractionMap;
9181
+ pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
9182
+ // Only decrement the pending interaction count if we're done.
9183
+ // If there's still work at the current priority,
9184
+ // That indicates that we are waiting for suspense data.
9185
+ if (earliestRemainingTimeAfterCommit === NoWork || scheduledExpirationTime < earliestRemainingTimeAfterCommit) {
9186
+ pendingInteractionMap.delete(scheduledExpirationTime);
9187
+
9188
+ scheduledInteractions.forEach(function (interaction) {
9189
+ interaction.__count--;
9190
+
9191
+ if (subscriber !== null && interaction.__count === 0) {
9192
+ try {
9193
+ subscriber.onInteractionScheduledWorkCompleted(interaction);
9194
+ } catch (error) {
9195
+ // It's not safe for commitRoot() to throw.
9196
+ // Store the error for now and we'll re-throw in finishRendering().
9197
+ if (!hasUnhandledError) {
9198
+ hasUnhandledError = true;
9199
+ unhandledError = error;
9200
+ }
8591
9201
  }
8592
9202
  }
8593
- }
8594
- });
8595
- }
9203
+ });
9204
+ }
9205
+ });
8596
9206
  }
8597
9207
  }
8598
9208
  }
@@ -8691,23 +9301,12 @@ function completeUnitOfWork(workInProgress) {
8691
9301
  } else {
8692
9302
  nextUnitOfWork = completeWork(current$$1, workInProgress, nextRenderExpirationTime);
8693
9303
  }
8694
- var next = nextUnitOfWork;
8695
9304
  stopWorkTimer(workInProgress);
8696
9305
  resetChildExpirationTime(workInProgress, nextRenderExpirationTime);
8697
9306
  {
8698
9307
  resetCurrentFiber();
8699
9308
  }
8700
9309
 
8701
- if (next !== null) {
8702
- stopWorkTimer(workInProgress);
8703
- if (true && ReactFiberInstrumentation_1.debugTool) {
8704
- ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
8705
- }
8706
- // If completing this work spawned new work, do that next. We'll come
8707
- // back here again.
8708
- return next;
8709
- }
8710
-
8711
9310
  if (returnFiber !== null &&
8712
9311
  // Do not append effects to parents if a sibling failed to complete
8713
9312
  (returnFiber.effectTag & Incomplete) === NoEffect) {
@@ -8767,7 +9366,7 @@ function completeUnitOfWork(workInProgress) {
8767
9366
  // This fiber did not complete because something threw. Pop values off
8768
9367
  // the stack without entering the complete phase. If this is a boundary,
8769
9368
  // capture values if possible.
8770
- var _next = unwindWork(workInProgress, nextRenderExpirationTime);
9369
+ var next = unwindWork(workInProgress, nextRenderExpirationTime);
8771
9370
  // Because this fiber did not complete, don't reset its expiration time.
8772
9371
  if (workInProgress.effectTag & DidCapture) {
8773
9372
  // Restarting an error boundary
@@ -8780,7 +9379,7 @@ function completeUnitOfWork(workInProgress) {
8780
9379
  resetCurrentFiber();
8781
9380
  }
8782
9381
 
8783
- if (_next !== null) {
9382
+ if (next !== null) {
8784
9383
  stopWorkTimer(workInProgress);
8785
9384
  if (true && ReactFiberInstrumentation_1.debugTool) {
8786
9385
  ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
@@ -8788,14 +9387,14 @@ function completeUnitOfWork(workInProgress) {
8788
9387
 
8789
9388
  if (enableProfilerTimer) {
8790
9389
  // Include the time spent working on failed children before continuing.
8791
- if (_next.mode & ProfileMode) {
8792
- var actualDuration = _next.actualDuration;
8793
- var child = _next.child;
9390
+ if (next.mode & ProfileMode) {
9391
+ var actualDuration = next.actualDuration;
9392
+ var child = next.child;
8794
9393
  while (child !== null) {
8795
9394
  actualDuration += child.actualDuration;
8796
9395
  child = child.sibling;
8797
9396
  }
8798
- _next.actualDuration = actualDuration;
9397
+ next.actualDuration = actualDuration;
8799
9398
  }
8800
9399
  }
8801
9400
 
@@ -8803,8 +9402,8 @@ function completeUnitOfWork(workInProgress) {
8803
9402
  // back here again.
8804
9403
  // Since we're restarting, remove anything that is not a host effect
8805
9404
  // from the effect tag.
8806
- _next.effectTag &= HostEffectMask;
8807
- return _next;
9405
+ next.effectTag &= HostEffectMask;
9406
+ return next;
8808
9407
  }
8809
9408
 
8810
9409
  if (returnFiber !== null) {
@@ -8860,6 +9459,7 @@ function performUnitOfWork(workInProgress) {
8860
9459
  }
8861
9460
 
8862
9461
  next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
9462
+ workInProgress.memoizedProps = workInProgress.pendingProps;
8863
9463
 
8864
9464
  if (workInProgress.mode & ProfileMode) {
8865
9465
  // Record the render duration assuming we didn't bailout (or error).
@@ -8867,6 +9467,7 @@ function performUnitOfWork(workInProgress) {
8867
9467
  }
8868
9468
  } else {
8869
9469
  next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
9470
+ workInProgress.memoizedProps = workInProgress.pendingProps;
8870
9471
  }
8871
9472
 
8872
9473
  {
@@ -8914,14 +9515,6 @@ function renderRoot(root, isYieldy, isExpired) {
8914
9515
 
8915
9516
  var expirationTime = root.nextExpirationTimeToWorkOn;
8916
9517
 
8917
- var prevInteractions = null;
8918
- if (enableSchedulerTracing) {
8919
- // We're about to start new traced work.
8920
- // Restore pending interactions so cascading work triggered during the render phase will be accounted for.
8921
- prevInteractions = __interactionsRef.current;
8922
- __interactionsRef.current = root.memoizedInteractions;
8923
- }
8924
-
8925
9518
  // Check if we're starting from a fresh stack, or if we're resuming from
8926
9519
  // previously yielded work.
8927
9520
  if (expirationTime !== nextRenderExpirationTime || root !== nextRoot || nextUnitOfWork === null) {
@@ -8970,6 +9563,14 @@ function renderRoot(root, isYieldy, isExpired) {
8970
9563
  }
8971
9564
  }
8972
9565
 
9566
+ var prevInteractions = null;
9567
+ if (enableSchedulerTracing) {
9568
+ // We're about to start new traced work.
9569
+ // Restore pending interactions so cascading work triggered during the render phase will be accounted for.
9570
+ prevInteractions = __interactionsRef.current;
9571
+ __interactionsRef.current = root.memoizedInteractions;
9572
+ }
9573
+
8973
9574
  var didFatal = false;
8974
9575
 
8975
9576
  startWorkLoopTimer(nextUnitOfWork);
@@ -9100,7 +9701,7 @@ function renderRoot(root, isYieldy, isExpired) {
9100
9701
  }
9101
9702
  }
9102
9703
 
9103
- if (enableSuspense && !isExpired && nextLatestAbsoluteTimeoutMs !== -1) {
9704
+ if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) {
9104
9705
  // The tree was suspended.
9105
9706
  var _suspendedExpirationTime2 = expirationTime;
9106
9707
  markSuspendedPriorityLevel(root, _suspendedExpirationTime2);
@@ -9140,10 +9741,9 @@ function dispatch(sourceFiber, value, expirationTime) {
9140
9741
  while (fiber !== null) {
9141
9742
  switch (fiber.tag) {
9142
9743
  case ClassComponent:
9143
- case ClassComponentLazy:
9144
9744
  var ctor = fiber.type;
9145
9745
  var instance = fiber.stateNode;
9146
- if (typeof ctor.getDerivedStateFromCatch === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
9746
+ if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
9147
9747
  var errorInfo = createCapturedValue(value, sourceFiber);
9148
9748
  var update = createClassErrorUpdate(fiber, errorInfo, expirationTime);
9149
9749
  enqueueUpdate(fiber, update);
@@ -9201,7 +9801,7 @@ function computeExpirationForFiber(currentTime, fiber) {
9201
9801
  } else {
9202
9802
  // No explicit expiration context was set, and we're not currently
9203
9803
  // performing work. Calculate a new expiration time.
9204
- if (fiber.mode & AsyncMode) {
9804
+ if (fiber.mode & ConcurrentMode) {
9205
9805
  if (isBatchingInteractiveUpdates) {
9206
9806
  // This is an interactive update
9207
9807
  expirationTime = computeInteractiveExpiration(currentTime);
@@ -9233,41 +9833,69 @@ function renderDidError() {
9233
9833
  nextRenderDidError = true;
9234
9834
  }
9235
9835
 
9236
- function retrySuspendedRoot(root, fiber, suspendedTime) {
9237
- if (enableSuspense) {
9238
- var retryTime = void 0;
9836
+ function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) {
9837
+ var retryTime = void 0;
9239
9838
 
9240
- if (isPriorityLevelSuspended(root, suspendedTime)) {
9241
- // Ping at the original level
9242
- retryTime = suspendedTime;
9243
- markPingedPriorityLevel(root, retryTime);
9244
- } else {
9245
- // Placeholder already timed out. Compute a new expiration time
9246
- var currentTime = requestCurrentTime();
9247
- retryTime = computeExpirationForFiber(currentTime, fiber);
9248
- markPendingPriorityLevel(root, retryTime);
9839
+ if (isPriorityLevelSuspended(root, suspendedTime)) {
9840
+ // Ping at the original level
9841
+ retryTime = suspendedTime;
9842
+
9843
+ markPingedPriorityLevel(root, retryTime);
9844
+ } else {
9845
+ // Suspense already timed out. Compute a new expiration time
9846
+ var currentTime = requestCurrentTime();
9847
+ retryTime = computeExpirationForFiber(currentTime, boundaryFiber);
9848
+ markPendingPriorityLevel(root, retryTime);
9849
+ }
9850
+
9851
+ // TODO: If the suspense fiber has already rendered the primary children
9852
+ // without suspending (that is, all of the promises have already resolved),
9853
+ // we should not trigger another update here. One case this happens is when
9854
+ // we are in sync mode and a single promise is thrown both on initial render
9855
+ // and on update; we attach two .then(retrySuspendedRoot) callbacks and each
9856
+ // one performs Sync work, rerendering the Suspense.
9857
+
9858
+ if ((boundaryFiber.mode & ConcurrentMode) !== NoContext) {
9859
+ if (root === nextRoot && nextRenderExpirationTime === suspendedTime) {
9860
+ // Received a ping at the same priority level at which we're currently
9861
+ // rendering. Restart from the root.
9862
+ nextRoot = null;
9249
9863
  }
9864
+ }
9250
9865
 
9251
- scheduleWorkToRoot(fiber, retryTime);
9252
- var rootExpirationTime = root.expirationTime;
9253
- if (rootExpirationTime !== NoWork) {
9254
- if (enableSchedulerTracing) {
9255
- // Restore previous interactions so that new work is associated with them.
9256
- var prevInteractions = __interactionsRef.current;
9257
- __interactionsRef.current = root.memoizedInteractions;
9258
- // Because suspense timeouts do not decrement the interaction count,
9259
- // Continued suspense work should also not increment the count.
9260
- storeInteractionsForExpirationTime(root, rootExpirationTime, false);
9261
- requestWork(root, rootExpirationTime);
9262
- __interactionsRef.current = prevInteractions;
9263
- } else {
9264
- requestWork(root, rootExpirationTime);
9265
- }
9866
+ scheduleWorkToRoot(boundaryFiber, retryTime);
9867
+ if ((boundaryFiber.mode & ConcurrentMode) === NoContext) {
9868
+ // Outside of concurrent mode, we must schedule an update on the source
9869
+ // fiber, too, since it already committed in an inconsistent state and
9870
+ // therefore does not have any pending work.
9871
+ scheduleWorkToRoot(sourceFiber, retryTime);
9872
+ var sourceTag = sourceFiber.tag;
9873
+ if (sourceTag === ClassComponent && sourceFiber.stateNode !== null) {
9874
+ // When we try rendering again, we should not reuse the current fiber,
9875
+ // since it's known to be in an inconsistent state. Use a force updte to
9876
+ // prevent a bail out.
9877
+ var update = createUpdate(retryTime);
9878
+ update.tag = ForceUpdate;
9879
+ enqueueUpdate(sourceFiber, update);
9266
9880
  }
9267
9881
  }
9882
+
9883
+ var rootExpirationTime = root.expirationTime;
9884
+ if (rootExpirationTime !== NoWork) {
9885
+ requestWork(root, rootExpirationTime);
9886
+ }
9268
9887
  }
9269
9888
 
9270
9889
  function scheduleWorkToRoot(fiber, expirationTime) {
9890
+ recordScheduleUpdate();
9891
+
9892
+ {
9893
+ if (fiber.tag === ClassComponent) {
9894
+ var instance = fiber.stateNode;
9895
+ warnAboutInvalidUpdates(instance);
9896
+ }
9897
+ }
9898
+
9271
9899
  // Update the source fiber's expiration time
9272
9900
  if (fiber.expirationTime === NoWork || fiber.expirationTime > expirationTime) {
9273
9901
  fiber.expirationTime = expirationTime;
@@ -9278,85 +9906,75 @@ function scheduleWorkToRoot(fiber, expirationTime) {
9278
9906
  }
9279
9907
  // Walk the parent path to the root and update the child expiration time.
9280
9908
  var node = fiber.return;
9909
+ var root = null;
9281
9910
  if (node === null && fiber.tag === HostRoot) {
9282
- return fiber.stateNode;
9283
- }
9284
- while (node !== null) {
9285
- alternate = node.alternate;
9286
- if (node.childExpirationTime === NoWork || node.childExpirationTime > expirationTime) {
9287
- node.childExpirationTime = expirationTime;
9288
- if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9911
+ root = fiber.stateNode;
9912
+ } else {
9913
+ while (node !== null) {
9914
+ alternate = node.alternate;
9915
+ if (node.childExpirationTime === NoWork || node.childExpirationTime > expirationTime) {
9916
+ node.childExpirationTime = expirationTime;
9917
+ if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9918
+ alternate.childExpirationTime = expirationTime;
9919
+ }
9920
+ } else if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9289
9921
  alternate.childExpirationTime = expirationTime;
9290
9922
  }
9291
- } else if (alternate !== null && (alternate.childExpirationTime === NoWork || alternate.childExpirationTime > expirationTime)) {
9292
- alternate.childExpirationTime = expirationTime;
9293
- }
9294
- if (node.return === null && node.tag === HostRoot) {
9295
- return node.stateNode;
9923
+ if (node.return === null && node.tag === HostRoot) {
9924
+ root = node.stateNode;
9925
+ break;
9926
+ }
9927
+ node = node.return;
9296
9928
  }
9297
- node = node.return;
9298
9929
  }
9299
- return null;
9300
- }
9301
9930
 
9302
- function storeInteractionsForExpirationTime(root, expirationTime, updateInteractionCounts) {
9303
- if (!enableSchedulerTracing) {
9304
- return;
9931
+ if (root === null) {
9932
+ if (true && fiber.tag === ClassComponent) {
9933
+ warnAboutUpdateOnUnmounted(fiber);
9934
+ }
9935
+ return null;
9305
9936
  }
9306
9937
 
9307
- var interactions = __interactionsRef.current;
9308
- if (interactions.size > 0) {
9309
- var pendingInteractions = root.pendingInteractionMap.get(expirationTime);
9310
- if (pendingInteractions != null) {
9311
- interactions.forEach(function (interaction) {
9312
- if (updateInteractionCounts && !pendingInteractions.has(interaction)) {
9313
- // Update the pending async work count for previously unscheduled interaction.
9314
- interaction.__count++;
9315
- }
9938
+ if (enableSchedulerTracing) {
9939
+ var interactions = __interactionsRef.current;
9940
+ if (interactions.size > 0) {
9941
+ var pendingInteractionMap = root.pendingInteractionMap;
9942
+ var pendingInteractions = pendingInteractionMap.get(expirationTime);
9943
+ if (pendingInteractions != null) {
9944
+ interactions.forEach(function (interaction) {
9945
+ if (!pendingInteractions.has(interaction)) {
9946
+ // Update the pending async work count for previously unscheduled interaction.
9947
+ interaction.__count++;
9948
+ }
9316
9949
 
9317
- pendingInteractions.add(interaction);
9318
- });
9319
- } else {
9320
- root.pendingInteractionMap.set(expirationTime, new Set(interactions));
9950
+ pendingInteractions.add(interaction);
9951
+ });
9952
+ } else {
9953
+ pendingInteractionMap.set(expirationTime, new Set(interactions));
9321
9954
 
9322
- // Update the pending async work count for the current interactions.
9323
- if (updateInteractionCounts) {
9955
+ // Update the pending async work count for the current interactions.
9324
9956
  interactions.forEach(function (interaction) {
9325
9957
  interaction.__count++;
9326
9958
  });
9327
9959
  }
9328
- }
9329
9960
 
9330
- var subscriber = __subscriberRef.current;
9331
- if (subscriber !== null) {
9332
- var threadID = computeThreadID(expirationTime, root.interactionThreadID);
9333
- subscriber.onWorkScheduled(interactions, threadID);
9961
+ var subscriber = __subscriberRef.current;
9962
+ if (subscriber !== null) {
9963
+ var threadID = computeThreadID(expirationTime, root.interactionThreadID);
9964
+ subscriber.onWorkScheduled(interactions, threadID);
9965
+ }
9334
9966
  }
9335
9967
  }
9968
+
9969
+ return root;
9336
9970
  }
9337
9971
 
9338
9972
  function scheduleWork(fiber, expirationTime) {
9339
- recordScheduleUpdate();
9340
-
9341
- {
9342
- if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) {
9343
- var instance = fiber.stateNode;
9344
- warnAboutInvalidUpdates(instance);
9345
- }
9346
- }
9347
-
9348
9973
  var root = scheduleWorkToRoot(fiber, expirationTime);
9349
9974
  if (root === null) {
9350
- if (true && (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy)) {
9351
- warnAboutUpdateOnUnmounted(fiber);
9352
- }
9353
9975
  return;
9354
9976
  }
9355
9977
 
9356
- if (enableSchedulerTracing) {
9357
- storeInteractionsForExpirationTime(root, expirationTime, true);
9358
- }
9359
-
9360
9978
  if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime < nextRenderExpirationTime) {
9361
9979
  // This is an interruption. (Used for performance tracking.)
9362
9980
  interruptedBy = fiber;
@@ -9468,7 +10086,7 @@ function onComplete(root, finishedWork, expirationTime) {
9468
10086
 
9469
10087
  function onSuspend(root, finishedWork, suspendedExpirationTime, rootExpirationTime, msUntilTimeout) {
9470
10088
  root.expirationTime = rootExpirationTime;
9471
- if (enableSuspense && msUntilTimeout === 0 && !shouldYield()) {
10089
+ if (msUntilTimeout === 0 && !shouldYield()) {
9472
10090
  // Don't wait an additional tick. Commit the tree immediately.
9473
10091
  root.pendingCommitExpirationTime = suspendedExpirationTime;
9474
10092
  root.finishedWork = finishedWork;
@@ -9483,26 +10101,15 @@ function onYield(root) {
9483
10101
  }
9484
10102
 
9485
10103
  function onTimeout(root, finishedWork, suspendedExpirationTime) {
9486
- if (enableSuspense) {
9487
- // The root timed out. Commit it.
9488
- root.pendingCommitExpirationTime = suspendedExpirationTime;
9489
- root.finishedWork = finishedWork;
9490
- // Read the current time before entering the commit phase. We can be
9491
- // certain this won't cause tearing related to batching of event updates
9492
- // because we're at the top of a timer event.
9493
- recomputeCurrentRendererTime();
9494
- currentSchedulerTime = currentRendererTime;
9495
-
9496
- if (enableSchedulerTracing) {
9497
- // Don't update pending interaction counts for suspense timeouts,
9498
- // Because we know we still need to do more work in this case.
9499
- suspenseDidTimeout = true;
9500
- flushRoot(root, suspendedExpirationTime);
9501
- suspenseDidTimeout = false;
9502
- } else {
9503
- flushRoot(root, suspendedExpirationTime);
9504
- }
9505
- }
10104
+ // The root timed out. Commit it.
10105
+ root.pendingCommitExpirationTime = suspendedExpirationTime;
10106
+ root.finishedWork = finishedWork;
10107
+ // Read the current time before entering the commit phase. We can be
10108
+ // certain this won't cause tearing related to batching of event updates
10109
+ // because we're at the top of a timer event.
10110
+ recomputeCurrentRendererTime();
10111
+ currentSchedulerTime = currentRendererTime;
10112
+ flushRoot(root, suspendedExpirationTime);
9506
10113
  }
9507
10114
 
9508
10115
  function onCommit(root, expirationTime) {
@@ -9801,7 +10408,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) {
9801
10408
  // If this root previously suspended, clear its existing timeout, since
9802
10409
  // we're about to try rendering again.
9803
10410
  var timeoutHandle = root.timeoutHandle;
9804
- if (enableSuspense && timeoutHandle !== noTimeout) {
10411
+ if (timeoutHandle !== noTimeout) {
9805
10412
  root.timeoutHandle = noTimeout;
9806
10413
  // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
9807
10414
  cancelTimeout(timeoutHandle);
@@ -9825,7 +10432,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) {
9825
10432
  // If this root previously suspended, clear its existing timeout, since
9826
10433
  // we're about to try rendering again.
9827
10434
  var _timeoutHandle = root.timeoutHandle;
9828
- if (enableSuspense && _timeoutHandle !== noTimeout) {
10435
+ if (_timeoutHandle !== noTimeout) {
9829
10436
  root.timeoutHandle = noTimeout;
9830
10437
  // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
9831
10438
  cancelTimeout(_timeoutHandle);
@@ -9931,9 +10538,9 @@ function flushSync(fn, a) {
9931
10538
 
9932
10539
 
9933
10540
  var didWarnAboutNestedUpdates = void 0;
9934
-
9935
10541
  {
9936
10542
  didWarnAboutNestedUpdates = false;
10543
+
9937
10544
  }
9938
10545
 
9939
10546
  function getContextForSubtree(parentComponent) {
@@ -9949,11 +10556,6 @@ function getContextForSubtree(parentComponent) {
9949
10556
  if (isContextProvider(Component)) {
9950
10557
  return processChildContext(fiber, Component, parentContext);
9951
10558
  }
9952
- } else if (fiber.tag === ClassComponentLazy) {
9953
- var _Component = getResultFromResolvedThenable(fiber.type);
9954
- if (isContextProvider(_Component)) {
9955
- return processChildContext(fiber, _Component, parentContext);
9956
- }
9957
10559
  }
9958
10560
 
9959
10561
  return parentContext;
@@ -10009,8 +10611,8 @@ function updateContainerAtExpirationTime(element, container, parentComponent, ex
10009
10611
  return scheduleRootUpdate(current$$1, element, expirationTime, callback);
10010
10612
  }
10011
10613
 
10012
- function createContainer(containerInfo, isAsync, hydrate) {
10013
- return createFiberRoot(containerInfo, isAsync, hydrate);
10614
+ function createContainer(containerInfo, isConcurrent, hydrate) {
10615
+ return createFiberRoot(containerInfo, isConcurrent, hydrate);
10014
10616
  }
10015
10617
 
10016
10618
  function updateContainer(element, container, parentComponent, callback) {
@@ -10180,7 +10782,7 @@ function batchedUpdates$1(fn, bookkeeping) {
10180
10782
 
10181
10783
  // TODO: this is special because it gets imported during build.
10182
10784
 
10183
- var ReactVersion = '16.5.2';
10785
+ var ReactVersion = '16.6.0';
10184
10786
 
10185
10787
  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; }; }();
10186
10788
 
@@ -10188,10 +10790,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
10188
10790
 
10189
10791
  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; }
10190
10792
 
10191
- /* eslint-disable no-use-before-define */
10192
-
10193
- /* eslint-enable no-use-before-define */
10194
-
10195
10793
  var defaultTestOptions = {
10196
10794
  createNodeMock: function () {
10197
10795
  return null;
@@ -10199,32 +10797,49 @@ var defaultTestOptions = {
10199
10797
  };
10200
10798
 
10201
10799
  function toJSON(inst) {
10800
+ if (inst.isHidden) {
10801
+ // Omit timed out children from output entirely. This seems like the least
10802
+ // surprising behavior. We could perhaps add a separate API that includes
10803
+ // them, if it turns out people need it.
10804
+ return null;
10805
+ }
10202
10806
  switch (inst.tag) {
10203
10807
  case 'TEXT':
10204
10808
  return inst.text;
10205
10809
  case 'INSTANCE':
10206
- /* eslint-disable no-unused-vars */
10207
- // We don't include the `children` prop in JSON.
10208
- // Instead, we will include the actual rendered children.
10209
- var _inst$props = inst.props,
10210
- _children = _inst$props.children,
10211
- _props = _objectWithoutProperties(_inst$props, ['children']);
10212
- /* eslint-enable */
10213
-
10214
-
10215
- var renderedChildren = null;
10216
- if (inst.children && inst.children.length) {
10217
- renderedChildren = inst.children.map(toJSON);
10810
+ {
10811
+ /* eslint-disable no-unused-vars */
10812
+ // We don't include the `children` prop in JSON.
10813
+ // Instead, we will include the actual rendered children.
10814
+ var _inst$props = inst.props,
10815
+ _children = _inst$props.children,
10816
+ _props = _objectWithoutProperties(_inst$props, ['children']);
10817
+ /* eslint-enable */
10818
+
10819
+
10820
+ var renderedChildren = null;
10821
+ if (inst.children && inst.children.length) {
10822
+ for (var i = 0; i < inst.children.length; i++) {
10823
+ var renderedChild = toJSON(inst.children[i]);
10824
+ if (renderedChild !== null) {
10825
+ if (renderedChildren === null) {
10826
+ renderedChildren = [renderedChild];
10827
+ } else {
10828
+ renderedChildren.push(renderedChild);
10829
+ }
10830
+ }
10831
+ }
10832
+ }
10833
+ var json = {
10834
+ type: inst.type,
10835
+ props: _props,
10836
+ children: renderedChildren
10837
+ };
10838
+ Object.defineProperty(json, '$$typeof', {
10839
+ value: Symbol.for('react.test.json')
10840
+ });
10841
+ return json;
10218
10842
  }
10219
- var json = {
10220
- type: inst.type,
10221
- props: _props,
10222
- children: renderedChildren
10223
- };
10224
- Object.defineProperty(json, '$$typeof', {
10225
- value: Symbol.for('react.test.json')
10226
- });
10227
- return json;
10228
10843
  default:
10229
10844
  throw new Error('Unexpected node type in toJSON: ' + inst.tag);
10230
10845
  }
@@ -10289,19 +10904,8 @@ function toTree(node) {
10289
10904
  instance: node.stateNode,
10290
10905
  rendered: childrenToTree(node.child)
10291
10906
  };
10292
- case ClassComponentLazy:
10293
- {
10294
- var thenable = node.type;
10295
- var _type = thenable._reactResult;
10296
- return {
10297
- nodeType: 'component',
10298
- type: _type,
10299
- props: _assign({}, node.memoizedProps),
10300
- instance: node.stateNode,
10301
- rendered: childrenToTree(node.child)
10302
- };
10303
- }
10304
- case FunctionalComponent:
10907
+ case FunctionComponent:
10908
+ case SimpleMemoComponent:
10305
10909
  return {
10306
10910
  nodeType: 'component',
10307
10911
  type: node.type,
@@ -10309,18 +10913,6 @@ function toTree(node) {
10309
10913
  instance: null,
10310
10914
  rendered: childrenToTree(node.child)
10311
10915
  };
10312
- case FunctionalComponentLazy:
10313
- {
10314
- var _thenable = node.type;
10315
- var _type2 = _thenable._reactResult;
10316
- return {
10317
- nodeType: 'component',
10318
- type: _type2,
10319
- props: _assign({}, node.memoizedProps),
10320
- instance: node.stateNode,
10321
- rendered: childrenToTree(node.child)
10322
- };
10323
- }
10324
10916
  case HostComponent:
10325
10917
  {
10326
10918
  return {
@@ -10339,14 +10931,15 @@ function toTree(node) {
10339
10931
  case Mode:
10340
10932
  case Profiler:
10341
10933
  case ForwardRef:
10342
- case ForwardRefLazy:
10934
+ case MemoComponent:
10935
+ case IncompleteClassComponent:
10343
10936
  return childrenToTree(node.child);
10344
10937
  default:
10345
10938
  invariant(false, 'toTree() does not yet know how to handle nodes with tag=%s', node.tag);
10346
10939
  }
10347
10940
  }
10348
10941
 
10349
- var validWrapperTypes = new Set([FunctionalComponent, FunctionalComponentLazy, ClassComponent, ClassComponentLazy, HostComponent, ForwardRef, ForwardRefLazy,
10942
+ var validWrapperTypes = new Set([FunctionComponent, ClassComponent, HostComponent, ForwardRef, MemoComponent,
10350
10943
  // Normally skipped, but used when there's more than one root child.
10351
10944
  HostRoot]);
10352
10945
 
@@ -10526,13 +11119,13 @@ function propsMatch(props, filter) {
10526
11119
  var ReactTestRendererFiber = {
10527
11120
  create: function (element, options) {
10528
11121
  var createNodeMock = defaultTestOptions.createNodeMock;
10529
- var isAsync = false;
11122
+ var isConcurrent = false;
10530
11123
  if (typeof options === 'object' && options !== null) {
10531
11124
  if (typeof options.createNodeMock === 'function') {
10532
11125
  createNodeMock = options.createNodeMock;
10533
11126
  }
10534
- if (options.unstable_isAsync === true) {
10535
- isAsync = true;
11127
+ if (options.unstable_isConcurrent === true) {
11128
+ isConcurrent = true;
10536
11129
  }
10537
11130
  }
10538
11131
  var container = {
@@ -10540,7 +11133,7 @@ var ReactTestRendererFiber = {
10540
11133
  createNodeMock: createNodeMock,
10541
11134
  tag: 'CONTAINER'
10542
11135
  };
10543
- var root = createContainer(container, isAsync, false);
11136
+ var root = createContainer(container, isConcurrent, false);
10544
11137
  !(root != null) ? invariant(false, 'something went wrong') : void 0;
10545
11138
  updateContainer(element, root, null, null);
10546
11139
 
@@ -10557,7 +11150,21 @@ var ReactTestRendererFiber = {
10557
11150
  if (container.children.length === 1) {
10558
11151
  return toJSON(container.children[0]);
10559
11152
  }
10560
- return container.children.map(toJSON);
11153
+
11154
+ var renderedChildren = null;
11155
+ if (container.children && container.children.length) {
11156
+ for (var i = 0; i < container.children.length; i++) {
11157
+ var renderedChild = toJSON(container.children[i]);
11158
+ if (renderedChild !== null) {
11159
+ if (renderedChildren === null) {
11160
+ renderedChildren = [renderedChild];
11161
+ } else {
11162
+ renderedChildren.push(renderedChild);
11163
+ }
11164
+ }
11165
+ }
11166
+ }
11167
+ return renderedChildren;
10561
11168
  },
10562
11169
  toTree: function () {
10563
11170
  if (root == null || root.current == null) {