react-dom 16.8.0 → 16.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-info.json +5 -5
- package/cjs/react-dom-server.browser.development.js +74 -34
- package/cjs/react-dom-server.browser.production.min.js +35 -33
- package/cjs/react-dom-server.node.development.js +74 -34
- package/cjs/react-dom-server.node.production.min.js +36 -34
- package/cjs/react-dom-test-utils.development.js +23 -5
- package/cjs/react-dom-test-utils.production.min.js +23 -23
- package/cjs/react-dom-unstable-fire.development.js +698 -204
- package/cjs/react-dom-unstable-fire.production.min.js +252 -251
- package/cjs/react-dom-unstable-fire.profiling.min.js +179 -177
- package/cjs/react-dom-unstable-fizz.browser.development.js +1 -1
- package/cjs/react-dom-unstable-fizz.browser.production.min.js +1 -1
- package/cjs/react-dom-unstable-fizz.node.development.js +1 -1
- package/cjs/react-dom-unstable-fizz.node.production.min.js +1 -1
- package/cjs/react-dom-unstable-native-dependencies.development.js +2 -2
- package/cjs/react-dom-unstable-native-dependencies.production.min.js +1 -1
- package/cjs/react-dom.development.js +698 -204
- package/cjs/react-dom.production.min.js +252 -251
- package/cjs/react-dom.profiling.min.js +179 -177
- package/package.json +2 -2
- package/umd/react-dom-server.browser.development.js +74 -34
- package/umd/react-dom-server.browser.production.min.js +22 -21
- package/umd/react-dom-test-utils.development.js +23 -5
- package/umd/react-dom-test-utils.production.min.js +22 -21
- package/umd/react-dom-unstable-fire.development.js +706 -204
- package/umd/react-dom-unstable-fire.production.min.js +208 -207
- package/umd/react-dom-unstable-fire.profiling.min.js +208 -207
- package/umd/react-dom-unstable-fizz.browser.development.js +1 -1
- package/umd/react-dom-unstable-fizz.browser.production.min.js +1 -1
- package/umd/react-dom-unstable-native-dependencies.development.js +2 -2
- package/umd/react-dom-unstable-native-dependencies.production.min.js +1 -1
- package/umd/react-dom.development.js +706 -204
- package/umd/react-dom.production.min.js +208 -207
- package/umd/react-dom.profiling.min.js +208 -207
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.8.
|
|
1
|
+
/** @license React v16.8.4
|
|
2
2
|
* react-dom.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
|
-
//
|
|
88
|
+
// unintuitive, though, because even though React has caught the error, from
|
|
89
89
|
// the developer's perspective, the error is uncaught.
|
|
90
90
|
//
|
|
91
91
|
// To preserve the expected "Pause on exceptions" behavior, we don't use a
|
|
@@ -842,6 +842,7 @@ var MemoComponent = 14;
|
|
|
842
842
|
var SimpleMemoComponent = 15;
|
|
843
843
|
var LazyComponent = 16;
|
|
844
844
|
var IncompleteClassComponent = 17;
|
|
845
|
+
var DehydratedSuspenseComponent = 18;
|
|
845
846
|
|
|
846
847
|
var randomKey = Math.random().toString(36).slice(2);
|
|
847
848
|
var internalInstanceKey = '__reactInternalInstance$' + randomKey;
|
|
@@ -2384,6 +2385,15 @@ function updateValueIfChanged(node) {
|
|
|
2384
2385
|
|
|
2385
2386
|
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
2386
2387
|
|
|
2388
|
+
// Prevent newer renderers from RTE when used with older react package versions.
|
|
2389
|
+
// Current owner and dispatcher used to share the same ref,
|
|
2390
|
+
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
2391
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
2392
|
+
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
2393
|
+
current: null
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2387
2397
|
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
2388
2398
|
|
|
2389
2399
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
@@ -2894,12 +2904,15 @@ var capitalize = function (token) {
|
|
|
2894
2904
|
attributeName, 'http://www.w3.org/XML/1998/namespace');
|
|
2895
2905
|
});
|
|
2896
2906
|
|
|
2897
|
-
//
|
|
2898
|
-
//
|
|
2899
|
-
//
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2907
|
+
// These attribute exists both in HTML and SVG.
|
|
2908
|
+
// The attribute name is case-sensitive in SVG so we can't just use
|
|
2909
|
+
// the React name like we do for attributes that exist only in HTML.
|
|
2910
|
+
['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
|
|
2911
|
+
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
|
|
2912
|
+
attributeName.toLowerCase(), // attributeName
|
|
2913
|
+
null);
|
|
2914
|
+
} // attributeNamespace
|
|
2915
|
+
);
|
|
2903
2916
|
|
|
2904
2917
|
/**
|
|
2905
2918
|
* Get the value for a property on a node. Only used in DEV for SSR validation.
|
|
@@ -3138,7 +3151,7 @@ var enableProfilerTimer = true;
|
|
|
3138
3151
|
var enableSchedulerTracing = true;
|
|
3139
3152
|
|
|
3140
3153
|
// Only used in www builds.
|
|
3141
|
-
// TODO: true? Here it might just be false.
|
|
3154
|
+
var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
|
|
3142
3155
|
|
|
3143
3156
|
// Only used in www builds.
|
|
3144
3157
|
|
|
@@ -8613,6 +8626,9 @@ var SUPPRESS_HYDRATION_WARNING = void 0;
|
|
|
8613
8626
|
SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
|
|
8614
8627
|
}
|
|
8615
8628
|
|
|
8629
|
+
var SUSPENSE_START_DATA = '$';
|
|
8630
|
+
var SUSPENSE_END_DATA = '/$';
|
|
8631
|
+
|
|
8616
8632
|
var STYLE = 'style';
|
|
8617
8633
|
|
|
8618
8634
|
var eventsEnabled = null;
|
|
@@ -8841,6 +8857,43 @@ function removeChildFromContainer(container, child) {
|
|
|
8841
8857
|
}
|
|
8842
8858
|
}
|
|
8843
8859
|
|
|
8860
|
+
function clearSuspenseBoundary(parentInstance, suspenseInstance) {
|
|
8861
|
+
var node = suspenseInstance;
|
|
8862
|
+
// Delete all nodes within this suspense boundary.
|
|
8863
|
+
// There might be nested nodes so we need to keep track of how
|
|
8864
|
+
// deep we are and only break out when we're back on top.
|
|
8865
|
+
var depth = 0;
|
|
8866
|
+
do {
|
|
8867
|
+
var nextNode = node.nextSibling;
|
|
8868
|
+
parentInstance.removeChild(node);
|
|
8869
|
+
if (nextNode && nextNode.nodeType === COMMENT_NODE) {
|
|
8870
|
+
var data = nextNode.data;
|
|
8871
|
+
if (data === SUSPENSE_END_DATA) {
|
|
8872
|
+
if (depth === 0) {
|
|
8873
|
+
parentInstance.removeChild(nextNode);
|
|
8874
|
+
return;
|
|
8875
|
+
} else {
|
|
8876
|
+
depth--;
|
|
8877
|
+
}
|
|
8878
|
+
} else if (data === SUSPENSE_START_DATA) {
|
|
8879
|
+
depth++;
|
|
8880
|
+
}
|
|
8881
|
+
}
|
|
8882
|
+
node = nextNode;
|
|
8883
|
+
} while (node);
|
|
8884
|
+
// TODO: Warn, we didn't find the end comment boundary.
|
|
8885
|
+
}
|
|
8886
|
+
|
|
8887
|
+
function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
|
|
8888
|
+
if (container.nodeType === COMMENT_NODE) {
|
|
8889
|
+
clearSuspenseBoundary(container.parentNode, suspenseInstance);
|
|
8890
|
+
} else if (container.nodeType === ELEMENT_NODE) {
|
|
8891
|
+
clearSuspenseBoundary(container, suspenseInstance);
|
|
8892
|
+
} else {
|
|
8893
|
+
// Document nodes should never contain suspense boundaries.
|
|
8894
|
+
}
|
|
8895
|
+
}
|
|
8896
|
+
|
|
8844
8897
|
function hideInstance(instance) {
|
|
8845
8898
|
// TODO: Does this work for all element types? What about MathML? Should we
|
|
8846
8899
|
// pass host context to this method?
|
|
@@ -8886,10 +8939,19 @@ function canHydrateTextInstance(instance, text) {
|
|
|
8886
8939
|
return instance;
|
|
8887
8940
|
}
|
|
8888
8941
|
|
|
8942
|
+
function canHydrateSuspenseInstance(instance) {
|
|
8943
|
+
if (instance.nodeType !== COMMENT_NODE) {
|
|
8944
|
+
// Empty strings are not parsed by HTML so there won't be a correct match here.
|
|
8945
|
+
return null;
|
|
8946
|
+
}
|
|
8947
|
+
// This has now been refined to a suspense node.
|
|
8948
|
+
return instance;
|
|
8949
|
+
}
|
|
8950
|
+
|
|
8889
8951
|
function getNextHydratableSibling(instance) {
|
|
8890
8952
|
var node = instance.nextSibling;
|
|
8891
8953
|
// Skip non-hydratable nodes.
|
|
8892
|
-
while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) {
|
|
8954
|
+
while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || node.nodeType !== COMMENT_NODE || node.data !== SUSPENSE_START_DATA)) {
|
|
8893
8955
|
node = node.nextSibling;
|
|
8894
8956
|
}
|
|
8895
8957
|
return node;
|
|
@@ -8898,7 +8960,7 @@ function getNextHydratableSibling(instance) {
|
|
|
8898
8960
|
function getFirstHydratableChild(parentInstance) {
|
|
8899
8961
|
var next = parentInstance.firstChild;
|
|
8900
8962
|
// Skip non-hydratable nodes.
|
|
8901
|
-
while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) {
|
|
8963
|
+
while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE && (!enableSuspenseServerRenderer || next.nodeType !== COMMENT_NODE || next.data !== SUSPENSE_START_DATA)) {
|
|
8902
8964
|
next = next.nextSibling;
|
|
8903
8965
|
}
|
|
8904
8966
|
return next;
|
|
@@ -8922,6 +8984,31 @@ function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
|
|
|
8922
8984
|
return diffHydratedText(textInstance, text);
|
|
8923
8985
|
}
|
|
8924
8986
|
|
|
8987
|
+
function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
|
|
8988
|
+
var node = suspenseInstance.nextSibling;
|
|
8989
|
+
// Skip past all nodes within this suspense boundary.
|
|
8990
|
+
// There might be nested nodes so we need to keep track of how
|
|
8991
|
+
// deep we are and only break out when we're back on top.
|
|
8992
|
+
var depth = 0;
|
|
8993
|
+
while (node) {
|
|
8994
|
+
if (node.nodeType === COMMENT_NODE) {
|
|
8995
|
+
var data = node.data;
|
|
8996
|
+
if (data === SUSPENSE_END_DATA) {
|
|
8997
|
+
if (depth === 0) {
|
|
8998
|
+
return getNextHydratableSibling(node);
|
|
8999
|
+
} else {
|
|
9000
|
+
depth--;
|
|
9001
|
+
}
|
|
9002
|
+
} else if (data === SUSPENSE_START_DATA) {
|
|
9003
|
+
depth++;
|
|
9004
|
+
}
|
|
9005
|
+
}
|
|
9006
|
+
node = node.nextSibling;
|
|
9007
|
+
}
|
|
9008
|
+
// TODO: Warn, we didn't find the end comment boundary.
|
|
9009
|
+
return null;
|
|
9010
|
+
}
|
|
9011
|
+
|
|
8925
9012
|
function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
|
|
8926
9013
|
{
|
|
8927
9014
|
warnForUnmatchedText(textInstance, text);
|
|
@@ -8938,6 +9025,8 @@ function didNotHydrateContainerInstance(parentContainer, instance) {
|
|
|
8938
9025
|
{
|
|
8939
9026
|
if (instance.nodeType === ELEMENT_NODE) {
|
|
8940
9027
|
warnForDeletedHydratableElement(parentContainer, instance);
|
|
9028
|
+
} else if (instance.nodeType === COMMENT_NODE) {
|
|
9029
|
+
// TODO: warnForDeletedHydratableSuspenseBoundary
|
|
8941
9030
|
} else {
|
|
8942
9031
|
warnForDeletedHydratableText(parentContainer, instance);
|
|
8943
9032
|
}
|
|
@@ -8948,6 +9037,8 @@ function didNotHydrateInstance(parentType, parentProps, parentInstance, instance
|
|
|
8948
9037
|
if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
|
|
8949
9038
|
if (instance.nodeType === ELEMENT_NODE) {
|
|
8950
9039
|
warnForDeletedHydratableElement(parentInstance, instance);
|
|
9040
|
+
} else if (instance.nodeType === COMMENT_NODE) {
|
|
9041
|
+
// TODO: warnForDeletedHydratableSuspenseBoundary
|
|
8951
9042
|
} else {
|
|
8952
9043
|
warnForDeletedHydratableText(parentInstance, instance);
|
|
8953
9044
|
}
|
|
@@ -8966,6 +9057,8 @@ function didNotFindHydratableContainerTextInstance(parentContainer, text) {
|
|
|
8966
9057
|
}
|
|
8967
9058
|
}
|
|
8968
9059
|
|
|
9060
|
+
|
|
9061
|
+
|
|
8969
9062
|
function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
|
|
8970
9063
|
if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
|
|
8971
9064
|
warnForInsertedHydratedElement(parentInstance, type, props);
|
|
@@ -8978,6 +9071,12 @@ function didNotFindHydratableTextInstance(parentType, parentProps, parentInstanc
|
|
|
8978
9071
|
}
|
|
8979
9072
|
}
|
|
8980
9073
|
|
|
9074
|
+
function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
|
|
9075
|
+
if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
|
|
9076
|
+
// TODO: warnForInsertedHydratedSuspense(parentInstance);
|
|
9077
|
+
}
|
|
9078
|
+
}
|
|
9079
|
+
|
|
8981
9080
|
// Prefix measurements so that it's possible to filter them.
|
|
8982
9081
|
// Longer prefixes are hard to read in DevTools.
|
|
8983
9082
|
var reactEmoji = '\u269B';
|
|
@@ -9233,7 +9332,7 @@ function stopFailedWorkTimer(fiber) {
|
|
|
9233
9332
|
return;
|
|
9234
9333
|
}
|
|
9235
9334
|
fiber._debugIsCurrentlyTiming = false;
|
|
9236
|
-
var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
|
|
9335
|
+
var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
|
|
9237
9336
|
endFiberMark(fiber, null, warning);
|
|
9238
9337
|
}
|
|
9239
9338
|
}
|
|
@@ -9902,6 +10001,7 @@ function FiberNode(tag, pendingProps, key, mode) {
|
|
|
9902
10001
|
this._debugSource = null;
|
|
9903
10002
|
this._debugOwner = null;
|
|
9904
10003
|
this._debugIsCurrentlyTiming = false;
|
|
10004
|
+
this._debugHookTypes = null;
|
|
9905
10005
|
if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
|
|
9906
10006
|
Object.preventExtensions(this);
|
|
9907
10007
|
}
|
|
@@ -9969,6 +10069,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
|
|
|
9969
10069
|
workInProgress._debugID = current._debugID;
|
|
9970
10070
|
workInProgress._debugSource = current._debugSource;
|
|
9971
10071
|
workInProgress._debugOwner = current._debugOwner;
|
|
10072
|
+
workInProgress._debugHookTypes = current._debugHookTypes;
|
|
9972
10073
|
}
|
|
9973
10074
|
|
|
9974
10075
|
workInProgress.alternate = current;
|
|
@@ -10236,6 +10337,7 @@ function assignFiberPropertiesInDEV(target, source) {
|
|
|
10236
10337
|
target._debugSource = source._debugSource;
|
|
10237
10338
|
target._debugOwner = source._debugOwner;
|
|
10238
10339
|
target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
|
|
10340
|
+
target._debugHookTypes = source._debugHookTypes;
|
|
10239
10341
|
return target;
|
|
10240
10342
|
}
|
|
10241
10343
|
|
|
@@ -12040,7 +12142,7 @@ function ChildReconciler(shouldTrackSideEffects) {
|
|
|
12040
12142
|
}
|
|
12041
12143
|
|
|
12042
12144
|
function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
|
|
12043
|
-
// This algorithm can't optimize by searching from
|
|
12145
|
+
// This algorithm can't optimize by searching from both ends since we
|
|
12044
12146
|
// don't have backpointers on fibers. I'm trying to see how far we can get
|
|
12045
12147
|
// with that model. If it ends up not being worth the tradeoffs, we can
|
|
12046
12148
|
// add it later.
|
|
@@ -12621,7 +12723,6 @@ var currentlyRenderingFiber$1 = null;
|
|
|
12621
12723
|
// current hook list is the list that belongs to the current fiber. The
|
|
12622
12724
|
// work-in-progress hook list is a new list that will be added to the
|
|
12623
12725
|
// work-in-progress fiber.
|
|
12624
|
-
var firstCurrentHook = null;
|
|
12625
12726
|
var currentHook = null;
|
|
12626
12727
|
var nextCurrentHook = null;
|
|
12627
12728
|
var firstWorkInProgressHook = null;
|
|
@@ -12651,39 +12752,67 @@ var RE_RENDER_LIMIT = 25;
|
|
|
12651
12752
|
// In DEV, this is the name of the currently executing primitive hook
|
|
12652
12753
|
var currentHookNameInDev = null;
|
|
12653
12754
|
|
|
12654
|
-
|
|
12755
|
+
// In DEV, this list ensures that hooks are called in the same order between renders.
|
|
12756
|
+
// The list stores the order of hooks used during the initial render (mount).
|
|
12757
|
+
// Subsequent renders (updates) reference this list.
|
|
12758
|
+
var hookTypesDev = null;
|
|
12759
|
+
var hookTypesUpdateIndexDev = -1;
|
|
12760
|
+
|
|
12761
|
+
function mountHookTypesDev() {
|
|
12762
|
+
{
|
|
12763
|
+
var hookName = currentHookNameInDev;
|
|
12764
|
+
|
|
12765
|
+
if (hookTypesDev === null) {
|
|
12766
|
+
hookTypesDev = [hookName];
|
|
12767
|
+
} else {
|
|
12768
|
+
hookTypesDev.push(hookName);
|
|
12769
|
+
}
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
|
|
12773
|
+
function updateHookTypesDev() {
|
|
12774
|
+
{
|
|
12775
|
+
var hookName = currentHookNameInDev;
|
|
12776
|
+
|
|
12777
|
+
if (hookTypesDev !== null) {
|
|
12778
|
+
hookTypesUpdateIndexDev++;
|
|
12779
|
+
if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
|
|
12780
|
+
warnOnHookMismatchInDev(hookName);
|
|
12781
|
+
}
|
|
12782
|
+
}
|
|
12783
|
+
}
|
|
12784
|
+
}
|
|
12785
|
+
|
|
12786
|
+
function warnOnHookMismatchInDev(currentHookName) {
|
|
12655
12787
|
{
|
|
12656
12788
|
var componentName = getComponentName(currentlyRenderingFiber$1.type);
|
|
12657
12789
|
if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
|
|
12658
12790
|
didWarnAboutMismatchedHooksForComponent.add(componentName);
|
|
12659
12791
|
|
|
12660
|
-
|
|
12792
|
+
if (hookTypesDev !== null) {
|
|
12793
|
+
var table = '';
|
|
12661
12794
|
|
|
12662
|
-
|
|
12663
|
-
var prevHook = firstCurrentHook;
|
|
12664
|
-
var nextHook = firstWorkInProgressHook;
|
|
12665
|
-
var n = 1;
|
|
12666
|
-
while (prevHook !== null && nextHook !== null) {
|
|
12667
|
-
var oldHookName = prevHook._debugType;
|
|
12668
|
-
var newHookName = nextHook._debugType;
|
|
12795
|
+
var secondColumnStart = 30;
|
|
12669
12796
|
|
|
12670
|
-
var
|
|
12797
|
+
for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
|
|
12798
|
+
var oldHookName = hookTypesDev[i];
|
|
12799
|
+
var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
|
|
12671
12800
|
|
|
12672
|
-
|
|
12673
|
-
// lol @ IE not supporting String#repeat
|
|
12674
|
-
while (row.length < secondColumnStart) {
|
|
12675
|
-
row += ' ';
|
|
12676
|
-
}
|
|
12801
|
+
var row = i + 1 + '. ' + oldHookName;
|
|
12677
12802
|
|
|
12678
|
-
|
|
12803
|
+
// Extra space so second column lines up
|
|
12804
|
+
// lol @ IE not supporting String#repeat
|
|
12805
|
+
while (row.length < secondColumnStart) {
|
|
12806
|
+
row += ' ';
|
|
12807
|
+
}
|
|
12679
12808
|
|
|
12680
|
-
|
|
12681
|
-
prevHook = prevHook.next;
|
|
12682
|
-
nextHook = nextHook.next;
|
|
12683
|
-
n++;
|
|
12684
|
-
}
|
|
12809
|
+
row += newHookName + '\n';
|
|
12685
12810
|
|
|
12686
|
-
|
|
12811
|
+
table += row;
|
|
12812
|
+
}
|
|
12813
|
+
|
|
12814
|
+
warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
|
|
12815
|
+
}
|
|
12687
12816
|
}
|
|
12688
12817
|
}
|
|
12689
12818
|
}
|
|
@@ -12719,7 +12848,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
|
|
|
12719
12848
|
function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
|
|
12720
12849
|
renderExpirationTime = nextRenderExpirationTime;
|
|
12721
12850
|
currentlyRenderingFiber$1 = workInProgress;
|
|
12722
|
-
|
|
12851
|
+
nextCurrentHook = current !== null ? current.memoizedState : null;
|
|
12852
|
+
|
|
12853
|
+
{
|
|
12854
|
+
hookTypesDev = current !== null ? current._debugHookTypes : null;
|
|
12855
|
+
hookTypesUpdateIndexDev = -1;
|
|
12856
|
+
}
|
|
12723
12857
|
|
|
12724
12858
|
// The following should have already been reset
|
|
12725
12859
|
// currentHook = null;
|
|
@@ -12733,8 +12867,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
|
|
|
12733
12867
|
// numberOfReRenders = 0;
|
|
12734
12868
|
// sideEffectTag = 0;
|
|
12735
12869
|
|
|
12870
|
+
// TODO Warn if no hooks are used at all during mount, then some are used during update.
|
|
12871
|
+
// Currently we will identify the update render as a mount because nextCurrentHook === null.
|
|
12872
|
+
// This is tricky because it's valid for certain types of components (e.g. React.lazy)
|
|
12873
|
+
|
|
12874
|
+
// Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
|
|
12875
|
+
// Non-stateful hooks (e.g. context) don't get added to memoizedState,
|
|
12876
|
+
// so nextCurrentHook would be null during updates and mounts.
|
|
12736
12877
|
{
|
|
12737
|
-
|
|
12878
|
+
if (nextCurrentHook !== null) {
|
|
12879
|
+
ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
|
12880
|
+
} else if (hookTypesDev !== null) {
|
|
12881
|
+
// This dispatcher handles an edge case where a component is updating,
|
|
12882
|
+
// but no stateful hooks have been used.
|
|
12883
|
+
// We want to match the production code behavior (which will use HooksDispatcherOnMount),
|
|
12884
|
+
// but with the extra DEV validation to ensure hooks ordering hasn't changed.
|
|
12885
|
+
// This dispatcher does that.
|
|
12886
|
+
ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
|
|
12887
|
+
} else {
|
|
12888
|
+
ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
|
|
12889
|
+
}
|
|
12738
12890
|
}
|
|
12739
12891
|
|
|
12740
12892
|
var children = Component(props, refOrContext);
|
|
@@ -12745,13 +12897,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
|
|
|
12745
12897
|
numberOfReRenders += 1;
|
|
12746
12898
|
|
|
12747
12899
|
// Start over from the beginning of the list
|
|
12748
|
-
|
|
12900
|
+
nextCurrentHook = current !== null ? current.memoizedState : null;
|
|
12749
12901
|
nextWorkInProgressHook = firstWorkInProgressHook;
|
|
12750
12902
|
|
|
12751
12903
|
currentHook = null;
|
|
12752
12904
|
workInProgressHook = null;
|
|
12753
12905
|
componentUpdateQueue = null;
|
|
12754
12906
|
|
|
12907
|
+
{
|
|
12908
|
+
// Also validate hook order for cascading updates.
|
|
12909
|
+
hookTypesUpdateIndexDev = -1;
|
|
12910
|
+
}
|
|
12911
|
+
|
|
12755
12912
|
ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
|
12756
12913
|
|
|
12757
12914
|
children = Component(props, refOrContext);
|
|
@@ -12761,10 +12918,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
|
|
|
12761
12918
|
numberOfReRenders = 0;
|
|
12762
12919
|
}
|
|
12763
12920
|
|
|
12764
|
-
{
|
|
12765
|
-
currentHookNameInDev = null;
|
|
12766
|
-
}
|
|
12767
|
-
|
|
12768
12921
|
// We can assume the previous dispatcher is always this one, since we set it
|
|
12769
12922
|
// at the beginning of the render phase and there's no re-entrancy.
|
|
12770
12923
|
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
|
@@ -12776,18 +12929,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
|
|
|
12776
12929
|
renderedWork.updateQueue = componentUpdateQueue;
|
|
12777
12930
|
renderedWork.effectTag |= sideEffectTag;
|
|
12778
12931
|
|
|
12932
|
+
{
|
|
12933
|
+
renderedWork._debugHookTypes = hookTypesDev;
|
|
12934
|
+
}
|
|
12935
|
+
|
|
12936
|
+
// This check uses currentHook so that it works the same in DEV and prod bundles.
|
|
12937
|
+
// hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
|
|
12779
12938
|
var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
|
|
12780
12939
|
|
|
12781
12940
|
renderExpirationTime = NoWork;
|
|
12782
12941
|
currentlyRenderingFiber$1 = null;
|
|
12783
12942
|
|
|
12784
|
-
firstCurrentHook = null;
|
|
12785
12943
|
currentHook = null;
|
|
12786
12944
|
nextCurrentHook = null;
|
|
12787
12945
|
firstWorkInProgressHook = null;
|
|
12788
12946
|
workInProgressHook = null;
|
|
12789
12947
|
nextWorkInProgressHook = null;
|
|
12790
12948
|
|
|
12949
|
+
{
|
|
12950
|
+
currentHookNameInDev = null;
|
|
12951
|
+
hookTypesDev = null;
|
|
12952
|
+
hookTypesUpdateIndexDev = -1;
|
|
12953
|
+
}
|
|
12954
|
+
|
|
12791
12955
|
remainingExpirationTime = NoWork;
|
|
12792
12956
|
componentUpdateQueue = null;
|
|
12793
12957
|
sideEffectTag = 0;
|
|
@@ -12821,21 +12985,23 @@ function resetHooks() {
|
|
|
12821
12985
|
renderExpirationTime = NoWork;
|
|
12822
12986
|
currentlyRenderingFiber$1 = null;
|
|
12823
12987
|
|
|
12824
|
-
firstCurrentHook = null;
|
|
12825
12988
|
currentHook = null;
|
|
12826
12989
|
nextCurrentHook = null;
|
|
12827
12990
|
firstWorkInProgressHook = null;
|
|
12828
12991
|
workInProgressHook = null;
|
|
12829
12992
|
nextWorkInProgressHook = null;
|
|
12830
12993
|
|
|
12831
|
-
remainingExpirationTime = NoWork;
|
|
12832
|
-
componentUpdateQueue = null;
|
|
12833
|
-
sideEffectTag = 0;
|
|
12834
|
-
|
|
12835
12994
|
{
|
|
12995
|
+
hookTypesDev = null;
|
|
12996
|
+
hookTypesUpdateIndexDev = -1;
|
|
12997
|
+
|
|
12836
12998
|
currentHookNameInDev = null;
|
|
12837
12999
|
}
|
|
12838
13000
|
|
|
13001
|
+
remainingExpirationTime = NoWork;
|
|
13002
|
+
componentUpdateQueue = null;
|
|
13003
|
+
sideEffectTag = 0;
|
|
13004
|
+
|
|
12839
13005
|
didScheduleRenderPhaseUpdate = false;
|
|
12840
13006
|
renderPhaseUpdates = null;
|
|
12841
13007
|
numberOfReRenders = 0;
|
|
@@ -12852,12 +13018,6 @@ function mountWorkInProgressHook() {
|
|
|
12852
13018
|
next: null
|
|
12853
13019
|
};
|
|
12854
13020
|
|
|
12855
|
-
{
|
|
12856
|
-
hook._debugType = currentHookNameInDev;
|
|
12857
|
-
if (currentlyRenderingFiber$1 !== null && currentlyRenderingFiber$1.alternate !== null) {
|
|
12858
|
-
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));
|
|
12859
|
-
}
|
|
12860
|
-
}
|
|
12861
13021
|
if (workInProgressHook === null) {
|
|
12862
13022
|
// This is the first hook in the list
|
|
12863
13023
|
firstWorkInProgressHook = workInProgressHook = hook;
|
|
@@ -12904,13 +13064,6 @@ function updateWorkInProgressHook() {
|
|
|
12904
13064
|
workInProgressHook = workInProgressHook.next = newHook;
|
|
12905
13065
|
}
|
|
12906
13066
|
nextCurrentHook = currentHook.next;
|
|
12907
|
-
|
|
12908
|
-
{
|
|
12909
|
-
newHook._debugType = currentHookNameInDev;
|
|
12910
|
-
if (currentHookNameInDev !== currentHook._debugType) {
|
|
12911
|
-
warnOnHookMismatchInDev();
|
|
12912
|
-
}
|
|
12913
|
-
}
|
|
12914
13067
|
}
|
|
12915
13068
|
return workInProgressHook;
|
|
12916
13069
|
}
|
|
@@ -12925,20 +13078,6 @@ function basicStateReducer(state, action) {
|
|
|
12925
13078
|
return typeof action === 'function' ? action(state) : action;
|
|
12926
13079
|
}
|
|
12927
13080
|
|
|
12928
|
-
function mountContext(context, observedBits) {
|
|
12929
|
-
{
|
|
12930
|
-
mountWorkInProgressHook();
|
|
12931
|
-
}
|
|
12932
|
-
return readContext(context, observedBits);
|
|
12933
|
-
}
|
|
12934
|
-
|
|
12935
|
-
function updateContext(context, observedBits) {
|
|
12936
|
-
{
|
|
12937
|
-
updateWorkInProgressHook();
|
|
12938
|
-
}
|
|
12939
|
-
return readContext(context, observedBits);
|
|
12940
|
-
}
|
|
12941
|
-
|
|
12942
13081
|
function mountReducer(reducer, initialArg, init) {
|
|
12943
13082
|
var hook = mountWorkInProgressHook();
|
|
12944
13083
|
var initialState = void 0;
|
|
@@ -12991,7 +13130,6 @@ function updateReducer(reducer, initialArg, init) {
|
|
|
12991
13130
|
}
|
|
12992
13131
|
|
|
12993
13132
|
hook.memoizedState = newState;
|
|
12994
|
-
|
|
12995
13133
|
// Don't persist the state accumlated from the render phase updates to
|
|
12996
13134
|
// the base state unless the queue is empty.
|
|
12997
13135
|
// TODO: Not sure if this is the desired semantics, but it's what we
|
|
@@ -13000,6 +13138,9 @@ function updateReducer(reducer, initialArg, init) {
|
|
|
13000
13138
|
hook.baseState = newState;
|
|
13001
13139
|
}
|
|
13002
13140
|
|
|
13141
|
+
queue.eagerReducer = reducer;
|
|
13142
|
+
queue.eagerState = newState;
|
|
13143
|
+
|
|
13003
13144
|
return [newState, _dispatch];
|
|
13004
13145
|
}
|
|
13005
13146
|
}
|
|
@@ -13219,7 +13360,7 @@ function mountImperativeHandle(ref, create, deps) {
|
|
|
13219
13360
|
}
|
|
13220
13361
|
|
|
13221
13362
|
// TODO: If deps are provided, should we skip comparing the ref itself?
|
|
13222
|
-
var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) :
|
|
13363
|
+
var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
|
13223
13364
|
|
|
13224
13365
|
return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
|
13225
13366
|
}
|
|
@@ -13230,7 +13371,7 @@ function updateImperativeHandle(ref, create, deps) {
|
|
|
13230
13371
|
}
|
|
13231
13372
|
|
|
13232
13373
|
// TODO: If deps are provided, should we skip comparing the ref itself?
|
|
13233
|
-
var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) :
|
|
13374
|
+
var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
|
13234
13375
|
|
|
13235
13376
|
return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
|
13236
13377
|
}
|
|
@@ -13297,7 +13438,7 @@ function updateMemo(nextCreate, deps) {
|
|
|
13297
13438
|
var shouldWarnForUnbatchedSetState = false;
|
|
13298
13439
|
|
|
13299
13440
|
{
|
|
13300
|
-
// jest
|
|
13441
|
+
// jest isn't a 'global', it's just exposed to tests via a wrapped function
|
|
13301
13442
|
// further, this isn't a test file, so flow doesn't recognize the symbol. So...
|
|
13302
13443
|
// $FlowExpectedError - because requirements don't give a damn about your type sigs.
|
|
13303
13444
|
if ('undefined' !== typeof jest) {
|
|
@@ -13429,6 +13570,7 @@ var ContextOnlyDispatcher = {
|
|
|
13429
13570
|
};
|
|
13430
13571
|
|
|
13431
13572
|
var HooksDispatcherOnMountInDEV = null;
|
|
13573
|
+
var HooksDispatcherOnMountWithHookTypesInDEV = null;
|
|
13432
13574
|
var HooksDispatcherOnUpdateInDEV = null;
|
|
13433
13575
|
var InvalidNestedHooksDispatcherOnMountInDEV = null;
|
|
13434
13576
|
var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
@@ -13448,26 +13590,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13448
13590
|
},
|
|
13449
13591
|
useCallback: function (callback, deps) {
|
|
13450
13592
|
currentHookNameInDev = 'useCallback';
|
|
13593
|
+
mountHookTypesDev();
|
|
13451
13594
|
return mountCallback(callback, deps);
|
|
13452
13595
|
},
|
|
13453
13596
|
useContext: function (context, observedBits) {
|
|
13454
13597
|
currentHookNameInDev = 'useContext';
|
|
13455
|
-
|
|
13598
|
+
mountHookTypesDev();
|
|
13599
|
+
return readContext(context, observedBits);
|
|
13456
13600
|
},
|
|
13457
13601
|
useEffect: function (create, deps) {
|
|
13458
13602
|
currentHookNameInDev = 'useEffect';
|
|
13603
|
+
mountHookTypesDev();
|
|
13459
13604
|
return mountEffect(create, deps);
|
|
13460
13605
|
},
|
|
13461
13606
|
useImperativeHandle: function (ref, create, deps) {
|
|
13462
13607
|
currentHookNameInDev = 'useImperativeHandle';
|
|
13608
|
+
mountHookTypesDev();
|
|
13463
13609
|
return mountImperativeHandle(ref, create, deps);
|
|
13464
13610
|
},
|
|
13465
13611
|
useLayoutEffect: function (create, deps) {
|
|
13466
13612
|
currentHookNameInDev = 'useLayoutEffect';
|
|
13613
|
+
mountHookTypesDev();
|
|
13467
13614
|
return mountLayoutEffect(create, deps);
|
|
13468
13615
|
},
|
|
13469
13616
|
useMemo: function (create, deps) {
|
|
13470
13617
|
currentHookNameInDev = 'useMemo';
|
|
13618
|
+
mountHookTypesDev();
|
|
13471
13619
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13472
13620
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13473
13621
|
try {
|
|
@@ -13478,6 +13626,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13478
13626
|
},
|
|
13479
13627
|
useReducer: function (reducer, initialArg, init) {
|
|
13480
13628
|
currentHookNameInDev = 'useReducer';
|
|
13629
|
+
mountHookTypesDev();
|
|
13481
13630
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13482
13631
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13483
13632
|
try {
|
|
@@ -13488,10 +13637,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13488
13637
|
},
|
|
13489
13638
|
useRef: function (initialValue) {
|
|
13490
13639
|
currentHookNameInDev = 'useRef';
|
|
13640
|
+
mountHookTypesDev();
|
|
13491
13641
|
return mountRef(initialValue);
|
|
13492
13642
|
},
|
|
13493
13643
|
useState: function (initialState) {
|
|
13494
13644
|
currentHookNameInDev = 'useState';
|
|
13645
|
+
mountHookTypesDev();
|
|
13495
13646
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13496
13647
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13497
13648
|
try {
|
|
@@ -13502,6 +13653,81 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13502
13653
|
},
|
|
13503
13654
|
useDebugValue: function (value, formatterFn) {
|
|
13504
13655
|
currentHookNameInDev = 'useDebugValue';
|
|
13656
|
+
mountHookTypesDev();
|
|
13657
|
+
return mountDebugValue(value, formatterFn);
|
|
13658
|
+
}
|
|
13659
|
+
};
|
|
13660
|
+
|
|
13661
|
+
HooksDispatcherOnMountWithHookTypesInDEV = {
|
|
13662
|
+
readContext: function (context, observedBits) {
|
|
13663
|
+
return readContext(context, observedBits);
|
|
13664
|
+
},
|
|
13665
|
+
useCallback: function (callback, deps) {
|
|
13666
|
+
currentHookNameInDev = 'useCallback';
|
|
13667
|
+
updateHookTypesDev();
|
|
13668
|
+
return mountCallback(callback, deps);
|
|
13669
|
+
},
|
|
13670
|
+
useContext: function (context, observedBits) {
|
|
13671
|
+
currentHookNameInDev = 'useContext';
|
|
13672
|
+
updateHookTypesDev();
|
|
13673
|
+
return readContext(context, observedBits);
|
|
13674
|
+
},
|
|
13675
|
+
useEffect: function (create, deps) {
|
|
13676
|
+
currentHookNameInDev = 'useEffect';
|
|
13677
|
+
updateHookTypesDev();
|
|
13678
|
+
return mountEffect(create, deps);
|
|
13679
|
+
},
|
|
13680
|
+
useImperativeHandle: function (ref, create, deps) {
|
|
13681
|
+
currentHookNameInDev = 'useImperativeHandle';
|
|
13682
|
+
updateHookTypesDev();
|
|
13683
|
+
return mountImperativeHandle(ref, create, deps);
|
|
13684
|
+
},
|
|
13685
|
+
useLayoutEffect: function (create, deps) {
|
|
13686
|
+
currentHookNameInDev = 'useLayoutEffect';
|
|
13687
|
+
updateHookTypesDev();
|
|
13688
|
+
return mountLayoutEffect(create, deps);
|
|
13689
|
+
},
|
|
13690
|
+
useMemo: function (create, deps) {
|
|
13691
|
+
currentHookNameInDev = 'useMemo';
|
|
13692
|
+
updateHookTypesDev();
|
|
13693
|
+
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13694
|
+
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13695
|
+
try {
|
|
13696
|
+
return mountMemo(create, deps);
|
|
13697
|
+
} finally {
|
|
13698
|
+
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
13699
|
+
}
|
|
13700
|
+
},
|
|
13701
|
+
useReducer: function (reducer, initialArg, init) {
|
|
13702
|
+
currentHookNameInDev = 'useReducer';
|
|
13703
|
+
updateHookTypesDev();
|
|
13704
|
+
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13705
|
+
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13706
|
+
try {
|
|
13707
|
+
return mountReducer(reducer, initialArg, init);
|
|
13708
|
+
} finally {
|
|
13709
|
+
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
13710
|
+
}
|
|
13711
|
+
},
|
|
13712
|
+
useRef: function (initialValue) {
|
|
13713
|
+
currentHookNameInDev = 'useRef';
|
|
13714
|
+
updateHookTypesDev();
|
|
13715
|
+
return mountRef(initialValue);
|
|
13716
|
+
},
|
|
13717
|
+
useState: function (initialState) {
|
|
13718
|
+
currentHookNameInDev = 'useState';
|
|
13719
|
+
updateHookTypesDev();
|
|
13720
|
+
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13721
|
+
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13722
|
+
try {
|
|
13723
|
+
return mountState(initialState);
|
|
13724
|
+
} finally {
|
|
13725
|
+
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
13726
|
+
}
|
|
13727
|
+
},
|
|
13728
|
+
useDebugValue: function (value, formatterFn) {
|
|
13729
|
+
currentHookNameInDev = 'useDebugValue';
|
|
13730
|
+
updateHookTypesDev();
|
|
13505
13731
|
return mountDebugValue(value, formatterFn);
|
|
13506
13732
|
}
|
|
13507
13733
|
};
|
|
@@ -13512,26 +13738,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13512
13738
|
},
|
|
13513
13739
|
useCallback: function (callback, deps) {
|
|
13514
13740
|
currentHookNameInDev = 'useCallback';
|
|
13741
|
+
updateHookTypesDev();
|
|
13515
13742
|
return updateCallback(callback, deps);
|
|
13516
13743
|
},
|
|
13517
13744
|
useContext: function (context, observedBits) {
|
|
13518
13745
|
currentHookNameInDev = 'useContext';
|
|
13519
|
-
|
|
13746
|
+
updateHookTypesDev();
|
|
13747
|
+
return readContext(context, observedBits);
|
|
13520
13748
|
},
|
|
13521
13749
|
useEffect: function (create, deps) {
|
|
13522
13750
|
currentHookNameInDev = 'useEffect';
|
|
13751
|
+
updateHookTypesDev();
|
|
13523
13752
|
return updateEffect(create, deps);
|
|
13524
13753
|
},
|
|
13525
13754
|
useImperativeHandle: function (ref, create, deps) {
|
|
13526
13755
|
currentHookNameInDev = 'useImperativeHandle';
|
|
13756
|
+
updateHookTypesDev();
|
|
13527
13757
|
return updateImperativeHandle(ref, create, deps);
|
|
13528
13758
|
},
|
|
13529
13759
|
useLayoutEffect: function (create, deps) {
|
|
13530
13760
|
currentHookNameInDev = 'useLayoutEffect';
|
|
13761
|
+
updateHookTypesDev();
|
|
13531
13762
|
return updateLayoutEffect(create, deps);
|
|
13532
13763
|
},
|
|
13533
13764
|
useMemo: function (create, deps) {
|
|
13534
13765
|
currentHookNameInDev = 'useMemo';
|
|
13766
|
+
updateHookTypesDev();
|
|
13535
13767
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13536
13768
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
13537
13769
|
try {
|
|
@@ -13542,6 +13774,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13542
13774
|
},
|
|
13543
13775
|
useReducer: function (reducer, initialArg, init) {
|
|
13544
13776
|
currentHookNameInDev = 'useReducer';
|
|
13777
|
+
updateHookTypesDev();
|
|
13545
13778
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13546
13779
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
13547
13780
|
try {
|
|
@@ -13552,10 +13785,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13552
13785
|
},
|
|
13553
13786
|
useRef: function (initialValue) {
|
|
13554
13787
|
currentHookNameInDev = 'useRef';
|
|
13788
|
+
updateHookTypesDev();
|
|
13555
13789
|
return updateRef(initialValue);
|
|
13556
13790
|
},
|
|
13557
13791
|
useState: function (initialState) {
|
|
13558
13792
|
currentHookNameInDev = 'useState';
|
|
13793
|
+
updateHookTypesDev();
|
|
13559
13794
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13560
13795
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
13561
13796
|
try {
|
|
@@ -13566,6 +13801,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13566
13801
|
},
|
|
13567
13802
|
useDebugValue: function (value, formatterFn) {
|
|
13568
13803
|
currentHookNameInDev = 'useDebugValue';
|
|
13804
|
+
updateHookTypesDev();
|
|
13569
13805
|
return updateDebugValue(value, formatterFn);
|
|
13570
13806
|
}
|
|
13571
13807
|
};
|
|
@@ -13578,31 +13814,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13578
13814
|
useCallback: function (callback, deps) {
|
|
13579
13815
|
currentHookNameInDev = 'useCallback';
|
|
13580
13816
|
warnInvalidHookAccess();
|
|
13817
|
+
mountHookTypesDev();
|
|
13581
13818
|
return mountCallback(callback, deps);
|
|
13582
13819
|
},
|
|
13583
13820
|
useContext: function (context, observedBits) {
|
|
13584
13821
|
currentHookNameInDev = 'useContext';
|
|
13585
13822
|
warnInvalidHookAccess();
|
|
13586
|
-
|
|
13823
|
+
mountHookTypesDev();
|
|
13824
|
+
return readContext(context, observedBits);
|
|
13587
13825
|
},
|
|
13588
13826
|
useEffect: function (create, deps) {
|
|
13589
13827
|
currentHookNameInDev = 'useEffect';
|
|
13590
13828
|
warnInvalidHookAccess();
|
|
13829
|
+
mountHookTypesDev();
|
|
13591
13830
|
return mountEffect(create, deps);
|
|
13592
13831
|
},
|
|
13593
13832
|
useImperativeHandle: function (ref, create, deps) {
|
|
13594
13833
|
currentHookNameInDev = 'useImperativeHandle';
|
|
13595
13834
|
warnInvalidHookAccess();
|
|
13835
|
+
mountHookTypesDev();
|
|
13596
13836
|
return mountImperativeHandle(ref, create, deps);
|
|
13597
13837
|
},
|
|
13598
13838
|
useLayoutEffect: function (create, deps) {
|
|
13599
13839
|
currentHookNameInDev = 'useLayoutEffect';
|
|
13600
13840
|
warnInvalidHookAccess();
|
|
13841
|
+
mountHookTypesDev();
|
|
13601
13842
|
return mountLayoutEffect(create, deps);
|
|
13602
13843
|
},
|
|
13603
13844
|
useMemo: function (create, deps) {
|
|
13604
13845
|
currentHookNameInDev = 'useMemo';
|
|
13605
13846
|
warnInvalidHookAccess();
|
|
13847
|
+
mountHookTypesDev();
|
|
13606
13848
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13607
13849
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13608
13850
|
try {
|
|
@@ -13614,6 +13856,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13614
13856
|
useReducer: function (reducer, initialArg, init) {
|
|
13615
13857
|
currentHookNameInDev = 'useReducer';
|
|
13616
13858
|
warnInvalidHookAccess();
|
|
13859
|
+
mountHookTypesDev();
|
|
13617
13860
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13618
13861
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13619
13862
|
try {
|
|
@@ -13625,11 +13868,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13625
13868
|
useRef: function (initialValue) {
|
|
13626
13869
|
currentHookNameInDev = 'useRef';
|
|
13627
13870
|
warnInvalidHookAccess();
|
|
13871
|
+
mountHookTypesDev();
|
|
13628
13872
|
return mountRef(initialValue);
|
|
13629
13873
|
},
|
|
13630
13874
|
useState: function (initialState) {
|
|
13631
13875
|
currentHookNameInDev = 'useState';
|
|
13632
13876
|
warnInvalidHookAccess();
|
|
13877
|
+
mountHookTypesDev();
|
|
13633
13878
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13634
13879
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
13635
13880
|
try {
|
|
@@ -13641,6 +13886,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13641
13886
|
useDebugValue: function (value, formatterFn) {
|
|
13642
13887
|
currentHookNameInDev = 'useDebugValue';
|
|
13643
13888
|
warnInvalidHookAccess();
|
|
13889
|
+
mountHookTypesDev();
|
|
13644
13890
|
return mountDebugValue(value, formatterFn);
|
|
13645
13891
|
}
|
|
13646
13892
|
};
|
|
@@ -13653,31 +13899,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13653
13899
|
useCallback: function (callback, deps) {
|
|
13654
13900
|
currentHookNameInDev = 'useCallback';
|
|
13655
13901
|
warnInvalidHookAccess();
|
|
13902
|
+
updateHookTypesDev();
|
|
13656
13903
|
return updateCallback(callback, deps);
|
|
13657
13904
|
},
|
|
13658
13905
|
useContext: function (context, observedBits) {
|
|
13659
13906
|
currentHookNameInDev = 'useContext';
|
|
13660
13907
|
warnInvalidHookAccess();
|
|
13661
|
-
|
|
13908
|
+
updateHookTypesDev();
|
|
13909
|
+
return readContext(context, observedBits);
|
|
13662
13910
|
},
|
|
13663
13911
|
useEffect: function (create, deps) {
|
|
13664
13912
|
currentHookNameInDev = 'useEffect';
|
|
13665
13913
|
warnInvalidHookAccess();
|
|
13914
|
+
updateHookTypesDev();
|
|
13666
13915
|
return updateEffect(create, deps);
|
|
13667
13916
|
},
|
|
13668
13917
|
useImperativeHandle: function (ref, create, deps) {
|
|
13669
13918
|
currentHookNameInDev = 'useImperativeHandle';
|
|
13670
13919
|
warnInvalidHookAccess();
|
|
13920
|
+
updateHookTypesDev();
|
|
13671
13921
|
return updateImperativeHandle(ref, create, deps);
|
|
13672
13922
|
},
|
|
13673
13923
|
useLayoutEffect: function (create, deps) {
|
|
13674
13924
|
currentHookNameInDev = 'useLayoutEffect';
|
|
13675
13925
|
warnInvalidHookAccess();
|
|
13926
|
+
updateHookTypesDev();
|
|
13676
13927
|
return updateLayoutEffect(create, deps);
|
|
13677
13928
|
},
|
|
13678
13929
|
useMemo: function (create, deps) {
|
|
13679
13930
|
currentHookNameInDev = 'useMemo';
|
|
13680
13931
|
warnInvalidHookAccess();
|
|
13932
|
+
updateHookTypesDev();
|
|
13681
13933
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13682
13934
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
13683
13935
|
try {
|
|
@@ -13689,6 +13941,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13689
13941
|
useReducer: function (reducer, initialArg, init) {
|
|
13690
13942
|
currentHookNameInDev = 'useReducer';
|
|
13691
13943
|
warnInvalidHookAccess();
|
|
13944
|
+
updateHookTypesDev();
|
|
13692
13945
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13693
13946
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
13694
13947
|
try {
|
|
@@ -13700,11 +13953,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13700
13953
|
useRef: function (initialValue) {
|
|
13701
13954
|
currentHookNameInDev = 'useRef';
|
|
13702
13955
|
warnInvalidHookAccess();
|
|
13956
|
+
updateHookTypesDev();
|
|
13703
13957
|
return updateRef(initialValue);
|
|
13704
13958
|
},
|
|
13705
13959
|
useState: function (initialState) {
|
|
13706
13960
|
currentHookNameInDev = 'useState';
|
|
13707
13961
|
warnInvalidHookAccess();
|
|
13962
|
+
updateHookTypesDev();
|
|
13708
13963
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
13709
13964
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
13710
13965
|
try {
|
|
@@ -13716,6 +13971,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
|
13716
13971
|
useDebugValue: function (value, formatterFn) {
|
|
13717
13972
|
currentHookNameInDev = 'useDebugValue';
|
|
13718
13973
|
warnInvalidHookAccess();
|
|
13974
|
+
updateHookTypesDev();
|
|
13719
13975
|
return updateDebugValue(value, formatterFn);
|
|
13720
13976
|
}
|
|
13721
13977
|
};
|
|
@@ -13787,6 +14043,18 @@ function enterHydrationState(fiber) {
|
|
|
13787
14043
|
return true;
|
|
13788
14044
|
}
|
|
13789
14045
|
|
|
14046
|
+
function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
|
|
14047
|
+
if (!supportsHydration) {
|
|
14048
|
+
return false;
|
|
14049
|
+
}
|
|
14050
|
+
|
|
14051
|
+
var suspenseInstance = fiber.stateNode;
|
|
14052
|
+
nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
|
|
14053
|
+
popToNextHostParent(fiber);
|
|
14054
|
+
isHydrating = true;
|
|
14055
|
+
return true;
|
|
14056
|
+
}
|
|
14057
|
+
|
|
13790
14058
|
function deleteHydratableInstance(returnFiber, instance) {
|
|
13791
14059
|
{
|
|
13792
14060
|
switch (returnFiber.tag) {
|
|
@@ -13833,6 +14101,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
|
|
|
13833
14101
|
case HostText:
|
|
13834
14102
|
var text = fiber.pendingProps;
|
|
13835
14103
|
didNotFindHydratableContainerTextInstance(parentContainer, text);
|
|
14104
|
+
break;
|
|
14105
|
+
case SuspenseComponent:
|
|
14106
|
+
|
|
13836
14107
|
break;
|
|
13837
14108
|
}
|
|
13838
14109
|
break;
|
|
@@ -13852,6 +14123,9 @@ function insertNonHydratedInstance(returnFiber, fiber) {
|
|
|
13852
14123
|
var _text = fiber.pendingProps;
|
|
13853
14124
|
didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
|
|
13854
14125
|
break;
|
|
14126
|
+
case SuspenseComponent:
|
|
14127
|
+
didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
|
|
14128
|
+
break;
|
|
13855
14129
|
}
|
|
13856
14130
|
break;
|
|
13857
14131
|
}
|
|
@@ -13884,6 +14158,19 @@ function tryHydrate(fiber, nextInstance) {
|
|
|
13884
14158
|
}
|
|
13885
14159
|
return false;
|
|
13886
14160
|
}
|
|
14161
|
+
case SuspenseComponent:
|
|
14162
|
+
{
|
|
14163
|
+
if (enableSuspenseServerRenderer) {
|
|
14164
|
+
var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
|
|
14165
|
+
if (suspenseInstance !== null) {
|
|
14166
|
+
// Downgrade the tag to a dehydrated component until we've hydrated it.
|
|
14167
|
+
fiber.tag = DehydratedSuspenseComponent;
|
|
14168
|
+
fiber.stateNode = suspenseInstance;
|
|
14169
|
+
return true;
|
|
14170
|
+
}
|
|
14171
|
+
}
|
|
14172
|
+
return false;
|
|
14173
|
+
}
|
|
13887
14174
|
default:
|
|
13888
14175
|
return false;
|
|
13889
14176
|
}
|
|
@@ -13977,9 +14264,18 @@ function prepareToHydrateHostTextInstance(fiber) {
|
|
|
13977
14264
|
return shouldUpdate;
|
|
13978
14265
|
}
|
|
13979
14266
|
|
|
14267
|
+
function skipPastDehydratedSuspenseInstance(fiber) {
|
|
14268
|
+
if (!supportsHydration) {
|
|
14269
|
+
invariant(false, 'Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
|
|
14270
|
+
}
|
|
14271
|
+
var suspenseInstance = fiber.stateNode;
|
|
14272
|
+
!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;
|
|
14273
|
+
nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
|
|
14274
|
+
}
|
|
14275
|
+
|
|
13980
14276
|
function popToNextHostParent(fiber) {
|
|
13981
14277
|
var parent = fiber.return;
|
|
13982
|
-
while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
|
|
14278
|
+
while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
|
|
13983
14279
|
parent = parent.return;
|
|
13984
14280
|
}
|
|
13985
14281
|
hydrationParentFiber = parent;
|
|
@@ -14087,6 +14383,10 @@ function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildre
|
|
|
14087
14383
|
}
|
|
14088
14384
|
|
|
14089
14385
|
function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
|
|
14386
|
+
// TODO: current can be non-null here even if the component
|
|
14387
|
+
// hasn't yet mounted. This happens after the first render suspends.
|
|
14388
|
+
// We'll need to figure out if this is fine or can cause issues.
|
|
14389
|
+
|
|
14090
14390
|
{
|
|
14091
14391
|
if (workInProgress.type !== workInProgress.elementType) {
|
|
14092
14392
|
// Lazy component props can't be validated in createElement
|
|
@@ -14192,6 +14492,10 @@ function updateMemoComponent(current$$1, workInProgress, Component, nextProps, u
|
|
|
14192
14492
|
}
|
|
14193
14493
|
|
|
14194
14494
|
function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
|
|
14495
|
+
// TODO: current can be non-null here even if the component
|
|
14496
|
+
// hasn't yet mounted. This happens when the inner render suspends.
|
|
14497
|
+
// We'll need to figure out if this is fine or can cause issues.
|
|
14498
|
+
|
|
14195
14499
|
{
|
|
14196
14500
|
if (workInProgress.type !== workInProgress.elementType) {
|
|
14197
14501
|
// Lazy component props can't be validated in createElement
|
|
@@ -14815,6 +15119,18 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
|
|
|
14815
15119
|
// children -- we skip over the primary children entirely.
|
|
14816
15120
|
var next = void 0;
|
|
14817
15121
|
if (current$$1 === null) {
|
|
15122
|
+
if (enableSuspenseServerRenderer) {
|
|
15123
|
+
// If we're currently hydrating, try to hydrate this boundary.
|
|
15124
|
+
// But only if this has a fallback.
|
|
15125
|
+
if (nextProps.fallback !== undefined) {
|
|
15126
|
+
tryToClaimNextHydratableInstance(workInProgress);
|
|
15127
|
+
// This could've changed the tag if this was a dehydrated suspense component.
|
|
15128
|
+
if (workInProgress.tag === DehydratedSuspenseComponent) {
|
|
15129
|
+
return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
|
|
15130
|
+
}
|
|
15131
|
+
}
|
|
15132
|
+
}
|
|
15133
|
+
|
|
14818
15134
|
// This is the initial mount. This branch is pretty simple because there's
|
|
14819
15135
|
// no previous state that needs to be preserved.
|
|
14820
15136
|
if (nextDidTimeout) {
|
|
@@ -14966,6 +15282,65 @@ function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTim
|
|
|
14966
15282
|
return next;
|
|
14967
15283
|
}
|
|
14968
15284
|
|
|
15285
|
+
function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
|
|
15286
|
+
if (current$$1 === null) {
|
|
15287
|
+
// During the first pass, we'll bail out and not drill into the children.
|
|
15288
|
+
// Instead, we'll leave the content in place and try to hydrate it later.
|
|
15289
|
+
workInProgress.expirationTime = Never;
|
|
15290
|
+
return null;
|
|
15291
|
+
}
|
|
15292
|
+
// We use childExpirationTime to indicate that a child might depend on context, so if
|
|
15293
|
+
// any context has changed, we need to treat is as if the input might have changed.
|
|
15294
|
+
var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
|
|
15295
|
+
if (didReceiveUpdate || hasContextChanged$$1) {
|
|
15296
|
+
// This boundary has changed since the first render. This means that we are now unable to
|
|
15297
|
+
// hydrate it. We might still be able to hydrate it using an earlier expiration time but
|
|
15298
|
+
// during this render we can't. Instead, we're going to delete the whole subtree and
|
|
15299
|
+
// instead inject a new real Suspense boundary to take its place, which may render content
|
|
15300
|
+
// or fallback. The real Suspense boundary will suspend for a while so we have some time
|
|
15301
|
+
// to ensure it can produce real content, but all state and pending events will be lost.
|
|
15302
|
+
|
|
15303
|
+
// Detach from the current dehydrated boundary.
|
|
15304
|
+
current$$1.alternate = null;
|
|
15305
|
+
workInProgress.alternate = null;
|
|
15306
|
+
|
|
15307
|
+
// Insert a deletion in the effect list.
|
|
15308
|
+
var returnFiber = workInProgress.return;
|
|
15309
|
+
!(returnFiber !== null) ? invariant(false, 'Suspense boundaries are never on the root. This is probably a bug in React.') : void 0;
|
|
15310
|
+
var last = returnFiber.lastEffect;
|
|
15311
|
+
if (last !== null) {
|
|
15312
|
+
last.nextEffect = current$$1;
|
|
15313
|
+
returnFiber.lastEffect = current$$1;
|
|
15314
|
+
} else {
|
|
15315
|
+
returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
|
|
15316
|
+
}
|
|
15317
|
+
current$$1.nextEffect = null;
|
|
15318
|
+
current$$1.effectTag = Deletion;
|
|
15319
|
+
|
|
15320
|
+
// Upgrade this work in progress to a real Suspense component.
|
|
15321
|
+
workInProgress.tag = SuspenseComponent;
|
|
15322
|
+
workInProgress.stateNode = null;
|
|
15323
|
+
workInProgress.memoizedState = null;
|
|
15324
|
+
// This is now an insertion.
|
|
15325
|
+
workInProgress.effectTag |= Placement;
|
|
15326
|
+
// Retry as a real Suspense component.
|
|
15327
|
+
return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
|
|
15328
|
+
}
|
|
15329
|
+
if ((workInProgress.effectTag & DidCapture) === NoEffect) {
|
|
15330
|
+
// This is the first attempt.
|
|
15331
|
+
reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
|
|
15332
|
+
var nextProps = workInProgress.pendingProps;
|
|
15333
|
+
var nextChildren = nextProps.children;
|
|
15334
|
+
workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
|
15335
|
+
return workInProgress.child;
|
|
15336
|
+
} else {
|
|
15337
|
+
// Something suspended. Leave the existing children in place.
|
|
15338
|
+
// TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
|
|
15339
|
+
workInProgress.child = null;
|
|
15340
|
+
return null;
|
|
15341
|
+
}
|
|
15342
|
+
}
|
|
15343
|
+
|
|
14969
15344
|
function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
|
|
14970
15345
|
pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
|
14971
15346
|
var nextChildren = workInProgress.pendingProps;
|
|
@@ -15177,6 +15552,16 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
|
|
|
15177
15552
|
}
|
|
15178
15553
|
break;
|
|
15179
15554
|
}
|
|
15555
|
+
case DehydratedSuspenseComponent:
|
|
15556
|
+
{
|
|
15557
|
+
if (enableSuspenseServerRenderer) {
|
|
15558
|
+
// We know that this component will suspend again because if it has
|
|
15559
|
+
// been unsuspended it has committed as a regular Suspense component.
|
|
15560
|
+
// If it needs to be retried, it should have work scheduled on it.
|
|
15561
|
+
workInProgress.effectTag |= DidCapture;
|
|
15562
|
+
break;
|
|
15563
|
+
}
|
|
15564
|
+
}
|
|
15180
15565
|
}
|
|
15181
15566
|
return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
|
|
15182
15567
|
}
|
|
@@ -15268,9 +15653,15 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) {
|
|
|
15268
15653
|
var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
|
|
15269
15654
|
return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
|
|
15270
15655
|
}
|
|
15271
|
-
|
|
15272
|
-
|
|
15656
|
+
case DehydratedSuspenseComponent:
|
|
15657
|
+
{
|
|
15658
|
+
if (enableSuspenseServerRenderer) {
|
|
15659
|
+
return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
|
|
15660
|
+
}
|
|
15661
|
+
break;
|
|
15662
|
+
}
|
|
15273
15663
|
}
|
|
15664
|
+
invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
|
|
15274
15665
|
}
|
|
15275
15666
|
|
|
15276
15667
|
var valueCursor = createCursor(null);
|
|
@@ -15359,6 +15750,28 @@ function calculateChangedBits(context, newValue, oldValue) {
|
|
|
15359
15750
|
}
|
|
15360
15751
|
}
|
|
15361
15752
|
|
|
15753
|
+
function scheduleWorkOnParentPath(parent, renderExpirationTime) {
|
|
15754
|
+
// Update the child expiration time of all the ancestors, including
|
|
15755
|
+
// the alternates.
|
|
15756
|
+
var node = parent;
|
|
15757
|
+
while (node !== null) {
|
|
15758
|
+
var alternate = node.alternate;
|
|
15759
|
+
if (node.childExpirationTime < renderExpirationTime) {
|
|
15760
|
+
node.childExpirationTime = renderExpirationTime;
|
|
15761
|
+
if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
|
15762
|
+
alternate.childExpirationTime = renderExpirationTime;
|
|
15763
|
+
}
|
|
15764
|
+
} else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
|
15765
|
+
alternate.childExpirationTime = renderExpirationTime;
|
|
15766
|
+
} else {
|
|
15767
|
+
// Neither alternate was updated, which means the rest of the
|
|
15768
|
+
// ancestor path already has sufficient priority.
|
|
15769
|
+
break;
|
|
15770
|
+
}
|
|
15771
|
+
node = node.return;
|
|
15772
|
+
}
|
|
15773
|
+
}
|
|
15774
|
+
|
|
15362
15775
|
function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
|
|
15363
15776
|
var fiber = workInProgress.child;
|
|
15364
15777
|
if (fiber !== null) {
|
|
@@ -15397,25 +15810,8 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
|
|
|
15397
15810
|
if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
|
|
15398
15811
|
alternate.expirationTime = renderExpirationTime;
|
|
15399
15812
|
}
|
|
15400
|
-
|
|
15401
|
-
|
|
15402
|
-
var node = fiber.return;
|
|
15403
|
-
while (node !== null) {
|
|
15404
|
-
alternate = node.alternate;
|
|
15405
|
-
if (node.childExpirationTime < renderExpirationTime) {
|
|
15406
|
-
node.childExpirationTime = renderExpirationTime;
|
|
15407
|
-
if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
|
15408
|
-
alternate.childExpirationTime = renderExpirationTime;
|
|
15409
|
-
}
|
|
15410
|
-
} else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
|
15411
|
-
alternate.childExpirationTime = renderExpirationTime;
|
|
15412
|
-
} else {
|
|
15413
|
-
// Neither alternate was updated, which means the rest of the
|
|
15414
|
-
// ancestor path already has sufficient priority.
|
|
15415
|
-
break;
|
|
15416
|
-
}
|
|
15417
|
-
node = node.return;
|
|
15418
|
-
}
|
|
15813
|
+
|
|
15814
|
+
scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
|
|
15419
15815
|
|
|
15420
15816
|
// Mark the expiration time on the list, too.
|
|
15421
15817
|
if (list.expirationTime < renderExpirationTime) {
|
|
@@ -15431,6 +15827,23 @@ function propagateContextChange(workInProgress, context, changedBits, renderExpi
|
|
|
15431
15827
|
} else if (fiber.tag === ContextProvider) {
|
|
15432
15828
|
// Don't scan deeper if this is a matching provider
|
|
15433
15829
|
nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
|
|
15830
|
+
} else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
|
|
15831
|
+
// If a dehydrated suspense component is in this subtree, we don't know
|
|
15832
|
+
// if it will have any context consumers in it. The best we can do is
|
|
15833
|
+
// mark it as having updates on its children.
|
|
15834
|
+
if (fiber.expirationTime < renderExpirationTime) {
|
|
15835
|
+
fiber.expirationTime = renderExpirationTime;
|
|
15836
|
+
}
|
|
15837
|
+
var _alternate = fiber.alternate;
|
|
15838
|
+
if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
|
|
15839
|
+
_alternate.expirationTime = renderExpirationTime;
|
|
15840
|
+
}
|
|
15841
|
+
// This is intentionally passing this fiber as the parent
|
|
15842
|
+
// because we want to schedule this fiber as having work
|
|
15843
|
+
// on its children. We'll use the childExpirationTime on
|
|
15844
|
+
// this fiber to indicate that a context has changed.
|
|
15845
|
+
scheduleWorkOnParentPath(fiber, renderExpirationTime);
|
|
15846
|
+
nextFiber = fiber.sibling;
|
|
15434
15847
|
} else {
|
|
15435
15848
|
// Traverse down.
|
|
15436
15849
|
nextFiber = fiber.child;
|
|
@@ -16554,6 +16967,26 @@ function completeWork(current, workInProgress, renderExpirationTime) {
|
|
|
16554
16967
|
}
|
|
16555
16968
|
break;
|
|
16556
16969
|
}
|
|
16970
|
+
case DehydratedSuspenseComponent:
|
|
16971
|
+
{
|
|
16972
|
+
if (enableSuspenseServerRenderer) {
|
|
16973
|
+
if (current === null) {
|
|
16974
|
+
var _wasHydrated2 = popHydrationState(workInProgress);
|
|
16975
|
+
!_wasHydrated2 ? invariant(false, 'A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.') : void 0;
|
|
16976
|
+
skipPastDehydratedSuspenseInstance(workInProgress);
|
|
16977
|
+
} else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
|
|
16978
|
+
// This boundary did not suspend so it's now hydrated.
|
|
16979
|
+
// To handle any future suspense cases, we're going to now upgrade it
|
|
16980
|
+
// to a Suspense component. We detach it from the existing current fiber.
|
|
16981
|
+
current.alternate = null;
|
|
16982
|
+
workInProgress.alternate = null;
|
|
16983
|
+
workInProgress.tag = SuspenseComponent;
|
|
16984
|
+
workInProgress.memoizedState = null;
|
|
16985
|
+
workInProgress.stateNode = null;
|
|
16986
|
+
}
|
|
16987
|
+
}
|
|
16988
|
+
break;
|
|
16989
|
+
}
|
|
16557
16990
|
default:
|
|
16558
16991
|
invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
|
|
16559
16992
|
}
|
|
@@ -16644,7 +17077,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
|
|
|
16644
17077
|
didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
|
|
16645
17078
|
}
|
|
16646
17079
|
|
|
16647
|
-
var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
|
|
17080
|
+
var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
|
|
16648
17081
|
|
|
16649
17082
|
function logError(boundary, errorInfo) {
|
|
16650
17083
|
var source = errorInfo.source;
|
|
@@ -16957,7 +17390,7 @@ function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpir
|
|
|
16957
17390
|
|
|
16958
17391
|
function hideOrUnhideAllChildren(finishedWork, isHidden) {
|
|
16959
17392
|
if (supportsMutation) {
|
|
16960
|
-
// We only have the top Fiber that was inserted but we need recurse down its
|
|
17393
|
+
// We only have the top Fiber that was inserted but we need to recurse down its
|
|
16961
17394
|
var node = finishedWork;
|
|
16962
17395
|
while (true) {
|
|
16963
17396
|
if (node.tag === HostComponent) {
|
|
@@ -17225,7 +17658,7 @@ function getHostSibling(fiber) {
|
|
|
17225
17658
|
}
|
|
17226
17659
|
node.sibling.return = node.return;
|
|
17227
17660
|
node = node.sibling;
|
|
17228
|
-
while (node.tag !== HostComponent && node.tag !== HostText) {
|
|
17661
|
+
while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
|
|
17229
17662
|
// If it is not host node and, we might have a host node inside it.
|
|
17230
17663
|
// Try to search down until we find one.
|
|
17231
17664
|
if (node.effectTag & Placement) {
|
|
@@ -17285,7 +17718,7 @@ function commitPlacement(finishedWork) {
|
|
|
17285
17718
|
}
|
|
17286
17719
|
|
|
17287
17720
|
var before = getHostSibling(finishedWork);
|
|
17288
|
-
// We only have the top Fiber that was inserted but we need recurse down its
|
|
17721
|
+
// We only have the top Fiber that was inserted but we need to recurse down its
|
|
17289
17722
|
// children to find all the terminal nodes.
|
|
17290
17723
|
var node = finishedWork;
|
|
17291
17724
|
while (true) {
|
|
@@ -17327,7 +17760,7 @@ function commitPlacement(finishedWork) {
|
|
|
17327
17760
|
}
|
|
17328
17761
|
|
|
17329
17762
|
function unmountHostComponents(current$$1) {
|
|
17330
|
-
// We only have the top Fiber that was deleted but we need recurse down its
|
|
17763
|
+
// We only have the top Fiber that was deleted but we need to recurse down its
|
|
17331
17764
|
var node = current$$1;
|
|
17332
17765
|
|
|
17333
17766
|
// Each iteration, currentParent is populated with node's host parent if not
|
|
@@ -17372,13 +17805,20 @@ function unmountHostComponents(current$$1) {
|
|
|
17372
17805
|
removeChild(currentParent, node.stateNode);
|
|
17373
17806
|
}
|
|
17374
17807
|
// Don't visit children because we already visited them.
|
|
17808
|
+
} else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
|
|
17809
|
+
// Delete the dehydrated suspense boundary and all of its content.
|
|
17810
|
+
if (currentParentIsContainer) {
|
|
17811
|
+
clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
|
|
17812
|
+
} else {
|
|
17813
|
+
clearSuspenseBoundary(currentParent, node.stateNode);
|
|
17814
|
+
}
|
|
17375
17815
|
} else if (node.tag === HostPortal) {
|
|
17376
|
-
// When we go into a portal, it becomes the parent to remove from.
|
|
17377
|
-
// We will reassign it back when we pop the portal on the way up.
|
|
17378
|
-
currentParent = node.stateNode.containerInfo;
|
|
17379
|
-
currentParentIsContainer = true;
|
|
17380
|
-
// Visit children because portals might contain host components.
|
|
17381
17816
|
if (node.child !== null) {
|
|
17817
|
+
// When we go into a portal, it becomes the parent to remove from.
|
|
17818
|
+
// We will reassign it back when we pop the portal on the way up.
|
|
17819
|
+
currentParent = node.stateNode.containerInfo;
|
|
17820
|
+
currentParentIsContainer = true;
|
|
17821
|
+
// Visit children because portals might contain host components.
|
|
17382
17822
|
node.child.return = node;
|
|
17383
17823
|
node = node.child;
|
|
17384
17824
|
continue;
|
|
@@ -17528,7 +17968,7 @@ function commitWork(current$$1, finishedWork) {
|
|
|
17528
17968
|
finishedWork.updateQueue = null;
|
|
17529
17969
|
var retryCache = finishedWork.stateNode;
|
|
17530
17970
|
if (retryCache === null) {
|
|
17531
|
-
retryCache = finishedWork.stateNode = new PossiblyWeakSet();
|
|
17971
|
+
retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
|
|
17532
17972
|
}
|
|
17533
17973
|
thenables.forEach(function (thenable) {
|
|
17534
17974
|
// Memoize using the boundary fiber to prevent redundant listeners.
|
|
@@ -17563,6 +18003,7 @@ function commitResetTextContent(current$$1) {
|
|
|
17563
18003
|
resetTextContent(current$$1.stateNode);
|
|
17564
18004
|
}
|
|
17565
18005
|
|
|
18006
|
+
var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
|
|
17566
18007
|
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
|
17567
18008
|
|
|
17568
18009
|
function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
|
|
@@ -17621,6 +18062,34 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
|
|
|
17621
18062
|
return update;
|
|
17622
18063
|
}
|
|
17623
18064
|
|
|
18065
|
+
function attachPingListener(root, renderExpirationTime, thenable) {
|
|
18066
|
+
// Attach a listener to the promise to "ping" the root and retry. But
|
|
18067
|
+
// only if one does not already exist for the current render expiration
|
|
18068
|
+
// time (which acts like a "thread ID" here).
|
|
18069
|
+
var pingCache = root.pingCache;
|
|
18070
|
+
var threadIDs = void 0;
|
|
18071
|
+
if (pingCache === null) {
|
|
18072
|
+
pingCache = root.pingCache = new PossiblyWeakMap();
|
|
18073
|
+
threadIDs = new Set();
|
|
18074
|
+
pingCache.set(thenable, threadIDs);
|
|
18075
|
+
} else {
|
|
18076
|
+
threadIDs = pingCache.get(thenable);
|
|
18077
|
+
if (threadIDs === undefined) {
|
|
18078
|
+
threadIDs = new Set();
|
|
18079
|
+
pingCache.set(thenable, threadIDs);
|
|
18080
|
+
}
|
|
18081
|
+
}
|
|
18082
|
+
if (!threadIDs.has(renderExpirationTime)) {
|
|
18083
|
+
// Memoize using the thread ID to prevent redundant listeners.
|
|
18084
|
+
threadIDs.add(renderExpirationTime);
|
|
18085
|
+
var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
|
|
18086
|
+
if (enableSchedulerTracing) {
|
|
18087
|
+
ping = tracing.unstable_wrap(ping);
|
|
18088
|
+
}
|
|
18089
|
+
thenable.then(ping, ping);
|
|
18090
|
+
}
|
|
18091
|
+
}
|
|
18092
|
+
|
|
17624
18093
|
function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
|
|
17625
18094
|
// The source fiber did not complete.
|
|
17626
18095
|
sourceFiber.effectTag |= Incomplete;
|
|
@@ -17662,6 +18131,9 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
|
|
|
17662
18131
|
}
|
|
17663
18132
|
}
|
|
17664
18133
|
}
|
|
18134
|
+
// If there is a DehydratedSuspenseComponent we don't have to do anything because
|
|
18135
|
+
// if something suspends inside it, we will simply leave that as dehydrated. It
|
|
18136
|
+
// will never timeout.
|
|
17665
18137
|
_workInProgress = _workInProgress.return;
|
|
17666
18138
|
} while (_workInProgress !== null);
|
|
17667
18139
|
|
|
@@ -17725,31 +18197,7 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
|
|
|
17725
18197
|
// Confirmed that the boundary is in a concurrent mode tree. Continue
|
|
17726
18198
|
// with the normal suspend path.
|
|
17727
18199
|
|
|
17728
|
-
|
|
17729
|
-
// only if one does not already exist for the current render expiration
|
|
17730
|
-
// time (which acts like a "thread ID" here).
|
|
17731
|
-
var pingCache = root.pingCache;
|
|
17732
|
-
var threadIDs = void 0;
|
|
17733
|
-
if (pingCache === null) {
|
|
17734
|
-
pingCache = root.pingCache = new PossiblyWeakMap();
|
|
17735
|
-
threadIDs = new Set();
|
|
17736
|
-
pingCache.set(thenable, threadIDs);
|
|
17737
|
-
} else {
|
|
17738
|
-
threadIDs = pingCache.get(thenable);
|
|
17739
|
-
if (threadIDs === undefined) {
|
|
17740
|
-
threadIDs = new Set();
|
|
17741
|
-
pingCache.set(thenable, threadIDs);
|
|
17742
|
-
}
|
|
17743
|
-
}
|
|
17744
|
-
if (!threadIDs.has(renderExpirationTime)) {
|
|
17745
|
-
// Memoize using the thread ID to prevent redundant listeners.
|
|
17746
|
-
threadIDs.add(renderExpirationTime);
|
|
17747
|
-
var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
|
|
17748
|
-
if (enableSchedulerTracing) {
|
|
17749
|
-
ping = tracing.unstable_wrap(ping);
|
|
17750
|
-
}
|
|
17751
|
-
thenable.then(ping, ping);
|
|
17752
|
-
}
|
|
18200
|
+
attachPingListener(root, renderExpirationTime, thenable);
|
|
17753
18201
|
|
|
17754
18202
|
var absoluteTimeoutMs = void 0;
|
|
17755
18203
|
if (earliestTimeoutMs === -1) {
|
|
@@ -17781,6 +18229,29 @@ function throwException(root, returnFiber, sourceFiber, value, renderExpirationT
|
|
|
17781
18229
|
// whole tree.
|
|
17782
18230
|
renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
|
|
17783
18231
|
|
|
18232
|
+
_workInProgress.effectTag |= ShouldCapture;
|
|
18233
|
+
_workInProgress.expirationTime = renderExpirationTime;
|
|
18234
|
+
return;
|
|
18235
|
+
} else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
|
|
18236
|
+
attachPingListener(root, renderExpirationTime, thenable);
|
|
18237
|
+
|
|
18238
|
+
// Since we already have a current fiber, we can eagerly add a retry listener.
|
|
18239
|
+
var retryCache = _workInProgress.memoizedState;
|
|
18240
|
+
if (retryCache === null) {
|
|
18241
|
+
retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
|
|
18242
|
+
var _current = _workInProgress.alternate;
|
|
18243
|
+
!_current ? invariant(false, 'A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.') : void 0;
|
|
18244
|
+
_current.memoizedState = retryCache;
|
|
18245
|
+
}
|
|
18246
|
+
// Memoize using the boundary fiber to prevent redundant listeners.
|
|
18247
|
+
if (!retryCache.has(thenable)) {
|
|
18248
|
+
retryCache.add(thenable);
|
|
18249
|
+
var retry = retryTimedOutBoundary.bind(null, _workInProgress, thenable);
|
|
18250
|
+
if (enableSchedulerTracing) {
|
|
18251
|
+
retry = tracing.unstable_wrap(retry);
|
|
18252
|
+
}
|
|
18253
|
+
thenable.then(retry, retry);
|
|
18254
|
+
}
|
|
17784
18255
|
_workInProgress.effectTag |= ShouldCapture;
|
|
17785
18256
|
_workInProgress.expirationTime = renderExpirationTime;
|
|
17786
18257
|
return;
|
|
@@ -17858,6 +18329,7 @@ function unwindWork(workInProgress, renderExpirationTime) {
|
|
|
17858
18329
|
}
|
|
17859
18330
|
case HostComponent:
|
|
17860
18331
|
{
|
|
18332
|
+
// TODO: popHydrationState
|
|
17861
18333
|
popHostContext(workInProgress);
|
|
17862
18334
|
return null;
|
|
17863
18335
|
}
|
|
@@ -17871,6 +18343,19 @@ function unwindWork(workInProgress, renderExpirationTime) {
|
|
|
17871
18343
|
}
|
|
17872
18344
|
return null;
|
|
17873
18345
|
}
|
|
18346
|
+
case DehydratedSuspenseComponent:
|
|
18347
|
+
{
|
|
18348
|
+
if (enableSuspenseServerRenderer) {
|
|
18349
|
+
// TODO: popHydrationState
|
|
18350
|
+
var _effectTag3 = workInProgress.effectTag;
|
|
18351
|
+
if (_effectTag3 & ShouldCapture) {
|
|
18352
|
+
workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
|
|
18353
|
+
// Captured a suspense effect. Re-render the boundary.
|
|
18354
|
+
return workInProgress;
|
|
18355
|
+
}
|
|
18356
|
+
}
|
|
18357
|
+
return null;
|
|
18358
|
+
}
|
|
17874
18359
|
case HostPortal:
|
|
17875
18360
|
popHostContainer(workInProgress);
|
|
17876
18361
|
return null;
|
|
@@ -17968,11 +18453,6 @@ if (enableSchedulerTracing) {
|
|
|
17968
18453
|
// Used to ensure computeUniqueAsyncExpiration is monotonically decreasing.
|
|
17969
18454
|
var lastUniqueAsyncExpiration = Sync - 1;
|
|
17970
18455
|
|
|
17971
|
-
// Represents the expiration time that incoming updates should use. (If this
|
|
17972
|
-
// is NoWork, use the default strategy: async updates in async mode, sync
|
|
17973
|
-
// updates in sync mode.)
|
|
17974
|
-
var expirationContext = NoWork;
|
|
17975
|
-
|
|
17976
18456
|
var isWorking = false;
|
|
17977
18457
|
|
|
17978
18458
|
// The next work in progress fiber that we're currently working on.
|
|
@@ -18268,6 +18748,10 @@ function commitPassiveEffects(root, firstEffect) {
|
|
|
18268
18748
|
if (rootExpirationTime !== NoWork) {
|
|
18269
18749
|
requestWork(root, rootExpirationTime);
|
|
18270
18750
|
}
|
|
18751
|
+
// Flush any sync work that was scheduled by effects
|
|
18752
|
+
if (!isBatchingUpdates && !isRendering) {
|
|
18753
|
+
performSyncWork();
|
|
18754
|
+
}
|
|
18271
18755
|
}
|
|
18272
18756
|
|
|
18273
18757
|
function isAlreadyFailedLegacyErrorBoundary(instance) {
|
|
@@ -18442,7 +18926,9 @@ function commitRoot(root, finishedWork) {
|
|
|
18442
18926
|
// here because that code is still in flux.
|
|
18443
18927
|
callback = tracing.unstable_wrap(callback);
|
|
18444
18928
|
}
|
|
18445
|
-
passiveEffectCallbackHandle =
|
|
18929
|
+
passiveEffectCallbackHandle = scheduler.unstable_runWithPriority(scheduler.unstable_NormalPriority, function () {
|
|
18930
|
+
return schedulePassiveEffects(callback);
|
|
18931
|
+
});
|
|
18446
18932
|
passiveEffectCallback = callback;
|
|
18447
18933
|
}
|
|
18448
18934
|
|
|
@@ -19031,7 +19517,7 @@ function renderRoot(root, isYieldy) {
|
|
|
19031
19517
|
return;
|
|
19032
19518
|
} else if (
|
|
19033
19519
|
// There's no lower priority work, but we're rendering asynchronously.
|
|
19034
|
-
//
|
|
19520
|
+
// Synchronously attempt to render the same level one more time. This is
|
|
19035
19521
|
// similar to a suspend, but without a timeout because we're not waiting
|
|
19036
19522
|
// for a promise to resolve.
|
|
19037
19523
|
!root.didError && isYieldy) {
|
|
@@ -19136,49 +19622,50 @@ function computeUniqueAsyncExpiration() {
|
|
|
19136
19622
|
}
|
|
19137
19623
|
|
|
19138
19624
|
function computeExpirationForFiber(currentTime, fiber) {
|
|
19625
|
+
var priorityLevel = scheduler.unstable_getCurrentPriorityLevel();
|
|
19626
|
+
|
|
19139
19627
|
var expirationTime = void 0;
|
|
19140
|
-
if (
|
|
19141
|
-
//
|
|
19142
|
-
expirationTime =
|
|
19143
|
-
} else if (isWorking) {
|
|
19144
|
-
|
|
19145
|
-
|
|
19146
|
-
// by default.
|
|
19147
|
-
expirationTime = Sync;
|
|
19148
|
-
} else {
|
|
19149
|
-
// Updates during the render phase should expire at the same time as
|
|
19150
|
-
// the work that is being rendered.
|
|
19151
|
-
expirationTime = nextRenderExpirationTime;
|
|
19152
|
-
}
|
|
19628
|
+
if ((fiber.mode & ConcurrentMode) === NoContext) {
|
|
19629
|
+
// Outside of concurrent mode, updates are always synchronous.
|
|
19630
|
+
expirationTime = Sync;
|
|
19631
|
+
} else if (isWorking && !isCommitting$1) {
|
|
19632
|
+
// During render phase, updates expire during as the current render.
|
|
19633
|
+
expirationTime = nextRenderExpirationTime;
|
|
19153
19634
|
} else {
|
|
19154
|
-
|
|
19155
|
-
|
|
19156
|
-
|
|
19157
|
-
|
|
19158
|
-
|
|
19635
|
+
switch (priorityLevel) {
|
|
19636
|
+
case scheduler.unstable_ImmediatePriority:
|
|
19637
|
+
expirationTime = Sync;
|
|
19638
|
+
break;
|
|
19639
|
+
case scheduler.unstable_UserBlockingPriority:
|
|
19159
19640
|
expirationTime = computeInteractiveExpiration(currentTime);
|
|
19160
|
-
|
|
19161
|
-
|
|
19641
|
+
break;
|
|
19642
|
+
case scheduler.unstable_NormalPriority:
|
|
19643
|
+
// This is a normal, concurrent update
|
|
19162
19644
|
expirationTime = computeAsyncExpiration(currentTime);
|
|
19163
|
-
|
|
19164
|
-
|
|
19165
|
-
|
|
19166
|
-
|
|
19167
|
-
|
|
19168
|
-
|
|
19169
|
-
|
|
19170
|
-
// This is a sync update
|
|
19171
|
-
expirationTime = Sync;
|
|
19645
|
+
break;
|
|
19646
|
+
case scheduler.unstable_LowPriority:
|
|
19647
|
+
case scheduler.unstable_IdlePriority:
|
|
19648
|
+
expirationTime = Never;
|
|
19649
|
+
break;
|
|
19650
|
+
default:
|
|
19651
|
+
invariant(false, 'Unknown priority level. This error is likely caused by a bug in React. Please file an issue.');
|
|
19172
19652
|
}
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
//
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
if (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime) {
|
|
19179
|
-
lowestPriorityPendingInteractiveExpirationTime = expirationTime;
|
|
19653
|
+
|
|
19654
|
+
// If we're in the middle of rendering a tree, do not update at the same
|
|
19655
|
+
// expiration time that is already rendering.
|
|
19656
|
+
if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
|
|
19657
|
+
expirationTime -= 1;
|
|
19180
19658
|
}
|
|
19181
19659
|
}
|
|
19660
|
+
|
|
19661
|
+
// Keep track of the lowest pending interactive expiration time. This
|
|
19662
|
+
// allows us to synchronously flush all interactive updates
|
|
19663
|
+
// when needed.
|
|
19664
|
+
// TODO: Move this to renderer?
|
|
19665
|
+
if (priorityLevel === scheduler.unstable_UserBlockingPriority && (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime)) {
|
|
19666
|
+
lowestPriorityPendingInteractiveExpirationTime = expirationTime;
|
|
19667
|
+
}
|
|
19668
|
+
|
|
19182
19669
|
return expirationTime;
|
|
19183
19670
|
}
|
|
19184
19671
|
|
|
@@ -19225,7 +19712,21 @@ function retryTimedOutBoundary(boundaryFiber, thenable) {
|
|
|
19225
19712
|
// The boundary fiber (a Suspense component) previously timed out and was
|
|
19226
19713
|
// rendered in its fallback state. One of the promises that suspended it has
|
|
19227
19714
|
// resolved, which means at least part of the tree was likely unblocked. Try
|
|
19228
|
-
var retryCache =
|
|
19715
|
+
var retryCache = void 0;
|
|
19716
|
+
if (enableSuspenseServerRenderer) {
|
|
19717
|
+
switch (boundaryFiber.tag) {
|
|
19718
|
+
case SuspenseComponent:
|
|
19719
|
+
retryCache = boundaryFiber.stateNode;
|
|
19720
|
+
break;
|
|
19721
|
+
case DehydratedSuspenseComponent:
|
|
19722
|
+
retryCache = boundaryFiber.memoizedState;
|
|
19723
|
+
break;
|
|
19724
|
+
default:
|
|
19725
|
+
invariant(false, 'Pinged unknown suspense boundary type. This is probably a bug in React.');
|
|
19726
|
+
}
|
|
19727
|
+
} else {
|
|
19728
|
+
retryCache = boundaryFiber.stateNode;
|
|
19729
|
+
}
|
|
19229
19730
|
if (retryCache !== null) {
|
|
19230
19731
|
// The thenable resolved, so we no longer need to memoize, because it will
|
|
19231
19732
|
// never be thrown again.
|
|
@@ -19324,7 +19825,7 @@ function scheduleWorkToRoot(fiber, expirationTime) {
|
|
|
19324
19825
|
function warnIfNotCurrentlyBatchingInDev(fiber) {
|
|
19325
19826
|
{
|
|
19326
19827
|
if (isRendering === false && isBatchingUpdates === false) {
|
|
19327
|
-
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));
|
|
19828
|
+
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));
|
|
19328
19829
|
}
|
|
19329
19830
|
}
|
|
19330
19831
|
}
|
|
@@ -19371,13 +19872,9 @@ function scheduleWork(fiber, expirationTime) {
|
|
|
19371
19872
|
}
|
|
19372
19873
|
|
|
19373
19874
|
function syncUpdates(fn, a, b, c, d) {
|
|
19374
|
-
|
|
19375
|
-
expirationContext = Sync;
|
|
19376
|
-
try {
|
|
19875
|
+
return scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
|
|
19377
19876
|
return fn(a, b, c, d);
|
|
19378
|
-
}
|
|
19379
|
-
expirationContext = previousExpirationContext;
|
|
19380
|
-
}
|
|
19877
|
+
});
|
|
19381
19878
|
}
|
|
19382
19879
|
|
|
19383
19880
|
// TODO: Everything below this is written as if it has been lifted to the
|
|
@@ -19398,7 +19895,6 @@ var unhandledError = null;
|
|
|
19398
19895
|
|
|
19399
19896
|
var isBatchingUpdates = false;
|
|
19400
19897
|
var isUnbatchingUpdates = false;
|
|
19401
|
-
var isBatchingInteractiveUpdates = false;
|
|
19402
19898
|
|
|
19403
19899
|
var completedBatches = null;
|
|
19404
19900
|
|
|
@@ -19872,7 +20368,9 @@ function completeRoot(root, finishedWork, expirationTime) {
|
|
|
19872
20368
|
lastCommittedRootDuringThisBatch = root;
|
|
19873
20369
|
nestedUpdateCount = 0;
|
|
19874
20370
|
}
|
|
19875
|
-
|
|
20371
|
+
scheduler.unstable_runWithPriority(scheduler.unstable_ImmediatePriority, function () {
|
|
20372
|
+
commitRoot(root, finishedWork);
|
|
20373
|
+
});
|
|
19876
20374
|
}
|
|
19877
20375
|
|
|
19878
20376
|
function onUncaughtError(error) {
|
|
@@ -19930,9 +20428,6 @@ function flushSync(fn, a) {
|
|
|
19930
20428
|
}
|
|
19931
20429
|
|
|
19932
20430
|
function interactiveUpdates$1(fn, a, b) {
|
|
19933
|
-
if (isBatchingInteractiveUpdates) {
|
|
19934
|
-
return fn(a, b);
|
|
19935
|
-
}
|
|
19936
20431
|
// If there are any pending interactive updates, synchronously flush them.
|
|
19937
20432
|
// This needs to happen before we read any handlers, because the effect of
|
|
19938
20433
|
// the previous event may influence which handlers are called during
|
|
@@ -19942,14 +20437,13 @@ function interactiveUpdates$1(fn, a, b) {
|
|
|
19942
20437
|
performWork(lowestPriorityPendingInteractiveExpirationTime, false);
|
|
19943
20438
|
lowestPriorityPendingInteractiveExpirationTime = NoWork;
|
|
19944
20439
|
}
|
|
19945
|
-
var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates;
|
|
19946
20440
|
var previousIsBatchingUpdates = isBatchingUpdates;
|
|
19947
|
-
isBatchingInteractiveUpdates = true;
|
|
19948
20441
|
isBatchingUpdates = true;
|
|
19949
20442
|
try {
|
|
19950
|
-
return
|
|
20443
|
+
return scheduler.unstable_runWithPriority(scheduler.unstable_UserBlockingPriority, function () {
|
|
20444
|
+
return fn(a, b);
|
|
20445
|
+
});
|
|
19951
20446
|
} finally {
|
|
19952
|
-
isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates;
|
|
19953
20447
|
isBatchingUpdates = previousIsBatchingUpdates;
|
|
19954
20448
|
if (!isBatchingUpdates && !isRendering) {
|
|
19955
20449
|
performSyncWork();
|
|
@@ -20212,7 +20706,7 @@ implementation) {
|
|
|
20212
20706
|
|
|
20213
20707
|
// TODO: this is special because it gets imported during build.
|
|
20214
20708
|
|
|
20215
|
-
var ReactVersion = '16.8.
|
|
20709
|
+
var ReactVersion = '16.8.4';
|
|
20216
20710
|
|
|
20217
20711
|
// TODO: This type is shared between the reconciler and ReactDOM, but will
|
|
20218
20712
|
// eventually be lifted out to the renderer.
|
|
@@ -20602,7 +21096,7 @@ var ReactDOM = {
|
|
|
20602
21096
|
hydrate: function (element, container, callback) {
|
|
20603
21097
|
!isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0;
|
|
20604
21098
|
{
|
|
20605
|
-
!!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
|
|
21099
|
+
!!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;
|
|
20606
21100
|
}
|
|
20607
21101
|
// TODO: throw or warn if we couldn't hydrate?
|
|
20608
21102
|
return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
|