react-dom 16.8.1 → 16.8.5

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 +67 -36
  3. package/cjs/react-dom-server.browser.production.min.js +17 -16
  4. package/cjs/react-dom-server.node.development.js +67 -36
  5. package/cjs/react-dom-server.node.production.min.js +18 -17
  6. package/cjs/react-dom-test-utils.development.js +2 -2
  7. package/cjs/react-dom-test-utils.production.min.js +1 -1
  8. package/cjs/react-dom-unstable-fire.development.js +709 -213
  9. package/cjs/react-dom-unstable-fire.production.min.js +252 -251
  10. package/cjs/react-dom-unstable-fire.profiling.min.js +176 -173
  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 +709 -213
  18. package/cjs/react-dom.production.min.js +252 -251
  19. package/cjs/react-dom.profiling.min.js +176 -173
  20. package/package.json +2 -2
  21. package/umd/react-dom-server.browser.development.js +67 -36
  22. package/umd/react-dom-server.browser.production.min.js +22 -21
  23. package/umd/react-dom-test-utils.development.js +2 -2
  24. package/umd/react-dom-test-utils.production.min.js +1 -1
  25. package/umd/react-dom-unstable-fire.development.js +717 -213
  26. package/umd/react-dom-unstable-fire.production.min.js +208 -207
  27. package/umd/react-dom-unstable-fire.profiling.min.js +208 -208
  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 +717 -213
  33. package/umd/react-dom.production.min.js +208 -207
  34. package/umd/react-dom.profiling.min.js +208 -208
@@ -1,4 +1,4 @@
1
- /** @license React v16.8.1
1
+ /** @license React v16.8.5
2
2
  * react-dom-unstable-fire.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -79,7 +79,7 @@ var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f)
79
79
  // invokeGuardedCallback uses a try-catch, all user exceptions are treated
80
80
  // like caught exceptions, and the DevTools won't pause unless the developer
81
81
  // takes the extra step of enabling pause on caught exceptions. This is
82
- // untintuitive, though, because even though React has caught the error, from
82
+ // unintuitive, though, because even though React has caught the error, from
83
83
  // the developer's perspective, the error is uncaught.
84
84
  //
85
85
  // To preserve the expected "Pause on exceptions" behavior, we don't use a
@@ -836,6 +836,7 @@ var MemoComponent = 14;
836
836
  var SimpleMemoComponent = 15;
837
837
  var LazyComponent = 16;
838
838
  var IncompleteClassComponent = 17;
839
+ var DehydratedSuspenseComponent = 18;
839
840
 
840
841
  var randomKey = Math.random().toString(36).slice(2);
841
842
  var internalInstanceKey = '__reactInternalInstance$' + randomKey;
@@ -2901,12 +2902,15 @@ var capitalize = function (token) {
2901
2902
  attributeName, 'http://www.w3.org/XML/1998/namespace');
2902
2903
  });
2903
2904
 
2904
- // Special case: this attribute exists both in HTML and SVG.
2905
- // Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
2906
- // its React `tabIndex` name, like we do for attributes that exist only in HTML.
2907
- properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty
2908
- 'tabindex', // attributeName
2909
- null);
2905
+ // These attribute exists both in HTML and SVG.
2906
+ // The attribute name is case-sensitive in SVG so we can't just use
2907
+ // the React name like we do for attributes that exist only in HTML.
2908
+ ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
2909
+ properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
2910
+ attributeName.toLowerCase(), // attributeName
2911
+ null);
2912
+ } // attributeNamespace
2913
+ );
2910
2914
 
2911
2915
  /**
2912
2916
  * Get the value for a property on a node. Only used in DEV for SSR validation.
@@ -3250,7 +3254,7 @@ var enableProfilerTimer = true;
3250
3254
  var enableSchedulerTracing = true;
3251
3255
 
3252
3256
  // Only used in www builds.
3253
- // TODO: true? Here it might just be false.
3257
+ var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
3254
3258
 
3255
3259
  // Only used in www builds.
3256
3260
 
@@ -7729,14 +7733,25 @@ function createElement(type, props, rootContainerElement, parentNamespace) {
7729
7733
  // See discussion in https://github.com/facebook/react/pull/6896
7730
7734
  // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
7731
7735
  domElement = ownerDocument.createElement(type);
7732
- // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple`
7733
- // attribute on `select`s needs to be added before `option`s are inserted. This prevents
7734
- // a bug where the `select` does not scroll to the correct option because singular
7735
- // `select` elements automatically pick the first item.
7736
+ // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
7737
+ // attributes on `select`s needs to be added before `option`s are inserted.
7738
+ // This prevents:
7739
+ // - a bug where the `select` does not scroll to the correct option because singular
7740
+ // `select` elements automatically pick the first item #13222
7741
+ // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
7736
7742
  // See https://github.com/facebook/react/issues/13222
7737
- if (type === 'select' && props.multiple) {
7743
+ // and https://github.com/facebook/react/issues/14239
7744
+ if (type === 'select') {
7738
7745
  var node = domElement;
7739
- node.multiple = true;
7746
+ if (props.multiple) {
7747
+ node.multiple = true;
7748
+ } else if (props.size) {
7749
+ // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
7750
+ // it is possible that no option is selected.
7751
+ //
7752
+ // This is only necessary when a select in "single selection mode".
7753
+ node.size = props.size;
7754
+ }
7740
7755
  }
7741
7756
  }
7742
7757
  } else {
@@ -8710,8 +8725,16 @@ var unstable_now = _ReactInternals$Sched.unstable_now;
8710
8725
  var unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback;
8711
8726
  var unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield;
8712
8727
  var unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode;
8728
+ var unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority;
8729
+ var unstable_next = _ReactInternals$Sched.unstable_next;
8713
8730
  var unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution;
8714
8731
  var unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution;
8732
+ var unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel;
8733
+ var unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority;
8734
+ var unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority;
8735
+ var unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority;
8736
+ var unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority;
8737
+ var unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority;
8715
8738
 
8716
8739
  // Renderers that don't support persistence
8717
8740
  // can re-export everything from this module.
@@ -8736,6 +8759,9 @@ var SUPPRESS_HYDRATION_WARNING = void 0;
8736
8759
  SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
8737
8760
  }
8738
8761
 
8762
+ var SUSPENSE_START_DATA = '$';
8763
+ var SUSPENSE_END_DATA = '/$';
8764
+
8739
8765
  var STYLE = 'style';
8740
8766
 
8741
8767
  var eventsEnabled = null;
@@ -8964,6 +8990,43 @@ function removeChildFromContainer(container, child) {
8964
8990
  }
8965
8991
  }
8966
8992
 
8993
+ function clearSuspenseBoundary(parentInstance, suspenseInstance) {
8994
+ var node = suspenseInstance;
8995
+ // Delete all nodes within this suspense boundary.
8996
+ // There might be nested nodes so we need to keep track of how
8997
+ // deep we are and only break out when we're back on top.
8998
+ var depth = 0;
8999
+ do {
9000
+ var nextNode = node.nextSibling;
9001
+ parentInstance.removeChild(node);
9002
+ if (nextNode && nextNode.nodeType === COMMENT_NODE) {
9003
+ var data = nextNode.data;
9004
+ if (data === SUSPENSE_END_DATA) {
9005
+ if (depth === 0) {
9006
+ parentInstance.removeChild(nextNode);
9007
+ return;
9008
+ } else {
9009
+ depth--;
9010
+ }
9011
+ } else if (data === SUSPENSE_START_DATA) {
9012
+ depth++;
9013
+ }
9014
+ }
9015
+ node = nextNode;
9016
+ } while (node);
9017
+ // TODO: Warn, we didn't find the end comment boundary.
9018
+ }
9019
+
9020
+ function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
9021
+ if (container.nodeType === COMMENT_NODE) {
9022
+ clearSuspenseBoundary(container.parentNode, suspenseInstance);
9023
+ } else if (container.nodeType === ELEMENT_NODE) {
9024
+ clearSuspenseBoundary(container, suspenseInstance);
9025
+ } else {
9026
+ // Document nodes should never contain suspense boundaries.
9027
+ }
9028
+ }
9029
+
8967
9030
  function hideInstance(instance) {
8968
9031
  // TODO: Does this work for all element types? What about MathML? Should we
8969
9032
  // pass host context to this method?
@@ -9009,10 +9072,19 @@ function canHydrateTextInstance(instance, text) {
9009
9072
  return instance;
9010
9073
  }
9011
9074
 
9075
+ function canHydrateSuspenseInstance(instance) {
9076
+ if (instance.nodeType !== COMMENT_NODE) {
9077
+ // Empty strings are not parsed by HTML so there won't be a correct match here.
9078
+ return null;
9079
+ }
9080
+ // This has now been refined to a suspense node.
9081
+ return instance;
9082
+ }
9083
+
9012
9084
  function getNextHydratableSibling(instance) {
9013
9085
  var node = instance.nextSibling;
9014
9086
  // Skip non-hydratable nodes.
9015
- while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) {
9087
+ while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || node.nodeType !== COMMENT_NODE || node.data !== SUSPENSE_START_DATA)) {
9016
9088
  node = node.nextSibling;
9017
9089
  }
9018
9090
  return node;
@@ -9021,7 +9093,7 @@ function getNextHydratableSibling(instance) {
9021
9093
  function getFirstHydratableChild(parentInstance) {
9022
9094
  var next = parentInstance.firstChild;
9023
9095
  // Skip non-hydratable nodes.
9024
- while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) {
9096
+ while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || next.nodeType !== COMMENT_NODE || next.data !== SUSPENSE_START_DATA)) {
9025
9097
  next = next.nextSibling;
9026
9098
  }
9027
9099
  return next;
@@ -9045,6 +9117,31 @@ function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
9045
9117
  return diffHydratedText(textInstance, text);
9046
9118
  }
9047
9119
 
9120
+ function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
9121
+ var node = suspenseInstance.nextSibling;
9122
+ // Skip past all nodes within this suspense boundary.
9123
+ // There might be nested nodes so we need to keep track of how
9124
+ // deep we are and only break out when we're back on top.
9125
+ var depth = 0;
9126
+ while (node) {
9127
+ if (node.nodeType === COMMENT_NODE) {
9128
+ var data = node.data;
9129
+ if (data === SUSPENSE_END_DATA) {
9130
+ if (depth === 0) {
9131
+ return getNextHydratableSibling(node);
9132
+ } else {
9133
+ depth--;
9134
+ }
9135
+ } else if (data === SUSPENSE_START_DATA) {
9136
+ depth++;
9137
+ }
9138
+ }
9139
+ node = node.nextSibling;
9140
+ }
9141
+ // TODO: Warn, we didn't find the end comment boundary.
9142
+ return null;
9143
+ }
9144
+
9048
9145
  function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
9049
9146
  {
9050
9147
  warnForUnmatchedText(textInstance, text);
@@ -9061,6 +9158,8 @@ function didNotHydrateContainerInstance(parentContainer, instance) {
9061
9158
  {
9062
9159
  if (instance.nodeType === ELEMENT_NODE) {
9063
9160
  warnForDeletedHydratableElement(parentContainer, instance);
9161
+ } else if (instance.nodeType === COMMENT_NODE) {
9162
+ // TODO: warnForDeletedHydratableSuspenseBoundary
9064
9163
  } else {
9065
9164
  warnForDeletedHydratableText(parentContainer, instance);
9066
9165
  }
@@ -9071,6 +9170,8 @@ function didNotHydrateInstance(parentType, parentProps, parentInstance, instance
9071
9170
  if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
9072
9171
  if (instance.nodeType === ELEMENT_NODE) {
9073
9172
  warnForDeletedHydratableElement(parentInstance, instance);
9173
+ } else if (instance.nodeType === COMMENT_NODE) {
9174
+ // TODO: warnForDeletedHydratableSuspenseBoundary
9074
9175
  } else {
9075
9176
  warnForDeletedHydratableText(parentInstance, instance);
9076
9177
  }
@@ -9089,6 +9190,8 @@ function didNotFindHydratableContainerTextInstance(parentContainer, text) {
9089
9190
  }
9090
9191
  }
9091
9192
 
9193
+
9194
+
9092
9195
  function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
9093
9196
  if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
9094
9197
  warnForInsertedHydratedElement(parentInstance, type, props);
@@ -9101,6 +9204,12 @@ function didNotFindHydratableTextInstance(parentType, parentProps, parentInstanc
9101
9204
  }
9102
9205
  }
9103
9206
 
9207
+ function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
9208
+ if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
9209
+ // TODO: warnForInsertedHydratedSuspense(parentInstance);
9210
+ }
9211
+ }
9212
+
9104
9213
  // This is just to get the setup running.
9105
9214
  // TODO: real implementation.
9106
9215
  // console.log('Hello from Fire host config.');
@@ -9360,7 +9469,7 @@ function stopFailedWorkTimer(fiber) {
9360
9469
  return;
9361
9470
  }
9362
9471
  fiber._debugIsCurrentlyTiming = false;
9363
- var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
9472
+ var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
9364
9473
  endFiberMark(fiber, null, warning);
9365
9474
  }
9366
9475
  }
@@ -10029,6 +10138,7 @@ function FiberNode(tag, pendingProps, key, mode) {
10029
10138
  this._debugSource = null;
10030
10139
  this._debugOwner = null;
10031
10140
  this._debugIsCurrentlyTiming = false;
10141
+ this._debugHookTypes = null;
10032
10142
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
10033
10143
  Object.preventExtensions(this);
10034
10144
  }
@@ -10096,6 +10206,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
10096
10206
  workInProgress._debugID = current._debugID;
10097
10207
  workInProgress._debugSource = current._debugSource;
10098
10208
  workInProgress._debugOwner = current._debugOwner;
10209
+ workInProgress._debugHookTypes = current._debugHookTypes;
10099
10210
  }
10100
10211
 
10101
10212
  workInProgress.alternate = current;
@@ -10363,6 +10474,7 @@ function assignFiberPropertiesInDEV(target, source) {
10363
10474
  target._debugSource = source._debugSource;
10364
10475
  target._debugOwner = source._debugOwner;
10365
10476
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
10477
+ target._debugHookTypes = source._debugHookTypes;
10366
10478
  return target;
10367
10479
  }
10368
10480
 
@@ -12180,7 +12292,7 @@ function ChildReconciler(shouldTrackSideEffects) {
12180
12292
  }
12181
12293
 
12182
12294
  function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
12183
- // This algorithm can't optimize by searching from boths ends since we
12295
+ // This algorithm can't optimize by searching from both ends since we
12184
12296
  // don't have backpointers on fibers. I'm trying to see how far we can get
12185
12297
  // with that model. If it ends up not being worth the tradeoffs, we can
12186
12298
  // add it later.
@@ -12761,7 +12873,6 @@ var currentlyRenderingFiber$1 = null;
12761
12873
  // current hook list is the list that belongs to the current fiber. The
12762
12874
  // work-in-progress hook list is a new list that will be added to the
12763
12875
  // work-in-progress fiber.
12764
- var firstCurrentHook = null;
12765
12876
  var currentHook = null;
12766
12877
  var nextCurrentHook = null;
12767
12878
  var firstWorkInProgressHook = null;
@@ -12791,45 +12902,73 @@ var RE_RENDER_LIMIT = 25;
12791
12902
  // In DEV, this is the name of the currently executing primitive hook
12792
12903
  var currentHookNameInDev = null;
12793
12904
 
12794
- function warnOnHookMismatchInDev() {
12905
+ // In DEV, this list ensures that hooks are called in the same order between renders.
12906
+ // The list stores the order of hooks used during the initial render (mount).
12907
+ // Subsequent renders (updates) reference this list.
12908
+ var hookTypesDev = null;
12909
+ var hookTypesUpdateIndexDev = -1;
12910
+
12911
+ function mountHookTypesDev() {
12912
+ {
12913
+ var hookName = currentHookNameInDev;
12914
+
12915
+ if (hookTypesDev === null) {
12916
+ hookTypesDev = [hookName];
12917
+ } else {
12918
+ hookTypesDev.push(hookName);
12919
+ }
12920
+ }
12921
+ }
12922
+
12923
+ function updateHookTypesDev() {
12924
+ {
12925
+ var hookName = currentHookNameInDev;
12926
+
12927
+ if (hookTypesDev !== null) {
12928
+ hookTypesUpdateIndexDev++;
12929
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
12930
+ warnOnHookMismatchInDev(hookName);
12931
+ }
12932
+ }
12933
+ }
12934
+ }
12935
+
12936
+ function warnOnHookMismatchInDev(currentHookName) {
12795
12937
  {
12796
12938
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
12797
12939
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
12798
12940
  didWarnAboutMismatchedHooksForComponent.add(componentName);
12799
12941
 
12800
- var secondColumnStart = 22;
12942
+ if (hookTypesDev !== null) {
12943
+ var table = '';
12801
12944
 
12802
- var table = '';
12803
- var prevHook = firstCurrentHook;
12804
- var nextHook = firstWorkInProgressHook;
12805
- var n = 1;
12806
- while (prevHook !== null && nextHook !== null) {
12807
- var oldHookName = prevHook._debugType;
12808
- var newHookName = nextHook._debugType;
12945
+ var secondColumnStart = 30;
12809
12946
 
12810
- var row = n + '. ' + oldHookName;
12947
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
12948
+ var oldHookName = hookTypesDev[i];
12949
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
12811
12950
 
12812
- // Extra space so second column lines up
12813
- // lol @ IE not supporting String#repeat
12814
- while (row.length < secondColumnStart) {
12815
- row += ' ';
12816
- }
12951
+ var row = i + 1 + '. ' + oldHookName;
12817
12952
 
12818
- row += newHookName + '\n';
12953
+ // Extra space so second column lines up
12954
+ // lol @ IE not supporting String#repeat
12955
+ while (row.length < secondColumnStart) {
12956
+ row += ' ';
12957
+ }
12819
12958
 
12820
- table += row;
12821
- prevHook = prevHook.next;
12822
- nextHook = nextHook.next;
12823
- n++;
12824
- }
12959
+ row += newHookName + '\n';
12960
+
12961
+ table += row;
12962
+ }
12825
12963
 
12826
- 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);
12964
+ 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);
12965
+ }
12827
12966
  }
12828
12967
  }
12829
12968
  }
12830
12969
 
12831
12970
  function throwInvalidHookError() {
12832
- invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)');
12971
+ invariant(false, 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.');
12833
12972
  }
12834
12973
 
12835
12974
  function areHookInputsEqual(nextDeps, prevDeps) {
@@ -12859,7 +12998,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
12859
12998
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
12860
12999
  renderExpirationTime = nextRenderExpirationTime;
12861
13000
  currentlyRenderingFiber$1 = workInProgress;
12862
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
13001
+ nextCurrentHook = current !== null ? current.memoizedState : null;
13002
+
13003
+ {
13004
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
13005
+ hookTypesUpdateIndexDev = -1;
13006
+ }
12863
13007
 
12864
13008
  // The following should have already been reset
12865
13009
  // currentHook = null;
@@ -12873,8 +13017,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12873
13017
  // numberOfReRenders = 0;
12874
13018
  // sideEffectTag = 0;
12875
13019
 
13020
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
13021
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
13022
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
13023
+
13024
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
13025
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
13026
+ // so nextCurrentHook would be null during updates and mounts.
12876
13027
  {
12877
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
13028
+ if (nextCurrentHook !== null) {
13029
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
13030
+ } else if (hookTypesDev !== null) {
13031
+ // This dispatcher handles an edge case where a component is updating,
13032
+ // but no stateful hooks have been used.
13033
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
13034
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
13035
+ // This dispatcher does that.
13036
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
13037
+ } else {
13038
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
13039
+ }
12878
13040
  }
12879
13041
 
12880
13042
  var children = Component(props, refOrContext);
@@ -12885,13 +13047,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12885
13047
  numberOfReRenders += 1;
12886
13048
 
12887
13049
  // Start over from the beginning of the list
12888
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
13050
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12889
13051
  nextWorkInProgressHook = firstWorkInProgressHook;
12890
13052
 
12891
13053
  currentHook = null;
12892
13054
  workInProgressHook = null;
12893
13055
  componentUpdateQueue = null;
12894
13056
 
13057
+ {
13058
+ // Also validate hook order for cascading updates.
13059
+ hookTypesUpdateIndexDev = -1;
13060
+ }
13061
+
12895
13062
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12896
13063
 
12897
13064
  children = Component(props, refOrContext);
@@ -12901,10 +13068,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12901
13068
  numberOfReRenders = 0;
12902
13069
  }
12903
13070
 
12904
- {
12905
- currentHookNameInDev = null;
12906
- }
12907
-
12908
13071
  // We can assume the previous dispatcher is always this one, since we set it
12909
13072
  // at the beginning of the render phase and there's no re-entrancy.
12910
13073
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -12916,18 +13079,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12916
13079
  renderedWork.updateQueue = componentUpdateQueue;
12917
13080
  renderedWork.effectTag |= sideEffectTag;
12918
13081
 
13082
+ {
13083
+ renderedWork._debugHookTypes = hookTypesDev;
13084
+ }
13085
+
13086
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
13087
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
12919
13088
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
12920
13089
 
12921
13090
  renderExpirationTime = NoWork;
12922
13091
  currentlyRenderingFiber$1 = null;
12923
13092
 
12924
- firstCurrentHook = null;
12925
13093
  currentHook = null;
12926
13094
  nextCurrentHook = null;
12927
13095
  firstWorkInProgressHook = null;
12928
13096
  workInProgressHook = null;
12929
13097
  nextWorkInProgressHook = null;
12930
13098
 
13099
+ {
13100
+ currentHookNameInDev = null;
13101
+ hookTypesDev = null;
13102
+ hookTypesUpdateIndexDev = -1;
13103
+ }
13104
+
12931
13105
  remainingExpirationTime = NoWork;
12932
13106
  componentUpdateQueue = null;
12933
13107
  sideEffectTag = 0;
@@ -12961,21 +13135,23 @@ function resetHooks() {
12961
13135
  renderExpirationTime = NoWork;
12962
13136
  currentlyRenderingFiber$1 = null;
12963
13137
 
12964
- firstCurrentHook = null;
12965
13138
  currentHook = null;
12966
13139
  nextCurrentHook = null;
12967
13140
  firstWorkInProgressHook = null;
12968
13141
  workInProgressHook = null;
12969
13142
  nextWorkInProgressHook = null;
12970
13143
 
12971
- remainingExpirationTime = NoWork;
12972
- componentUpdateQueue = null;
12973
- sideEffectTag = 0;
12974
-
12975
13144
  {
13145
+ hookTypesDev = null;
13146
+ hookTypesUpdateIndexDev = -1;
13147
+
12976
13148
  currentHookNameInDev = null;
12977
13149
  }
12978
13150
 
13151
+ remainingExpirationTime = NoWork;
13152
+ componentUpdateQueue = null;
13153
+ sideEffectTag = 0;
13154
+
12979
13155
  didScheduleRenderPhaseUpdate = false;
12980
13156
  renderPhaseUpdates = null;
12981
13157
  numberOfReRenders = 0;
@@ -12992,12 +13168,6 @@ function mountWorkInProgressHook() {
12992
13168
  next: null
12993
13169
  };
12994
13170
 
12995
- {
12996
- hook._debugType = currentHookNameInDev;
12997
- if (currentlyRenderingFiber$1 !== null && currentlyRenderingFiber$1.alternate !== null) {
12998
- 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));
12999
- }
13000
- }
13001
13171
  if (workInProgressHook === null) {
13002
13172
  // This is the first hook in the list
13003
13173
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -13044,13 +13214,6 @@ function updateWorkInProgressHook() {
13044
13214
  workInProgressHook = workInProgressHook.next = newHook;
13045
13215
  }
13046
13216
  nextCurrentHook = currentHook.next;
13047
-
13048
- {
13049
- newHook._debugType = currentHookNameInDev;
13050
- if (currentHookNameInDev !== currentHook._debugType) {
13051
- warnOnHookMismatchInDev();
13052
- }
13053
- }
13054
13217
  }
13055
13218
  return workInProgressHook;
13056
13219
  }
@@ -13065,20 +13228,6 @@ function basicStateReducer(state, action) {
13065
13228
  return typeof action === 'function' ? action(state) : action;
13066
13229
  }
13067
13230
 
13068
- function mountContext(context, observedBits) {
13069
- {
13070
- mountWorkInProgressHook();
13071
- }
13072
- return readContext(context, observedBits);
13073
- }
13074
-
13075
- function updateContext(context, observedBits) {
13076
- {
13077
- updateWorkInProgressHook();
13078
- }
13079
- return readContext(context, observedBits);
13080
- }
13081
-
13082
13231
  function mountReducer(reducer, initialArg, init) {
13083
13232
  var hook = mountWorkInProgressHook();
13084
13233
  var initialState = void 0;
@@ -13131,7 +13280,6 @@ function updateReducer(reducer, initialArg, init) {
13131
13280
  }
13132
13281
 
13133
13282
  hook.memoizedState = newState;
13134
-
13135
13283
  // Don't persist the state accumlated from the render phase updates to
13136
13284
  // the base state unless the queue is empty.
13137
13285
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -13140,6 +13288,9 @@ function updateReducer(reducer, initialArg, init) {
13140
13288
  hook.baseState = newState;
13141
13289
  }
13142
13290
 
13291
+ queue.eagerReducer = reducer;
13292
+ queue.eagerState = newState;
13293
+
13143
13294
  return [newState, _dispatch];
13144
13295
  }
13145
13296
  }
@@ -13359,7 +13510,7 @@ function mountImperativeHandle(ref, create, deps) {
13359
13510
  }
13360
13511
 
13361
13512
  // TODO: If deps are provided, should we skip comparing the ref itself?
13362
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
13513
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
13363
13514
 
13364
13515
  return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
13365
13516
  }
@@ -13370,7 +13521,7 @@ function updateImperativeHandle(ref, create, deps) {
13370
13521
  }
13371
13522
 
13372
13523
  // TODO: If deps are provided, should we skip comparing the ref itself?
13373
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
13524
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
13374
13525
 
13375
13526
  return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
13376
13527
  }
@@ -13437,7 +13588,7 @@ function updateMemo(nextCreate, deps) {
13437
13588
  var shouldWarnForUnbatchedSetState = false;
13438
13589
 
13439
13590
  {
13440
- // jest isnt' a 'global', it's just exposed to tests via a wrapped function
13591
+ // jest isn't a 'global', it's just exposed to tests via a wrapped function
13441
13592
  // further, this isn't a test file, so flow doesn't recognize the symbol. So...
13442
13593
  // $FlowExpectedError - because requirements don't give a damn about your type sigs.
13443
13594
  if ('undefined' !== typeof jest) {
@@ -13569,6 +13720,7 @@ var ContextOnlyDispatcher = {
13569
13720
  };
13570
13721
 
13571
13722
  var HooksDispatcherOnMountInDEV = null;
13723
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
13572
13724
  var HooksDispatcherOnUpdateInDEV = null;
13573
13725
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
13574
13726
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -13588,26 +13740,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13588
13740
  },
13589
13741
  useCallback: function (callback, deps) {
13590
13742
  currentHookNameInDev = 'useCallback';
13743
+ mountHookTypesDev();
13744
+ return mountCallback(callback, deps);
13745
+ },
13746
+ useContext: function (context, observedBits) {
13747
+ currentHookNameInDev = 'useContext';
13748
+ mountHookTypesDev();
13749
+ return readContext(context, observedBits);
13750
+ },
13751
+ useEffect: function (create, deps) {
13752
+ currentHookNameInDev = 'useEffect';
13753
+ mountHookTypesDev();
13754
+ return mountEffect(create, deps);
13755
+ },
13756
+ useImperativeHandle: function (ref, create, deps) {
13757
+ currentHookNameInDev = 'useImperativeHandle';
13758
+ mountHookTypesDev();
13759
+ return mountImperativeHandle(ref, create, deps);
13760
+ },
13761
+ useLayoutEffect: function (create, deps) {
13762
+ currentHookNameInDev = 'useLayoutEffect';
13763
+ mountHookTypesDev();
13764
+ return mountLayoutEffect(create, deps);
13765
+ },
13766
+ useMemo: function (create, deps) {
13767
+ currentHookNameInDev = 'useMemo';
13768
+ mountHookTypesDev();
13769
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13770
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13771
+ try {
13772
+ return mountMemo(create, deps);
13773
+ } finally {
13774
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13775
+ }
13776
+ },
13777
+ useReducer: function (reducer, initialArg, init) {
13778
+ currentHookNameInDev = 'useReducer';
13779
+ mountHookTypesDev();
13780
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13781
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13782
+ try {
13783
+ return mountReducer(reducer, initialArg, init);
13784
+ } finally {
13785
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13786
+ }
13787
+ },
13788
+ useRef: function (initialValue) {
13789
+ currentHookNameInDev = 'useRef';
13790
+ mountHookTypesDev();
13791
+ return mountRef(initialValue);
13792
+ },
13793
+ useState: function (initialState) {
13794
+ currentHookNameInDev = 'useState';
13795
+ mountHookTypesDev();
13796
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13797
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13798
+ try {
13799
+ return mountState(initialState);
13800
+ } finally {
13801
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13802
+ }
13803
+ },
13804
+ useDebugValue: function (value, formatterFn) {
13805
+ currentHookNameInDev = 'useDebugValue';
13806
+ mountHookTypesDev();
13807
+ return mountDebugValue(value, formatterFn);
13808
+ }
13809
+ };
13810
+
13811
+ HooksDispatcherOnMountWithHookTypesInDEV = {
13812
+ readContext: function (context, observedBits) {
13813
+ return readContext(context, observedBits);
13814
+ },
13815
+ useCallback: function (callback, deps) {
13816
+ currentHookNameInDev = 'useCallback';
13817
+ updateHookTypesDev();
13591
13818
  return mountCallback(callback, deps);
13592
13819
  },
13593
13820
  useContext: function (context, observedBits) {
13594
13821
  currentHookNameInDev = 'useContext';
13595
- return mountContext(context, observedBits);
13822
+ updateHookTypesDev();
13823
+ return readContext(context, observedBits);
13596
13824
  },
13597
13825
  useEffect: function (create, deps) {
13598
13826
  currentHookNameInDev = 'useEffect';
13827
+ updateHookTypesDev();
13599
13828
  return mountEffect(create, deps);
13600
13829
  },
13601
13830
  useImperativeHandle: function (ref, create, deps) {
13602
13831
  currentHookNameInDev = 'useImperativeHandle';
13832
+ updateHookTypesDev();
13603
13833
  return mountImperativeHandle(ref, create, deps);
13604
13834
  },
13605
13835
  useLayoutEffect: function (create, deps) {
13606
13836
  currentHookNameInDev = 'useLayoutEffect';
13837
+ updateHookTypesDev();
13607
13838
  return mountLayoutEffect(create, deps);
13608
13839
  },
13609
13840
  useMemo: function (create, deps) {
13610
13841
  currentHookNameInDev = 'useMemo';
13842
+ updateHookTypesDev();
13611
13843
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13612
13844
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13613
13845
  try {
@@ -13618,6 +13850,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13618
13850
  },
13619
13851
  useReducer: function (reducer, initialArg, init) {
13620
13852
  currentHookNameInDev = 'useReducer';
13853
+ updateHookTypesDev();
13621
13854
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13622
13855
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13623
13856
  try {
@@ -13628,10 +13861,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13628
13861
  },
13629
13862
  useRef: function (initialValue) {
13630
13863
  currentHookNameInDev = 'useRef';
13864
+ updateHookTypesDev();
13631
13865
  return mountRef(initialValue);
13632
13866
  },
13633
13867
  useState: function (initialState) {
13634
13868
  currentHookNameInDev = 'useState';
13869
+ updateHookTypesDev();
13635
13870
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13636
13871
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13637
13872
  try {
@@ -13642,6 +13877,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13642
13877
  },
13643
13878
  useDebugValue: function (value, formatterFn) {
13644
13879
  currentHookNameInDev = 'useDebugValue';
13880
+ updateHookTypesDev();
13645
13881
  return mountDebugValue(value, formatterFn);
13646
13882
  }
13647
13883
  };
@@ -13652,26 +13888,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13652
13888
  },
13653
13889
  useCallback: function (callback, deps) {
13654
13890
  currentHookNameInDev = 'useCallback';
13891
+ updateHookTypesDev();
13655
13892
  return updateCallback(callback, deps);
13656
13893
  },
13657
13894
  useContext: function (context, observedBits) {
13658
13895
  currentHookNameInDev = 'useContext';
13659
- return updateContext(context, observedBits);
13896
+ updateHookTypesDev();
13897
+ return readContext(context, observedBits);
13660
13898
  },
13661
13899
  useEffect: function (create, deps) {
13662
13900
  currentHookNameInDev = 'useEffect';
13901
+ updateHookTypesDev();
13663
13902
  return updateEffect(create, deps);
13664
13903
  },
13665
13904
  useImperativeHandle: function (ref, create, deps) {
13666
13905
  currentHookNameInDev = 'useImperativeHandle';
13906
+ updateHookTypesDev();
13667
13907
  return updateImperativeHandle(ref, create, deps);
13668
13908
  },
13669
13909
  useLayoutEffect: function (create, deps) {
13670
13910
  currentHookNameInDev = 'useLayoutEffect';
13911
+ updateHookTypesDev();
13671
13912
  return updateLayoutEffect(create, deps);
13672
13913
  },
13673
13914
  useMemo: function (create, deps) {
13674
13915
  currentHookNameInDev = 'useMemo';
13916
+ updateHookTypesDev();
13675
13917
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13676
13918
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13677
13919
  try {
@@ -13682,6 +13924,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13682
13924
  },
13683
13925
  useReducer: function (reducer, initialArg, init) {
13684
13926
  currentHookNameInDev = 'useReducer';
13927
+ updateHookTypesDev();
13685
13928
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13686
13929
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13687
13930
  try {
@@ -13692,10 +13935,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13692
13935
  },
13693
13936
  useRef: function (initialValue) {
13694
13937
  currentHookNameInDev = 'useRef';
13938
+ updateHookTypesDev();
13695
13939
  return updateRef(initialValue);
13696
13940
  },
13697
13941
  useState: function (initialState) {
13698
13942
  currentHookNameInDev = 'useState';
13943
+ updateHookTypesDev();
13699
13944
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13700
13945
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13701
13946
  try {
@@ -13706,6 +13951,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13706
13951
  },
13707
13952
  useDebugValue: function (value, formatterFn) {
13708
13953
  currentHookNameInDev = 'useDebugValue';
13954
+ updateHookTypesDev();
13709
13955
  return updateDebugValue(value, formatterFn);
13710
13956
  }
13711
13957
  };
@@ -13718,31 +13964,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13718
13964
  useCallback: function (callback, deps) {
13719
13965
  currentHookNameInDev = 'useCallback';
13720
13966
  warnInvalidHookAccess();
13967
+ mountHookTypesDev();
13721
13968
  return mountCallback(callback, deps);
13722
13969
  },
13723
13970
  useContext: function (context, observedBits) {
13724
13971
  currentHookNameInDev = 'useContext';
13725
13972
  warnInvalidHookAccess();
13726
- return mountContext(context, observedBits);
13973
+ mountHookTypesDev();
13974
+ return readContext(context, observedBits);
13727
13975
  },
13728
13976
  useEffect: function (create, deps) {
13729
13977
  currentHookNameInDev = 'useEffect';
13730
13978
  warnInvalidHookAccess();
13979
+ mountHookTypesDev();
13731
13980
  return mountEffect(create, deps);
13732
13981
  },
13733
13982
  useImperativeHandle: function (ref, create, deps) {
13734
13983
  currentHookNameInDev = 'useImperativeHandle';
13735
13984
  warnInvalidHookAccess();
13985
+ mountHookTypesDev();
13736
13986
  return mountImperativeHandle(ref, create, deps);
13737
13987
  },
13738
13988
  useLayoutEffect: function (create, deps) {
13739
13989
  currentHookNameInDev = 'useLayoutEffect';
13740
13990
  warnInvalidHookAccess();
13991
+ mountHookTypesDev();
13741
13992
  return mountLayoutEffect(create, deps);
13742
13993
  },
13743
13994
  useMemo: function (create, deps) {
13744
13995
  currentHookNameInDev = 'useMemo';
13745
13996
  warnInvalidHookAccess();
13997
+ mountHookTypesDev();
13746
13998
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13747
13999
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13748
14000
  try {
@@ -13754,6 +14006,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13754
14006
  useReducer: function (reducer, initialArg, init) {
13755
14007
  currentHookNameInDev = 'useReducer';
13756
14008
  warnInvalidHookAccess();
14009
+ mountHookTypesDev();
13757
14010
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13758
14011
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13759
14012
  try {
@@ -13765,11 +14018,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13765
14018
  useRef: function (initialValue) {
13766
14019
  currentHookNameInDev = 'useRef';
13767
14020
  warnInvalidHookAccess();
14021
+ mountHookTypesDev();
13768
14022
  return mountRef(initialValue);
13769
14023
  },
13770
14024
  useState: function (initialState) {
13771
14025
  currentHookNameInDev = 'useState';
13772
14026
  warnInvalidHookAccess();
14027
+ mountHookTypesDev();
13773
14028
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13774
14029
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13775
14030
  try {
@@ -13781,6 +14036,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13781
14036
  useDebugValue: function (value, formatterFn) {
13782
14037
  currentHookNameInDev = 'useDebugValue';
13783
14038
  warnInvalidHookAccess();
14039
+ mountHookTypesDev();
13784
14040
  return mountDebugValue(value, formatterFn);
13785
14041
  }
13786
14042
  };
@@ -13793,31 +14049,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13793
14049
  useCallback: function (callback, deps) {
13794
14050
  currentHookNameInDev = 'useCallback';
13795
14051
  warnInvalidHookAccess();
14052
+ updateHookTypesDev();
13796
14053
  return updateCallback(callback, deps);
13797
14054
  },
13798
14055
  useContext: function (context, observedBits) {
13799
14056
  currentHookNameInDev = 'useContext';
13800
14057
  warnInvalidHookAccess();
13801
- return updateContext(context, observedBits);
14058
+ updateHookTypesDev();
14059
+ return readContext(context, observedBits);
13802
14060
  },
13803
14061
  useEffect: function (create, deps) {
13804
14062
  currentHookNameInDev = 'useEffect';
13805
14063
  warnInvalidHookAccess();
14064
+ updateHookTypesDev();
13806
14065
  return updateEffect(create, deps);
13807
14066
  },
13808
14067
  useImperativeHandle: function (ref, create, deps) {
13809
14068
  currentHookNameInDev = 'useImperativeHandle';
13810
14069
  warnInvalidHookAccess();
14070
+ updateHookTypesDev();
13811
14071
  return updateImperativeHandle(ref, create, deps);
13812
14072
  },
13813
14073
  useLayoutEffect: function (create, deps) {
13814
14074
  currentHookNameInDev = 'useLayoutEffect';
13815
14075
  warnInvalidHookAccess();
14076
+ updateHookTypesDev();
13816
14077
  return updateLayoutEffect(create, deps);
13817
14078
  },
13818
14079
  useMemo: function (create, deps) {
13819
14080
  currentHookNameInDev = 'useMemo';
13820
14081
  warnInvalidHookAccess();
14082
+ updateHookTypesDev();
13821
14083
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13822
14084
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13823
14085
  try {
@@ -13829,6 +14091,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13829
14091
  useReducer: function (reducer, initialArg, init) {
13830
14092
  currentHookNameInDev = 'useReducer';
13831
14093
  warnInvalidHookAccess();
14094
+ updateHookTypesDev();
13832
14095
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13833
14096
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13834
14097
  try {
@@ -13840,11 +14103,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13840
14103
  useRef: function (initialValue) {
13841
14104
  currentHookNameInDev = 'useRef';
13842
14105
  warnInvalidHookAccess();
14106
+ updateHookTypesDev();
13843
14107
  return updateRef(initialValue);
13844
14108
  },
13845
14109
  useState: function (initialState) {
13846
14110
  currentHookNameInDev = 'useState';
13847
14111
  warnInvalidHookAccess();
14112
+ updateHookTypesDev();
13848
14113
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13849
14114
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13850
14115
  try {
@@ -13856,6 +14121,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13856
14121
  useDebugValue: function (value, formatterFn) {
13857
14122
  currentHookNameInDev = 'useDebugValue';
13858
14123
  warnInvalidHookAccess();
14124
+ updateHookTypesDev();
13859
14125
  return updateDebugValue(value, formatterFn);
13860
14126
  }
13861
14127
  };
@@ -13927,6 +14193,18 @@ function enterHydrationState(fiber) {
13927
14193
  return true;
13928
14194
  }
13929
14195
 
14196
+ function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
14197
+ if (!supportsHydration) {
14198
+ return false;
14199
+ }
14200
+
14201
+ var suspenseInstance = fiber.stateNode;
14202
+ nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
14203
+ popToNextHostParent(fiber);
14204
+ isHydrating = true;
14205
+ return true;
14206
+ }
14207
+
13930
14208
  function deleteHydratableInstance(returnFiber, instance) {
13931
14209
  {
13932
14210
  switch (returnFiber.tag) {
@@ -13973,6 +14251,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
13973
14251
  case HostText:
13974
14252
  var text = fiber.pendingProps;
13975
14253
  didNotFindHydratableContainerTextInstance(parentContainer, text);
14254
+ break;
14255
+ case SuspenseComponent:
14256
+
13976
14257
  break;
13977
14258
  }
13978
14259
  break;
@@ -13992,6 +14273,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
13992
14273
  var _text = fiber.pendingProps;
13993
14274
  didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
13994
14275
  break;
14276
+ case SuspenseComponent:
14277
+ didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
14278
+ break;
13995
14279
  }
13996
14280
  break;
13997
14281
  }
@@ -14024,6 +14308,19 @@ function tryHydrate(fiber, nextInstance) {
14024
14308
  }
14025
14309
  return false;
14026
14310
  }
14311
+ case SuspenseComponent:
14312
+ {
14313
+ if (enableSuspenseServerRenderer) {
14314
+ var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
14315
+ if (suspenseInstance !== null) {
14316
+ // Downgrade the tag to a dehydrated component until we've hydrated it.
14317
+ fiber.tag = DehydratedSuspenseComponent;
14318
+ fiber.stateNode = suspenseInstance;
14319
+ return true;
14320
+ }
14321
+ }
14322
+ return false;
14323
+ }
14027
14324
  default:
14028
14325
  return false;
14029
14326
  }
@@ -14117,9 +14414,18 @@ function prepareToHydrateHostTextInstance(fiber) {
14117
14414
  return shouldUpdate;
14118
14415
  }
14119
14416
 
14417
+ function skipPastDehydratedSuspenseInstance(fiber) {
14418
+ if (!supportsHydration) {
14419
+ invariant(false, 'Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
14420
+ }
14421
+ var suspenseInstance = fiber.stateNode;
14422
+ !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;
14423
+ nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
14424
+ }
14425
+
14120
14426
  function popToNextHostParent(fiber) {
14121
14427
  var parent = fiber.return;
14122
- while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
14428
+ while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
14123
14429
  parent = parent.return;
14124
14430
  }
14125
14431
  hydrationParentFiber = parent;
@@ -14227,6 +14533,10 @@ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildre
14227
14533
  }
14228
14534
 
14229
14535
  function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
14536
+ // TODO: current can be non-null here even if the component
14537
+ // hasn't yet mounted. This happens after the first render suspends.
14538
+ // We'll need to figure out if this is fine or can cause issues.
14539
+
14230
14540
  {
14231
14541
  if (workInProgress.type !== workInProgress.elementType) {
14232
14542
  // Lazy component props can't be validated in createElement
@@ -14332,6 +14642,10 @@ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, u
14332
14642
  }
14333
14643
 
14334
14644
  function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
14645
+ // TODO: current can be non-null here even if the component
14646
+ // hasn't yet mounted. This happens when the inner render suspends.
14647
+ // We'll need to figure out if this is fine or can cause issues.
14648
+
14335
14649
  {
14336
14650
  if (workInProgress.type !== workInProgress.elementType) {
14337
14651
  // Lazy component props can't be validated in createElement
@@ -14955,6 +15269,18 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
14955
15269
  // children -- we skip over the primary children entirely.
14956
15270
  var next = void 0;
14957
15271
  if (current$$1 === null) {
15272
+ if (enableSuspenseServerRenderer) {
15273
+ // If we're currently hydrating, try to hydrate this boundary.
15274
+ // But only if this has a fallback.
15275
+ if (nextProps.fallback !== undefined) {
15276
+ tryToClaimNextHydratableInstance(workInProgress);
15277
+ // This could've changed the tag if this was a dehydrated suspense component.
15278
+ if (workInProgress.tag === DehydratedSuspenseComponent) {
15279
+ return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
15280
+ }
15281
+ }
15282
+ }
15283
+
14958
15284
  // This is the initial mount. This branch is pretty simple because there's
14959
15285
  // no previous state that needs to be preserved.
14960
15286
  if (nextDidTimeout) {
@@ -15106,6 +15432,65 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
15106
15432
  return next;
15107
15433
  }
15108
15434
 
15435
+ function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
15436
+ if (current$$1 === null) {
15437
+ // During the first pass, we'll bail out and not drill into the children.
15438
+ // Instead, we'll leave the content in place and try to hydrate it later.
15439
+ workInProgress.expirationTime = Never;
15440
+ return null;
15441
+ }
15442
+ // We use childExpirationTime to indicate that a child might depend on context, so if
15443
+ // any context has changed, we need to treat is as if the input might have changed.
15444
+ var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
15445
+ if (didReceiveUpdate || hasContextChanged$$1) {
15446
+ // This boundary has changed since the first render. This means that we are now unable to
15447
+ // hydrate it. We might still be able to hydrate it using an earlier expiration time but
15448
+ // during this render we can't. Instead, we're going to delete the whole subtree and
15449
+ // instead inject a new real Suspense boundary to take its place, which may render content
15450
+ // or fallback. The real Suspense boundary will suspend for a while so we have some time
15451
+ // to ensure it can produce real content, but all state and pending events will be lost.
15452
+
15453
+ // Detach from the current dehydrated boundary.
15454
+ current$$1.alternate = null;
15455
+ workInProgress.alternate = null;
15456
+
15457
+ // Insert a deletion in the effect list.
15458
+ var returnFiber = workInProgress.return;
15459
+ !(returnFiber !== null) ? invariant(false, 'Suspense boundaries are never on the root. This is probably a bug in React.') : void 0;
15460
+ var last = returnFiber.lastEffect;
15461
+ if (last !== null) {
15462
+ last.nextEffect = current$$1;
15463
+ returnFiber.lastEffect = current$$1;
15464
+ } else {
15465
+ returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
15466
+ }
15467
+ current$$1.nextEffect = null;
15468
+ current$$1.effectTag = Deletion;
15469
+
15470
+ // Upgrade this work in progress to a real Suspense component.
15471
+ workInProgress.tag = SuspenseComponent;
15472
+ workInProgress.stateNode = null;
15473
+ workInProgress.memoizedState = null;
15474
+ // This is now an insertion.
15475
+ workInProgress.effectTag |= Placement;
15476
+ // Retry as a real Suspense component.
15477
+ return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
15478
+ }
15479
+ if ((workInProgress.effectTag & DidCapture) === NoEffect) {
15480
+ // This is the first attempt.
15481
+ reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
15482
+ var nextProps = workInProgress.pendingProps;
15483
+ var nextChildren = nextProps.children;
15484
+ workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
15485
+ return workInProgress.child;
15486
+ } else {
15487
+ // Something suspended. Leave the existing children in place.
15488
+ // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
15489
+ workInProgress.child = null;
15490
+ return null;
15491
+ }
15492
+ }
15493
+
15109
15494
  function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
15110
15495
  pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
15111
15496
  var nextChildren = workInProgress.pendingProps;
@@ -15317,6 +15702,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
15317
15702
  }
15318
15703
  break;
15319
15704
  }
15705
+ case DehydratedSuspenseComponent:
15706
+ {
15707
+ if (enableSuspenseServerRenderer) {
15708
+ // We know that this component will suspend again because if it has
15709
+ // been unsuspended it has committed as a regular Suspense component.
15710
+ // If it needs to be retried, it should have work scheduled on it.
15711
+ workInProgress.effectTag |= DidCapture;
15712
+ break;
15713
+ }
15714
+ }
15320
15715
  }
15321
15716
  return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
15322
15717
  }
@@ -15408,9 +15803,15 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
15408
15803
  var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
15409
15804
  return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
15410
15805
  }
15411
- default:
15412
- invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
15806
+ case DehydratedSuspenseComponent:
15807
+ {
15808
+ if (enableSuspenseServerRenderer) {
15809
+ return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
15810
+ }
15811
+ break;
15812
+ }
15413
15813
  }
15814
+ invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
15414
15815
  }
15415
15816
 
15416
15817
  var valueCursor = createCursor(null);
@@ -15499,6 +15900,28 @@ function calculateChangedBits(context, newValue, oldValue) {
15499
15900
  }
15500
15901
  }
15501
15902
 
15903
+ function scheduleWorkOnParentPath(parent, renderExpirationTime) {
15904
+ // Update the child expiration time of all the ancestors, including
15905
+ // the alternates.
15906
+ var node = parent;
15907
+ while (node !== null) {
15908
+ var alternate = node.alternate;
15909
+ if (node.childExpirationTime < renderExpirationTime) {
15910
+ node.childExpirationTime = renderExpirationTime;
15911
+ if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15912
+ alternate.childExpirationTime = renderExpirationTime;
15913
+ }
15914
+ } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15915
+ alternate.childExpirationTime = renderExpirationTime;
15916
+ } else {
15917
+ // Neither alternate was updated, which means the rest of the
15918
+ // ancestor path already has sufficient priority.
15919
+ break;
15920
+ }
15921
+ node = node.return;
15922
+ }
15923
+ }
15924
+
15502
15925
  function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
15503
15926
  var fiber = workInProgress.child;
15504
15927
  if (fiber !== null) {
@@ -15537,25 +15960,8 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
15537
15960
  if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
15538
15961
  alternate.expirationTime = renderExpirationTime;
15539
15962
  }
15540
- // Update the child expiration time of all the ancestors, including
15541
- // the alternates.
15542
- var node = fiber.return;
15543
- while (node !== null) {
15544
- alternate = node.alternate;
15545
- if (node.childExpirationTime < renderExpirationTime) {
15546
- node.childExpirationTime = renderExpirationTime;
15547
- if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15548
- alternate.childExpirationTime = renderExpirationTime;
15549
- }
15550
- } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15551
- alternate.childExpirationTime = renderExpirationTime;
15552
- } else {
15553
- // Neither alternate was updated, which means the rest of the
15554
- // ancestor path already has sufficient priority.
15555
- break;
15556
- }
15557
- node = node.return;
15558
- }
15963
+
15964
+ scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
15559
15965
 
15560
15966
  // Mark the expiration time on the list, too.
15561
15967
  if (list.expirationTime < renderExpirationTime) {
@@ -15571,6 +15977,23 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
15571
15977
  } else if (fiber.tag === ContextProvider) {
15572
15978
  // Don't scan deeper if this is a matching provider
15573
15979
  nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
15980
+ } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
15981
+ // If a dehydrated suspense component is in this subtree, we don't know
15982
+ // if it will have any context consumers in it. The best we can do is
15983
+ // mark it as having updates on its children.
15984
+ if (fiber.expirationTime < renderExpirationTime) {
15985
+ fiber.expirationTime = renderExpirationTime;
15986
+ }
15987
+ var _alternate = fiber.alternate;
15988
+ if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
15989
+ _alternate.expirationTime = renderExpirationTime;
15990
+ }
15991
+ // This is intentionally passing this fiber as the parent
15992
+ // because we want to schedule this fiber as having work
15993
+ // on its children. We'll use the childExpirationTime on
15994
+ // this fiber to indicate that a context has changed.
15995
+ scheduleWorkOnParentPath(fiber, renderExpirationTime);
15996
+ nextFiber = fiber.sibling;
15574
15997
  } else {
15575
15998
  // Traverse down.
15576
15999
  nextFiber = fiber.child;
@@ -16694,6 +17117,26 @@ function completeWork(current, workInProgress, renderExpirationTime) {
16694
17117
  }
16695
17118
  break;
16696
17119
  }
17120
+ case DehydratedSuspenseComponent:
17121
+ {
17122
+ if (enableSuspenseServerRenderer) {
17123
+ if (current === null) {
17124
+ var _wasHydrated2 = popHydrationState(workInProgress);
17125
+ !_wasHydrated2 ? invariant(false, 'A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.') : void 0;
17126
+ skipPastDehydratedSuspenseInstance(workInProgress);
17127
+ } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
17128
+ // This boundary did not suspend so it's now hydrated.
17129
+ // To handle any future suspense cases, we're going to now upgrade it
17130
+ // to a Suspense component. We detach it from the existing current fiber.
17131
+ current.alternate = null;
17132
+ workInProgress.alternate = null;
17133
+ workInProgress.tag = SuspenseComponent;
17134
+ workInProgress.memoizedState = null;
17135
+ workInProgress.stateNode = null;
17136
+ }
17137
+ }
17138
+ break;
17139
+ }
16697
17140
  default:
16698
17141
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
16699
17142
  }
@@ -16784,7 +17227,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
16784
17227
  didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
16785
17228
  }
16786
17229
 
16787
- var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
17230
+ var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
16788
17231
 
16789
17232
  function logError(boundary, errorInfo) {
16790
17233
  var source = errorInfo.source;
@@ -16950,11 +17393,11 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) {
16950
17393
  if (_destroy === null) {
16951
17394
  addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
16952
17395
  } else if (typeof _destroy.then === 'function') {
16953
- addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, you may write an async function separately ' + 'and then call it from inside the effect:\n\n' + 'async function fetchComment(commentId) {\n' + ' // You can await here\n' + '}\n\n' + 'useEffect(() => {\n' + ' fetchComment(commentId);\n' + '}, [commentId]);\n\n' + 'In the future, React will provide a more idiomatic solution for data fetching ' + "that doesn't involve writing effects manually.";
17396
+ addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + '}, [someId]); // Or [] if effect doesn\'t need props or state\n\n' + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
16954
17397
  } else {
16955
17398
  addendum = ' You returned: ' + _destroy;
16956
17399
  }
16957
- warningWithoutStack$1(false, 'An Effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17400
+ warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
16958
17401
  }
16959
17402
  }
16960
17403
  }
@@ -17097,7 +17540,7 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
17097
17540
 
17098
17541
  function hideOrUnhideAllChildren(finishedWork, isHidden) {
17099
17542
  if (supportsMutation) {
17100
- // We only have the top Fiber that was inserted but we need recurse down its
17543
+ // We only have the top Fiber that was inserted but we need to recurse down its
17101
17544
  var node = finishedWork;
17102
17545
  while (true) {
17103
17546
  if (node.tag === HostComponent) {
@@ -17365,7 +17808,7 @@ function getHostSibling(fiber) {
17365
17808
  }
17366
17809
  node.sibling.return = node.return;
17367
17810
  node = node.sibling;
17368
- while (node.tag !== HostComponent && node.tag !== HostText) {
17811
+ while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
17369
17812
  // If it is not host node and, we might have a host node inside it.
17370
17813
  // Try to search down until we find one.
17371
17814
  if (node.effectTag & Placement) {
@@ -17425,7 +17868,7 @@ function commitPlacement(finishedWork) {
17425
17868
  }
17426
17869
 
17427
17870
  var before = getHostSibling(finishedWork);
17428
- // We only have the top Fiber that was inserted but we need recurse down its
17871
+ // We only have the top Fiber that was inserted but we need to recurse down its
17429
17872
  // children to find all the terminal nodes.
17430
17873
  var node = finishedWork;
17431
17874
  while (true) {
@@ -17467,7 +17910,7 @@ function commitPlacement(finishedWork) {
17467
17910
  }
17468
17911
 
17469
17912
  function unmountHostComponents(current$$1) {
17470
- // We only have the top Fiber that was deleted but we need recurse down its
17913
+ // We only have the top Fiber that was deleted but we need to recurse down its
17471
17914
  var node = current$$1;
17472
17915
 
17473
17916
  // Each iteration, currentParent is populated with node's host parent if not
@@ -17512,13 +17955,20 @@ function unmountHostComponents(current$$1) {
17512
17955
  removeChild(currentParent, node.stateNode);
17513
17956
  }
17514
17957
  // Don't visit children because we already visited them.
17958
+ } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
17959
+ // Delete the dehydrated suspense boundary and all of its content.
17960
+ if (currentParentIsContainer) {
17961
+ clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
17962
+ } else {
17963
+ clearSuspenseBoundary(currentParent, node.stateNode);
17964
+ }
17515
17965
  } else if (node.tag === HostPortal) {
17516
- // When we go into a portal, it becomes the parent to remove from.
17517
- // We will reassign it back when we pop the portal on the way up.
17518
- currentParent = node.stateNode.containerInfo;
17519
- currentParentIsContainer = true;
17520
- // Visit children because portals might contain host components.
17521
17966
  if (node.child !== null) {
17967
+ // When we go into a portal, it becomes the parent to remove from.
17968
+ // We will reassign it back when we pop the portal on the way up.
17969
+ currentParent = node.stateNode.containerInfo;
17970
+ currentParentIsContainer = true;
17971
+ // Visit children because portals might contain host components.
17522
17972
  node.child.return = node;
17523
17973
  node = node.child;
17524
17974
  continue;
@@ -17668,7 +18118,7 @@ function commitWork(current$$1, finishedWork) {
17668
18118
  finishedWork.updateQueue = null;
17669
18119
  var retryCache = finishedWork.stateNode;
17670
18120
  if (retryCache === null) {
17671
- retryCache = finishedWork.stateNode = new PossiblyWeakSet();
18121
+ retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
17672
18122
  }
17673
18123
  thenables.forEach(function (thenable) {
17674
18124
  // Memoize using the boundary fiber to prevent redundant listeners.
@@ -17703,6 +18153,7 @@ function commitResetTextContent(current$$1) {
17703
18153
  resetTextContent(current$$1.stateNode);
17704
18154
  }
17705
18155
 
18156
+ var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
17706
18157
  var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
17707
18158
 
17708
18159
  function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
@@ -17761,6 +18212,34 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
17761
18212
  return update;
17762
18213
  }
17763
18214
 
18215
+ function attachPingListener(root, renderExpirationTime, thenable) {
18216
+ // Attach a listener to the promise to "ping" the root and retry. But
18217
+ // only if one does not already exist for the current render expiration
18218
+ // time (which acts like a "thread ID" here).
18219
+ var pingCache = root.pingCache;
18220
+ var threadIDs = void 0;
18221
+ if (pingCache === null) {
18222
+ pingCache = root.pingCache = new PossiblyWeakMap();
18223
+ threadIDs = new Set();
18224
+ pingCache.set(thenable, threadIDs);
18225
+ } else {
18226
+ threadIDs = pingCache.get(thenable);
18227
+ if (threadIDs === undefined) {
18228
+ threadIDs = new Set();
18229
+ pingCache.set(thenable, threadIDs);
18230
+ }
18231
+ }
18232
+ if (!threadIDs.has(renderExpirationTime)) {
18233
+ // Memoize using the thread ID to prevent redundant listeners.
18234
+ threadIDs.add(renderExpirationTime);
18235
+ var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
18236
+ if (enableSchedulerTracing) {
18237
+ ping = unstable_wrap(ping);
18238
+ }
18239
+ thenable.then(ping, ping);
18240
+ }
18241
+ }
18242
+
17764
18243
  function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
17765
18244
  // The source fiber did not complete.
17766
18245
  sourceFiber.effectTag |= Incomplete;
@@ -17802,6 +18281,9 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17802
18281
  }
17803
18282
  }
17804
18283
  }
18284
+ // If there is a DehydratedSuspenseComponent we don't have to do anything because
18285
+ // if something suspends inside it, we will simply leave that as dehydrated. It
18286
+ // will never timeout.
17805
18287
  _workInProgress = _workInProgress.return;
17806
18288
  } while (_workInProgress !== null);
17807
18289
 
@@ -17865,31 +18347,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17865
18347
  // Confirmed that the boundary is in a concurrent mode tree. Continue
17866
18348
  // with the normal suspend path.
17867
18349
 
17868
- // Attach a listener to the promise to "ping" the root and retry. But
17869
- // only if one does not already exist for the current render expiration
17870
- // time (which acts like a "thread ID" here).
17871
- var pingCache = root.pingCache;
17872
- var threadIDs = void 0;
17873
- if (pingCache === null) {
17874
- pingCache = root.pingCache = new PossiblyWeakMap();
17875
- threadIDs = new Set();
17876
- pingCache.set(thenable, threadIDs);
17877
- } else {
17878
- threadIDs = pingCache.get(thenable);
17879
- if (threadIDs === undefined) {
17880
- threadIDs = new Set();
17881
- pingCache.set(thenable, threadIDs);
17882
- }
17883
- }
17884
- if (!threadIDs.has(renderExpirationTime)) {
17885
- // Memoize using the thread ID to prevent redundant listeners.
17886
- threadIDs.add(renderExpirationTime);
17887
- var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
17888
- if (enableSchedulerTracing) {
17889
- ping = unstable_wrap(ping);
17890
- }
17891
- thenable.then(ping, ping);
17892
- }
18350
+ attachPingListener(root, renderExpirationTime, thenable);
17893
18351
 
17894
18352
  var absoluteTimeoutMs = void 0;
17895
18353
  if (earliestTimeoutMs === -1) {
@@ -17921,6 +18379,29 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17921
18379
  // whole tree.
17922
18380
  renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
17923
18381
 
18382
+ _workInProgress.effectTag |= ShouldCapture;
18383
+ _workInProgress.expirationTime = renderExpirationTime;
18384
+ return;
18385
+ } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
18386
+ attachPingListener(root, renderExpirationTime, thenable);
18387
+
18388
+ // Since we already have a current fiber, we can eagerly add a retry listener.
18389
+ var retryCache = _workInProgress.memoizedState;
18390
+ if (retryCache === null) {
18391
+ retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
18392
+ var _current = _workInProgress.alternate;
18393
+ !_current ? invariant(false, 'A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.') : void 0;
18394
+ _current.memoizedState = retryCache;
18395
+ }
18396
+ // Memoize using the boundary fiber to prevent redundant listeners.
18397
+ if (!retryCache.has(thenable)) {
18398
+ retryCache.add(thenable);
18399
+ var retry = retryTimedOutBoundary.bind(null, _workInProgress, thenable);
18400
+ if (enableSchedulerTracing) {
18401
+ retry = unstable_wrap(retry);
18402
+ }
18403
+ thenable.then(retry, retry);
18404
+ }
17924
18405
  _workInProgress.effectTag |= ShouldCapture;
17925
18406
  _workInProgress.expirationTime = renderExpirationTime;
17926
18407
  return;
@@ -17998,6 +18479,7 @@ function unwindWork(workInProgress, renderExpirationTime) {
17998
18479
  }
17999
18480
  case HostComponent:
18000
18481
  {
18482
+ // TODO: popHydrationState
18001
18483
  popHostContext(workInProgress);
18002
18484
  return null;
18003
18485
  }
@@ -18011,6 +18493,19 @@ function unwindWork(workInProgress, renderExpirationTime) {
18011
18493
  }
18012
18494
  return null;
18013
18495
  }
18496
+ case DehydratedSuspenseComponent:
18497
+ {
18498
+ if (enableSuspenseServerRenderer) {
18499
+ // TODO: popHydrationState
18500
+ var _effectTag3 = workInProgress.effectTag;
18501
+ if (_effectTag3 & ShouldCapture) {
18502
+ workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
18503
+ // Captured a suspense effect. Re-render the boundary.
18504
+ return workInProgress;
18505
+ }
18506
+ }
18507
+ return null;
18508
+ }
18014
18509
  case HostPortal:
18015
18510
  popHostContainer(workInProgress);
18016
18511
  return null;
@@ -18108,11 +18603,6 @@ if (enableSchedulerTracing) {
18108
18603
  // Used to ensure computeUniqueAsyncExpiration is monotonically decreasing.
18109
18604
  var lastUniqueAsyncExpiration = Sync - 1;
18110
18605
 
18111
- // Represents the expiration time that incoming updates should use. (If this
18112
- // is NoWork, use the default strategy: async updates in async mode, sync
18113
- // updates in sync mode.)
18114
- var expirationContext = NoWork;
18115
-
18116
18606
  var isWorking = false;
18117
18607
 
18118
18608
  // The next work in progress fiber that we're currently working on.
@@ -18408,6 +18898,10 @@ function commitPassiveEffects(root, firstEffect) {
18408
18898
  if (rootExpirationTime !== NoWork) {
18409
18899
  requestWork(root, rootExpirationTime);
18410
18900
  }
18901
+ // Flush any sync work that was scheduled by effects
18902
+ if (!isBatchingUpdates && !isRendering) {
18903
+ performSyncWork();
18904
+ }
18411
18905
  }
18412
18906
 
18413
18907
  function isAlreadyFailedLegacyErrorBoundary(instance) {
@@ -18582,7 +19076,9 @@ function commitRoot(root, finishedWork) {
18582
19076
  // here because that code is still in flux.
18583
19077
  callback = unstable_wrap(callback);
18584
19078
  }
18585
- passiveEffectCallbackHandle = schedulePassiveEffects(callback);
19079
+ passiveEffectCallbackHandle = unstable_runWithPriority(unstable_NormalPriority, function () {
19080
+ return schedulePassiveEffects(callback);
19081
+ });
18586
19082
  passiveEffectCallback = callback;
18587
19083
  }
18588
19084
 
@@ -19171,7 +19667,7 @@ function renderRoot(root, isYieldy) {
19171
19667
  return;
19172
19668
  } else if (
19173
19669
  // There's no lower priority work, but we're rendering asynchronously.
19174
- // Synchronsouly attempt to render the same level one more time. This is
19670
+ // Synchronously attempt to render the same level one more time. This is
19175
19671
  // similar to a suspend, but without a timeout because we're not waiting
19176
19672
  // for a promise to resolve.
19177
19673
  !root.didError && isYieldy) {
@@ -19276,49 +19772,50 @@ function computeUniqueAsyncExpiration() {
19276
19772
  }
19277
19773
 
19278
19774
  function computeExpirationForFiber(currentTime, fiber) {
19775
+ var priorityLevel = unstable_getCurrentPriorityLevel();
19776
+
19279
19777
  var expirationTime = void 0;
19280
- if (expirationContext !== NoWork) {
19281
- // An explicit expiration context was set;
19282
- expirationTime = expirationContext;
19283
- } else if (isWorking) {
19284
- if (isCommitting$1) {
19285
- // Updates that occur during the commit phase should have sync priority
19286
- // by default.
19287
- expirationTime = Sync;
19288
- } else {
19289
- // Updates during the render phase should expire at the same time as
19290
- // the work that is being rendered.
19291
- expirationTime = nextRenderExpirationTime;
19292
- }
19778
+ if ((fiber.mode & ConcurrentMode) === NoContext) {
19779
+ // Outside of concurrent mode, updates are always synchronous.
19780
+ expirationTime = Sync;
19781
+ } else if (isWorking && !isCommitting$1) {
19782
+ // During render phase, updates expire during as the current render.
19783
+ expirationTime = nextRenderExpirationTime;
19293
19784
  } else {
19294
- // No explicit expiration context was set, and we're not currently
19295
- // performing work. Calculate a new expiration time.
19296
- if (fiber.mode & ConcurrentMode) {
19297
- if (isBatchingInteractiveUpdates) {
19298
- // This is an interactive update
19785
+ switch (priorityLevel) {
19786
+ case unstable_ImmediatePriority:
19787
+ expirationTime = Sync;
19788
+ break;
19789
+ case unstable_UserBlockingPriority:
19299
19790
  expirationTime = computeInteractiveExpiration(currentTime);
19300
- } else {
19301
- // This is an async update
19791
+ break;
19792
+ case unstable_NormalPriority:
19793
+ // This is a normal, concurrent update
19302
19794
  expirationTime = computeAsyncExpiration(currentTime);
19303
- }
19304
- // If we're in the middle of rendering a tree, do not update at the same
19305
- // expiration time that is already rendering.
19306
- if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
19307
- expirationTime -= 1;
19308
- }
19309
- } else {
19310
- // This is a sync update
19311
- expirationTime = Sync;
19795
+ break;
19796
+ case unstable_LowPriority:
19797
+ case unstable_IdlePriority:
19798
+ expirationTime = Never;
19799
+ break;
19800
+ default:
19801
+ invariant(false, 'Unknown priority level. This error is likely caused by a bug in React. Please file an issue.');
19312
19802
  }
19313
- }
19314
- if (isBatchingInteractiveUpdates) {
19315
- // This is an interactive update. Keep track of the lowest pending
19316
- // interactive expiration time. This allows us to synchronously flush
19317
- // all interactive updates when needed.
19318
- if (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime) {
19319
- lowestPriorityPendingInteractiveExpirationTime = expirationTime;
19803
+
19804
+ // If we're in the middle of rendering a tree, do not update at the same
19805
+ // expiration time that is already rendering.
19806
+ if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
19807
+ expirationTime -= 1;
19320
19808
  }
19321
19809
  }
19810
+
19811
+ // Keep track of the lowest pending interactive expiration time. This
19812
+ // allows us to synchronously flush all interactive updates
19813
+ // when needed.
19814
+ // TODO: Move this to renderer?
19815
+ if (priorityLevel === unstable_UserBlockingPriority && (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime)) {
19816
+ lowestPriorityPendingInteractiveExpirationTime = expirationTime;
19817
+ }
19818
+
19322
19819
  return expirationTime;
19323
19820
  }
19324
19821
 
@@ -19365,7 +19862,21 @@ function retryTimedOutBoundary(boundaryFiber, thenable) {
19365
19862
  // The boundary fiber (a Suspense component) previously timed out and was
19366
19863
  // rendered in its fallback state. One of the promises that suspended it has
19367
19864
  // resolved, which means at least part of the tree was likely unblocked. Try
19368
- var retryCache = boundaryFiber.stateNode;
19865
+ var retryCache = void 0;
19866
+ if (enableSuspenseServerRenderer) {
19867
+ switch (boundaryFiber.tag) {
19868
+ case SuspenseComponent:
19869
+ retryCache = boundaryFiber.stateNode;
19870
+ break;
19871
+ case DehydratedSuspenseComponent:
19872
+ retryCache = boundaryFiber.memoizedState;
19873
+ break;
19874
+ default:
19875
+ invariant(false, 'Pinged unknown suspense boundary type. This is probably a bug in React.');
19876
+ }
19877
+ } else {
19878
+ retryCache = boundaryFiber.stateNode;
19879
+ }
19369
19880
  if (retryCache !== null) {
19370
19881
  // The thenable resolved, so we no longer need to memoize, because it will
19371
19882
  // never be thrown again.
@@ -19464,7 +19975,7 @@ function scheduleWorkToRoot(fiber, expirationTime) {
19464
19975
  function warnIfNotCurrentlyBatchingInDev(fiber) {
19465
19976
  {
19466
19977
  if (isRendering === false && isBatchingUpdates === false) {
19467
- 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));
19978
+ 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));
19468
19979
  }
19469
19980
  }
19470
19981
  }
@@ -19511,13 +20022,9 @@ function scheduleWork(fiber, expirationTime) {
19511
20022
  }
19512
20023
 
19513
20024
  function syncUpdates(fn, a, b, c, d) {
19514
- var previousExpirationContext = expirationContext;
19515
- expirationContext = Sync;
19516
- try {
20025
+ return unstable_runWithPriority(unstable_ImmediatePriority, function () {
19517
20026
  return fn(a, b, c, d);
19518
- } finally {
19519
- expirationContext = previousExpirationContext;
19520
- }
20027
+ });
19521
20028
  }
19522
20029
 
19523
20030
  // TODO: Everything below this is written as if it has been lifted to the
@@ -19538,7 +20045,6 @@ var unhandledError = null;
19538
20045
 
19539
20046
  var isBatchingUpdates = false;
19540
20047
  var isUnbatchingUpdates = false;
19541
- var isBatchingInteractiveUpdates = false;
19542
20048
 
19543
20049
  var completedBatches = null;
19544
20050
 
@@ -20012,7 +20518,9 @@ function completeRoot(root, finishedWork, expirationTime) {
20012
20518
  lastCommittedRootDuringThisBatch = root;
20013
20519
  nestedUpdateCount = 0;
20014
20520
  }
20015
- commitRoot(root, finishedWork);
20521
+ unstable_runWithPriority(unstable_ImmediatePriority, function () {
20522
+ commitRoot(root, finishedWork);
20523
+ });
20016
20524
  }
20017
20525
 
20018
20526
  function onUncaughtError(error) {
@@ -20070,9 +20578,6 @@ function flushSync(fn, a) {
20070
20578
  }
20071
20579
 
20072
20580
  function interactiveUpdates$1(fn, a, b) {
20073
- if (isBatchingInteractiveUpdates) {
20074
- return fn(a, b);
20075
- }
20076
20581
  // If there are any pending interactive updates, synchronously flush them.
20077
20582
  // This needs to happen before we read any handlers, because the effect of
20078
20583
  // the previous event may influence which handlers are called during
@@ -20082,14 +20587,13 @@ function interactiveUpdates$1(fn, a, b) {
20082
20587
  performWork(lowestPriorityPendingInteractiveExpirationTime, false);
20083
20588
  lowestPriorityPendingInteractiveExpirationTime = NoWork;
20084
20589
  }
20085
- var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates;
20086
20590
  var previousIsBatchingUpdates = isBatchingUpdates;
20087
- isBatchingInteractiveUpdates = true;
20088
20591
  isBatchingUpdates = true;
20089
20592
  try {
20090
- return fn(a, b);
20593
+ return unstable_runWithPriority(unstable_UserBlockingPriority, function () {
20594
+ return fn(a, b);
20595
+ });
20091
20596
  } finally {
20092
- isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates;
20093
20597
  isBatchingUpdates = previousIsBatchingUpdates;
20094
20598
  if (!isBatchingUpdates && !isRendering) {
20095
20599
  performSyncWork();
@@ -20352,7 +20856,7 @@ implementation) {
20352
20856
 
20353
20857
  // TODO: this is special because it gets imported during build.
20354
20858
 
20355
- var ReactVersion = '16.8.1';
20859
+ var ReactVersion = '16.8.5';
20356
20860
 
20357
20861
  // This file is copy paste from ReactDOM with adjusted paths
20358
20862
  // and a different host config import (react-reconciler/inline.fire).
@@ -20747,7 +21251,7 @@ var ReactDOM = {
20747
21251
  hydrate: function (element, container, callback) {
20748
21252
  !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0;
20749
21253
  {
20750
- !!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;
21254
+ !!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;
20751
21255
  }
20752
21256
  // TODO: throw or warn if we couldn't hydrate?
20753
21257
  return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);