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.
@@ -19,6 +19,7 @@ var _assign = require('object-assign');
19
19
  var React = require('react');
20
20
  var checkPropTypes = require('prop-types/checkPropTypes');
21
21
  var tracing = require('scheduler/tracing');
22
+ var scheduler = require('scheduler');
22
23
 
23
24
  /**
24
25
  * Use invariant() to assert state which your program assumes to be true.
@@ -144,6 +145,15 @@ function set(key, value) {
144
145
 
145
146
  var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
146
147
 
148
+ // Prevent newer renderers from RTE when used with older react package versions.
149
+ // Current owner and dispatcher used to share the same ref,
150
+ // but PR #14548 split them out to better support the react-debug-tools package.
151
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
152
+ ReactSharedInternals.ReactCurrentDispatcher = {
153
+ current: null
154
+ };
155
+ }
156
+
147
157
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
148
158
  // nor polyfill, then a plain number is used for performance.
149
159
  var hasSymbol = typeof Symbol === 'function' && Symbol.for;
@@ -260,6 +270,7 @@ var MemoComponent = 14;
260
270
  var SimpleMemoComponent = 15;
261
271
  var LazyComponent = 16;
262
272
  var IncompleteClassComponent = 17;
273
+ var DehydratedSuspenseComponent = 18;
263
274
 
264
275
  // Don't change these two values. They're used by React Dev Tools.
265
276
  var NoEffect = /* */0;
@@ -620,21 +631,28 @@ function shim$1() {
620
631
  }
621
632
 
622
633
  // Hydration (when unsupported)
634
+
623
635
  var supportsHydration = false;
624
636
  var canHydrateInstance = shim$1;
625
637
  var canHydrateTextInstance = shim$1;
638
+ var canHydrateSuspenseInstance = shim$1;
626
639
  var getNextHydratableSibling = shim$1;
627
640
  var getFirstHydratableChild = shim$1;
628
641
  var hydrateInstance = shim$1;
629
642
  var hydrateTextInstance = shim$1;
643
+ var getNextHydratableInstanceAfterSuspenseInstance = shim$1;
644
+ var clearSuspenseBoundary = shim$1;
645
+ var clearSuspenseBoundaryFromContainer = shim$1;
630
646
  var didNotMatchHydratedContainerTextInstance = shim$1;
631
647
  var didNotMatchHydratedTextInstance = shim$1;
632
648
  var didNotHydrateContainerInstance = shim$1;
633
649
  var didNotHydrateInstance = shim$1;
634
650
  var didNotFindHydratableContainerInstance = shim$1;
635
651
  var didNotFindHydratableContainerTextInstance = shim$1;
652
+ var didNotFindHydratableContainerSuspenseInstance = shim$1;
636
653
  var didNotFindHydratableInstance = shim$1;
637
654
  var didNotFindHydratableTextInstance = shim$1;
655
+ var didNotFindHydratableSuspenseInstance = shim$1;
638
656
 
639
657
  var NO_CONTEXT = {};
640
658
  var UPDATE_SIGNAL = {};
@@ -915,7 +933,7 @@ var warnAboutDeprecatedLifecycles = false;
915
933
  var replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
916
934
  var enableProfilerTimer = false;
917
935
  var enableSchedulerTracing = false;
918
-
936
+ var enableSuspenseServerRenderer = false;
919
937
 
920
938
 
921
939
 
@@ -1178,7 +1196,7 @@ function stopFailedWorkTimer(fiber) {
1178
1196
  return;
1179
1197
  }
1180
1198
  fiber._debugIsCurrentlyTiming = false;
1181
- var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1199
+ var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1182
1200
  endFiberMark(fiber, null, warning);
1183
1201
  }
1184
1202
  }
@@ -1847,6 +1865,7 @@ function FiberNode(tag, pendingProps, key, mode) {
1847
1865
  this._debugSource = null;
1848
1866
  this._debugOwner = null;
1849
1867
  this._debugIsCurrentlyTiming = false;
1868
+ this._debugHookTypes = null;
1850
1869
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
1851
1870
  Object.preventExtensions(this);
1852
1871
  }
@@ -1914,6 +1933,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
1914
1933
  workInProgress._debugID = current._debugID;
1915
1934
  workInProgress._debugSource = current._debugSource;
1916
1935
  workInProgress._debugOwner = current._debugOwner;
1936
+ workInProgress._debugHookTypes = current._debugHookTypes;
1917
1937
  }
1918
1938
 
1919
1939
  workInProgress.alternate = current;
@@ -2181,6 +2201,7 @@ function assignFiberPropertiesInDEV(target, source) {
2181
2201
  target._debugSource = source._debugSource;
2182
2202
  target._debugOwner = source._debugOwner;
2183
2203
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
2204
+ target._debugHookTypes = source._debugHookTypes;
2184
2205
  return target;
2185
2206
  }
2186
2207
 
@@ -2292,7 +2313,7 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
2292
2313
  // invokeGuardedCallback uses a try-catch, all user exceptions are treated
2293
2314
  // like caught exceptions, and the DevTools won't pause unless the developer
2294
2315
  // takes the extra step of enabling pause on caught exceptions. This is
2295
- // untintuitive, though, because even though React has caught the error, from
2316
+ // unintuitive, though, because even though React has caught the error, from
2296
2317
  // the developer's perspective, the error is uncaught.
2297
2318
  //
2298
2319
  // To preserve the expected "Pause on exceptions" behavior, we don't use a
@@ -4244,7 +4265,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4244
4265
  }
4245
4266
 
4246
4267
  function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
4247
- // This algorithm can't optimize by searching from boths ends since we
4268
+ // This algorithm can't optimize by searching from both ends since we
4248
4269
  // don't have backpointers on fibers. I'm trying to see how far we can get
4249
4270
  // with that model. If it ends up not being worth the tradeoffs, we can
4250
4271
  // add it later.
@@ -4825,7 +4846,6 @@ var currentlyRenderingFiber$1 = null;
4825
4846
  // current hook list is the list that belongs to the current fiber. The
4826
4847
  // work-in-progress hook list is a new list that will be added to the
4827
4848
  // work-in-progress fiber.
4828
- var firstCurrentHook = null;
4829
4849
  var currentHook = null;
4830
4850
  var nextCurrentHook = null;
4831
4851
  var firstWorkInProgressHook = null;
@@ -4855,39 +4875,67 @@ var RE_RENDER_LIMIT = 25;
4855
4875
  // In DEV, this is the name of the currently executing primitive hook
4856
4876
  var currentHookNameInDev = null;
4857
4877
 
4858
- function warnOnHookMismatchInDev() {
4878
+ // In DEV, this list ensures that hooks are called in the same order between renders.
4879
+ // The list stores the order of hooks used during the initial render (mount).
4880
+ // Subsequent renders (updates) reference this list.
4881
+ var hookTypesDev = null;
4882
+ var hookTypesUpdateIndexDev = -1;
4883
+
4884
+ function mountHookTypesDev() {
4885
+ {
4886
+ var hookName = currentHookNameInDev;
4887
+
4888
+ if (hookTypesDev === null) {
4889
+ hookTypesDev = [hookName];
4890
+ } else {
4891
+ hookTypesDev.push(hookName);
4892
+ }
4893
+ }
4894
+ }
4895
+
4896
+ function updateHookTypesDev() {
4897
+ {
4898
+ var hookName = currentHookNameInDev;
4899
+
4900
+ if (hookTypesDev !== null) {
4901
+ hookTypesUpdateIndexDev++;
4902
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
4903
+ warnOnHookMismatchInDev(hookName);
4904
+ }
4905
+ }
4906
+ }
4907
+ }
4908
+
4909
+ function warnOnHookMismatchInDev(currentHookName) {
4859
4910
  {
4860
4911
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
4861
4912
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
4862
4913
  didWarnAboutMismatchedHooksForComponent.add(componentName);
4863
4914
 
4864
- var secondColumnStart = 22;
4915
+ if (hookTypesDev !== null) {
4916
+ var table = '';
4865
4917
 
4866
- var table = '';
4867
- var prevHook = firstCurrentHook;
4868
- var nextHook = firstWorkInProgressHook;
4869
- var n = 1;
4870
- while (prevHook !== null && nextHook !== null) {
4871
- var oldHookName = prevHook._debugType;
4872
- var newHookName = nextHook._debugType;
4918
+ var secondColumnStart = 30;
4873
4919
 
4874
- var row = n + '. ' + oldHookName;
4920
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
4921
+ var oldHookName = hookTypesDev[i];
4922
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
4875
4923
 
4876
- // Extra space so second column lines up
4877
- // lol @ IE not supporting String#repeat
4878
- while (row.length < secondColumnStart) {
4879
- row += ' ';
4880
- }
4924
+ var row = i + 1 + '. ' + oldHookName;
4881
4925
 
4882
- row += newHookName + '\n';
4926
+ // Extra space so second column lines up
4927
+ // lol @ IE not supporting String#repeat
4928
+ while (row.length < secondColumnStart) {
4929
+ row += ' ';
4930
+ }
4883
4931
 
4884
- table += row;
4885
- prevHook = prevHook.next;
4886
- nextHook = nextHook.next;
4887
- n++;
4888
- }
4932
+ row += newHookName + '\n';
4889
4933
 
4890
- 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);
4934
+ table += row;
4935
+ }
4936
+
4937
+ 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);
4938
+ }
4891
4939
  }
4892
4940
  }
4893
4941
  }
@@ -4923,7 +4971,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
4923
4971
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
4924
4972
  renderExpirationTime = nextRenderExpirationTime;
4925
4973
  currentlyRenderingFiber$1 = workInProgress;
4926
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
4974
+ nextCurrentHook = current !== null ? current.memoizedState : null;
4975
+
4976
+ {
4977
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
4978
+ hookTypesUpdateIndexDev = -1;
4979
+ }
4927
4980
 
4928
4981
  // The following should have already been reset
4929
4982
  // currentHook = null;
@@ -4937,8 +4990,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4937
4990
  // numberOfReRenders = 0;
4938
4991
  // sideEffectTag = 0;
4939
4992
 
4993
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
4994
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
4995
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
4996
+
4997
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
4998
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
4999
+ // so nextCurrentHook would be null during updates and mounts.
4940
5000
  {
4941
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
5001
+ if (nextCurrentHook !== null) {
5002
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
5003
+ } else if (hookTypesDev !== null) {
5004
+ // This dispatcher handles an edge case where a component is updating,
5005
+ // but no stateful hooks have been used.
5006
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
5007
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
5008
+ // This dispatcher does that.
5009
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
5010
+ } else {
5011
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
5012
+ }
4942
5013
  }
4943
5014
 
4944
5015
  var children = Component(props, refOrContext);
@@ -4949,13 +5020,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4949
5020
  numberOfReRenders += 1;
4950
5021
 
4951
5022
  // Start over from the beginning of the list
4952
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
5023
+ nextCurrentHook = current !== null ? current.memoizedState : null;
4953
5024
  nextWorkInProgressHook = firstWorkInProgressHook;
4954
5025
 
4955
5026
  currentHook = null;
4956
5027
  workInProgressHook = null;
4957
5028
  componentUpdateQueue = null;
4958
5029
 
5030
+ {
5031
+ // Also validate hook order for cascading updates.
5032
+ hookTypesUpdateIndexDev = -1;
5033
+ }
5034
+
4959
5035
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
4960
5036
 
4961
5037
  children = Component(props, refOrContext);
@@ -4965,10 +5041,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4965
5041
  numberOfReRenders = 0;
4966
5042
  }
4967
5043
 
4968
- {
4969
- currentHookNameInDev = null;
4970
- }
4971
-
4972
5044
  // We can assume the previous dispatcher is always this one, since we set it
4973
5045
  // at the beginning of the render phase and there's no re-entrancy.
4974
5046
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -4980,18 +5052,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4980
5052
  renderedWork.updateQueue = componentUpdateQueue;
4981
5053
  renderedWork.effectTag |= sideEffectTag;
4982
5054
 
5055
+ {
5056
+ renderedWork._debugHookTypes = hookTypesDev;
5057
+ }
5058
+
5059
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
5060
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
4983
5061
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
4984
5062
 
4985
5063
  renderExpirationTime = NoWork;
4986
5064
  currentlyRenderingFiber$1 = null;
4987
5065
 
4988
- firstCurrentHook = null;
4989
5066
  currentHook = null;
4990
5067
  nextCurrentHook = null;
4991
5068
  firstWorkInProgressHook = null;
4992
5069
  workInProgressHook = null;
4993
5070
  nextWorkInProgressHook = null;
4994
5071
 
5072
+ {
5073
+ currentHookNameInDev = null;
5074
+ hookTypesDev = null;
5075
+ hookTypesUpdateIndexDev = -1;
5076
+ }
5077
+
4995
5078
  remainingExpirationTime = NoWork;
4996
5079
  componentUpdateQueue = null;
4997
5080
  sideEffectTag = 0;
@@ -5025,21 +5108,23 @@ function resetHooks() {
5025
5108
  renderExpirationTime = NoWork;
5026
5109
  currentlyRenderingFiber$1 = null;
5027
5110
 
5028
- firstCurrentHook = null;
5029
5111
  currentHook = null;
5030
5112
  nextCurrentHook = null;
5031
5113
  firstWorkInProgressHook = null;
5032
5114
  workInProgressHook = null;
5033
5115
  nextWorkInProgressHook = null;
5034
5116
 
5035
- remainingExpirationTime = NoWork;
5036
- componentUpdateQueue = null;
5037
- sideEffectTag = 0;
5038
-
5039
5117
  {
5118
+ hookTypesDev = null;
5119
+ hookTypesUpdateIndexDev = -1;
5120
+
5040
5121
  currentHookNameInDev = null;
5041
5122
  }
5042
5123
 
5124
+ remainingExpirationTime = NoWork;
5125
+ componentUpdateQueue = null;
5126
+ sideEffectTag = 0;
5127
+
5043
5128
  didScheduleRenderPhaseUpdate = false;
5044
5129
  renderPhaseUpdates = null;
5045
5130
  numberOfReRenders = 0;
@@ -5056,12 +5141,6 @@ function mountWorkInProgressHook() {
5056
5141
  next: null
5057
5142
  };
5058
5143
 
5059
- {
5060
- hook._debugType = currentHookNameInDev;
5061
- if (currentlyRenderingFiber$1 !== null && currentlyRenderingFiber$1.alternate !== null) {
5062
- 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));
5063
- }
5064
- }
5065
5144
  if (workInProgressHook === null) {
5066
5145
  // This is the first hook in the list
5067
5146
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -5108,13 +5187,6 @@ function updateWorkInProgressHook() {
5108
5187
  workInProgressHook = workInProgressHook.next = newHook;
5109
5188
  }
5110
5189
  nextCurrentHook = currentHook.next;
5111
-
5112
- {
5113
- newHook._debugType = currentHookNameInDev;
5114
- if (currentHookNameInDev !== currentHook._debugType) {
5115
- warnOnHookMismatchInDev();
5116
- }
5117
- }
5118
5190
  }
5119
5191
  return workInProgressHook;
5120
5192
  }
@@ -5129,20 +5201,6 @@ function basicStateReducer(state, action) {
5129
5201
  return typeof action === 'function' ? action(state) : action;
5130
5202
  }
5131
5203
 
5132
- function mountContext(context, observedBits) {
5133
- {
5134
- mountWorkInProgressHook();
5135
- }
5136
- return readContext(context, observedBits);
5137
- }
5138
-
5139
- function updateContext(context, observedBits) {
5140
- {
5141
- updateWorkInProgressHook();
5142
- }
5143
- return readContext(context, observedBits);
5144
- }
5145
-
5146
5204
  function mountReducer(reducer, initialArg, init) {
5147
5205
  var hook = mountWorkInProgressHook();
5148
5206
  var initialState = void 0;
@@ -5195,7 +5253,6 @@ function updateReducer(reducer, initialArg, init) {
5195
5253
  }
5196
5254
 
5197
5255
  hook.memoizedState = newState;
5198
-
5199
5256
  // Don't persist the state accumlated from the render phase updates to
5200
5257
  // the base state unless the queue is empty.
5201
5258
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -5204,6 +5261,9 @@ function updateReducer(reducer, initialArg, init) {
5204
5261
  hook.baseState = newState;
5205
5262
  }
5206
5263
 
5264
+ queue.eagerReducer = reducer;
5265
+ queue.eagerState = newState;
5266
+
5207
5267
  return [newState, _dispatch];
5208
5268
  }
5209
5269
  }
@@ -5423,7 +5483,7 @@ function mountImperativeHandle(ref, create, deps) {
5423
5483
  }
5424
5484
 
5425
5485
  // TODO: If deps are provided, should we skip comparing the ref itself?
5426
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
5486
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
5427
5487
 
5428
5488
  return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
5429
5489
  }
@@ -5434,7 +5494,7 @@ function updateImperativeHandle(ref, create, deps) {
5434
5494
  }
5435
5495
 
5436
5496
  // TODO: If deps are provided, should we skip comparing the ref itself?
5437
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
5497
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
5438
5498
 
5439
5499
  return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
5440
5500
  }
@@ -5501,7 +5561,7 @@ function updateMemo(nextCreate, deps) {
5501
5561
  var shouldWarnForUnbatchedSetState = false;
5502
5562
 
5503
5563
  {
5504
- // jest isnt' a 'global', it's just exposed to tests via a wrapped function
5564
+ // jest isn't a 'global', it's just exposed to tests via a wrapped function
5505
5565
  // further, this isn't a test file, so flow doesn't recognize the symbol. So...
5506
5566
  // $FlowExpectedError - because requirements don't give a damn about your type sigs.
5507
5567
  if ('undefined' !== typeof jest) {
@@ -5633,6 +5693,7 @@ var ContextOnlyDispatcher = {
5633
5693
  };
5634
5694
 
5635
5695
  var HooksDispatcherOnMountInDEV = null;
5696
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
5636
5697
  var HooksDispatcherOnUpdateInDEV = null;
5637
5698
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
5638
5699
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -5652,26 +5713,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5652
5713
  },
5653
5714
  useCallback: function (callback, deps) {
5654
5715
  currentHookNameInDev = 'useCallback';
5716
+ mountHookTypesDev();
5717
+ return mountCallback(callback, deps);
5718
+ },
5719
+ useContext: function (context, observedBits) {
5720
+ currentHookNameInDev = 'useContext';
5721
+ mountHookTypesDev();
5722
+ return readContext(context, observedBits);
5723
+ },
5724
+ useEffect: function (create, deps) {
5725
+ currentHookNameInDev = 'useEffect';
5726
+ mountHookTypesDev();
5727
+ return mountEffect(create, deps);
5728
+ },
5729
+ useImperativeHandle: function (ref, create, deps) {
5730
+ currentHookNameInDev = 'useImperativeHandle';
5731
+ mountHookTypesDev();
5732
+ return mountImperativeHandle(ref, create, deps);
5733
+ },
5734
+ useLayoutEffect: function (create, deps) {
5735
+ currentHookNameInDev = 'useLayoutEffect';
5736
+ mountHookTypesDev();
5737
+ return mountLayoutEffect(create, deps);
5738
+ },
5739
+ useMemo: function (create, deps) {
5740
+ currentHookNameInDev = 'useMemo';
5741
+ mountHookTypesDev();
5742
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5743
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5744
+ try {
5745
+ return mountMemo(create, deps);
5746
+ } finally {
5747
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5748
+ }
5749
+ },
5750
+ useReducer: function (reducer, initialArg, init) {
5751
+ currentHookNameInDev = 'useReducer';
5752
+ mountHookTypesDev();
5753
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5754
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5755
+ try {
5756
+ return mountReducer(reducer, initialArg, init);
5757
+ } finally {
5758
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5759
+ }
5760
+ },
5761
+ useRef: function (initialValue) {
5762
+ currentHookNameInDev = 'useRef';
5763
+ mountHookTypesDev();
5764
+ return mountRef(initialValue);
5765
+ },
5766
+ useState: function (initialState) {
5767
+ currentHookNameInDev = 'useState';
5768
+ mountHookTypesDev();
5769
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5770
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5771
+ try {
5772
+ return mountState(initialState);
5773
+ } finally {
5774
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5775
+ }
5776
+ },
5777
+ useDebugValue: function (value, formatterFn) {
5778
+ currentHookNameInDev = 'useDebugValue';
5779
+ mountHookTypesDev();
5780
+ return mountDebugValue(value, formatterFn);
5781
+ }
5782
+ };
5783
+
5784
+ HooksDispatcherOnMountWithHookTypesInDEV = {
5785
+ readContext: function (context, observedBits) {
5786
+ return readContext(context, observedBits);
5787
+ },
5788
+ useCallback: function (callback, deps) {
5789
+ currentHookNameInDev = 'useCallback';
5790
+ updateHookTypesDev();
5655
5791
  return mountCallback(callback, deps);
5656
5792
  },
5657
5793
  useContext: function (context, observedBits) {
5658
5794
  currentHookNameInDev = 'useContext';
5659
- return mountContext(context, observedBits);
5795
+ updateHookTypesDev();
5796
+ return readContext(context, observedBits);
5660
5797
  },
5661
5798
  useEffect: function (create, deps) {
5662
5799
  currentHookNameInDev = 'useEffect';
5800
+ updateHookTypesDev();
5663
5801
  return mountEffect(create, deps);
5664
5802
  },
5665
5803
  useImperativeHandle: function (ref, create, deps) {
5666
5804
  currentHookNameInDev = 'useImperativeHandle';
5805
+ updateHookTypesDev();
5667
5806
  return mountImperativeHandle(ref, create, deps);
5668
5807
  },
5669
5808
  useLayoutEffect: function (create, deps) {
5670
5809
  currentHookNameInDev = 'useLayoutEffect';
5810
+ updateHookTypesDev();
5671
5811
  return mountLayoutEffect(create, deps);
5672
5812
  },
5673
5813
  useMemo: function (create, deps) {
5674
5814
  currentHookNameInDev = 'useMemo';
5815
+ updateHookTypesDev();
5675
5816
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5676
5817
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5677
5818
  try {
@@ -5682,6 +5823,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5682
5823
  },
5683
5824
  useReducer: function (reducer, initialArg, init) {
5684
5825
  currentHookNameInDev = 'useReducer';
5826
+ updateHookTypesDev();
5685
5827
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5686
5828
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5687
5829
  try {
@@ -5692,10 +5834,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5692
5834
  },
5693
5835
  useRef: function (initialValue) {
5694
5836
  currentHookNameInDev = 'useRef';
5837
+ updateHookTypesDev();
5695
5838
  return mountRef(initialValue);
5696
5839
  },
5697
5840
  useState: function (initialState) {
5698
5841
  currentHookNameInDev = 'useState';
5842
+ updateHookTypesDev();
5699
5843
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5700
5844
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5701
5845
  try {
@@ -5706,6 +5850,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5706
5850
  },
5707
5851
  useDebugValue: function (value, formatterFn) {
5708
5852
  currentHookNameInDev = 'useDebugValue';
5853
+ updateHookTypesDev();
5709
5854
  return mountDebugValue(value, formatterFn);
5710
5855
  }
5711
5856
  };
@@ -5716,26 +5861,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5716
5861
  },
5717
5862
  useCallback: function (callback, deps) {
5718
5863
  currentHookNameInDev = 'useCallback';
5864
+ updateHookTypesDev();
5719
5865
  return updateCallback(callback, deps);
5720
5866
  },
5721
5867
  useContext: function (context, observedBits) {
5722
5868
  currentHookNameInDev = 'useContext';
5723
- return updateContext(context, observedBits);
5869
+ updateHookTypesDev();
5870
+ return readContext(context, observedBits);
5724
5871
  },
5725
5872
  useEffect: function (create, deps) {
5726
5873
  currentHookNameInDev = 'useEffect';
5874
+ updateHookTypesDev();
5727
5875
  return updateEffect(create, deps);
5728
5876
  },
5729
5877
  useImperativeHandle: function (ref, create, deps) {
5730
5878
  currentHookNameInDev = 'useImperativeHandle';
5879
+ updateHookTypesDev();
5731
5880
  return updateImperativeHandle(ref, create, deps);
5732
5881
  },
5733
5882
  useLayoutEffect: function (create, deps) {
5734
5883
  currentHookNameInDev = 'useLayoutEffect';
5884
+ updateHookTypesDev();
5735
5885
  return updateLayoutEffect(create, deps);
5736
5886
  },
5737
5887
  useMemo: function (create, deps) {
5738
5888
  currentHookNameInDev = 'useMemo';
5889
+ updateHookTypesDev();
5739
5890
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5740
5891
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5741
5892
  try {
@@ -5746,6 +5897,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5746
5897
  },
5747
5898
  useReducer: function (reducer, initialArg, init) {
5748
5899
  currentHookNameInDev = 'useReducer';
5900
+ updateHookTypesDev();
5749
5901
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5750
5902
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5751
5903
  try {
@@ -5756,10 +5908,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5756
5908
  },
5757
5909
  useRef: function (initialValue) {
5758
5910
  currentHookNameInDev = 'useRef';
5911
+ updateHookTypesDev();
5759
5912
  return updateRef(initialValue);
5760
5913
  },
5761
5914
  useState: function (initialState) {
5762
5915
  currentHookNameInDev = 'useState';
5916
+ updateHookTypesDev();
5763
5917
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5764
5918
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5765
5919
  try {
@@ -5770,6 +5924,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5770
5924
  },
5771
5925
  useDebugValue: function (value, formatterFn) {
5772
5926
  currentHookNameInDev = 'useDebugValue';
5927
+ updateHookTypesDev();
5773
5928
  return updateDebugValue(value, formatterFn);
5774
5929
  }
5775
5930
  };
@@ -5782,31 +5937,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5782
5937
  useCallback: function (callback, deps) {
5783
5938
  currentHookNameInDev = 'useCallback';
5784
5939
  warnInvalidHookAccess();
5940
+ mountHookTypesDev();
5785
5941
  return mountCallback(callback, deps);
5786
5942
  },
5787
5943
  useContext: function (context, observedBits) {
5788
5944
  currentHookNameInDev = 'useContext';
5789
5945
  warnInvalidHookAccess();
5790
- return mountContext(context, observedBits);
5946
+ mountHookTypesDev();
5947
+ return readContext(context, observedBits);
5791
5948
  },
5792
5949
  useEffect: function (create, deps) {
5793
5950
  currentHookNameInDev = 'useEffect';
5794
5951
  warnInvalidHookAccess();
5952
+ mountHookTypesDev();
5795
5953
  return mountEffect(create, deps);
5796
5954
  },
5797
5955
  useImperativeHandle: function (ref, create, deps) {
5798
5956
  currentHookNameInDev = 'useImperativeHandle';
5799
5957
  warnInvalidHookAccess();
5958
+ mountHookTypesDev();
5800
5959
  return mountImperativeHandle(ref, create, deps);
5801
5960
  },
5802
5961
  useLayoutEffect: function (create, deps) {
5803
5962
  currentHookNameInDev = 'useLayoutEffect';
5804
5963
  warnInvalidHookAccess();
5964
+ mountHookTypesDev();
5805
5965
  return mountLayoutEffect(create, deps);
5806
5966
  },
5807
5967
  useMemo: function (create, deps) {
5808
5968
  currentHookNameInDev = 'useMemo';
5809
5969
  warnInvalidHookAccess();
5970
+ mountHookTypesDev();
5810
5971
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5811
5972
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5812
5973
  try {
@@ -5818,6 +5979,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5818
5979
  useReducer: function (reducer, initialArg, init) {
5819
5980
  currentHookNameInDev = 'useReducer';
5820
5981
  warnInvalidHookAccess();
5982
+ mountHookTypesDev();
5821
5983
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5822
5984
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5823
5985
  try {
@@ -5829,11 +5991,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5829
5991
  useRef: function (initialValue) {
5830
5992
  currentHookNameInDev = 'useRef';
5831
5993
  warnInvalidHookAccess();
5994
+ mountHookTypesDev();
5832
5995
  return mountRef(initialValue);
5833
5996
  },
5834
5997
  useState: function (initialState) {
5835
5998
  currentHookNameInDev = 'useState';
5836
5999
  warnInvalidHookAccess();
6000
+ mountHookTypesDev();
5837
6001
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5838
6002
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5839
6003
  try {
@@ -5845,6 +6009,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5845
6009
  useDebugValue: function (value, formatterFn) {
5846
6010
  currentHookNameInDev = 'useDebugValue';
5847
6011
  warnInvalidHookAccess();
6012
+ mountHookTypesDev();
5848
6013
  return mountDebugValue(value, formatterFn);
5849
6014
  }
5850
6015
  };
@@ -5857,31 +6022,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5857
6022
  useCallback: function (callback, deps) {
5858
6023
  currentHookNameInDev = 'useCallback';
5859
6024
  warnInvalidHookAccess();
6025
+ updateHookTypesDev();
5860
6026
  return updateCallback(callback, deps);
5861
6027
  },
5862
6028
  useContext: function (context, observedBits) {
5863
6029
  currentHookNameInDev = 'useContext';
5864
6030
  warnInvalidHookAccess();
5865
- return updateContext(context, observedBits);
6031
+ updateHookTypesDev();
6032
+ return readContext(context, observedBits);
5866
6033
  },
5867
6034
  useEffect: function (create, deps) {
5868
6035
  currentHookNameInDev = 'useEffect';
5869
6036
  warnInvalidHookAccess();
6037
+ updateHookTypesDev();
5870
6038
  return updateEffect(create, deps);
5871
6039
  },
5872
6040
  useImperativeHandle: function (ref, create, deps) {
5873
6041
  currentHookNameInDev = 'useImperativeHandle';
5874
6042
  warnInvalidHookAccess();
6043
+ updateHookTypesDev();
5875
6044
  return updateImperativeHandle(ref, create, deps);
5876
6045
  },
5877
6046
  useLayoutEffect: function (create, deps) {
5878
6047
  currentHookNameInDev = 'useLayoutEffect';
5879
6048
  warnInvalidHookAccess();
6049
+ updateHookTypesDev();
5880
6050
  return updateLayoutEffect(create, deps);
5881
6051
  },
5882
6052
  useMemo: function (create, deps) {
5883
6053
  currentHookNameInDev = 'useMemo';
5884
6054
  warnInvalidHookAccess();
6055
+ updateHookTypesDev();
5885
6056
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5886
6057
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5887
6058
  try {
@@ -5893,6 +6064,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5893
6064
  useReducer: function (reducer, initialArg, init) {
5894
6065
  currentHookNameInDev = 'useReducer';
5895
6066
  warnInvalidHookAccess();
6067
+ updateHookTypesDev();
5896
6068
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5897
6069
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5898
6070
  try {
@@ -5904,11 +6076,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5904
6076
  useRef: function (initialValue) {
5905
6077
  currentHookNameInDev = 'useRef';
5906
6078
  warnInvalidHookAccess();
6079
+ updateHookTypesDev();
5907
6080
  return updateRef(initialValue);
5908
6081
  },
5909
6082
  useState: function (initialState) {
5910
6083
  currentHookNameInDev = 'useState';
5911
6084
  warnInvalidHookAccess();
6085
+ updateHookTypesDev();
5912
6086
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5913
6087
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5914
6088
  try {
@@ -5920,6 +6094,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5920
6094
  useDebugValue: function (value, formatterFn) {
5921
6095
  currentHookNameInDev = 'useDebugValue';
5922
6096
  warnInvalidHookAccess();
6097
+ updateHookTypesDev();
5923
6098
  return updateDebugValue(value, formatterFn);
5924
6099
  }
5925
6100
  };
@@ -5991,6 +6166,18 @@ function enterHydrationState(fiber) {
5991
6166
  return true;
5992
6167
  }
5993
6168
 
6169
+ function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
6170
+ if (!supportsHydration) {
6171
+ return false;
6172
+ }
6173
+
6174
+ var suspenseInstance = fiber.stateNode;
6175
+ nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
6176
+ popToNextHostParent(fiber);
6177
+ isHydrating = true;
6178
+ return true;
6179
+ }
6180
+
5994
6181
  function deleteHydratableInstance(returnFiber, instance) {
5995
6182
  {
5996
6183
  switch (returnFiber.tag) {
@@ -6038,6 +6225,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
6038
6225
  var text = fiber.pendingProps;
6039
6226
  didNotFindHydratableContainerTextInstance(parentContainer, text);
6040
6227
  break;
6228
+ case SuspenseComponent:
6229
+ didNotFindHydratableContainerSuspenseInstance(parentContainer);
6230
+ break;
6041
6231
  }
6042
6232
  break;
6043
6233
  }
@@ -6056,6 +6246,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
6056
6246
  var _text = fiber.pendingProps;
6057
6247
  didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
6058
6248
  break;
6249
+ case SuspenseComponent:
6250
+ didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
6251
+ break;
6059
6252
  }
6060
6253
  break;
6061
6254
  }
@@ -6088,6 +6281,19 @@ function tryHydrate(fiber, nextInstance) {
6088
6281
  }
6089
6282
  return false;
6090
6283
  }
6284
+ case SuspenseComponent:
6285
+ {
6286
+ if (enableSuspenseServerRenderer) {
6287
+ var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
6288
+ if (suspenseInstance !== null) {
6289
+ // Downgrade the tag to a dehydrated component until we've hydrated it.
6290
+ fiber.tag = DehydratedSuspenseComponent;
6291
+ fiber.stateNode = suspenseInstance;
6292
+ return true;
6293
+ }
6294
+ }
6295
+ return false;
6296
+ }
6091
6297
  default:
6092
6298
  return false;
6093
6299
  }
@@ -6181,9 +6387,18 @@ function prepareToHydrateHostTextInstance(fiber) {
6181
6387
  return shouldUpdate;
6182
6388
  }
6183
6389
 
6390
+ function skipPastDehydratedSuspenseInstance(fiber) {
6391
+ if (!supportsHydration) {
6392
+ invariant(false, 'Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
6393
+ }
6394
+ var suspenseInstance = fiber.stateNode;
6395
+ !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;
6396
+ nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
6397
+ }
6398
+
6184
6399
  function popToNextHostParent(fiber) {
6185
6400
  var parent = fiber.return;
6186
- while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
6401
+ while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
6187
6402
  parent = parent.return;
6188
6403
  }
6189
6404
  hydrationParentFiber = parent;
@@ -6291,6 +6506,10 @@ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildre
6291
6506
  }
6292
6507
 
6293
6508
  function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
6509
+ // TODO: current can be non-null here even if the component
6510
+ // hasn't yet mounted. This happens after the first render suspends.
6511
+ // We'll need to figure out if this is fine or can cause issues.
6512
+
6294
6513
  {
6295
6514
  if (workInProgress.type !== workInProgress.elementType) {
6296
6515
  // Lazy component props can't be validated in createElement
@@ -6396,6 +6615,10 @@ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, u
6396
6615
  }
6397
6616
 
6398
6617
  function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
6618
+ // TODO: current can be non-null here even if the component
6619
+ // hasn't yet mounted. This happens when the inner render suspends.
6620
+ // We'll need to figure out if this is fine or can cause issues.
6621
+
6399
6622
  {
6400
6623
  if (workInProgress.type !== workInProgress.elementType) {
6401
6624
  // Lazy component props can't be validated in createElement
@@ -7019,6 +7242,18 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
7019
7242
  // children -- we skip over the primary children entirely.
7020
7243
  var next = void 0;
7021
7244
  if (current$$1 === null) {
7245
+ if (enableSuspenseServerRenderer) {
7246
+ // If we're currently hydrating, try to hydrate this boundary.
7247
+ // But only if this has a fallback.
7248
+ if (nextProps.fallback !== undefined) {
7249
+ tryToClaimNextHydratableInstance(workInProgress);
7250
+ // This could've changed the tag if this was a dehydrated suspense component.
7251
+ if (workInProgress.tag === DehydratedSuspenseComponent) {
7252
+ return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
7253
+ }
7254
+ }
7255
+ }
7256
+
7022
7257
  // This is the initial mount. This branch is pretty simple because there's
7023
7258
  // no previous state that needs to be preserved.
7024
7259
  if (nextDidTimeout) {
@@ -7170,6 +7405,65 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
7170
7405
  return next;
7171
7406
  }
7172
7407
 
7408
+ function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
7409
+ if (current$$1 === null) {
7410
+ // During the first pass, we'll bail out and not drill into the children.
7411
+ // Instead, we'll leave the content in place and try to hydrate it later.
7412
+ workInProgress.expirationTime = Never;
7413
+ return null;
7414
+ }
7415
+ // We use childExpirationTime to indicate that a child might depend on context, so if
7416
+ // any context has changed, we need to treat is as if the input might have changed.
7417
+ var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
7418
+ if (didReceiveUpdate || hasContextChanged$$1) {
7419
+ // This boundary has changed since the first render. This means that we are now unable to
7420
+ // hydrate it. We might still be able to hydrate it using an earlier expiration time but
7421
+ // during this render we can't. Instead, we're going to delete the whole subtree and
7422
+ // instead inject a new real Suspense boundary to take its place, which may render content
7423
+ // or fallback. The real Suspense boundary will suspend for a while so we have some time
7424
+ // to ensure it can produce real content, but all state and pending events will be lost.
7425
+
7426
+ // Detach from the current dehydrated boundary.
7427
+ current$$1.alternate = null;
7428
+ workInProgress.alternate = null;
7429
+
7430
+ // Insert a deletion in the effect list.
7431
+ var returnFiber = workInProgress.return;
7432
+ !(returnFiber !== null) ? invariant(false, 'Suspense boundaries are never on the root. This is probably a bug in React.') : void 0;
7433
+ var last = returnFiber.lastEffect;
7434
+ if (last !== null) {
7435
+ last.nextEffect = current$$1;
7436
+ returnFiber.lastEffect = current$$1;
7437
+ } else {
7438
+ returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
7439
+ }
7440
+ current$$1.nextEffect = null;
7441
+ current$$1.effectTag = Deletion;
7442
+
7443
+ // Upgrade this work in progress to a real Suspense component.
7444
+ workInProgress.tag = SuspenseComponent;
7445
+ workInProgress.stateNode = null;
7446
+ workInProgress.memoizedState = null;
7447
+ // This is now an insertion.
7448
+ workInProgress.effectTag |= Placement;
7449
+ // Retry as a real Suspense component.
7450
+ return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
7451
+ }
7452
+ if ((workInProgress.effectTag & DidCapture) === NoEffect) {
7453
+ // This is the first attempt.
7454
+ reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
7455
+ var nextProps = workInProgress.pendingProps;
7456
+ var nextChildren = nextProps.children;
7457
+ workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7458
+ return workInProgress.child;
7459
+ } else {
7460
+ // Something suspended. Leave the existing children in place.
7461
+ // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
7462
+ workInProgress.child = null;
7463
+ return null;
7464
+ }
7465
+ }
7466
+
7173
7467
  function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
7174
7468
  pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
7175
7469
  var nextChildren = workInProgress.pendingProps;
@@ -7381,6 +7675,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
7381
7675
  }
7382
7676
  break;
7383
7677
  }
7678
+ case DehydratedSuspenseComponent:
7679
+ {
7680
+ if (enableSuspenseServerRenderer) {
7681
+ // We know that this component will suspend again because if it has
7682
+ // been unsuspended it has committed as a regular Suspense component.
7683
+ // If it needs to be retried, it should have work scheduled on it.
7684
+ workInProgress.effectTag |= DidCapture;
7685
+ break;
7686
+ }
7687
+ }
7384
7688
  }
7385
7689
  return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7386
7690
  }
@@ -7472,9 +7776,15 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
7472
7776
  var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
7473
7777
  return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
7474
7778
  }
7475
- default:
7476
- invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
7779
+ case DehydratedSuspenseComponent:
7780
+ {
7781
+ if (enableSuspenseServerRenderer) {
7782
+ return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
7783
+ }
7784
+ break;
7785
+ }
7477
7786
  }
7787
+ invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
7478
7788
  }
7479
7789
 
7480
7790
  var valueCursor = createCursor(null);
@@ -7563,6 +7873,28 @@ function calculateChangedBits(context, newValue, oldValue) {
7563
7873
  }
7564
7874
  }
7565
7875
 
7876
+ function scheduleWorkOnParentPath(parent, renderExpirationTime) {
7877
+ // Update the child expiration time of all the ancestors, including
7878
+ // the alternates.
7879
+ var node = parent;
7880
+ while (node !== null) {
7881
+ var alternate = node.alternate;
7882
+ if (node.childExpirationTime < renderExpirationTime) {
7883
+ node.childExpirationTime = renderExpirationTime;
7884
+ if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
7885
+ alternate.childExpirationTime = renderExpirationTime;
7886
+ }
7887
+ } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
7888
+ alternate.childExpirationTime = renderExpirationTime;
7889
+ } else {
7890
+ // Neither alternate was updated, which means the rest of the
7891
+ // ancestor path already has sufficient priority.
7892
+ break;
7893
+ }
7894
+ node = node.return;
7895
+ }
7896
+ }
7897
+
7566
7898
  function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
7567
7899
  var fiber = workInProgress.child;
7568
7900
  if (fiber !== null) {
@@ -7601,25 +7933,8 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
7601
7933
  if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
7602
7934
  alternate.expirationTime = renderExpirationTime;
7603
7935
  }
7604
- // Update the child expiration time of all the ancestors, including
7605
- // the alternates.
7606
- var node = fiber.return;
7607
- while (node !== null) {
7608
- alternate = node.alternate;
7609
- if (node.childExpirationTime < renderExpirationTime) {
7610
- node.childExpirationTime = renderExpirationTime;
7611
- if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
7612
- alternate.childExpirationTime = renderExpirationTime;
7613
- }
7614
- } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
7615
- alternate.childExpirationTime = renderExpirationTime;
7616
- } else {
7617
- // Neither alternate was updated, which means the rest of the
7618
- // ancestor path already has sufficient priority.
7619
- break;
7620
- }
7621
- node = node.return;
7622
- }
7936
+
7937
+ scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
7623
7938
 
7624
7939
  // Mark the expiration time on the list, too.
7625
7940
  if (list.expirationTime < renderExpirationTime) {
@@ -7635,6 +7950,23 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
7635
7950
  } else if (fiber.tag === ContextProvider) {
7636
7951
  // Don't scan deeper if this is a matching provider
7637
7952
  nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
7953
+ } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
7954
+ // If a dehydrated suspense component is in this subtree, we don't know
7955
+ // if it will have any context consumers in it. The best we can do is
7956
+ // mark it as having updates on its children.
7957
+ if (fiber.expirationTime < renderExpirationTime) {
7958
+ fiber.expirationTime = renderExpirationTime;
7959
+ }
7960
+ var _alternate = fiber.alternate;
7961
+ if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
7962
+ _alternate.expirationTime = renderExpirationTime;
7963
+ }
7964
+ // This is intentionally passing this fiber as the parent
7965
+ // because we want to schedule this fiber as having work
7966
+ // on its children. We'll use the childExpirationTime on
7967
+ // this fiber to indicate that a context has changed.
7968
+ scheduleWorkOnParentPath(fiber, renderExpirationTime);
7969
+ nextFiber = fiber.sibling;
7638
7970
  } else {
7639
7971
  // Traverse down.
7640
7972
  nextFiber = fiber.child;
@@ -8758,6 +9090,26 @@ function completeWork(current, workInProgress, renderExpirationTime) {
8758
9090
  }
8759
9091
  break;
8760
9092
  }
9093
+ case DehydratedSuspenseComponent:
9094
+ {
9095
+ if (enableSuspenseServerRenderer) {
9096
+ if (current === null) {
9097
+ var _wasHydrated2 = popHydrationState(workInProgress);
9098
+ !_wasHydrated2 ? invariant(false, 'A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.') : void 0;
9099
+ skipPastDehydratedSuspenseInstance(workInProgress);
9100
+ } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
9101
+ // This boundary did not suspend so it's now hydrated.
9102
+ // To handle any future suspense cases, we're going to now upgrade it
9103
+ // to a Suspense component. We detach it from the existing current fiber.
9104
+ current.alternate = null;
9105
+ workInProgress.alternate = null;
9106
+ workInProgress.tag = SuspenseComponent;
9107
+ workInProgress.memoizedState = null;
9108
+ workInProgress.stateNode = null;
9109
+ }
9110
+ }
9111
+ break;
9112
+ }
8761
9113
  default:
8762
9114
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
8763
9115
  }
@@ -8848,7 +9200,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
8848
9200
  didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
8849
9201
  }
8850
9202
 
8851
- var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
9203
+ var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
8852
9204
 
8853
9205
  function logError(boundary, errorInfo) {
8854
9206
  var source = errorInfo.source;
@@ -9161,7 +9513,7 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
9161
9513
 
9162
9514
  function hideOrUnhideAllChildren(finishedWork, isHidden) {
9163
9515
  if (supportsMutation) {
9164
- // We only have the top Fiber that was inserted but we need recurse down its
9516
+ // We only have the top Fiber that was inserted but we need to recurse down its
9165
9517
  var node = finishedWork;
9166
9518
  while (true) {
9167
9519
  if (node.tag === HostComponent) {
@@ -9429,7 +9781,7 @@ function getHostSibling(fiber) {
9429
9781
  }
9430
9782
  node.sibling.return = node.return;
9431
9783
  node = node.sibling;
9432
- while (node.tag !== HostComponent && node.tag !== HostText) {
9784
+ while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
9433
9785
  // If it is not host node and, we might have a host node inside it.
9434
9786
  // Try to search down until we find one.
9435
9787
  if (node.effectTag & Placement) {
@@ -9487,7 +9839,7 @@ function commitPlacement(finishedWork) {
9487
9839
  }
9488
9840
 
9489
9841
  var before = getHostSibling(finishedWork);
9490
- // We only have the top Fiber that was inserted but we need recurse down its
9842
+ // We only have the top Fiber that was inserted but we need to recurse down its
9491
9843
  // children to find all the terminal nodes.
9492
9844
  var node = finishedWork;
9493
9845
  while (true) {
@@ -9529,7 +9881,7 @@ function commitPlacement(finishedWork) {
9529
9881
  }
9530
9882
 
9531
9883
  function unmountHostComponents(current$$1) {
9532
- // We only have the top Fiber that was deleted but we need recurse down its
9884
+ // We only have the top Fiber that was deleted but we need to recurse down its
9533
9885
  var node = current$$1;
9534
9886
 
9535
9887
  // Each iteration, currentParent is populated with node's host parent if not
@@ -9574,13 +9926,20 @@ function unmountHostComponents(current$$1) {
9574
9926
  removeChild(currentParent, node.stateNode);
9575
9927
  }
9576
9928
  // Don't visit children because we already visited them.
9929
+ } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
9930
+ // Delete the dehydrated suspense boundary and all of its content.
9931
+ if (currentParentIsContainer) {
9932
+ clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
9933
+ } else {
9934
+ clearSuspenseBoundary(currentParent, node.stateNode);
9935
+ }
9577
9936
  } else if (node.tag === HostPortal) {
9578
- // When we go into a portal, it becomes the parent to remove from.
9579
- // We will reassign it back when we pop the portal on the way up.
9580
- currentParent = node.stateNode.containerInfo;
9581
- currentParentIsContainer = true;
9582
- // Visit children because portals might contain host components.
9583
9937
  if (node.child !== null) {
9938
+ // When we go into a portal, it becomes the parent to remove from.
9939
+ // We will reassign it back when we pop the portal on the way up.
9940
+ currentParent = node.stateNode.containerInfo;
9941
+ currentParentIsContainer = true;
9942
+ // Visit children because portals might contain host components.
9584
9943
  node.child.return = node;
9585
9944
  node = node.child;
9586
9945
  continue;
@@ -9730,7 +10089,7 @@ function commitWork(current$$1, finishedWork) {
9730
10089
  finishedWork.updateQueue = null;
9731
10090
  var retryCache = finishedWork.stateNode;
9732
10091
  if (retryCache === null) {
9733
- retryCache = finishedWork.stateNode = new PossiblyWeakSet();
10092
+ retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
9734
10093
  }
9735
10094
  thenables.forEach(function (thenable) {
9736
10095
  // Memoize using the boundary fiber to prevent redundant listeners.
@@ -9765,6 +10124,7 @@ function commitResetTextContent(current$$1) {
9765
10124
  resetTextContent(current$$1.stateNode);
9766
10125
  }
9767
10126
 
10127
+ var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
9768
10128
  var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
9769
10129
 
9770
10130
  function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
@@ -9823,6 +10183,34 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
9823
10183
  return update;
9824
10184
  }
9825
10185
 
10186
+ function attachPingListener(root, renderExpirationTime, thenable) {
10187
+ // Attach a listener to the promise to "ping" the root and retry. But
10188
+ // only if one does not already exist for the current render expiration
10189
+ // time (which acts like a "thread ID" here).
10190
+ var pingCache = root.pingCache;
10191
+ var threadIDs = void 0;
10192
+ if (pingCache === null) {
10193
+ pingCache = root.pingCache = new PossiblyWeakMap();
10194
+ threadIDs = new Set();
10195
+ pingCache.set(thenable, threadIDs);
10196
+ } else {
10197
+ threadIDs = pingCache.get(thenable);
10198
+ if (threadIDs === undefined) {
10199
+ threadIDs = new Set();
10200
+ pingCache.set(thenable, threadIDs);
10201
+ }
10202
+ }
10203
+ if (!threadIDs.has(renderExpirationTime)) {
10204
+ // Memoize using the thread ID to prevent redundant listeners.
10205
+ threadIDs.add(renderExpirationTime);
10206
+ var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
10207
+ if (enableSchedulerTracing) {
10208
+ ping = tracing.unstable_wrap(ping);
10209
+ }
10210
+ thenable.then(ping, ping);
10211
+ }
10212
+ }
10213
+
9826
10214
  function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
9827
10215
  // The source fiber did not complete.
9828
10216
  sourceFiber.effectTag |= Incomplete;
@@ -9864,6 +10252,9 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
9864
10252
  }
9865
10253
  }
9866
10254
  }
10255
+ // If there is a DehydratedSuspenseComponent we don't have to do anything because
10256
+ // if something suspends inside it, we will simply leave that as dehydrated. It
10257
+ // will never timeout.
9867
10258
  _workInProgress = _workInProgress.return;
9868
10259
  } while (_workInProgress !== null);
9869
10260
 
@@ -9927,31 +10318,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
9927
10318
  // Confirmed that the boundary is in a concurrent mode tree. Continue
9928
10319
  // with the normal suspend path.
9929
10320
 
9930
- // Attach a listener to the promise to "ping" the root and retry. But
9931
- // only if one does not already exist for the current render expiration
9932
- // time (which acts like a "thread ID" here).
9933
- var pingCache = root.pingCache;
9934
- var threadIDs = void 0;
9935
- if (pingCache === null) {
9936
- pingCache = root.pingCache = new PossiblyWeakMap();
9937
- threadIDs = new Set();
9938
- pingCache.set(thenable, threadIDs);
9939
- } else {
9940
- threadIDs = pingCache.get(thenable);
9941
- if (threadIDs === undefined) {
9942
- threadIDs = new Set();
9943
- pingCache.set(thenable, threadIDs);
9944
- }
9945
- }
9946
- if (!threadIDs.has(renderExpirationTime)) {
9947
- // Memoize using the thread ID to prevent redundant listeners.
9948
- threadIDs.add(renderExpirationTime);
9949
- var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
9950
- if (enableSchedulerTracing) {
9951
- ping = tracing.unstable_wrap(ping);
9952
- }
9953
- thenable.then(ping, ping);
9954
- }
10321
+ attachPingListener(root, renderExpirationTime, thenable);
9955
10322
 
9956
10323
  var absoluteTimeoutMs = void 0;
9957
10324
  if (earliestTimeoutMs === -1) {
@@ -9983,6 +10350,29 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
9983
10350
  // whole tree.
9984
10351
  renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
9985
10352
 
10353
+ _workInProgress.effectTag |= ShouldCapture;
10354
+ _workInProgress.expirationTime = renderExpirationTime;
10355
+ return;
10356
+ } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
10357
+ attachPingListener(root, renderExpirationTime, thenable);
10358
+
10359
+ // Since we already have a current fiber, we can eagerly add a retry listener.
10360
+ var retryCache = _workInProgress.memoizedState;
10361
+ if (retryCache === null) {
10362
+ retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
10363
+ var _current = _workInProgress.alternate;
10364
+ !_current ? invariant(false, 'A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.') : void 0;
10365
+ _current.memoizedState = retryCache;
10366
+ }
10367
+ // Memoize using the boundary fiber to prevent redundant listeners.
10368
+ if (!retryCache.has(thenable)) {
10369
+ retryCache.add(thenable);
10370
+ var retry = retryTimedOutBoundary.bind(null, _workInProgress, thenable);
10371
+ if (enableSchedulerTracing) {
10372
+ retry = tracing.unstable_wrap(retry);
10373
+ }
10374
+ thenable.then(retry, retry);
10375
+ }
9986
10376
  _workInProgress.effectTag |= ShouldCapture;
9987
10377
  _workInProgress.expirationTime = renderExpirationTime;
9988
10378
  return;
@@ -10060,6 +10450,7 @@ function unwindWork(workInProgress, renderExpirationTime) {
10060
10450
  }
10061
10451
  case HostComponent:
10062
10452
  {
10453
+ // TODO: popHydrationState
10063
10454
  popHostContext(workInProgress);
10064
10455
  return null;
10065
10456
  }
@@ -10073,6 +10464,19 @@ function unwindWork(workInProgress, renderExpirationTime) {
10073
10464
  }
10074
10465
  return null;
10075
10466
  }
10467
+ case DehydratedSuspenseComponent:
10468
+ {
10469
+ if (enableSuspenseServerRenderer) {
10470
+ // TODO: popHydrationState
10471
+ var _effectTag3 = workInProgress.effectTag;
10472
+ if (_effectTag3 & ShouldCapture) {
10473
+ workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
10474
+ // Captured a suspense effect. Re-render the boundary.
10475
+ return workInProgress;
10476
+ }
10477
+ }
10478
+ return null;
10479
+ }
10076
10480
  case HostPortal:
10077
10481
  popHostContainer(workInProgress);
10078
10482
  return null;
@@ -10167,11 +10571,6 @@ if (enableSchedulerTracing) {
10167
10571
  };
10168
10572
  }
10169
10573
 
10170
- // Represents the expiration time that incoming updates should use. (If this
10171
- // is NoWork, use the default strategy: async updates in async mode, sync
10172
- // updates in sync mode.)
10173
- var expirationContext = NoWork;
10174
-
10175
10574
  var isWorking = false;
10176
10575
 
10177
10576
  // The next work in progress fiber that we're currently working on.
@@ -10467,6 +10866,10 @@ function commitPassiveEffects(root, firstEffect) {
10467
10866
  if (rootExpirationTime !== NoWork) {
10468
10867
  requestWork(root, rootExpirationTime);
10469
10868
  }
10869
+ // Flush any sync work that was scheduled by effects
10870
+ if (!isBatchingUpdates && !isRendering) {
10871
+ performSyncWork();
10872
+ }
10470
10873
  }
10471
10874
 
10472
10875
  function isAlreadyFailedLegacyErrorBoundary(instance) {
@@ -10641,7 +11044,9 @@ function commitRoot(root, finishedWork) {
10641
11044
  // here because that code is still in flux.
10642
11045
  callback = tracing.unstable_wrap(callback);
10643
11046
  }
10644
- passiveEffectCallbackHandle = schedulePassiveEffects(callback);
11047
+ passiveEffectCallbackHandle = scheduler.unstable_runWithPriority(scheduler.unstable_NormalPriority, function () {
11048
+ return schedulePassiveEffects(callback);
11049
+ });
10645
11050
  passiveEffectCallback = callback;
10646
11051
  }
10647
11052
 
@@ -11230,7 +11635,7 @@ function renderRoot(root, isYieldy) {
11230
11635
  return;
11231
11636
  } else if (
11232
11637
  // There's no lower priority work, but we're rendering asynchronously.
11233
- // Synchronsouly attempt to render the same level one more time. This is
11638
+ // Synchronously attempt to render the same level one more time. This is
11234
11639
  // similar to a suspend, but without a timeout because we're not waiting
11235
11640
  // for a promise to resolve.
11236
11641
  !root.didError && isYieldy) {
@@ -11321,41 +11726,46 @@ function computeThreadID(expirationTime, interactionThreadID) {
11321
11726
  }
11322
11727
 
11323
11728
  function computeExpirationForFiber(currentTime, fiber) {
11729
+ var priorityLevel = scheduler.unstable_getCurrentPriorityLevel();
11730
+
11324
11731
  var expirationTime = void 0;
11325
- if (expirationContext !== NoWork) {
11326
- // An explicit expiration context was set;
11327
- expirationTime = expirationContext;
11328
- } else if (isWorking) {
11329
- if (isCommitting$1) {
11330
- // Updates that occur during the commit phase should have sync priority
11331
- // by default.
11332
- expirationTime = Sync;
11333
- } else {
11334
- // Updates during the render phase should expire at the same time as
11335
- // the work that is being rendered.
11336
- expirationTime = nextRenderExpirationTime;
11337
- }
11732
+ if ((fiber.mode & ConcurrentMode) === NoContext) {
11733
+ // Outside of concurrent mode, updates are always synchronous.
11734
+ expirationTime = Sync;
11735
+ } else if (isWorking && !isCommitting$1) {
11736
+ // During render phase, updates expire during as the current render.
11737
+ expirationTime = nextRenderExpirationTime;
11338
11738
  } else {
11339
- // No explicit expiration context was set, and we're not currently
11340
- // performing work. Calculate a new expiration time.
11341
- if (fiber.mode & ConcurrentMode) {
11342
- if (isBatchingInteractiveUpdates) {
11343
- // This is an interactive update
11739
+ switch (priorityLevel) {
11740
+ case scheduler.unstable_ImmediatePriority:
11741
+ expirationTime = Sync;
11742
+ break;
11743
+ case scheduler.unstable_UserBlockingPriority:
11344
11744
  expirationTime = computeInteractiveExpiration(currentTime);
11345
- } else {
11346
- // This is an async update
11745
+ break;
11746
+ case scheduler.unstable_NormalPriority:
11747
+ // This is a normal, concurrent update
11347
11748
  expirationTime = computeAsyncExpiration(currentTime);
11348
- }
11349
- // If we're in the middle of rendering a tree, do not update at the same
11350
- // expiration time that is already rendering.
11351
- if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
11352
- expirationTime -= 1;
11353
- }
11354
- } else {
11355
- // This is a sync update
11356
- expirationTime = Sync;
11749
+ break;
11750
+ case scheduler.unstable_LowPriority:
11751
+ case scheduler.unstable_IdlePriority:
11752
+ expirationTime = Never;
11753
+ break;
11754
+ default:
11755
+ invariant(false, 'Unknown priority level. This error is likely caused by a bug in React. Please file an issue.');
11756
+ }
11757
+
11758
+ // If we're in the middle of rendering a tree, do not update at the same
11759
+ // expiration time that is already rendering.
11760
+ if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
11761
+ expirationTime -= 1;
11357
11762
  }
11358
11763
  }
11764
+
11765
+ // Keep track of the lowest pending interactive expiration time. This
11766
+ // allows us to synchronously flush all interactive updates
11767
+ // when needed.
11768
+ // TODO: Move this to renderer?
11359
11769
  return expirationTime;
11360
11770
  }
11361
11771
 
@@ -11402,7 +11812,21 @@ function retryTimedOutBoundary(boundaryFiber, thenable) {
11402
11812
  // The boundary fiber (a Suspense component) previously timed out and was
11403
11813
  // rendered in its fallback state. One of the promises that suspended it has
11404
11814
  // resolved, which means at least part of the tree was likely unblocked. Try
11405
- var retryCache = boundaryFiber.stateNode;
11815
+ var retryCache = void 0;
11816
+ if (enableSuspenseServerRenderer) {
11817
+ switch (boundaryFiber.tag) {
11818
+ case SuspenseComponent:
11819
+ retryCache = boundaryFiber.stateNode;
11820
+ break;
11821
+ case DehydratedSuspenseComponent:
11822
+ retryCache = boundaryFiber.memoizedState;
11823
+ break;
11824
+ default:
11825
+ invariant(false, 'Pinged unknown suspense boundary type. This is probably a bug in React.');
11826
+ }
11827
+ } else {
11828
+ retryCache = boundaryFiber.stateNode;
11829
+ }
11406
11830
  if (retryCache !== null) {
11407
11831
  // The thenable resolved, so we no longer need to memoize, because it will
11408
11832
  // never be thrown again.
@@ -11501,7 +11925,7 @@ function scheduleWorkToRoot(fiber, expirationTime) {
11501
11925
  function warnIfNotCurrentlyBatchingInDev(fiber) {
11502
11926
  {
11503
11927
  if (isRendering === false && isBatchingUpdates === false) {
11504
- 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));
11928
+ 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));
11505
11929
  }
11506
11930
  }
11507
11931
  }
@@ -11548,13 +11972,9 @@ function scheduleWork(fiber, expirationTime) {
11548
11972
  }
11549
11973
 
11550
11974
  function syncUpdates(fn, a, b, c, d) {
11551
- var previousExpirationContext = expirationContext;
11552
- expirationContext = Sync;
11553
- try {
11975
+ return scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
11554
11976
  return fn(a, b, c, d);
11555
- } finally {
11556
- expirationContext = previousExpirationContext;
11557
- }
11977
+ });
11558
11978
  }
11559
11979
 
11560
11980
  // TODO: Everything below this is written as if it has been lifted to the
@@ -11574,7 +11994,6 @@ var unhandledError = null;
11574
11994
 
11575
11995
  var isBatchingUpdates = false;
11576
11996
  var isUnbatchingUpdates = false;
11577
- var isBatchingInteractiveUpdates = false;
11578
11997
 
11579
11998
  var completedBatches = null;
11580
11999
 
@@ -12048,7 +12467,9 @@ function completeRoot(root, finishedWork, expirationTime) {
12048
12467
  lastCommittedRootDuringThisBatch = root;
12049
12468
  nestedUpdateCount = 0;
12050
12469
  }
12051
- commitRoot(root, finishedWork);
12470
+ scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
12471
+ commitRoot(root, finishedWork);
12472
+ });
12052
12473
  }
12053
12474
 
12054
12475
  function onUncaughtError(error) {
@@ -12256,7 +12677,7 @@ function injectIntoDevTools(devToolsConfig) {
12256
12677
 
12257
12678
  // TODO: this is special because it gets imported during build.
12258
12679
 
12259
- var ReactVersion = '16.8.0';
12680
+ var ReactVersion = '16.8.4';
12260
12681
 
12261
12682
  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; }; }();
12262
12683