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.
@@ -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;
@@ -2903,12 +2904,15 @@ var capitalize = function (token) {
2903
2904
  attributeName, 'http://www.w3.org/XML/1998/namespace');
2904
2905
  });
2905
2906
 
2906
- // Special case: this attribute exists both in HTML and SVG.
2907
- // Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
2908
- // its React `tabIndex` name, like we do for attributes that exist only in HTML.
2909
- properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty
2910
- 'tabindex', // attributeName
2911
- 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
+ );
2912
2916
 
2913
2917
  /**
2914
2918
  * Get the value for a property on a node. Only used in DEV for SSR validation.
@@ -3147,7 +3151,7 @@ var enableProfilerTimer = true;
3147
3151
  var enableSchedulerTracing = true;
3148
3152
 
3149
3153
  // Only used in www builds.
3150
- // TODO: true? Here it might just be false.
3154
+ var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
3151
3155
 
3152
3156
  // Only used in www builds.
3153
3157
 
@@ -7626,14 +7630,25 @@ function createElement(type, props, rootContainerElement, parentNamespace) {
7626
7630
  // See discussion in https://github.com/facebook/react/pull/6896
7627
7631
  // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
7628
7632
  domElement = ownerDocument.createElement(type);
7629
- // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple`
7630
- // attribute on `select`s needs to be added before `option`s are inserted. This prevents
7631
- // a bug where the `select` does not scroll to the correct option because singular
7632
- // `select` elements automatically pick the first item.
7633
+ // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
7634
+ // attributes on `select`s needs to be added before `option`s are inserted.
7635
+ // This prevents:
7636
+ // - a bug where the `select` does not scroll to the correct option because singular
7637
+ // `select` elements automatically pick the first item #13222
7638
+ // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
7633
7639
  // See https://github.com/facebook/react/issues/13222
7634
- if (type === 'select' && props.multiple) {
7640
+ // and https://github.com/facebook/react/issues/14239
7641
+ if (type === 'select') {
7635
7642
  var node = domElement;
7636
- node.multiple = true;
7643
+ if (props.multiple) {
7644
+ node.multiple = true;
7645
+ } else if (props.size) {
7646
+ // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
7647
+ // it is possible that no option is selected.
7648
+ //
7649
+ // This is only necessary when a select in "single selection mode".
7650
+ node.size = props.size;
7651
+ }
7637
7652
  }
7638
7653
  }
7639
7654
  } else {
@@ -8622,6 +8637,9 @@ var SUPPRESS_HYDRATION_WARNING = void 0;
8622
8637
  SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
8623
8638
  }
8624
8639
 
8640
+ var SUSPENSE_START_DATA = '$';
8641
+ var SUSPENSE_END_DATA = '/$';
8642
+
8625
8643
  var STYLE = 'style';
8626
8644
 
8627
8645
  var eventsEnabled = null;
@@ -8850,6 +8868,43 @@ function removeChildFromContainer(container, child) {
8850
8868
  }
8851
8869
  }
8852
8870
 
8871
+ function clearSuspenseBoundary(parentInstance, suspenseInstance) {
8872
+ var node = suspenseInstance;
8873
+ // Delete all nodes within this suspense boundary.
8874
+ // There might be nested nodes so we need to keep track of how
8875
+ // deep we are and only break out when we're back on top.
8876
+ var depth = 0;
8877
+ do {
8878
+ var nextNode = node.nextSibling;
8879
+ parentInstance.removeChild(node);
8880
+ if (nextNode && nextNode.nodeType === COMMENT_NODE) {
8881
+ var data = nextNode.data;
8882
+ if (data === SUSPENSE_END_DATA) {
8883
+ if (depth === 0) {
8884
+ parentInstance.removeChild(nextNode);
8885
+ return;
8886
+ } else {
8887
+ depth--;
8888
+ }
8889
+ } else if (data === SUSPENSE_START_DATA) {
8890
+ depth++;
8891
+ }
8892
+ }
8893
+ node = nextNode;
8894
+ } while (node);
8895
+ // TODO: Warn, we didn't find the end comment boundary.
8896
+ }
8897
+
8898
+ function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
8899
+ if (container.nodeType === COMMENT_NODE) {
8900
+ clearSuspenseBoundary(container.parentNode, suspenseInstance);
8901
+ } else if (container.nodeType === ELEMENT_NODE) {
8902
+ clearSuspenseBoundary(container, suspenseInstance);
8903
+ } else {
8904
+ // Document nodes should never contain suspense boundaries.
8905
+ }
8906
+ }
8907
+
8853
8908
  function hideInstance(instance) {
8854
8909
  // TODO: Does this work for all element types? What about MathML? Should we
8855
8910
  // pass host context to this method?
@@ -8895,10 +8950,19 @@ function canHydrateTextInstance(instance, text) {
8895
8950
  return instance;
8896
8951
  }
8897
8952
 
8953
+ function canHydrateSuspenseInstance(instance) {
8954
+ if (instance.nodeType !== COMMENT_NODE) {
8955
+ // Empty strings are not parsed by HTML so there won't be a correct match here.
8956
+ return null;
8957
+ }
8958
+ // This has now been refined to a suspense node.
8959
+ return instance;
8960
+ }
8961
+
8898
8962
  function getNextHydratableSibling(instance) {
8899
8963
  var node = instance.nextSibling;
8900
8964
  // Skip non-hydratable nodes.
8901
- while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) {
8965
+ while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || node.nodeType !== COMMENT_NODE || node.data !== SUSPENSE_START_DATA)) {
8902
8966
  node = node.nextSibling;
8903
8967
  }
8904
8968
  return node;
@@ -8907,7 +8971,7 @@ function getNextHydratableSibling(instance) {
8907
8971
  function getFirstHydratableChild(parentInstance) {
8908
8972
  var next = parentInstance.firstChild;
8909
8973
  // Skip non-hydratable nodes.
8910
- while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) {
8974
+ while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || next.nodeType !== COMMENT_NODE || next.data !== SUSPENSE_START_DATA)) {
8911
8975
  next = next.nextSibling;
8912
8976
  }
8913
8977
  return next;
@@ -8931,6 +8995,31 @@ function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
8931
8995
  return diffHydratedText(textInstance, text);
8932
8996
  }
8933
8997
 
8998
+ function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
8999
+ var node = suspenseInstance.nextSibling;
9000
+ // Skip past all nodes within this suspense boundary.
9001
+ // There might be nested nodes so we need to keep track of how
9002
+ // deep we are and only break out when we're back on top.
9003
+ var depth = 0;
9004
+ while (node) {
9005
+ if (node.nodeType === COMMENT_NODE) {
9006
+ var data = node.data;
9007
+ if (data === SUSPENSE_END_DATA) {
9008
+ if (depth === 0) {
9009
+ return getNextHydratableSibling(node);
9010
+ } else {
9011
+ depth--;
9012
+ }
9013
+ } else if (data === SUSPENSE_START_DATA) {
9014
+ depth++;
9015
+ }
9016
+ }
9017
+ node = node.nextSibling;
9018
+ }
9019
+ // TODO: Warn, we didn't find the end comment boundary.
9020
+ return null;
9021
+ }
9022
+
8934
9023
  function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
8935
9024
  {
8936
9025
  warnForUnmatchedText(textInstance, text);
@@ -8947,6 +9036,8 @@ function didNotHydrateContainerInstance(parentContainer, instance) {
8947
9036
  {
8948
9037
  if (instance.nodeType === ELEMENT_NODE) {
8949
9038
  warnForDeletedHydratableElement(parentContainer, instance);
9039
+ } else if (instance.nodeType === COMMENT_NODE) {
9040
+ // TODO: warnForDeletedHydratableSuspenseBoundary
8950
9041
  } else {
8951
9042
  warnForDeletedHydratableText(parentContainer, instance);
8952
9043
  }
@@ -8957,6 +9048,8 @@ function didNotHydrateInstance(parentType, parentProps, parentInstance, instance
8957
9048
  if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
8958
9049
  if (instance.nodeType === ELEMENT_NODE) {
8959
9050
  warnForDeletedHydratableElement(parentInstance, instance);
9051
+ } else if (instance.nodeType === COMMENT_NODE) {
9052
+ // TODO: warnForDeletedHydratableSuspenseBoundary
8960
9053
  } else {
8961
9054
  warnForDeletedHydratableText(parentInstance, instance);
8962
9055
  }
@@ -8975,6 +9068,8 @@ function didNotFindHydratableContainerTextInstance(parentContainer, text) {
8975
9068
  }
8976
9069
  }
8977
9070
 
9071
+
9072
+
8978
9073
  function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
8979
9074
  if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
8980
9075
  warnForInsertedHydratedElement(parentInstance, type, props);
@@ -8987,6 +9082,12 @@ function didNotFindHydratableTextInstance(parentType, parentProps, parentInstanc
8987
9082
  }
8988
9083
  }
8989
9084
 
9085
+ function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
9086
+ if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
9087
+ // TODO: warnForInsertedHydratedSuspense(parentInstance);
9088
+ }
9089
+ }
9090
+
8990
9091
  // This is just to get the setup running.
8991
9092
  // TODO: real implementation.
8992
9093
  // console.log('Hello from Fire host config.');
@@ -9246,7 +9347,7 @@ function stopFailedWorkTimer(fiber) {
9246
9347
  return;
9247
9348
  }
9248
9349
  fiber._debugIsCurrentlyTiming = false;
9249
- var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
9350
+ var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
9250
9351
  endFiberMark(fiber, null, warning);
9251
9352
  }
9252
9353
  }
@@ -9915,6 +10016,7 @@ function FiberNode(tag, pendingProps, key, mode) {
9915
10016
  this._debugSource = null;
9916
10017
  this._debugOwner = null;
9917
10018
  this._debugIsCurrentlyTiming = false;
10019
+ this._debugHookTypes = null;
9918
10020
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
9919
10021
  Object.preventExtensions(this);
9920
10022
  }
@@ -9982,6 +10084,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
9982
10084
  workInProgress._debugID = current._debugID;
9983
10085
  workInProgress._debugSource = current._debugSource;
9984
10086
  workInProgress._debugOwner = current._debugOwner;
10087
+ workInProgress._debugHookTypes = current._debugHookTypes;
9985
10088
  }
9986
10089
 
9987
10090
  workInProgress.alternate = current;
@@ -10249,6 +10352,7 @@ function assignFiberPropertiesInDEV(target, source) {
10249
10352
  target._debugSource = source._debugSource;
10250
10353
  target._debugOwner = source._debugOwner;
10251
10354
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
10355
+ target._debugHookTypes = source._debugHookTypes;
10252
10356
  return target;
10253
10357
  }
10254
10358
 
@@ -12053,7 +12157,7 @@ function ChildReconciler(shouldTrackSideEffects) {
12053
12157
  }
12054
12158
 
12055
12159
  function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
12056
- // This algorithm can't optimize by searching from boths ends since we
12160
+ // This algorithm can't optimize by searching from both ends since we
12057
12161
  // don't have backpointers on fibers. I'm trying to see how far we can get
12058
12162
  // with that model. If it ends up not being worth the tradeoffs, we can
12059
12163
  // add it later.
@@ -12634,7 +12738,6 @@ var currentlyRenderingFiber$1 = null;
12634
12738
  // current hook list is the list that belongs to the current fiber. The
12635
12739
  // work-in-progress hook list is a new list that will be added to the
12636
12740
  // work-in-progress fiber.
12637
- var firstCurrentHook = null;
12638
12741
  var currentHook = null;
12639
12742
  var nextCurrentHook = null;
12640
12743
  var firstWorkInProgressHook = null;
@@ -12664,45 +12767,73 @@ var RE_RENDER_LIMIT = 25;
12664
12767
  // In DEV, this is the name of the currently executing primitive hook
12665
12768
  var currentHookNameInDev = null;
12666
12769
 
12667
- function warnOnHookMismatchInDev() {
12770
+ // In DEV, this list ensures that hooks are called in the same order between renders.
12771
+ // The list stores the order of hooks used during the initial render (mount).
12772
+ // Subsequent renders (updates) reference this list.
12773
+ var hookTypesDev = null;
12774
+ var hookTypesUpdateIndexDev = -1;
12775
+
12776
+ function mountHookTypesDev() {
12777
+ {
12778
+ var hookName = currentHookNameInDev;
12779
+
12780
+ if (hookTypesDev === null) {
12781
+ hookTypesDev = [hookName];
12782
+ } else {
12783
+ hookTypesDev.push(hookName);
12784
+ }
12785
+ }
12786
+ }
12787
+
12788
+ function updateHookTypesDev() {
12789
+ {
12790
+ var hookName = currentHookNameInDev;
12791
+
12792
+ if (hookTypesDev !== null) {
12793
+ hookTypesUpdateIndexDev++;
12794
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
12795
+ warnOnHookMismatchInDev(hookName);
12796
+ }
12797
+ }
12798
+ }
12799
+ }
12800
+
12801
+ function warnOnHookMismatchInDev(currentHookName) {
12668
12802
  {
12669
12803
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
12670
12804
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
12671
12805
  didWarnAboutMismatchedHooksForComponent.add(componentName);
12672
12806
 
12673
- var secondColumnStart = 22;
12807
+ if (hookTypesDev !== null) {
12808
+ var table = '';
12674
12809
 
12675
- var table = '';
12676
- var prevHook = firstCurrentHook;
12677
- var nextHook = firstWorkInProgressHook;
12678
- var n = 1;
12679
- while (prevHook !== null && nextHook !== null) {
12680
- var oldHookName = prevHook._debugType;
12681
- var newHookName = nextHook._debugType;
12810
+ var secondColumnStart = 30;
12682
12811
 
12683
- var row = n + '. ' + oldHookName;
12812
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
12813
+ var oldHookName = hookTypesDev[i];
12814
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
12684
12815
 
12685
- // Extra space so second column lines up
12686
- // lol @ IE not supporting String#repeat
12687
- while (row.length < secondColumnStart) {
12688
- row += ' ';
12689
- }
12816
+ var row = i + 1 + '. ' + oldHookName;
12690
12817
 
12691
- row += newHookName + '\n';
12818
+ // Extra space so second column lines up
12819
+ // lol @ IE not supporting String#repeat
12820
+ while (row.length < secondColumnStart) {
12821
+ row += ' ';
12822
+ }
12692
12823
 
12693
- table += row;
12694
- prevHook = prevHook.next;
12695
- nextHook = nextHook.next;
12696
- n++;
12697
- }
12824
+ row += newHookName + '\n';
12825
+
12826
+ table += row;
12827
+ }
12698
12828
 
12699
- 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);
12829
+ 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);
12830
+ }
12700
12831
  }
12701
12832
  }
12702
12833
  }
12703
12834
 
12704
12835
  function throwInvalidHookError() {
12705
- invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)');
12836
+ 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.');
12706
12837
  }
12707
12838
 
12708
12839
  function areHookInputsEqual(nextDeps, prevDeps) {
@@ -12732,7 +12863,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
12732
12863
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
12733
12864
  renderExpirationTime = nextRenderExpirationTime;
12734
12865
  currentlyRenderingFiber$1 = workInProgress;
12735
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
12866
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12867
+
12868
+ {
12869
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
12870
+ hookTypesUpdateIndexDev = -1;
12871
+ }
12736
12872
 
12737
12873
  // The following should have already been reset
12738
12874
  // currentHook = null;
@@ -12746,8 +12882,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12746
12882
  // numberOfReRenders = 0;
12747
12883
  // sideEffectTag = 0;
12748
12884
 
12885
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
12886
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
12887
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
12888
+
12889
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
12890
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
12891
+ // so nextCurrentHook would be null during updates and mounts.
12749
12892
  {
12750
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
12893
+ if (nextCurrentHook !== null) {
12894
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12895
+ } else if (hookTypesDev !== null) {
12896
+ // This dispatcher handles an edge case where a component is updating,
12897
+ // but no stateful hooks have been used.
12898
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
12899
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
12900
+ // This dispatcher does that.
12901
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
12902
+ } else {
12903
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
12904
+ }
12751
12905
  }
12752
12906
 
12753
12907
  var children = Component(props, refOrContext);
@@ -12758,13 +12912,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12758
12912
  numberOfReRenders += 1;
12759
12913
 
12760
12914
  // Start over from the beginning of the list
12761
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
12915
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12762
12916
  nextWorkInProgressHook = firstWorkInProgressHook;
12763
12917
 
12764
12918
  currentHook = null;
12765
12919
  workInProgressHook = null;
12766
12920
  componentUpdateQueue = null;
12767
12921
 
12922
+ {
12923
+ // Also validate hook order for cascading updates.
12924
+ hookTypesUpdateIndexDev = -1;
12925
+ }
12926
+
12768
12927
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12769
12928
 
12770
12929
  children = Component(props, refOrContext);
@@ -12774,10 +12933,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12774
12933
  numberOfReRenders = 0;
12775
12934
  }
12776
12935
 
12777
- {
12778
- currentHookNameInDev = null;
12779
- }
12780
-
12781
12936
  // We can assume the previous dispatcher is always this one, since we set it
12782
12937
  // at the beginning of the render phase and there's no re-entrancy.
12783
12938
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -12789,18 +12944,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12789
12944
  renderedWork.updateQueue = componentUpdateQueue;
12790
12945
  renderedWork.effectTag |= sideEffectTag;
12791
12946
 
12947
+ {
12948
+ renderedWork._debugHookTypes = hookTypesDev;
12949
+ }
12950
+
12951
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
12952
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
12792
12953
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
12793
12954
 
12794
12955
  renderExpirationTime = NoWork;
12795
12956
  currentlyRenderingFiber$1 = null;
12796
12957
 
12797
- firstCurrentHook = null;
12798
12958
  currentHook = null;
12799
12959
  nextCurrentHook = null;
12800
12960
  firstWorkInProgressHook = null;
12801
12961
  workInProgressHook = null;
12802
12962
  nextWorkInProgressHook = null;
12803
12963
 
12964
+ {
12965
+ currentHookNameInDev = null;
12966
+ hookTypesDev = null;
12967
+ hookTypesUpdateIndexDev = -1;
12968
+ }
12969
+
12804
12970
  remainingExpirationTime = NoWork;
12805
12971
  componentUpdateQueue = null;
12806
12972
  sideEffectTag = 0;
@@ -12834,21 +13000,23 @@ function resetHooks() {
12834
13000
  renderExpirationTime = NoWork;
12835
13001
  currentlyRenderingFiber$1 = null;
12836
13002
 
12837
- firstCurrentHook = null;
12838
13003
  currentHook = null;
12839
13004
  nextCurrentHook = null;
12840
13005
  firstWorkInProgressHook = null;
12841
13006
  workInProgressHook = null;
12842
13007
  nextWorkInProgressHook = null;
12843
13008
 
12844
- remainingExpirationTime = NoWork;
12845
- componentUpdateQueue = null;
12846
- sideEffectTag = 0;
12847
-
12848
13009
  {
13010
+ hookTypesDev = null;
13011
+ hookTypesUpdateIndexDev = -1;
13012
+
12849
13013
  currentHookNameInDev = null;
12850
13014
  }
12851
13015
 
13016
+ remainingExpirationTime = NoWork;
13017
+ componentUpdateQueue = null;
13018
+ sideEffectTag = 0;
13019
+
12852
13020
  didScheduleRenderPhaseUpdate = false;
12853
13021
  renderPhaseUpdates = null;
12854
13022
  numberOfReRenders = 0;
@@ -12865,12 +13033,6 @@ function mountWorkInProgressHook() {
12865
13033
  next: null
12866
13034
  };
12867
13035
 
12868
- {
12869
- hook._debugType = currentHookNameInDev;
12870
- if (currentlyRenderingFiber$1 !== null && currentlyRenderingFiber$1.alternate !== null) {
12871
- 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));
12872
- }
12873
- }
12874
13036
  if (workInProgressHook === null) {
12875
13037
  // This is the first hook in the list
12876
13038
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -12917,13 +13079,6 @@ function updateWorkInProgressHook() {
12917
13079
  workInProgressHook = workInProgressHook.next = newHook;
12918
13080
  }
12919
13081
  nextCurrentHook = currentHook.next;
12920
-
12921
- {
12922
- newHook._debugType = currentHookNameInDev;
12923
- if (currentHookNameInDev !== currentHook._debugType) {
12924
- warnOnHookMismatchInDev();
12925
- }
12926
- }
12927
13082
  }
12928
13083
  return workInProgressHook;
12929
13084
  }
@@ -12938,20 +13093,6 @@ function basicStateReducer(state, action) {
12938
13093
  return typeof action === 'function' ? action(state) : action;
12939
13094
  }
12940
13095
 
12941
- function mountContext(context, observedBits) {
12942
- {
12943
- mountWorkInProgressHook();
12944
- }
12945
- return readContext(context, observedBits);
12946
- }
12947
-
12948
- function updateContext(context, observedBits) {
12949
- {
12950
- updateWorkInProgressHook();
12951
- }
12952
- return readContext(context, observedBits);
12953
- }
12954
-
12955
13096
  function mountReducer(reducer, initialArg, init) {
12956
13097
  var hook = mountWorkInProgressHook();
12957
13098
  var initialState = void 0;
@@ -13004,7 +13145,6 @@ function updateReducer(reducer, initialArg, init) {
13004
13145
  }
13005
13146
 
13006
13147
  hook.memoizedState = newState;
13007
-
13008
13148
  // Don't persist the state accumlated from the render phase updates to
13009
13149
  // the base state unless the queue is empty.
13010
13150
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -13013,6 +13153,9 @@ function updateReducer(reducer, initialArg, init) {
13013
13153
  hook.baseState = newState;
13014
13154
  }
13015
13155
 
13156
+ queue.eagerReducer = reducer;
13157
+ queue.eagerState = newState;
13158
+
13016
13159
  return [newState, _dispatch];
13017
13160
  }
13018
13161
  }
@@ -13232,7 +13375,7 @@ function mountImperativeHandle(ref, create, deps) {
13232
13375
  }
13233
13376
 
13234
13377
  // TODO: If deps are provided, should we skip comparing the ref itself?
13235
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
13378
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
13236
13379
 
13237
13380
  return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
13238
13381
  }
@@ -13243,7 +13386,7 @@ function updateImperativeHandle(ref, create, deps) {
13243
13386
  }
13244
13387
 
13245
13388
  // TODO: If deps are provided, should we skip comparing the ref itself?
13246
- var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : [ref];
13389
+ var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
13247
13390
 
13248
13391
  return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
13249
13392
  }
@@ -13310,7 +13453,7 @@ function updateMemo(nextCreate, deps) {
13310
13453
  var shouldWarnForUnbatchedSetState = false;
13311
13454
 
13312
13455
  {
13313
- // jest isnt' a 'global', it's just exposed to tests via a wrapped function
13456
+ // jest isn't a 'global', it's just exposed to tests via a wrapped function
13314
13457
  // further, this isn't a test file, so flow doesn't recognize the symbol. So...
13315
13458
  // $FlowExpectedError - because requirements don't give a damn about your type sigs.
13316
13459
  if ('undefined' !== typeof jest) {
@@ -13442,6 +13585,7 @@ var ContextOnlyDispatcher = {
13442
13585
  };
13443
13586
 
13444
13587
  var HooksDispatcherOnMountInDEV = null;
13588
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
13445
13589
  var HooksDispatcherOnUpdateInDEV = null;
13446
13590
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
13447
13591
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -13461,26 +13605,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13461
13605
  },
13462
13606
  useCallback: function (callback, deps) {
13463
13607
  currentHookNameInDev = 'useCallback';
13608
+ mountHookTypesDev();
13609
+ return mountCallback(callback, deps);
13610
+ },
13611
+ useContext: function (context, observedBits) {
13612
+ currentHookNameInDev = 'useContext';
13613
+ mountHookTypesDev();
13614
+ return readContext(context, observedBits);
13615
+ },
13616
+ useEffect: function (create, deps) {
13617
+ currentHookNameInDev = 'useEffect';
13618
+ mountHookTypesDev();
13619
+ return mountEffect(create, deps);
13620
+ },
13621
+ useImperativeHandle: function (ref, create, deps) {
13622
+ currentHookNameInDev = 'useImperativeHandle';
13623
+ mountHookTypesDev();
13624
+ return mountImperativeHandle(ref, create, deps);
13625
+ },
13626
+ useLayoutEffect: function (create, deps) {
13627
+ currentHookNameInDev = 'useLayoutEffect';
13628
+ mountHookTypesDev();
13629
+ return mountLayoutEffect(create, deps);
13630
+ },
13631
+ useMemo: function (create, deps) {
13632
+ currentHookNameInDev = 'useMemo';
13633
+ mountHookTypesDev();
13634
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13635
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13636
+ try {
13637
+ return mountMemo(create, deps);
13638
+ } finally {
13639
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13640
+ }
13641
+ },
13642
+ useReducer: function (reducer, initialArg, init) {
13643
+ currentHookNameInDev = 'useReducer';
13644
+ mountHookTypesDev();
13645
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13646
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13647
+ try {
13648
+ return mountReducer(reducer, initialArg, init);
13649
+ } finally {
13650
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13651
+ }
13652
+ },
13653
+ useRef: function (initialValue) {
13654
+ currentHookNameInDev = 'useRef';
13655
+ mountHookTypesDev();
13656
+ return mountRef(initialValue);
13657
+ },
13658
+ useState: function (initialState) {
13659
+ currentHookNameInDev = 'useState';
13660
+ mountHookTypesDev();
13661
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13662
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13663
+ try {
13664
+ return mountState(initialState);
13665
+ } finally {
13666
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13667
+ }
13668
+ },
13669
+ useDebugValue: function (value, formatterFn) {
13670
+ currentHookNameInDev = 'useDebugValue';
13671
+ mountHookTypesDev();
13672
+ return mountDebugValue(value, formatterFn);
13673
+ }
13674
+ };
13675
+
13676
+ HooksDispatcherOnMountWithHookTypesInDEV = {
13677
+ readContext: function (context, observedBits) {
13678
+ return readContext(context, observedBits);
13679
+ },
13680
+ useCallback: function (callback, deps) {
13681
+ currentHookNameInDev = 'useCallback';
13682
+ updateHookTypesDev();
13464
13683
  return mountCallback(callback, deps);
13465
13684
  },
13466
13685
  useContext: function (context, observedBits) {
13467
13686
  currentHookNameInDev = 'useContext';
13468
- return mountContext(context, observedBits);
13687
+ updateHookTypesDev();
13688
+ return readContext(context, observedBits);
13469
13689
  },
13470
13690
  useEffect: function (create, deps) {
13471
13691
  currentHookNameInDev = 'useEffect';
13692
+ updateHookTypesDev();
13472
13693
  return mountEffect(create, deps);
13473
13694
  },
13474
13695
  useImperativeHandle: function (ref, create, deps) {
13475
13696
  currentHookNameInDev = 'useImperativeHandle';
13697
+ updateHookTypesDev();
13476
13698
  return mountImperativeHandle(ref, create, deps);
13477
13699
  },
13478
13700
  useLayoutEffect: function (create, deps) {
13479
13701
  currentHookNameInDev = 'useLayoutEffect';
13702
+ updateHookTypesDev();
13480
13703
  return mountLayoutEffect(create, deps);
13481
13704
  },
13482
13705
  useMemo: function (create, deps) {
13483
13706
  currentHookNameInDev = 'useMemo';
13707
+ updateHookTypesDev();
13484
13708
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13485
13709
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13486
13710
  try {
@@ -13491,6 +13715,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13491
13715
  },
13492
13716
  useReducer: function (reducer, initialArg, init) {
13493
13717
  currentHookNameInDev = 'useReducer';
13718
+ updateHookTypesDev();
13494
13719
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13495
13720
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13496
13721
  try {
@@ -13501,10 +13726,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13501
13726
  },
13502
13727
  useRef: function (initialValue) {
13503
13728
  currentHookNameInDev = 'useRef';
13729
+ updateHookTypesDev();
13504
13730
  return mountRef(initialValue);
13505
13731
  },
13506
13732
  useState: function (initialState) {
13507
13733
  currentHookNameInDev = 'useState';
13734
+ updateHookTypesDev();
13508
13735
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13509
13736
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13510
13737
  try {
@@ -13515,6 +13742,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13515
13742
  },
13516
13743
  useDebugValue: function (value, formatterFn) {
13517
13744
  currentHookNameInDev = 'useDebugValue';
13745
+ updateHookTypesDev();
13518
13746
  return mountDebugValue(value, formatterFn);
13519
13747
  }
13520
13748
  };
@@ -13525,26 +13753,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13525
13753
  },
13526
13754
  useCallback: function (callback, deps) {
13527
13755
  currentHookNameInDev = 'useCallback';
13756
+ updateHookTypesDev();
13528
13757
  return updateCallback(callback, deps);
13529
13758
  },
13530
13759
  useContext: function (context, observedBits) {
13531
13760
  currentHookNameInDev = 'useContext';
13532
- return updateContext(context, observedBits);
13761
+ updateHookTypesDev();
13762
+ return readContext(context, observedBits);
13533
13763
  },
13534
13764
  useEffect: function (create, deps) {
13535
13765
  currentHookNameInDev = 'useEffect';
13766
+ updateHookTypesDev();
13536
13767
  return updateEffect(create, deps);
13537
13768
  },
13538
13769
  useImperativeHandle: function (ref, create, deps) {
13539
13770
  currentHookNameInDev = 'useImperativeHandle';
13771
+ updateHookTypesDev();
13540
13772
  return updateImperativeHandle(ref, create, deps);
13541
13773
  },
13542
13774
  useLayoutEffect: function (create, deps) {
13543
13775
  currentHookNameInDev = 'useLayoutEffect';
13776
+ updateHookTypesDev();
13544
13777
  return updateLayoutEffect(create, deps);
13545
13778
  },
13546
13779
  useMemo: function (create, deps) {
13547
13780
  currentHookNameInDev = 'useMemo';
13781
+ updateHookTypesDev();
13548
13782
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13549
13783
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13550
13784
  try {
@@ -13555,6 +13789,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13555
13789
  },
13556
13790
  useReducer: function (reducer, initialArg, init) {
13557
13791
  currentHookNameInDev = 'useReducer';
13792
+ updateHookTypesDev();
13558
13793
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13559
13794
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13560
13795
  try {
@@ -13565,10 +13800,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13565
13800
  },
13566
13801
  useRef: function (initialValue) {
13567
13802
  currentHookNameInDev = 'useRef';
13803
+ updateHookTypesDev();
13568
13804
  return updateRef(initialValue);
13569
13805
  },
13570
13806
  useState: function (initialState) {
13571
13807
  currentHookNameInDev = 'useState';
13808
+ updateHookTypesDev();
13572
13809
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13573
13810
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13574
13811
  try {
@@ -13579,6 +13816,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13579
13816
  },
13580
13817
  useDebugValue: function (value, formatterFn) {
13581
13818
  currentHookNameInDev = 'useDebugValue';
13819
+ updateHookTypesDev();
13582
13820
  return updateDebugValue(value, formatterFn);
13583
13821
  }
13584
13822
  };
@@ -13591,31 +13829,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13591
13829
  useCallback: function (callback, deps) {
13592
13830
  currentHookNameInDev = 'useCallback';
13593
13831
  warnInvalidHookAccess();
13832
+ mountHookTypesDev();
13594
13833
  return mountCallback(callback, deps);
13595
13834
  },
13596
13835
  useContext: function (context, observedBits) {
13597
13836
  currentHookNameInDev = 'useContext';
13598
13837
  warnInvalidHookAccess();
13599
- return mountContext(context, observedBits);
13838
+ mountHookTypesDev();
13839
+ return readContext(context, observedBits);
13600
13840
  },
13601
13841
  useEffect: function (create, deps) {
13602
13842
  currentHookNameInDev = 'useEffect';
13603
13843
  warnInvalidHookAccess();
13844
+ mountHookTypesDev();
13604
13845
  return mountEffect(create, deps);
13605
13846
  },
13606
13847
  useImperativeHandle: function (ref, create, deps) {
13607
13848
  currentHookNameInDev = 'useImperativeHandle';
13608
13849
  warnInvalidHookAccess();
13850
+ mountHookTypesDev();
13609
13851
  return mountImperativeHandle(ref, create, deps);
13610
13852
  },
13611
13853
  useLayoutEffect: function (create, deps) {
13612
13854
  currentHookNameInDev = 'useLayoutEffect';
13613
13855
  warnInvalidHookAccess();
13856
+ mountHookTypesDev();
13614
13857
  return mountLayoutEffect(create, deps);
13615
13858
  },
13616
13859
  useMemo: function (create, deps) {
13617
13860
  currentHookNameInDev = 'useMemo';
13618
13861
  warnInvalidHookAccess();
13862
+ mountHookTypesDev();
13619
13863
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13620
13864
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13621
13865
  try {
@@ -13627,6 +13871,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13627
13871
  useReducer: function (reducer, initialArg, init) {
13628
13872
  currentHookNameInDev = 'useReducer';
13629
13873
  warnInvalidHookAccess();
13874
+ mountHookTypesDev();
13630
13875
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13631
13876
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13632
13877
  try {
@@ -13638,11 +13883,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13638
13883
  useRef: function (initialValue) {
13639
13884
  currentHookNameInDev = 'useRef';
13640
13885
  warnInvalidHookAccess();
13886
+ mountHookTypesDev();
13641
13887
  return mountRef(initialValue);
13642
13888
  },
13643
13889
  useState: function (initialState) {
13644
13890
  currentHookNameInDev = 'useState';
13645
13891
  warnInvalidHookAccess();
13892
+ mountHookTypesDev();
13646
13893
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13647
13894
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13648
13895
  try {
@@ -13654,6 +13901,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13654
13901
  useDebugValue: function (value, formatterFn) {
13655
13902
  currentHookNameInDev = 'useDebugValue';
13656
13903
  warnInvalidHookAccess();
13904
+ mountHookTypesDev();
13657
13905
  return mountDebugValue(value, formatterFn);
13658
13906
  }
13659
13907
  };
@@ -13666,31 +13914,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13666
13914
  useCallback: function (callback, deps) {
13667
13915
  currentHookNameInDev = 'useCallback';
13668
13916
  warnInvalidHookAccess();
13917
+ updateHookTypesDev();
13669
13918
  return updateCallback(callback, deps);
13670
13919
  },
13671
13920
  useContext: function (context, observedBits) {
13672
13921
  currentHookNameInDev = 'useContext';
13673
13922
  warnInvalidHookAccess();
13674
- return updateContext(context, observedBits);
13923
+ updateHookTypesDev();
13924
+ return readContext(context, observedBits);
13675
13925
  },
13676
13926
  useEffect: function (create, deps) {
13677
13927
  currentHookNameInDev = 'useEffect';
13678
13928
  warnInvalidHookAccess();
13929
+ updateHookTypesDev();
13679
13930
  return updateEffect(create, deps);
13680
13931
  },
13681
13932
  useImperativeHandle: function (ref, create, deps) {
13682
13933
  currentHookNameInDev = 'useImperativeHandle';
13683
13934
  warnInvalidHookAccess();
13935
+ updateHookTypesDev();
13684
13936
  return updateImperativeHandle(ref, create, deps);
13685
13937
  },
13686
13938
  useLayoutEffect: function (create, deps) {
13687
13939
  currentHookNameInDev = 'useLayoutEffect';
13688
13940
  warnInvalidHookAccess();
13941
+ updateHookTypesDev();
13689
13942
  return updateLayoutEffect(create, deps);
13690
13943
  },
13691
13944
  useMemo: function (create, deps) {
13692
13945
  currentHookNameInDev = 'useMemo';
13693
13946
  warnInvalidHookAccess();
13947
+ updateHookTypesDev();
13694
13948
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13695
13949
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13696
13950
  try {
@@ -13702,6 +13956,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13702
13956
  useReducer: function (reducer, initialArg, init) {
13703
13957
  currentHookNameInDev = 'useReducer';
13704
13958
  warnInvalidHookAccess();
13959
+ updateHookTypesDev();
13705
13960
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13706
13961
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13707
13962
  try {
@@ -13713,11 +13968,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13713
13968
  useRef: function (initialValue) {
13714
13969
  currentHookNameInDev = 'useRef';
13715
13970
  warnInvalidHookAccess();
13971
+ updateHookTypesDev();
13716
13972
  return updateRef(initialValue);
13717
13973
  },
13718
13974
  useState: function (initialState) {
13719
13975
  currentHookNameInDev = 'useState';
13720
13976
  warnInvalidHookAccess();
13977
+ updateHookTypesDev();
13721
13978
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13722
13979
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13723
13980
  try {
@@ -13729,6 +13986,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13729
13986
  useDebugValue: function (value, formatterFn) {
13730
13987
  currentHookNameInDev = 'useDebugValue';
13731
13988
  warnInvalidHookAccess();
13989
+ updateHookTypesDev();
13732
13990
  return updateDebugValue(value, formatterFn);
13733
13991
  }
13734
13992
  };
@@ -13800,6 +14058,18 @@ function enterHydrationState(fiber) {
13800
14058
  return true;
13801
14059
  }
13802
14060
 
14061
+ function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
14062
+ if (!supportsHydration) {
14063
+ return false;
14064
+ }
14065
+
14066
+ var suspenseInstance = fiber.stateNode;
14067
+ nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
14068
+ popToNextHostParent(fiber);
14069
+ isHydrating = true;
14070
+ return true;
14071
+ }
14072
+
13803
14073
  function deleteHydratableInstance(returnFiber, instance) {
13804
14074
  {
13805
14075
  switch (returnFiber.tag) {
@@ -13846,6 +14116,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
13846
14116
  case HostText:
13847
14117
  var text = fiber.pendingProps;
13848
14118
  didNotFindHydratableContainerTextInstance(parentContainer, text);
14119
+ break;
14120
+ case SuspenseComponent:
14121
+
13849
14122
  break;
13850
14123
  }
13851
14124
  break;
@@ -13865,6 +14138,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
13865
14138
  var _text = fiber.pendingProps;
13866
14139
  didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
13867
14140
  break;
14141
+ case SuspenseComponent:
14142
+ didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
14143
+ break;
13868
14144
  }
13869
14145
  break;
13870
14146
  }
@@ -13897,6 +14173,19 @@ function tryHydrate(fiber, nextInstance) {
13897
14173
  }
13898
14174
  return false;
13899
14175
  }
14176
+ case SuspenseComponent:
14177
+ {
14178
+ if (enableSuspenseServerRenderer) {
14179
+ var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
14180
+ if (suspenseInstance !== null) {
14181
+ // Downgrade the tag to a dehydrated component until we've hydrated it.
14182
+ fiber.tag = DehydratedSuspenseComponent;
14183
+ fiber.stateNode = suspenseInstance;
14184
+ return true;
14185
+ }
14186
+ }
14187
+ return false;
14188
+ }
13900
14189
  default:
13901
14190
  return false;
13902
14191
  }
@@ -13990,9 +14279,18 @@ function prepareToHydrateHostTextInstance(fiber) {
13990
14279
  return shouldUpdate;
13991
14280
  }
13992
14281
 
14282
+ function skipPastDehydratedSuspenseInstance(fiber) {
14283
+ if (!supportsHydration) {
14284
+ invariant(false, 'Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
14285
+ }
14286
+ var suspenseInstance = fiber.stateNode;
14287
+ !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;
14288
+ nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
14289
+ }
14290
+
13993
14291
  function popToNextHostParent(fiber) {
13994
14292
  var parent = fiber.return;
13995
- while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
14293
+ while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
13996
14294
  parent = parent.return;
13997
14295
  }
13998
14296
  hydrationParentFiber = parent;
@@ -14100,6 +14398,10 @@ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildre
14100
14398
  }
14101
14399
 
14102
14400
  function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
14401
+ // TODO: current can be non-null here even if the component
14402
+ // hasn't yet mounted. This happens after the first render suspends.
14403
+ // We'll need to figure out if this is fine or can cause issues.
14404
+
14103
14405
  {
14104
14406
  if (workInProgress.type !== workInProgress.elementType) {
14105
14407
  // Lazy component props can't be validated in createElement
@@ -14205,6 +14507,10 @@ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, u
14205
14507
  }
14206
14508
 
14207
14509
  function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
14510
+ // TODO: current can be non-null here even if the component
14511
+ // hasn't yet mounted. This happens when the inner render suspends.
14512
+ // We'll need to figure out if this is fine or can cause issues.
14513
+
14208
14514
  {
14209
14515
  if (workInProgress.type !== workInProgress.elementType) {
14210
14516
  // Lazy component props can't be validated in createElement
@@ -14828,6 +15134,18 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
14828
15134
  // children -- we skip over the primary children entirely.
14829
15135
  var next = void 0;
14830
15136
  if (current$$1 === null) {
15137
+ if (enableSuspenseServerRenderer) {
15138
+ // If we're currently hydrating, try to hydrate this boundary.
15139
+ // But only if this has a fallback.
15140
+ if (nextProps.fallback !== undefined) {
15141
+ tryToClaimNextHydratableInstance(workInProgress);
15142
+ // This could've changed the tag if this was a dehydrated suspense component.
15143
+ if (workInProgress.tag === DehydratedSuspenseComponent) {
15144
+ return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
15145
+ }
15146
+ }
15147
+ }
15148
+
14831
15149
  // This is the initial mount. This branch is pretty simple because there's
14832
15150
  // no previous state that needs to be preserved.
14833
15151
  if (nextDidTimeout) {
@@ -14979,6 +15297,65 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
14979
15297
  return next;
14980
15298
  }
14981
15299
 
15300
+ function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
15301
+ if (current$$1 === null) {
15302
+ // During the first pass, we'll bail out and not drill into the children.
15303
+ // Instead, we'll leave the content in place and try to hydrate it later.
15304
+ workInProgress.expirationTime = Never;
15305
+ return null;
15306
+ }
15307
+ // We use childExpirationTime to indicate that a child might depend on context, so if
15308
+ // any context has changed, we need to treat is as if the input might have changed.
15309
+ var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
15310
+ if (didReceiveUpdate || hasContextChanged$$1) {
15311
+ // This boundary has changed since the first render. This means that we are now unable to
15312
+ // hydrate it. We might still be able to hydrate it using an earlier expiration time but
15313
+ // during this render we can't. Instead, we're going to delete the whole subtree and
15314
+ // instead inject a new real Suspense boundary to take its place, which may render content
15315
+ // or fallback. The real Suspense boundary will suspend for a while so we have some time
15316
+ // to ensure it can produce real content, but all state and pending events will be lost.
15317
+
15318
+ // Detach from the current dehydrated boundary.
15319
+ current$$1.alternate = null;
15320
+ workInProgress.alternate = null;
15321
+
15322
+ // Insert a deletion in the effect list.
15323
+ var returnFiber = workInProgress.return;
15324
+ !(returnFiber !== null) ? invariant(false, 'Suspense boundaries are never on the root. This is probably a bug in React.') : void 0;
15325
+ var last = returnFiber.lastEffect;
15326
+ if (last !== null) {
15327
+ last.nextEffect = current$$1;
15328
+ returnFiber.lastEffect = current$$1;
15329
+ } else {
15330
+ returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
15331
+ }
15332
+ current$$1.nextEffect = null;
15333
+ current$$1.effectTag = Deletion;
15334
+
15335
+ // Upgrade this work in progress to a real Suspense component.
15336
+ workInProgress.tag = SuspenseComponent;
15337
+ workInProgress.stateNode = null;
15338
+ workInProgress.memoizedState = null;
15339
+ // This is now an insertion.
15340
+ workInProgress.effectTag |= Placement;
15341
+ // Retry as a real Suspense component.
15342
+ return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
15343
+ }
15344
+ if ((workInProgress.effectTag & DidCapture) === NoEffect) {
15345
+ // This is the first attempt.
15346
+ reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
15347
+ var nextProps = workInProgress.pendingProps;
15348
+ var nextChildren = nextProps.children;
15349
+ workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
15350
+ return workInProgress.child;
15351
+ } else {
15352
+ // Something suspended. Leave the existing children in place.
15353
+ // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
15354
+ workInProgress.child = null;
15355
+ return null;
15356
+ }
15357
+ }
15358
+
14982
15359
  function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
14983
15360
  pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
14984
15361
  var nextChildren = workInProgress.pendingProps;
@@ -15190,6 +15567,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
15190
15567
  }
15191
15568
  break;
15192
15569
  }
15570
+ case DehydratedSuspenseComponent:
15571
+ {
15572
+ if (enableSuspenseServerRenderer) {
15573
+ // We know that this component will suspend again because if it has
15574
+ // been unsuspended it has committed as a regular Suspense component.
15575
+ // If it needs to be retried, it should have work scheduled on it.
15576
+ workInProgress.effectTag |= DidCapture;
15577
+ break;
15578
+ }
15579
+ }
15193
15580
  }
15194
15581
  return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
15195
15582
  }
@@ -15281,9 +15668,15 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
15281
15668
  var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
15282
15669
  return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
15283
15670
  }
15284
- default:
15285
- invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
15671
+ case DehydratedSuspenseComponent:
15672
+ {
15673
+ if (enableSuspenseServerRenderer) {
15674
+ return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
15675
+ }
15676
+ break;
15677
+ }
15286
15678
  }
15679
+ invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
15287
15680
  }
15288
15681
 
15289
15682
  var valueCursor = createCursor(null);
@@ -15372,6 +15765,28 @@ function calculateChangedBits(context, newValue, oldValue) {
15372
15765
  }
15373
15766
  }
15374
15767
 
15768
+ function scheduleWorkOnParentPath(parent, renderExpirationTime) {
15769
+ // Update the child expiration time of all the ancestors, including
15770
+ // the alternates.
15771
+ var node = parent;
15772
+ while (node !== null) {
15773
+ var alternate = node.alternate;
15774
+ if (node.childExpirationTime < renderExpirationTime) {
15775
+ node.childExpirationTime = renderExpirationTime;
15776
+ if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15777
+ alternate.childExpirationTime = renderExpirationTime;
15778
+ }
15779
+ } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15780
+ alternate.childExpirationTime = renderExpirationTime;
15781
+ } else {
15782
+ // Neither alternate was updated, which means the rest of the
15783
+ // ancestor path already has sufficient priority.
15784
+ break;
15785
+ }
15786
+ node = node.return;
15787
+ }
15788
+ }
15789
+
15375
15790
  function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
15376
15791
  var fiber = workInProgress.child;
15377
15792
  if (fiber !== null) {
@@ -15410,25 +15825,8 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
15410
15825
  if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
15411
15826
  alternate.expirationTime = renderExpirationTime;
15412
15827
  }
15413
- // Update the child expiration time of all the ancestors, including
15414
- // the alternates.
15415
- var node = fiber.return;
15416
- while (node !== null) {
15417
- alternate = node.alternate;
15418
- if (node.childExpirationTime < renderExpirationTime) {
15419
- node.childExpirationTime = renderExpirationTime;
15420
- if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15421
- alternate.childExpirationTime = renderExpirationTime;
15422
- }
15423
- } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
15424
- alternate.childExpirationTime = renderExpirationTime;
15425
- } else {
15426
- // Neither alternate was updated, which means the rest of the
15427
- // ancestor path already has sufficient priority.
15428
- break;
15429
- }
15430
- node = node.return;
15431
- }
15828
+
15829
+ scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
15432
15830
 
15433
15831
  // Mark the expiration time on the list, too.
15434
15832
  if (list.expirationTime < renderExpirationTime) {
@@ -15444,6 +15842,23 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
15444
15842
  } else if (fiber.tag === ContextProvider) {
15445
15843
  // Don't scan deeper if this is a matching provider
15446
15844
  nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
15845
+ } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
15846
+ // If a dehydrated suspense component is in this subtree, we don't know
15847
+ // if it will have any context consumers in it. The best we can do is
15848
+ // mark it as having updates on its children.
15849
+ if (fiber.expirationTime < renderExpirationTime) {
15850
+ fiber.expirationTime = renderExpirationTime;
15851
+ }
15852
+ var _alternate = fiber.alternate;
15853
+ if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
15854
+ _alternate.expirationTime = renderExpirationTime;
15855
+ }
15856
+ // This is intentionally passing this fiber as the parent
15857
+ // because we want to schedule this fiber as having work
15858
+ // on its children. We'll use the childExpirationTime on
15859
+ // this fiber to indicate that a context has changed.
15860
+ scheduleWorkOnParentPath(fiber, renderExpirationTime);
15861
+ nextFiber = fiber.sibling;
15447
15862
  } else {
15448
15863
  // Traverse down.
15449
15864
  nextFiber = fiber.child;
@@ -16567,6 +16982,26 @@ function completeWork(current, workInProgress, renderExpirationTime) {
16567
16982
  }
16568
16983
  break;
16569
16984
  }
16985
+ case DehydratedSuspenseComponent:
16986
+ {
16987
+ if (enableSuspenseServerRenderer) {
16988
+ if (current === null) {
16989
+ var _wasHydrated2 = popHydrationState(workInProgress);
16990
+ !_wasHydrated2 ? invariant(false, 'A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.') : void 0;
16991
+ skipPastDehydratedSuspenseInstance(workInProgress);
16992
+ } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
16993
+ // This boundary did not suspend so it's now hydrated.
16994
+ // To handle any future suspense cases, we're going to now upgrade it
16995
+ // to a Suspense component. We detach it from the existing current fiber.
16996
+ current.alternate = null;
16997
+ workInProgress.alternate = null;
16998
+ workInProgress.tag = SuspenseComponent;
16999
+ workInProgress.memoizedState = null;
17000
+ workInProgress.stateNode = null;
17001
+ }
17002
+ }
17003
+ break;
17004
+ }
16570
17005
  default:
16571
17006
  invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
16572
17007
  }
@@ -16657,7 +17092,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
16657
17092
  didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
16658
17093
  }
16659
17094
 
16660
- var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
17095
+ var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
16661
17096
 
16662
17097
  function logError(boundary, errorInfo) {
16663
17098
  var source = errorInfo.source;
@@ -16823,11 +17258,11 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) {
16823
17258
  if (_destroy === null) {
16824
17259
  addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
16825
17260
  } else if (typeof _destroy.then === 'function') {
16826
- 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.";
17261
+ 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';
16827
17262
  } else {
16828
17263
  addendum = ' You returned: ' + _destroy;
16829
17264
  }
16830
- warningWithoutStack$1(false, 'An Effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17265
+ warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
16831
17266
  }
16832
17267
  }
16833
17268
  }
@@ -16970,7 +17405,7 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
16970
17405
 
16971
17406
  function hideOrUnhideAllChildren(finishedWork, isHidden) {
16972
17407
  if (supportsMutation) {
16973
- // We only have the top Fiber that was inserted but we need recurse down its
17408
+ // We only have the top Fiber that was inserted but we need to recurse down its
16974
17409
  var node = finishedWork;
16975
17410
  while (true) {
16976
17411
  if (node.tag === HostComponent) {
@@ -17238,7 +17673,7 @@ function getHostSibling(fiber) {
17238
17673
  }
17239
17674
  node.sibling.return = node.return;
17240
17675
  node = node.sibling;
17241
- while (node.tag !== HostComponent && node.tag !== HostText) {
17676
+ while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
17242
17677
  // If it is not host node and, we might have a host node inside it.
17243
17678
  // Try to search down until we find one.
17244
17679
  if (node.effectTag & Placement) {
@@ -17298,7 +17733,7 @@ function commitPlacement(finishedWork) {
17298
17733
  }
17299
17734
 
17300
17735
  var before = getHostSibling(finishedWork);
17301
- // We only have the top Fiber that was inserted but we need recurse down its
17736
+ // We only have the top Fiber that was inserted but we need to recurse down its
17302
17737
  // children to find all the terminal nodes.
17303
17738
  var node = finishedWork;
17304
17739
  while (true) {
@@ -17340,7 +17775,7 @@ function commitPlacement(finishedWork) {
17340
17775
  }
17341
17776
 
17342
17777
  function unmountHostComponents(current$$1) {
17343
- // We only have the top Fiber that was deleted but we need recurse down its
17778
+ // We only have the top Fiber that was deleted but we need to recurse down its
17344
17779
  var node = current$$1;
17345
17780
 
17346
17781
  // Each iteration, currentParent is populated with node's host parent if not
@@ -17385,13 +17820,20 @@ function unmountHostComponents(current$$1) {
17385
17820
  removeChild(currentParent, node.stateNode);
17386
17821
  }
17387
17822
  // Don't visit children because we already visited them.
17823
+ } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
17824
+ // Delete the dehydrated suspense boundary and all of its content.
17825
+ if (currentParentIsContainer) {
17826
+ clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
17827
+ } else {
17828
+ clearSuspenseBoundary(currentParent, node.stateNode);
17829
+ }
17388
17830
  } else if (node.tag === HostPortal) {
17389
- // When we go into a portal, it becomes the parent to remove from.
17390
- // We will reassign it back when we pop the portal on the way up.
17391
- currentParent = node.stateNode.containerInfo;
17392
- currentParentIsContainer = true;
17393
- // Visit children because portals might contain host components.
17394
17831
  if (node.child !== null) {
17832
+ // When we go into a portal, it becomes the parent to remove from.
17833
+ // We will reassign it back when we pop the portal on the way up.
17834
+ currentParent = node.stateNode.containerInfo;
17835
+ currentParentIsContainer = true;
17836
+ // Visit children because portals might contain host components.
17395
17837
  node.child.return = node;
17396
17838
  node = node.child;
17397
17839
  continue;
@@ -17541,7 +17983,7 @@ function commitWork(current$$1, finishedWork) {
17541
17983
  finishedWork.updateQueue = null;
17542
17984
  var retryCache = finishedWork.stateNode;
17543
17985
  if (retryCache === null) {
17544
- retryCache = finishedWork.stateNode = new PossiblyWeakSet();
17986
+ retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
17545
17987
  }
17546
17988
  thenables.forEach(function (thenable) {
17547
17989
  // Memoize using the boundary fiber to prevent redundant listeners.
@@ -17576,6 +18018,7 @@ function commitResetTextContent(current$$1) {
17576
18018
  resetTextContent(current$$1.stateNode);
17577
18019
  }
17578
18020
 
18021
+ var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
17579
18022
  var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
17580
18023
 
17581
18024
  function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
@@ -17634,6 +18077,34 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
17634
18077
  return update;
17635
18078
  }
17636
18079
 
18080
+ function attachPingListener(root, renderExpirationTime, thenable) {
18081
+ // Attach a listener to the promise to "ping" the root and retry. But
18082
+ // only if one does not already exist for the current render expiration
18083
+ // time (which acts like a "thread ID" here).
18084
+ var pingCache = root.pingCache;
18085
+ var threadIDs = void 0;
18086
+ if (pingCache === null) {
18087
+ pingCache = root.pingCache = new PossiblyWeakMap();
18088
+ threadIDs = new Set();
18089
+ pingCache.set(thenable, threadIDs);
18090
+ } else {
18091
+ threadIDs = pingCache.get(thenable);
18092
+ if (threadIDs === undefined) {
18093
+ threadIDs = new Set();
18094
+ pingCache.set(thenable, threadIDs);
18095
+ }
18096
+ }
18097
+ if (!threadIDs.has(renderExpirationTime)) {
18098
+ // Memoize using the thread ID to prevent redundant listeners.
18099
+ threadIDs.add(renderExpirationTime);
18100
+ var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
18101
+ if (enableSchedulerTracing) {
18102
+ ping = tracing.unstable_wrap(ping);
18103
+ }
18104
+ thenable.then(ping, ping);
18105
+ }
18106
+ }
18107
+
17637
18108
  function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
17638
18109
  // The source fiber did not complete.
17639
18110
  sourceFiber.effectTag |= Incomplete;
@@ -17675,6 +18146,9 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17675
18146
  }
17676
18147
  }
17677
18148
  }
18149
+ // If there is a DehydratedSuspenseComponent we don't have to do anything because
18150
+ // if something suspends inside it, we will simply leave that as dehydrated. It
18151
+ // will never timeout.
17678
18152
  _workInProgress = _workInProgress.return;
17679
18153
  } while (_workInProgress !== null);
17680
18154
 
@@ -17738,31 +18212,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17738
18212
  // Confirmed that the boundary is in a concurrent mode tree. Continue
17739
18213
  // with the normal suspend path.
17740
18214
 
17741
- // Attach a listener to the promise to "ping" the root and retry. But
17742
- // only if one does not already exist for the current render expiration
17743
- // time (which acts like a "thread ID" here).
17744
- var pingCache = root.pingCache;
17745
- var threadIDs = void 0;
17746
- if (pingCache === null) {
17747
- pingCache = root.pingCache = new PossiblyWeakMap();
17748
- threadIDs = new Set();
17749
- pingCache.set(thenable, threadIDs);
17750
- } else {
17751
- threadIDs = pingCache.get(thenable);
17752
- if (threadIDs === undefined) {
17753
- threadIDs = new Set();
17754
- pingCache.set(thenable, threadIDs);
17755
- }
17756
- }
17757
- if (!threadIDs.has(renderExpirationTime)) {
17758
- // Memoize using the thread ID to prevent redundant listeners.
17759
- threadIDs.add(renderExpirationTime);
17760
- var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
17761
- if (enableSchedulerTracing) {
17762
- ping = tracing.unstable_wrap(ping);
17763
- }
17764
- thenable.then(ping, ping);
17765
- }
18215
+ attachPingListener(root, renderExpirationTime, thenable);
17766
18216
 
17767
18217
  var absoluteTimeoutMs = void 0;
17768
18218
  if (earliestTimeoutMs === -1) {
@@ -17794,6 +18244,29 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
17794
18244
  // whole tree.
17795
18245
  renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
17796
18246
 
18247
+ _workInProgress.effectTag |= ShouldCapture;
18248
+ _workInProgress.expirationTime = renderExpirationTime;
18249
+ return;
18250
+ } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
18251
+ attachPingListener(root, renderExpirationTime, thenable);
18252
+
18253
+ // Since we already have a current fiber, we can eagerly add a retry listener.
18254
+ var retryCache = _workInProgress.memoizedState;
18255
+ if (retryCache === null) {
18256
+ retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
18257
+ var _current = _workInProgress.alternate;
18258
+ !_current ? invariant(false, 'A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.') : void 0;
18259
+ _current.memoizedState = retryCache;
18260
+ }
18261
+ // Memoize using the boundary fiber to prevent redundant listeners.
18262
+ if (!retryCache.has(thenable)) {
18263
+ retryCache.add(thenable);
18264
+ var retry = retryTimedOutBoundary.bind(null, _workInProgress, thenable);
18265
+ if (enableSchedulerTracing) {
18266
+ retry = tracing.unstable_wrap(retry);
18267
+ }
18268
+ thenable.then(retry, retry);
18269
+ }
17797
18270
  _workInProgress.effectTag |= ShouldCapture;
17798
18271
  _workInProgress.expirationTime = renderExpirationTime;
17799
18272
  return;
@@ -17871,6 +18344,7 @@ function unwindWork(workInProgress, renderExpirationTime) {
17871
18344
  }
17872
18345
  case HostComponent:
17873
18346
  {
18347
+ // TODO: popHydrationState
17874
18348
  popHostContext(workInProgress);
17875
18349
  return null;
17876
18350
  }
@@ -17884,6 +18358,19 @@ function unwindWork(workInProgress, renderExpirationTime) {
17884
18358
  }
17885
18359
  return null;
17886
18360
  }
18361
+ case DehydratedSuspenseComponent:
18362
+ {
18363
+ if (enableSuspenseServerRenderer) {
18364
+ // TODO: popHydrationState
18365
+ var _effectTag3 = workInProgress.effectTag;
18366
+ if (_effectTag3 & ShouldCapture) {
18367
+ workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
18368
+ // Captured a suspense effect. Re-render the boundary.
18369
+ return workInProgress;
18370
+ }
18371
+ }
18372
+ return null;
18373
+ }
17887
18374
  case HostPortal:
17888
18375
  popHostContainer(workInProgress);
17889
18376
  return null;
@@ -17981,11 +18468,6 @@ if (enableSchedulerTracing) {
17981
18468
  // Used to ensure computeUniqueAsyncExpiration is monotonically decreasing.
17982
18469
  var lastUniqueAsyncExpiration = Sync - 1;
17983
18470
 
17984
- // Represents the expiration time that incoming updates should use. (If this
17985
- // is NoWork, use the default strategy: async updates in async mode, sync
17986
- // updates in sync mode.)
17987
- var expirationContext = NoWork;
17988
-
17989
18471
  var isWorking = false;
17990
18472
 
17991
18473
  // The next work in progress fiber that we're currently working on.
@@ -18281,6 +18763,10 @@ function commitPassiveEffects(root, firstEffect) {
18281
18763
  if (rootExpirationTime !== NoWork) {
18282
18764
  requestWork(root, rootExpirationTime);
18283
18765
  }
18766
+ // Flush any sync work that was scheduled by effects
18767
+ if (!isBatchingUpdates && !isRendering) {
18768
+ performSyncWork();
18769
+ }
18284
18770
  }
18285
18771
 
18286
18772
  function isAlreadyFailedLegacyErrorBoundary(instance) {
@@ -18455,7 +18941,9 @@ function commitRoot(root, finishedWork) {
18455
18941
  // here because that code is still in flux.
18456
18942
  callback = tracing.unstable_wrap(callback);
18457
18943
  }
18458
- passiveEffectCallbackHandle = schedulePassiveEffects(callback);
18944
+ passiveEffectCallbackHandle = scheduler.unstable_runWithPriority(scheduler.unstable_NormalPriority, function () {
18945
+ return schedulePassiveEffects(callback);
18946
+ });
18459
18947
  passiveEffectCallback = callback;
18460
18948
  }
18461
18949
 
@@ -19044,7 +19532,7 @@ function renderRoot(root, isYieldy) {
19044
19532
  return;
19045
19533
  } else if (
19046
19534
  // There's no lower priority work, but we're rendering asynchronously.
19047
- // Synchronsouly attempt to render the same level one more time. This is
19535
+ // Synchronously attempt to render the same level one more time. This is
19048
19536
  // similar to a suspend, but without a timeout because we're not waiting
19049
19537
  // for a promise to resolve.
19050
19538
  !root.didError && isYieldy) {
@@ -19149,49 +19637,50 @@ function computeUniqueAsyncExpiration() {
19149
19637
  }
19150
19638
 
19151
19639
  function computeExpirationForFiber(currentTime, fiber) {
19640
+ var priorityLevel = scheduler.unstable_getCurrentPriorityLevel();
19641
+
19152
19642
  var expirationTime = void 0;
19153
- if (expirationContext !== NoWork) {
19154
- // An explicit expiration context was set;
19155
- expirationTime = expirationContext;
19156
- } else if (isWorking) {
19157
- if (isCommitting$1) {
19158
- // Updates that occur during the commit phase should have sync priority
19159
- // by default.
19160
- expirationTime = Sync;
19161
- } else {
19162
- // Updates during the render phase should expire at the same time as
19163
- // the work that is being rendered.
19164
- expirationTime = nextRenderExpirationTime;
19165
- }
19643
+ if ((fiber.mode & ConcurrentMode) === NoContext) {
19644
+ // Outside of concurrent mode, updates are always synchronous.
19645
+ expirationTime = Sync;
19646
+ } else if (isWorking && !isCommitting$1) {
19647
+ // During render phase, updates expire during as the current render.
19648
+ expirationTime = nextRenderExpirationTime;
19166
19649
  } else {
19167
- // No explicit expiration context was set, and we're not currently
19168
- // performing work. Calculate a new expiration time.
19169
- if (fiber.mode & ConcurrentMode) {
19170
- if (isBatchingInteractiveUpdates) {
19171
- // This is an interactive update
19650
+ switch (priorityLevel) {
19651
+ case scheduler.unstable_ImmediatePriority:
19652
+ expirationTime = Sync;
19653
+ break;
19654
+ case scheduler.unstable_UserBlockingPriority:
19172
19655
  expirationTime = computeInteractiveExpiration(currentTime);
19173
- } else {
19174
- // This is an async update
19656
+ break;
19657
+ case scheduler.unstable_NormalPriority:
19658
+ // This is a normal, concurrent update
19175
19659
  expirationTime = computeAsyncExpiration(currentTime);
19176
- }
19177
- // If we're in the middle of rendering a tree, do not update at the same
19178
- // expiration time that is already rendering.
19179
- if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
19180
- expirationTime -= 1;
19181
- }
19182
- } else {
19183
- // This is a sync update
19184
- expirationTime = Sync;
19660
+ break;
19661
+ case scheduler.unstable_LowPriority:
19662
+ case scheduler.unstable_IdlePriority:
19663
+ expirationTime = Never;
19664
+ break;
19665
+ default:
19666
+ invariant(false, 'Unknown priority level. This error is likely caused by a bug in React. Please file an issue.');
19185
19667
  }
19186
- }
19187
- if (isBatchingInteractiveUpdates) {
19188
- // This is an interactive update. Keep track of the lowest pending
19189
- // interactive expiration time. This allows us to synchronously flush
19190
- // all interactive updates when needed.
19191
- if (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime) {
19192
- lowestPriorityPendingInteractiveExpirationTime = expirationTime;
19668
+
19669
+ // If we're in the middle of rendering a tree, do not update at the same
19670
+ // expiration time that is already rendering.
19671
+ if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
19672
+ expirationTime -= 1;
19193
19673
  }
19194
19674
  }
19675
+
19676
+ // Keep track of the lowest pending interactive expiration time. This
19677
+ // allows us to synchronously flush all interactive updates
19678
+ // when needed.
19679
+ // TODO: Move this to renderer?
19680
+ if (priorityLevel === scheduler.unstable_UserBlockingPriority && (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime)) {
19681
+ lowestPriorityPendingInteractiveExpirationTime = expirationTime;
19682
+ }
19683
+
19195
19684
  return expirationTime;
19196
19685
  }
19197
19686
 
@@ -19238,7 +19727,21 @@ function retryTimedOutBoundary(boundaryFiber, thenable) {
19238
19727
  // The boundary fiber (a Suspense component) previously timed out and was
19239
19728
  // rendered in its fallback state. One of the promises that suspended it has
19240
19729
  // resolved, which means at least part of the tree was likely unblocked. Try
19241
- var retryCache = boundaryFiber.stateNode;
19730
+ var retryCache = void 0;
19731
+ if (enableSuspenseServerRenderer) {
19732
+ switch (boundaryFiber.tag) {
19733
+ case SuspenseComponent:
19734
+ retryCache = boundaryFiber.stateNode;
19735
+ break;
19736
+ case DehydratedSuspenseComponent:
19737
+ retryCache = boundaryFiber.memoizedState;
19738
+ break;
19739
+ default:
19740
+ invariant(false, 'Pinged unknown suspense boundary type. This is probably a bug in React.');
19741
+ }
19742
+ } else {
19743
+ retryCache = boundaryFiber.stateNode;
19744
+ }
19242
19745
  if (retryCache !== null) {
19243
19746
  // The thenable resolved, so we no longer need to memoize, because it will
19244
19747
  // never be thrown again.
@@ -19337,7 +19840,7 @@ function scheduleWorkToRoot(fiber, expirationTime) {
19337
19840
  function warnIfNotCurrentlyBatchingInDev(fiber) {
19338
19841
  {
19339
19842
  if (isRendering === false && isBatchingUpdates === false) {
19340
- 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));
19843
+ 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));
19341
19844
  }
19342
19845
  }
19343
19846
  }
@@ -19384,13 +19887,9 @@ function scheduleWork(fiber, expirationTime) {
19384
19887
  }
19385
19888
 
19386
19889
  function syncUpdates(fn, a, b, c, d) {
19387
- var previousExpirationContext = expirationContext;
19388
- expirationContext = Sync;
19389
- try {
19890
+ return scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
19390
19891
  return fn(a, b, c, d);
19391
- } finally {
19392
- expirationContext = previousExpirationContext;
19393
- }
19892
+ });
19394
19893
  }
19395
19894
 
19396
19895
  // TODO: Everything below this is written as if it has been lifted to the
@@ -19411,7 +19910,6 @@ var unhandledError = null;
19411
19910
 
19412
19911
  var isBatchingUpdates = false;
19413
19912
  var isUnbatchingUpdates = false;
19414
- var isBatchingInteractiveUpdates = false;
19415
19913
 
19416
19914
  var completedBatches = null;
19417
19915
 
@@ -19885,7 +20383,9 @@ function completeRoot(root, finishedWork, expirationTime) {
19885
20383
  lastCommittedRootDuringThisBatch = root;
19886
20384
  nestedUpdateCount = 0;
19887
20385
  }
19888
- commitRoot(root, finishedWork);
20386
+ scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
20387
+ commitRoot(root, finishedWork);
20388
+ });
19889
20389
  }
19890
20390
 
19891
20391
  function onUncaughtError(error) {
@@ -19943,9 +20443,6 @@ function flushSync(fn, a) {
19943
20443
  }
19944
20444
 
19945
20445
  function interactiveUpdates$1(fn, a, b) {
19946
- if (isBatchingInteractiveUpdates) {
19947
- return fn(a, b);
19948
- }
19949
20446
  // If there are any pending interactive updates, synchronously flush them.
19950
20447
  // This needs to happen before we read any handlers, because the effect of
19951
20448
  // the previous event may influence which handlers are called during
@@ -19955,14 +20452,13 @@ function interactiveUpdates$1(fn, a, b) {
19955
20452
  performWork(lowestPriorityPendingInteractiveExpirationTime, false);
19956
20453
  lowestPriorityPendingInteractiveExpirationTime = NoWork;
19957
20454
  }
19958
- var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates;
19959
20455
  var previousIsBatchingUpdates = isBatchingUpdates;
19960
- isBatchingInteractiveUpdates = true;
19961
20456
  isBatchingUpdates = true;
19962
20457
  try {
19963
- return fn(a, b);
20458
+ return scheduler.unstable_runWithPriority(scheduler.unstable_UserBlockingPriority, function () {
20459
+ return fn(a, b);
20460
+ });
19964
20461
  } finally {
19965
- isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates;
19966
20462
  isBatchingUpdates = previousIsBatchingUpdates;
19967
20463
  if (!isBatchingUpdates && !isRendering) {
19968
20464
  performSyncWork();
@@ -20225,7 +20721,7 @@ implementation) {
20225
20721
 
20226
20722
  // TODO: this is special because it gets imported during build.
20227
20723
 
20228
- var ReactVersion = '16.8.1';
20724
+ var ReactVersion = '16.8.5';
20229
20725
 
20230
20726
  // This file is copy paste from ReactDOM with adjusted paths
20231
20727
  // and a different host config import (react-reconciler/inline.fire).
@@ -20620,7 +21116,7 @@ var ReactDOM = {
20620
21116
  hydrate: function (element, container, callback) {
20621
21117
  !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0;
20622
21118
  {
20623
- !!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;
21119
+ !!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;
20624
21120
  }
20625
21121
  // TODO: throw or warn if we couldn't hydrate?
20626
21122
  return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);