react-test-renderer 16.8.0 → 16.8.4

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.8.0
1
+ /** @license React v16.8.4
2
2
  * react-test-renderer.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -143,6 +143,15 @@ function set(key, value) {
143
143
 
144
144
  var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
145
145
 
146
+ // Prevent newer renderers from RTE when used with older react package versions.
147
+ // Current owner and dispatcher used to share the same ref,
148
+ // but PR #14548 split them out to better support the react-debug-tools package.
149
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
150
+ ReactSharedInternals.ReactCurrentDispatcher = {
151
+ current: null
152
+ };
153
+ }
154
+
146
155
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
147
156
  // nor polyfill, then a plain number is used for performance.
148
157
  var hasSymbol = typeof Symbol === 'function' && Symbol.for;
@@ -259,6 +268,7 @@ var MemoComponent = 14;
259
268
  var SimpleMemoComponent = 15;
260
269
  var LazyComponent = 16;
261
270
  var IncompleteClassComponent = 17;
271
+ var DehydratedSuspenseComponent = 18;
262
272
 
263
273
  // Don't change these two values. They're used by React Dev Tools.
264
274
  var NoEffect = /* */0;
@@ -619,21 +629,28 @@ function shim$1() {
619
629
  }
620
630
 
621
631
  // Hydration (when unsupported)
632
+
622
633
  var supportsHydration = false;
623
634
  var canHydrateInstance = shim$1;
624
635
  var canHydrateTextInstance = shim$1;
636
+ var canHydrateSuspenseInstance = shim$1;
625
637
  var getNextHydratableSibling = shim$1;
626
638
  var getFirstHydratableChild = shim$1;
627
639
  var hydrateInstance = shim$1;
628
640
  var hydrateTextInstance = shim$1;
641
+ var getNextHydratableInstanceAfterSuspenseInstance = shim$1;
642
+ var clearSuspenseBoundary = shim$1;
643
+ var clearSuspenseBoundaryFromContainer = shim$1;
629
644
  var didNotMatchHydratedContainerTextInstance = shim$1;
630
645
  var didNotMatchHydratedTextInstance = shim$1;
631
646
  var didNotHydrateContainerInstance = shim$1;
632
647
  var didNotHydrateInstance = shim$1;
633
648
  var didNotFindHydratableContainerInstance = shim$1;
634
649
  var didNotFindHydratableContainerTextInstance = shim$1;
650
+ var didNotFindHydratableContainerSuspenseInstance = shim$1;
635
651
  var didNotFindHydratableInstance = shim$1;
636
652
  var didNotFindHydratableTextInstance = shim$1;
653
+ var didNotFindHydratableSuspenseInstance = shim$1;
637
654
 
638
655
  var NO_CONTEXT = {};
639
656
  var UPDATE_SIGNAL = {};
@@ -1019,7 +1036,7 @@ var warnAboutDeprecatedLifecycles = false;
1019
1036
  var replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
1020
1037
  var enableProfilerTimer = false;
1021
1038
  var enableSchedulerTracing = false;
1022
-
1039
+ var enableSuspenseServerRenderer = false;
1023
1040
 
1024
1041
 
1025
1042
 
@@ -1282,7 +1299,7 @@ function stopFailedWorkTimer(fiber) {
1282
1299
  return;
1283
1300
  }
1284
1301
  fiber._debugIsCurrentlyTiming = false;
1285
- var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1302
+ var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1286
1303
  endFiberMark(fiber, null, warning);
1287
1304
  }
1288
1305
  }
@@ -1951,6 +1968,7 @@ function FiberNode(tag, pendingProps, key, mode) {
1951
1968
  this._debugSource = null;
1952
1969
  this._debugOwner = null;
1953
1970
  this._debugIsCurrentlyTiming = false;
1971
+ this._debugHookTypes = null;
1954
1972
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
1955
1973
  Object.preventExtensions(this);
1956
1974
  }
@@ -2018,6 +2036,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
2018
2036
  workInProgress._debugID = current._debugID;
2019
2037
  workInProgress._debugSource = current._debugSource;
2020
2038
  workInProgress._debugOwner = current._debugOwner;
2039
+ workInProgress._debugHookTypes = current._debugHookTypes;
2021
2040
  }
2022
2041
 
2023
2042
  workInProgress.alternate = current;
@@ -2285,6 +2304,7 @@ function assignFiberPropertiesInDEV(target, source) {
2285
2304
  target._debugSource = source._debugSource;
2286
2305
  target._debugOwner = source._debugOwner;
2287
2306
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
2307
+ target._debugHookTypes = source._debugHookTypes;
2288
2308
  return target;
2289
2309
  }
2290
2310
 
@@ -2392,6 +2412,25 @@ function createFiberRoot(containerInfo, isConcurrent, hydrate) {
2392
2412
  return root;
2393
2413
  }
2394
2414
 
2415
+ var ReactInternals$2 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2416
+
2417
+ var _ReactInternals$Sched$1 = ReactInternals$2.Scheduler;
2418
+ var unstable_cancelCallback = _ReactInternals$Sched$1.unstable_cancelCallback;
2419
+ var unstable_now = _ReactInternals$Sched$1.unstable_now;
2420
+ var unstable_scheduleCallback = _ReactInternals$Sched$1.unstable_scheduleCallback;
2421
+ var unstable_shouldYield = _ReactInternals$Sched$1.unstable_shouldYield;
2422
+ var unstable_getFirstCallbackNode = _ReactInternals$Sched$1.unstable_getFirstCallbackNode;
2423
+ var unstable_runWithPriority = _ReactInternals$Sched$1.unstable_runWithPriority;
2424
+ var unstable_next = _ReactInternals$Sched$1.unstable_next;
2425
+ var unstable_continueExecution = _ReactInternals$Sched$1.unstable_continueExecution;
2426
+ var unstable_pauseExecution = _ReactInternals$Sched$1.unstable_pauseExecution;
2427
+ var unstable_getCurrentPriorityLevel = _ReactInternals$Sched$1.unstable_getCurrentPriorityLevel;
2428
+ var unstable_ImmediatePriority = _ReactInternals$Sched$1.unstable_ImmediatePriority;
2429
+ var unstable_UserBlockingPriority = _ReactInternals$Sched$1.unstable_UserBlockingPriority;
2430
+ var unstable_NormalPriority = _ReactInternals$Sched$1.unstable_NormalPriority;
2431
+ var unstable_LowPriority = _ReactInternals$Sched$1.unstable_LowPriority;
2432
+ var unstable_IdlePriority = _ReactInternals$Sched$1.unstable_IdlePriority;
2433
+
2395
2434
  var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
2396
2435
  var funcArgs = Array.prototype.slice.call(arguments, 3);
2397
2436
  try {
@@ -2409,7 +2448,7 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
2409
2448
  // invokeGuardedCallback uses a try-catch, all user exceptions are treated
2410
2449
  // like caught exceptions, and the DevTools won't pause unless the developer
2411
2450
  // takes the extra step of enabling pause on caught exceptions. This is
2412
- // untintuitive, though, because even though React has caught the error, from
2451
+ // unintuitive, though, because even though React has caught the error, from
2413
2452
  // the developer's perspective, the error is uncaught.
2414
2453
  //
2415
2454
  // To preserve the expected "Pause on exceptions" behavior, we don't use a
@@ -4361,7 +4400,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4361
4400
  }
4362
4401
 
4363
4402
  function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
4364
- // This algorithm can't optimize by searching from boths ends since we
4403
+ // This algorithm can't optimize by searching from both ends since we
4365
4404
  // don't have backpointers on fibers. I'm trying to see how far we can get
4366
4405
  // with that model. If it ends up not being worth the tradeoffs, we can
4367
4406
  // add it later.
@@ -4942,7 +4981,6 @@ var currentlyRenderingFiber$1 = null;
4942
4981
  // current hook list is the list that belongs to the current fiber. The
4943
4982
  // work-in-progress hook list is a new list that will be added to the
4944
4983
  // work-in-progress fiber.
4945
- var firstCurrentHook = null;
4946
4984
  var currentHook = null;
4947
4985
  var nextCurrentHook = null;
4948
4986
  var firstWorkInProgressHook = null;
@@ -4972,39 +5010,67 @@ var RE_RENDER_LIMIT = 25;
4972
5010
  // In DEV, this is the name of the currently executing primitive hook
4973
5011
  var currentHookNameInDev = null;
4974
5012
 
4975
- function warnOnHookMismatchInDev() {
5013
+ // In DEV, this list ensures that hooks are called in the same order between renders.
5014
+ // The list stores the order of hooks used during the initial render (mount).
5015
+ // Subsequent renders (updates) reference this list.
5016
+ var hookTypesDev = null;
5017
+ var hookTypesUpdateIndexDev = -1;
5018
+
5019
+ function mountHookTypesDev() {
5020
+ {
5021
+ var hookName = currentHookNameInDev;
5022
+
5023
+ if (hookTypesDev === null) {
5024
+ hookTypesDev = [hookName];
5025
+ } else {
5026
+ hookTypesDev.push(hookName);
5027
+ }
5028
+ }
5029
+ }
5030
+
5031
+ function updateHookTypesDev() {
5032
+ {
5033
+ var hookName = currentHookNameInDev;
5034
+
5035
+ if (hookTypesDev !== null) {
5036
+ hookTypesUpdateIndexDev++;
5037
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
5038
+ warnOnHookMismatchInDev(hookName);
5039
+ }
5040
+ }
5041
+ }
5042
+ }
5043
+
5044
+ function warnOnHookMismatchInDev(currentHookName) {
4976
5045
  {
4977
5046
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
4978
5047
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
4979
5048
  didWarnAboutMismatchedHooksForComponent.add(componentName);
4980
5049
 
4981
- var secondColumnStart = 22;
5050
+ if (hookTypesDev !== null) {
5051
+ var table = '';
4982
5052
 
4983
- var table = '';
4984
- var prevHook = firstCurrentHook;
4985
- var nextHook = firstWorkInProgressHook;
4986
- var n = 1;
4987
- while (prevHook !== null && nextHook !== null) {
4988
- var oldHookName = prevHook._debugType;
4989
- var newHookName = nextHook._debugType;
5053
+ var secondColumnStart = 30;
4990
5054
 
4991
- var row = n + '. ' + oldHookName;
5055
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
5056
+ var oldHookName = hookTypesDev[i];
5057
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
4992
5058
 
4993
- // Extra space so second column lines up
4994
- // lol @ IE not supporting String#repeat
4995
- while (row.length < secondColumnStart) {
4996
- row += ' ';
4997
- }
5059
+ var row = i + 1 + '. ' + oldHookName;
4998
5060
 
4999
- row += newHookName + '\n';
5061
+ // Extra space so second column lines up
5062
+ // lol @ IE not supporting String#repeat
5063
+ while (row.length < secondColumnStart) {
5064
+ row += ' ';
5065
+ }
5000
5066
 
5001
- table += row;
5002
- prevHook = prevHook.next;
5003
- nextHook = nextHook.next;
5004
- n++;
5005
- }
5067
+ row += newHookName + '\n';
5068
+
5069
+ table += row;
5070
+ }
5006
5071
 
5007
- warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' -------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
5072
+ warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
5073
+ }
5008
5074
  }
5009
5075
  }
5010
5076
  }
@@ -5040,7 +5106,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
5040
5106
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
5041
5107
  renderExpirationTime = nextRenderExpirationTime;
5042
5108
  currentlyRenderingFiber$1 = workInProgress;
5043
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
5109
+ nextCurrentHook = current !== null ? current.memoizedState : null;
5110
+
5111
+ {
5112
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
5113
+ hookTypesUpdateIndexDev = -1;
5114
+ }
5044
5115
 
5045
5116
  // The following should have already been reset
5046
5117
  // currentHook = null;
@@ -5054,8 +5125,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
5054
5125
  // numberOfReRenders = 0;
5055
5126
  // sideEffectTag = 0;
5056
5127
 
5128
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
5129
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
5130
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
5131
+
5132
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
5133
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
5134
+ // so nextCurrentHook would be null during updates and mounts.
5057
5135
  {
5058
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
5136
+ if (nextCurrentHook !== null) {
5137
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
5138
+ } else if (hookTypesDev !== null) {
5139
+ // This dispatcher handles an edge case where a component is updating,
5140
+ // but no stateful hooks have been used.
5141
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
5142
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
5143
+ // This dispatcher does that.
5144
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
5145
+ } else {
5146
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
5147
+ }
5059
5148
  }
5060
5149
 
5061
5150
  var children = Component(props, refOrContext);
@@ -5066,13 +5155,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
5066
5155
  numberOfReRenders += 1;
5067
5156
 
5068
5157
  // Start over from the beginning of the list
5069
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
5158
+ nextCurrentHook = current !== null ? current.memoizedState : null;
5070
5159
  nextWorkInProgressHook = firstWorkInProgressHook;
5071
5160
 
5072
5161
  currentHook = null;
5073
5162
  workInProgressHook = null;
5074
5163
  componentUpdateQueue = null;
5075
5164
 
5165
+ {
5166
+ // Also validate hook order for cascading updates.
5167
+ hookTypesUpdateIndexDev = -1;
5168
+ }
5169
+
5076
5170
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
5077
5171
 
5078
5172
  children = Component(props, refOrContext);
@@ -5082,10 +5176,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
5082
5176
  numberOfReRenders = 0;
5083
5177
  }
5084
5178
 
5085
- {
5086
- currentHookNameInDev = null;
5087
- }
5088
-
5089
5179
  // We can assume the previous dispatcher is always this one, since we set it
5090
5180
  // at the beginning of the render phase and there's no re-entrancy.
5091
5181
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -5097,18 +5187,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
5097
5187
  renderedWork.updateQueue = componentUpdateQueue;
5098
5188
  renderedWork.effectTag |= sideEffectTag;
5099
5189
 
5190
+ {
5191
+ renderedWork._debugHookTypes = hookTypesDev;
5192
+ }
5193
+
5194
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
5195
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
5100
5196
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
5101
5197
 
5102
5198
  renderExpirationTime = NoWork;
5103
5199
  currentlyRenderingFiber$1 = null;
5104
5200
 
5105
- firstCurrentHook = null;
5106
5201
  currentHook = null;
5107
5202
  nextCurrentHook = null;
5108
5203
  firstWorkInProgressHook = null;
5109
5204
  workInProgressHook = null;
5110
5205
  nextWorkInProgressHook = null;
5111
5206
 
5207
+ {
5208
+ currentHookNameInDev = null;
5209
+ hookTypesDev = null;
5210
+ hookTypesUpdateIndexDev = -1;
5211
+ }
5212
+
5112
5213
  remainingExpirationTime = NoWork;
5113
5214
  componentUpdateQueue = null;
5114
5215
  sideEffectTag = 0;
@@ -5142,21 +5243,23 @@ function resetHooks() {
5142
5243
  renderExpirationTime = NoWork;
5143
5244
  currentlyRenderingFiber$1 = null;
5144
5245
 
5145
- firstCurrentHook = null;
5146
5246
  currentHook = null;
5147
5247
  nextCurrentHook = null;
5148
5248
  firstWorkInProgressHook = null;
5149
5249
  workInProgressHook = null;
5150
5250
  nextWorkInProgressHook = null;
5151
5251
 
5152
- remainingExpirationTime = NoWork;
5153
- componentUpdateQueue = null;
5154
- sideEffectTag = 0;
5155
-
5156
5252
  {
5253
+ hookTypesDev = null;
5254
+ hookTypesUpdateIndexDev = -1;
5255
+
5157
5256
  currentHookNameInDev = null;
5158
5257
  }
5159
5258
 
5259
+ remainingExpirationTime = NoWork;
5260
+ componentUpdateQueue = null;
5261
+ sideEffectTag = 0;
5262
+
5160
5263
  didScheduleRenderPhaseUpdate = false;
5161
5264
  renderPhaseUpdates = null;
5162
5265
  numberOfReRenders = 0;
@@ -5173,12 +5276,6 @@ function mountWorkInProgressHook() {
5173
5276
  next: null
5174
5277
  };
5175
5278
 
5176
- {
5177
- hook._debugType = currentHookNameInDev;
5178
- if (currentlyRenderingFiber$1 !== null && currentlyRenderingFiber$1.alternate !== null) {
5179
- warning$1(false, '%s: Rendered more hooks than during the previous render. This is ' + 'not currently supported and may lead to unexpected behavior.', getComponentName(currentlyRenderingFiber$1.type));
5180
- }
5181
- }
5182
5279
  if (workInProgressHook === null) {
5183
5280
  // This is the first hook in the list
5184
5281
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -5225,13 +5322,6 @@ function updateWorkInProgressHook() {
5225
5322
  workInProgressHook = workInProgressHook.next = newHook;
5226
5323
  }
5227
5324
  nextCurrentHook = currentHook.next;
5228
-
5229
- {
5230
- newHook._debugType = currentHookNameInDev;
5231
- if (currentHookNameInDev !== currentHook._debugType) {
5232
- warnOnHookMismatchInDev();
5233
- }
5234
- }
5235
5325
  }
5236
5326
  return workInProgressHook;
5237
5327
  }
@@ -5246,20 +5336,6 @@ function basicStateReducer(state, action) {
5246
5336
  return typeof action === 'function' ? action(state) : action;
5247
5337
  }
5248
5338
 
5249
- function mountContext(context, observedBits) {
5250
- {
5251
- mountWorkInProgressHook();
5252
- }
5253
- return readContext(context, observedBits);
5254
- }
5255
-
5256
- function updateContext(context, observedBits) {
5257
- {
5258
- updateWorkInProgressHook();
5259
- }
5260
- return readContext(context, observedBits);
5261
- }
5262
-
5263
5339
  function mountReducer(reducer, initialArg, init) {
5264
5340
  var hook = mountWorkInProgressHook();
5265
5341
  var initialState = void 0;
@@ -5312,7 +5388,6 @@ function updateReducer(reducer, initialArg, init) {
5312
5388
  }
5313
5389
 
5314
5390
  hook.memoizedState = newState;
5315
-
5316
5391
  // Don't persist the state accumlated from the render phase updates to
5317
5392
  // the base state unless the queue is empty.
5318
5393
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -5321,6 +5396,9 @@ function updateReducer(reducer, initialArg, init) {
5321
5396
  hook.baseState = newState;
5322
5397
  }
5323
5398
 
5399
+ queue.eagerReducer = reducer;
5400
+ queue.eagerState = newState;
5401
+
5324
5402
  return [newState, _dispatch];
5325
5403
  }
5326
5404
  }
@@ -5540,7 +5618,7 @@ function mountImperativeHandle(ref, create, deps) {
5540
5618
  }
5541
5619
 
5542
5620
  // TODO: If deps are provided, should we skip comparing the ref itself?
5543
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
5621
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
5544
5622
 
5545
5623
  return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
5546
5624
  }
@@ -5551,7 +5629,7 @@ function updateImperativeHandle(ref, create, deps) {
5551
5629
  }
5552
5630
 
5553
5631
  // TODO: If deps are provided, should we skip comparing the ref itself?
5554
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
5632
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
5555
5633
 
5556
5634
  return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
5557
5635
  }
@@ -5618,7 +5696,7 @@ function updateMemo(nextCreate, deps) {
5618
5696
  var shouldWarnForUnbatchedSetState = false;
5619
5697
 
5620
5698
  {
5621
- // jest isnt' a 'global', it's just exposed to tests via a wrapped function
5699
+ // jest isn't a 'global', it's just exposed to tests via a wrapped function
5622
5700
  // further, this isn't a test file, so flow doesn't recognize the symbol. So...
5623
5701
  // $FlowExpectedError - because requirements don't give a damn about your type sigs.
5624
5702
  if ('undefined' !== typeof jest) {
@@ -5750,6 +5828,7 @@ var ContextOnlyDispatcher = {
5750
5828
  };
5751
5829
 
5752
5830
  var HooksDispatcherOnMountInDEV = null;
5831
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
5753
5832
  var HooksDispatcherOnUpdateInDEV = null;
5754
5833
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
5755
5834
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -5769,26 +5848,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5769
5848
  },
5770
5849
  useCallback: function (callback, deps) {
5771
5850
  currentHookNameInDev = 'useCallback';
5851
+ mountHookTypesDev();
5852
+ return mountCallback(callback, deps);
5853
+ },
5854
+ useContext: function (context, observedBits) {
5855
+ currentHookNameInDev = 'useContext';
5856
+ mountHookTypesDev();
5857
+ return readContext(context, observedBits);
5858
+ },
5859
+ useEffect: function (create, deps) {
5860
+ currentHookNameInDev = 'useEffect';
5861
+ mountHookTypesDev();
5862
+ return mountEffect(create, deps);
5863
+ },
5864
+ useImperativeHandle: function (ref, create, deps) {
5865
+ currentHookNameInDev = 'useImperativeHandle';
5866
+ mountHookTypesDev();
5867
+ return mountImperativeHandle(ref, create, deps);
5868
+ },
5869
+ useLayoutEffect: function (create, deps) {
5870
+ currentHookNameInDev = 'useLayoutEffect';
5871
+ mountHookTypesDev();
5872
+ return mountLayoutEffect(create, deps);
5873
+ },
5874
+ useMemo: function (create, deps) {
5875
+ currentHookNameInDev = 'useMemo';
5876
+ mountHookTypesDev();
5877
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5878
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5879
+ try {
5880
+ return mountMemo(create, deps);
5881
+ } finally {
5882
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5883
+ }
5884
+ },
5885
+ useReducer: function (reducer, initialArg, init) {
5886
+ currentHookNameInDev = 'useReducer';
5887
+ mountHookTypesDev();
5888
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5889
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5890
+ try {
5891
+ return mountReducer(reducer, initialArg, init);
5892
+ } finally {
5893
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5894
+ }
5895
+ },
5896
+ useRef: function (initialValue) {
5897
+ currentHookNameInDev = 'useRef';
5898
+ mountHookTypesDev();
5899
+ return mountRef(initialValue);
5900
+ },
5901
+ useState: function (initialState) {
5902
+ currentHookNameInDev = 'useState';
5903
+ mountHookTypesDev();
5904
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5905
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5906
+ try {
5907
+ return mountState(initialState);
5908
+ } finally {
5909
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5910
+ }
5911
+ },
5912
+ useDebugValue: function (value, formatterFn) {
5913
+ currentHookNameInDev = 'useDebugValue';
5914
+ mountHookTypesDev();
5915
+ return mountDebugValue(value, formatterFn);
5916
+ }
5917
+ };
5918
+
5919
+ HooksDispatcherOnMountWithHookTypesInDEV = {
5920
+ readContext: function (context, observedBits) {
5921
+ return readContext(context, observedBits);
5922
+ },
5923
+ useCallback: function (callback, deps) {
5924
+ currentHookNameInDev = 'useCallback';
5925
+ updateHookTypesDev();
5772
5926
  return mountCallback(callback, deps);
5773
5927
  },
5774
5928
  useContext: function (context, observedBits) {
5775
5929
  currentHookNameInDev = 'useContext';
5776
- return mountContext(context, observedBits);
5930
+ updateHookTypesDev();
5931
+ return readContext(context, observedBits);
5777
5932
  },
5778
5933
  useEffect: function (create, deps) {
5779
5934
  currentHookNameInDev = 'useEffect';
5935
+ updateHookTypesDev();
5780
5936
  return mountEffect(create, deps);
5781
5937
  },
5782
5938
  useImperativeHandle: function (ref, create, deps) {
5783
5939
  currentHookNameInDev = 'useImperativeHandle';
5940
+ updateHookTypesDev();
5784
5941
  return mountImperativeHandle(ref, create, deps);
5785
5942
  },
5786
5943
  useLayoutEffect: function (create, deps) {
5787
5944
  currentHookNameInDev = 'useLayoutEffect';
5945
+ updateHookTypesDev();
5788
5946
  return mountLayoutEffect(create, deps);
5789
5947
  },
5790
5948
  useMemo: function (create, deps) {
5791
5949
  currentHookNameInDev = 'useMemo';
5950
+ updateHookTypesDev();
5792
5951
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5793
5952
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5794
5953
  try {
@@ -5799,6 +5958,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5799
5958
  },
5800
5959
  useReducer: function (reducer, initialArg, init) {
5801
5960
  currentHookNameInDev = 'useReducer';
5961
+ updateHookTypesDev();
5802
5962
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5803
5963
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5804
5964
  try {
@@ -5809,10 +5969,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5809
5969
  },
5810
5970
  useRef: function (initialValue) {
5811
5971
  currentHookNameInDev = 'useRef';
5972
+ updateHookTypesDev();
5812
5973
  return mountRef(initialValue);
5813
5974
  },
5814
5975
  useState: function (initialState) {
5815
5976
  currentHookNameInDev = 'useState';
5977
+ updateHookTypesDev();
5816
5978
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5817
5979
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5818
5980
  try {
@@ -5823,6 +5985,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5823
5985
  },
5824
5986
  useDebugValue: function (value, formatterFn) {
5825
5987
  currentHookNameInDev = 'useDebugValue';
5988
+ updateHookTypesDev();
5826
5989
  return mountDebugValue(value, formatterFn);
5827
5990
  }
5828
5991
  };
@@ -5833,26 +5996,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5833
5996
  },
5834
5997
  useCallback: function (callback, deps) {
5835
5998
  currentHookNameInDev = 'useCallback';
5999
+ updateHookTypesDev();
5836
6000
  return updateCallback(callback, deps);
5837
6001
  },
5838
6002
  useContext: function (context, observedBits) {
5839
6003
  currentHookNameInDev = 'useContext';
5840
- return updateContext(context, observedBits);
6004
+ updateHookTypesDev();
6005
+ return readContext(context, observedBits);
5841
6006
  },
5842
6007
  useEffect: function (create, deps) {
5843
6008
  currentHookNameInDev = 'useEffect';
6009
+ updateHookTypesDev();
5844
6010
  return updateEffect(create, deps);
5845
6011
  },
5846
6012
  useImperativeHandle: function (ref, create, deps) {
5847
6013
  currentHookNameInDev = 'useImperativeHandle';
6014
+ updateHookTypesDev();
5848
6015
  return updateImperativeHandle(ref, create, deps);
5849
6016
  },
5850
6017
  useLayoutEffect: function (create, deps) {
5851
6018
  currentHookNameInDev = 'useLayoutEffect';
6019
+ updateHookTypesDev();
5852
6020
  return updateLayoutEffect(create, deps);
5853
6021
  },
5854
6022
  useMemo: function (create, deps) {
5855
6023
  currentHookNameInDev = 'useMemo';
6024
+ updateHookTypesDev();
5856
6025
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5857
6026
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5858
6027
  try {
@@ -5863,6 +6032,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5863
6032
  },
5864
6033
  useReducer: function (reducer, initialArg, init) {
5865
6034
  currentHookNameInDev = 'useReducer';
6035
+ updateHookTypesDev();
5866
6036
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5867
6037
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5868
6038
  try {
@@ -5873,10 +6043,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5873
6043
  },
5874
6044
  useRef: function (initialValue) {
5875
6045
  currentHookNameInDev = 'useRef';
6046
+ updateHookTypesDev();
5876
6047
  return updateRef(initialValue);
5877
6048
  },
5878
6049
  useState: function (initialState) {
5879
6050
  currentHookNameInDev = 'useState';
6051
+ updateHookTypesDev();
5880
6052
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5881
6053
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5882
6054
  try {
@@ -5887,6 +6059,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5887
6059
  },
5888
6060
  useDebugValue: function (value, formatterFn) {
5889
6061
  currentHookNameInDev = 'useDebugValue';
6062
+ updateHookTypesDev();
5890
6063
  return updateDebugValue(value, formatterFn);
5891
6064
  }
5892
6065
  };
@@ -5899,31 +6072,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5899
6072
  useCallback: function (callback, deps) {
5900
6073
  currentHookNameInDev = 'useCallback';
5901
6074
  warnInvalidHookAccess();
6075
+ mountHookTypesDev();
5902
6076
  return mountCallback(callback, deps);
5903
6077
  },
5904
6078
  useContext: function (context, observedBits) {
5905
6079
  currentHookNameInDev = 'useContext';
5906
6080
  warnInvalidHookAccess();
5907
- return mountContext(context, observedBits);
6081
+ mountHookTypesDev();
6082
+ return readContext(context, observedBits);
5908
6083
  },
5909
6084
  useEffect: function (create, deps) {
5910
6085
  currentHookNameInDev = 'useEffect';
5911
6086
  warnInvalidHookAccess();
6087
+ mountHookTypesDev();
5912
6088
  return mountEffect(create, deps);
5913
6089
  },
5914
6090
  useImperativeHandle: function (ref, create, deps) {
5915
6091
  currentHookNameInDev = 'useImperativeHandle';
5916
6092
  warnInvalidHookAccess();
6093
+ mountHookTypesDev();
5917
6094
  return mountImperativeHandle(ref, create, deps);
5918
6095
  },
5919
6096
  useLayoutEffect: function (create, deps) {
5920
6097
  currentHookNameInDev = 'useLayoutEffect';
5921
6098
  warnInvalidHookAccess();
6099
+ mountHookTypesDev();
5922
6100
  return mountLayoutEffect(create, deps);
5923
6101
  },
5924
6102
  useMemo: function (create, deps) {
5925
6103
  currentHookNameInDev = 'useMemo';
5926
6104
  warnInvalidHookAccess();
6105
+ mountHookTypesDev();
5927
6106
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5928
6107
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5929
6108
  try {
@@ -5935,6 +6114,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5935
6114
  useReducer: function (reducer, initialArg, init) {
5936
6115
  currentHookNameInDev = 'useReducer';
5937
6116
  warnInvalidHookAccess();
6117
+ mountHookTypesDev();
5938
6118
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5939
6119
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5940
6120
  try {
@@ -5946,11 +6126,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5946
6126
  useRef: function (initialValue) {
5947
6127
  currentHookNameInDev = 'useRef';
5948
6128
  warnInvalidHookAccess();
6129
+ mountHookTypesDev();
5949
6130
  return mountRef(initialValue);
5950
6131
  },
5951
6132
  useState: function (initialState) {
5952
6133
  currentHookNameInDev = 'useState';
5953
6134
  warnInvalidHookAccess();
6135
+ mountHookTypesDev();
5954
6136
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5955
6137
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5956
6138
  try {
@@ -5962,6 +6144,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5962
6144
  useDebugValue: function (value, formatterFn) {
5963
6145
  currentHookNameInDev = 'useDebugValue';
5964
6146
  warnInvalidHookAccess();
6147
+ mountHookTypesDev();
5965
6148
  return mountDebugValue(value, formatterFn);
5966
6149
  }
5967
6150
  };
@@ -5974,31 +6157,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5974
6157
  useCallback: function (callback, deps) {
5975
6158
  currentHookNameInDev = 'useCallback';
5976
6159
  warnInvalidHookAccess();
6160
+ updateHookTypesDev();
5977
6161
  return updateCallback(callback, deps);
5978
6162
  },
5979
6163
  useContext: function (context, observedBits) {
5980
6164
  currentHookNameInDev = 'useContext';
5981
6165
  warnInvalidHookAccess();
5982
- return updateContext(context, observedBits);
6166
+ updateHookTypesDev();
6167
+ return readContext(context, observedBits);
5983
6168
  },
5984
6169
  useEffect: function (create, deps) {
5985
6170
  currentHookNameInDev = 'useEffect';
5986
6171
  warnInvalidHookAccess();
6172
+ updateHookTypesDev();
5987
6173
  return updateEffect(create, deps);
5988
6174
  },
5989
6175
  useImperativeHandle: function (ref, create, deps) {
5990
6176
  currentHookNameInDev = 'useImperativeHandle';
5991
6177
  warnInvalidHookAccess();
6178
+ updateHookTypesDev();
5992
6179
  return updateImperativeHandle(ref, create, deps);
5993
6180
  },
5994
6181
  useLayoutEffect: function (create, deps) {
5995
6182
  currentHookNameInDev = 'useLayoutEffect';
5996
6183
  warnInvalidHookAccess();
6184
+ updateHookTypesDev();
5997
6185
  return updateLayoutEffect(create, deps);
5998
6186
  },
5999
6187
  useMemo: function (create, deps) {
6000
6188
  currentHookNameInDev = 'useMemo';
6001
6189
  warnInvalidHookAccess();
6190
+ updateHookTypesDev();
6002
6191
  var prevDispatcher = ReactCurrentDispatcher$1.current;
6003
6192
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6004
6193
  try {
@@ -6010,6 +6199,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
6010
6199
  useReducer: function (reducer, initialArg, init) {
6011
6200
  currentHookNameInDev = 'useReducer';
6012
6201
  warnInvalidHookAccess();
6202
+ updateHookTypesDev();
6013
6203
  var prevDispatcher = ReactCurrentDispatcher$1.current;
6014
6204
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6015
6205
  try {
@@ -6021,11 +6211,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
6021
6211
  useRef: function (initialValue) {
6022
6212
  currentHookNameInDev = 'useRef';
6023
6213
  warnInvalidHookAccess();
6214
+ updateHookTypesDev();
6024
6215
  return updateRef(initialValue);
6025
6216
  },
6026
6217
  useState: function (initialState) {
6027
6218
  currentHookNameInDev = 'useState';
6028
6219
  warnInvalidHookAccess();
6220
+ updateHookTypesDev();
6029
6221
  var prevDispatcher = ReactCurrentDispatcher$1.current;
6030
6222
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6031
6223
  try {
@@ -6037,6 +6229,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
6037
6229
  useDebugValue: function (value, formatterFn) {
6038
6230
  currentHookNameInDev = 'useDebugValue';
6039
6231
  warnInvalidHookAccess();
6232
+ updateHookTypesDev();
6040
6233
  return updateDebugValue(value, formatterFn);
6041
6234
  }
6042
6235
  };
@@ -6108,6 +6301,18 @@ function enterHydrationState(fiber) {
6108
6301
  return true;
6109
6302
  }
6110
6303
 
6304
+ function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
6305
+ if (!supportsHydration) {
6306
+ return false;
6307
+ }
6308
+
6309
+ var suspenseInstance = fiber.stateNode;
6310
+ nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
6311
+ popToNextHostParent(fiber);
6312
+ isHydrating = true;
6313
+ return true;
6314
+ }
6315
+
6111
6316
  function deleteHydratableInstance(returnFiber, instance) {
6112
6317
  {
6113
6318
  switch (returnFiber.tag) {
@@ -6155,6 +6360,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
6155
6360
  var text = fiber.pendingProps;
6156
6361
  didNotFindHydratableContainerTextInstance(parentContainer, text);
6157
6362
  break;
6363
+ case SuspenseComponent:
6364
+ didNotFindHydratableContainerSuspenseInstance(parentContainer);
6365
+ break;
6158
6366
  }
6159
6367
  break;
6160
6368
  }
@@ -6173,6 +6381,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
6173
6381
  var _text = fiber.pendingProps;
6174
6382
  didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
6175
6383
  break;
6384
+ case SuspenseComponent:
6385
+ didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
6386
+ break;
6176
6387
  }
6177
6388
  break;
6178
6389
  }
@@ -6205,6 +6416,19 @@ function tryHydrate(fiber, nextInstance) {
6205
6416
  }
6206
6417
  return false;
6207
6418
  }
6419
+ case SuspenseComponent:
6420
+ {
6421
+ if (enableSuspenseServerRenderer) {
6422
+ var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
6423
+ if (suspenseInstance !== null) {
6424
+ // Downgrade the tag to a dehydrated component until we've hydrated it.
6425
+ fiber.tag = DehydratedSuspenseComponent;
6426
+ fiber.stateNode = suspenseInstance;
6427
+ return true;
6428
+ }
6429
+ }
6430
+ return false;
6431
+ }
6208
6432
  default:
6209
6433
  return false;
6210
6434
  }
@@ -6298,9 +6522,18 @@ function prepareToHydrateHostTextInstance(fiber) {
6298
6522
  return shouldUpdate;
6299
6523
  }
6300
6524
 
6525
+ function skipPastDehydratedSuspenseInstance(fiber) {
6526
+ if (!supportsHydration) {
6527
+ invariant(false, 'Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
6528
+ }
6529
+ var suspenseInstance = fiber.stateNode;
6530
+ !suspenseInstance ? invariant(false, 'Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.') : void 0;
6531
+ nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
6532
+ }
6533
+
6301
6534
  function popToNextHostParent(fiber) {
6302
6535
  var parent = fiber.return;
6303
- while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
6536
+ while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
6304
6537
  parent = parent.return;
6305
6538
  }
6306
6539
  hydrationParentFiber = parent;
@@ -6408,6 +6641,10 @@ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildre
6408
6641
  }
6409
6642
 
6410
6643
  function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
6644
+ // TODO: current can be non-null here even if the component
6645
+ // hasn't yet mounted. This happens after the first render suspends.
6646
+ // We'll need to figure out if this is fine or can cause issues.
6647
+
6411
6648
  {
6412
6649
  if (workInProgress.type !== workInProgress.elementType) {
6413
6650
  // Lazy component props can't be validated in createElement
@@ -6513,6 +6750,10 @@ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, u
6513
6750
  }
6514
6751
 
6515
6752
  function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
6753
+ // TODO: current can be non-null here even if the component
6754
+ // hasn't yet mounted. This happens when the inner render suspends.
6755
+ // We'll need to figure out if this is fine or can cause issues.
6756
+
6516
6757
  {
6517
6758
  if (workInProgress.type !== workInProgress.elementType) {
6518
6759
  // Lazy component props can't be validated in createElement
@@ -7136,6 +7377,18 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
7136
7377
  // children -- we skip over the primary children entirely.
7137
7378
  var next = void 0;
7138
7379
  if (current$$1 === null) {
7380
+ if (enableSuspenseServerRenderer) {
7381
+ // If we're currently hydrating, try to hydrate this boundary.
7382
+ // But only if this has a fallback.
7383
+ if (nextProps.fallback !== undefined) {
7384
+ tryToClaimNextHydratableInstance(workInProgress);
7385
+ // This could've changed the tag if this was a dehydrated suspense component.
7386
+ if (workInProgress.tag === DehydratedSuspenseComponent) {
7387
+ return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
7388
+ }
7389
+ }
7390
+ }
7391
+
7139
7392
  // This is the initial mount. This branch is pretty simple because there's
7140
7393
  // no previous state that needs to be preserved.
7141
7394
  if (nextDidTimeout) {
@@ -7287,6 +7540,65 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
7287
7540
  return next;
7288
7541
  }
7289
7542
 
7543
+ function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
7544
+ if (current$$1 === null) {
7545
+ // During the first pass, we'll bail out and not drill into the children.
7546
+ // Instead, we'll leave the content in place and try to hydrate it later.
7547
+ workInProgress.expirationTime = Never;
7548
+ return null;
7549
+ }
7550
+ // We use childExpirationTime to indicate that a child might depend on context, so if
7551
+ // any context has changed, we need to treat is as if the input might have changed.
7552
+ var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
7553
+ if (didReceiveUpdate || hasContextChanged$$1) {
7554
+ // This boundary has changed since the first render. This means that we are now unable to
7555
+ // hydrate it. We might still be able to hydrate it using an earlier expiration time but
7556
+ // during this render we can't. Instead, we're going to delete the whole subtree and
7557
+ // instead inject a new real Suspense boundary to take its place, which may render content
7558
+ // or fallback. The real Suspense boundary will suspend for a while so we have some time
7559
+ // to ensure it can produce real content, but all state and pending events will be lost.
7560
+
7561
+ // Detach from the current dehydrated boundary.
7562
+ current$$1.alternate = null;
7563
+ workInProgress.alternate = null;
7564
+
7565
+ // Insert a deletion in the effect list.
7566
+ var returnFiber = workInProgress.return;
7567
+ !(returnFiber !== null) ? invariant(false, 'Suspense boundaries are never on the root. This is probably a bug in React.') : void 0;
7568
+ var last = returnFiber.lastEffect;
7569
+ if (last !== null) {
7570
+ last.nextEffect = current$$1;
7571
+ returnFiber.lastEffect = current$$1;
7572
+ } else {
7573
+ returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
7574
+ }
7575
+ current$$1.nextEffect = null;
7576
+ current$$1.effectTag = Deletion;
7577
+
7578
+ // Upgrade this work in progress to a real Suspense component.
7579
+ workInProgress.tag = SuspenseComponent;
7580
+ workInProgress.stateNode = null;
7581
+ workInProgress.memoizedState = null;
7582
+ // This is now an insertion.
7583
+ workInProgress.effectTag |= Placement;
7584
+ // Retry as a real Suspense component.
7585
+ return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
7586
+ }
7587
+ if ((workInProgress.effectTag & DidCapture) === NoEffect) {
7588
+ // This is the first attempt.
7589
+ reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
7590
+ var nextProps = workInProgress.pendingProps;
7591
+ var nextChildren = nextProps.children;
7592
+ workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7593
+ return workInProgress.child;
7594
+ } else {
7595
+ // Something suspended. Leave the existing children in place.
7596
+ // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
7597
+ workInProgress.child = null;
7598
+ return null;
7599
+ }
7600
+ }
7601
+
7290
7602
  function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
7291
7603
  pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
7292
7604
  var nextChildren = workInProgress.pendingProps;
@@ -7498,6 +7810,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
7498
7810
  }
7499
7811
  break;
7500
7812
  }
7813
+ case DehydratedSuspenseComponent:
7814
+ {
7815
+ if (enableSuspenseServerRenderer) {
7816
+ // We know that this component will suspend again because if it has
7817
+ // been unsuspended it has committed as a regular Suspense component.
7818
+ // If it needs to be retried, it should have work scheduled on it.
7819
+ workInProgress.effectTag |= DidCapture;
7820
+ break;
7821
+ }
7822
+ }
7501
7823
  }
7502
7824
  return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7503
7825
  }
@@ -7589,9 +7911,15 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
7589
7911
  var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
7590
7912
  return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
7591
7913
  }
7592
- default:
7593
- invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
7914
+ case DehydratedSuspenseComponent:
7915
+ {
7916
+ if (enableSuspenseServerRenderer) {
7917
+ return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
7918
+ }
7919
+ break;
7920
+ }
7594
7921
  }
7922
+ invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
7595
7923
  }
7596
7924
 
7597
7925
  var valueCursor = createCursor(null);
@@ -7680,6 +8008,28 @@ function calculateChangedBits(context, newValue, oldValue) {
7680
8008
  }
7681
8009
  }
7682
8010
 
8011
+ function scheduleWorkOnParentPath(parent, renderExpirationTime) {
8012
+ // Update the child expiration time of all the ancestors, including
8013
+ // the alternates.
8014
+ var node = parent;
8015
+ while (node !== null) {
8016
+ var alternate = node.alternate;
8017
+ if (node.childExpirationTime < renderExpirationTime) {
8018
+ node.childExpirationTime = renderExpirationTime;
8019
+ if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
8020
+ alternate.childExpirationTime = renderExpirationTime;
8021
+ }
8022
+ } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
8023
+ alternate.childExpirationTime = renderExpirationTime;
8024
+ } else {
8025
+ // Neither alternate was updated, which means the rest of the
8026
+ // ancestor path already has sufficient priority.
8027
+ break;
8028
+ }
8029
+ node = node.return;
8030
+ }
8031
+ }
8032
+
7683
8033
  function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
7684
8034
  var fiber = workInProgress.child;
7685
8035
  if (fiber !== null) {
@@ -7718,25 +8068,8 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
7718
8068
  if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
7719
8069
  alternate.expirationTime = renderExpirationTime;
7720
8070
  }
7721
- // Update the child expiration time of all the ancestors, including
7722
- // the alternates.
7723
- var node = fiber.return;
7724
- while (node !== null) {
7725
- alternate = node.alternate;
7726
- if (node.childExpirationTime < renderExpirationTime) {
7727
- node.childExpirationTime = renderExpirationTime;
7728
- if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
7729
- alternate.childExpirationTime = renderExpirationTime;
7730
- }
7731
- } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
7732
- alternate.childExpirationTime = renderExpirationTime;
7733
- } else {
7734
- // Neither alternate was updated, which means the rest of the
7735
- // ancestor path already has sufficient priority.
7736
- break;
7737
- }
7738
- node = node.return;
7739
- }
8071
+
8072
+ scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
7740
8073
 
7741
8074
  // Mark the expiration time on the list, too.
7742
8075
  if (list.expirationTime < renderExpirationTime) {
@@ -7752,6 +8085,23 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
7752
8085
  } else if (fiber.tag === ContextProvider) {
7753
8086
  // Don't scan deeper if this is a matching provider
7754
8087
  nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
8088
+ } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
8089
+ // If a dehydrated suspense component is in this subtree, we don't know
8090
+ // if it will have any context consumers in it. The best we can do is
8091
+ // mark it as having updates on its children.
8092
+ if (fiber.expirationTime < renderExpirationTime) {
8093
+ fiber.expirationTime = renderExpirationTime;
8094
+ }
8095
+ var _alternate = fiber.alternate;
8096
+ if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
8097
+ _alternate.expirationTime = renderExpirationTime;
8098
+ }
8099
+ // This is intentionally passing this fiber as the parent
8100
+ // because we want to schedule this fiber as having work
8101
+ // on its children. We'll use the childExpirationTime on
8102
+ // this fiber to indicate that a context has changed.
8103
+ scheduleWorkOnParentPath(fiber, renderExpirationTime);
8104
+ nextFiber = fiber.sibling;
7755
8105
  } else {
7756
8106
  // Traverse down.
7757
8107
  nextFiber = fiber.child;
@@ -8875,6 +9225,26 @@ function completeWork(current, workInProgress, renderExpirationTime) {
8875
9225
  }
8876
9226
  break;
8877
9227
  }
9228
+ case DehydratedSuspenseComponent:
9229
+ {
9230
+ if (enableSuspenseServerRenderer) {
9231
+ if (current === null) {
9232
+ var _wasHydrated2 = popHydrationState(workInProgress);
9233
+ !_wasHydrated2 ? invariant(false, 'A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.') : void 0;
9234
+ skipPastDehydratedSuspenseInstance(workInProgress);
9235
+ } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
9236
+ // This boundary did not suspend so it's now hydrated.
9237
+ // To handle any future suspense cases, we're going to now upgrade it
9238
+ // to a Suspense component. We detach it from the existing current fiber.
9239
+ current.alternate = null;
9240
+ workInProgress.alternate = null;
9241
+ workInProgress.tag = SuspenseComponent;
9242
+ workInProgress.memoizedState = null;
9243
+ workInProgress.stateNode = null;
9244
+ }
9245
+ }
9246
+ break;
9247
+ }
8878
9248
  default:
8879
9249
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
8880
9250
  }
@@ -8965,7 +9335,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
8965
9335
  didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
8966
9336
  }
8967
9337
 
8968
- var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
9338
+ var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
8969
9339
 
8970
9340
  function logError(boundary, errorInfo) {
8971
9341
  var source = errorInfo.source;
@@ -9278,7 +9648,7 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
9278
9648
 
9279
9649
  function hideOrUnhideAllChildren(finishedWork, isHidden) {
9280
9650
  if (supportsMutation) {
9281
- // We only have the top Fiber that was inserted but we need recurse down its
9651
+ // We only have the top Fiber that was inserted but we need to recurse down its
9282
9652
  var node = finishedWork;
9283
9653
  while (true) {
9284
9654
  if (node.tag === HostComponent) {
@@ -9546,7 +9916,7 @@ function getHostSibling(fiber) {
9546
9916
  }
9547
9917
  node.sibling.return = node.return;
9548
9918
  node = node.sibling;
9549
- while (node.tag !== HostComponent && node.tag !== HostText) {
9919
+ while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
9550
9920
  // If it is not host node and, we might have a host node inside it.
9551
9921
  // Try to search down until we find one.
9552
9922
  if (node.effectTag & Placement) {
@@ -9604,7 +9974,7 @@ function commitPlacement(finishedWork) {
9604
9974
  }
9605
9975
 
9606
9976
  var before = getHostSibling(finishedWork);
9607
- // We only have the top Fiber that was inserted but we need recurse down its
9977
+ // We only have the top Fiber that was inserted but we need to recurse down its
9608
9978
  // children to find all the terminal nodes.
9609
9979
  var node = finishedWork;
9610
9980
  while (true) {
@@ -9646,7 +10016,7 @@ function commitPlacement(finishedWork) {
9646
10016
  }
9647
10017
 
9648
10018
  function unmountHostComponents(current$$1) {
9649
- // We only have the top Fiber that was deleted but we need recurse down its
10019
+ // We only have the top Fiber that was deleted but we need to recurse down its
9650
10020
  var node = current$$1;
9651
10021
 
9652
10022
  // Each iteration, currentParent is populated with node's host parent if not
@@ -9691,13 +10061,20 @@ function unmountHostComponents(current$$1) {
9691
10061
  removeChild(currentParent, node.stateNode);
9692
10062
  }
9693
10063
  // Don't visit children because we already visited them.
10064
+ } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
10065
+ // Delete the dehydrated suspense boundary and all of its content.
10066
+ if (currentParentIsContainer) {
10067
+ clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
10068
+ } else {
10069
+ clearSuspenseBoundary(currentParent, node.stateNode);
10070
+ }
9694
10071
  } else if (node.tag === HostPortal) {
9695
- // When we go into a portal, it becomes the parent to remove from.
9696
- // We will reassign it back when we pop the portal on the way up.
9697
- currentParent = node.stateNode.containerInfo;
9698
- currentParentIsContainer = true;
9699
- // Visit children because portals might contain host components.
9700
10072
  if (node.child !== null) {
10073
+ // When we go into a portal, it becomes the parent to remove from.
10074
+ // We will reassign it back when we pop the portal on the way up.
10075
+ currentParent = node.stateNode.containerInfo;
10076
+ currentParentIsContainer = true;
10077
+ // Visit children because portals might contain host components.
9701
10078
  node.child.return = node;
9702
10079
  node = node.child;
9703
10080
  continue;
@@ -9847,7 +10224,7 @@ function commitWork(current$$1, finishedWork) {
9847
10224
  finishedWork.updateQueue = null;
9848
10225
  var retryCache = finishedWork.stateNode;
9849
10226
  if (retryCache === null) {
9850
- retryCache = finishedWork.stateNode = new PossiblyWeakSet();
10227
+ retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
9851
10228
  }
9852
10229
  thenables.forEach(function (thenable) {
9853
10230
  // Memoize using the boundary fiber to prevent redundant listeners.
@@ -9882,6 +10259,7 @@ function commitResetTextContent(current$$1) {
9882
10259
  resetTextContent(current$$1.stateNode);
9883
10260
  }
9884
10261
 
10262
+ var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
9885
10263
  var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
9886
10264
 
9887
10265
  function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
@@ -9940,6 +10318,34 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
9940
10318
  return update;
9941
10319
  }
9942
10320
 
10321
+ function attachPingListener(root, renderExpirationTime, thenable) {
10322
+ // Attach a listener to the promise to "ping" the root and retry. But
10323
+ // only if one does not already exist for the current render expiration
10324
+ // time (which acts like a "thread ID" here).
10325
+ var pingCache = root.pingCache;
10326
+ var threadIDs = void 0;
10327
+ if (pingCache === null) {
10328
+ pingCache = root.pingCache = new PossiblyWeakMap();
10329
+ threadIDs = new Set();
10330
+ pingCache.set(thenable, threadIDs);
10331
+ } else {
10332
+ threadIDs = pingCache.get(thenable);
10333
+ if (threadIDs === undefined) {
10334
+ threadIDs = new Set();
10335
+ pingCache.set(thenable, threadIDs);
10336
+ }
10337
+ }
10338
+ if (!threadIDs.has(renderExpirationTime)) {
10339
+ // Memoize using the thread ID to prevent redundant listeners.
10340
+ threadIDs.add(renderExpirationTime);
10341
+ var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
10342
+ if (enableSchedulerTracing) {
10343
+ ping = unstable_wrap(ping);
10344
+ }
10345
+ thenable.then(ping, ping);
10346
+ }
10347
+ }
10348
+
9943
10349
  function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
9944
10350
  // The source fiber did not complete.
9945
10351
  sourceFiber.effectTag |= Incomplete;
@@ -9981,6 +10387,9 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
9981
10387
  }
9982
10388
  }
9983
10389
  }
10390
+ // If there is a DehydratedSuspenseComponent we don't have to do anything because
10391
+ // if something suspends inside it, we will simply leave that as dehydrated. It
10392
+ // will never timeout.
9984
10393
  _workInProgress = _workInProgress.return;
9985
10394
  } while (_workInProgress !== null);
9986
10395
 
@@ -10044,31 +10453,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
10044
10453
  // Confirmed that the boundary is in a concurrent mode tree. Continue
10045
10454
  // with the normal suspend path.
10046
10455
 
10047
- // Attach a listener to the promise to "ping" the root and retry. But
10048
- // only if one does not already exist for the current render expiration
10049
- // time (which acts like a "thread ID" here).
10050
- var pingCache = root.pingCache;
10051
- var threadIDs = void 0;
10052
- if (pingCache === null) {
10053
- pingCache = root.pingCache = new PossiblyWeakMap();
10054
- threadIDs = new Set();
10055
- pingCache.set(thenable, threadIDs);
10056
- } else {
10057
- threadIDs = pingCache.get(thenable);
10058
- if (threadIDs === undefined) {
10059
- threadIDs = new Set();
10060
- pingCache.set(thenable, threadIDs);
10061
- }
10062
- }
10063
- if (!threadIDs.has(renderExpirationTime)) {
10064
- // Memoize using the thread ID to prevent redundant listeners.
10065
- threadIDs.add(renderExpirationTime);
10066
- var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
10067
- if (enableSchedulerTracing) {
10068
- ping = unstable_wrap(ping);
10069
- }
10070
- thenable.then(ping, ping);
10071
- }
10456
+ attachPingListener(root, renderExpirationTime, thenable);
10072
10457
 
10073
10458
  var absoluteTimeoutMs = void 0;
10074
10459
  if (earliestTimeoutMs === -1) {
@@ -10100,6 +10485,29 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
10100
10485
  // whole tree.
10101
10486
  renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
10102
10487
 
10488
+ _workInProgress.effectTag |= ShouldCapture;
10489
+ _workInProgress.expirationTime = renderExpirationTime;
10490
+ return;
10491
+ } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
10492
+ attachPingListener(root, renderExpirationTime, thenable);
10493
+
10494
+ // Since we already have a current fiber, we can eagerly add a retry listener.
10495
+ var retryCache = _workInProgress.memoizedState;
10496
+ if (retryCache === null) {
10497
+ retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
10498
+ var _current = _workInProgress.alternate;
10499
+ !_current ? invariant(false, 'A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.') : void 0;
10500
+ _current.memoizedState = retryCache;
10501
+ }
10502
+ // Memoize using the boundary fiber to prevent redundant listeners.
10503
+ if (!retryCache.has(thenable)) {
10504
+ retryCache.add(thenable);
10505
+ var retry = retryTimedOutBoundary.bind(null, _workInProgress, thenable);
10506
+ if (enableSchedulerTracing) {
10507
+ retry = unstable_wrap(retry);
10508
+ }
10509
+ thenable.then(retry, retry);
10510
+ }
10103
10511
  _workInProgress.effectTag |= ShouldCapture;
10104
10512
  _workInProgress.expirationTime = renderExpirationTime;
10105
10513
  return;
@@ -10177,6 +10585,7 @@ function unwindWork(workInProgress, renderExpirationTime) {
10177
10585
  }
10178
10586
  case HostComponent:
10179
10587
  {
10588
+ // TODO: popHydrationState
10180
10589
  popHostContext(workInProgress);
10181
10590
  return null;
10182
10591
  }
@@ -10190,6 +10599,19 @@ function unwindWork(workInProgress, renderExpirationTime) {
10190
10599
  }
10191
10600
  return null;
10192
10601
  }
10602
+ case DehydratedSuspenseComponent:
10603
+ {
10604
+ if (enableSuspenseServerRenderer) {
10605
+ // TODO: popHydrationState
10606
+ var _effectTag3 = workInProgress.effectTag;
10607
+ if (_effectTag3 & ShouldCapture) {
10608
+ workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
10609
+ // Captured a suspense effect. Re-render the boundary.
10610
+ return workInProgress;
10611
+ }
10612
+ }
10613
+ return null;
10614
+ }
10193
10615
  case HostPortal:
10194
10616
  popHostContainer(workInProgress);
10195
10617
  return null;
@@ -10284,11 +10706,6 @@ if (enableSchedulerTracing) {
10284
10706
  };
10285
10707
  }
10286
10708
 
10287
- // Represents the expiration time that incoming updates should use. (If this
10288
- // is NoWork, use the default strategy: async updates in async mode, sync
10289
- // updates in sync mode.)
10290
- var expirationContext = NoWork;
10291
-
10292
10709
  var isWorking = false;
10293
10710
 
10294
10711
  // The next work in progress fiber that we're currently working on.
@@ -10584,6 +11001,10 @@ function commitPassiveEffects(root, firstEffect) {
10584
11001
  if (rootExpirationTime !== NoWork) {
10585
11002
  requestWork(root, rootExpirationTime);
10586
11003
  }
11004
+ // Flush any sync work that was scheduled by effects
11005
+ if (!isBatchingUpdates && !isRendering) {
11006
+ performSyncWork();
11007
+ }
10587
11008
  }
10588
11009
 
10589
11010
  function isAlreadyFailedLegacyErrorBoundary(instance) {
@@ -10758,7 +11179,9 @@ function commitRoot(root, finishedWork) {
10758
11179
  // here because that code is still in flux.
10759
11180
  callback = unstable_wrap(callback);
10760
11181
  }
10761
- passiveEffectCallbackHandle = schedulePassiveEffects(callback);
11182
+ passiveEffectCallbackHandle = unstable_runWithPriority(unstable_NormalPriority, function () {
11183
+ return schedulePassiveEffects(callback);
11184
+ });
10762
11185
  passiveEffectCallback = callback;
10763
11186
  }
10764
11187
 
@@ -11347,7 +11770,7 @@ function renderRoot(root, isYieldy) {
11347
11770
  return;
11348
11771
  } else if (
11349
11772
  // There's no lower priority work, but we're rendering asynchronously.
11350
- // Synchronsouly attempt to render the same level one more time. This is
11773
+ // Synchronously attempt to render the same level one more time. This is
11351
11774
  // similar to a suspend, but without a timeout because we're not waiting
11352
11775
  // for a promise to resolve.
11353
11776
  !root.didError && isYieldy) {
@@ -11438,41 +11861,46 @@ function computeThreadID(expirationTime, interactionThreadID) {
11438
11861
  }
11439
11862
 
11440
11863
  function computeExpirationForFiber(currentTime, fiber) {
11864
+ var priorityLevel = unstable_getCurrentPriorityLevel();
11865
+
11441
11866
  var expirationTime = void 0;
11442
- if (expirationContext !== NoWork) {
11443
- // An explicit expiration context was set;
11444
- expirationTime = expirationContext;
11445
- } else if (isWorking) {
11446
- if (isCommitting$1) {
11447
- // Updates that occur during the commit phase should have sync priority
11448
- // by default.
11449
- expirationTime = Sync;
11450
- } else {
11451
- // Updates during the render phase should expire at the same time as
11452
- // the work that is being rendered.
11453
- expirationTime = nextRenderExpirationTime;
11454
- }
11867
+ if ((fiber.mode & ConcurrentMode) === NoContext) {
11868
+ // Outside of concurrent mode, updates are always synchronous.
11869
+ expirationTime = Sync;
11870
+ } else if (isWorking && !isCommitting$1) {
11871
+ // During render phase, updates expire during as the current render.
11872
+ expirationTime = nextRenderExpirationTime;
11455
11873
  } else {
11456
- // No explicit expiration context was set, and we're not currently
11457
- // performing work. Calculate a new expiration time.
11458
- if (fiber.mode & ConcurrentMode) {
11459
- if (isBatchingInteractiveUpdates) {
11460
- // This is an interactive update
11874
+ switch (priorityLevel) {
11875
+ case unstable_ImmediatePriority:
11876
+ expirationTime = Sync;
11877
+ break;
11878
+ case unstable_UserBlockingPriority:
11461
11879
  expirationTime = computeInteractiveExpiration(currentTime);
11462
- } else {
11463
- // This is an async update
11880
+ break;
11881
+ case unstable_NormalPriority:
11882
+ // This is a normal, concurrent update
11464
11883
  expirationTime = computeAsyncExpiration(currentTime);
11465
- }
11466
- // If we're in the middle of rendering a tree, do not update at the same
11467
- // expiration time that is already rendering.
11468
- if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
11469
- expirationTime -= 1;
11470
- }
11471
- } else {
11472
- // This is a sync update
11473
- expirationTime = Sync;
11884
+ break;
11885
+ case unstable_LowPriority:
11886
+ case unstable_IdlePriority:
11887
+ expirationTime = Never;
11888
+ break;
11889
+ default:
11890
+ invariant(false, 'Unknown priority level. This error is likely caused by a bug in React. Please file an issue.');
11891
+ }
11892
+
11893
+ // If we're in the middle of rendering a tree, do not update at the same
11894
+ // expiration time that is already rendering.
11895
+ if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
11896
+ expirationTime -= 1;
11474
11897
  }
11475
11898
  }
11899
+
11900
+ // Keep track of the lowest pending interactive expiration time. This
11901
+ // allows us to synchronously flush all interactive updates
11902
+ // when needed.
11903
+ // TODO: Move this to renderer?
11476
11904
  return expirationTime;
11477
11905
  }
11478
11906
 
@@ -11519,7 +11947,21 @@ function retryTimedOutBoundary(boundaryFiber, thenable) {
11519
11947
  // The boundary fiber (a Suspense component) previously timed out and was
11520
11948
  // rendered in its fallback state. One of the promises that suspended it has
11521
11949
  // resolved, which means at least part of the tree was likely unblocked. Try
11522
- var retryCache = boundaryFiber.stateNode;
11950
+ var retryCache = void 0;
11951
+ if (enableSuspenseServerRenderer) {
11952
+ switch (boundaryFiber.tag) {
11953
+ case SuspenseComponent:
11954
+ retryCache = boundaryFiber.stateNode;
11955
+ break;
11956
+ case DehydratedSuspenseComponent:
11957
+ retryCache = boundaryFiber.memoizedState;
11958
+ break;
11959
+ default:
11960
+ invariant(false, 'Pinged unknown suspense boundary type. This is probably a bug in React.');
11961
+ }
11962
+ } else {
11963
+ retryCache = boundaryFiber.stateNode;
11964
+ }
11523
11965
  if (retryCache !== null) {
11524
11966
  // The thenable resolved, so we no longer need to memoize, because it will
11525
11967
  // never be thrown again.
@@ -11618,7 +12060,7 @@ function scheduleWorkToRoot(fiber, expirationTime) {
11618
12060
  function warnIfNotCurrentlyBatchingInDev(fiber) {
11619
12061
  {
11620
12062
  if (isRendering === false && isBatchingUpdates === false) {
11621
- warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see in the browser." + ' Learn more at https://fb.me/react-wrap-tests-with-act', getComponentName(fiber.type));
12063
+ warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see in the browser." + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
11622
12064
  }
11623
12065
  }
11624
12066
  }
@@ -11665,13 +12107,9 @@ function scheduleWork(fiber, expirationTime) {
11665
12107
  }
11666
12108
 
11667
12109
  function syncUpdates(fn, a, b, c, d) {
11668
- var previousExpirationContext = expirationContext;
11669
- expirationContext = Sync;
11670
- try {
12110
+ return unstable_runWithPriority(unstable_ImmediatePriority, function () {
11671
12111
  return fn(a, b, c, d);
11672
- } finally {
11673
- expirationContext = previousExpirationContext;
11674
- }
12112
+ });
11675
12113
  }
11676
12114
 
11677
12115
  // TODO: Everything below this is written as if it has been lifted to the
@@ -11691,7 +12129,6 @@ var unhandledError = null;
11691
12129
 
11692
12130
  var isBatchingUpdates = false;
11693
12131
  var isUnbatchingUpdates = false;
11694
- var isBatchingInteractiveUpdates = false;
11695
12132
 
11696
12133
  var completedBatches = null;
11697
12134
 
@@ -12165,7 +12602,9 @@ function completeRoot(root, finishedWork, expirationTime) {
12165
12602
  lastCommittedRootDuringThisBatch = root;
12166
12603
  nestedUpdateCount = 0;
12167
12604
  }
12168
- commitRoot(root, finishedWork);
12605
+ unstable_runWithPriority(unstable_ImmediatePriority, function () {
12606
+ commitRoot(root, finishedWork);
12607
+ });
12169
12608
  }
12170
12609
 
12171
12610
  function onUncaughtError(error) {
@@ -12373,7 +12812,7 @@ function injectIntoDevTools(devToolsConfig) {
12373
12812
 
12374
12813
  // TODO: this is special because it gets imported during build.
12375
12814
 
12376
- var ReactVersion = '16.8.0';
12815
+ var ReactVersion = '16.8.4';
12377
12816
 
12378
12817
  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; }; }();
12379
12818