react-dom 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.
Files changed (34) hide show
  1. package/build-info.json +5 -5
  2. package/cjs/react-dom-server.browser.development.js +74 -34
  3. package/cjs/react-dom-server.browser.production.min.js +35 -33
  4. package/cjs/react-dom-server.node.development.js +74 -34
  5. package/cjs/react-dom-server.node.production.min.js +36 -34
  6. package/cjs/react-dom-test-utils.development.js +23 -5
  7. package/cjs/react-dom-test-utils.production.min.js +23 -23
  8. package/cjs/react-dom-unstable-fire.development.js +698 -204
  9. package/cjs/react-dom-unstable-fire.production.min.js +252 -251
  10. package/cjs/react-dom-unstable-fire.profiling.min.js +179 -177
  11. package/cjs/react-dom-unstable-fizz.browser.development.js +1 -1
  12. package/cjs/react-dom-unstable-fizz.browser.production.min.js +1 -1
  13. package/cjs/react-dom-unstable-fizz.node.development.js +1 -1
  14. package/cjs/react-dom-unstable-fizz.node.production.min.js +1 -1
  15. package/cjs/react-dom-unstable-native-dependencies.development.js +2 -2
  16. package/cjs/react-dom-unstable-native-dependencies.production.min.js +1 -1
  17. package/cjs/react-dom.development.js +698 -204
  18. package/cjs/react-dom.production.min.js +252 -251
  19. package/cjs/react-dom.profiling.min.js +179 -177
  20. package/package.json +2 -2
  21. package/umd/react-dom-server.browser.development.js +74 -34
  22. package/umd/react-dom-server.browser.production.min.js +22 -21
  23. package/umd/react-dom-test-utils.development.js +23 -5
  24. package/umd/react-dom-test-utils.production.min.js +22 -21
  25. package/umd/react-dom-unstable-fire.development.js +706 -204
  26. package/umd/react-dom-unstable-fire.production.min.js +208 -207
  27. package/umd/react-dom-unstable-fire.profiling.min.js +208 -207
  28. package/umd/react-dom-unstable-fizz.browser.development.js +1 -1
  29. package/umd/react-dom-unstable-fizz.browser.production.min.js +1 -1
  30. package/umd/react-dom-unstable-native-dependencies.development.js +2 -2
  31. package/umd/react-dom-unstable-native-dependencies.production.min.js +1 -1
  32. package/umd/react-dom.development.js +706 -204
  33. package/umd/react-dom.production.min.js +208 -207
  34. package/umd/react-dom.profiling.min.js +208 -207
@@ -1,4 +1,4 @@
1
- /** @license React v16.8.0
1
+ /** @license React v16.8.4
2
2
  * react-dom-unstable-fire.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -85,7 +85,7 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
85
85
  // invokeGuardedCallback uses a try-catch, all user exceptions are treated
86
86
  // like caught exceptions, and the DevTools won't pause unless the developer
87
87
  // takes the extra step of enabling pause on caught exceptions. This is
88
- // untintuitive, though, because even though React has caught the error, from
88
+ // unintuitive, though, because even though React has caught the error, from
89
89
  // the developer's perspective, the error is uncaught.
90
90
  //
91
91
  // To preserve the expected "Pause on exceptions" behavior, we don't use a
@@ -842,6 +842,7 @@ var MemoComponent = 14;
842
842
  var SimpleMemoComponent = 15;
843
843
  var LazyComponent = 16;
844
844
  var IncompleteClassComponent = 17;
845
+ var DehydratedSuspenseComponent = 18;
845
846
 
846
847
  var randomKey = Math.random().toString(36).slice(2);
847
848
  var internalInstanceKey = '__reactInternalInstance$' + randomKey;
@@ -2384,6 +2385,15 @@ function updateValueIfChanged(node) {
2384
2385
 
2385
2386
  var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2386
2387
 
2388
+ // Prevent newer renderers from RTE when used with older react package versions.
2389
+ // Current owner and dispatcher used to share the same ref,
2390
+ // but PR #14548 split them out to better support the react-debug-tools package.
2391
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
2392
+ ReactSharedInternals.ReactCurrentDispatcher = {
2393
+ current: null
2394
+ };
2395
+ }
2396
+
2387
2397
  var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
2388
2398
 
2389
2399
  var describeComponentFrame = function (name, source, ownerName) {
@@ -2894,12 +2904,15 @@ var capitalize = function (token) {
2894
2904
  attributeName, 'http://www.w3.org/XML/1998/namespace');
2895
2905
  });
2896
2906
 
2897
- // Special case: this attribute exists both in HTML and SVG.
2898
- // Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
2899
- // its React `tabIndex` name, like we do for attributes that exist only in HTML.
2900
- properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty
2901
- 'tabindex', // attributeName
2902
- null);
2907
+ // These attribute exists both in HTML and SVG.
2908
+ // The attribute name is case-sensitive in SVG so we can't just use
2909
+ // the React name like we do for attributes that exist only in HTML.
2910
+ ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
2911
+ properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
2912
+ attributeName.toLowerCase(), // attributeName
2913
+ null);
2914
+ } // attributeNamespace
2915
+ );
2903
2916
 
2904
2917
  /**
2905
2918
  * Get the value for a property on a node. Only used in DEV for SSR validation.
@@ -3138,7 +3151,7 @@ var enableProfilerTimer = true;
3138
3151
  var enableSchedulerTracing = true;
3139
3152
 
3140
3153
  // Only used in www builds.
3141
- // TODO: true? Here it might just be false.
3154
+ var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
3142
3155
 
3143
3156
  // Only used in www builds.
3144
3157
 
@@ -8613,6 +8626,9 @@ var SUPPRESS_HYDRATION_WARNING = void 0;
8613
8626
  SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
8614
8627
  }
8615
8628
 
8629
+ var SUSPENSE_START_DATA = '$';
8630
+ var SUSPENSE_END_DATA = '/$';
8631
+
8616
8632
  var STYLE = 'style';
8617
8633
 
8618
8634
  var eventsEnabled = null;
@@ -8841,6 +8857,43 @@ function removeChildFromContainer(container, child) {
8841
8857
  }
8842
8858
  }
8843
8859
 
8860
+ function clearSuspenseBoundary(parentInstance, suspenseInstance) {
8861
+ var node = suspenseInstance;
8862
+ // Delete all nodes within this suspense boundary.
8863
+ // There might be nested nodes so we need to keep track of how
8864
+ // deep we are and only break out when we're back on top.
8865
+ var depth = 0;
8866
+ do {
8867
+ var nextNode = node.nextSibling;
8868
+ parentInstance.removeChild(node);
8869
+ if (nextNode && nextNode.nodeType === COMMENT_NODE) {
8870
+ var data = nextNode.data;
8871
+ if (data === SUSPENSE_END_DATA) {
8872
+ if (depth === 0) {
8873
+ parentInstance.removeChild(nextNode);
8874
+ return;
8875
+ } else {
8876
+ depth--;
8877
+ }
8878
+ } else if (data === SUSPENSE_START_DATA) {
8879
+ depth++;
8880
+ }
8881
+ }
8882
+ node = nextNode;
8883
+ } while (node);
8884
+ // TODO: Warn, we didn't find the end comment boundary.
8885
+ }
8886
+
8887
+ function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
8888
+ if (container.nodeType === COMMENT_NODE) {
8889
+ clearSuspenseBoundary(container.parentNode, suspenseInstance);
8890
+ } else if (container.nodeType === ELEMENT_NODE) {
8891
+ clearSuspenseBoundary(container, suspenseInstance);
8892
+ } else {
8893
+ // Document nodes should never contain suspense boundaries.
8894
+ }
8895
+ }
8896
+
8844
8897
  function hideInstance(instance) {
8845
8898
  // TODO: Does this work for all element types? What about MathML? Should we
8846
8899
  // pass host context to this method?
@@ -8886,10 +8939,19 @@ function canHydrateTextInstance(instance, text) {
8886
8939
  return instance;
8887
8940
  }
8888
8941
 
8942
+ function canHydrateSuspenseInstance(instance) {
8943
+ if (instance.nodeType !== COMMENT_NODE) {
8944
+ // Empty strings are not parsed by HTML so there won't be a correct match here.
8945
+ return null;
8946
+ }
8947
+ // This has now been refined to a suspense node.
8948
+ return instance;
8949
+ }
8950
+
8889
8951
  function getNextHydratableSibling(instance) {
8890
8952
  var node = instance.nextSibling;
8891
8953
  // Skip non-hydratable nodes.
8892
- while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) {
8954
+ while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || node.nodeType !== COMMENT_NODE || node.data !== SUSPENSE_START_DATA)) {
8893
8955
  node = node.nextSibling;
8894
8956
  }
8895
8957
  return node;
@@ -8898,7 +8960,7 @@ function getNextHydratableSibling(instance) {
8898
8960
  function getFirstHydratableChild(parentInstance) {
8899
8961
  var next = parentInstance.firstChild;
8900
8962
  // Skip non-hydratable nodes.
8901
- while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) {
8963
+ while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || next.nodeType !== COMMENT_NODE || next.data !== SUSPENSE_START_DATA)) {
8902
8964
  next = next.nextSibling;
8903
8965
  }
8904
8966
  return next;
@@ -8922,6 +8984,31 @@ function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
8922
8984
  return diffHydratedText(textInstance, text);
8923
8985
  }
8924
8986
 
8987
+ function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
8988
+ var node = suspenseInstance.nextSibling;
8989
+ // Skip past all nodes within this suspense boundary.
8990
+ // There might be nested nodes so we need to keep track of how
8991
+ // deep we are and only break out when we're back on top.
8992
+ var depth = 0;
8993
+ while (node) {
8994
+ if (node.nodeType === COMMENT_NODE) {
8995
+ var data = node.data;
8996
+ if (data === SUSPENSE_END_DATA) {
8997
+ if (depth === 0) {
8998
+ return getNextHydratableSibling(node);
8999
+ } else {
9000
+ depth--;
9001
+ }
9002
+ } else if (data === SUSPENSE_START_DATA) {
9003
+ depth++;
9004
+ }
9005
+ }
9006
+ node = node.nextSibling;
9007
+ }
9008
+ // TODO: Warn, we didn't find the end comment boundary.
9009
+ return null;
9010
+ }
9011
+
8925
9012
  function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
8926
9013
  {
8927
9014
  warnForUnmatchedText(textInstance, text);
@@ -8938,6 +9025,8 @@ function didNotHydrateContainerInstance(parentContainer, instance) {
8938
9025
  {
8939
9026
  if (instance.nodeType === ELEMENT_NODE) {
8940
9027
  warnForDeletedHydratableElement(parentContainer, instance);
9028
+ } else if (instance.nodeType === COMMENT_NODE) {
9029
+ // TODO: warnForDeletedHydratableSuspenseBoundary
8941
9030
  } else {
8942
9031
  warnForDeletedHydratableText(parentContainer, instance);
8943
9032
  }
@@ -8948,6 +9037,8 @@ function didNotHydrateInstance(parentType, parentProps, parentInstance, instance
8948
9037
  if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
8949
9038
  if (instance.nodeType === ELEMENT_NODE) {
8950
9039
  warnForDeletedHydratableElement(parentInstance, instance);
9040
+ } else if (instance.nodeType === COMMENT_NODE) {
9041
+ // TODO: warnForDeletedHydratableSuspenseBoundary
8951
9042
  } else {
8952
9043
  warnForDeletedHydratableText(parentInstance, instance);
8953
9044
  }
@@ -8966,6 +9057,8 @@ function didNotFindHydratableContainerTextInstance(parentContainer, text) {
8966
9057
  }
8967
9058
  }
8968
9059
 
9060
+
9061
+
8969
9062
  function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
8970
9063
  if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
8971
9064
  warnForInsertedHydratedElement(parentInstance, type, props);
@@ -8978,6 +9071,12 @@ function didNotFindHydratableTextInstance(parentType, parentProps, parentInstanc
8978
9071
  }
8979
9072
  }
8980
9073
 
9074
+ function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
9075
+ if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
9076
+ // TODO: warnForInsertedHydratedSuspense(parentInstance);
9077
+ }
9078
+ }
9079
+
8981
9080
  // This is just to get the setup running.
8982
9081
  // TODO: real implementation.
8983
9082
  // console.log('Hello from Fire host config.');
@@ -9237,7 +9336,7 @@ function stopFailedWorkTimer(fiber) {
9237
9336
  return;
9238
9337
  }
9239
9338
  fiber._debugIsCurrentlyTiming = false;
9240
- var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
9339
+ var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
9241
9340
  endFiberMark(fiber, null, warning);
9242
9341
  }
9243
9342
  }
@@ -9906,6 +10005,7 @@ function FiberNode(tag, pendingProps, key, mode) {
9906
10005
  this._debugSource = null;
9907
10006
  this._debugOwner = null;
9908
10007
  this._debugIsCurrentlyTiming = false;
10008
+ this._debugHookTypes = null;
9909
10009
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
9910
10010
  Object.preventExtensions(this);
9911
10011
  }
@@ -9973,6 +10073,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
9973
10073
  workInProgress._debugID = current._debugID;
9974
10074
  workInProgress._debugSource = current._debugSource;
9975
10075
  workInProgress._debugOwner = current._debugOwner;
10076
+ workInProgress._debugHookTypes = current._debugHookTypes;
9976
10077
  }
9977
10078
 
9978
10079
  workInProgress.alternate = current;
@@ -10240,6 +10341,7 @@ function assignFiberPropertiesInDEV(target, source) {
10240
10341
  target._debugSource = source._debugSource;
10241
10342
  target._debugOwner = source._debugOwner;
10242
10343
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
10344
+ target._debugHookTypes = source._debugHookTypes;
10243
10345
  return target;
10244
10346
  }
10245
10347
 
@@ -12044,7 +12146,7 @@ function ChildReconciler(shouldTrackSideEffects) {
12044
12146
  }
12045
12147
 
12046
12148
  function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
12047
- // This algorithm can't optimize by searching from boths ends since we
12149
+ // This algorithm can't optimize by searching from both ends since we
12048
12150
  // don't have backpointers on fibers. I'm trying to see how far we can get
12049
12151
  // with that model. If it ends up not being worth the tradeoffs, we can
12050
12152
  // add it later.
@@ -12625,7 +12727,6 @@ var currentlyRenderingFiber$1 = null;
12625
12727
  // current hook list is the list that belongs to the current fiber. The
12626
12728
  // work-in-progress hook list is a new list that will be added to the
12627
12729
  // work-in-progress fiber.
12628
- var firstCurrentHook = null;
12629
12730
  var currentHook = null;
12630
12731
  var nextCurrentHook = null;
12631
12732
  var firstWorkInProgressHook = null;
@@ -12655,39 +12756,67 @@ var RE_RENDER_LIMIT = 25;
12655
12756
  // In DEV, this is the name of the currently executing primitive hook
12656
12757
  var currentHookNameInDev = null;
12657
12758
 
12658
- function warnOnHookMismatchInDev() {
12759
+ // In DEV, this list ensures that hooks are called in the same order between renders.
12760
+ // The list stores the order of hooks used during the initial render (mount).
12761
+ // Subsequent renders (updates) reference this list.
12762
+ var hookTypesDev = null;
12763
+ var hookTypesUpdateIndexDev = -1;
12764
+
12765
+ function mountHookTypesDev() {
12766
+ {
12767
+ var hookName = currentHookNameInDev;
12768
+
12769
+ if (hookTypesDev === null) {
12770
+ hookTypesDev = [hookName];
12771
+ } else {
12772
+ hookTypesDev.push(hookName);
12773
+ }
12774
+ }
12775
+ }
12776
+
12777
+ function updateHookTypesDev() {
12778
+ {
12779
+ var hookName = currentHookNameInDev;
12780
+
12781
+ if (hookTypesDev !== null) {
12782
+ hookTypesUpdateIndexDev++;
12783
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
12784
+ warnOnHookMismatchInDev(hookName);
12785
+ }
12786
+ }
12787
+ }
12788
+ }
12789
+
12790
+ function warnOnHookMismatchInDev(currentHookName) {
12659
12791
  {
12660
12792
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
12661
12793
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
12662
12794
  didWarnAboutMismatchedHooksForComponent.add(componentName);
12663
12795
 
12664
- var secondColumnStart = 22;
12796
+ if (hookTypesDev !== null) {
12797
+ var table = '';
12665
12798
 
12666
- var table = '';
12667
- var prevHook = firstCurrentHook;
12668
- var nextHook = firstWorkInProgressHook;
12669
- var n = 1;
12670
- while (prevHook !== null && nextHook !== null) {
12671
- var oldHookName = prevHook._debugType;
12672
- var newHookName = nextHook._debugType;
12799
+ var secondColumnStart = 30;
12673
12800
 
12674
- var row = n + '. ' + oldHookName;
12801
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
12802
+ var oldHookName = hookTypesDev[i];
12803
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
12675
12804
 
12676
- // Extra space so second column lines up
12677
- // lol @ IE not supporting String#repeat
12678
- while (row.length < secondColumnStart) {
12679
- row += ' ';
12680
- }
12805
+ var row = i + 1 + '. ' + oldHookName;
12681
12806
 
12682
- row += newHookName + '\n';
12807
+ // Extra space so second column lines up
12808
+ // lol @ IE not supporting String#repeat
12809
+ while (row.length < secondColumnStart) {
12810
+ row += ' ';
12811
+ }
12683
12812
 
12684
- table += row;
12685
- prevHook = prevHook.next;
12686
- nextHook = nextHook.next;
12687
- n++;
12688
- }
12813
+ row += newHookName + '\n';
12689
12814
 
12690
- 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);
12815
+ table += row;
12816
+ }
12817
+
12818
+ 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);
12819
+ }
12691
12820
  }
12692
12821
  }
12693
12822
  }
@@ -12723,7 +12852,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
12723
12852
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
12724
12853
  renderExpirationTime = nextRenderExpirationTime;
12725
12854
  currentlyRenderingFiber$1 = workInProgress;
12726
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
12855
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12856
+
12857
+ {
12858
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
12859
+ hookTypesUpdateIndexDev = -1;
12860
+ }
12727
12861
 
12728
12862
  // The following should have already been reset
12729
12863
  // currentHook = null;
@@ -12737,8 +12871,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12737
12871
  // numberOfReRenders = 0;
12738
12872
  // sideEffectTag = 0;
12739
12873
 
12874
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
12875
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
12876
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
12877
+
12878
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
12879
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
12880
+ // so nextCurrentHook would be null during updates and mounts.
12740
12881
  {
12741
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
12882
+ if (nextCurrentHook !== null) {
12883
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12884
+ } else if (hookTypesDev !== null) {
12885
+ // This dispatcher handles an edge case where a component is updating,
12886
+ // but no stateful hooks have been used.
12887
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
12888
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
12889
+ // This dispatcher does that.
12890
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
12891
+ } else {
12892
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
12893
+ }
12742
12894
  }
12743
12895
 
12744
12896
  var children = Component(props, refOrContext);
@@ -12749,13 +12901,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12749
12901
  numberOfReRenders += 1;
12750
12902
 
12751
12903
  // Start over from the beginning of the list
12752
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
12904
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12753
12905
  nextWorkInProgressHook = firstWorkInProgressHook;
12754
12906
 
12755
12907
  currentHook = null;
12756
12908
  workInProgressHook = null;
12757
12909
  componentUpdateQueue = null;
12758
12910
 
12911
+ {
12912
+ // Also validate hook order for cascading updates.
12913
+ hookTypesUpdateIndexDev = -1;
12914
+ }
12915
+
12759
12916
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12760
12917
 
12761
12918
  children = Component(props, refOrContext);
@@ -12765,10 +12922,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12765
12922
  numberOfReRenders = 0;
12766
12923
  }
12767
12924
 
12768
- {
12769
- currentHookNameInDev = null;
12770
- }
12771
-
12772
12925
  // We can assume the previous dispatcher is always this one, since we set it
12773
12926
  // at the beginning of the render phase and there's no re-entrancy.
12774
12927
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -12780,18 +12933,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12780
12933
  renderedWork.updateQueue = componentUpdateQueue;
12781
12934
  renderedWork.effectTag |= sideEffectTag;
12782
12935
 
12936
+ {
12937
+ renderedWork._debugHookTypes = hookTypesDev;
12938
+ }
12939
+
12940
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
12941
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
12783
12942
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
12784
12943
 
12785
12944
  renderExpirationTime = NoWork;
12786
12945
  currentlyRenderingFiber$1 = null;
12787
12946
 
12788
- firstCurrentHook = null;
12789
12947
  currentHook = null;
12790
12948
  nextCurrentHook = null;
12791
12949
  firstWorkInProgressHook = null;
12792
12950
  workInProgressHook = null;
12793
12951
  nextWorkInProgressHook = null;
12794
12952
 
12953
+ {
12954
+ currentHookNameInDev = null;
12955
+ hookTypesDev = null;
12956
+ hookTypesUpdateIndexDev = -1;
12957
+ }
12958
+
12795
12959
  remainingExpirationTime = NoWork;
12796
12960
  componentUpdateQueue = null;
12797
12961
  sideEffectTag = 0;
@@ -12825,21 +12989,23 @@ function resetHooks() {
12825
12989
  renderExpirationTime = NoWork;
12826
12990
  currentlyRenderingFiber$1 = null;
12827
12991
 
12828
- firstCurrentHook = null;
12829
12992
  currentHook = null;
12830
12993
  nextCurrentHook = null;
12831
12994
  firstWorkInProgressHook = null;
12832
12995
  workInProgressHook = null;
12833
12996
  nextWorkInProgressHook = null;
12834
12997
 
12835
- remainingExpirationTime = NoWork;
12836
- componentUpdateQueue = null;
12837
- sideEffectTag = 0;
12838
-
12839
12998
  {
12999
+ hookTypesDev = null;
13000
+ hookTypesUpdateIndexDev = -1;
13001
+
12840
13002
  currentHookNameInDev = null;
12841
13003
  }
12842
13004
 
13005
+ remainingExpirationTime = NoWork;
13006
+ componentUpdateQueue = null;
13007
+ sideEffectTag = 0;
13008
+
12843
13009
  didScheduleRenderPhaseUpdate = false;
12844
13010
  renderPhaseUpdates = null;
12845
13011
  numberOfReRenders = 0;
@@ -12856,12 +13022,6 @@ function mountWorkInProgressHook() {
12856
13022
  next: null
12857
13023
  };
12858
13024
 
12859
- {
12860
- hook._debugType = currentHookNameInDev;
12861
- if (currentlyRenderingFiber$1 !== null && currentlyRenderingFiber$1.alternate !== null) {
12862
- 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));
12863
- }
12864
- }
12865
13025
  if (workInProgressHook === null) {
12866
13026
  // This is the first hook in the list
12867
13027
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -12908,13 +13068,6 @@ function updateWorkInProgressHook() {
12908
13068
  workInProgressHook = workInProgressHook.next = newHook;
12909
13069
  }
12910
13070
  nextCurrentHook = currentHook.next;
12911
-
12912
- {
12913
- newHook._debugType = currentHookNameInDev;
12914
- if (currentHookNameInDev !== currentHook._debugType) {
12915
- warnOnHookMismatchInDev();
12916
- }
12917
- }
12918
13071
  }
12919
13072
  return workInProgressHook;
12920
13073
  }
@@ -12929,20 +13082,6 @@ function basicStateReducer(state, action) {
12929
13082
  return typeof action === 'function' ? action(state) : action;
12930
13083
  }
12931
13084
 
12932
- function mountContext(context, observedBits) {
12933
- {
12934
- mountWorkInProgressHook();
12935
- }
12936
- return readContext(context, observedBits);
12937
- }
12938
-
12939
- function updateContext(context, observedBits) {
12940
- {
12941
- updateWorkInProgressHook();
12942
- }
12943
- return readContext(context, observedBits);
12944
- }
12945
-
12946
13085
  function mountReducer(reducer, initialArg, init) {
12947
13086
  var hook = mountWorkInProgressHook();
12948
13087
  var initialState = void 0;
@@ -12995,7 +13134,6 @@ function updateReducer(reducer, initialArg, init) {
12995
13134
  }
12996
13135
 
12997
13136
  hook.memoizedState = newState;
12998
-
12999
13137
  // Don't persist the state accumlated from the render phase updates to
13000
13138
  // the base state unless the queue is empty.
13001
13139
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -13004,6 +13142,9 @@ function updateReducer(reducer, initialArg, init) {
13004
13142
  hook.baseState = newState;
13005
13143
  }
13006
13144
 
13145
+ queue.eagerReducer = reducer;
13146
+ queue.eagerState = newState;
13147
+
13007
13148
  return [newState, _dispatch];
13008
13149
  }
13009
13150
  }
@@ -13223,7 +13364,7 @@ function mountImperativeHandle(ref, create, deps) {
13223
13364
  }
13224
13365
 
13225
13366
  // TODO: If deps are provided, should we skip comparing the ref itself?
13226
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
13367
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
13227
13368
 
13228
13369
  return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
13229
13370
  }
@@ -13234,7 +13375,7 @@ function updateImperativeHandle(ref, create, deps) {
13234
13375
  }
13235
13376
 
13236
13377
  // TODO: If deps are provided, should we skip comparing the ref itself?
13237
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
13378
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
13238
13379
 
13239
13380
  return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
13240
13381
  }
@@ -13301,7 +13442,7 @@ function updateMemo(nextCreate, deps) {
13301
13442
  var shouldWarnForUnbatchedSetState = false;
13302
13443
 
13303
13444
  {
13304
- // jest isnt' a 'global', it's just exposed to tests via a wrapped function
13445
+ // jest isn't a 'global', it's just exposed to tests via a wrapped function
13305
13446
  // further, this isn't a test file, so flow doesn't recognize the symbol. So...
13306
13447
  // $FlowExpectedError - because requirements don't give a damn about your type sigs.
13307
13448
  if ('undefined' !== typeof jest) {
@@ -13433,6 +13574,7 @@ var ContextOnlyDispatcher = {
13433
13574
  };
13434
13575
 
13435
13576
  var HooksDispatcherOnMountInDEV = null;
13577
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
13436
13578
  var HooksDispatcherOnUpdateInDEV = null;
13437
13579
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
13438
13580
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -13452,26 +13594,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13452
13594
  },
13453
13595
  useCallback: function (callback, deps) {
13454
13596
  currentHookNameInDev = 'useCallback';
13597
+ mountHookTypesDev();
13455
13598
  return mountCallback(callback, deps);
13456
13599
  },
13457
13600
  useContext: function (context, observedBits) {
13458
13601
  currentHookNameInDev = 'useContext';
13459
- return mountContext(context, observedBits);
13602
+ mountHookTypesDev();
13603
+ return readContext(context, observedBits);
13460
13604
  },
13461
13605
  useEffect: function (create, deps) {
13462
13606
  currentHookNameInDev = 'useEffect';
13607
+ mountHookTypesDev();
13463
13608
  return mountEffect(create, deps);
13464
13609
  },
13465
13610
  useImperativeHandle: function (ref, create, deps) {
13466
13611
  currentHookNameInDev = 'useImperativeHandle';
13612
+ mountHookTypesDev();
13467
13613
  return mountImperativeHandle(ref, create, deps);
13468
13614
  },
13469
13615
  useLayoutEffect: function (create, deps) {
13470
13616
  currentHookNameInDev = 'useLayoutEffect';
13617
+ mountHookTypesDev();
13471
13618
  return mountLayoutEffect(create, deps);
13472
13619
  },
13473
13620
  useMemo: function (create, deps) {
13474
13621
  currentHookNameInDev = 'useMemo';
13622
+ mountHookTypesDev();
13475
13623
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13476
13624
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13477
13625
  try {
@@ -13482,6 +13630,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13482
13630
  },
13483
13631
  useReducer: function (reducer, initialArg, init) {
13484
13632
  currentHookNameInDev = 'useReducer';
13633
+ mountHookTypesDev();
13485
13634
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13486
13635
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13487
13636
  try {
@@ -13492,10 +13641,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13492
13641
  },
13493
13642
  useRef: function (initialValue) {
13494
13643
  currentHookNameInDev = 'useRef';
13644
+ mountHookTypesDev();
13495
13645
  return mountRef(initialValue);
13496
13646
  },
13497
13647
  useState: function (initialState) {
13498
13648
  currentHookNameInDev = 'useState';
13649
+ mountHookTypesDev();
13499
13650
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13500
13651
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13501
13652
  try {
@@ -13506,6 +13657,81 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13506
13657
  },
13507
13658
  useDebugValue: function (value, formatterFn) {
13508
13659
  currentHookNameInDev = 'useDebugValue';
13660
+ mountHookTypesDev();
13661
+ return mountDebugValue(value, formatterFn);
13662
+ }
13663
+ };
13664
+
13665
+ HooksDispatcherOnMountWithHookTypesInDEV = {
13666
+ readContext: function (context, observedBits) {
13667
+ return readContext(context, observedBits);
13668
+ },
13669
+ useCallback: function (callback, deps) {
13670
+ currentHookNameInDev = 'useCallback';
13671
+ updateHookTypesDev();
13672
+ return mountCallback(callback, deps);
13673
+ },
13674
+ useContext: function (context, observedBits) {
13675
+ currentHookNameInDev = 'useContext';
13676
+ updateHookTypesDev();
13677
+ return readContext(context, observedBits);
13678
+ },
13679
+ useEffect: function (create, deps) {
13680
+ currentHookNameInDev = 'useEffect';
13681
+ updateHookTypesDev();
13682
+ return mountEffect(create, deps);
13683
+ },
13684
+ useImperativeHandle: function (ref, create, deps) {
13685
+ currentHookNameInDev = 'useImperativeHandle';
13686
+ updateHookTypesDev();
13687
+ return mountImperativeHandle(ref, create, deps);
13688
+ },
13689
+ useLayoutEffect: function (create, deps) {
13690
+ currentHookNameInDev = 'useLayoutEffect';
13691
+ updateHookTypesDev();
13692
+ return mountLayoutEffect(create, deps);
13693
+ },
13694
+ useMemo: function (create, deps) {
13695
+ currentHookNameInDev = 'useMemo';
13696
+ updateHookTypesDev();
13697
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13698
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13699
+ try {
13700
+ return mountMemo(create, deps);
13701
+ } finally {
13702
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13703
+ }
13704
+ },
13705
+ useReducer: function (reducer, initialArg, init) {
13706
+ currentHookNameInDev = 'useReducer';
13707
+ updateHookTypesDev();
13708
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13709
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13710
+ try {
13711
+ return mountReducer(reducer, initialArg, init);
13712
+ } finally {
13713
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13714
+ }
13715
+ },
13716
+ useRef: function (initialValue) {
13717
+ currentHookNameInDev = 'useRef';
13718
+ updateHookTypesDev();
13719
+ return mountRef(initialValue);
13720
+ },
13721
+ useState: function (initialState) {
13722
+ currentHookNameInDev = 'useState';
13723
+ updateHookTypesDev();
13724
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13725
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13726
+ try {
13727
+ return mountState(initialState);
13728
+ } finally {
13729
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13730
+ }
13731
+ },
13732
+ useDebugValue: function (value, formatterFn) {
13733
+ currentHookNameInDev = 'useDebugValue';
13734
+ updateHookTypesDev();
13509
13735
  return mountDebugValue(value, formatterFn);
13510
13736
  }
13511
13737
  };
@@ -13516,26 +13742,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13516
13742
  },
13517
13743
  useCallback: function (callback, deps) {
13518
13744
  currentHookNameInDev = 'useCallback';
13745
+ updateHookTypesDev();
13519
13746
  return updateCallback(callback, deps);
13520
13747
  },
13521
13748
  useContext: function (context, observedBits) {
13522
13749
  currentHookNameInDev = 'useContext';
13523
- return updateContext(context, observedBits);
13750
+ updateHookTypesDev();
13751
+ return readContext(context, observedBits);
13524
13752
  },
13525
13753
  useEffect: function (create, deps) {
13526
13754
  currentHookNameInDev = 'useEffect';
13755
+ updateHookTypesDev();
13527
13756
  return updateEffect(create, deps);
13528
13757
  },
13529
13758
  useImperativeHandle: function (ref, create, deps) {
13530
13759
  currentHookNameInDev = 'useImperativeHandle';
13760
+ updateHookTypesDev();
13531
13761
  return updateImperativeHandle(ref, create, deps);
13532
13762
  },
13533
13763
  useLayoutEffect: function (create, deps) {
13534
13764
  currentHookNameInDev = 'useLayoutEffect';
13765
+ updateHookTypesDev();
13535
13766
  return updateLayoutEffect(create, deps);
13536
13767
  },
13537
13768
  useMemo: function (create, deps) {
13538
13769
  currentHookNameInDev = 'useMemo';
13770
+ updateHookTypesDev();
13539
13771
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13540
13772
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13541
13773
  try {
@@ -13546,6 +13778,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13546
13778
  },
13547
13779
  useReducer: function (reducer, initialArg, init) {
13548
13780
  currentHookNameInDev = 'useReducer';
13781
+ updateHookTypesDev();
13549
13782
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13550
13783
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13551
13784
  try {
@@ -13556,10 +13789,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13556
13789
  },
13557
13790
  useRef: function (initialValue) {
13558
13791
  currentHookNameInDev = 'useRef';
13792
+ updateHookTypesDev();
13559
13793
  return updateRef(initialValue);
13560
13794
  },
13561
13795
  useState: function (initialState) {
13562
13796
  currentHookNameInDev = 'useState';
13797
+ updateHookTypesDev();
13563
13798
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13564
13799
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13565
13800
  try {
@@ -13570,6 +13805,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13570
13805
  },
13571
13806
  useDebugValue: function (value, formatterFn) {
13572
13807
  currentHookNameInDev = 'useDebugValue';
13808
+ updateHookTypesDev();
13573
13809
  return updateDebugValue(value, formatterFn);
13574
13810
  }
13575
13811
  };
@@ -13582,31 +13818,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13582
13818
  useCallback: function (callback, deps) {
13583
13819
  currentHookNameInDev = 'useCallback';
13584
13820
  warnInvalidHookAccess();
13821
+ mountHookTypesDev();
13585
13822
  return mountCallback(callback, deps);
13586
13823
  },
13587
13824
  useContext: function (context, observedBits) {
13588
13825
  currentHookNameInDev = 'useContext';
13589
13826
  warnInvalidHookAccess();
13590
- return mountContext(context, observedBits);
13827
+ mountHookTypesDev();
13828
+ return readContext(context, observedBits);
13591
13829
  },
13592
13830
  useEffect: function (create, deps) {
13593
13831
  currentHookNameInDev = 'useEffect';
13594
13832
  warnInvalidHookAccess();
13833
+ mountHookTypesDev();
13595
13834
  return mountEffect(create, deps);
13596
13835
  },
13597
13836
  useImperativeHandle: function (ref, create, deps) {
13598
13837
  currentHookNameInDev = 'useImperativeHandle';
13599
13838
  warnInvalidHookAccess();
13839
+ mountHookTypesDev();
13600
13840
  return mountImperativeHandle(ref, create, deps);
13601
13841
  },
13602
13842
  useLayoutEffect: function (create, deps) {
13603
13843
  currentHookNameInDev = 'useLayoutEffect';
13604
13844
  warnInvalidHookAccess();
13845
+ mountHookTypesDev();
13605
13846
  return mountLayoutEffect(create, deps);
13606
13847
  },
13607
13848
  useMemo: function (create, deps) {
13608
13849
  currentHookNameInDev = 'useMemo';
13609
13850
  warnInvalidHookAccess();
13851
+ mountHookTypesDev();
13610
13852
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13611
13853
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13612
13854
  try {
@@ -13618,6 +13860,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13618
13860
  useReducer: function (reducer, initialArg, init) {
13619
13861
  currentHookNameInDev = 'useReducer';
13620
13862
  warnInvalidHookAccess();
13863
+ mountHookTypesDev();
13621
13864
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13622
13865
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13623
13866
  try {
@@ -13629,11 +13872,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13629
13872
  useRef: function (initialValue) {
13630
13873
  currentHookNameInDev = 'useRef';
13631
13874
  warnInvalidHookAccess();
13875
+ mountHookTypesDev();
13632
13876
  return mountRef(initialValue);
13633
13877
  },
13634
13878
  useState: function (initialState) {
13635
13879
  currentHookNameInDev = 'useState';
13636
13880
  warnInvalidHookAccess();
13881
+ mountHookTypesDev();
13637
13882
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13638
13883
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13639
13884
  try {
@@ -13645,6 +13890,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13645
13890
  useDebugValue: function (value, formatterFn) {
13646
13891
  currentHookNameInDev = 'useDebugValue';
13647
13892
  warnInvalidHookAccess();
13893
+ mountHookTypesDev();
13648
13894
  return mountDebugValue(value, formatterFn);
13649
13895
  }
13650
13896
  };
@@ -13657,31 +13903,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13657
13903
  useCallback: function (callback, deps) {
13658
13904
  currentHookNameInDev = 'useCallback';
13659
13905
  warnInvalidHookAccess();
13906
+ updateHookTypesDev();
13660
13907
  return updateCallback(callback, deps);
13661
13908
  },
13662
13909
  useContext: function (context, observedBits) {
13663
13910
  currentHookNameInDev = 'useContext';
13664
13911
  warnInvalidHookAccess();
13665
- return updateContext(context, observedBits);
13912
+ updateHookTypesDev();
13913
+ return readContext(context, observedBits);
13666
13914
  },
13667
13915
  useEffect: function (create, deps) {
13668
13916
  currentHookNameInDev = 'useEffect';
13669
13917
  warnInvalidHookAccess();
13918
+ updateHookTypesDev();
13670
13919
  return updateEffect(create, deps);
13671
13920
  },
13672
13921
  useImperativeHandle: function (ref, create, deps) {
13673
13922
  currentHookNameInDev = 'useImperativeHandle';
13674
13923
  warnInvalidHookAccess();
13924
+ updateHookTypesDev();
13675
13925
  return updateImperativeHandle(ref, create, deps);
13676
13926
  },
13677
13927
  useLayoutEffect: function (create, deps) {
13678
13928
  currentHookNameInDev = 'useLayoutEffect';
13679
13929
  warnInvalidHookAccess();
13930
+ updateHookTypesDev();
13680
13931
  return updateLayoutEffect(create, deps);
13681
13932
  },
13682
13933
  useMemo: function (create, deps) {
13683
13934
  currentHookNameInDev = 'useMemo';
13684
13935
  warnInvalidHookAccess();
13936
+ updateHookTypesDev();
13685
13937
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13686
13938
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13687
13939
  try {
@@ -13693,6 +13945,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13693
13945
  useReducer: function (reducer, initialArg, init) {
13694
13946
  currentHookNameInDev = 'useReducer';
13695
13947
  warnInvalidHookAccess();
13948
+ updateHookTypesDev();
13696
13949
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13697
13950
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13698
13951
  try {
@@ -13704,11 +13957,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13704
13957
  useRef: function (initialValue) {
13705
13958
  currentHookNameInDev = 'useRef';
13706
13959
  warnInvalidHookAccess();
13960
+ updateHookTypesDev();
13707
13961
  return updateRef(initialValue);
13708
13962
  },
13709
13963
  useState: function (initialState) {
13710
13964
  currentHookNameInDev = 'useState';
13711
13965
  warnInvalidHookAccess();
13966
+ updateHookTypesDev();
13712
13967
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13713
13968
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13714
13969
  try {
@@ -13720,6 +13975,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13720
13975
  useDebugValue: function (value, formatterFn) {
13721
13976
  currentHookNameInDev = 'useDebugValue';
13722
13977
  warnInvalidHookAccess();
13978
+ updateHookTypesDev();
13723
13979
  return updateDebugValue(value, formatterFn);
13724
13980
  }
13725
13981
  };
@@ -13791,6 +14047,18 @@ function enterHydrationState(fiber) {
13791
14047
  return true;
13792
14048
  }
13793
14049
 
14050
+ function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
14051
+ if (!supportsHydration) {
14052
+ return false;
14053
+ }
14054
+
14055
+ var suspenseInstance = fiber.stateNode;
14056
+ nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
14057
+ popToNextHostParent(fiber);
14058
+ isHydrating = true;
14059
+ return true;
14060
+ }
14061
+
13794
14062
  function deleteHydratableInstance(returnFiber, instance) {
13795
14063
  {
13796
14064
  switch (returnFiber.tag) {
@@ -13837,6 +14105,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
13837
14105
  case HostText:
13838
14106
  var text = fiber.pendingProps;
13839
14107
  didNotFindHydratableContainerTextInstance(parentContainer, text);
14108
+ break;
14109
+ case SuspenseComponent:
14110
+
13840
14111
  break;
13841
14112
  }
13842
14113
  break;
@@ -13856,6 +14127,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
13856
14127
  var _text = fiber.pendingProps;
13857
14128
  didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
13858
14129
  break;
14130
+ case SuspenseComponent:
14131
+ didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
14132
+ break;
13859
14133
  }
13860
14134
  break;
13861
14135
  }
@@ -13888,6 +14162,19 @@ function tryHydrate(fiber, nextInstance) {
13888
14162
  }
13889
14163
  return false;
13890
14164
  }
14165
+ case SuspenseComponent:
14166
+ {
14167
+ if (enableSuspenseServerRenderer) {
14168
+ var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
14169
+ if (suspenseInstance !== null) {
14170
+ // Downgrade the tag to a dehydrated component until we've hydrated it.
14171
+ fiber.tag = DehydratedSuspenseComponent;
14172
+ fiber.stateNode = suspenseInstance;
14173
+ return true;
14174
+ }
14175
+ }
14176
+ return false;
14177
+ }
13891
14178
  default:
13892
14179
  return false;
13893
14180
  }
@@ -13981,9 +14268,18 @@ function prepareToHydrateHostTextInstance(fiber) {
13981
14268
  return shouldUpdate;
13982
14269
  }
13983
14270
 
14271
+ function skipPastDehydratedSuspenseInstance(fiber) {
14272
+ if (!supportsHydration) {
14273
+ invariant(false, 'Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
14274
+ }
14275
+ var suspenseInstance = fiber.stateNode;
14276
+ !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;
14277
+ nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
14278
+ }
14279
+
13984
14280
  function popToNextHostParent(fiber) {
13985
14281
  var parent = fiber.return;
13986
- while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
14282
+ while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
13987
14283
  parent = parent.return;
13988
14284
  }
13989
14285
  hydrationParentFiber = parent;
@@ -14091,6 +14387,10 @@ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildre
14091
14387
  }
14092
14388
 
14093
14389
  function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
14390
+ // TODO: current can be non-null here even if the component
14391
+ // hasn't yet mounted. This happens after the first render suspends.
14392
+ // We'll need to figure out if this is fine or can cause issues.
14393
+
14094
14394
  {
14095
14395
  if (workInProgress.type !== workInProgress.elementType) {
14096
14396
  // Lazy component props can't be validated in createElement
@@ -14196,6 +14496,10 @@ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, u
14196
14496
  }
14197
14497
 
14198
14498
  function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
14499
+ // TODO: current can be non-null here even if the component
14500
+ // hasn't yet mounted. This happens when the inner render suspends.
14501
+ // We'll need to figure out if this is fine or can cause issues.
14502
+
14199
14503
  {
14200
14504
  if (workInProgress.type !== workInProgress.elementType) {
14201
14505
  // Lazy component props can't be validated in createElement
@@ -14819,6 +15123,18 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
14819
15123
  // children -- we skip over the primary children entirely.
14820
15124
  var next = void 0;
14821
15125
  if (current$$1 === null) {
15126
+ if (enableSuspenseServerRenderer) {
15127
+ // If we're currently hydrating, try to hydrate this boundary.
15128
+ // But only if this has a fallback.
15129
+ if (nextProps.fallback !== undefined) {
15130
+ tryToClaimNextHydratableInstance(workInProgress);
15131
+ // This could've changed the tag if this was a dehydrated suspense component.
15132
+ if (workInProgress.tag === DehydratedSuspenseComponent) {
15133
+ return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
15134
+ }
15135
+ }
15136
+ }
15137
+
14822
15138
  // This is the initial mount. This branch is pretty simple because there's
14823
15139
  // no previous state that needs to be preserved.
14824
15140
  if (nextDidTimeout) {
@@ -14970,6 +15286,65 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
14970
15286
  return next;
14971
15287
  }
14972
15288
 
15289
+ function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
15290
+ if (current$$1 === null) {
15291
+ // During the first pass, we'll bail out and not drill into the children.
15292
+ // Instead, we'll leave the content in place and try to hydrate it later.
15293
+ workInProgress.expirationTime = Never;
15294
+ return null;
15295
+ }
15296
+ // We use childExpirationTime to indicate that a child might depend on context, so if
15297
+ // any context has changed, we need to treat is as if the input might have changed.
15298
+ var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
15299
+ if (didReceiveUpdate || hasContextChanged$$1) {
15300
+ // This boundary has changed since the first render. This means that we are now unable to
15301
+ // hydrate it. We might still be able to hydrate it using an earlier expiration time but
15302
+ // during this render we can't. Instead, we're going to delete the whole subtree and
15303
+ // instead inject a new real Suspense boundary to take its place, which may render content
15304
+ // or fallback. The real Suspense boundary will suspend for a while so we have some time
15305
+ // to ensure it can produce real content, but all state and pending events will be lost.
15306
+
15307
+ // Detach from the current dehydrated boundary.
15308
+ current$$1.alternate = null;
15309
+ workInProgress.alternate = null;
15310
+
15311
+ // Insert a deletion in the effect list.
15312
+ var returnFiber = workInProgress.return;
15313
+ !(returnFiber !== null) ? invariant(false, 'Suspense boundaries are never on the root. This is probably a bug in React.') : void 0;
15314
+ var last = returnFiber.lastEffect;
15315
+ if (last !== null) {
15316
+ last.nextEffect = current$$1;
15317
+ returnFiber.lastEffect = current$$1;
15318
+ } else {
15319
+ returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
15320
+ }
15321
+ current$$1.nextEffect = null;
15322
+ current$$1.effectTag = Deletion;
15323
+
15324
+ // Upgrade this work in progress to a real Suspense component.
15325
+ workInProgress.tag = SuspenseComponent;
15326
+ workInProgress.stateNode = null;
15327
+ workInProgress.memoizedState = null;
15328
+ // This is now an insertion.
15329
+ workInProgress.effectTag |= Placement;
15330
+ // Retry as a real Suspense component.
15331
+ return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
15332
+ }
15333
+ if ((workInProgress.effectTag & DidCapture) === NoEffect) {
15334
+ // This is the first attempt.
15335
+ reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
15336
+ var nextProps = workInProgress.pendingProps;
15337
+ var nextChildren = nextProps.children;
15338
+ workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
15339
+ return workInProgress.child;
15340
+ } else {
15341
+ // Something suspended. Leave the existing children in place.
15342
+ // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
15343
+ workInProgress.child = null;
15344
+ return null;
15345
+ }
15346
+ }
15347
+
14973
15348
  function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
14974
15349
  pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
14975
15350
  var nextChildren = workInProgress.pendingProps;
@@ -15181,6 +15556,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
15181
15556
  }
15182
15557
  break;
15183
15558
  }
15559
+ case DehydratedSuspenseComponent:
15560
+ {
15561
+ if (enableSuspenseServerRenderer) {
15562
+ // We know that this component will suspend again because if it has
15563
+ // been unsuspended it has committed as a regular Suspense component.
15564
+ // If it needs to be retried, it should have work scheduled on it.
15565
+ workInProgress.effectTag |= DidCapture;
15566
+ break;
15567
+ }
15568
+ }
15184
15569
  }
15185
15570
  return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
15186
15571
  }
@@ -15272,9 +15657,15 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
15272
15657
  var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
15273
15658
  return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
15274
15659
  }
15275
- default:
15276
- invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
15660
+ case DehydratedSuspenseComponent:
15661
+ {
15662
+ if (enableSuspenseServerRenderer) {
15663
+ return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
15664
+ }
15665
+ break;
15666
+ }
15277
15667
  }
15668
+ invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
15278
15669
  }
15279
15670
 
15280
15671
  var valueCursor = createCursor(null);
@@ -15363,6 +15754,28 @@ function calculateChangedBits(context, newValue, oldValue) {
15363
15754
  }
15364
15755
  }
15365
15756
 
15757
+ function scheduleWorkOnParentPath(parent, renderExpirationTime) {
15758
+ // Update the child expiration time of all the ancestors, including
15759
+ // the alternates.
15760
+ var node = parent;
15761
+ while (node !== null) {
15762
+ var alternate = node.alternate;
15763
+ if (node.childExpirationTime < renderExpirationTime) {
15764
+ node.childExpirationTime = renderExpirationTime;
15765
+ if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15766
+ alternate.childExpirationTime = renderExpirationTime;
15767
+ }
15768
+ } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15769
+ alternate.childExpirationTime = renderExpirationTime;
15770
+ } else {
15771
+ // Neither alternate was updated, which means the rest of the
15772
+ // ancestor path already has sufficient priority.
15773
+ break;
15774
+ }
15775
+ node = node.return;
15776
+ }
15777
+ }
15778
+
15366
15779
  function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
15367
15780
  var fiber = workInProgress.child;
15368
15781
  if (fiber !== null) {
@@ -15401,25 +15814,8 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
15401
15814
  if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
15402
15815
  alternate.expirationTime = renderExpirationTime;
15403
15816
  }
15404
- // Update the child expiration time of all the ancestors, including
15405
- // the alternates.
15406
- var node = fiber.return;
15407
- while (node !== null) {
15408
- alternate = node.alternate;
15409
- if (node.childExpirationTime < renderExpirationTime) {
15410
- node.childExpirationTime = renderExpirationTime;
15411
- if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15412
- alternate.childExpirationTime = renderExpirationTime;
15413
- }
15414
- } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15415
- alternate.childExpirationTime = renderExpirationTime;
15416
- } else {
15417
- // Neither alternate was updated, which means the rest of the
15418
- // ancestor path already has sufficient priority.
15419
- break;
15420
- }
15421
- node = node.return;
15422
- }
15817
+
15818
+ scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
15423
15819
 
15424
15820
  // Mark the expiration time on the list, too.
15425
15821
  if (list.expirationTime < renderExpirationTime) {
@@ -15435,6 +15831,23 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
15435
15831
  } else if (fiber.tag === ContextProvider) {
15436
15832
  // Don't scan deeper if this is a matching provider
15437
15833
  nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
15834
+ } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
15835
+ // If a dehydrated suspense component is in this subtree, we don't know
15836
+ // if it will have any context consumers in it. The best we can do is
15837
+ // mark it as having updates on its children.
15838
+ if (fiber.expirationTime < renderExpirationTime) {
15839
+ fiber.expirationTime = renderExpirationTime;
15840
+ }
15841
+ var _alternate = fiber.alternate;
15842
+ if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
15843
+ _alternate.expirationTime = renderExpirationTime;
15844
+ }
15845
+ // This is intentionally passing this fiber as the parent
15846
+ // because we want to schedule this fiber as having work
15847
+ // on its children. We'll use the childExpirationTime on
15848
+ // this fiber to indicate that a context has changed.
15849
+ scheduleWorkOnParentPath(fiber, renderExpirationTime);
15850
+ nextFiber = fiber.sibling;
15438
15851
  } else {
15439
15852
  // Traverse down.
15440
15853
  nextFiber = fiber.child;
@@ -16558,6 +16971,26 @@ function completeWork(current, workInProgress, renderExpirationTime) {
16558
16971
  }
16559
16972
  break;
16560
16973
  }
16974
+ case DehydratedSuspenseComponent:
16975
+ {
16976
+ if (enableSuspenseServerRenderer) {
16977
+ if (current === null) {
16978
+ var _wasHydrated2 = popHydrationState(workInProgress);
16979
+ !_wasHydrated2 ? invariant(false, 'A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.') : void 0;
16980
+ skipPastDehydratedSuspenseInstance(workInProgress);
16981
+ } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
16982
+ // This boundary did not suspend so it's now hydrated.
16983
+ // To handle any future suspense cases, we're going to now upgrade it
16984
+ // to a Suspense component. We detach it from the existing current fiber.
16985
+ current.alternate = null;
16986
+ workInProgress.alternate = null;
16987
+ workInProgress.tag = SuspenseComponent;
16988
+ workInProgress.memoizedState = null;
16989
+ workInProgress.stateNode = null;
16990
+ }
16991
+ }
16992
+ break;
16993
+ }
16561
16994
  default:
16562
16995
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
16563
16996
  }
@@ -16648,7 +17081,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
16648
17081
  didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
16649
17082
  }
16650
17083
 
16651
- var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
17084
+ var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
16652
17085
 
16653
17086
  function logError(boundary, errorInfo) {
16654
17087
  var source = errorInfo.source;
@@ -16961,7 +17394,7 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
16961
17394
 
16962
17395
  function hideOrUnhideAllChildren(finishedWork, isHidden) {
16963
17396
  if (supportsMutation) {
16964
- // We only have the top Fiber that was inserted but we need recurse down its
17397
+ // We only have the top Fiber that was inserted but we need to recurse down its
16965
17398
  var node = finishedWork;
16966
17399
  while (true) {
16967
17400
  if (node.tag === HostComponent) {
@@ -17229,7 +17662,7 @@ function getHostSibling(fiber) {
17229
17662
  }
17230
17663
  node.sibling.return = node.return;
17231
17664
  node = node.sibling;
17232
- while (node.tag !== HostComponent && node.tag !== HostText) {
17665
+ while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
17233
17666
  // If it is not host node and, we might have a host node inside it.
17234
17667
  // Try to search down until we find one.
17235
17668
  if (node.effectTag & Placement) {
@@ -17289,7 +17722,7 @@ function commitPlacement(finishedWork) {
17289
17722
  }
17290
17723
 
17291
17724
  var before = getHostSibling(finishedWork);
17292
- // We only have the top Fiber that was inserted but we need recurse down its
17725
+ // We only have the top Fiber that was inserted but we need to recurse down its
17293
17726
  // children to find all the terminal nodes.
17294
17727
  var node = finishedWork;
17295
17728
  while (true) {
@@ -17331,7 +17764,7 @@ function commitPlacement(finishedWork) {
17331
17764
  }
17332
17765
 
17333
17766
  function unmountHostComponents(current$$1) {
17334
- // We only have the top Fiber that was deleted but we need recurse down its
17767
+ // We only have the top Fiber that was deleted but we need to recurse down its
17335
17768
  var node = current$$1;
17336
17769
 
17337
17770
  // Each iteration, currentParent is populated with node's host parent if not
@@ -17376,13 +17809,20 @@ function unmountHostComponents(current$$1) {
17376
17809
  removeChild(currentParent, node.stateNode);
17377
17810
  }
17378
17811
  // Don't visit children because we already visited them.
17812
+ } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
17813
+ // Delete the dehydrated suspense boundary and all of its content.
17814
+ if (currentParentIsContainer) {
17815
+ clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
17816
+ } else {
17817
+ clearSuspenseBoundary(currentParent, node.stateNode);
17818
+ }
17379
17819
  } else if (node.tag === HostPortal) {
17380
- // When we go into a portal, it becomes the parent to remove from.
17381
- // We will reassign it back when we pop the portal on the way up.
17382
- currentParent = node.stateNode.containerInfo;
17383
- currentParentIsContainer = true;
17384
- // Visit children because portals might contain host components.
17385
17820
  if (node.child !== null) {
17821
+ // When we go into a portal, it becomes the parent to remove from.
17822
+ // We will reassign it back when we pop the portal on the way up.
17823
+ currentParent = node.stateNode.containerInfo;
17824
+ currentParentIsContainer = true;
17825
+ // Visit children because portals might contain host components.
17386
17826
  node.child.return = node;
17387
17827
  node = node.child;
17388
17828
  continue;
@@ -17532,7 +17972,7 @@ function commitWork(current$$1, finishedWork) {
17532
17972
  finishedWork.updateQueue = null;
17533
17973
  var retryCache = finishedWork.stateNode;
17534
17974
  if (retryCache === null) {
17535
- retryCache = finishedWork.stateNode = new PossiblyWeakSet();
17975
+ retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
17536
17976
  }
17537
17977
  thenables.forEach(function (thenable) {
17538
17978
  // Memoize using the boundary fiber to prevent redundant listeners.
@@ -17567,6 +18007,7 @@ function commitResetTextContent(current$$1) {
17567
18007
  resetTextContent(current$$1.stateNode);
17568
18008
  }
17569
18009
 
18010
+ var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
17570
18011
  var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
17571
18012
 
17572
18013
  function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
@@ -17625,6 +18066,34 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
17625
18066
  return update;
17626
18067
  }
17627
18068
 
18069
+ function attachPingListener(root, renderExpirationTime, thenable) {
18070
+ // Attach a listener to the promise to "ping" the root and retry. But
18071
+ // only if one does not already exist for the current render expiration
18072
+ // time (which acts like a "thread ID" here).
18073
+ var pingCache = root.pingCache;
18074
+ var threadIDs = void 0;
18075
+ if (pingCache === null) {
18076
+ pingCache = root.pingCache = new PossiblyWeakMap();
18077
+ threadIDs = new Set();
18078
+ pingCache.set(thenable, threadIDs);
18079
+ } else {
18080
+ threadIDs = pingCache.get(thenable);
18081
+ if (threadIDs === undefined) {
18082
+ threadIDs = new Set();
18083
+ pingCache.set(thenable, threadIDs);
18084
+ }
18085
+ }
18086
+ if (!threadIDs.has(renderExpirationTime)) {
18087
+ // Memoize using the thread ID to prevent redundant listeners.
18088
+ threadIDs.add(renderExpirationTime);
18089
+ var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
18090
+ if (enableSchedulerTracing) {
18091
+ ping = tracing.unstable_wrap(ping);
18092
+ }
18093
+ thenable.then(ping, ping);
18094
+ }
18095
+ }
18096
+
17628
18097
  function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
17629
18098
  // The source fiber did not complete.
17630
18099
  sourceFiber.effectTag |= Incomplete;
@@ -17666,6 +18135,9 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17666
18135
  }
17667
18136
  }
17668
18137
  }
18138
+ // If there is a DehydratedSuspenseComponent we don't have to do anything because
18139
+ // if something suspends inside it, we will simply leave that as dehydrated. It
18140
+ // will never timeout.
17669
18141
  _workInProgress = _workInProgress.return;
17670
18142
  } while (_workInProgress !== null);
17671
18143
 
@@ -17729,31 +18201,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17729
18201
  // Confirmed that the boundary is in a concurrent mode tree. Continue
17730
18202
  // with the normal suspend path.
17731
18203
 
17732
- // Attach a listener to the promise to "ping" the root and retry. But
17733
- // only if one does not already exist for the current render expiration
17734
- // time (which acts like a "thread ID" here).
17735
- var pingCache = root.pingCache;
17736
- var threadIDs = void 0;
17737
- if (pingCache === null) {
17738
- pingCache = root.pingCache = new PossiblyWeakMap();
17739
- threadIDs = new Set();
17740
- pingCache.set(thenable, threadIDs);
17741
- } else {
17742
- threadIDs = pingCache.get(thenable);
17743
- if (threadIDs === undefined) {
17744
- threadIDs = new Set();
17745
- pingCache.set(thenable, threadIDs);
17746
- }
17747
- }
17748
- if (!threadIDs.has(renderExpirationTime)) {
17749
- // Memoize using the thread ID to prevent redundant listeners.
17750
- threadIDs.add(renderExpirationTime);
17751
- var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
17752
- if (enableSchedulerTracing) {
17753
- ping = tracing.unstable_wrap(ping);
17754
- }
17755
- thenable.then(ping, ping);
17756
- }
18204
+ attachPingListener(root, renderExpirationTime, thenable);
17757
18205
 
17758
18206
  var absoluteTimeoutMs = void 0;
17759
18207
  if (earliestTimeoutMs === -1) {
@@ -17785,6 +18233,29 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17785
18233
  // whole tree.
17786
18234
  renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
17787
18235
 
18236
+ _workInProgress.effectTag |= ShouldCapture;
18237
+ _workInProgress.expirationTime = renderExpirationTime;
18238
+ return;
18239
+ } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
18240
+ attachPingListener(root, renderExpirationTime, thenable);
18241
+
18242
+ // Since we already have a current fiber, we can eagerly add a retry listener.
18243
+ var retryCache = _workInProgress.memoizedState;
18244
+ if (retryCache === null) {
18245
+ retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
18246
+ var _current = _workInProgress.alternate;
18247
+ !_current ? invariant(false, 'A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.') : void 0;
18248
+ _current.memoizedState = retryCache;
18249
+ }
18250
+ // Memoize using the boundary fiber to prevent redundant listeners.
18251
+ if (!retryCache.has(thenable)) {
18252
+ retryCache.add(thenable);
18253
+ var retry = retryTimedOutBoundary.bind(null, _workInProgress, thenable);
18254
+ if (enableSchedulerTracing) {
18255
+ retry = tracing.unstable_wrap(retry);
18256
+ }
18257
+ thenable.then(retry, retry);
18258
+ }
17788
18259
  _workInProgress.effectTag |= ShouldCapture;
17789
18260
  _workInProgress.expirationTime = renderExpirationTime;
17790
18261
  return;
@@ -17862,6 +18333,7 @@ function unwindWork(workInProgress, renderExpirationTime) {
17862
18333
  }
17863
18334
  case HostComponent:
17864
18335
  {
18336
+ // TODO: popHydrationState
17865
18337
  popHostContext(workInProgress);
17866
18338
  return null;
17867
18339
  }
@@ -17875,6 +18347,19 @@ function unwindWork(workInProgress, renderExpirationTime) {
17875
18347
  }
17876
18348
  return null;
17877
18349
  }
18350
+ case DehydratedSuspenseComponent:
18351
+ {
18352
+ if (enableSuspenseServerRenderer) {
18353
+ // TODO: popHydrationState
18354
+ var _effectTag3 = workInProgress.effectTag;
18355
+ if (_effectTag3 & ShouldCapture) {
18356
+ workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
18357
+ // Captured a suspense effect. Re-render the boundary.
18358
+ return workInProgress;
18359
+ }
18360
+ }
18361
+ return null;
18362
+ }
17878
18363
  case HostPortal:
17879
18364
  popHostContainer(workInProgress);
17880
18365
  return null;
@@ -17972,11 +18457,6 @@ if (enableSchedulerTracing) {
17972
18457
  // Used to ensure computeUniqueAsyncExpiration is monotonically decreasing.
17973
18458
  var lastUniqueAsyncExpiration = Sync - 1;
17974
18459
 
17975
- // Represents the expiration time that incoming updates should use. (If this
17976
- // is NoWork, use the default strategy: async updates in async mode, sync
17977
- // updates in sync mode.)
17978
- var expirationContext = NoWork;
17979
-
17980
18460
  var isWorking = false;
17981
18461
 
17982
18462
  // The next work in progress fiber that we're currently working on.
@@ -18272,6 +18752,10 @@ function commitPassiveEffects(root, firstEffect) {
18272
18752
  if (rootExpirationTime !== NoWork) {
18273
18753
  requestWork(root, rootExpirationTime);
18274
18754
  }
18755
+ // Flush any sync work that was scheduled by effects
18756
+ if (!isBatchingUpdates && !isRendering) {
18757
+ performSyncWork();
18758
+ }
18275
18759
  }
18276
18760
 
18277
18761
  function isAlreadyFailedLegacyErrorBoundary(instance) {
@@ -18446,7 +18930,9 @@ function commitRoot(root, finishedWork) {
18446
18930
  // here because that code is still in flux.
18447
18931
  callback = tracing.unstable_wrap(callback);
18448
18932
  }
18449
- passiveEffectCallbackHandle = schedulePassiveEffects(callback);
18933
+ passiveEffectCallbackHandle = scheduler.unstable_runWithPriority(scheduler.unstable_NormalPriority, function () {
18934
+ return schedulePassiveEffects(callback);
18935
+ });
18450
18936
  passiveEffectCallback = callback;
18451
18937
  }
18452
18938
 
@@ -19035,7 +19521,7 @@ function renderRoot(root, isYieldy) {
19035
19521
  return;
19036
19522
  } else if (
19037
19523
  // There's no lower priority work, but we're rendering asynchronously.
19038
- // Synchronsouly attempt to render the same level one more time. This is
19524
+ // Synchronously attempt to render the same level one more time. This is
19039
19525
  // similar to a suspend, but without a timeout because we're not waiting
19040
19526
  // for a promise to resolve.
19041
19527
  !root.didError && isYieldy) {
@@ -19140,49 +19626,50 @@ function computeUniqueAsyncExpiration() {
19140
19626
  }
19141
19627
 
19142
19628
  function computeExpirationForFiber(currentTime, fiber) {
19629
+ var priorityLevel = scheduler.unstable_getCurrentPriorityLevel();
19630
+
19143
19631
  var expirationTime = void 0;
19144
- if (expirationContext !== NoWork) {
19145
- // An explicit expiration context was set;
19146
- expirationTime = expirationContext;
19147
- } else if (isWorking) {
19148
- if (isCommitting$1) {
19149
- // Updates that occur during the commit phase should have sync priority
19150
- // by default.
19151
- expirationTime = Sync;
19152
- } else {
19153
- // Updates during the render phase should expire at the same time as
19154
- // the work that is being rendered.
19155
- expirationTime = nextRenderExpirationTime;
19156
- }
19632
+ if ((fiber.mode & ConcurrentMode) === NoContext) {
19633
+ // Outside of concurrent mode, updates are always synchronous.
19634
+ expirationTime = Sync;
19635
+ } else if (isWorking && !isCommitting$1) {
19636
+ // During render phase, updates expire during as the current render.
19637
+ expirationTime = nextRenderExpirationTime;
19157
19638
  } else {
19158
- // No explicit expiration context was set, and we're not currently
19159
- // performing work. Calculate a new expiration time.
19160
- if (fiber.mode & ConcurrentMode) {
19161
- if (isBatchingInteractiveUpdates) {
19162
- // This is an interactive update
19639
+ switch (priorityLevel) {
19640
+ case scheduler.unstable_ImmediatePriority:
19641
+ expirationTime = Sync;
19642
+ break;
19643
+ case scheduler.unstable_UserBlockingPriority:
19163
19644
  expirationTime = computeInteractiveExpiration(currentTime);
19164
- } else {
19165
- // This is an async update
19645
+ break;
19646
+ case scheduler.unstable_NormalPriority:
19647
+ // This is a normal, concurrent update
19166
19648
  expirationTime = computeAsyncExpiration(currentTime);
19167
- }
19168
- // If we're in the middle of rendering a tree, do not update at the same
19169
- // expiration time that is already rendering.
19170
- if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
19171
- expirationTime -= 1;
19172
- }
19173
- } else {
19174
- // This is a sync update
19175
- expirationTime = Sync;
19649
+ break;
19650
+ case scheduler.unstable_LowPriority:
19651
+ case scheduler.unstable_IdlePriority:
19652
+ expirationTime = Never;
19653
+ break;
19654
+ default:
19655
+ invariant(false, 'Unknown priority level. This error is likely caused by a bug in React. Please file an issue.');
19176
19656
  }
19177
- }
19178
- if (isBatchingInteractiveUpdates) {
19179
- // This is an interactive update. Keep track of the lowest pending
19180
- // interactive expiration time. This allows us to synchronously flush
19181
- // all interactive updates when needed.
19182
- if (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime) {
19183
- lowestPriorityPendingInteractiveExpirationTime = expirationTime;
19657
+
19658
+ // If we're in the middle of rendering a tree, do not update at the same
19659
+ // expiration time that is already rendering.
19660
+ if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
19661
+ expirationTime -= 1;
19184
19662
  }
19185
19663
  }
19664
+
19665
+ // Keep track of the lowest pending interactive expiration time. This
19666
+ // allows us to synchronously flush all interactive updates
19667
+ // when needed.
19668
+ // TODO: Move this to renderer?
19669
+ if (priorityLevel === scheduler.unstable_UserBlockingPriority && (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime)) {
19670
+ lowestPriorityPendingInteractiveExpirationTime = expirationTime;
19671
+ }
19672
+
19186
19673
  return expirationTime;
19187
19674
  }
19188
19675
 
@@ -19229,7 +19716,21 @@ function retryTimedOutBoundary(boundaryFiber, thenable) {
19229
19716
  // The boundary fiber (a Suspense component) previously timed out and was
19230
19717
  // rendered in its fallback state. One of the promises that suspended it has
19231
19718
  // resolved, which means at least part of the tree was likely unblocked. Try
19232
- var retryCache = boundaryFiber.stateNode;
19719
+ var retryCache = void 0;
19720
+ if (enableSuspenseServerRenderer) {
19721
+ switch (boundaryFiber.tag) {
19722
+ case SuspenseComponent:
19723
+ retryCache = boundaryFiber.stateNode;
19724
+ break;
19725
+ case DehydratedSuspenseComponent:
19726
+ retryCache = boundaryFiber.memoizedState;
19727
+ break;
19728
+ default:
19729
+ invariant(false, 'Pinged unknown suspense boundary type. This is probably a bug in React.');
19730
+ }
19731
+ } else {
19732
+ retryCache = boundaryFiber.stateNode;
19733
+ }
19233
19734
  if (retryCache !== null) {
19234
19735
  // The thenable resolved, so we no longer need to memoize, because it will
19235
19736
  // never be thrown again.
@@ -19328,7 +19829,7 @@ function scheduleWorkToRoot(fiber, expirationTime) {
19328
19829
  function warnIfNotCurrentlyBatchingInDev(fiber) {
19329
19830
  {
19330
19831
  if (isRendering === false && isBatchingUpdates === false) {
19331
- 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));
19832
+ 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));
19332
19833
  }
19333
19834
  }
19334
19835
  }
@@ -19375,13 +19876,9 @@ function scheduleWork(fiber, expirationTime) {
19375
19876
  }
19376
19877
 
19377
19878
  function syncUpdates(fn, a, b, c, d) {
19378
- var previousExpirationContext = expirationContext;
19379
- expirationContext = Sync;
19380
- try {
19879
+ return scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
19381
19880
  return fn(a, b, c, d);
19382
- } finally {
19383
- expirationContext = previousExpirationContext;
19384
- }
19881
+ });
19385
19882
  }
19386
19883
 
19387
19884
  // TODO: Everything below this is written as if it has been lifted to the
@@ -19402,7 +19899,6 @@ var unhandledError = null;
19402
19899
 
19403
19900
  var isBatchingUpdates = false;
19404
19901
  var isUnbatchingUpdates = false;
19405
- var isBatchingInteractiveUpdates = false;
19406
19902
 
19407
19903
  var completedBatches = null;
19408
19904
 
@@ -19876,7 +20372,9 @@ function completeRoot(root, finishedWork, expirationTime) {
19876
20372
  lastCommittedRootDuringThisBatch = root;
19877
20373
  nestedUpdateCount = 0;
19878
20374
  }
19879
- commitRoot(root, finishedWork);
20375
+ scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
20376
+ commitRoot(root, finishedWork);
20377
+ });
19880
20378
  }
19881
20379
 
19882
20380
  function onUncaughtError(error) {
@@ -19934,9 +20432,6 @@ function flushSync(fn, a) {
19934
20432
  }
19935
20433
 
19936
20434
  function interactiveUpdates$1(fn, a, b) {
19937
- if (isBatchingInteractiveUpdates) {
19938
- return fn(a, b);
19939
- }
19940
20435
  // If there are any pending interactive updates, synchronously flush them.
19941
20436
  // This needs to happen before we read any handlers, because the effect of
19942
20437
  // the previous event may influence which handlers are called during
@@ -19946,14 +20441,13 @@ function interactiveUpdates$1(fn, a, b) {
19946
20441
  performWork(lowestPriorityPendingInteractiveExpirationTime, false);
19947
20442
  lowestPriorityPendingInteractiveExpirationTime = NoWork;
19948
20443
  }
19949
- var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates;
19950
20444
  var previousIsBatchingUpdates = isBatchingUpdates;
19951
- isBatchingInteractiveUpdates = true;
19952
20445
  isBatchingUpdates = true;
19953
20446
  try {
19954
- return fn(a, b);
20447
+ return scheduler.unstable_runWithPriority(scheduler.unstable_UserBlockingPriority, function () {
20448
+ return fn(a, b);
20449
+ });
19955
20450
  } finally {
19956
- isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates;
19957
20451
  isBatchingUpdates = previousIsBatchingUpdates;
19958
20452
  if (!isBatchingUpdates && !isRendering) {
19959
20453
  performSyncWork();
@@ -20216,7 +20710,7 @@ implementation) {
20216
20710
 
20217
20711
  // TODO: this is special because it gets imported during build.
20218
20712
 
20219
- var ReactVersion = '16.8.0';
20713
+ var ReactVersion = '16.8.4';
20220
20714
 
20221
20715
  // This file is copy paste from ReactDOM with adjusted paths
20222
20716
  // and a different host config import (react-reconciler/inline.fire).
@@ -20611,7 +21105,7 @@ var ReactDOM = {
20611
21105
  hydrate: function (element, container, callback) {
20612
21106
  !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0;
20613
21107
  {
20614
- !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. ' + 'Did you mean to call root.render(element, {hydrate: true})?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
21108
+ !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
20615
21109
  }
20616
21110
  // TODO: throw or warn if we couldn't hydrate?
20617
21111
  return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);