diff --git a/Libraries/LogBox/__tests__/LogBox-integration-test.js b/Libraries/LogBox/__tests__/LogBox-integration-test.js
index f8187a4e5cb020..8a02754df3df83 100644
--- a/Libraries/LogBox/__tests__/LogBox-integration-test.js
+++ b/Libraries/LogBox/__tests__/LogBox-integration-test.js
@@ -49,7 +49,10 @@ const cleanLog = logs => {
});
};
-describe('LogBox', () => {
+// TODO(T71117418): Re-enable skipped LogBox integration tests once React component
+// stack frames are the same internally and in open source.
+// eslint-disable-next-line jest/no-disabled-tests
+describe.skip('LogBox', () => {
const {error, warn} = console;
const mockError = jest.fn();
const mockWarn = jest.fn();
diff --git a/Libraries/LogBox/__tests__/__snapshots__/LogBox-integration-test.js.snap b/Libraries/LogBox/__tests__/__snapshots__/LogBox-integration-test.js.snap
deleted file mode 100644
index 9209ee6be5f0b4..00000000000000
--- a/Libraries/LogBox/__tests__/__snapshots__/LogBox-integration-test.js.snap
+++ /dev/null
@@ -1,94 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`LogBox integrates with React and handles a fragment warning in LogBox: Log added to LogBox 1`] = `
-Array [
- Object {
- "category": "Warning: Invalid prop \`%s\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props.",
- "componentStack": Array [
- Object {
- "content": "Fragment",
- "fileName": "ReactWarningFixtures.js",
- "location": Object {
- "column": -1,
- "row": 28,
- },
- },
- ],
- "level": "warn",
- "message": Object {
- "content": "Warning: Invalid prop \`invalid\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props.",
- "substitutions": Array [
- Object {
- "length": 7,
- "offset": 23,
- },
- ],
- },
- },
-]
-`;
-
-exports[`LogBox integrates with React and handles a fragment warning in LogBox: Log passed to console error 1`] = `
-Array [
- "Warning: Invalid prop \`invalid\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props.
- in Fragment (at ReactWarningFixtures.js:28)",
-]
-`;
-
-exports[`LogBox integrates with React and handles a fragment warning in LogBox: Log sent from React 1`] = `
-Array [
- "Warning: Invalid prop \`%s\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props.%s",
- "invalid",
- "
- in Fragment (at ReactWarningFixtures.js:28)",
-]
-`;
-
-exports[`LogBox integrates with React and handles a key error in LogBox: Log added to LogBox 1`] = `
-Array [
- Object {
- "category": "Warning: Each child in a list should have a unique \\"key\\" prop.%s%s See https://fb.me/react-warning-keys for more information.",
- "componentStack": Array [
- Object {
- "content": "Text",
- "fileName": "ReactWarningFixtures.js",
- "location": Object {
- "column": -1,
- "row": 20,
- },
- },
- ],
- "level": "warn",
- "message": Object {
- "content": "Warning: Each child in a list should have a unique \\"key\\" prop. See https://fb.me/react-warning-keys for more information.",
- "substitutions": Array [
- Object {
- "length": 0,
- "offset": 62,
- },
- Object {
- "length": 0,
- "offset": 62,
- },
- ],
- },
- },
-]
-`;
-
-exports[`LogBox integrates with React and handles a key error in LogBox: Log passed to console error 1`] = `
-Array [
- "Warning: Each child in a list should have a unique \\"key\\" prop. See https://fb.me/react-warning-keys for more information.
- in Text (at ReactWarningFixtures.js:20)",
-]
-`;
-
-exports[`LogBox integrates with React and handles a key error in LogBox: Log sent from React 1`] = `
-Array [
- "Warning: Each child in a list should have a unique \\"key\\" prop.%s%s See https://fb.me/react-warning-keys for more information.%s",
- "",
- "",
- "
- in Text (at ReactWarningFixtures.js:20)",
-]
-`;
diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION
index 55c9a60f3d6303..bb3889c83793bd 100644
--- a/Libraries/Renderer/REVISION
+++ b/Libraries/Renderer/REVISION
@@ -1 +1 @@
-b5c6dd2de557428974855b5aa88bf9c6595beb2b
\ No newline at end of file
+a437f3ff302dc92347d812d518c9a9659d9aa546
\ No newline at end of file
diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js
index 2a462f48ee41d0..58a9f4d2b2d425 100644
--- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js
+++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js
@@ -23,21 +23,7 @@ var Scheduler = require("scheduler");
var tracing = require("scheduler/tracing");
var ReactSharedInternals =
- React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
-// Current owner and dispatcher used to share the same ref,
-// but PR #14548 split them out to better support the react-debug-tools package.
-
-if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) {
- ReactSharedInternals.ReactCurrentDispatcher = {
- current: null
- };
-}
-
-if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) {
- ReactSharedInternals.ReactCurrentBatchConfig = {
- suspense: null
- };
-}
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// by calls to these methods by a Babel plugin.
//
@@ -79,19 +65,12 @@ function printWarning(level, format, args) {
// When changing this logic, you might want to also
// update consoleWithStackDev.www.js as well.
{
- var hasExistingStack =
- args.length > 0 &&
- typeof args[args.length - 1] === "string" &&
- args[args.length - 1].indexOf("\n in") === 0;
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
- if (!hasExistingStack) {
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
- var stack = ReactDebugCurrentFrame.getStackAddendum();
-
- if (stack !== "") {
- format += "%s";
- args = args.concat([stack]);
- }
+ if (stack !== "") {
+ format += "%s";
+ args = args.concat([stack]);
}
var argsWithFormat = args.map(function(item) {
@@ -103,161 +82,10 @@ function printWarning(level, format, args) {
// eslint-disable-next-line react-internal/no-production-logging
Function.prototype.apply.call(console[level], console, argsWithFormat);
-
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- var argIndex = 0;
- var message =
- "Warning: " +
- format.replace(/%s/g, function() {
- return args[argIndex++];
- });
- throw new Error(message);
- } catch (x) {}
- }
-}
-
-var FunctionComponent = 0;
-var ClassComponent = 1;
-var IndeterminateComponent = 2; // Before we know whether it is function or class
-
-var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
-
-var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
-
-var HostComponent = 5;
-var HostText = 6;
-var Fragment = 7;
-var Mode = 8;
-var ContextConsumer = 9;
-var ContextProvider = 10;
-var ForwardRef = 11;
-var Profiler = 12;
-var SuspenseComponent = 13;
-var MemoComponent = 14;
-var SimpleMemoComponent = 15;
-var LazyComponent = 16;
-var IncompleteClassComponent = 17;
-var DehydratedFragment = 18;
-var SuspenseListComponent = 19;
-var FundamentalComponent = 20;
-var ScopeComponent = 21;
-var Block = 22;
-
-function getParent(inst) {
- do {
- inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
- // That is depending on if we want nested subtrees (layers) to bubble
- // events to their parent. We could also go through parentNode on the
- // host node but that wouldn't work for React Native and doesn't let us
- // do the portal feature.
- } while (inst && inst.tag !== HostComponent);
-
- if (inst) {
- return inst;
- }
-
- return null;
-}
-/**
- * Return the lowest common ancestor of A and B, or null if they are in
- * different trees.
- */
-
-function getLowestCommonAncestor(instA, instB) {
- var depthA = 0;
-
- for (var tempA = instA; tempA; tempA = getParent(tempA)) {
- depthA++;
- }
-
- var depthB = 0;
-
- for (var tempB = instB; tempB; tempB = getParent(tempB)) {
- depthB++;
- } // If A is deeper, crawl up.
-
- while (depthA - depthB > 0) {
- instA = getParent(instA);
- depthA--;
- } // If B is deeper, crawl up.
-
- while (depthB - depthA > 0) {
- instB = getParent(instB);
- depthB--;
- } // Walk in lockstep until we find a match.
-
- var depth = depthA;
-
- while (depth--) {
- if (instA === instB || instA === instB.alternate) {
- return instA;
- }
-
- instA = getParent(instA);
- instB = getParent(instB);
- }
-
- return null;
-}
-/**
- * Return if A is an ancestor of B.
- */
-
-function isAncestor(instA, instB) {
- while (instB) {
- if (instA === instB || instA === instB.alternate) {
- return true;
- }
-
- instB = getParent(instB);
- }
-
- return false;
-}
-/**
- * Return the parent instance of the passed-in instance.
- */
-
-function getParentInstance(inst) {
- return getParent(inst);
-}
-/**
- * Simulates the traversal of a two-phase, capture/bubble event dispatch.
- */
-
-function traverseTwoPhase(inst, fn, arg) {
- var path = [];
-
- while (inst) {
- path.push(inst);
- inst = getParent(inst);
- }
-
- var i;
-
- for (i = path.length; i-- > 0; ) {
- fn(path[i], "captured", arg);
- }
-
- for (i = 0; i < path.length; i++) {
- fn(path[i], "bubbled", arg);
}
}
-var invokeGuardedCallbackImpl = function(
- name,
- func,
- context,
- a,
- b,
- c,
- d,
- e,
- f
-) {
+function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
var funcArgs = Array.prototype.slice.call(arguments, 3);
try {
@@ -265,7 +93,9 @@ var invokeGuardedCallbackImpl = function(
} catch (error) {
this.onError(error);
}
-};
+}
+
+var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
{
// In DEV mode, we swap out invokeGuardedCallback for a special version
@@ -296,7 +126,7 @@ var invokeGuardedCallbackImpl = function(
) {
var fakeNode = document.createElement("react");
- var invokeGuardedCallbackDev = function(
+ invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(
name,
func,
context,
@@ -317,7 +147,8 @@ var invokeGuardedCallbackImpl = function(
);
}
- var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We
+ var evt = document.createEvent("Event");
+ var didCall = false; // Keeps track of whether the user-provided callback threw an error. We
// set this to true at the beginning, then set it to false right after
// calling the function. If the function errors, `didError` will never be
// set to false. This strategy works even if the browser is flaky and
@@ -334,13 +165,9 @@ var invokeGuardedCallbackImpl = function(
var windowEventDescriptor = Object.getOwnPropertyDescriptor(
window,
"event"
- ); // Create an event handler for our fake event. We will synchronously
- // dispatch our fake event using `dispatchEvent`. Inside the handler, we
- // call the user-provided callback.
-
- var funcArgs = Array.prototype.slice.call(arguments, 3);
+ );
- function callCallback() {
+ function restoreAfterDispatch() {
// We immediately remove the callback from event listeners so that
// nested `invokeGuardedCallback` calls do not clash. Otherwise, a
// nested call would trigger the fake event handlers of any call higher
@@ -356,7 +183,15 @@ var invokeGuardedCallbackImpl = function(
) {
window.event = windowEvent;
}
+ } // Create an event handler for our fake event. We will synchronously
+ // dispatch our fake event using `dispatchEvent`. Inside the handler, we
+ // call the user-provided callback.
+
+ var funcArgs = Array.prototype.slice.call(arguments, 3);
+ function callCallback() {
+ didCall = true;
+ restoreAfterDispatch();
func.apply(context, funcArgs);
didError = false;
} // Create a global error event handler. We use this to capture the value
@@ -411,7 +246,7 @@ var invokeGuardedCallbackImpl = function(
Object.defineProperty(window, "event", windowEventDescriptor);
}
- if (didError) {
+ if (didCall && didError) {
if (!didSetError) {
// The callback errored, but the error event never fired.
error = new Error(
@@ -436,9 +271,16 @@ var invokeGuardedCallbackImpl = function(
} // Remove our event listeners
window.removeEventListener("error", handleWindowError);
- };
- invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
+ if (!didCall) {
+ // Something went really wrong, and our event was not dispatched.
+ // https://github.com/facebook/react/issues/16734
+ // https://github.com/facebook/react/issues/16585
+ // Fall back to the production implementation.
+ restoreAfterDispatch();
+ return invokeGuardedCallbackProd.apply(this, arguments);
+ }
+ };
}
}
@@ -707,293 +549,53 @@ function hasDispatches(event) {
return !!event._dispatchListeners;
}
-function isInteractive(tag) {
- return (
- tag === "button" ||
- tag === "input" ||
- tag === "select" ||
- tag === "textarea"
- );
-}
-
-function shouldPreventMouseEvent(name, type, props) {
- switch (name) {
- case "onClick":
- case "onClickCapture":
- case "onDoubleClick":
- case "onDoubleClickCapture":
- case "onMouseDown":
- case "onMouseDownCapture":
- case "onMouseMove":
- case "onMouseMoveCapture":
- case "onMouseUp":
- case "onMouseUpCapture":
- case "onMouseEnter":
- return !!(props.disabled && isInteractive(type));
-
- default:
- return false;
- }
-}
+var EVENT_POOL_SIZE = 10;
/**
- * @param {object} inst The instance, which is the source of events.
- * @param {string} registrationName Name of listener (e.g. `onClick`).
- * @return {?function} The stored callback.
+ * @interface Event
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
*/
-function getListener(inst, registrationName) {
- var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
- // live here; needs to be moved to a better place soon
-
- var stateNode = inst.stateNode;
-
- if (!stateNode) {
- // Work in progress (ex: onload events in incremental mode).
- return null;
- }
-
- var props = getFiberCurrentPropsFromNode(stateNode);
-
- if (!props) {
- // Work in progress.
- return null;
- }
-
- listener = props[registrationName];
-
- if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
+var EventInterface = {
+ type: null,
+ target: null,
+ // currentTarget is set when dispatching; no use in copying it here
+ currentTarget: function() {
return null;
- }
-
- if (!(!listener || typeof listener === "function")) {
- throw Error(
- "Expected `" +
- registrationName +
- "` listener to be a function, instead got a value of `" +
- typeof listener +
- "` type."
- );
- }
+ },
+ eventPhase: null,
+ bubbles: null,
+ cancelable: null,
+ timeStamp: function(event) {
+ return event.timeStamp || Date.now();
+ },
+ defaultPrevented: null,
+ isTrusted: null
+};
- return listener;
+function functionThatReturnsTrue() {
+ return true;
}
+function functionThatReturnsFalse() {
+ return false;
+}
/**
- * Accumulates items that must not be null or undefined into the first one. This
- * is used to conserve memory by avoiding array allocations, and thus sacrifices
- * API cleanness. Since `current` can be null before being passed in and not
- * null after this function, make sure to assign it back to `current`:
+ * Synthetic events are dispatched by event plugins, typically in response to a
+ * top-level event delegation handler.
*
- * `a = accumulateInto(a, b);`
+ * These systems should generally use pooling to reduce the frequency of garbage
+ * collection. The system should check `isPersistent` to determine whether the
+ * event should be released into the pool after being dispatched. Users that
+ * need a persisted event should invoke `persist`.
*
- * This API should be sparingly used. Try `accumulate` for something cleaner.
+ * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
+ * normalizing browser quirks. Subclasses do not necessarily have to implement a
+ * DOM interface; custom application-specific events can also subclass this.
*
- * @return {*|array<*>} An accumulation of items.
- */
-
-function accumulateInto(current, next) {
- if (!(next != null)) {
- throw Error(
- "accumulateInto(...): Accumulated items must not be null or undefined."
- );
- }
-
- if (current == null) {
- return next;
- } // Both are not empty. Warning: Never call x.concat(y) when you are not
- // certain that x is an Array (x could be a string with concat method).
-
- if (Array.isArray(current)) {
- if (Array.isArray(next)) {
- current.push.apply(current, next);
- return current;
- }
-
- current.push(next);
- return current;
- }
-
- if (Array.isArray(next)) {
- // A bit too dangerous to mutate `next`.
- return [current].concat(next);
- }
-
- return [current, next];
-}
-
-/**
- * @param {array} arr an "accumulation" of items which is either an Array or
- * a single item. Useful when paired with the `accumulate` module. This is a
- * simple utility that allows us to reason about a collection of items, but
- * handling the case when there is exactly one item (and we do not need to
- * allocate an array).
- * @param {function} cb Callback invoked with each element or a collection.
- * @param {?} [scope] Scope used as `this` in a callback.
- */
-function forEachAccumulated(arr, cb, scope) {
- if (Array.isArray(arr)) {
- arr.forEach(cb, scope);
- } else if (arr) {
- cb.call(scope, arr);
- }
-}
-
-/**
- * Some event types have a notion of different registration names for different
- * "phases" of propagation. This finds listeners by a given phase.
- */
-function listenerAtPhase(inst, event, propagationPhase) {
- var registrationName =
- event.dispatchConfig.phasedRegistrationNames[propagationPhase];
- return getListener(inst, registrationName);
-}
-/**
- * A small set of propagation patterns, each of which will accept a small amount
- * of information, and generate a set of "dispatch ready event objects" - which
- * are sets of events that have already been annotated with a set of dispatched
- * listener functions/ids. The API is designed this way to discourage these
- * propagation strategies from actually executing the dispatches, since we
- * always want to collect the entire set of dispatches before executing even a
- * single one.
- */
-
-/**
- * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
- * here, allows us to not have to bind or create functions for each event.
- * Mutating the event's members allows us to not have to create a wrapping
- * "dispatch" object that pairs the event with the listener.
- */
-
-function accumulateDirectionalDispatches(inst, phase, event) {
- {
- if (!inst) {
- error("Dispatching inst must not be null");
- }
- }
-
- var listener = listenerAtPhase(inst, event, phase);
-
- if (listener) {
- event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- );
- event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
- }
-}
-/**
- * Collect dispatches (must be entirely collected before dispatching - see unit
- * tests). Lazily allocate the array to conserve memory. We must loop through
- * each event and perform the traversal for each one. We cannot perform a
- * single traversal for the entire collection of events because each event may
- * have a different target.
- */
-
-function accumulateTwoPhaseDispatchesSingle(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
- }
-}
-/**
- * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
- */
-
-function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- var targetInst = event._targetInst;
- var parentInst = targetInst ? getParentInstance(targetInst) : null;
- traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
- }
-}
-/**
- * Accumulates without regard to direction, does not look for phased
- * registration names. Same as `accumulateDirectDispatchesSingle` but without
- * requiring that the `dispatchMarker` be the same as the dispatched ID.
- */
-
-function accumulateDispatches(inst, ignoredDirection, event) {
- if (inst && event && event.dispatchConfig.registrationName) {
- var registrationName = event.dispatchConfig.registrationName;
- var listener = getListener(inst, registrationName);
-
- if (listener) {
- event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- );
- event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
- }
- }
-}
-/**
- * Accumulates dispatches on an `SyntheticEvent`, but only for the
- * `dispatchMarker`.
- * @param {SyntheticEvent} event
- */
-
-function accumulateDirectDispatchesSingle(event) {
- if (event && event.dispatchConfig.registrationName) {
- accumulateDispatches(event._targetInst, null, event);
- }
-}
-
-function accumulateTwoPhaseDispatches(events) {
- forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
-}
-function accumulateTwoPhaseDispatchesSkipTarget(events) {
- forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
-}
-function accumulateDirectDispatches(events) {
- forEachAccumulated(events, accumulateDirectDispatchesSingle);
-}
-
-var EVENT_POOL_SIZE = 10;
-/**
- * @interface Event
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
- */
-
-var EventInterface = {
- type: null,
- target: null,
- // currentTarget is set when dispatching; no use in copying it here
- currentTarget: function() {
- return null;
- },
- eventPhase: null,
- bubbles: null,
- cancelable: null,
- timeStamp: function(event) {
- return event.timeStamp || Date.now();
- },
- defaultPrevented: null,
- isTrusted: null
-};
-
-function functionThatReturnsTrue() {
- return true;
-}
-
-function functionThatReturnsFalse() {
- return false;
-}
-/**
- * Synthetic events are dispatched by event plugins, typically in response to a
- * top-level event delegation handler.
- *
- * These systems should generally use pooling to reduce the frequency of garbage
- * collection. The system should check `isPersistent` to determine whether the
- * event should be released into the pool after being dispatched. Users that
- * need a persisted event should invoke `persist`.
- *
- * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
- * normalizing browser quirks. Subclasses do not necessarily have to implement a
- * DOM interface; custom application-specific events can also subclass this.
- *
- * @param {object} dispatchConfig Configuration used to dispatch this event.
- * @param {*} targetInst Marker identifying the event target.
- * @param {object} nativeEvent Native browser event.
- * @param {DOMEventTarget} nativeEventTarget Target node.
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
+ * @param {*} targetInst Marker identifying the event target.
+ * @param {object} nativeEvent Native browser event.
+ * @param {DOMEventTarget} nativeEventTarget Target node.
*/
function SyntheticEvent(
@@ -1014,6 +616,8 @@ function SyntheticEvent(
this.dispatchConfig = dispatchConfig;
this._targetInst = targetInst;
this.nativeEvent = nativeEvent;
+ this._dispatchListeners = null;
+ this._dispatchInstances = null;
var Interface = this.constructor.Interface;
for (var propName in Interface) {
@@ -1239,7 +843,12 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
}
}
-function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
+function createOrGetPooledEvent(
+ dispatchConfig,
+ targetInst,
+ nativeEvent,
+ nativeInst
+) {
var EventConstructor = this;
if (EventConstructor.eventPool.length) {
@@ -1279,8 +888,8 @@ function releasePooledEvent(event) {
}
function addEventPoolingTo(EventConstructor) {
+ EventConstructor.getPooled = createOrGetPooledEvent;
EventConstructor.eventPool = [];
- EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}
@@ -1546,63 +1155,152 @@ function accumulate(current, next) {
}
/**
- * Instance of element that should respond to touch/move types of interactions,
- * as indicated explicitly by relevant callbacks.
+ * Accumulates items that must not be null or undefined into the first one. This
+ * is used to conserve memory by avoiding array allocations, and thus sacrifices
+ * API cleanness. Since `current` can be null before being passed in and not
+ * null after this function, make sure to assign it back to `current`:
+ *
+ * `a = accumulateInto(a, b);`
+ *
+ * This API should be sparingly used. Try `accumulate` for something cleaner.
+ *
+ * @return {*|array<*>} An accumulation of items.
*/
-var responderInst = null;
-/**
- * Count of current touches. A textInput should become responder iff the
- * selection changes while there is a touch on the screen.
- */
+function accumulateInto(current, next) {
+ if (!(next != null)) {
+ throw Error(
+ "accumulateInto(...): Accumulated items must not be null or undefined."
+ );
+ }
-var trackedTouchCount = 0;
+ if (current == null) {
+ return next;
+ } // Both are not empty. Warning: Never call x.concat(y) when you are not
+ // certain that x is an Array (x could be a string with concat method).
-var changeResponder = function(nextResponderInst, blockHostResponder) {
- var oldResponderInst = responderInst;
- responderInst = nextResponderInst;
+ if (Array.isArray(current)) {
+ if (Array.isArray(next)) {
+ current.push.apply(current, next);
+ return current;
+ }
- if (ResponderEventPlugin.GlobalResponderHandler !== null) {
- ResponderEventPlugin.GlobalResponderHandler.onChange(
- oldResponderInst,
- nextResponderInst,
- blockHostResponder
- );
+ current.push(next);
+ return current;
}
-};
-var eventTypes = {
- /**
- * On a `touchStart`/`mouseDown`, is it desired that this element become the
- * responder?
- */
- startShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onStartShouldSetResponder",
- captured: "onStartShouldSetResponderCapture"
- },
- dependencies: startDependencies
- },
+ if (Array.isArray(next)) {
+ // A bit too dangerous to mutate `next`.
+ return [current].concat(next);
+ }
- /**
- * On a `scroll`, is it desired that this element become the responder? This
- * is usually not needed, but should be used to retroactively infer that a
- * `touchStart` had occurred during momentum scroll. During a momentum scroll,
- * a touch start will be immediately followed by a scroll event if the view is
- * currently scrolling.
- *
- * TODO: This shouldn't bubble.
- */
- scrollShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onScrollShouldSetResponder",
- captured: "onScrollShouldSetResponderCapture"
- },
- dependencies: [TOP_SCROLL]
- },
+ return [current, next];
+}
- /**
- * On text selection change, should this element become the responder? This
+/**
+ * @param {array} arr an "accumulation" of items which is either an Array or
+ * a single item. Useful when paired with the `accumulate` module. This is a
+ * simple utility that allows us to reason about a collection of items, but
+ * handling the case when there is exactly one item (and we do not need to
+ * allocate an array).
+ * @param {function} cb Callback invoked with each element or a collection.
+ * @param {?} [scope] Scope used as `this` in a callback.
+ */
+function forEachAccumulated(arr, cb, scope) {
+ if (Array.isArray(arr)) {
+ arr.forEach(cb, scope);
+ } else if (arr) {
+ cb.call(scope, arr);
+ }
+}
+
+var FunctionComponent = 0;
+var ClassComponent = 1;
+var IndeterminateComponent = 2; // Before we know whether it is function or class
+
+var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
+
+var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
+
+var HostComponent = 5;
+var HostText = 6;
+var Fragment = 7;
+var Mode = 8;
+var ContextConsumer = 9;
+var ContextProvider = 10;
+var ForwardRef = 11;
+var Profiler = 12;
+var SuspenseComponent = 13;
+var MemoComponent = 14;
+var SimpleMemoComponent = 15;
+var LazyComponent = 16;
+var IncompleteClassComponent = 17;
+var DehydratedFragment = 18;
+var SuspenseListComponent = 19;
+var FundamentalComponent = 20;
+var ScopeComponent = 21;
+var Block = 22;
+var OffscreenComponent = 23;
+var LegacyHiddenComponent = 24;
+
+/**
+ * Instance of element that should respond to touch/move types of interactions,
+ * as indicated explicitly by relevant callbacks.
+ */
+
+var responderInst = null;
+/**
+ * Count of current touches. A textInput should become responder iff the
+ * selection changes while there is a touch on the screen.
+ */
+
+var trackedTouchCount = 0;
+
+var changeResponder = function(nextResponderInst, blockHostResponder) {
+ var oldResponderInst = responderInst;
+ responderInst = nextResponderInst;
+
+ if (ResponderEventPlugin.GlobalResponderHandler !== null) {
+ ResponderEventPlugin.GlobalResponderHandler.onChange(
+ oldResponderInst,
+ nextResponderInst,
+ blockHostResponder
+ );
+ }
+};
+
+var eventTypes = {
+ /**
+ * On a `touchStart`/`mouseDown`, is it desired that this element become the
+ * responder?
+ */
+ startShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onStartShouldSetResponder",
+ captured: "onStartShouldSetResponderCapture"
+ },
+ dependencies: startDependencies
+ },
+
+ /**
+ * On a `scroll`, is it desired that this element become the responder? This
+ * is usually not needed, but should be used to retroactively infer that a
+ * `touchStart` had occurred during momentum scroll. During a momentum scroll,
+ * a touch start will be immediately followed by a scroll event if the view is
+ * currently scrolling.
+ *
+ * TODO: This shouldn't bubble.
+ */
+ scrollShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onScrollShouldSetResponder",
+ captured: "onScrollShouldSetResponderCapture"
+ },
+ dependencies: [TOP_SCROLL]
+ },
+
+ /**
+ * On text selection change, should this element become the responder? This
* is needed for text inputs or other views with native selection, so the
* JS view can claim the responder.
*
@@ -1663,144 +1361,352 @@ var eventTypes = {
registrationName: "onResponderTerminate",
dependencies: []
}
-};
+}; // Start of inline: the below functions were inlined from
+// EventPropagator.js, as they deviated from ReactDOM's newer
+// implementations.
+
+function getParent(inst) {
+ do {
+ inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
+ // That is depending on if we want nested subtrees (layers) to bubble
+ // events to their parent. We could also go through parentNode on the
+ // host node but that wouldn't work for React Native and doesn't let us
+ // do the portal feature.
+ } while (inst && inst.tag !== HostComponent);
+
+ if (inst) {
+ return inst;
+ }
+
+ return null;
+}
/**
- *
- * Responder System:
- * ----------------
- *
- * - A global, solitary "interaction lock" on a view.
- * - If a node becomes the responder, it should convey visual feedback
- * immediately to indicate so, either by highlighting or moving accordingly.
- * - To be the responder means, that touches are exclusively important to that
- * responder view, and no other view.
- * - While touches are still occurring, the responder lock can be transferred to
- * a new view, but only to increasingly "higher" views (meaning ancestors of
- * the current responder).
- *
- * Responder being granted:
- * ------------------------
- *
- * - Touch starts, moves, and scrolls can cause an ID to become the responder.
- * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to
- * the "appropriate place".
- * - If nothing is currently the responder, the "appropriate place" is the
- * initiating event's `targetID`.
- * - If something *is* already the responder, the "appropriate place" is the
- * first common ancestor of the event target and the current `responderInst`.
- * - Some negotiation happens: See the timing diagram below.
- * - Scrolled views automatically become responder. The reasoning is that a
- * platform scroll view that isn't built on top of the responder system has
- * began scrolling, and the active responder must now be notified that the
- * interaction is no longer locked to it - the system has taken over.
- *
- * - Responder being released:
- * As soon as no more touches that *started* inside of descendants of the
- * *current* responderInst, an `onResponderRelease` event is dispatched to the
- * current responder, and the responder lock is released.
- *
- * TODO:
- * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that
- * determines if the responder lock should remain.
- * - If a view shouldn't "remain" the responder, any active touches should by
- * default be considered "dead" and do not influence future negotiations or
- * bubble paths. It should be as if those touches do not exist.
- * -- For multitouch: Usually a translate-z will choose to "remain" responder
- * after one out of many touches ended. For translate-y, usually the view
- * doesn't wish to "remain" responder after one of many touches end.
- * - Consider building this on top of a `stopPropagation` model similar to
- * `W3C` events.
- * - Ensure that `onResponderTerminate` is called on touch cancels, whether or
- * not `onResponderTerminationRequest` returns `true` or `false`.
- *
+ * Return the lowest common ancestor of A and B, or null if they are in
+ * different trees.
*/
-/* Negotiation Performed
- +-----------------------+
- / \
-Process low level events to + Current Responder + wantsResponderID
-determine who to perform negot-| (if any exists at all) |
-iation/transition | Otherwise just pass through|
--------------------------------+----------------------------+------------------+
-Bubble to find first ID | |
-to return true:wantsResponderID| |
- | |
- +-------------+ | |
- | onTouchStart| | |
- +------+------+ none | |
- | return| |
-+-----------v-------------+true| +------------------------+ |
-|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+
-+-----------+-------------+ | +------------------------+ | |
- | | | +--------+-------+
- | returned true for| false:REJECT +-------->|onResponderReject
- | wantsResponderID | | | +----------------+
- | (now attempt | +------------------+-----+ |
- | handoff) | | onResponder | |
- +------------------->| TerminationRequest| |
- | +------------------+-----+ |
- | | | +----------------+
- | true:GRANT +-------->|onResponderGrant|
- | | +--------+-------+
- | +------------------------+ | |
- | | onResponderTerminate |<-----------+
- | +------------------+-----+ |
- | | | +----------------+
- | +-------->|onResponderStart|
- | | +----------------+
-Bubble to find first ID | |
-to return true:wantsResponderID| |
- | |
- +-------------+ | |
- | onTouchMove | | |
- +------+------+ none | |
- | return| |
-+-----------v-------------+true| +------------------------+ |
-|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+
-+-----------+-------------+ | +------------------------+ | |
- | | | +--------+-------+
- | returned true for| false:REJECT +-------->|onResponderRejec|
- | wantsResponderID | | | +----------------+
- | (now attempt | +------------------+-----+ |
- | handoff) | | onResponder | |
- +------------------->| TerminationRequest| |
- | +------------------+-----+ |
- | | | +----------------+
- | true:GRANT +-------->|onResponderGrant|
- | | +--------+-------+
- | +------------------------+ | |
- | | onResponderTerminate |<-----------+
- | +------------------+-----+ |
- | | | +----------------+
- | +-------->|onResponderMove |
- | | +----------------+
- | |
- | |
- Some active touch started| |
- inside current responder | +------------------------+ |
- +------------------------->| onResponderEnd | |
- | | +------------------------+ |
- +---+---------+ | |
- | onTouchEnd | | |
- +---+---------+ | |
- | | +------------------------+ |
- +------------------------->| onResponderEnd | |
- No active touches started| +-----------+------------+ |
- inside current responder | | |
- | v |
- | +------------------------+ |
- | | onResponderRelease | |
- | +------------------------+ |
- | |
- + + */
+function getLowestCommonAncestor(instA, instB) {
+ var depthA = 0;
-/**
- * A note about event ordering in the `EventPluginRegistry`.
- *
- * Suppose plugins are injected in the following order:
- *
- * `[R, S, C]`
- *
+ for (var tempA = instA; tempA; tempA = getParent(tempA)) {
+ depthA++;
+ }
+
+ var depthB = 0;
+
+ for (var tempB = instB; tempB; tempB = getParent(tempB)) {
+ depthB++;
+ } // If A is deeper, crawl up.
+
+ while (depthA - depthB > 0) {
+ instA = getParent(instA);
+ depthA--;
+ } // If B is deeper, crawl up.
+
+ while (depthB - depthA > 0) {
+ instB = getParent(instB);
+ depthB--;
+ } // Walk in lockstep until we find a match.
+
+ var depth = depthA;
+
+ while (depth--) {
+ if (instA === instB || instA === instB.alternate) {
+ return instA;
+ }
+
+ instA = getParent(instA);
+ instB = getParent(instB);
+ }
+
+ return null;
+}
+/**
+ * Return if A is an ancestor of B.
+ */
+
+function isAncestor(instA, instB) {
+ while (instB) {
+ if (instA === instB || instA === instB.alternate) {
+ return true;
+ }
+
+ instB = getParent(instB);
+ }
+
+ return false;
+}
+/**
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
+ */
+
+function traverseTwoPhase(inst, fn, arg) {
+ var path = [];
+
+ while (inst) {
+ path.push(inst);
+ inst = getParent(inst);
+ }
+
+ var i;
+
+ for (i = path.length; i-- > 0; ) {
+ fn(path[i], "captured", arg);
+ }
+
+ for (i = 0; i < path.length; i++) {
+ fn(path[i], "bubbled", arg);
+ }
+}
+
+function getListener(inst, registrationName) {
+ var stateNode = inst.stateNode;
+
+ if (stateNode === null) {
+ // Work in progress (ex: onload events in incremental mode).
+ return null;
+ }
+
+ var props = getFiberCurrentPropsFromNode(stateNode);
+
+ if (props === null) {
+ // Work in progress.
+ return null;
+ }
+
+ var listener = props[registrationName];
+
+ if (!(!listener || typeof listener === "function")) {
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof listener +
+ "` type."
+ );
+ }
+
+ return listener;
+}
+
+function listenerAtPhase(inst, event, propagationPhase) {
+ var registrationName =
+ event.dispatchConfig.phasedRegistrationNames[propagationPhase];
+ return getListener(inst, registrationName);
+}
+
+function accumulateDirectionalDispatches(inst, phase, event) {
+ {
+ if (!inst) {
+ error("Dispatching inst must not be null");
+ }
+ }
+
+ var listener = listenerAtPhase(inst, event, phase);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
+ }
+}
+/**
+ * Accumulates without regard to direction, does not look for phased
+ * registration names. Same as `accumulateDirectDispatchesSingle` but without
+ * requiring that the `dispatchMarker` be the same as the dispatched ID.
+ */
+
+function accumulateDispatches(inst, ignoredDirection, event) {
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var registrationName = event.dispatchConfig.registrationName;
+ var listener = getListener(inst, registrationName);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
+ }
+ }
+}
+/**
+ * Accumulates dispatches on an `SyntheticEvent`, but only for the
+ * `dispatchMarker`.
+ * @param {SyntheticEvent} event
+ */
+
+function accumulateDirectDispatchesSingle(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ accumulateDispatches(event._targetInst, null, event);
+ }
+}
+
+function accumulateDirectDispatches(events) {
+ forEachAccumulated(events, accumulateDirectDispatchesSingle);
+}
+
+function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ var targetInst = event._targetInst;
+ var parentInst = targetInst ? getParent(targetInst) : null;
+ traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
+ }
+}
+
+function accumulateTwoPhaseDispatchesSkipTarget(events) {
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
+}
+
+function accumulateTwoPhaseDispatchesSingle(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
+ }
+}
+
+function accumulateTwoPhaseDispatches(events) {
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
+} // End of inline
+
+/**
+ *
+ * Responder System:
+ * ----------------
+ *
+ * - A global, solitary "interaction lock" on a view.
+ * - If a node becomes the responder, it should convey visual feedback
+ * immediately to indicate so, either by highlighting or moving accordingly.
+ * - To be the responder means, that touches are exclusively important to that
+ * responder view, and no other view.
+ * - While touches are still occurring, the responder lock can be transferred to
+ * a new view, but only to increasingly "higher" views (meaning ancestors of
+ * the current responder).
+ *
+ * Responder being granted:
+ * ------------------------
+ *
+ * - Touch starts, moves, and scrolls can cause an ID to become the responder.
+ * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to
+ * the "appropriate place".
+ * - If nothing is currently the responder, the "appropriate place" is the
+ * initiating event's `targetID`.
+ * - If something *is* already the responder, the "appropriate place" is the
+ * first common ancestor of the event target and the current `responderInst`.
+ * - Some negotiation happens: See the timing diagram below.
+ * - Scrolled views automatically become responder. The reasoning is that a
+ * platform scroll view that isn't built on top of the responder system has
+ * began scrolling, and the active responder must now be notified that the
+ * interaction is no longer locked to it - the system has taken over.
+ *
+ * - Responder being released:
+ * As soon as no more touches that *started* inside of descendants of the
+ * *current* responderInst, an `onResponderRelease` event is dispatched to the
+ * current responder, and the responder lock is released.
+ *
+ * TODO:
+ * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that
+ * determines if the responder lock should remain.
+ * - If a view shouldn't "remain" the responder, any active touches should by
+ * default be considered "dead" and do not influence future negotiations or
+ * bubble paths. It should be as if those touches do not exist.
+ * -- For multitouch: Usually a translate-z will choose to "remain" responder
+ * after one out of many touches ended. For translate-y, usually the view
+ * doesn't wish to "remain" responder after one of many touches end.
+ * - Consider building this on top of a `stopPropagation` model similar to
+ * `W3C` events.
+ * - Ensure that `onResponderTerminate` is called on touch cancels, whether or
+ * not `onResponderTerminationRequest` returns `true` or `false`.
+ *
+ */
+
+/* Negotiation Performed
+ +-----------------------+
+ / \
+Process low level events to + Current Responder + wantsResponderID
+determine who to perform negot-| (if any exists at all) |
+iation/transition | Otherwise just pass through|
+-------------------------------+----------------------------+------------------+
+Bubble to find first ID | |
+to return true:wantsResponderID| |
+ | |
+ +-------------+ | |
+ | onTouchStart| | |
+ +------+------+ none | |
+ | return| |
++-----------v-------------+true| +------------------------+ |
+|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+
++-----------+-------------+ | +------------------------+ | |
+ | | | +--------+-------+
+ | returned true for| false:REJECT +-------->|onResponderReject
+ | wantsResponderID | | | +----------------+
+ | (now attempt | +------------------+-----+ |
+ | handoff) | | onResponder | |
+ +------------------->| TerminationRequest| |
+ | +------------------+-----+ |
+ | | | +----------------+
+ | true:GRANT +-------->|onResponderGrant|
+ | | +--------+-------+
+ | +------------------------+ | |
+ | | onResponderTerminate |<-----------+
+ | +------------------+-----+ |
+ | | | +----------------+
+ | +-------->|onResponderStart|
+ | | +----------------+
+Bubble to find first ID | |
+to return true:wantsResponderID| |
+ | |
+ +-------------+ | |
+ | onTouchMove | | |
+ +------+------+ none | |
+ | return| |
++-----------v-------------+true| +------------------------+ |
+|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+
++-----------+-------------+ | +------------------------+ | |
+ | | | +--------+-------+
+ | returned true for| false:REJECT +-------->|onResponderRejec|
+ | wantsResponderID | | | +----------------+
+ | (now attempt | +------------------+-----+ |
+ | handoff) | | onResponder | |
+ +------------------->| TerminationRequest| |
+ | +------------------+-----+ |
+ | | | +----------------+
+ | true:GRANT +-------->|onResponderGrant|
+ | | +--------+-------+
+ | +------------------------+ | |
+ | | onResponderTerminate |<-----------+
+ | +------------------+-----+ |
+ | | | +----------------+
+ | +-------->|onResponderMove |
+ | | +----------------+
+ | |
+ | |
+ Some active touch started| |
+ inside current responder | +------------------------+ |
+ +------------------------->| onResponderEnd | |
+ | | +------------------------+ |
+ +---+---------+ | |
+ | onTouchEnd | | |
+ +---+---------+ | |
+ | | +------------------------+ |
+ +------------------------->| onResponderEnd | |
+ No active touches started| +-----------+------------+ |
+ inside current responder | | |
+ | v |
+ | +------------------------+ |
+ | | onResponderRelease | |
+ | +------------------------+ |
+ | |
+ + + */
+
+/**
+ * A note about event ordering in the `EventPluginRegistry`.
+ *
+ * Suppose plugins are injected in the following order:
+ *
+ * `[R, S, C]`
+ *
* To help illustrate the example, assume `S` is `SimpleEventPlugin` (for
* `onClick` etc) and `R` is `ResponderEventPlugin`.
*
@@ -2351,20 +2257,163 @@ function injectEventPluginsByName(injectedNamesToPlugins) {
}
}
+function getListener$1(inst, registrationName) {
+ var stateNode = inst.stateNode;
+
+ if (stateNode === null) {
+ // Work in progress (ex: onload events in incremental mode).
+ return null;
+ }
+
+ var props = getFiberCurrentPropsFromNode(stateNode);
+
+ if (props === null) {
+ // Work in progress.
+ return null;
+ }
+
+ var listener = props[registrationName];
+
+ if (!(!listener || typeof listener === "function")) {
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof listener +
+ "` type."
+ );
+ }
+
+ return listener;
+}
+
var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customBubblingEventTypes,
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
- .customDirectEventTypes;
+ .customDirectEventTypes; // Start of inline: the below functions were inlined from
+// EventPropagator.js, as they deviated from ReactDOM's newer
+// implementations.
+
+function listenerAtPhase$1(inst, event, propagationPhase) {
+ var registrationName =
+ event.dispatchConfig.phasedRegistrationNames[propagationPhase];
+ return getListener$1(inst, registrationName);
+}
+
+function accumulateDirectionalDispatches$1(inst, phase, event) {
+ {
+ if (!inst) {
+ error("Dispatching inst must not be null");
+ }
+ }
+
+ var listener = listenerAtPhase$1(inst, event, phase);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
+ }
+}
+
+function getParent$1(inst) {
+ do {
+ inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
+ // That is depending on if we want nested subtrees (layers) to bubble
+ // events to their parent. We could also go through parentNode on the
+ // host node but that wouldn't work for React Native and doesn't let us
+ // do the portal feature.
+ } while (inst && inst.tag !== HostComponent);
+
+ if (inst) {
+ return inst;
+ }
+
+ return null;
+}
+/**
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
+ */
+
+function traverseTwoPhase$1(inst, fn, arg) {
+ var path = [];
+
+ while (inst) {
+ path.push(inst);
+ inst = getParent$1(inst);
+ }
+
+ var i;
+
+ for (i = path.length; i-- > 0; ) {
+ fn(path[i], "captured", arg);
+ }
+
+ for (i = 0; i < path.length; i++) {
+ fn(path[i], "bubbled", arg);
+ }
+}
+
+function accumulateTwoPhaseDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event
+ );
+ }
+}
+
+function accumulateTwoPhaseDispatches$1(events) {
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1);
+}
+/**
+ * Accumulates without regard to direction, does not look for phased
+ * registration names. Same as `accumulateDirectDispatchesSingle` but without
+ * requiring that the `dispatchMarker` be the same as the dispatched ID.
+ */
+
+function accumulateDispatches$1(inst, ignoredDirection, event) {
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var registrationName = event.dispatchConfig.registrationName;
+ var listener = getListener$1(inst, registrationName);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
+ }
+ }
+}
+/**
+ * Accumulates dispatches on an `SyntheticEvent`, but only for the
+ * `dispatchMarker`.
+ * @param {SyntheticEvent} event
+ */
+
+function accumulateDirectDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ accumulateDispatches$1(event._targetInst, null, event);
+ }
+}
+
+function accumulateDirectDispatches$1(events) {
+ forEachAccumulated(events, accumulateDirectDispatchesSingle$1);
+} // End of inline
+
var ReactNativeBridgeEventPlugin = {
eventTypes: {},
extractEvents: function(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
) {
if (targetInst == null) {
// Probably a node belonging to another renderer's tree.
@@ -2388,9 +2437,9 @@ var ReactNativeBridgeEventPlugin = {
);
if (bubbleDispatchConfig) {
- accumulateTwoPhaseDispatches(event);
+ accumulateTwoPhaseDispatches$1(event);
} else if (directDispatchConfig) {
- accumulateDirectDispatches(event);
+ accumulateDirectDispatches$1(event);
} else {
return null;
}
@@ -2476,37 +2525,64 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler(
* If this becomes an actual Map, that will break.
*/
function get(key) {
- return key._reactInternalFiber;
+ return key._reactInternals;
}
function set(key, value) {
- key._reactInternalFiber = value;
+ key._reactInternals = value;
}
+// ATTENTION
+// When adding new symbols to this file,
+// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
-var hasSymbol = typeof Symbol === "function" && Symbol.for;
-var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7;
-var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca;
-var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb;
-var REACT_STRICT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.strict_mode")
- : 0xeacc;
-var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2;
-var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd;
-var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
-var REACT_CONCURRENT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.concurrent_mode")
- : 0xeacf;
-var REACT_FORWARD_REF_TYPE = hasSymbol
- ? Symbol.for("react.forward_ref")
- : 0xead0;
-var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1;
-var REACT_SUSPENSE_LIST_TYPE = hasSymbol
- ? Symbol.for("react.suspense_list")
- : 0xead8;
-var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3;
-var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4;
-var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 0xead9;
+var REACT_ELEMENT_TYPE = 0xeac7;
+var REACT_PORTAL_TYPE = 0xeaca;
+var REACT_FRAGMENT_TYPE = 0xeacb;
+var REACT_STRICT_MODE_TYPE = 0xeacc;
+var REACT_PROFILER_TYPE = 0xead2;
+var REACT_PROVIDER_TYPE = 0xeacd;
+var REACT_CONTEXT_TYPE = 0xeace;
+var REACT_FORWARD_REF_TYPE = 0xead0;
+var REACT_SUSPENSE_TYPE = 0xead1;
+var REACT_SUSPENSE_LIST_TYPE = 0xead8;
+var REACT_MEMO_TYPE = 0xead3;
+var REACT_LAZY_TYPE = 0xead4;
+var REACT_BLOCK_TYPE = 0xead9;
+var REACT_SERVER_BLOCK_TYPE = 0xeada;
+var REACT_FUNDAMENTAL_TYPE = 0xead5;
+var REACT_RESPONDER_TYPE = 0xead6;
+var REACT_SCOPE_TYPE = 0xead7;
+var REACT_OPAQUE_ID_TYPE = 0xeae0;
+var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
+var REACT_OFFSCREEN_TYPE = 0xeae2;
+var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
+
+if (typeof Symbol === "function" && Symbol.for) {
+ var symbolFor = Symbol.for;
+ REACT_ELEMENT_TYPE = symbolFor("react.element");
+ REACT_PORTAL_TYPE = symbolFor("react.portal");
+ REACT_FRAGMENT_TYPE = symbolFor("react.fragment");
+ REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
+ REACT_PROFILER_TYPE = symbolFor("react.profiler");
+ REACT_PROVIDER_TYPE = symbolFor("react.provider");
+ REACT_CONTEXT_TYPE = symbolFor("react.context");
+ REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
+ REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
+ REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
+ REACT_MEMO_TYPE = symbolFor("react.memo");
+ REACT_LAZY_TYPE = symbolFor("react.lazy");
+ REACT_BLOCK_TYPE = symbolFor("react.block");
+ REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block");
+ REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental");
+ REACT_RESPONDER_TYPE = symbolFor("react.responder");
+ REACT_SCOPE_TYPE = symbolFor("react.scope");
+ REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id");
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
+ REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
+}
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
function getIteratorFn(maybeIterable) {
@@ -2525,63 +2601,6 @@ function getIteratorFn(maybeIterable) {
return null;
}
-// TODO: Move this to "react" once we can import from externals.
-var Uninitialized = -1;
-var Pending = 0;
-var Resolved = 1;
-var Rejected = 2;
-
-function refineResolvedLazyComponent(lazyComponent) {
- return lazyComponent._status === Resolved ? lazyComponent._result : null;
-}
-function initializeLazyComponentType(lazyComponent) {
- if (lazyComponent._status === Uninitialized) {
- var ctor = lazyComponent._result;
-
- if (!ctor) {
- // TODO: Remove this later. THis only exists in case you use an older "react" package.
- ctor = lazyComponent._ctor;
- }
-
- var thenable = ctor(); // Transition to the next state.
-
- var pending = lazyComponent;
- pending._status = Pending;
- pending._result = thenable;
- thenable.then(
- function(moduleObject) {
- if (lazyComponent._status === Pending) {
- var defaultExport = moduleObject.default;
-
- {
- if (defaultExport === undefined) {
- error(
- "lazy: Expected the result of a dynamic import() call. " +
- "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies.
- "const MyComponent = lazy(() => imp" +
- "ort('./MyComponent'))",
- moduleObject
- );
- }
- } // Transition to the next state.
-
- var resolved = lazyComponent;
- resolved._status = Resolved;
- resolved._result = defaultExport;
- }
- },
- function(error) {
- if (lazyComponent._status === Pending) {
- // Transition to the next state.
- var rejected = lazyComponent;
- rejected._status = Rejected;
- rejected._result = error;
- }
- }
- );
- }
-}
-
function getWrappedName(outerType, innerType, wrapperName) {
var functionName = innerType.displayName || innerType.name || "";
return (
@@ -2654,17 +2673,18 @@ function getComponentName(type) {
return getComponentName(type.type);
case REACT_BLOCK_TYPE:
- return getComponentName(type.render);
+ return getComponentName(type._render);
case REACT_LAZY_TYPE: {
- var thenable = type;
- var resolvedThenable = refineResolvedLazyComponent(thenable);
+ var lazyComponent = type;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- if (resolvedThenable) {
- return getComponentName(resolvedThenable);
+ try {
+ return getComponentName(init(payload));
+ } catch (x) {
+ return null;
}
-
- break;
}
}
}
@@ -2674,65 +2694,75 @@ function getComponentName(type) {
// Don't change these two values. They're used by React Dev Tools.
var NoEffect =
- /* */
+ /* */
0;
var PerformedWork =
- /* */
+ /* */
1; // You can change the rest (and add more).
var Placement =
- /* */
+ /* */
2;
var Update =
- /* */
+ /* */
4;
var PlacementAndUpdate =
- /* */
+ /* */
6;
var Deletion =
- /* */
+ /* */
8;
var ContentReset =
- /* */
+ /* */
16;
var Callback =
- /* */
+ /* */
32;
var DidCapture =
- /* */
+ /* */
64;
var Ref =
- /* */
+ /* */
128;
var Snapshot =
- /* */
+ /* */
256;
var Passive =
- /* */
- 512;
+ /* */
+ 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old.
+
+var PassiveUnmountPendingDev =
+ /* */
+ 8192;
var Hydrating =
- /* */
+ /* */
1024;
var HydratingAndUpdate =
- /* */
+ /* */
1028; // Passive & Update & Callback & Ref & Snapshot
var LifecycleEffectMask =
- /* */
+ /* */
932; // Union of all host effects
var HostEffectMask =
- /* */
- 2047;
+ /* */
+ 2047; // These are not really side effects, but we still reuse this field.
+
var Incomplete =
- /* */
+ /* */
2048;
var ShouldCapture =
- /* */
+ /* */
4096;
+var ForceUpdateForLegacySuspense =
+ /* */
+ 16384; // Static tags describe aspects of a fiber that are not specific to a render,
+// The rest of the flags are static for better dead code elimination.
var enableProfilerTimer = true;
var warnAboutStringRefs = false;
+var enableNewReconciler = false;
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
function getNearestMountedFiber(fiber) {
@@ -3007,6 +3037,20 @@ function findCurrentHostFiber(parent) {
return null;
}
+function doesFiberContain(parentFiber, childFiber) {
+ var node = childFiber;
+ var parentFiberAlternate = parentFiber.alternate;
+
+ while (node !== null) {
+ if (node === parentFiber || node === parentFiberAlternate) {
+ return true;
+ }
+
+ node = node.return;
+ }
+
+ return false;
+}
/**
* In the future, we should cleanup callbacks by cancelling them instead of
@@ -3496,19 +3540,16 @@ function diff(prevProps, nextProps, validAttributes) {
);
}
-var PLUGIN_EVENT_SYSTEM = 1;
-
+// Used as a way to call batchedUpdates when we don't have a reference to
// the renderer. Such as when we're dispatching events or if third party
// libraries need to call batchedUpdates. Eventually, this API will go away when
// everything is batched by default. We'll then have a similar API to opt-out of
// scheduled work and instead do synchronous work.
// Defaults
-
var batchedUpdatesImpl = function(fn, bookkeeping) {
return fn(bookkeeping);
};
var isInsideEventHandler = false;
-
function batchedUpdates(fn, bookkeeping) {
if (isInsideEventHandler) {
// If we are currently inside another batch, we need to wait until it
@@ -3596,22 +3637,21 @@ function extractPluginEvents(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
) {
var events = null;
+ var legacyPlugins = plugins;
- for (var i = 0; i < plugins.length; i++) {
+ for (var i = 0; i < legacyPlugins.length; i++) {
// Not every plugin in the ordering may be loaded at runtime.
- var possiblePlugin = plugins[i];
+ var possiblePlugin = legacyPlugins[i];
if (possiblePlugin) {
var extractedEvents = possiblePlugin.extractEvents(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
);
if (extractedEvents) {
@@ -3627,15 +3667,13 @@ function runExtractedPluginEventsInBatch(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
) {
var events = extractPluginEvents(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
);
runEventsInBatch(events);
}
@@ -3658,8 +3696,7 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
topLevelType,
targetFiber,
nativeEvent,
- eventTarget,
- PLUGIN_EVENT_SYSTEM
+ eventTarget
);
}); // React Native doesn't use ReactControlledComponent but if it did, here's
// where it would do it.
@@ -3677,6 +3714,7 @@ function shim() {
var supportsMutation = false;
var commitMount = shim;
+var clearContainer = shim;
// can re-export everything from this module.
@@ -3896,617 +3934,425 @@ function getPublicInstance(instance) {
}
function prepareForCommit(containerInfo) {
// Noop
-}
-function prepareUpdate(
- instance,
- type,
- oldProps,
- newProps,
- rootContainerInstance,
- hostContext
-) {
- var viewConfig = instance.canonical.viewConfig;
- var updatePayload = diff(oldProps, newProps, viewConfig.validAttributes); // TODO: If the event handlers have changed, we need to update the current props
- // in the commit phase but there is no host config hook to do it yet.
- // So instead we hack it by updating it in the render phase.
-
- instance.canonical.currentProps = newProps;
- return updatePayload;
-}
-function resetAfterCommit(containerInfo) {
- // Noop
-}
-function shouldDeprioritizeSubtree(type, props) {
- return false;
-}
-function shouldSetTextContent(type, props) {
- // TODO (bvaughn) Revisit this decision.
- // Always returning false simplifies the createInstance() implementation,
- // But creates an additional child Fiber for raw text children.
- // No additional native views are created though.
- // It's not clear to me which is better so I'm deferring for now.
- // More context @ github.com/facebook/react/pull/8560#discussion_r92111303
- return false;
-} // The Fabric renderer is secondary to the existing React Native renderer.
-var scheduleTimeout = setTimeout;
-var cancelTimeout = clearTimeout;
-var noTimeout = -1; // -------------------
-function cloneInstance(
- instance,
- updatePayload,
- type,
- oldProps,
- newProps,
- internalInstanceHandle,
- keepChildren,
- recyclableInstance
-) {
- var node = instance.node;
- var clone;
-
- if (keepChildren) {
- if (updatePayload !== null) {
- clone = cloneNodeWithNewProps(node, updatePayload);
- } else {
- clone = cloneNode(node);
- }
- } else {
- if (updatePayload !== null) {
- clone = cloneNodeWithNewChildrenAndProps(node, updatePayload);
- } else {
- clone = cloneNodeWithNewChildren(node);
- }
- }
-
- return {
- node: clone,
- canonical: instance.canonical
- };
-}
-function cloneHiddenInstance(instance, type, props, internalInstanceHandle) {
- var viewConfig = instance.canonical.viewConfig;
- var node = instance.node;
- var updatePayload = create(
- {
- style: {
- display: "none"
- }
- },
- viewConfig.validAttributes
- );
- return {
- node: cloneNodeWithNewProps(node, updatePayload),
- canonical: instance.canonical
- };
-}
-function cloneHiddenTextInstance(instance, text, internalInstanceHandle) {
- throw new Error("Not yet implemented.");
-}
-function createContainerChildSet(container) {
- return createChildNodeSet(container);
-}
-function appendChildToContainerChildSet(childSet, child) {
- appendChildNodeToSet(childSet, child.node);
-}
-function finalizeContainerChildren(container, newChildren) {
- completeRoot(container, newChildren);
-}
-
-var loggedTypeFailures = {};
-function checkPropTypes(typeSpecs, values, location, componentName) {
- {
- // $FlowFixMe This is okay but Flow doesn't know it.
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
-
- for (var typeSpecName in typeSpecs) {
- if (has(typeSpecs, typeSpecName)) {
- var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
- // fail the render phase where it didn't fail before. So we log it.
- // After these have been cleaned up, we'll let them throw.
-
- try {
- // This is intentionally an invariant that gets caught. It's the same
- // behavior as without this statement except with a better message.
- if (typeof typeSpecs[typeSpecName] !== "function") {
- var err = Error(
- (componentName || "React class") +
- ": " +
- location +
- " type `" +
- typeSpecName +
- "` is invalid; " +
- "it must be a function, usually from the `prop-types` package, but received `" +
- typeof typeSpecs[typeSpecName] +
- "`." +
- "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
- );
- err.name = "Invariant Violation";
- throw err;
- }
-
- error$1 = typeSpecs[typeSpecName](
- values,
- typeSpecName,
- componentName,
- location,
- null,
- "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"
- );
- } catch (ex) {
- error$1 = ex;
- }
-
- if (error$1 && !(error$1 instanceof Error)) {
- error(
- "%s: type specification of %s" +
- " `%s` is invalid; the type checker " +
- "function must return `null` or an `Error` but returned a %s. " +
- "You may have forgotten to pass an argument to the type checker " +
- "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " +
- "shape all require an argument).",
- componentName || "React class",
- location,
- typeSpecName,
- typeof error$1
- );
- }
-
- if (
- error$1 instanceof Error &&
- !(error$1.message in loggedTypeFailures)
- ) {
- // Only monitor this failure once because there tends to be a lot of the
- // same error.
- loggedTypeFailures[error$1.message] = true;
-
- error("Failed %s type: %s", location, error$1.message);
- }
- }
- }
- }
-}
-
-// Prefix measurements so that it's possible to filter them.
-// Longer prefixes are hard to read in DevTools.
-var reactEmoji = "\u269B";
-var warningEmoji = "\u26D4";
-var supportsUserTiming =
- typeof performance !== "undefined" &&
- typeof performance.mark === "function" &&
- typeof performance.clearMarks === "function" &&
- typeof performance.measure === "function" &&
- typeof performance.clearMeasures === "function"; // Keep track of current fiber so that we know the path to unwind on pause.
-// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
-
-var currentFiber = null; // If we're in the middle of user code, which fiber and method is it?
-// Reusing `currentFiber` would be confusing for this because user code fiber
-// can change during commit phase too, but we don't need to unwind it (since
-// lifecycles in the commit phase don't resemble a tree).
-
-var currentPhase = null;
-var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem,
-// so we will keep track of it, and include it in the report.
-// Track commits caused by cascading updates.
-
-var isCommitting = false;
-var hasScheduledUpdateInCurrentCommit = false;
-var hasScheduledUpdateInCurrentPhase = false;
-var commitCountInCurrentWorkLoop = 0;
-var effectCountInCurrentCommit = 0;
-// to avoid stretch the commit phase with measurement overhead.
-
-var labelsInCurrentCommit = new Set();
-
-var formatMarkName = function(markName) {
- return reactEmoji + " " + markName;
-};
-
-var formatLabel = function(label, warning) {
- var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
- var suffix = warning ? " Warning: " + warning : "";
- return "" + prefix + label + suffix;
-};
-
-var beginMark = function(markName) {
- performance.mark(formatMarkName(markName));
-};
-
-var clearMark = function(markName) {
- performance.clearMarks(formatMarkName(markName));
-};
-
-var endMark = function(label, markName, warning) {
- var formattedMarkName = formatMarkName(markName);
- var formattedLabel = formatLabel(label, warning);
-
- try {
- performance.measure(formattedLabel, formattedMarkName);
- } catch (err) {} // If previous mark was missing for some reason, this will throw.
- // This could only happen if React crashed in an unexpected place earlier.
- // Don't pile on with more errors.
- // Clear marks immediately to avoid growing buffer.
-
- performance.clearMarks(formattedMarkName);
- performance.clearMeasures(formattedLabel);
-};
-
-var getFiberMarkName = function(label, debugID) {
- return label + " (#" + debugID + ")";
-};
-
-var getFiberLabel = function(componentName, isMounted, phase) {
- if (phase === null) {
- // These are composite component total time measurements.
- return componentName + " [" + (isMounted ? "update" : "mount") + "]";
- } else {
- // Composite component methods.
- return componentName + "." + phase;
- }
-};
-
-var beginFiberMark = function(fiber, phase) {
- var componentName = getComponentName(fiber.type) || "Unknown";
- var debugID = fiber._debugID;
- var isMounted = fiber.alternate !== null;
- var label = getFiberLabel(componentName, isMounted, phase);
-
- if (isCommitting && labelsInCurrentCommit.has(label)) {
- // During the commit phase, we don't show duplicate labels because
- // there is a fixed overhead for every measurement, and we don't
- // want to stretch the commit phase beyond necessary.
- return false;
- }
-
- labelsInCurrentCommit.add(label);
- var markName = getFiberMarkName(label, debugID);
- beginMark(markName);
- return true;
-};
-
-var clearFiberMark = function(fiber, phase) {
- var componentName = getComponentName(fiber.type) || "Unknown";
- var debugID = fiber._debugID;
- var isMounted = fiber.alternate !== null;
- var label = getFiberLabel(componentName, isMounted, phase);
- var markName = getFiberMarkName(label, debugID);
- clearMark(markName);
-};
-
-var endFiberMark = function(fiber, phase, warning) {
- var componentName = getComponentName(fiber.type) || "Unknown";
- var debugID = fiber._debugID;
- var isMounted = fiber.alternate !== null;
- var label = getFiberLabel(componentName, isMounted, phase);
- var markName = getFiberMarkName(label, debugID);
- endMark(label, markName, warning);
-};
-
-var shouldIgnoreFiber = function(fiber) {
- // Host components should be skipped in the timeline.
- // We could check typeof fiber.type, but does this work with RN?
- switch (fiber.tag) {
- case HostRoot:
- case HostComponent:
- case HostText:
- case HostPortal:
- case Fragment:
- case ContextProvider:
- case ContextConsumer:
- case Mode:
- return true;
-
- default:
- return false;
- }
-};
-
-var clearPendingPhaseMeasurement = function() {
- if (currentPhase !== null && currentPhaseFiber !== null) {
- clearFiberMark(currentPhaseFiber, currentPhase);
- }
-
- currentPhaseFiber = null;
- currentPhase = null;
- hasScheduledUpdateInCurrentPhase = false;
-};
+ return null;
+}
+function prepareUpdate(
+ instance,
+ type,
+ oldProps,
+ newProps,
+ rootContainerInstance,
+ hostContext
+) {
+ var viewConfig = instance.canonical.viewConfig;
+ var updatePayload = diff(oldProps, newProps, viewConfig.validAttributes); // TODO: If the event handlers have changed, we need to update the current props
+ // in the commit phase but there is no host config hook to do it yet.
+ // So instead we hack it by updating it in the render phase.
-var pauseTimers = function() {
- // Stops all currently active measurements so that they can be resumed
- // if we continue in a later deferred loop from the same unit of work.
- var fiber = currentFiber;
+ instance.canonical.currentProps = newProps;
+ return updatePayload;
+}
+function resetAfterCommit(containerInfo) {
+ // Noop
+}
+function shouldSetTextContent(type, props) {
+ // TODO (bvaughn) Revisit this decision.
+ // Always returning false simplifies the createInstance() implementation,
+ // But creates an additional child Fiber for raw text children.
+ // No additional native views are created though.
+ // It's not clear to me which is better so I'm deferring for now.
+ // More context @ github.com/facebook/react/pull/8560#discussion_r92111303
+ return false;
+} // The Fabric renderer is secondary to the existing React Native renderer.
+var scheduleTimeout = setTimeout;
+var cancelTimeout = clearTimeout;
+var noTimeout = -1; // -------------------
+function cloneInstance(
+ instance,
+ updatePayload,
+ type,
+ oldProps,
+ newProps,
+ internalInstanceHandle,
+ keepChildren,
+ recyclableInstance
+) {
+ var node = instance.node;
+ var clone;
- while (fiber) {
- if (fiber._debugIsCurrentlyTiming) {
- endFiberMark(fiber, null, null);
+ if (keepChildren) {
+ if (updatePayload !== null) {
+ clone = cloneNodeWithNewProps(node, updatePayload);
+ } else {
+ clone = cloneNode(node);
+ }
+ } else {
+ if (updatePayload !== null) {
+ clone = cloneNodeWithNewChildrenAndProps(node, updatePayload);
+ } else {
+ clone = cloneNodeWithNewChildren(node);
}
-
- fiber = fiber.return;
}
-};
-var resumeTimersRecursively = function(fiber) {
- if (fiber.return !== null) {
- resumeTimersRecursively(fiber.return);
- }
+ return {
+ node: clone,
+ canonical: instance.canonical
+ };
+}
+function cloneHiddenInstance(instance, type, props, internalInstanceHandle) {
+ var viewConfig = instance.canonical.viewConfig;
+ var node = instance.node;
+ var updatePayload = create(
+ {
+ style: {
+ display: "none"
+ }
+ },
+ viewConfig.validAttributes
+ );
+ return {
+ node: cloneNodeWithNewProps(node, updatePayload),
+ canonical: instance.canonical
+ };
+}
+function cloneHiddenTextInstance(instance, text, internalInstanceHandle) {
+ throw new Error("Not yet implemented.");
+}
+function createContainerChildSet(container) {
+ return createChildNodeSet(container);
+}
+function appendChildToContainerChildSet(childSet, child) {
+ appendChildNodeToSet(childSet, child.node);
+}
+function finalizeContainerChildren(container, newChildren) {
+ completeRoot(container, newChildren);
+}
+function makeClientIdInDEV(warnOnAccessInDEV) {
+ throw new Error("Not yet implemented");
+}
+function preparePortalMount(portalInstance) {
+ // noop
+}
- if (fiber._debugIsCurrentlyTiming) {
- beginFiberMark(fiber, null);
- }
-};
+// Helpers to patch console.logs to avoid logging during side-effect free
+// replaying on render function. This currently only patches the object
+// lazily which won't cover if the log function was extracted eagerly.
+// We could also eagerly patch the method.
+var disabledDepth = 0;
+var prevLog;
+var prevInfo;
+var prevWarn;
+var prevError;
+var prevGroup;
+var prevGroupCollapsed;
+var prevGroupEnd;
-var resumeTimers = function() {
- // Resumes all measurements that were active during the last deferred loop.
- if (currentFiber !== null) {
- resumeTimersRecursively(currentFiber);
- }
-};
+function disabledLog() {}
-function recordEffect() {
+disabledLog.__reactDisabledLog = true;
+function disableLogs() {
{
- effectCountInCurrentCommit++;
+ if (disabledDepth === 0) {
+ /* eslint-disable react-internal/no-production-logging */
+ prevLog = console.log;
+ prevInfo = console.info;
+ prevWarn = console.warn;
+ prevError = console.error;
+ prevGroup = console.group;
+ prevGroupCollapsed = console.groupCollapsed;
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
+
+ var props = {
+ configurable: true,
+ enumerable: true,
+ value: disabledLog,
+ writable: true
+ }; // $FlowFixMe Flow thinks console is immutable.
+
+ Object.defineProperties(console, {
+ info: props,
+ log: props,
+ warn: props,
+ error: props,
+ group: props,
+ groupCollapsed: props,
+ groupEnd: props
+ });
+ /* eslint-enable react-internal/no-production-logging */
+ }
+
+ disabledDepth++;
}
}
-function recordScheduleUpdate() {
+function reenableLogs() {
{
- if (isCommitting) {
- hasScheduledUpdateInCurrentCommit = true;
+ disabledDepth--;
+
+ if (disabledDepth === 0) {
+ /* eslint-disable react-internal/no-production-logging */
+ var props = {
+ configurable: true,
+ enumerable: true,
+ writable: true
+ }; // $FlowFixMe Flow thinks console is immutable.
+
+ Object.defineProperties(console, {
+ log: Object.assign({}, props, {
+ value: prevLog
+ }),
+ info: Object.assign({}, props, {
+ value: prevInfo
+ }),
+ warn: Object.assign({}, props, {
+ value: prevWarn
+ }),
+ error: Object.assign({}, props, {
+ value: prevError
+ }),
+ group: Object.assign({}, props, {
+ value: prevGroup
+ }),
+ groupCollapsed: Object.assign({}, props, {
+ value: prevGroupCollapsed
+ }),
+ groupEnd: Object.assign({}, props, {
+ value: prevGroupEnd
+ })
+ });
+ /* eslint-enable react-internal/no-production-logging */
}
- if (
- currentPhase !== null &&
- currentPhase !== "componentWillMount" &&
- currentPhase !== "componentWillReceiveProps"
- ) {
- hasScheduledUpdateInCurrentPhase = true;
+ if (disabledDepth < 0) {
+ error(
+ "disabledDepth fell below zero. " +
+ "This is a bug in React. Please file an issue."
+ );
}
}
}
-function startWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // If we pause, this is the fiber to unwind from.
- currentFiber = fiber;
+var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
+function describeBuiltInComponentFrame(name, source, ownerFn) {
+ {
+ var ownerName = null;
- if (!beginFiberMark(fiber, null)) {
- return;
+ if (ownerFn) {
+ ownerName = ownerFn.displayName || ownerFn.name || null;
}
- fiber._debugIsCurrentlyTiming = true;
+ return describeComponentFrame(name, source, ownerName);
}
}
-function cancelWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // Remember we shouldn't complete measurement for this fiber.
- // Otherwise flamechart will be deep even for small updates.
+var componentFrameCache;
- fiber._debugIsCurrentlyTiming = false;
- clearFiberMark(fiber, null);
- }
+{
+ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
+ componentFrameCache = new PossiblyWeakMap();
}
-function stopWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // If we pause, its parent is the fiber to unwind from.
+var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
- currentFiber = fiber.return;
+function describeComponentFrame(name, source, ownerName) {
+ var sourceInfo = "";
- if (!fiber._debugIsCurrentlyTiming) {
- return;
- }
+ if (source) {
+ var path = source.fileName;
+ var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case:
+ // prefer "folder/index.js" instead of just "index.js".
- fiber._debugIsCurrentlyTiming = false;
- endFiberMark(fiber, null, null);
- }
-}
-function stopFailedWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // If we pause, its parent is the fiber to unwind from.
+ if (/^index\./.test(fileName)) {
+ var match = path.match(BEFORE_SLASH_RE);
- currentFiber = fiber.return;
+ if (match) {
+ var pathBeforeSlash = match[1];
- if (!fiber._debugIsCurrentlyTiming) {
- return;
+ if (pathBeforeSlash) {
+ var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, "");
+ fileName = folderName + "/" + fileName;
+ }
+ }
}
- fiber._debugIsCurrentlyTiming = false;
- var warning =
- fiber.tag === SuspenseComponent
- ? "Rendering was suspended"
- : "An error was thrown inside this error boundary";
- endFiberMark(fiber, null, warning);
+ sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")";
+ } else if (ownerName) {
+ sourceInfo = " (created by " + ownerName + ")";
}
-}
-function startPhaseTimer(fiber, phase) {
- {
- if (!supportsUserTiming) {
- return;
- }
- clearPendingPhaseMeasurement();
-
- if (!beginFiberMark(fiber, phase)) {
- return;
- }
+ return "\n in " + (name || "Unknown") + sourceInfo;
+}
- currentPhaseFiber = fiber;
- currentPhase = phase;
+function describeClassComponentFrame(ctor, source, ownerFn) {
+ {
+ return describeFunctionComponentFrame(ctor, source, ownerFn);
}
}
-function stopPhaseTimer() {
+function describeFunctionComponentFrame(fn, source, ownerFn) {
{
- if (!supportsUserTiming) {
- return;
+ if (!fn) {
+ return "";
}
- if (currentPhase !== null && currentPhaseFiber !== null) {
- var warning = hasScheduledUpdateInCurrentPhase
- ? "Scheduled a cascading update"
- : null;
- endFiberMark(currentPhaseFiber, currentPhase, warning);
+ var name = fn.displayName || fn.name || null;
+ var ownerName = null;
+
+ if (ownerFn) {
+ ownerName = ownerFn.displayName || ownerFn.name || null;
}
- currentPhase = null;
- currentPhaseFiber = null;
+ return describeComponentFrame(name, source, ownerName);
}
}
-function startWorkLoopTimer(nextUnitOfWork) {
- {
- currentFiber = nextUnitOfWork;
- if (!supportsUserTiming) {
- return;
+function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
+ if (type == null) {
+ return "";
+ }
+
+ if (typeof type === "function") {
+ {
+ return describeFunctionComponentFrame(type, source, ownerFn);
}
+ }
- commitCountInCurrentWorkLoop = 0; // This is top level call.
- // Any other measurements are performed within.
+ if (typeof type === "string") {
+ return describeBuiltInComponentFrame(type, source, ownerFn);
+ }
- beginMark("(React Tree Reconciliation)"); // Resume any measurements that were in progress during the last loop.
+ switch (type) {
+ case REACT_SUSPENSE_TYPE:
+ return describeBuiltInComponentFrame("Suspense", source, ownerFn);
- resumeTimers();
+ case REACT_SUSPENSE_LIST_TYPE:
+ return describeBuiltInComponentFrame("SuspenseList", source, ownerFn);
}
-}
-function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
- {
- if (!supportsUserTiming) {
- return;
- }
- var warning = null;
+ if (typeof type === "object") {
+ switch (type.$$typeof) {
+ case REACT_FORWARD_REF_TYPE:
+ return describeFunctionComponentFrame(type.render, source, ownerFn);
- if (interruptedBy !== null) {
- if (interruptedBy.tag === HostRoot) {
- warning = "A top-level update interrupted the previous render";
- } else {
- var componentName = getComponentName(interruptedBy.type) || "Unknown";
- warning =
- "An update to " + componentName + " interrupted the previous render";
- }
- } else if (commitCountInCurrentWorkLoop > 1) {
- warning = "There were cascading updates";
- }
+ case REACT_MEMO_TYPE:
+ // Memo may contain any component type so we recursively resolve it.
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
+
+ case REACT_BLOCK_TYPE:
+ return describeFunctionComponentFrame(type._render, source, ownerFn);
- commitCountInCurrentWorkLoop = 0;
- var label = didCompleteRoot
- ? "(React Tree Reconciliation: Completed Root)"
- : "(React Tree Reconciliation: Yielded)"; // Pause any measurements until the next loop.
+ case REACT_LAZY_TYPE: {
+ var lazyComponent = type;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- pauseTimers();
- endMark(label, "(React Tree Reconciliation)", warning);
+ try {
+ // Lazy may contain any component type so we recursively resolve it.
+ return describeUnknownElementTypeFrameInDEV(
+ init(payload),
+ source,
+ ownerFn
+ );
+ } catch (x) {}
+ }
+ }
}
+
+ return "";
}
-function startCommitTimer() {
+
+var loggedTypeFailures = {};
+var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
+
+function setCurrentlyValidatingElement(element) {
{
- if (!supportsUserTiming) {
- return;
+ if (element) {
+ var owner = element._owner;
+ var stack = describeUnknownElementTypeFrameInDEV(
+ element.type,
+ element._source,
+ owner ? owner.type : null
+ );
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
+ } else {
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
}
-
- isCommitting = true;
- hasScheduledUpdateInCurrentCommit = false;
- labelsInCurrentCommit.clear();
- beginMark("(Committing Changes)");
}
}
-function stopCommitTimer() {
+
+function checkPropTypes(typeSpecs, values, location, componentName, element) {
{
- if (!supportsUserTiming) {
- return;
- }
+ // $FlowFixMe This is okay but Flow doesn't know it.
+ var has = Function.call.bind(Object.prototype.hasOwnProperty);
- var warning = null;
+ for (var typeSpecName in typeSpecs) {
+ if (has(typeSpecs, typeSpecName)) {
+ var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
+ // fail the render phase where it didn't fail before. So we log it.
+ // After these have been cleaned up, we'll let them throw.
- if (hasScheduledUpdateInCurrentCommit) {
- warning = "Lifecycle hook scheduled a cascading update";
- } else if (commitCountInCurrentWorkLoop > 0) {
- warning = "Caused by a cascading update in earlier commit";
- }
+ try {
+ // This is intentionally an invariant that gets caught. It's the same
+ // behavior as without this statement except with a better message.
+ if (typeof typeSpecs[typeSpecName] !== "function") {
+ var err = Error(
+ (componentName || "React class") +
+ ": " +
+ location +
+ " type `" +
+ typeSpecName +
+ "` is invalid; " +
+ "it must be a function, usually from the `prop-types` package, but received `" +
+ typeof typeSpecs[typeSpecName] +
+ "`." +
+ "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
+ );
+ err.name = "Invariant Violation";
+ throw err;
+ }
- hasScheduledUpdateInCurrentCommit = false;
- commitCountInCurrentWorkLoop++;
- isCommitting = false;
- labelsInCurrentCommit.clear();
- endMark("(Committing Changes)", "(Committing Changes)", warning);
- }
-}
-function startCommitSnapshotEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ error$1 = typeSpecs[typeSpecName](
+ values,
+ typeSpecName,
+ componentName,
+ location,
+ null,
+ "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"
+ );
+ } catch (ex) {
+ error$1 = ex;
+ }
- effectCountInCurrentCommit = 0;
- beginMark("(Committing Snapshot Effects)");
- }
-}
-function stopCommitSnapshotEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ if (error$1 && !(error$1 instanceof Error)) {
+ setCurrentlyValidatingElement(element);
- var count = effectCountInCurrentCommit;
- effectCountInCurrentCommit = 0;
- endMark(
- "(Committing Snapshot Effects: " + count + " Total)",
- "(Committing Snapshot Effects)",
- null
- );
- }
-}
-function startCommitHostEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ error(
+ "%s: type specification of %s" +
+ " `%s` is invalid; the type checker " +
+ "function must return `null` or an `Error` but returned a %s. " +
+ "You may have forgotten to pass an argument to the type checker " +
+ "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " +
+ "shape all require an argument).",
+ componentName || "React class",
+ location,
+ typeSpecName,
+ typeof error$1
+ );
- effectCountInCurrentCommit = 0;
- beginMark("(Committing Host Effects)");
- }
-}
-function stopCommitHostEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ setCurrentlyValidatingElement(null);
+ }
- var count = effectCountInCurrentCommit;
- effectCountInCurrentCommit = 0;
- endMark(
- "(Committing Host Effects: " + count + " Total)",
- "(Committing Host Effects)",
- null
- );
- }
-}
-function startCommitLifeCyclesTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ if (
+ error$1 instanceof Error &&
+ !(error$1.message in loggedTypeFailures)
+ ) {
+ // Only monitor this failure once because there tends to be a lot of the
+ // same error.
+ loggedTypeFailures[error$1.message] = true;
+ setCurrentlyValidatingElement(element);
- effectCountInCurrentCommit = 0;
- beginMark("(Calling Lifecycle Methods)");
- }
-}
-function stopCommitLifeCyclesTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ error("Failed %s type: %s", location, error$1.message);
- var count = effectCountInCurrentCommit;
- effectCountInCurrentCommit = 0;
- endMark(
- "(Calling Lifecycle Methods: " + count + " Total)",
- "(Calling Lifecycle Methods)",
- null
- );
+ setCurrentlyValidatingElement(null);
+ }
+ }
+ }
}
}
@@ -4713,10 +4559,7 @@ function processChildContext(fiber, type, parentContext) {
return parentContext;
}
- var childContext;
- startPhaseTimer(fiber, "getChildContext");
- childContext = instance.getChildContext();
- stopPhaseTimer();
+ var childContext = instance.getChildContext();
for (var contextKey in childContext) {
if (!(contextKey in childContextTypes)) {
@@ -4837,20 +4680,112 @@ var LegacyRoot = 0;
var BlockingRoot = 1;
var ConcurrentRoot = 2;
+var rendererID = null;
+var injectedHook = null;
+var hasLoggedError = false;
+var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
+function injectInternals(internals) {
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") {
+ // No DevTools
+ return false;
+ }
+
+ var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+
+ if (hook.isDisabled) {
+ // This isn't a real property on the hook, but it can be set to opt out
+ // of DevTools integration and associated warnings and logs.
+ // https://github.com/facebook/react/issues/3877
+ return true;
+ }
+
+ if (!hook.supportsFiber) {
+ {
+ error(
+ "The installed version of React DevTools is too old and will not work " +
+ "with the current version of React. Please update React DevTools. " +
+ "https://fb.me/react-devtools"
+ );
+ } // DevTools exists, even though it doesn't support Fiber.
+
+ return true;
+ }
+
+ try {
+ rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
+
+ injectedHook = hook;
+ } catch (err) {
+ // Catch all errors because it is unsafe to throw during initialization.
+ {
+ error("React instrumentation encountered an error: %s.", err);
+ }
+ } // DevTools exists
+
+ return true;
+}
+function onScheduleRoot(root, children) {
+ {
+ if (
+ injectedHook &&
+ typeof injectedHook.onScheduleFiberRoot === "function"
+ ) {
+ try {
+ injectedHook.onScheduleFiberRoot(rendererID, root, children);
+ } catch (err) {
+ if (!hasLoggedError) {
+ hasLoggedError = true;
+
+ error("React instrumentation encountered an error: %s", err);
+ }
+ }
+ }
+ }
+}
+function onCommitRoot(root, priorityLevel) {
+ if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") {
+ try {
+ var didError = (root.current.effectTag & DidCapture) === DidCapture;
+
+ if (enableProfilerTimer) {
+ injectedHook.onCommitFiberRoot(
+ rendererID,
+ root,
+ priorityLevel,
+ didError
+ );
+ } else {
+ injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError);
+ }
+ } catch (err) {
+ {
+ if (!hasLoggedError) {
+ hasLoggedError = true;
+
+ error("React instrumentation encountered an error: %s", err);
+ }
+ }
+ }
+ }
+}
+function onCommitUnmount(fiber) {
+ if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") {
+ try {
+ injectedHook.onCommitFiberUnmount(rendererID, fiber);
+ } catch (err) {
+ {
+ if (!hasLoggedError) {
+ hasLoggedError = true;
+
+ error("React instrumentation encountered an error: %s", err);
+ }
+ }
+ }
+ }
+}
+
// Intentionally not named imports because Rollup would use dynamic dispatch for
-var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
- Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
- Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
- Scheduler_shouldYield = Scheduler.unstable_shouldYield,
- Scheduler_requestPaint = Scheduler.unstable_requestPaint,
- Scheduler_now = Scheduler.unstable_now,
- Scheduler_getCurrentPriorityLevel =
- Scheduler.unstable_getCurrentPriorityLevel,
- Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
- Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
- Scheduler_NormalPriority = Scheduler.unstable_NormalPriority,
- Scheduler_LowPriority = Scheduler.unstable_LowPriority,
- Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
+var Scheduler_now = Scheduler.unstable_now;
{
// Provide explicit error message when production+profiling bundle of e.g.
@@ -4867,8 +4802,6 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
);
}
}
-
-var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
// ascending numbers so we can compare them like numbers. They start at 90 to
// avoid clashing with Scheduler's priorities.
@@ -4879,1214 +4812,1458 @@ var LowPriority = 96;
var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
var NoPriority = 90;
-var shouldYield = Scheduler_shouldYield;
-var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
- Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {};
-var syncQueue = null;
-var immediateQueueCallbackNode = null;
-var isFlushingSyncQueue = false;
var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
-// This will be the case for modern browsers that support `performance.now`. In
-// older browsers, Scheduler falls back to `Date.now`, which returns a Unix
-// timestamp. In that case, subtract the module initialization time to simulate
-// the behavior of performance.now and keep our times small enough to fit
-// within 32 bits.
-// TODO: Consider lifting this into Scheduler.
-
-var now =
- initialTimeMs < 10000
- ? Scheduler_now
- : function() {
- return Scheduler_now() - initialTimeMs;
- };
-function getCurrentPriorityLevel() {
- switch (Scheduler_getCurrentPriorityLevel()) {
- case Scheduler_ImmediatePriority:
- return ImmediatePriority;
-
- case Scheduler_UserBlockingPriority:
- return UserBlockingPriority;
-
- case Scheduler_NormalPriority:
- return NormalPriority;
-
- case Scheduler_LowPriority:
- return LowPriority;
-
- case Scheduler_IdlePriority:
- return IdlePriority;
-
- default: {
- throw Error("Unknown priority level.");
- }
- }
-}
-
-function reactPriorityToSchedulerPriority(reactPriorityLevel) {
- switch (reactPriorityLevel) {
- case ImmediatePriority:
- return Scheduler_ImmediatePriority;
-
- case UserBlockingPriority:
- return Scheduler_UserBlockingPriority;
-
- case NormalPriority:
- return Scheduler_NormalPriority;
-
- case LowPriority:
- return Scheduler_LowPriority;
-
- case IdlePriority:
- return Scheduler_IdlePriority;
-
- default: {
- throw Error("Unknown priority level.");
- }
- }
-}
-
-function runWithPriority(reactPriorityLevel, fn) {
- var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
- return Scheduler_runWithPriority(priorityLevel, fn);
-}
-function scheduleCallback(reactPriorityLevel, callback, options) {
- var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
- return Scheduler_scheduleCallback(priorityLevel, callback, options);
-}
-function scheduleSyncCallback(callback) {
- // Push this callback into an internal queue. We'll flush these either in
- // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
- if (syncQueue === null) {
- syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
-
- immediateQueueCallbackNode = Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueueImpl
- );
- } else {
- // Push onto existing queue. Don't need to schedule a callback because
- // we already scheduled one when we created the queue.
- syncQueue.push(callback);
- }
-
- return fakeCallbackNode;
-}
-function cancelCallback(callbackNode) {
- if (callbackNode !== fakeCallbackNode) {
- Scheduler_cancelCallback(callbackNode);
- }
-}
-function flushSyncCallbackQueue() {
- if (immediateQueueCallbackNode !== null) {
- var node = immediateQueueCallbackNode;
- immediateQueueCallbackNode = null;
- Scheduler_cancelCallback(node);
- }
-
- flushSyncCallbackQueueImpl();
-}
-
-function flushSyncCallbackQueueImpl() {
- if (!isFlushingSyncQueue && syncQueue !== null) {
- // Prevent re-entrancy.
- isFlushingSyncQueue = true;
- var i = 0;
-
- try {
- var _isSync = true;
- var queue = syncQueue;
- runWithPriority(ImmediatePriority, function() {
- for (; i < queue.length; i++) {
- var callback = queue[i];
- do {
- callback = callback(_isSync);
- } while (callback !== null);
- }
- });
- syncQueue = null;
- } catch (error) {
- // If something throws, leave the remaining callbacks on the queue.
- if (syncQueue !== null) {
- syncQueue = syncQueue.slice(i + 1);
- } // Resume flushing in the next tick
+var SyncLanePriority = 17;
+var SyncBatchedLanePriority = 16;
+var InputDiscreteHydrationLanePriority = 15;
+var InputDiscreteLanePriority = 14;
+var InputContinuousHydrationLanePriority = 13;
+var InputContinuousLanePriority = 12;
+var DefaultHydrationLanePriority = 11;
+var DefaultLanePriority = 10;
+var TransitionShortHydrationLanePriority = 9;
+var TransitionShortLanePriority = 8;
+var TransitionLongHydrationLanePriority = 7;
+var TransitionLongLanePriority = 6;
+var RetryLanePriority = 5;
+var SelectiveHydrationLanePriority = 4;
+var IdleHydrationLanePriority = 3;
+var IdleLanePriority = 2;
+var OffscreenLanePriority = 1;
+var NoLanePriority = 0;
+var TotalLanes = 31;
+var NoLanes =
+ /* */
+ 0;
+var NoLane =
+ /* */
+ 0;
+var SyncLane =
+ /* */
+ 1;
+var SyncBatchedLane =
+ /* */
+ 2;
+var InputDiscreteHydrationLane =
+ /* */
+ 4;
+var InputDiscreteLanes =
+ /* */
+ 24;
+var InputContinuousHydrationLane =
+ /* */
+ 32;
+var InputContinuousLanes =
+ /* */
+ 192;
+var DefaultHydrationLane =
+ /* */
+ 256;
+var DefaultLanes =
+ /* */
+ 3584;
+var TransitionShortHydrationLane =
+ /* */
+ 4096;
+var TransitionShortLanes =
+ /* */
+ 122880;
+var TransitionLongHydrationLane =
+ /* */
+ 131072;
+var TransitionLongLanes =
+ /* */
+ 3932160;
+var RetryLanes =
+ /* */
+ 62914560;
+var SelectiveHydrationLane =
+ /* */
+ 67108864;
+var NonIdleLanes =
+ /* */
+ 134217727;
+var IdleHydrationLane =
+ /* */
+ 134217728;
+var IdleLanes =
+ /* */
+ 805306368;
+var OffscreenLane =
+ /* */
+ 1073741824;
+var NoTimestamp = -1;
+function setCurrentUpdateLanePriority(newLanePriority) {} // "Registers" used to "return" multiple values
+// Used by getHighestPriorityLanes and getNextLanes:
- Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueue
- );
- throw error;
- } finally {
- isFlushingSyncQueue = false;
- }
+var return_highestLanePriority = DefaultLanePriority;
+
+function getHighestPriorityLanes(lanes) {
+ if ((SyncLane & lanes) !== NoLanes) {
+ return_highestLanePriority = SyncLanePriority;
+ return SyncLane;
}
-}
-var NoMode = 0;
-var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
-// tag instead
+ if ((SyncBatchedLane & lanes) !== NoLanes) {
+ return_highestLanePriority = SyncBatchedLanePriority;
+ return SyncBatchedLane;
+ }
-var BlockingMode = 2;
-var ConcurrentMode = 4;
-var ProfileMode = 8;
+ if ((InputDiscreteHydrationLane & lanes) !== NoLanes) {
+ return_highestLanePriority = InputDiscreteHydrationLanePriority;
+ return InputDiscreteHydrationLane;
+ }
-// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
-// Math.pow(2, 30) - 1
-// 0b111111111111111111111111111111
-var MAX_SIGNED_31_BIT_INT = 1073741823;
+ var inputDiscreteLanes = InputDiscreteLanes & lanes;
-var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that
-// Never work can be committed in an inconsistent state without tearing the UI.
-// The main example is offscreen content, like a hidden subtree. So one possible
-// name is Offscreen. However, it also includes dehydrated Suspense boundaries,
-// which are inconsistent in the sense that they haven't finished yet, but
-// aren't visibly inconsistent because the server rendered HTML matches what the
-// hydrated tree would look like.
+ if (inputDiscreteLanes !== NoLanes) {
+ return_highestLanePriority = InputDiscreteLanePriority;
+ return inputDiscreteLanes;
+ }
-var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in
-// order to be consistent.
+ if ((lanes & InputContinuousHydrationLane) !== NoLanes) {
+ return_highestLanePriority = InputContinuousHydrationLanePriority;
+ return InputContinuousHydrationLane;
+ }
-var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase
-var Sync = MAX_SIGNED_31_BIT_INT;
-var Batched = Sync - 1;
-var UNIT_SIZE = 10;
-var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms.
+ var inputContinuousLanes = InputContinuousLanes & lanes;
-function msToExpirationTime(ms) {
- // Always subtract from the offset so that we don't clash with the magic number for NoWork.
- return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0);
-}
-function expirationTimeToMs(expirationTime) {
- return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
-}
+ if (inputContinuousLanes !== NoLanes) {
+ return_highestLanePriority = InputContinuousLanePriority;
+ return inputContinuousLanes;
+ }
-function ceiling(num, precision) {
- return (((num / precision) | 0) + 1) * precision;
-}
+ if ((lanes & DefaultHydrationLane) !== NoLanes) {
+ return_highestLanePriority = DefaultHydrationLanePriority;
+ return DefaultHydrationLane;
+ }
-function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
- return (
- MAGIC_NUMBER_OFFSET -
- ceiling(
- MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE,
- bucketSizeMs / UNIT_SIZE
- )
- );
-} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
-// the names to reflect.
-
-var LOW_PRIORITY_EXPIRATION = 5000;
-var LOW_PRIORITY_BATCH_SIZE = 250;
-function computeAsyncExpiration(currentTime) {
- return computeExpirationBucket(
- currentTime,
- LOW_PRIORITY_EXPIRATION,
- LOW_PRIORITY_BATCH_SIZE
- );
-}
-function computeSuspenseExpiration(currentTime, timeoutMs) {
- // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
- return computeExpirationBucket(
- currentTime,
- timeoutMs,
- LOW_PRIORITY_BATCH_SIZE
- );
-} // We intentionally set a higher expiration time for interactive updates in
-// dev than in production.
-//
-// If the main thread is being blocked so long that you hit the expiration,
-// it's a problem that could be solved with better scheduling.
-//
-// People will be more likely to notice this and fix it with the long
-// expiration time in development.
-//
-// In production we opt for better UX at the risk of masking scheduling
-// problems, by expiring fast.
-
-var HIGH_PRIORITY_EXPIRATION = 500;
-var HIGH_PRIORITY_BATCH_SIZE = 100;
-function computeInteractiveExpiration(currentTime) {
- return computeExpirationBucket(
- currentTime,
- HIGH_PRIORITY_EXPIRATION,
- HIGH_PRIORITY_BATCH_SIZE
- );
-}
-function inferPriorityFromExpirationTime(currentTime, expirationTime) {
- if (expirationTime === Sync) {
- return ImmediatePriority;
+ var defaultLanes = DefaultLanes & lanes;
+
+ if (defaultLanes !== NoLanes) {
+ return_highestLanePriority = DefaultLanePriority;
+ return defaultLanes;
}
- if (expirationTime === Never || expirationTime === Idle) {
- return IdlePriority;
+ if ((lanes & TransitionShortHydrationLane) !== NoLanes) {
+ return_highestLanePriority = TransitionShortHydrationLanePriority;
+ return TransitionShortHydrationLane;
}
- var msUntil =
- expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
+ var transitionShortLanes = TransitionShortLanes & lanes;
- if (msUntil <= 0) {
- return ImmediatePriority;
+ if (transitionShortLanes !== NoLanes) {
+ return_highestLanePriority = TransitionShortLanePriority;
+ return transitionShortLanes;
}
- if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
- return UserBlockingPriority;
+ if ((lanes & TransitionLongHydrationLane) !== NoLanes) {
+ return_highestLanePriority = TransitionLongHydrationLanePriority;
+ return TransitionLongHydrationLane;
}
- if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
- return NormalPriority;
- } // TODO: Handle LowPriority
- // Assume anything lower has idle priority
-
- return IdlePriority;
-}
+ var transitionLongLanes = TransitionLongLanes & lanes;
-/**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
- */
-function is(x, y) {
- return (
- (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
- );
-}
+ if (transitionLongLanes !== NoLanes) {
+ return_highestLanePriority = TransitionLongLanePriority;
+ return transitionLongLanes;
+ }
-var objectIs = typeof Object.is === "function" ? Object.is : is;
+ var retryLanes = RetryLanes & lanes;
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-/**
- * Performs equality by iterating through keys on an object and returning false
- * when any key has values which are not strictly equal between the arguments.
- * Returns true when the values of all keys are strictly equal.
- */
+ if (retryLanes !== NoLanes) {
+ return_highestLanePriority = RetryLanePriority;
+ return retryLanes;
+ }
-function shallowEqual(objA, objB) {
- if (objectIs(objA, objB)) {
- return true;
+ if (lanes & SelectiveHydrationLane) {
+ return_highestLanePriority = SelectiveHydrationLanePriority;
+ return SelectiveHydrationLane;
}
- if (
- typeof objA !== "object" ||
- objA === null ||
- typeof objB !== "object" ||
- objB === null
- ) {
- return false;
+ if ((lanes & IdleHydrationLane) !== NoLanes) {
+ return_highestLanePriority = IdleHydrationLanePriority;
+ return IdleHydrationLane;
}
- var keysA = Object.keys(objA);
- var keysB = Object.keys(objB);
+ var idleLanes = IdleLanes & lanes;
- if (keysA.length !== keysB.length) {
- return false;
- } // Test for A's keys different from B.
+ if (idleLanes !== NoLanes) {
+ return_highestLanePriority = IdleLanePriority;
+ return idleLanes;
+ }
- for (var i = 0; i < keysA.length; i++) {
- if (
- !hasOwnProperty.call(objB, keysA[i]) ||
- !objectIs(objA[keysA[i]], objB[keysA[i]])
- ) {
- return false;
- }
+ if ((OffscreenLane & lanes) !== NoLanes) {
+ return_highestLanePriority = OffscreenLanePriority;
+ return OffscreenLane;
}
- return true;
+ {
+ error("Should have found matching lanes. This is a bug in React.");
+ } // This shouldn't be reachable, but as a fallback, return the entire bitmask.
+
+ return_highestLanePriority = DefaultLanePriority;
+ return lanes;
}
-var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
-function describeComponentFrame(name, source, ownerName) {
- var sourceInfo = "";
+function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
+ switch (schedulerPriorityLevel) {
+ case ImmediatePriority:
+ return SyncLanePriority;
- if (source) {
- var path = source.fileName;
- var fileName = path.replace(BEFORE_SLASH_RE, "");
+ case UserBlockingPriority:
+ return InputContinuousLanePriority;
- {
- // In DEV, include code for a common special case:
- // prefer "folder/index.js" instead of just "index.js".
- if (/^index\./.test(fileName)) {
- var match = path.match(BEFORE_SLASH_RE);
+ case NormalPriority:
+ case LowPriority:
+ // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration.
+ return DefaultLanePriority;
+
+ case IdlePriority:
+ return IdleLanePriority;
- if (match) {
- var pathBeforeSlash = match[1];
+ default:
+ return NoLanePriority;
+ }
+}
+function lanePriorityToSchedulerPriority(lanePriority) {
+ switch (lanePriority) {
+ case SyncLanePriority:
+ case SyncBatchedLanePriority:
+ return ImmediatePriority;
- if (pathBeforeSlash) {
- var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, "");
- fileName = folderName + "/" + fileName;
- }
- }
- }
+ case InputDiscreteHydrationLanePriority:
+ case InputDiscreteLanePriority:
+ case InputContinuousHydrationLanePriority:
+ case InputContinuousLanePriority:
+ return UserBlockingPriority;
+
+ case DefaultHydrationLanePriority:
+ case DefaultLanePriority:
+ case TransitionShortHydrationLanePriority:
+ case TransitionShortLanePriority:
+ case TransitionLongHydrationLanePriority:
+ case TransitionLongLanePriority:
+ case SelectiveHydrationLanePriority:
+ case RetryLanePriority:
+ return NormalPriority;
+
+ case IdleHydrationLanePriority:
+ case IdleLanePriority:
+ case OffscreenLanePriority:
+ return IdlePriority;
+
+ case NoLanePriority:
+ return NoPriority;
+
+ default: {
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
}
+ }
+}
+function getNextLanes(root, wipLanes) {
+ // Early bailout if there's no pending work left.
+ var pendingLanes = root.pendingLanes;
- sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")";
- } else if (ownerName) {
- sourceInfo = " (created by " + ownerName + ")";
+ if (pendingLanes === NoLanes) {
+ return_highestLanePriority = NoLanePriority;
+ return NoLanes;
}
- return "\n in " + (name || "Unknown") + sourceInfo;
-}
+ var nextLanes = NoLanes;
+ var nextLanePriority = NoLanePriority;
+ var expiredLanes = root.expiredLanes;
+ var suspendedLanes = root.suspendedLanes;
+ var pingedLanes = root.pingedLanes; // Check if any work has expired.
-var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
+ if (expiredLanes !== NoLanes) {
+ nextLanes = expiredLanes;
+ nextLanePriority = return_highestLanePriority = SyncLanePriority;
+ } else {
+ // Do not work on any idle work until all the non-idle work has finished,
+ // even if the work is suspended.
+ var nonIdlePendingLanes = pendingLanes & NonIdleLanes;
-function describeFiber(fiber) {
- switch (fiber.tag) {
- case HostRoot:
- case HostPortal:
- case HostText:
- case Fragment:
- case ContextProvider:
- case ContextConsumer:
- return "";
+ if (nonIdlePendingLanes !== NoLanes) {
+ var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
- default:
- var owner = fiber._debugOwner;
- var source = fiber._debugSource;
- var name = getComponentName(fiber.type);
- var ownerName = null;
+ if (nonIdleUnblockedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
+ nextLanePriority = return_highestLanePriority;
+ } else {
+ var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
- if (owner) {
- ownerName = getComponentName(owner.type);
+ if (nonIdlePingedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
+ nextLanePriority = return_highestLanePriority;
+ }
}
+ } else {
+ // The only remaining work is Idle.
+ var unblockedLanes = pendingLanes & ~suspendedLanes;
- return describeComponentFrame(name, source, ownerName);
+ if (unblockedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(unblockedLanes);
+ nextLanePriority = return_highestLanePriority;
+ } else {
+ if (pingedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(pingedLanes);
+ nextLanePriority = return_highestLanePriority;
+ }
+ }
+ }
}
-}
-function getStackByFiberInDevAndProd(workInProgress) {
- var info = "";
- var node = workInProgress;
+ if (nextLanes === NoLanes) {
+ // This should only be reachable if we're suspended
+ // TODO: Consider warning in this path if a fallback timer is not scheduled.
+ return NoLanes;
+ } // If there are higher priority lanes, we'll include them even if they
+ // are suspended.
- do {
- info += describeFiber(node);
- node = node.return;
- } while (node);
+ nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt
+ // it and we'll lose our progress. We should only do this if the new lanes are
+ // higher priority.
- return info;
-}
-var current = null;
-var isRendering = false;
-function getCurrentFiberOwnerNameInDevOrNull() {
- {
- if (current === null) {
- return null;
+ if (
+ wipLanes !== NoLanes &&
+ wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't
+ // bother waiting until the root is complete.
+ (wipLanes & suspendedLanes) === NoLanes
+ ) {
+ getHighestPriorityLanes(wipLanes);
+ var wipLanePriority = return_highestLanePriority;
+
+ if (nextLanePriority <= wipLanePriority) {
+ return wipLanes;
+ } else {
+ return_highestLanePriority = nextLanePriority;
}
+ } // Check for entangled lanes and add them to the batch.
+ //
+ // A lane is said to be entangled with another when it's not allowed to render
+ // in a batch that does not also include the other lane. Typically we do this
+ // when multiple updates have the same source, and we only want to respond to
+ // the most recent event from that source.
+ //
+ // Note that we apply entanglements *after* checking for partial work above.
+ // This means that if a lane is entangled during an interleaved event while
+ // it's already rendering, we won't interrupt it. This is intentional, since
+ // entanglement is usually "best effort": we'll try our best to render the
+ // lanes in the same batch, but it's not worth throwing out partially
+ // completed work in order to do it.
+ //
+ // For those exceptions where entanglement is semantically important, like
+ // useMutableSource, we should ensure that there is no partial work at the
+ // time we apply the entanglement.
- var owner = current._debugOwner;
+ var entangledLanes = root.entangledLanes;
- if (owner !== null && typeof owner !== "undefined") {
- return getComponentName(owner.type);
+ if (entangledLanes !== NoLanes) {
+ var entanglements = root.entanglements;
+ var lanes = nextLanes & entangledLanes;
+
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ nextLanes |= entanglements[index];
+ lanes &= ~lane;
}
}
- return null;
+ return nextLanes;
}
-function getCurrentFiberStackInDev() {
- {
- if (current === null) {
- return "";
- } // Safe because if current fiber exists, we are reconciling,
- // and it is guaranteed to be the work-in-progress version.
+function getMostRecentEventTime(root, lanes) {
+ var eventTimes = root.eventTimes;
+ var mostRecentEventTime = NoTimestamp;
- return getStackByFiberInDevAndProd(current);
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ var eventTime = eventTimes[index];
+
+ if (eventTime > mostRecentEventTime) {
+ mostRecentEventTime = eventTime;
+ }
+
+ lanes &= ~lane;
}
+
+ return mostRecentEventTime;
}
-function resetCurrentFiber() {
- {
- ReactDebugCurrentFrame.getCurrentStack = null;
- current = null;
- isRendering = false;
+
+function computeExpirationTime(lane, currentTime) {
+ // TODO: Expiration heuristic is constant per lane, so could use a map.
+ getHighestPriorityLanes(lane);
+ var priority = return_highestLanePriority;
+
+ if (priority >= InputContinuousLanePriority) {
+ // User interactions should expire slightly more quickly.
+ return currentTime + 1000;
+ } else if (priority >= TransitionLongLanePriority) {
+ return currentTime + 5000;
+ } else {
+ // Anything idle priority or lower should never expire.
+ return NoTimestamp;
}
}
-function setCurrentFiber(fiber) {
- {
- ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
- current = fiber;
- isRendering = false;
+
+function markStarvedLanesAsExpired(root, currentTime) {
+ // TODO: This gets called every time we yield. We can optimize by storing
+ // the earliest expiration time on the root. Then use that to quickly bail out
+ // of this function.
+ var pendingLanes = root.pendingLanes;
+ var suspendedLanes = root.suspendedLanes;
+ var pingedLanes = root.pingedLanes;
+ var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their
+ // expiration time. If so, we'll assume the update is being starved and mark
+ // it as expired to force it to finish.
+
+ var lanes = pendingLanes;
+
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ var expirationTime = expirationTimes[index];
+
+ if (expirationTime === NoTimestamp) {
+ // Found a pending lane with no expiration time. If it's not suspended, or
+ // if it's pinged, assume it's CPU-bound. Compute a new expiration time
+ // using the current time.
+ if (
+ (lane & suspendedLanes) === NoLanes ||
+ (lane & pingedLanes) !== NoLanes
+ ) {
+ // Assumes timestamps are monotonically increasing.
+ expirationTimes[index] = computeExpirationTime(lane, currentTime);
+ }
+ } else if (expirationTime <= currentTime) {
+ // This lane expired
+ root.expiredLanes |= lane;
+ }
+
+ lanes &= ~lane;
}
-}
-function setIsRendering(rendering) {
- {
- isRendering = rendering;
+} // This returns the highest priority pending lanes regardless of whether they
+function getLanesToRetrySynchronouslyOnError(root) {
+ var everythingButOffscreen = root.pendingLanes & ~OffscreenLane;
+
+ if (everythingButOffscreen !== NoLanes) {
+ return everythingButOffscreen;
}
+
+ if (everythingButOffscreen & OffscreenLane) {
+ return OffscreenLane;
+ }
+
+ return NoLanes;
+}
+function returnNextLanesPriority() {
+ return return_highestLanePriority;
}
+function includesNonIdleWork(lanes) {
+ return (lanes & NonIdleLanes) !== NoLanes;
+}
+function includesOnlyRetries(lanes) {
+ return (lanes & RetryLanes) === lanes;
+} // To ensure consistency across multiple updates in the same event, this should
+// be a pure function, so that it always returns the same lane for given inputs.
-var ReactStrictModeWarnings = {
- recordUnsafeLifecycleWarnings: function(fiber, instance) {},
- flushPendingUnsafeLifecycleWarnings: function() {},
- recordLegacyContextWarning: function(fiber, instance) {},
- flushLegacyContextWarning: function() {},
- discardPendingWarnings: function() {}
-};
+function findUpdateLane(lanePriority, wipLanes) {
+ switch (lanePriority) {
+ case NoLanePriority:
+ break;
-{
- var findStrictRoot = function(fiber) {
- var maybeStrictRoot = null;
- var node = fiber;
+ case SyncLanePriority:
+ return SyncLane;
- while (node !== null) {
- if (node.mode & StrictMode) {
- maybeStrictRoot = node;
+ case SyncBatchedLanePriority:
+ return SyncBatchedLane;
+
+ case InputDiscreteLanePriority: {
+ var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes);
+
+ if (_lane === NoLane) {
+ // Shift to the next priority level
+ return findUpdateLane(InputContinuousLanePriority, wipLanes);
+ }
+
+ return _lane;
+ }
+
+ case InputContinuousLanePriority: {
+ var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes);
+
+ if (_lane2 === NoLane) {
+ // Shift to the next priority level
+ return findUpdateLane(DefaultLanePriority, wipLanes);
+ }
+
+ return _lane2;
+ }
+
+ case DefaultLanePriority: {
+ var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes);
+
+ if (_lane3 === NoLane) {
+ // If all the default lanes are already being worked on, look for a
+ // lane in the transition range.
+ _lane3 = pickArbitraryLane(
+ (TransitionShortLanes | TransitionLongLanes) & ~wipLanes
+ );
+
+ if (_lane3 === NoLane) {
+ // All the transition lanes are taken, too. This should be very
+ // rare, but as a last resort, pick a default lane. This will have
+ // the effect of interrupting the current work-in-progress render.
+ _lane3 = pickArbitraryLane(DefaultLanes);
+ }
+ }
+
+ return _lane3;
+ }
+
+ case TransitionShortLanePriority: // Should be handled by findTransitionLane instead
+
+ case TransitionLongLanePriority:
+ case RetryLanePriority:
+ // Should be handled by findRetryLane instead
+ break;
+
+ case IdleLanePriority:
+ var lane = pickArbitraryLane(IdleLanes & ~wipLanes);
+
+ if (lane === NoLane) {
+ lane = pickArbitraryLane(IdleLanes);
}
- node = node.return;
- }
+ return lane;
+ }
+
+ {
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+ }
+} // To ensure consistency across multiple updates in the same event, this should
+// be pure function, so that it always returns the same lane for given inputs.
+
+function findTransitionLane(lanePriority, wipLanes, pendingLanes) {
+ if (lanePriority === TransitionShortLanePriority) {
+ // First look for lanes that are completely unclaimed, i.e. have no
+ // pending work.
+ var lane = pickArbitraryLane(TransitionShortLanes & ~pendingLanes);
- return maybeStrictRoot;
- };
+ if (lane === NoLane) {
+ // If all lanes have pending work, look for a lane that isn't currently
+ // being worked on.
+ lane = pickArbitraryLane(TransitionShortLanes & ~wipLanes);
- var setToSortedString = function(set) {
- var array = [];
- set.forEach(function(value) {
- array.push(value);
- });
- return array.sort().join(", ");
- };
+ if (lane === NoLane) {
+ // If everything is being worked on, pick any lane. This has the
+ // effect of interrupting the current work-in-progress.
+ lane = pickArbitraryLane(TransitionShortLanes);
+ }
+ }
- var pendingComponentWillMountWarnings = [];
- var pendingUNSAFE_ComponentWillMountWarnings = [];
- var pendingComponentWillReceivePropsWarnings = [];
- var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
- var pendingComponentWillUpdateWarnings = [];
- var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
+ return lane;
+ }
- var didWarnAboutUnsafeLifecycles = new Set();
+ if (lanePriority === TransitionLongLanePriority) {
+ // First look for lanes that are completely unclaimed, i.e. have no
+ // pending work.
+ var _lane4 = pickArbitraryLane(TransitionLongLanes & ~pendingLanes);
- ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function(
- fiber,
- instance
- ) {
- // Dedup strategy: Warn once per component.
- if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
- return;
- }
+ if (_lane4 === NoLane) {
+ // If all lanes have pending work, look for a lane that isn't currently
+ // being worked on.
+ _lane4 = pickArbitraryLane(TransitionLongLanes & ~wipLanes);
- if (
- typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components.
- instance.componentWillMount.__suppressDeprecationWarning !== true
- ) {
- pendingComponentWillMountWarnings.push(fiber);
+ if (_lane4 === NoLane) {
+ // If everything is being worked on, pick any lane. This has the
+ // effect of interrupting the current work-in-progress.
+ _lane4 = pickArbitraryLane(TransitionLongLanes);
+ }
}
- if (
- fiber.mode & StrictMode &&
- typeof instance.UNSAFE_componentWillMount === "function"
- ) {
- pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
- }
+ return _lane4;
+ }
- if (
- typeof instance.componentWillReceiveProps === "function" &&
- instance.componentWillReceiveProps.__suppressDeprecationWarning !== true
- ) {
- pendingComponentWillReceivePropsWarnings.push(fiber);
- }
+ {
+ throw Error(
+ "Invalid transition priority: " +
+ lanePriority +
+ ". This is a bug in React."
+ );
+ }
+} // To ensure consistency across multiple updates in the same event, this should
+// be pure function, so that it always returns the same lane for given inputs.
- if (
- fiber.mode & StrictMode &&
- typeof instance.UNSAFE_componentWillReceiveProps === "function"
- ) {
- pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
- }
+function findRetryLane(wipLanes) {
+ // This is a fork of `findUpdateLane` designed specifically for Suspense
+ // "retries" — a special update that attempts to flip a Suspense boundary
+ // from its placeholder state to its primary/resolved state.
+ var lane = pickArbitraryLane(RetryLanes & ~wipLanes);
- if (
- typeof instance.componentWillUpdate === "function" &&
- instance.componentWillUpdate.__suppressDeprecationWarning !== true
- ) {
- pendingComponentWillUpdateWarnings.push(fiber);
- }
+ if (lane === NoLane) {
+ lane = pickArbitraryLane(RetryLanes);
+ }
- if (
- fiber.mode & StrictMode &&
- typeof instance.UNSAFE_componentWillUpdate === "function"
- ) {
- pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
- }
- };
+ return lane;
+}
- ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() {
- // We do an initial pass to gather component names
- var componentWillMountUniqueNames = new Set();
+function getHighestPriorityLane(lanes) {
+ return lanes & -lanes;
+}
- if (pendingComponentWillMountWarnings.length > 0) {
- pendingComponentWillMountWarnings.forEach(function(fiber) {
- componentWillMountUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingComponentWillMountWarnings = [];
- }
+function getLowestPriorityLane(lanes) {
+ // This finds the most significant non-zero bit.
+ var index = 31 - clz32(lanes);
+ return index < 0 ? NoLanes : 1 << index;
+}
- var UNSAFE_componentWillMountUniqueNames = new Set();
+function getEqualOrHigherPriorityLanes(lanes) {
+ return (getLowestPriorityLane(lanes) << 1) - 1;
+}
- if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
- pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) {
- UNSAFE_componentWillMountUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingUNSAFE_ComponentWillMountWarnings = [];
- }
+function pickArbitraryLane(lanes) {
+ // This wrapper function gets inlined. Only exists so to communicate that it
+ // doesn't matter which bit is selected; you can pick any bit without
+ // affecting the algorithms where its used. Here I'm using
+ // getHighestPriorityLane because it requires the fewest operations.
+ return getHighestPriorityLane(lanes);
+}
- var componentWillReceivePropsUniqueNames = new Set();
+function pickArbitraryLaneIndex(lanes) {
+ return 31 - clz32(lanes);
+}
- if (pendingComponentWillReceivePropsWarnings.length > 0) {
- pendingComponentWillReceivePropsWarnings.forEach(function(fiber) {
- componentWillReceivePropsUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingComponentWillReceivePropsWarnings = [];
- }
+function laneToIndex(lane) {
+ return pickArbitraryLaneIndex(lane);
+}
- var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
+function includesSomeLane(a, b) {
+ return (a & b) !== NoLanes;
+}
+function isSubsetOfLanes(set, subset) {
+ return (set & subset) === subset;
+}
+function mergeLanes(a, b) {
+ return a | b;
+}
+function removeLanes(set, subset) {
+ return set & ~subset;
+} // Seems redundant, but it changes the type from a single lane (used for
+// updates) to a group of lanes (used for flushing work).
- if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
- pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) {
- UNSAFE_componentWillReceivePropsUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
- }
+function laneToLanes(lane) {
+ return lane;
+}
+function createLaneMap(initial) {
+ return new Array(TotalLanes).fill(initial);
+}
+function markRootUpdated(root, updateLane, eventTime) {
+ root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But
+ // it's not practical to try every single possible combination. We need a
+ // heuristic to decide which lanes to attempt to render, and in which batches.
+ // For now, we use the same heuristic as in the old ExpirationTimes model:
+ // retry any lane at equal or lower priority, but don't try updates at higher
+ // priority without also including the lower priority updates. This works well
+ // when considering updates across different priority levels, but isn't
+ // sufficient for updates within the same priority, since we want to treat
+ // those updates as parallel.
+ // Unsuspend any update at equal or lower priority.
- var componentWillUpdateUniqueNames = new Set();
+ var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111
- if (pendingComponentWillUpdateWarnings.length > 0) {
- pendingComponentWillUpdateWarnings.forEach(function(fiber) {
- componentWillUpdateUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingComponentWillUpdateWarnings = [];
- }
+ root.suspendedLanes &= higherPriorityLanes;
+ root.pingedLanes &= higherPriorityLanes;
+ var eventTimes = root.eventTimes;
+ var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most
+ // recent event, and we assume time is monotonically increasing.
- var UNSAFE_componentWillUpdateUniqueNames = new Set();
+ eventTimes[index] = eventTime;
+}
+function markRootSuspended(root, suspendedLanes) {
+ root.suspendedLanes |= suspendedLanes;
+ root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times.
- if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
- pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) {
- UNSAFE_componentWillUpdateUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingUNSAFE_ComponentWillUpdateWarnings = [];
- } // Finally, we flush all the warnings
- // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
+ var expirationTimes = root.expirationTimes;
+ var lanes = suspendedLanes;
- if (UNSAFE_componentWillMountUniqueNames.size > 0) {
- var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ expirationTimes[index] = NoTimestamp;
+ lanes &= ~lane;
+ }
+}
+function markRootPinged(root, pingedLanes, eventTime) {
+ root.pingedLanes |= root.suspendedLanes & pingedLanes;
+}
+function markRootExpired(root, expiredLanes) {
+ root.expiredLanes |= expiredLanes & root.pendingLanes;
+}
+function hasDiscreteLanes(lanes) {
+ return (lanes & InputDiscreteLanes) !== NoLanes;
+}
+function markRootMutableRead(root, updateLane) {
+ root.mutableReadLanes |= updateLane & root.pendingLanes;
+}
+function markRootFinished(root, remainingLanes) {
+ var noLongerPendingLanes = root.pendingLanes & ~remainingLanes;
+ root.pendingLanes = remainingLanes; // Let's try everything again
- error(
- "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
- "\nPlease update the following components: %s",
- sortedNames
- );
- }
+ root.suspendedLanes = 0;
+ root.pingedLanes = 0;
+ root.expiredLanes &= remainingLanes;
+ root.mutableReadLanes &= remainingLanes;
+ root.entangledLanes &= remainingLanes;
+ var entanglements = root.entanglements;
+ var eventTimes = root.eventTimes;
+ var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work
- if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
- var _sortedNames = setToSortedString(
- UNSAFE_componentWillReceivePropsUniqueNames
- );
+ var lanes = noLongerPendingLanes;
- error(
- "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " +
- "and may indicate bugs in your code. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "* If you're updating state whenever props change, " +
- "refactor your code to use memoization techniques or move it to " +
- "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
- "\nPlease update the following components: %s",
- _sortedNames
- );
- }
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ entanglements[index] = NoLanes;
+ eventTimes[index] = NoTimestamp;
+ expirationTimes[index] = NoTimestamp;
+ lanes &= ~lane;
+ }
+}
+function markRootEntangled(root, entangledLanes) {
+ root.entangledLanes |= entangledLanes;
+ var entanglements = root.entanglements;
+ var lanes = entangledLanes;
- if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
- var _sortedNames2 = setToSortedString(
- UNSAFE_componentWillUpdateUniqueNames
- );
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ entanglements[index] |= entangledLanes;
+ lanes &= ~lane;
+ }
+}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer.
+// Based on:
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
- error(
- "Using UNSAFE_componentWillUpdate in strict mode is not recommended " +
- "and may indicate bugs in your code. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "\nPlease update the following components: %s",
- _sortedNames2
- );
- }
+var log = Math.log;
+var LN2 = Math.LN2;
- if (componentWillMountUniqueNames.size > 0) {
- var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
+function clz32Fallback(lanes) {
+ if (lanes === 0) {
+ return 32;
+ }
- warn(
- "componentWillMount has been renamed, and is not recommended for use. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
- "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " +
- "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " +
- "To rename all deprecated lifecycles to their new names, you can run " +
- "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
- "\nPlease update the following components: %s",
- _sortedNames3
- );
- }
+ return (31 - ((log(lanes) / LN2) | 0)) | 0;
+}
- if (componentWillReceivePropsUniqueNames.size > 0) {
- var _sortedNames4 = setToSortedString(
- componentWillReceivePropsUniqueNames
- );
+// Intentionally not named imports because Rollup would use dynamic dispatch for
+var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
+ Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
+ Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
+ Scheduler_shouldYield = Scheduler.unstable_shouldYield,
+ Scheduler_requestPaint = Scheduler.unstable_requestPaint,
+ Scheduler_now$1 = Scheduler.unstable_now,
+ Scheduler_getCurrentPriorityLevel =
+ Scheduler.unstable_getCurrentPriorityLevel,
+ Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
+ Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
+ Scheduler_NormalPriority = Scheduler.unstable_NormalPriority,
+ Scheduler_LowPriority = Scheduler.unstable_LowPriority,
+ Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
- warn(
- "componentWillReceiveProps has been renamed, and is not recommended for use. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "* If you're updating state whenever props change, refactor your " +
- "code to use memoization techniques or move it to " +
- "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
- "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " +
- "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " +
- "To rename all deprecated lifecycles to their new names, you can run " +
- "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
- "\nPlease update the following components: %s",
- _sortedNames4
- );
- }
+{
+ // Provide explicit error message when production+profiling bundle of e.g.
+ // react-dom is used with production (non-profiling) bundle of
+ // scheduler/tracing
+ if (
+ !(
+ tracing.__interactionsRef != null &&
+ tracing.__interactionsRef.current != null
+ )
+ ) {
+ throw Error(
+ "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling"
+ );
+ }
+}
- if (componentWillUpdateUniqueNames.size > 0) {
- var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
+var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
+// ascending numbers so we can compare them like numbers. They start at 90 to
+// avoid clashing with Scheduler's priorities.
- warn(
- "componentWillUpdate has been renamed, and is not recommended for use. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " +
- "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " +
- "To rename all deprecated lifecycles to their new names, you can run " +
- "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
- "\nPlease update the following components: %s",
- _sortedNames5
- );
- }
- };
+var ImmediatePriority$1 = 99;
+var UserBlockingPriority$1 = 98;
+var NormalPriority$1 = 97;
+var LowPriority$1 = 96;
+var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only.
- var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
+var NoPriority$1 = 90;
+var shouldYield = Scheduler_shouldYield;
+var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
+ Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {};
+var syncQueue = null;
+var immediateQueueCallbackNode = null;
+var isFlushingSyncQueue = false;
+var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
+// This will be the case for modern browsers that support `performance.now`. In
+// older browsers, Scheduler falls back to `Date.now`, which returns a Unix
+// timestamp. In that case, subtract the module initialization time to simulate
+// the behavior of performance.now and keep our times small enough to fit
+// within 32 bits.
+// TODO: Consider lifting this into Scheduler.
- var didWarnAboutLegacyContext = new Set();
+var now =
+ initialTimeMs$1 < 10000
+ ? Scheduler_now$1
+ : function() {
+ return Scheduler_now$1() - initialTimeMs$1;
+ };
+function getCurrentPriorityLevel() {
+ switch (Scheduler_getCurrentPriorityLevel()) {
+ case Scheduler_ImmediatePriority:
+ return ImmediatePriority$1;
- ReactStrictModeWarnings.recordLegacyContextWarning = function(
- fiber,
- instance
- ) {
- var strictRoot = findStrictRoot(fiber);
+ case Scheduler_UserBlockingPriority:
+ return UserBlockingPriority$1;
- if (strictRoot === null) {
- error(
- "Expected to find a StrictMode component in a strict mode tree. " +
- "This error is likely caused by a bug in React. Please file an issue."
- );
+ case Scheduler_NormalPriority:
+ return NormalPriority$1;
- return;
- } // Dedup strategy: Warn once per component.
+ case Scheduler_LowPriority:
+ return LowPriority$1;
- if (didWarnAboutLegacyContext.has(fiber.type)) {
- return;
+ case Scheduler_IdlePriority:
+ return IdlePriority$1;
+
+ default: {
+ throw Error("Unknown priority level.");
}
+ }
+}
- var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
+function reactPriorityToSchedulerPriority(reactPriorityLevel) {
+ switch (reactPriorityLevel) {
+ case ImmediatePriority$1:
+ return Scheduler_ImmediatePriority;
- if (
- fiber.type.contextTypes != null ||
- fiber.type.childContextTypes != null ||
- (instance !== null && typeof instance.getChildContext === "function")
- ) {
- if (warningsForRoot === undefined) {
- warningsForRoot = [];
- pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
- }
+ case UserBlockingPriority$1:
+ return Scheduler_UserBlockingPriority;
- warningsForRoot.push(fiber);
- }
- };
+ case NormalPriority$1:
+ return Scheduler_NormalPriority;
- ReactStrictModeWarnings.flushLegacyContextWarning = function() {
- pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) {
- if (fiberArray.length === 0) {
- return;
- }
+ case LowPriority$1:
+ return Scheduler_LowPriority;
- var firstFiber = fiberArray[0];
- var uniqueNames = new Set();
- fiberArray.forEach(function(fiber) {
- uniqueNames.add(getComponentName(fiber.type) || "Component");
- didWarnAboutLegacyContext.add(fiber.type);
- });
- var sortedNames = setToSortedString(uniqueNames);
- var firstComponentStack = getStackByFiberInDevAndProd(firstFiber);
+ case IdlePriority$1:
+ return Scheduler_IdlePriority;
- error(
- "Legacy context API has been detected within a strict-mode tree." +
- "\n\nThe old API will be supported in all 16.x releases, but applications " +
- "using it should migrate to the new version." +
- "\n\nPlease update the following components: %s" +
- "\n\nLearn more about this warning here: https://fb.me/react-legacy-context" +
- "%s",
- sortedNames,
- firstComponentStack
- );
- });
- };
+ default: {
+ throw Error("Unknown priority level.");
+ }
+ }
+}
- ReactStrictModeWarnings.discardPendingWarnings = function() {
- pendingComponentWillMountWarnings = [];
- pendingUNSAFE_ComponentWillMountWarnings = [];
- pendingComponentWillReceivePropsWarnings = [];
- pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
- pendingComponentWillUpdateWarnings = [];
- pendingUNSAFE_ComponentWillUpdateWarnings = [];
- pendingLegacyContextWarning = new Map();
- };
+function runWithPriority(reactPriorityLevel, fn) {
+ var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
+ return Scheduler_runWithPriority(priorityLevel, fn);
+}
+function scheduleCallback(reactPriorityLevel, callback, options) {
+ var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
+ return Scheduler_scheduleCallback(priorityLevel, callback, options);
}
+function scheduleSyncCallback(callback) {
+ // Push this callback into an internal queue. We'll flush these either in
+ // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
+ if (syncQueue === null) {
+ syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
-var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
+ immediateQueueCallbackNode = Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueueImpl
+ );
+ } else {
+ // Push onto existing queue. Don't need to schedule a callback because
+ // we already scheduled one when we created the queue.
+ syncQueue.push(callback);
+ }
-var failedBoundaries = null;
-var setRefreshHandler = function(handler) {
- {
- resolveFamily = handler;
+ return fakeCallbackNode;
+}
+function cancelCallback(callbackNode) {
+ if (callbackNode !== fakeCallbackNode) {
+ Scheduler_cancelCallback(callbackNode);
+ }
+}
+function flushSyncCallbackQueue() {
+ if (immediateQueueCallbackNode !== null) {
+ var node = immediateQueueCallbackNode;
+ immediateQueueCallbackNode = null;
+ Scheduler_cancelCallback(node);
}
-};
-function resolveFunctionForHotReloading(type) {
- {
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return type;
- }
- var family = resolveFamily(type);
+ flushSyncCallbackQueueImpl();
+}
- if (family === undefined) {
- return type;
- } // Use the latest known implementation.
+function flushSyncCallbackQueueImpl() {
+ if (!isFlushingSyncQueue && syncQueue !== null) {
+ // Prevent re-entrancy.
+ isFlushingSyncQueue = true;
+ var i = 0;
- return family.current;
+ try {
+ var _isSync = true;
+ var queue = syncQueue;
+ setCurrentUpdateLanePriority(SyncLanePriority);
+ runWithPriority(ImmediatePriority$1, function() {
+ for (; i < queue.length; i++) {
+ var callback = queue[i];
+
+ do {
+ callback = callback(_isSync);
+ } while (callback !== null);
+ }
+ });
+ syncQueue = null;
+ } catch (error) {
+ // If something throws, leave the remaining callbacks on the queue.
+ if (syncQueue !== null) {
+ syncQueue = syncQueue.slice(i + 1);
+ } // Resume flushing in the next tick
+
+ Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueue
+ );
+ throw error;
+ } finally {
+ isFlushingSyncQueue = false;
+ }
}
}
-function resolveClassForHotReloading(type) {
- // No implementation differences.
- return resolveFunctionForHotReloading(type);
-}
-function resolveForwardRefForHotReloading(type) {
- {
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return type;
- }
- var family = resolveFamily(type);
+function describeFiber(fiber) {
+ var owner = fiber._debugOwner ? fiber._debugOwner.type : null;
+ var source = fiber._debugSource;
- if (family === undefined) {
- // Check if we're dealing with a real forwardRef. Don't want to crash early.
- if (
- type !== null &&
- type !== undefined &&
- typeof type.render === "function"
- ) {
- // ForwardRef is special because its resolved .type is an object,
- // but it's possible that we only have its inner render function in the map.
- // If that inner render function is different, we'll build a new forwardRef type.
- var currentRender = resolveFunctionForHotReloading(type.render);
+ switch (fiber.tag) {
+ case HostComponent:
+ return describeBuiltInComponentFrame(fiber.type, source, owner);
- if (type.render !== currentRender) {
- var syntheticType = {
- $$typeof: REACT_FORWARD_REF_TYPE,
- render: currentRender
- };
+ case LazyComponent:
+ return describeBuiltInComponentFrame("Lazy", source, owner);
- if (type.displayName !== undefined) {
- syntheticType.displayName = type.displayName;
- }
+ case SuspenseComponent:
+ return describeBuiltInComponentFrame("Suspense", source, owner);
- return syntheticType;
- }
- }
+ case SuspenseListComponent:
+ return describeBuiltInComponentFrame("SuspenseList", source, owner);
- return type;
- } // Use the latest known implementation.
+ case FunctionComponent:
+ case IndeterminateComponent:
+ case SimpleMemoComponent:
+ return describeFunctionComponentFrame(fiber.type, source, owner);
- return family.current;
+ case ForwardRef:
+ return describeFunctionComponentFrame(fiber.type.render, source, owner);
+
+ case Block:
+ return describeFunctionComponentFrame(fiber.type._render, source, owner);
+
+ case ClassComponent:
+ return describeClassComponentFrame(fiber.type, source, owner);
+
+ default:
+ return "";
}
-}
-function isCompatibleFamilyForHotReloading(fiber, element) {
- {
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return false;
- }
+}
- var prevType = fiber.elementType;
- var nextType = element.type; // If we got here, we know types aren't === equal.
+function getStackByFiberInDevAndProd(workInProgress) {
+ try {
+ var info = "";
+ var node = workInProgress;
- var needsCompareFamilies = false;
- var $$typeofNextType =
- typeof nextType === "object" && nextType !== null
- ? nextType.$$typeof
- : null;
+ do {
+ info += describeFiber(node);
+ node = node.return;
+ } while (node);
- switch (fiber.tag) {
- case ClassComponent: {
- if (typeof nextType === "function") {
- needsCompareFamilies = true;
- }
+ return info;
+ } catch (x) {
+ return "\nError generating stack: " + x.message + "\n" + x.stack;
+ }
+}
- break;
- }
+var NoMode = 0;
+var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
+// tag instead
- case FunctionComponent: {
- if (typeof nextType === "function") {
- needsCompareFamilies = true;
- } else if ($$typeofNextType === REACT_LAZY_TYPE) {
- // We don't know the inner type yet.
- // We're going to assume that the lazy inner type is stable,
- // and so it is sufficient to avoid reconciling it away.
- // We're not going to unwrap or actually use the new lazy type.
- needsCompareFamilies = true;
- }
+var BlockingMode = 2;
+var ConcurrentMode = 4;
+var ProfileMode = 8;
+var DebugTracingMode = 16;
- break;
- }
+/**
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
+ */
+function is(x, y) {
+ return (
+ (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
+ );
+}
- case ForwardRef: {
- if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
- needsCompareFamilies = true;
- } else if ($$typeofNextType === REACT_LAZY_TYPE) {
- needsCompareFamilies = true;
- }
+var objectIs = typeof Object.is === "function" ? Object.is : is;
- break;
- }
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+/**
+ * Performs equality by iterating through keys on an object and returning false
+ * when any key has values which are not strictly equal between the arguments.
+ * Returns true when the values of all keys are strictly equal.
+ */
- case MemoComponent:
- case SimpleMemoComponent: {
- if ($$typeofNextType === REACT_MEMO_TYPE) {
- // TODO: if it was but can no longer be simple,
- // we shouldn't set this.
- needsCompareFamilies = true;
- } else if ($$typeofNextType === REACT_LAZY_TYPE) {
- needsCompareFamilies = true;
- }
+function shallowEqual(objA, objB) {
+ if (objectIs(objA, objB)) {
+ return true;
+ }
- break;
- }
+ if (
+ typeof objA !== "object" ||
+ objA === null ||
+ typeof objB !== "object" ||
+ objB === null
+ ) {
+ return false;
+ }
- default:
- return false;
- } // Check if both types have a family and it's the same one.
+ var keysA = Object.keys(objA);
+ var keysB = Object.keys(objB);
- if (needsCompareFamilies) {
- // Note: memo() and forwardRef() we'll compare outer rather than inner type.
- // This means both of them need to be registered to preserve state.
- // If we unwrapped and compared the inner types for wrappers instead,
- // then we would risk falsely saying two separate memo(Foo)
- // calls are equivalent because they wrap the same Foo function.
- var prevFamily = resolveFamily(prevType);
+ if (keysA.length !== keysB.length) {
+ return false;
+ } // Test for A's keys different from B.
- if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
- return true;
- }
+ for (var i = 0; i < keysA.length; i++) {
+ if (
+ !hasOwnProperty.call(objB, keysA[i]) ||
+ !objectIs(objA[keysA[i]], objB[keysA[i]])
+ ) {
+ return false;
}
-
- return false;
}
+
+ return true;
}
-function markFailedErrorBoundaryForHotReloading(fiber) {
+
+var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
+var current = null;
+var isRendering = false;
+function getCurrentFiberOwnerNameInDevOrNull() {
{
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return;
+ if (current === null) {
+ return null;
}
- if (typeof WeakSet !== "function") {
- return;
- }
+ var owner = current._debugOwner;
- if (failedBoundaries === null) {
- failedBoundaries = new WeakSet();
+ if (owner !== null && typeof owner !== "undefined") {
+ return getComponentName(owner.type);
}
+ }
- failedBoundaries.add(fiber);
+ return null;
+}
+
+function getCurrentFiberStackInDev() {
+ {
+ if (current === null) {
+ return "";
+ } // Safe because if current fiber exists, we are reconciling,
+ // and it is guaranteed to be the work-in-progress version.
+
+ return getStackByFiberInDevAndProd(current);
}
}
-var scheduleRefresh = function(root, update) {
+
+function resetCurrentFiber() {
{
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return;
+ ReactDebugCurrentFrame$1.getCurrentStack = null;
+ current = null;
+ isRendering = false;
+ }
+}
+function setCurrentFiber(fiber) {
+ {
+ ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev;
+ current = fiber;
+ isRendering = false;
+ }
+}
+function setIsRendering(rendering) {
+ {
+ isRendering = rendering;
+ }
+}
+function getIsRendering() {
+ {
+ return isRendering;
+ }
+}
+
+var ReactStrictModeWarnings = {
+ recordUnsafeLifecycleWarnings: function(fiber, instance) {},
+ flushPendingUnsafeLifecycleWarnings: function() {},
+ recordLegacyContextWarning: function(fiber, instance) {},
+ flushLegacyContextWarning: function() {},
+ discardPendingWarnings: function() {}
+};
+
+{
+ var findStrictRoot = function(fiber) {
+ var maybeStrictRoot = null;
+ var node = fiber;
+
+ while (node !== null) {
+ if (node.mode & StrictMode) {
+ maybeStrictRoot = node;
+ }
+
+ node = node.return;
}
- var staleFamilies = update.staleFamilies,
- updatedFamilies = update.updatedFamilies;
- flushPassiveEffects();
- flushSync(function() {
- scheduleFibersWithFamiliesRecursively(
- root.current,
- updatedFamilies,
- staleFamilies
- );
+ return maybeStrictRoot;
+ };
+
+ var setToSortedString = function(set) {
+ var array = [];
+ set.forEach(function(value) {
+ array.push(value);
});
- }
-};
-var scheduleRoot = function(root, element) {
- {
- if (root.context !== emptyContextObject) {
- // Super edge case: root has a legacy _renderSubtree context
- // but we don't know the parentComponent so we can't pass it.
- // Just ignore. We'll delete this with _renderSubtree code path later.
+ return array.sort().join(", ");
+ };
+
+ var pendingComponentWillMountWarnings = [];
+ var pendingUNSAFE_ComponentWillMountWarnings = [];
+ var pendingComponentWillReceivePropsWarnings = [];
+ var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
+ var pendingComponentWillUpdateWarnings = [];
+ var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
+
+ var didWarnAboutUnsafeLifecycles = new Set();
+
+ ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function(
+ fiber,
+ instance
+ ) {
+ // Dedup strategy: Warn once per component.
+ if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
return;
}
- flushPassiveEffects();
- syncUpdates(function() {
- updateContainer(element, root, null, null);
- });
- }
-};
+ if (
+ typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components.
+ instance.componentWillMount.__suppressDeprecationWarning !== true
+ ) {
+ pendingComponentWillMountWarnings.push(fiber);
+ }
-function scheduleFibersWithFamiliesRecursively(
- fiber,
- updatedFamilies,
- staleFamilies
-) {
- {
- var alternate = fiber.alternate,
- child = fiber.child,
- sibling = fiber.sibling,
- tag = fiber.tag,
- type = fiber.type;
- var candidateType = null;
+ if (
+ fiber.mode & StrictMode &&
+ typeof instance.UNSAFE_componentWillMount === "function"
+ ) {
+ pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
+ }
- switch (tag) {
- case FunctionComponent:
- case SimpleMemoComponent:
- case ClassComponent:
- candidateType = type;
- break;
+ if (
+ typeof instance.componentWillReceiveProps === "function" &&
+ instance.componentWillReceiveProps.__suppressDeprecationWarning !== true
+ ) {
+ pendingComponentWillReceivePropsWarnings.push(fiber);
+ }
- case ForwardRef:
- candidateType = type.render;
- break;
+ if (
+ fiber.mode & StrictMode &&
+ typeof instance.UNSAFE_componentWillReceiveProps === "function"
+ ) {
+ pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
}
- if (resolveFamily === null) {
- throw new Error("Expected resolveFamily to be set during hot reload.");
+ if (
+ typeof instance.componentWillUpdate === "function" &&
+ instance.componentWillUpdate.__suppressDeprecationWarning !== true
+ ) {
+ pendingComponentWillUpdateWarnings.push(fiber);
}
- var needsRender = false;
- var needsRemount = false;
+ if (
+ fiber.mode & StrictMode &&
+ typeof instance.UNSAFE_componentWillUpdate === "function"
+ ) {
+ pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
+ }
+ };
- if (candidateType !== null) {
- var family = resolveFamily(candidateType);
+ ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() {
+ // We do an initial pass to gather component names
+ var componentWillMountUniqueNames = new Set();
- if (family !== undefined) {
- if (staleFamilies.has(family)) {
- needsRemount = true;
- } else if (updatedFamilies.has(family)) {
- if (tag === ClassComponent) {
- needsRemount = true;
- } else {
- needsRender = true;
- }
- }
- }
+ if (pendingComponentWillMountWarnings.length > 0) {
+ pendingComponentWillMountWarnings.forEach(function(fiber) {
+ componentWillMountUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingComponentWillMountWarnings = [];
}
- if (failedBoundaries !== null) {
- if (
- failedBoundaries.has(fiber) ||
- (alternate !== null && failedBoundaries.has(alternate))
- ) {
- needsRemount = true;
- }
+ var UNSAFE_componentWillMountUniqueNames = new Set();
+
+ if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
+ pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) {
+ UNSAFE_componentWillMountUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingUNSAFE_ComponentWillMountWarnings = [];
}
- if (needsRemount) {
- fiber._debugNeedsRemount = true;
+ var componentWillReceivePropsUniqueNames = new Set();
+
+ if (pendingComponentWillReceivePropsWarnings.length > 0) {
+ pendingComponentWillReceivePropsWarnings.forEach(function(fiber) {
+ componentWillReceivePropsUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingComponentWillReceivePropsWarnings = [];
}
- if (needsRemount || needsRender) {
- scheduleWork(fiber, Sync);
+ var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
+
+ if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
+ pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) {
+ UNSAFE_componentWillReceivePropsUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
}
- if (child !== null && !needsRemount) {
- scheduleFibersWithFamiliesRecursively(
- child,
- updatedFamilies,
- staleFamilies
- );
+ var componentWillUpdateUniqueNames = new Set();
+
+ if (pendingComponentWillUpdateWarnings.length > 0) {
+ pendingComponentWillUpdateWarnings.forEach(function(fiber) {
+ componentWillUpdateUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingComponentWillUpdateWarnings = [];
}
- if (sibling !== null) {
- scheduleFibersWithFamiliesRecursively(
- sibling,
- updatedFamilies,
- staleFamilies
+ var UNSAFE_componentWillUpdateUniqueNames = new Set();
+
+ if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
+ pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) {
+ UNSAFE_componentWillUpdateUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingUNSAFE_ComponentWillUpdateWarnings = [];
+ } // Finally, we flush all the warnings
+ // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
+
+ if (UNSAFE_componentWillMountUniqueNames.size > 0) {
+ var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
+
+ error(
+ "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
+ "\nPlease update the following components: %s",
+ sortedNames
);
}
- }
-}
-var findHostInstancesForRefresh = function(root, families) {
- {
- var hostInstances = new Set();
- var types = new Set(
- families.map(function(family) {
- return family.current;
- })
- );
- findHostInstancesForMatchingFibersRecursively(
- root.current,
- types,
- hostInstances
- );
- return hostInstances;
- }
-};
+ if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
+ var _sortedNames = setToSortedString(
+ UNSAFE_componentWillReceivePropsUniqueNames
+ );
-function findHostInstancesForMatchingFibersRecursively(
- fiber,
- types,
- hostInstances
-) {
- {
- var child = fiber.child,
- sibling = fiber.sibling,
- tag = fiber.tag,
- type = fiber.type;
- var candidateType = null;
+ error(
+ "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " +
+ "and may indicate bugs in your code. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "* If you're updating state whenever props change, " +
+ "refactor your code to use memoization techniques or move it to " +
+ "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames
+ );
+ }
- switch (tag) {
- case FunctionComponent:
- case SimpleMemoComponent:
- case ClassComponent:
- candidateType = type;
- break;
+ if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
+ var _sortedNames2 = setToSortedString(
+ UNSAFE_componentWillUpdateUniqueNames
+ );
- case ForwardRef:
- candidateType = type.render;
- break;
+ error(
+ "Using UNSAFE_componentWillUpdate in strict mode is not recommended " +
+ "and may indicate bugs in your code. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames2
+ );
}
- var didMatch = false;
+ if (componentWillMountUniqueNames.size > 0) {
+ var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
- if (candidateType !== null) {
- if (types.has(candidateType)) {
- didMatch = true;
- }
+ warn(
+ "componentWillMount has been renamed, and is not recommended for use. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
+ "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " +
+ "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " +
+ "To rename all deprecated lifecycles to their new names, you can run " +
+ "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames3
+ );
}
- if (didMatch) {
- // We have a match. This only drills down to the closest host components.
- // There's no need to search deeper because for the purpose of giving
- // visual feedback, "flashing" outermost parent rectangles is sufficient.
- findHostInstancesForFiberShallowly(fiber, hostInstances);
- } else {
- // If there's no match, maybe there will be one further down in the child tree.
- if (child !== null) {
- findHostInstancesForMatchingFibersRecursively(
- child,
- types,
- hostInstances
- );
- }
+ if (componentWillReceivePropsUniqueNames.size > 0) {
+ var _sortedNames4 = setToSortedString(
+ componentWillReceivePropsUniqueNames
+ );
+
+ warn(
+ "componentWillReceiveProps has been renamed, and is not recommended for use. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "* If you're updating state whenever props change, refactor your " +
+ "code to use memoization techniques or move it to " +
+ "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
+ "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " +
+ "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " +
+ "To rename all deprecated lifecycles to their new names, you can run " +
+ "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames4
+ );
}
- if (sibling !== null) {
- findHostInstancesForMatchingFibersRecursively(
- sibling,
- types,
- hostInstances
+ if (componentWillUpdateUniqueNames.size > 0) {
+ var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
+
+ warn(
+ "componentWillUpdate has been renamed, and is not recommended for use. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " +
+ "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " +
+ "To rename all deprecated lifecycles to their new names, you can run " +
+ "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames5
);
}
- }
-}
+ };
-function findHostInstancesForFiberShallowly(fiber, hostInstances) {
- {
- var foundHostInstances = findChildHostInstancesForFiberShallowly(
- fiber,
- hostInstances
- );
+ var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
- if (foundHostInstances) {
- return;
- } // If we didn't find any host children, fallback to closest host parent.
+ var didWarnAboutLegacyContext = new Set();
- var node = fiber;
+ ReactStrictModeWarnings.recordLegacyContextWarning = function(
+ fiber,
+ instance
+ ) {
+ var strictRoot = findStrictRoot(fiber);
- while (true) {
- switch (node.tag) {
- case HostComponent:
- hostInstances.add(node.stateNode);
- return;
+ if (strictRoot === null) {
+ error(
+ "Expected to find a StrictMode component in a strict mode tree. " +
+ "This error is likely caused by a bug in React. Please file an issue."
+ );
- case HostPortal:
- hostInstances.add(node.stateNode.containerInfo);
- return;
+ return;
+ } // Dedup strategy: Warn once per component.
- case HostRoot:
- hostInstances.add(node.stateNode.containerInfo);
- return;
- }
+ if (didWarnAboutLegacyContext.has(fiber.type)) {
+ return;
+ }
- if (node.return === null) {
- throw new Error("Expected to reach root first.");
+ var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
+
+ if (
+ fiber.type.contextTypes != null ||
+ fiber.type.childContextTypes != null ||
+ (instance !== null && typeof instance.getChildContext === "function")
+ ) {
+ if (warningsForRoot === undefined) {
+ warningsForRoot = [];
+ pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
}
- node = node.return;
+ warningsForRoot.push(fiber);
}
- }
-}
-
-function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
- {
- var node = fiber;
- var foundHostInstances = false;
+ };
- while (true) {
- if (node.tag === HostComponent) {
- // We got a match.
- foundHostInstances = true;
- hostInstances.add(node.stateNode); // There may still be more, so keep searching.
- } else if (node.child !== null) {
- node.child.return = node;
- node = node.child;
- continue;
+ ReactStrictModeWarnings.flushLegacyContextWarning = function() {
+ pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) {
+ if (fiberArray.length === 0) {
+ return;
}
- if (node === fiber) {
- return foundHostInstances;
- }
+ var firstFiber = fiberArray[0];
+ var uniqueNames = new Set();
+ fiberArray.forEach(function(fiber) {
+ uniqueNames.add(getComponentName(fiber.type) || "Component");
+ didWarnAboutLegacyContext.add(fiber.type);
+ });
+ var sortedNames = setToSortedString(uniqueNames);
- while (node.sibling === null) {
- if (node.return === null || node.return === fiber) {
- return foundHostInstances;
- }
+ try {
+ setCurrentFiber(firstFiber);
- node = node.return;
+ error(
+ "Legacy context API has been detected within a strict-mode tree." +
+ "\n\nThe old API will be supported in all 16.x releases, but applications " +
+ "using it should migrate to the new version." +
+ "\n\nPlease update the following components: %s" +
+ "\n\nLearn more about this warning here: https://fb.me/react-legacy-context",
+ sortedNames
+ );
+ } finally {
+ resetCurrentFiber();
}
+ });
+ };
- node.sibling.return = node.return;
- node = node.sibling;
- }
- }
-
- return false;
+ ReactStrictModeWarnings.discardPendingWarnings = function() {
+ pendingComponentWillMountWarnings = [];
+ pendingUNSAFE_ComponentWillMountWarnings = [];
+ pendingComponentWillReceivePropsWarnings = [];
+ pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
+ pendingComponentWillUpdateWarnings = [];
+ pendingUNSAFE_ComponentWillUpdateWarnings = [];
+ pendingLegacyContextWarning = new Map();
+ };
}
function resolveDefaultProps(Component, baseProps) {
@@ -6106,15 +6283,11 @@ function resolveDefaultProps(Component, baseProps) {
return baseProps;
}
-function readLazyComponentType(lazyComponent) {
- initializeLazyComponentType(lazyComponent);
-
- if (lazyComponent._status !== Resolved) {
- throw lazyComponent._result;
- }
- return lazyComponent._result;
-}
+// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
+// Math.pow(2, 30) - 1
+// 0b111111111111111111111111111111
+var MAX_SIGNED_31_BIT_INT = 1073741823;
var valueCursor = createCursor(null);
var rendererSigil;
@@ -6204,28 +6377,24 @@ function calculateChangedBits(context, newValue, oldValue) {
return changedBits | 0;
}
}
-function scheduleWorkOnParentPath(parent, renderExpirationTime) {
- // Update the child expiration time of all the ancestors, including
- // the alternates.
+function scheduleWorkOnParentPath(parent, renderLanes) {
+ // Update the child lanes of all the ancestors, including the alternates.
var node = parent;
while (node !== null) {
var alternate = node.alternate;
- if (node.childExpirationTime < renderExpirationTime) {
- node.childExpirationTime = renderExpirationTime;
+ if (!isSubsetOfLanes(node.childLanes, renderLanes)) {
+ node.childLanes = mergeLanes(node.childLanes, renderLanes);
- if (
- alternate !== null &&
- alternate.childExpirationTime < renderExpirationTime
- ) {
- alternate.childExpirationTime = renderExpirationTime;
+ if (alternate !== null) {
+ alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
}
} else if (
alternate !== null &&
- alternate.childExpirationTime < renderExpirationTime
+ !isSubsetOfLanes(alternate.childLanes, renderLanes)
) {
- alternate.childExpirationTime = renderExpirationTime;
+ alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
} else {
// Neither alternate was updated, which means the rest of the
// ancestor path already has sufficient priority.
@@ -6239,7 +6408,7 @@ function propagateContextChange(
workInProgress,
context,
changedBits,
- renderExpirationTime
+ renderLanes
) {
var fiber = workInProgress.child;
@@ -6266,7 +6435,11 @@ function propagateContextChange(
// Match! Schedule an update on this fiber.
if (fiber.tag === ClassComponent) {
// Schedule a force update on the work-in-progress.
- var update = createUpdate(renderExpirationTime, null);
+ var update = createUpdate(
+ NoTimestamp,
+ pickArbitraryLane(renderLanes),
+ null
+ );
update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
// update to the current fiber, too, which means it will persist even if
// this render is thrown away. Since it's a race condition, not sure it's
@@ -6275,24 +6448,16 @@ function propagateContextChange(
enqueueUpdate(fiber, update);
}
- if (fiber.expirationTime < renderExpirationTime) {
- fiber.expirationTime = renderExpirationTime;
- }
-
+ fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
var alternate = fiber.alternate;
- if (
- alternate !== null &&
- alternate.expirationTime < renderExpirationTime
- ) {
- alternate.expirationTime = renderExpirationTime;
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
}
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
+ scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too.
- if (list.expirationTime < renderExpirationTime) {
- list.expirationTime = renderExpirationTime;
- } // Since we already found a match, we can stop traversing the
+ list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the
// dependency list.
break;
@@ -6338,7 +6503,7 @@ function propagateContextChange(
fiber = nextFiber;
}
}
-function prepareToReadContext(workInProgress, renderExpirationTime) {
+function prepareToReadContext(workInProgress, renderLanes) {
currentlyRenderingFiber = workInProgress;
lastContextDependency = null;
lastContextWithAllBitsObserved = null;
@@ -6348,7 +6513,7 @@ function prepareToReadContext(workInProgress, renderExpirationTime) {
var firstContext = dependencies.firstContext;
if (firstContext !== null) {
- if (dependencies.expirationTime >= renderExpirationTime) {
+ if (includesSomeLane(dependencies.lanes, renderLanes)) {
// Context list has a pending update. Mark that this fiber performed work.
markWorkInProgressReceivedUpdate();
} // Reset the work-in-progress list
@@ -6402,7 +6567,7 @@ function readContext(context, observedBits) {
lastContextDependency = contextItem;
currentlyRenderingFiber.dependencies = {
- expirationTime: NoWork,
+ lanes: NoLanes,
firstContext: contextItem,
responders: null
};
@@ -6434,7 +6599,8 @@ var currentlyProcessingQueue;
function initializeUpdateQueue(fiber) {
var queue = {
baseState: fiber.memoizedState,
- baseQueue: null,
+ firstBaseUpdate: null,
+ lastBaseUpdate: null,
shared: {
pending: null
},
@@ -6450,28 +6616,24 @@ function cloneUpdateQueue(current, workInProgress) {
if (queue === currentQueue) {
var clone = {
baseState: currentQueue.baseState,
- baseQueue: currentQueue.baseQueue,
+ firstBaseUpdate: currentQueue.firstBaseUpdate,
+ lastBaseUpdate: currentQueue.lastBaseUpdate,
shared: currentQueue.shared,
effects: currentQueue.effects
};
workInProgress.updateQueue = clone;
}
}
-function createUpdate(expirationTime, suspenseConfig) {
+function createUpdate(eventTime, lane, suspenseConfig) {
var update = {
- expirationTime: expirationTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
tag: UpdateState,
payload: null,
callback: null,
next: null
};
- update.next = update;
-
- {
- update.priority = getCurrentPriorityLevel();
- }
-
return update;
}
function enqueueUpdate(fiber, update) {
@@ -6511,25 +6673,85 @@ function enqueueUpdate(fiber, update) {
}
}
}
-function enqueueCapturedUpdate(workInProgress, update) {
+function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
+ // Captured updates are updates that are thrown by a child during the render
+ // phase. They should be discarded if the render is aborted. Therefore,
+ // we should only put them on the work-in-progress queue, not the current one.
+ var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone.
+
var current = workInProgress.alternate;
if (current !== null) {
- // Ensure the work-in-progress queue is a clone
- cloneUpdateQueue(current, workInProgress);
- } // Captured updates go only on the work-in-progress queue.
+ var currentQueue = current.updateQueue;
+
+ if (queue === currentQueue) {
+ // The work-in-progress queue is the same as current. This happens when
+ // we bail out on a parent fiber that then captures an error thrown by
+ // a child. Since we want to append the update only to the work-in
+ // -progress queue, we need to clone the updates. We usually clone during
+ // processUpdateQueue, but that didn't happen in this case because we
+ // skipped over the parent when we bailed out.
+ var newFirst = null;
+ var newLast = null;
+ var firstBaseUpdate = queue.firstBaseUpdate;
+
+ if (firstBaseUpdate !== null) {
+ // Loop through the updates and clone them.
+ var update = firstBaseUpdate;
+
+ do {
+ var clone = {
+ eventTime: update.eventTime,
+ lane: update.lane,
+ suspenseConfig: update.suspenseConfig,
+ tag: update.tag,
+ payload: update.payload,
+ callback: update.callback,
+ next: null
+ };
- var queue = workInProgress.updateQueue; // Append the update to the end of the list.
+ if (newLast === null) {
+ newFirst = newLast = clone;
+ } else {
+ newLast.next = clone;
+ newLast = clone;
+ }
- var last = queue.baseQueue;
+ update = update.next;
+ } while (update !== null); // Append the captured update the end of the cloned list.
- if (last === null) {
- queue.baseQueue = update.next = update;
- update.next = update;
+ if (newLast === null) {
+ newFirst = newLast = capturedUpdate;
+ } else {
+ newLast.next = capturedUpdate;
+ newLast = capturedUpdate;
+ }
+ } else {
+ // There are no base updates.
+ newFirst = newLast = capturedUpdate;
+ }
+
+ queue = {
+ baseState: currentQueue.baseState,
+ firstBaseUpdate: newFirst,
+ lastBaseUpdate: newLast,
+ shared: currentQueue.shared,
+ effects: currentQueue.effects
+ };
+ workInProgress.updateQueue = queue;
+ return;
+ }
+ } // Append the update to the end of the list.
+
+ var lastBaseUpdate = queue.lastBaseUpdate;
+
+ if (lastBaseUpdate === null) {
+ queue.firstBaseUpdate = capturedUpdate;
} else {
- update.next = last.next;
- last.next = update;
+ lastBaseUpdate.next = capturedUpdate;
}
+
+ queue.lastBaseUpdate = capturedUpdate;
}
function getStateFromUpdate(
@@ -6548,15 +6770,21 @@ function getStateFromUpdate(
// Updater function
{
enterDisallowedContextReadInDEV();
-
- if (workInProgress.mode & StrictMode) {
- payload.call(instance, prevState, nextProps);
- }
}
var nextState = payload.call(instance, prevState, nextProps);
{
+ if (workInProgress.mode & StrictMode) {
+ disableLogs();
+
+ try {
+ payload.call(instance, prevState, nextProps);
+ } finally {
+ reenableLogs();
+ }
+ }
+
exitDisallowedContextReadInDEV();
}
@@ -6580,15 +6808,21 @@ function getStateFromUpdate(
// Updater function
{
enterDisallowedContextReadInDEV();
-
- if (workInProgress.mode & StrictMode) {
- _payload.call(instance, prevState, nextProps);
- }
}
partialState = _payload.call(instance, prevState, nextProps);
{
+ if (workInProgress.mode & StrictMode) {
+ disableLogs();
+
+ try {
+ _payload.call(instance, prevState, nextProps);
+ } finally {
+ reenableLogs();
+ }
+ }
+
exitDisallowedContextReadInDEV();
}
} else {
@@ -6613,161 +6847,172 @@ function getStateFromUpdate(
return prevState;
}
-function processUpdateQueue(
- workInProgress,
- props,
- instance,
- renderExpirationTime
-) {
+function processUpdateQueue(workInProgress, props, instance, renderLanes) {
// This is always non-null on a ClassComponent or HostRoot
var queue = workInProgress.updateQueue;
hasForceUpdate = false;
{
currentlyProcessingQueue = queue.shared;
- } // The last rebase update that is NOT part of the base state.
+ }
- var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet.
+ var firstBaseUpdate = queue.firstBaseUpdate;
+ var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue.
var pendingQueue = queue.shared.pending;
if (pendingQueue !== null) {
- // We have new updates that haven't been processed yet.
- // We'll add them to the base queue.
- if (baseQueue !== null) {
- // Merge the pending queue and the base queue.
- var baseFirst = baseQueue.next;
- var pendingFirst = pendingQueue.next;
- baseQueue.next = pendingFirst;
- pendingQueue.next = baseFirst;
+ queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first
+ // and last so that it's non-circular.
+
+ var lastPendingUpdate = pendingQueue;
+ var firstPendingUpdate = lastPendingUpdate.next;
+ lastPendingUpdate.next = null; // Append pending updates to base queue
+
+ if (lastBaseUpdate === null) {
+ firstBaseUpdate = firstPendingUpdate;
+ } else {
+ lastBaseUpdate.next = firstPendingUpdate;
}
- baseQueue = pendingQueue;
- queue.shared.pending = null; // TODO: Pass `current` as argument
+ lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then
+ // we need to transfer the updates to that queue, too. Because the base
+ // queue is a singly-linked list with no cycles, we can append to both
+ // lists and take advantage of structural sharing.
+ // TODO: Pass `current` as argument
var current = workInProgress.alternate;
if (current !== null) {
+ // This is always non-null on a ClassComponent or HostRoot
var currentQueue = current.updateQueue;
+ var currentLastBaseUpdate = currentQueue.lastBaseUpdate;
+
+ if (currentLastBaseUpdate !== lastBaseUpdate) {
+ if (currentLastBaseUpdate === null) {
+ currentQueue.firstBaseUpdate = firstPendingUpdate;
+ } else {
+ currentLastBaseUpdate.next = firstPendingUpdate;
+ }
- if (currentQueue !== null) {
- currentQueue.baseQueue = pendingQueue;
+ currentQueue.lastBaseUpdate = lastPendingUpdate;
}
}
} // These values may change as we process the queue.
- if (baseQueue !== null) {
- var first = baseQueue.next; // Iterate through the list of updates to compute the result.
+ if (firstBaseUpdate !== null) {
+ // Iterate through the list of updates to compute the result.
+ var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes
+ // from the original lanes.
- var newState = queue.baseState;
- var newExpirationTime = NoWork;
+ var newLanes = NoLanes;
var newBaseState = null;
- var newBaseQueueFirst = null;
- var newBaseQueueLast = null;
+ var newFirstBaseUpdate = null;
+ var newLastBaseUpdate = null;
+ var update = firstBaseUpdate;
+
+ do {
+ var updateLane = update.lane;
+ var updateEventTime = update.eventTime;
- if (first !== null) {
- var update = first;
+ if (!isSubsetOfLanes(renderLanes, updateLane)) {
+ // Priority is insufficient. Skip this update. If this is the first
+ // skipped update, the previous update/state is the new base
+ // update/state.
+ var clone = {
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: update.suspenseConfig,
+ tag: update.tag,
+ payload: update.payload,
+ callback: update.callback,
+ next: null
+ };
- do {
- var updateExpirationTime = update.expirationTime;
+ if (newLastBaseUpdate === null) {
+ newFirstBaseUpdate = newLastBaseUpdate = clone;
+ newBaseState = newState;
+ } else {
+ newLastBaseUpdate = newLastBaseUpdate.next = clone;
+ } // Update the remaining priority in the queue.
- if (updateExpirationTime < renderExpirationTime) {
- // Priority is insufficient. Skip this update. If this is the first
- // skipped update, the previous update/state is the new base
- // update/state.
- var clone = {
- expirationTime: update.expirationTime,
+ newLanes = mergeLanes(newLanes, updateLane);
+ } else {
+ // This update does have sufficient priority.
+ if (newLastBaseUpdate !== null) {
+ var _clone = {
+ eventTime: updateEventTime,
+ // This update is going to be committed so we never want uncommit
+ // it. Using NoLane works because 0 is a subset of all bitmasks, so
+ // this will never be skipped by the check above.
+ lane: NoLane,
suspenseConfig: update.suspenseConfig,
tag: update.tag,
payload: update.payload,
callback: update.callback,
next: null
};
+ newLastBaseUpdate = newLastBaseUpdate.next = _clone;
+ } // Mark the event time of this update as relevant to this render pass.
+ // TODO: This should ideally use the true event time of this update rather than
+ // its priority which is a derived and not reversible value.
+ // TODO: We should skip this update if it was already committed but currently
+ // we have no way of detecting the difference between a committed and suspended
+ // update here.
- if (newBaseQueueLast === null) {
- newBaseQueueFirst = newBaseQueueLast = clone;
- newBaseState = newState;
- } else {
- newBaseQueueLast = newBaseQueueLast.next = clone;
- } // Update the remaining priority in the queue.
+ markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig); // Process this update.
- if (updateExpirationTime > newExpirationTime) {
- newExpirationTime = updateExpirationTime;
- }
- } else {
- // This update does have sufficient priority.
- if (newBaseQueueLast !== null) {
- var _clone = {
- expirationTime: Sync,
- // This update is going to be committed so we never want uncommit it.
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
- next: null
- };
- newBaseQueueLast = newBaseQueueLast.next = _clone;
- } // Mark the event time of this update as relevant to this render pass.
- // TODO: This should ideally use the true event time of this update rather than
- // its priority which is a derived and not reverseable value.
- // TODO: We should skip this update if it was already committed but currently
- // we have no way of detecting the difference between a committed and suspended
- // update here.
-
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ); // Process this update.
-
- newState = getStateFromUpdate(
- workInProgress,
- queue,
- update,
- newState,
- props,
- instance
- );
- var callback = update.callback;
+ newState = getStateFromUpdate(
+ workInProgress,
+ queue,
+ update,
+ newState,
+ props,
+ instance
+ );
+ var callback = update.callback;
- if (callback !== null) {
- workInProgress.effectTag |= Callback;
- var effects = queue.effects;
+ if (callback !== null) {
+ workInProgress.effectTag |= Callback;
+ var effects = queue.effects;
- if (effects === null) {
- queue.effects = [update];
- } else {
- effects.push(update);
- }
+ if (effects === null) {
+ queue.effects = [update];
+ } else {
+ effects.push(update);
}
}
+ }
- update = update.next;
+ update = update.next;
- if (update === null || update === first) {
- pendingQueue = queue.shared.pending;
+ if (update === null) {
+ pendingQueue = queue.shared.pending;
- if (pendingQueue === null) {
- break;
- } else {
- // An update was scheduled from inside a reducer. Add the new
- // pending updates to the end of the list and keep processing.
- update = baseQueue.next = pendingQueue.next;
- pendingQueue.next = first;
- queue.baseQueue = baseQueue = pendingQueue;
- queue.shared.pending = null;
- }
+ if (pendingQueue === null) {
+ break;
+ } else {
+ // An update was scheduled from inside a reducer. Add the new
+ // pending updates to the end of the list and keep processing.
+ var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we
+ // unravel them when transferring them to the base queue.
+
+ var _firstPendingUpdate = _lastPendingUpdate.next;
+ _lastPendingUpdate.next = null;
+ update = _firstPendingUpdate;
+ queue.lastBaseUpdate = _lastPendingUpdate;
+ queue.shared.pending = null;
}
- } while (true);
- }
+ }
+ } while (true);
- if (newBaseQueueLast === null) {
+ if (newLastBaseUpdate === null) {
newBaseState = newState;
- } else {
- newBaseQueueLast.next = newBaseQueueFirst;
}
queue.baseState = newBaseState;
- queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue.
+ queue.firstBaseUpdate = newFirstBaseUpdate;
+ queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue.
// This should be fine because the only two other things that contribute to
// expiration time are props and context. We're already in the middle of the
// begin phase by the time we start processing the queue, so we've already
@@ -6775,8 +7020,8 @@ function processUpdateQueue(
// shouldComponentUpdate is tricky; but we'll have to account for
// that regardless.
- markUnprocessedUpdateTime(newExpirationTime);
- workInProgress.expirationTime = newExpirationTime;
+ markSkippedUpdateLanes(newLanes);
+ workInProgress.lanes = newLanes;
workInProgress.memoizedState = newState;
}
@@ -6914,8 +7159,14 @@ function applyDerivedStateFromProps(
{
if (workInProgress.mode & StrictMode) {
- // Invoke the function an extra time to help detect side-effects.
- getDerivedStateFromProps(nextProps, prevState);
+ disableLogs();
+
+ try {
+ // Invoke the function an extra time to help detect side-effects.
+ getDerivedStateFromProps(nextProps, prevState);
+ } finally {
+ reenableLogs();
+ }
}
}
@@ -6932,7 +7183,7 @@ function applyDerivedStateFromProps(
workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
// base state.
- if (workInProgress.expirationTime === NoWork) {
+ if (workInProgress.lanes === NoLanes) {
// Queue is always non-null for classes
var updateQueue = workInProgress.updateQueue;
updateQueue.baseState = memoizedState;
@@ -6942,14 +7193,10 @@ var classComponentUpdater = {
isMounted: isMounted,
enqueueSetState: function(inst, payload, callback) {
var fiber = get(inst);
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
- var update = createUpdate(expirationTime, suspenseConfig);
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ var update = createUpdate(eventTime, lane, suspenseConfig);
update.payload = payload;
if (callback !== undefined && callback !== null) {
@@ -6961,18 +7208,14 @@ var classComponentUpdater = {
}
enqueueUpdate(fiber, update);
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
},
enqueueReplaceState: function(inst, payload, callback) {
var fiber = get(inst);
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
- var update = createUpdate(expirationTime, suspenseConfig);
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ var update = createUpdate(eventTime, lane, suspenseConfig);
update.tag = ReplaceState;
update.payload = payload;
@@ -6985,18 +7228,14 @@ var classComponentUpdater = {
}
enqueueUpdate(fiber, update);
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
},
enqueueForceUpdate: function(inst, callback) {
var fiber = get(inst);
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
- var update = createUpdate(expirationTime, suspenseConfig);
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ var update = createUpdate(eventTime, lane, suspenseConfig);
update.tag = ForceUpdate;
if (callback !== undefined && callback !== null) {
@@ -7008,7 +7247,7 @@ var classComponentUpdater = {
}
enqueueUpdate(fiber, update);
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
};
@@ -7026,18 +7265,22 @@ function checkShouldComponentUpdate(
if (typeof instance.shouldComponentUpdate === "function") {
{
if (workInProgress.mode & StrictMode) {
- // Invoke the function an extra time to help detect side-effects.
- instance.shouldComponentUpdate(newProps, newState, nextContext);
+ disableLogs();
+
+ try {
+ // Invoke the function an extra time to help detect side-effects.
+ instance.shouldComponentUpdate(newProps, newState, nextContext);
+ } finally {
+ reenableLogs();
+ }
}
}
- startPhaseTimer(workInProgress, "shouldComponentUpdate");
var shouldUpdate = instance.shouldComponentUpdate(
newProps,
newState,
nextContext
);
- stopPhaseTimer();
{
if (shouldUpdate === undefined) {
@@ -7358,7 +7601,13 @@ function constructClassInstance(workInProgress, ctor, props) {
{
if (workInProgress.mode & StrictMode) {
- new ctor(props, context); // eslint-disable-line no-new
+ disableLogs();
+
+ try {
+ new ctor(props, context); // eslint-disable-line no-new
+ } finally {
+ reenableLogs();
+ }
}
}
@@ -7469,7 +7718,6 @@ function constructClassInstance(workInProgress, ctor, props) {
}
function callComponentWillMount(workInProgress, instance) {
- startPhaseTimer(workInProgress, "componentWillMount");
var oldState = instance.state;
if (typeof instance.componentWillMount === "function") {
@@ -7480,8 +7728,6 @@ function callComponentWillMount(workInProgress, instance) {
instance.UNSAFE_componentWillMount();
}
- stopPhaseTimer();
-
if (oldState !== instance.state) {
{
error(
@@ -7503,7 +7749,6 @@ function callComponentWillReceiveProps(
nextContext
) {
var oldState = instance.state;
- startPhaseTimer(workInProgress, "componentWillReceiveProps");
if (typeof instance.componentWillReceiveProps === "function") {
instance.componentWillReceiveProps(newProps, nextContext);
@@ -7513,8 +7758,6 @@ function callComponentWillReceiveProps(
instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
}
- stopPhaseTimer();
-
if (instance.state !== oldState) {
{
var componentName = getComponentName(workInProgress.type) || "Component";
@@ -7535,12 +7778,7 @@ function callComponentWillReceiveProps(
}
} // Invokes the mount life-cycles on a previously never rendered instance.
-function mountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
{
checkClassInstance(workInProgress, ctor, newProps);
}
@@ -7590,7 +7828,7 @@ function mountClassInstance(
}
}
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
@@ -7614,12 +7852,7 @@ function mountClassInstance(
callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
// process them now.
- processUpdateQueue(
- workInProgress,
- newProps,
- instance,
- renderExpirationTime
- );
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
}
@@ -7628,12 +7861,7 @@ function mountClassInstance(
}
}
-function resumeMountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
var oldProps = workInProgress.memoizedProps;
instance.props = oldProps;
@@ -7679,7 +7907,7 @@ function resumeMountClassInstance(
resetHasForceUpdateBeforeProcessing();
var oldState = workInProgress.memoizedState;
var newState = (instance.state = oldState);
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
newState = workInProgress.memoizedState;
if (
@@ -7727,8 +7955,6 @@ function resumeMountClassInstance(
(typeof instance.UNSAFE_componentWillMount === "function" ||
typeof instance.componentWillMount === "function")
) {
- startPhaseTimer(workInProgress, "componentWillMount");
-
if (typeof instance.componentWillMount === "function") {
instance.componentWillMount();
}
@@ -7736,8 +7962,6 @@ function resumeMountClassInstance(
if (typeof instance.UNSAFE_componentWillMount === "function") {
instance.UNSAFE_componentWillMount();
}
-
- stopPhaseTimer();
}
if (typeof instance.componentDidMount === "function") {
@@ -7767,15 +7991,17 @@ function updateClassInstance(
workInProgress,
ctor,
newProps,
- renderExpirationTime
+ renderLanes
) {
var instance = workInProgress.stateNode;
cloneUpdateQueue(current, workInProgress);
- var oldProps = workInProgress.memoizedProps;
- instance.props =
+ var unresolvedOldProps = workInProgress.memoizedProps;
+ var oldProps =
workInProgress.type === workInProgress.elementType
- ? oldProps
- : resolveDefaultProps(workInProgress.type, oldProps);
+ ? unresolvedOldProps
+ : resolveDefaultProps(workInProgress.type, unresolvedOldProps);
+ instance.props = oldProps;
+ var unresolvedNewProps = workInProgress.pendingProps;
var oldContext = instance.context;
var contextType = ctor.contextType;
var nextContext = emptyContextObject;
@@ -7801,7 +8027,10 @@ function updateClassInstance(
(typeof instance.UNSAFE_componentWillReceiveProps === "function" ||
typeof instance.componentWillReceiveProps === "function")
) {
- if (oldProps !== newProps || oldContext !== nextContext) {
+ if (
+ unresolvedOldProps !== unresolvedNewProps ||
+ oldContext !== nextContext
+ ) {
callComponentWillReceiveProps(
workInProgress,
instance,
@@ -7814,11 +8043,11 @@ function updateClassInstance(
resetHasForceUpdateBeforeProcessing();
var oldState = workInProgress.memoizedState;
var newState = (instance.state = oldState);
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
newState = workInProgress.memoizedState;
if (
- oldProps === newProps &&
+ unresolvedOldProps === unresolvedNewProps &&
oldState === newState &&
!hasContextChanged() &&
!checkHasForceUpdateAfterProcessing()
@@ -7827,7 +8056,7 @@ function updateClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Update;
@@ -7836,7 +8065,7 @@ function updateClassInstance(
if (typeof instance.getSnapshotBeforeUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Snapshot;
@@ -7876,8 +8105,6 @@ function updateClassInstance(
(typeof instance.UNSAFE_componentWillUpdate === "function" ||
typeof instance.componentWillUpdate === "function")
) {
- startPhaseTimer(workInProgress, "componentWillUpdate");
-
if (typeof instance.componentWillUpdate === "function") {
instance.componentWillUpdate(newProps, newState, nextContext);
}
@@ -7885,8 +8112,6 @@ function updateClassInstance(
if (typeof instance.UNSAFE_componentWillUpdate === "function") {
instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
}
-
- stopPhaseTimer();
}
if (typeof instance.componentDidUpdate === "function") {
@@ -7901,7 +8126,7 @@ function updateClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Update;
@@ -7910,7 +8135,7 @@ function updateClassInstance(
if (typeof instance.getSnapshotBeforeUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Snapshot;
@@ -7935,7 +8160,7 @@ var didWarnAboutStringRefs;
var ownerHasKeyUseWarning;
var ownerHasFunctionTypeWarning;
-var warnForMissingKey = function(child) {};
+var warnForMissingKey = function(child, returnFiber) {};
{
didWarnAboutMaps = false;
@@ -7950,7 +8175,7 @@ var warnForMissingKey = function(child) {};
ownerHasKeyUseWarning = {};
ownerHasFunctionTypeWarning = {};
- warnForMissingKey = function(child) {
+ warnForMissingKey = function(child, returnFiber) {
if (child === null || typeof child !== "object") {
return;
}
@@ -7966,17 +8191,13 @@ var warnForMissingKey = function(child) {};
}
child._store.validated = true;
- var currentComponentErrorInfo =
- "Each child in a list should have a unique " +
- '"key" prop. See https://fb.me/react-warning-keys for ' +
- "more information." +
- getCurrentFiberStackInDev();
+ var componentName = getComponentName(returnFiber.type) || "Component";
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
+ if (ownerHasKeyUseWarning[componentName]) {
return;
}
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
+ ownerHasKeyUseWarning[componentName] = true;
error(
"Each child in a list should have a unique " +
@@ -8018,9 +8239,8 @@ function coerceRef(returnFiber, current, element) {
"String refs are a source of potential bugs and should be avoided. " +
"We recommend using useRef() or createRef() instead. " +
"Learn more about using refs safely here: " +
- "https://fb.me/react-strict-mode-string-ref%s",
- mixedRef,
- getStackByFiberInDevAndProd(returnFiber)
+ "https://fb.me/react-strict-mode-string-ref",
+ mixedRef
);
}
@@ -8103,41 +8323,27 @@ function coerceRef(returnFiber, current, element) {
function throwOnInvalidObjectType(returnFiber, newChild) {
if (returnFiber.type !== "textarea") {
- var addendum = "";
-
- {
- addendum =
- " If you meant to render a collection of children, use an array " +
- "instead." +
- getCurrentFiberStackInDev();
- }
-
{
throw Error(
"Objects are not valid as a React child (found: " +
(Object.prototype.toString.call(newChild) === "[object Object]"
? "object with keys {" + Object.keys(newChild).join(", ") + "}"
: newChild) +
- ")." +
- addendum
+ "). If you meant to render a collection of children, use an array instead."
);
}
}
}
-function warnOnFunctionType() {
+function warnOnFunctionType(returnFiber) {
{
- var currentComponentErrorInfo =
- "Functions are not valid as a React child. This may happen if " +
- "you return a Component instead of from render. " +
- "Or maybe you meant to call this function rather than return it." +
- getCurrentFiberStackInDev();
+ var componentName = getComponentName(returnFiber.type) || "Component";
- if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
+ if (ownerHasFunctionTypeWarning[componentName]) {
return;
}
- ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
+ ownerHasFunctionTypeWarning[componentName] = true;
error(
"Functions are not valid as a React child. This may happen if " +
@@ -8145,7 +8351,7 @@ function warnOnFunctionType() {
"Or maybe you meant to call this function rather than return it."
);
}
-} // This wrapper function exists because I expect to clone the code in each path
+} // We avoid inlining this to avoid potential deopts from using try/catch.
// to be able to optimize each path individually by branching early. This needs
// a compiler or we can do it manually. Helpers that don't need this branching
// live outside of this function.
@@ -8258,14 +8464,10 @@ function ChildReconciler(shouldTrackSideEffects) {
return newFiber;
}
- function updateTextNode(returnFiber, current, textContent, expirationTime) {
+ function updateTextNode(returnFiber, current, textContent, lanes) {
if (current === null || current.tag !== HostText) {
// Insert
- var created = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromText(textContent, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
} else {
@@ -8276,7 +8478,7 @@ function ChildReconciler(shouldTrackSideEffects) {
}
}
- function updateElement(returnFiber, current, element, expirationTime) {
+ function updateElement(returnFiber, current, element, lanes) {
if (current !== null) {
if (
current.elementType === element.type || // Keep this check inline so it only runs on the false path:
@@ -8296,17 +8498,13 @@ function ChildReconciler(shouldTrackSideEffects) {
}
} // Insert
- var created = createFiberFromElement(
- element,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromElement(element, returnFiber.mode, lanes);
created.ref = coerceRef(returnFiber, current, element);
created.return = returnFiber;
return created;
}
- function updatePortal(returnFiber, current, portal, expirationTime) {
+ function updatePortal(returnFiber, current, portal, lanes) {
if (
current === null ||
current.tag !== HostPortal ||
@@ -8314,11 +8512,7 @@ function ChildReconciler(shouldTrackSideEffects) {
current.stateNode.implementation !== portal.implementation
) {
// Insert
- var created = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
} else {
@@ -8329,13 +8523,13 @@ function ChildReconciler(shouldTrackSideEffects) {
}
}
- function updateFragment(returnFiber, current, fragment, expirationTime, key) {
+ function updateFragment(returnFiber, current, fragment, lanes, key) {
if (current === null || current.tag !== Fragment) {
// Insert
var created = createFiberFromFragment(
fragment,
returnFiber.mode,
- expirationTime,
+ lanes,
key
);
created.return = returnFiber;
@@ -8348,16 +8542,12 @@ function ChildReconciler(shouldTrackSideEffects) {
}
}
- function createChild(returnFiber, newChild, expirationTime) {
+ function createChild(returnFiber, newChild, lanes) {
if (typeof newChild === "string" || typeof newChild === "number") {
// Text nodes don't have keys. If the previous node is implicitly keyed
// we can continue to replace it without aborting even if it is not a text
// node.
- var created = createFiberFromText(
- "" + newChild,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromText("" + newChild, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
}
@@ -8368,7 +8558,7 @@ function ChildReconciler(shouldTrackSideEffects) {
var _created = createFiberFromElement(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
_created.ref = coerceRef(returnFiber, null, newChild);
@@ -8380,7 +8570,7 @@ function ChildReconciler(shouldTrackSideEffects) {
var _created2 = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
_created2.return = returnFiber;
@@ -8392,7 +8582,7 @@ function ChildReconciler(shouldTrackSideEffects) {
var _created3 = createFiberFromFragment(
newChild,
returnFiber.mode,
- expirationTime,
+ lanes,
null
);
@@ -8405,14 +8595,14 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
return null;
}
- function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
+ function updateSlot(returnFiber, oldFiber, newChild, lanes) {
// Update the fiber if the keys match, otherwise return null.
var key = oldFiber !== null ? oldFiber.key : null;
@@ -8424,12 +8614,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return null;
}
- return updateTextNode(
- returnFiber,
- oldFiber,
- "" + newChild,
- expirationTime
- );
+ return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
}
if (typeof newChild === "object" && newChild !== null) {
@@ -8441,17 +8626,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChild.props.children,
- expirationTime,
+ lanes,
key
);
}
- return updateElement(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime
- );
+ return updateElement(returnFiber, oldFiber, newChild, lanes);
} else {
return null;
}
@@ -8459,12 +8639,7 @@ function ChildReconciler(shouldTrackSideEffects) {
case REACT_PORTAL_TYPE: {
if (newChild.key === key) {
- return updatePortal(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime
- );
+ return updatePortal(returnFiber, oldFiber, newChild, lanes);
} else {
return null;
}
@@ -8476,13 +8651,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return null;
}
- return updateFragment(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime,
- null
- );
+ return updateFragment(returnFiber, oldFiber, newChild, lanes, null);
}
throwOnInvalidObjectType(returnFiber, newChild);
@@ -8490,7 +8659,7 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
@@ -8502,18 +8671,13 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChild,
- expirationTime
+ lanes
) {
if (typeof newChild === "string" || typeof newChild === "number") {
// Text nodes don't have keys, so we neither have to check the old nor
// new node for the key. If both are text nodes, they match.
var matchedFiber = existingChildren.get(newIdx) || null;
- return updateTextNode(
- returnFiber,
- matchedFiber,
- "" + newChild,
- expirationTime
- );
+ return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes);
}
if (typeof newChild === "object" && newChild !== null) {
@@ -8529,17 +8693,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
_matchedFiber,
newChild.props.children,
- expirationTime,
+ lanes,
newChild.key
);
}
- return updateElement(
- returnFiber,
- _matchedFiber,
- newChild,
- expirationTime
- );
+ return updateElement(returnFiber, _matchedFiber, newChild, lanes);
}
case REACT_PORTAL_TYPE: {
@@ -8548,12 +8707,7 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild.key === null ? newIdx : newChild.key
) || null;
- return updatePortal(
- returnFiber,
- _matchedFiber2,
- newChild,
- expirationTime
- );
+ return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);
}
}
@@ -8564,7 +8718,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
_matchedFiber3,
newChild,
- expirationTime,
+ lanes,
null
);
}
@@ -8574,7 +8728,7 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
@@ -8584,7 +8738,7 @@ function ChildReconciler(shouldTrackSideEffects) {
* Warns if there is a duplicate or missing key
*/
- function warnOnInvalidKey(child, knownKeys) {
+ function warnOnInvalidKey(child, knownKeys, returnFiber) {
{
if (typeof child !== "object" || child === null) {
return knownKeys;
@@ -8593,7 +8747,7 @@ function ChildReconciler(shouldTrackSideEffects) {
switch (child.$$typeof) {
case REACT_ELEMENT_TYPE:
case REACT_PORTAL_TYPE:
- warnForMissingKey(child);
+ warnForMissingKey(child, returnFiber);
var key = child.key;
if (typeof key !== "string") {
@@ -8631,7 +8785,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildren,
- expirationTime
+ lanes
) {
// This algorithm can't optimize by searching from both ends since we
// don't have backpointers on fibers. I'm trying to see how far we can get
@@ -8654,7 +8808,7 @@ function ChildReconciler(shouldTrackSideEffects) {
for (var i = 0; i < newChildren.length; i++) {
var child = newChildren[i];
- knownKeys = warnOnInvalidKey(child, knownKeys);
+ knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
}
}
@@ -8677,7 +8831,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (newFiber === null) {
@@ -8727,11 +8881,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// If we don't have any more existing children we can choose a fast path
// since the rest will all be insertions.
for (; newIdx < newChildren.length; newIdx++) {
- var _newFiber = createChild(
- returnFiber,
- newChildren[newIdx],
- expirationTime
- );
+ var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);
if (_newFiber === null) {
continue;
@@ -8760,7 +8910,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (_newFiber2 !== null) {
@@ -8803,7 +8953,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildrenIterable,
- expirationTime
+ lanes
) {
// This is the same implementation as reconcileChildrenArray(),
// but using the iterator instead.
@@ -8838,9 +8988,8 @@ function ChildReconciler(shouldTrackSideEffects) {
if (newChildrenIterable.entries === iteratorFn) {
if (!didWarnAboutMaps) {
error(
- "Using Maps as children is unsupported and will likely yield " +
- "unexpected results. Convert it to a sequence/iterable of keyed " +
- "ReactElements instead."
+ "Using Maps as children is not supported. " +
+ "Use an array of keyed ReactElements instead."
);
}
@@ -8857,7 +9006,7 @@ function ChildReconciler(shouldTrackSideEffects) {
for (; !_step.done; _step = _newChildren.next()) {
var child = _step.value;
- knownKeys = warnOnInvalidKey(child, knownKeys);
+ knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
}
}
}
@@ -8888,12 +9037,7 @@ function ChildReconciler(shouldTrackSideEffects) {
nextOldFiber = oldFiber.sibling;
}
- var newFiber = updateSlot(
- returnFiber,
- oldFiber,
- step.value,
- expirationTime
- );
+ var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
if (newFiber === null) {
// TODO: This breaks on empty slots like null children. That's
@@ -8942,7 +9086,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// If we don't have any more existing children we can choose a fast path
// since the rest will all be insertions.
for (; !step.done; newIdx++, step = newChildren.next()) {
- var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
+ var _newFiber3 = createChild(returnFiber, step.value, lanes);
if (_newFiber3 === null) {
continue;
@@ -8971,7 +9115,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
step.value,
- expirationTime
+ lanes
);
if (_newFiber4 !== null) {
@@ -9014,7 +9158,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
textContent,
- expirationTime
+ lanes
) {
// There's no need to check for keys on text nodes since we don't have a
// way to define them.
@@ -9029,11 +9173,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// and delete the existing ones.
deleteRemainingChildren(returnFiber, currentFirstChild);
- var created = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromText(textContent, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
}
@@ -9042,7 +9182,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
element,
- expirationTime
+ lanes
) {
var key = element.key;
var child = currentFirstChild;
@@ -9111,17 +9251,13 @@ function ChildReconciler(shouldTrackSideEffects) {
var created = createFiberFromFragment(
element.props.children,
returnFiber.mode,
- expirationTime,
+ lanes,
element.key
);
created.return = returnFiber;
return created;
} else {
- var _created4 = createFiberFromElement(
- element,
- returnFiber.mode,
- expirationTime
- );
+ var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);
_created4.ref = coerceRef(returnFiber, currentFirstChild, element);
_created4.return = returnFiber;
@@ -9133,7 +9269,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
portal,
- expirationTime
+ lanes
) {
var key = portal.key;
var child = currentFirstChild;
@@ -9162,11 +9298,7 @@ function ChildReconciler(shouldTrackSideEffects) {
child = child.sibling;
}
- var created = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
} // This API will tag the children with the side-effect of the reconciliation
@@ -9177,7 +9309,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
) {
// This function is not recursive.
// If the top level item is an array, we treat it as a set of children,
@@ -9206,7 +9338,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
)
);
@@ -9216,7 +9348,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
)
);
}
@@ -9228,7 +9360,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
"" + newChild,
- expirationTime
+ lanes
)
);
}
@@ -9238,7 +9370,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
}
@@ -9247,7 +9379,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
}
@@ -9257,7 +9389,7 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
@@ -9327,11 +9459,11 @@ function cloneChildFibers(current, workInProgress) {
newChild.sibling = null;
} // Reset a workInProgress child set to prepare it for a second pass.
-function resetChildFibers(workInProgress, renderExpirationTime) {
+function resetChildFibers(workInProgress, lanes) {
var child = workInProgress.child;
while (child !== null) {
- resetWorkInProgress(child, renderExpirationTime);
+ resetWorkInProgress(child, lanes);
child = child.sibling;
}
}
@@ -9449,6 +9581,13 @@ function popSuspenseContext(fiber) {
pop(suspenseStackCursor, fiber);
}
+// A non-null SuspenseState means that it is blocked for one reason or another.
+// - A non-null dehydrated field means it's blocked pending hydration.
+// - A non-null dehydrated field can use isSuspenseInstancePending or
+// isSuspenseInstanceFallback to query the reason for being dehydrated.
+// - A null dehydrated field means it's blocked by something suspending and
+// we're currently showing a fallback instead.
+
function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
// If it was the primary children that just suspended, capture and render the
// fallback. Otherwise, don't capture and bubble to the next boundary.
@@ -9546,6 +9685,10 @@ function createDeprecatedResponderListener(responder, props) {
return eventResponderListener;
}
+var NoEffect$1 =
+ /* */
+ 0; // Represents whether effect should fire.
+
var HasEffect =
/* */
1; // Represents the phase in which the effect (not the clean-up) fires.
@@ -9557,16 +9700,113 @@ var Passive$1 =
/* */
4;
-var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
+var isHydrating = false;
+
+function enterHydrationState(fiber) {
+ {
+ return false;
+ }
+}
+
+function prepareToHydrateHostInstance(
+ fiber,
+ rootContainerInstance,
+ hostContext
+) {
+ {
+ {
+ throw Error(
+ "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
+ }
+}
+
+function prepareToHydrateHostTextInstance(fiber) {
+ {
+ {
+ throw Error(
+ "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
+ }
+ var shouldUpdate = hydrateTextInstance();
+}
+
+function popHydrationState(fiber) {
+ {
+ return false;
+ }
+}
+
+function getIsHydrating() {
+ return isHydrating;
+}
+
+// and should be reset before starting a new render.
+// This tracks which mutable sources need to be reset after a render.
+
+var workInProgressSources = [];
+var rendererSigil$1;
+
+{
+ // Used to detect multiple renderers using the same mutable source.
+ rendererSigil$1 = {};
+}
+
+function markSourceAsDirty(mutableSource) {
+ workInProgressSources.push(mutableSource);
+}
+function resetWorkInProgressVersions() {
+ for (var i = 0; i < workInProgressSources.length; i++) {
+ var mutableSource = workInProgressSources[i];
+
+ {
+ mutableSource._workInProgressVersionSecondary = null;
+ }
+ }
+
+ workInProgressSources.length = 0;
+}
+function getWorkInProgressVersion(mutableSource) {
+ {
+ return mutableSource._workInProgressVersionSecondary;
+ }
+}
+function setWorkInProgressVersion(mutableSource, version) {
+ {
+ mutableSource._workInProgressVersionSecondary = version;
+ }
+
+ workInProgressSources.push(mutableSource);
+}
+function warnAboutMultipleRenderersDEV(mutableSource) {
+ {
+ {
+ if (mutableSource._currentSecondaryRenderer == null) {
+ mutableSource._currentSecondaryRenderer = rendererSigil$1;
+ } else if (mutableSource._currentSecondaryRenderer !== rendererSigil$1) {
+ error(
+ "Detected multiple renderers concurrently rendering the " +
+ "same mutable source. This is currently unsupported."
+ );
+ }
+ }
+ }
+} // Eager reads the version of a mutable source and stores it on the root.
+
+var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
var didWarnAboutMismatchedHooksForComponent;
+var didWarnAboutUseOpaqueIdentifier;
{
+ didWarnAboutUseOpaqueIdentifier = {};
didWarnAboutMismatchedHooksForComponent = new Set();
}
// These are set right before calling the component.
-var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from
+var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from
// the work-in-progress hook.
var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
@@ -9580,7 +9820,12 @@ var workInProgressHook = null; // Whether an update was scheduled at any point d
// finished evaluating this component. This is an optimization so we know
// whether we need to clear render phase updates after a throw.
-var didScheduleRenderPhaseUpdate = false;
+var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This
+// gets reset after each attempt.
+// TODO: Maybe there's some way to consolidate this with
+// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`.
+
+var didScheduleRenderPhaseUpdateDuringThisPass = false;
var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
@@ -9739,9 +9984,9 @@ function renderWithHooks(
Component,
props,
secondArg,
- nextRenderExpirationTime
+ nextRenderLanes
) {
- renderExpirationTime = nextRenderExpirationTime;
+ renderLanes = nextRenderLanes;
currentlyRenderingFiber$1 = workInProgress;
{
@@ -9754,7 +9999,7 @@ function renderWithHooks(
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- workInProgress.expirationTime = NoWork; // The following should have already been reset
+ workInProgress.lanes = NoLanes; // The following should have already been reset
// currentHook = null;
// workInProgressHook = null;
// didScheduleRenderPhaseUpdate = false;
@@ -9767,28 +10012,28 @@ function renderWithHooks(
{
if (current !== null && current.memoizedState !== null) {
- ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
} else if (hookTypesDev !== null) {
// This dispatcher handles an edge case where a component is updating,
// but no stateful hooks have been used.
// We want to match the production code behavior (which will use HooksDispatcherOnMount),
// but with the extra DEV validation to ensure hooks ordering hasn't changed.
// This dispatcher does that.
- ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
} else {
- ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
}
}
var children = Component(props, secondArg); // Check if there was a render phase update
- if (workInProgress.expirationTime === renderExpirationTime) {
+ if (didScheduleRenderPhaseUpdateDuringThisPass) {
// Keep rendering in a loop for as long as render phase updates continue to
// be scheduled. Use a counter to prevent infinite loops.
var numberOfReRenders = 0;
do {
- workInProgress.expirationTime = NoWork;
+ didScheduleRenderPhaseUpdateDuringThisPass = false;
if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
throw Error(
@@ -9813,13 +10058,13 @@ function renderWithHooks(
hookTypesUpdateIndexDev = -1;
}
- ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV;
children = Component(props, secondArg);
- } while (workInProgress.expirationTime === renderExpirationTime);
+ } while (didScheduleRenderPhaseUpdateDuringThisPass);
} // We can assume the previous dispatcher is always this one, since we set it
// at the beginning of the render phase and there's no re-entrancy.
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
{
workInProgress._debugHookTypes = hookTypesDev;
@@ -9827,7 +10072,7 @@ function renderWithHooks(
// hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
- renderExpirationTime = NoWork;
+ renderLanes = NoLanes;
currentlyRenderingFiber$1 = null;
currentHook = null;
workInProgressHook = null;
@@ -9848,18 +10093,15 @@ function renderWithHooks(
return children;
}
-function bailoutHooks(current, workInProgress, expirationTime) {
+function bailoutHooks(current, workInProgress, lanes) {
workInProgress.updateQueue = current.updateQueue;
workInProgress.effectTag &= ~(Passive | Update);
-
- if (current.expirationTime <= expirationTime) {
- current.expirationTime = NoWork;
- }
+ current.lanes = removeLanes(current.lanes, lanes);
}
function resetHooksAfterThrow() {
// We can assume the previous dispatcher is always this one, since we set it
// at the beginning of the render phase and there's no re-entrancy.
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
if (didScheduleRenderPhaseUpdate) {
// There were render phase updates. These are only valid for this render
@@ -9881,9 +10123,11 @@ function resetHooksAfterThrow() {
hook = hook.next;
}
+
+ didScheduleRenderPhaseUpdate = false;
}
- renderExpirationTime = NoWork;
+ renderLanes = NoLanes;
currentlyRenderingFiber$1 = null;
currentHook = null;
workInProgressHook = null;
@@ -9892,9 +10136,10 @@ function resetHooksAfterThrow() {
hookTypesDev = null;
hookTypesUpdateIndexDev = -1;
currentHookNameInDev = null;
+ isUpdatingOpaqueValueInRenderPhase = false;
}
- didScheduleRenderPhaseUpdate = false;
+ didScheduleRenderPhaseUpdateDuringThisPass = false;
}
function mountWorkInProgressHook() {
@@ -10041,6 +10286,17 @@ function updateReducer(reducer, initialArg, init) {
pendingQueue.next = baseFirst;
}
+ {
+ if (current.baseQueue !== baseQueue) {
+ // Internal invariant that should never happen, but feasibly could in
+ // the future if we implement resuming, or some form of that.
+ error(
+ "Internal error: Expected work-in-progress queue to be a clone. " +
+ "This is a bug in React."
+ );
+ }
+ }
+
current.baseQueue = baseQueue = pendingQueue;
queue.pending = null;
}
@@ -10055,15 +10311,18 @@ function updateReducer(reducer, initialArg, init) {
var update = first;
do {
- var updateExpirationTime = update.expirationTime;
+ var suspenseConfig = update.suspenseConfig;
+ var updateLane = update.lane;
+ var updateEventTime = update.eventTime;
- if (updateExpirationTime < renderExpirationTime) {
+ if (!isSubsetOfLanes(renderLanes, updateLane)) {
// Priority is insufficient. Skip this update. If this is the first
// skipped update, the previous update/state is the new base
// update/state.
var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
@@ -10076,17 +10335,23 @@ function updateReducer(reducer, initialArg, init) {
} else {
newBaseQueueLast = newBaseQueueLast.next = clone;
} // Update the remaining priority in the queue.
+ // TODO: Don't need to accumulate this. Instead, we can remove
+ // renderLanes from the original lanes.
- if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) {
- currentlyRenderingFiber$1.expirationTime = updateExpirationTime;
- markUnprocessedUpdateTime(updateExpirationTime);
- }
+ currentlyRenderingFiber$1.lanes = mergeLanes(
+ currentlyRenderingFiber$1.lanes,
+ updateLane
+ );
+ markSkippedUpdateLanes(updateLane);
} else {
// This update does have sufficient priority.
if (newBaseQueueLast !== null) {
var _clone = {
- expirationTime: Sync,
- // This update is going to be committed so we never want uncommit it.
+ eventTime: updateEventTime,
+ // This update is going to be committed so we never want uncommit
+ // it. Using NoLane works because 0 is a subset of all bitmasks, so
+ // this will never be skipped by the check above.
+ lane: NoLane,
suspenseConfig: update.suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
@@ -10096,15 +10361,12 @@ function updateReducer(reducer, initialArg, init) {
newBaseQueueLast = newBaseQueueLast.next = _clone;
} // Mark the event time of this update as relevant to this render pass.
// TODO: This should ideally use the true event time of this update rather than
- // its priority which is a derived and not reverseable value.
+ // its priority which is a derived and not reversible value.
// TODO: We should skip this update if it was already committed but currently
// we have no way of detecting the difference between a committed and suspended
// update here.
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ); // Process this update.
+ markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); // Process this update.
if (update.eagerReducer === reducer) {
// If this update was processed eagerly, and its reducer matches the
@@ -10186,10 +10448,257 @@ function rerenderReducer(reducer, initialArg, init) {
hook.baseState = newState;
}
- queue.lastRenderedState = newState;
+ queue.lastRenderedState = newState;
+ }
+
+ return [newState, dispatch];
+}
+
+function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+ {
+ warnAboutMultipleRenderersDEV(source);
+ }
+
+ var getVersion = source._getVersion;
+ var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render?
+
+ var isSafeToReadFromSource = false; // Check the version first.
+ // If this render has already been started with a specific version,
+ // we can use it alone to determine if we can safely read from the source.
+
+ var currentRenderVersion = getWorkInProgressVersion(source);
+
+ if (currentRenderVersion !== null) {
+ // It's safe to read if the store hasn't been mutated since the last time
+ // we read something.
+ isSafeToReadFromSource = currentRenderVersion === version;
+ } else {
+ // If there's no version, then this is the first time we've read from the
+ // source during the current render pass, so we need to do a bit more work.
+ // What we need to determine is if there are any hooks that already
+ // subscribed to the source, and if so, whether there are any pending
+ // mutations that haven't been synchronized yet.
+ //
+ // If there are no pending mutations, then `root.mutableReadLanes` will be
+ // empty, and we know we can safely read.
+ //
+ // If there *are* pending mutations, we may still be able to safely read
+ // if the currently rendering lanes are inclusive of the pending mutation
+ // lanes, since that guarantees that the value we're about to read from
+ // the source is consistent with the values that we read during the most
+ // recent mutation.
+ isSafeToReadFromSource = isSubsetOfLanes(
+ renderLanes,
+ root.mutableReadLanes
+ );
+
+ if (isSafeToReadFromSource) {
+ // If it's safe to read from this source during the current render,
+ // store the version in case other components read from it.
+ // A changed version number will let those components know to throw and restart the render.
+ setWorkInProgressVersion(source, version);
+ }
+ }
+
+ if (isSafeToReadFromSource) {
+ var snapshot = getSnapshot(source._source);
+
+ {
+ if (typeof snapshot === "function") {
+ error(
+ "Mutable source should not return a function as the snapshot value. " +
+ "Functions may close over mutable values and cause tearing."
+ );
+ }
+ }
+
+ return snapshot;
+ } else {
+ // This handles the special case of a mutable source being shared between renderers.
+ // In that case, if the source is mutated between the first and second renderer,
+ // The second renderer don't know that it needs to reset the WIP version during unwind,
+ // (because the hook only marks sources as dirty if it's written to their WIP version).
+ // That would cause this tear check to throw again and eventually be visible to the user.
+ // We can avoid this infinite loop by explicitly marking the source as dirty.
+ //
+ // This can lead to tearing in the first renderer when it resumes,
+ // but there's nothing we can do about that (short of throwing here and refusing to continue the render).
+ markSourceAsDirty(source);
+
+ {
+ throw Error(
+ "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
+ );
+ }
+ }
+}
+
+function useMutableSource(hook, source, getSnapshot, subscribe) {
+ var root = getWorkInProgressRoot();
+
+ if (!(root !== null)) {
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ }
+
+ var getVersion = source._getVersion;
+ var version = getVersion(source._source);
+ var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const
+
+ var _dispatcher$useState = dispatcher.useState(function() {
+ return readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ }),
+ currentSnapshot = _dispatcher$useState[0],
+ setSnapshot = _dispatcher$useState[1];
+
+ var snapshot = currentSnapshot; // Grab a handle to the state hook as well.
+ // We use it to clear the pending update queue if we have a new source.
+
+ var stateHook = workInProgressHook;
+ var memoizedState = hook.memoizedState;
+ var refs = memoizedState.refs;
+ var prevGetSnapshot = refs.getSnapshot;
+ var prevSource = memoizedState.source;
+ var prevSubscribe = memoizedState.subscribe;
+ var fiber = currentlyRenderingFiber$1;
+ hook.memoizedState = {
+ refs: refs,
+ source: source,
+ subscribe: subscribe
+ }; // Sync the values needed by our subscription handler after each commit.
+
+ dispatcher.useEffect(
+ function() {
+ refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes,
+ // but this hook recreates the queue in certain cases to avoid updates from stale sources.
+ // handleChange() below needs to reference the dispatch function without re-subscribing,
+ // so we use a ref to ensure that it always has the latest version.
+
+ refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now.
+
+ var maybeNewVersion = getVersion(source._source);
+
+ if (!objectIs(version, maybeNewVersion)) {
+ var maybeNewSnapshot = getSnapshot(source._source);
+
+ {
+ if (typeof maybeNewSnapshot === "function") {
+ error(
+ "Mutable source should not return a function as the snapshot value. " +
+ "Functions may close over mutable values and cause tearing."
+ );
+ }
+ }
+
+ if (!objectIs(snapshot, maybeNewSnapshot)) {
+ setSnapshot(maybeNewSnapshot);
+ var suspenseConfig = requestCurrentSuspenseConfig();
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ markRootMutableRead(root, lane);
+ } // If the source mutated between render and now,
+ // there may be state updates already scheduled from the old source.
+ // Entangle the updates so that they render in the same batch.
+
+ markRootEntangled(root, root.mutableReadLanes);
+ }
+ },
+ [getSnapshot, source, subscribe]
+ ); // If we got a new source or subscribe function, re-subscribe in a passive effect.
+
+ dispatcher.useEffect(
+ function() {
+ var handleChange = function() {
+ var latestGetSnapshot = refs.getSnapshot;
+ var latestSetSnapshot = refs.setSnapshot;
+
+ try {
+ latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time.
+
+ var suspenseConfig = requestCurrentSuspenseConfig();
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ markRootMutableRead(root, lane);
+ } catch (error) {
+ // A selector might throw after a source mutation.
+ // e.g. it might try to read from a part of the store that no longer exists.
+ // In this case we should still schedule an update with React.
+ // Worst case the selector will throw again and then an error boundary will handle it.
+ latestSetSnapshot(function() {
+ throw error;
+ });
+ }
+ };
+
+ var unsubscribe = subscribe(source._source, handleChange);
+
+ {
+ if (typeof unsubscribe !== "function") {
+ error(
+ "Mutable source subscribe function must return an unsubscribe function."
+ );
+ }
+ }
+
+ return unsubscribe;
+ },
+ [source, subscribe]
+ ); // If any of the inputs to useMutableSource change, reading is potentially unsafe.
+ //
+ // If either the source or the subscription have changed we can't can't trust the update queue.
+ // Maybe the source changed in a way that the old subscription ignored but the new one depends on.
+ //
+ // If the getSnapshot function changed, we also shouldn't rely on the update queue.
+ // It's possible that the underlying source was mutated between the when the last "change" event fired,
+ // and when the current render (with the new getSnapshot function) is processed.
+ //
+ // In both cases, we need to throw away pending updates (since they are no longer relevant)
+ // and treat reading from the source as we do in the mount case.
+
+ if (
+ !objectIs(prevGetSnapshot, getSnapshot) ||
+ !objectIs(prevSource, source) ||
+ !objectIs(prevSubscribe, subscribe)
+ ) {
+ // Create a new queue and setState method,
+ // So if there are interleaved updates, they get pushed to the older queue.
+ // When this becomes current, the previous queue and dispatch method will be discarded,
+ // including any interleaving updates that occur.
+ var newQueue = {
+ pending: null,
+ dispatch: null,
+ lastRenderedReducer: basicStateReducer,
+ lastRenderedState: snapshot
+ };
+ newQueue.dispatch = setSnapshot = dispatchAction.bind(
+ null,
+ currentlyRenderingFiber$1,
+ newQueue
+ );
+ stateHook.queue = newQueue;
+ stateHook.baseQueue = null;
+ snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ stateHook.memoizedState = stateHook.baseState = snapshot;
}
- return [newState, dispatch];
+ return snapshot;
+}
+
+function mountMutableSource(source, getSnapshot, subscribe) {
+ var hook = mountWorkInProgressHook();
+ hook.memoizedState = {
+ refs: {
+ getSnapshot: getSnapshot,
+ setSnapshot: null
+ },
+ source: source,
+ subscribe: subscribe
+ };
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+}
+
+function updateMutableSource(source, getSnapshot, subscribe) {
+ var hook = updateWorkInProgressHook();
+ return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountState(initialState) {
@@ -10532,13 +11041,15 @@ function rerenderDeferredValue(value, config) {
function startTransition(setPending, config, callback) {
var priorityLevel = getCurrentPriorityLevel();
runWithPriority(
- priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel,
+ priorityLevel < UserBlockingPriority$1
+ ? UserBlockingPriority$1
+ : priorityLevel,
function() {
setPending(true);
}
- );
+ ); // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition.
runWithPriority(
- priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
+ priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel,
function() {
var previousConfig = ReactCurrentBatchConfig$1.suspense;
ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
@@ -10589,6 +11100,54 @@ function rerenderTransition(config) {
return [start, isPending];
}
+var isUpdatingOpaqueValueInRenderPhase = false;
+function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
+ {
+ return isUpdatingOpaqueValueInRenderPhase;
+ }
+}
+
+function warnOnOpaqueIdentifierAccessInDEV(fiber) {
+ {
+ // TODO: Should warn in effects and callbacks, too
+ var name = getComponentName(fiber.type) || "Unknown";
+
+ if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) {
+ error(
+ "The object passed back from useOpaqueIdentifier is meant to be " +
+ "passed through to attributes only. Do not read the " +
+ "value directly."
+ );
+
+ didWarnAboutUseOpaqueIdentifier[name] = true;
+ }
+ }
+}
+
+function mountOpaqueIdentifier() {
+ var makeId = makeClientIdInDEV.bind(
+ null,
+ warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)
+ );
+
+ {
+ var _id = makeId();
+
+ mountState(_id);
+ return _id;
+ }
+}
+
+function updateOpaqueIdentifier() {
+ var id = updateState()[0];
+ return id;
+}
+
+function rerenderOpaqueIdentifier() {
+ var id = rerenderState()[0];
+ return id;
+}
+
function dispatchAction(fiber, queue, action) {
{
if (typeof arguments[3] === "function") {
@@ -10600,25 +11159,18 @@ function dispatchAction(fiber, queue, action) {
}
}
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
+ var lane = requestUpdateLane(fiber, suspenseConfig);
var update = {
- expirationTime: expirationTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
action: action,
eagerReducer: null,
eagerState: null,
next: null
- };
-
- {
- update.priority = getCurrentPriorityLevel();
- } // Append the update to the end of the list.
+ }; // Append the update to the end of the list.
var pending = queue.pending;
@@ -10640,13 +11192,11 @@ function dispatchAction(fiber, queue, action) {
// This is a render phase update. Stash it in a lazily-created map of
// queue -> linked list of updates. After this render pass, we'll restart
// and apply the stashed updates on top of the work-in-progress hook.
- didScheduleRenderPhaseUpdate = true;
- update.expirationTime = renderExpirationTime;
- currentlyRenderingFiber$1.expirationTime = renderExpirationTime;
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
} else {
if (
- fiber.expirationTime === NoWork &&
- (alternate === null || alternate.expirationTime === NoWork)
+ fiber.lanes === NoLanes &&
+ (alternate === null || alternate.lanes === NoLanes)
) {
// The queue is currently empty, which means we can eagerly compute the
// next state before entering the render phase. If the new state is the
@@ -10657,8 +11207,8 @@ function dispatchAction(fiber, queue, action) {
var prevDispatcher;
{
- prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
}
try {
@@ -10682,24 +11232,16 @@ function dispatchAction(fiber, queue, action) {
// Suppress the error. It will throw again in the render phase.
} finally {
{
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
}
}
}
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
}
-function mountEventListener(event) {
- return undefined;
-}
-
-function updateEventListener(event) {
- return undefined;
-}
-
var ContextOnlyDispatcher = {
readContext: readContext,
useCallback: throwInvalidHookError,
@@ -10715,7 +11257,9 @@ var ContextOnlyDispatcher = {
useResponder: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
- useEvent: throwInvalidHookError
+ useMutableSource: throwInvalidHookError,
+ useOpaqueIdentifier: throwInvalidHookError,
+ unstable_isNewReconciler: enableNewReconciler
};
var HooksDispatcherOnMountInDEV = null;
var HooksDispatcherOnMountWithHookTypesInDEV = null;
@@ -10781,25 +11325,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
mountHookTypesDev();
checkDepsAreArrayDev(deps);
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -10810,13 +11354,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -10839,11 +11383,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
mountHookTypesDev();
- return mountEventListener();
- }
+ return mountMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ mountHookTypesDev();
+ return mountOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
HooksDispatcherOnMountWithHookTypesInDEV = {
readContext: function(context, observedBits) {
@@ -10877,25 +11427,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMemo: function(create, deps) {
currentHookNameInDev = "useMemo";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -10906,13 +11456,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -10935,11 +11485,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return mountTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return mountEventListener();
- }
+ return mountMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ updateHookTypesDev();
+ return mountOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
HooksDispatcherOnUpdateInDEV = {
readContext: function(context, observedBits) {
@@ -10973,25 +11529,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMemo: function(create, deps) {
currentHookNameInDev = "useMemo";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11002,13 +11558,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11031,11 +11587,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ updateHookTypesDev();
+ return updateOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
HooksDispatcherOnRerenderInDEV = {
readContext: function(context, observedBits) {
@@ -11069,25 +11631,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMemo: function(create, deps) {
currentHookNameInDev = "useMemo";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
try {
return rerenderReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11098,13 +11660,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
try {
return rerenderState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11127,11 +11689,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return rerenderTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ updateHookTypesDev();
+ return rerenderOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
InvalidNestedHooksDispatcherOnMountInDEV = {
readContext: function(context, observedBits) {
@@ -11172,26 +11740,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
warnInvalidHookAccess();
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
warnInvalidHookAccess();
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11204,13 +11772,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useState";
warnInvalidHookAccess();
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11237,12 +11805,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
mountHookTypesDev();
- return mountEventListener();
- }
+ return mountMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ warnInvalidHookAccess();
+ mountHookTypesDev();
+ return mountOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
InvalidNestedHooksDispatcherOnUpdateInDEV = {
readContext: function(context, observedBits) {
@@ -11283,26 +11858,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11315,13 +11890,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useState";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11348,12 +11923,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
InvalidNestedHooksDispatcherOnRerenderInDEV = {
readContext: function(context, observedBits) {
@@ -11394,26 +11976,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return rerenderReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11426,13 +12008,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useState";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return rerenderState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11459,12 +12041,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return rerenderTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return rerenderOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
}
@@ -11505,40 +12094,15 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
}
}
-function enterHydrationState(fiber) {
- {
- return false;
- }
-}
-
-function prepareToHydrateHostInstance(
- fiber,
- rootContainerInstance,
- hostContext
-) {
- {
- {
- throw Error(
- "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
- );
- }
- }
-}
-
-function prepareToHydrateHostTextInstance(fiber) {
- {
- {
- throw Error(
- "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
- );
- }
- }
- var shouldUpdate = hydrateTextInstance();
-}
+function transferActualDuration(fiber) {
+ // Transfer time spent rendering these children so we don't lose it
+ // after we rerender. This is used as a helper in special cases
+ // where we should count the work of multiple passes.
+ var child = fiber.child;
-function popHydrationState(fiber) {
- {
- return false;
+ while (child) {
+ fiber.actualDuration += child.actualDuration;
+ child = child.sibling;
}
}
@@ -11564,12 +12128,7 @@ var didWarnAboutTailOptions;
didWarnAboutTailOptions = {};
}
-function reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
-) {
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
if (current === null) {
// If this is a fresh new component that hasn't been rendered yet, we
// won't update its child set by applying minimal side-effects. Instead,
@@ -11579,7 +12138,7 @@ function reconcileChildren(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
} else {
// If the current child is the same as the work in progress, it means that
@@ -11591,7 +12150,7 @@ function reconcileChildren(
workInProgress,
current.child,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
}
@@ -11600,7 +12159,7 @@ function forceUnmountCurrentAndReconcile(
current,
workInProgress,
nextChildren,
- renderExpirationTime
+ renderLanes
) {
// This function is fork of reconcileChildren. It's used in cases where we
// want to reconcile without matching against the existing set. This has the
@@ -11614,7 +12173,7 @@ function forceUnmountCurrentAndReconcile(
workInProgress,
current.child,
null,
- renderExpirationTime
+ renderLanes
); // In the second pass, we mount the new children. The trick here is that we
// pass null in place of where we usually pass the current child set. This has
// the effect of remounting all children regardless of whether their
@@ -11624,7 +12183,7 @@ function forceUnmountCurrentAndReconcile(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
@@ -11633,7 +12192,7 @@ function updateForwardRef(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
// TODO: current can be non-null here even if the component
// hasn't yet mounted. This happens after the first render suspends.
@@ -11659,7 +12218,7 @@ function updateForwardRef(
var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
var nextChildren;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
{
ReactCurrentOwner$1.current = workInProgress;
@@ -11670,20 +12229,23 @@ function updateForwardRef(
render,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
if (workInProgress.mode & StrictMode) {
- // Only double-render components with Hooks
- if (workInProgress.memoizedState !== null) {
+ disableLogs();
+
+ try {
nextChildren = renderWithHooks(
current,
workInProgress,
render,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
+ } finally {
+ reenableLogs();
}
}
@@ -11691,21 +12253,12 @@ function updateForwardRef(
}
if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderExpirationTime);
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
} // React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -11714,8 +12267,8 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (current === null) {
var type = Component.type;
@@ -11745,8 +12298,8 @@ function updateMemoComponent(
workInProgress,
resolvedType,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -11771,7 +12324,7 @@ function updateMemoComponent(
nextProps,
null,
workInProgress.mode,
- renderExpirationTime
+ renderLanes
);
child.ref = workInProgress.ref;
child.return = workInProgress;
@@ -11797,7 +12350,7 @@ function updateMemoComponent(
var currentChild = current.child; // This is always exactly one child
- if (updateExpirationTime < renderExpirationTime) {
+ if (!includesSomeLane(updateLanes, renderLanes)) {
// This will be the props with resolved defaultProps,
// unlike current.memoizedProps which will be the unresolved ones.
var prevProps = currentChild.memoizedProps; // Default to shallow comparison
@@ -11806,11 +12359,7 @@ function updateMemoComponent(
compare = compare !== null ? compare : shallowEqual;
if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
} // React DevTools reads this flag.
@@ -11827,8 +12376,8 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
// TODO: current can be non-null here even if the component
// hasn't yet mounted. This happens when the inner render suspends.
@@ -11843,19 +12392,27 @@ function updateSimpleMemoComponent(
// We warn when you define propTypes on lazy()
// so let's just skip over it to find memo() outer wrapper.
// Inner props for memo are validated later.
- outerMemoType = refineResolvedLazyComponent(outerMemoType);
- }
-
- var outerPropTypes = outerMemoType && outerMemoType.propTypes;
+ var lazyComponent = outerMemoType;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
- "prop",
- getComponentName(outerMemoType)
- );
- } // Inner propTypes will be validated in the function component path.
+ try {
+ outerMemoType = init(payload);
+ } catch (x) {
+ outerMemoType = null;
+ } // Inner propTypes will be validated in the function component path.
+
+ var outerPropTypes = outerMemoType && outerMemoType.propTypes;
+
+ if (outerPropTypes) {
+ checkPropTypes(
+ outerPropTypes,
+ nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
+ "prop",
+ getComponentName(outerMemoType)
+ );
+ }
+ }
}
}
@@ -11869,10 +12426,10 @@ function updateSimpleMemoComponent(
) {
didReceiveUpdate = false;
- if (updateExpirationTime < renderExpirationTime) {
- // The pending update priority was cleared at the beginning of
- // beginWork. We're about to bail out, but there might be additional
- // updates at a lower priority. Usually, the priority level of the
+ if (!includesSomeLane(renderLanes, updateLanes)) {
+ // The pending lanes were cleared at the beginning of beginWork. We're
+ // about to bail out, but there might be other lanes that weren't
+ // included in the current render. Usually, the priority level of the
// remaining updates is accumlated during the evaluation of the
// component (i.e. when processing the update queue). But since since
// we're bailing out early *without* evaluating the component, we need
@@ -11883,12 +12440,19 @@ function updateSimpleMemoComponent(
// contains hooks.
// TODO: Move the reset at in beginWork out of the common path so that
// this is no longer necessary.
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.lanes = current.lanes;
return bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
+ } else if (
+ (current.effectTag & ForceUpdateForLegacySuspense) !==
+ NoEffect
+ ) {
+ // This is a special case that only exists for legacy mode.
+ // See https://github.com/facebook/react/pull/19216.
+ didReceiveUpdate = true;
}
}
}
@@ -11898,33 +12462,101 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
);
}
-function updateFragment(current, workInProgress, renderExpirationTime) {
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps;
+ var nextChildren = nextProps.children;
+ var prevState = current !== null ? current.memoizedState : null;
+
+ if (
+ nextProps.mode === "hidden" ||
+ nextProps.mode === "unstable-defer-without-hiding"
+ ) {
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ // In legacy sync mode, don't defer the subtree. Render it now.
+ // TODO: Figure out what we should do in Blocking mode.
+ var nextState = {
+ baseLanes: NoLanes
+ };
+ workInProgress.memoizedState = nextState;
+ pushRenderLanes(workInProgress, renderLanes);
+ } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
+ var nextBaseLanes;
+
+ if (prevState !== null) {
+ var prevBaseLanes = prevState.baseLanes;
+ nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes);
+ } else {
+ nextBaseLanes = renderLanes;
+ } // Schedule this fiber to re-render at offscreen priority. Then bailout.
+
+ {
+ markSpawnedWork(OffscreenLane);
+ }
+
+ workInProgress.lanes = workInProgress.childLanes = laneToLanes(
+ OffscreenLane
+ );
+ var _nextState = {
+ baseLanes: nextBaseLanes
+ };
+ workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway
+ // to avoid a push/pop misalignment.
+
+ pushRenderLanes(workInProgress, nextBaseLanes);
+ return null;
+ } else {
+ // Rendering at offscreen, so we can clear the base lanes.
+ var _nextState2 = {
+ baseLanes: NoLanes
+ };
+ workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out.
+
+ var subtreeRenderLanes =
+ prevState !== null ? prevState.baseLanes : renderLanes;
+ pushRenderLanes(workInProgress, subtreeRenderLanes);
+ }
+ } else {
+ var _subtreeRenderLanes;
+
+ if (prevState !== null) {
+ _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state
+
+ workInProgress.memoizedState = null;
+ } else {
+ // We weren't previously hidden, and we still aren't, so there's nothing
+ // special to do. Need to push to the stack regardless, though, to avoid
+ // a push/pop misalignment.
+ _subtreeRenderLanes = renderLanes;
+ }
+
+ pushRenderLanes(workInProgress, _subtreeRenderLanes);
+ }
+
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+} // Note: These happen to have identical begin phases, for now. We shouldn't hold
+// ourselves to this constraint, though. If the behavior diverges, we should
+// fork the function.
+
+var updateLegacyHiddenComponent = updateOffscreenComponent;
+
+function updateFragment(current, workInProgress, renderLanes) {
var nextChildren = workInProgress.pendingProps;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function updateMode(current, workInProgress, renderExpirationTime) {
+function updateMode(current, workInProgress, renderLanes) {
var nextChildren = workInProgress.pendingProps.children;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function updateProfiler(current, workInProgress, renderExpirationTime) {
+function updateProfiler(current, workInProgress, renderLanes) {
{
workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase.
// These are reset during render to allow the DevTools commit hook a chance to read them,
@@ -11936,12 +12568,7 @@ function updateProfiler(current, workInProgress, renderExpirationTime) {
var nextProps = workInProgress.pendingProps;
var nextChildren = nextProps.children;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -11962,7 +12589,7 @@ function updateFunctionComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
{
if (workInProgress.type !== workInProgress.elementType) {
@@ -11989,7 +12616,7 @@ function updateFunctionComponent(
}
var nextChildren;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
{
ReactCurrentOwner$1.current = workInProgress;
@@ -12000,20 +12627,23 @@ function updateFunctionComponent(
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
if (workInProgress.mode & StrictMode) {
- // Only double-render components with Hooks
- if (workInProgress.memoizedState !== null) {
+ disableLogs();
+
+ try {
nextChildren = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
+ } finally {
+ reenableLogs();
}
}
@@ -12021,21 +12651,12 @@ function updateFunctionComponent(
}
if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderExpirationTime);
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
} // React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -12044,7 +12665,7 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
{
if (workInProgress.type !== workInProgress.elementType) {
@@ -12074,7 +12695,7 @@ function updateClassComponent(
hasContext = false;
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
var instance = workInProgress.stateNode;
var shouldUpdate;
@@ -12091,12 +12712,7 @@ function updateClassComponent(
} // In the initial pass we might need to construct the instance.
constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- );
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
shouldUpdate = true;
} else if (current === null) {
// In a resume, we'll already have an instance we can reuse.
@@ -12104,7 +12720,7 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
);
} else {
shouldUpdate = updateClassInstance(
@@ -12112,7 +12728,7 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
);
}
@@ -12122,13 +12738,13 @@ function updateClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
);
{
var inst = workInProgress.stateNode;
- if (inst.props !== nextProps) {
+ if (shouldUpdate && inst.props !== nextProps) {
if (!didWarnAboutReassigningProps) {
error(
"It looks like %s is reassigning its own `this.props` while rendering. " +
@@ -12150,7 +12766,7 @@ function finishClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
) {
// Refs should update even if shouldComponentUpdate returns false
markRef(current, workInProgress);
@@ -12162,11 +12778,7 @@ function finishClassComponent(
invalidateContextProvider(workInProgress, Component, false);
}
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
var instance = workInProgress.stateNode; // Rerender
@@ -12194,7 +12806,13 @@ function finishClassComponent(
nextChildren = instance.render();
if (workInProgress.mode & StrictMode) {
- instance.render();
+ disableLogs();
+
+ try {
+ instance.render();
+ } finally {
+ reenableLogs();
+ }
}
setIsRendering(false);
@@ -12212,15 +12830,10 @@ function finishClassComponent(
current,
workInProgress,
nextChildren,
- renderExpirationTime
+ renderLanes
);
} else {
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
} // Memoize state using the values we just used to render.
// TODO: Restructure so we never read values from the instance.
@@ -12250,7 +12863,7 @@ function pushHostRootContext(workInProgress) {
pushHostContainer(workInProgress, root.containerInfo);
}
-function updateHostRoot(current, workInProgress, renderExpirationTime) {
+function updateHostRoot(current, workInProgress, renderLanes) {
pushHostRootContext(workInProgress);
var updateQueue = workInProgress.updateQueue;
@@ -12264,32 +12877,24 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) {
var prevState = workInProgress.memoizedState;
var prevChildren = prevState !== null ? prevState.element : null;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime);
+ processUpdateQueue(workInProgress, nextProps, null, renderLanes);
var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
// being called "element".
var nextChildren = nextState.element;
if (nextChildren === prevChildren) {
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
var root = workInProgress.stateNode;
if (root.hydrate && enterHydrationState()) {
- // If we don't have any current children this might be the first pass.
- // We always try to hydrate. If this isn't a hydration pass there won't
- // be any children to hydrate which is effectively the same thing as
- // not hydrating.
var child = mountChildFibers(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
workInProgress.child = child;
var node = child;
@@ -12307,18 +12912,13 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) {
} else {
// Otherwise reset hydration state in case we aborted and resumed another
// root.
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
}
return workInProgress.child;
}
-function updateHostComponent(current, workInProgress, renderExpirationTime) {
+function updateHostComponent(current, workInProgress, renderLanes) {
pushHostContext(workInProgress);
var type = workInProgress.type;
@@ -12332,27 +12932,8 @@ function updateHostComponent(current, workInProgress, renderExpirationTime) {
workInProgress.effectTag |= ContentReset;
}
- markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden.
-
- if (
- workInProgress.mode & ConcurrentMode &&
- renderExpirationTime !== Never &&
- shouldDeprioritizeSubtree()
- ) {
- {
- markSpawnedWork(Never);
- } // Schedule this fiber to re-render at offscreen priority. Then bailout.
-
- workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
- return null;
- }
-
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ markRef(current, workInProgress);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -12366,8 +12947,8 @@ function mountLazyComponent(
_current,
workInProgress,
elementType,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (_current !== null) {
// A lazy component only mounts if it suspended inside a non-
@@ -12380,15 +12961,14 @@ function mountLazyComponent(
workInProgress.effectTag |= Placement;
}
- var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet.
- // Cancel and resume right after we know the tag.
-
- cancelWorkTimer(workInProgress);
- var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type.
+ var props = workInProgress.pendingProps;
+ var lazyComponent = elementType;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
+ var Component = init(payload); // Store the unwrapped component in the type.
workInProgress.type = Component;
var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component));
- startWorkTimer(workInProgress);
var resolvedProps = resolveDefaultProps(Component, props);
var child;
@@ -12406,7 +12986,7 @@ function mountLazyComponent(
workInProgress,
Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
return child;
}
@@ -12423,7 +13003,7 @@ function mountLazyComponent(
workInProgress,
Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
return child;
}
@@ -12440,7 +13020,7 @@ function mountLazyComponent(
workInProgress,
Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
return child;
}
@@ -12466,8 +13046,8 @@ function mountLazyComponent(
workInProgress,
Component,
resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
return child;
}
@@ -12502,7 +13082,7 @@ function mountIncompleteClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
if (_current !== null) {
// An incomplete component only mounts if it suspended inside a non-
@@ -12529,21 +13109,16 @@ function mountIncompleteClassComponent(
hasContext = false;
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- );
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
return finishClassComponent(
null,
workInProgress,
Component,
true,
hasContext,
- renderExpirationTime
+ renderLanes
);
}
@@ -12551,7 +13126,7 @@ function mountIndeterminateComponent(
_current,
workInProgress,
Component,
- renderExpirationTime
+ renderLanes
) {
if (_current !== null) {
// An indeterminate component only mounts if it suspended inside a non-
@@ -12572,7 +13147,7 @@ function mountIndeterminateComponent(
context = getMaskedContext(workInProgress, unmaskedContext);
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
var value;
{
@@ -12598,6 +13173,7 @@ function mountIndeterminateComponent(
ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
}
+ setIsRendering(true);
ReactCurrentOwner$1.current = workInProgress;
value = renderWithHooks(
null,
@@ -12605,34 +13181,65 @@ function mountIndeterminateComponent(
Component,
props,
context,
- renderExpirationTime
+ renderLanes
);
+ setIsRendering(false);
} // React DevTools reads this flag.
- workInProgress.effectTag |= PerformedWork;
+ workInProgress.effectTag |= PerformedWork;
+
+ {
+ // Support for module components is deprecated and is removed behind a flag.
+ // Whether or not it would crash later, we want to show a good message in DEV first.
+ if (
+ typeof value === "object" &&
+ value !== null &&
+ typeof value.render === "function" &&
+ value.$$typeof === undefined
+ ) {
+ var _componentName = getComponentName(Component) || "Unknown";
+
+ if (!didWarnAboutModulePatternComponent[_componentName]) {
+ error(
+ "The <%s /> component appears to be a function component that returns a class instance. " +
+ "Change %s to a class that extends React.Component instead. " +
+ "If you can't use a class try assigning the prototype on the function as a workaround. " +
+ "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " +
+ "cannot be called with `new` by React.",
+ _componentName,
+ _componentName,
+ _componentName
+ );
+
+ didWarnAboutModulePatternComponent[_componentName] = true;
+ }
+ }
+ }
if (
+ // Run these checks in production only if the flag is off.
+ // Eventually we'll delete this branch altogether.
typeof value === "object" &&
value !== null &&
typeof value.render === "function" &&
value.$$typeof === undefined
) {
{
- var _componentName = getComponentName(Component) || "Unknown";
+ var _componentName2 = getComponentName(Component) || "Unknown";
- if (!didWarnAboutModulePatternComponent[_componentName]) {
+ if (!didWarnAboutModulePatternComponent[_componentName2]) {
error(
"The <%s /> component appears to be a function component that returns a class instance. " +
"Change %s to a class that extends React.Component instead. " +
"If you can't use a class try assigning the prototype on the function as a workaround. " +
"`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " +
"cannot be called with `new` by React.",
- _componentName,
- _componentName,
- _componentName
+ _componentName2,
+ _componentName2,
+ _componentName2
);
- didWarnAboutModulePatternComponent[_componentName] = true;
+ didWarnAboutModulePatternComponent[_componentName2] = true;
}
} // Proceed under the assumption that this is a class instance
@@ -12667,14 +13274,14 @@ function mountIndeterminateComponent(
}
adoptClassInstance(workInProgress, value);
- mountClassInstance(workInProgress, Component, props, renderExpirationTime);
+ mountClassInstance(workInProgress, Component, props, renderLanes);
return finishClassComponent(
null,
workInProgress,
Component,
true,
hasContext,
- renderExpirationTime
+ renderLanes
);
} else {
// Proceed under the assumption that this is a function component
@@ -12682,21 +13289,24 @@ function mountIndeterminateComponent(
{
if (workInProgress.mode & StrictMode) {
- // Only double-render components with Hooks
- if (workInProgress.memoizedState !== null) {
+ disableLogs();
+
+ try {
value = renderWithHooks(
null,
workInProgress,
Component,
props,
context,
- renderExpirationTime
+ renderLanes
);
+ } finally {
+ reenableLogs();
}
}
}
- reconcileChildren(null, workInProgress, value, renderExpirationTime);
+ reconcileChildren(null, workInProgress, value, renderLanes);
{
validateFunctionComponentInDev(workInProgress, Component);
@@ -12745,15 +13355,15 @@ function validateFunctionComponentInDev(workInProgress, Component) {
}
if (typeof Component.getDerivedStateFromProps === "function") {
- var _componentName2 = getComponentName(Component) || "Unknown";
+ var _componentName3 = getComponentName(Component) || "Unknown";
- if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
+ if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
error(
"%s: Function components do not support getDerivedStateFromProps.",
- _componentName2
+ _componentName3
);
- didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
+ didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
}
}
@@ -12761,15 +13371,15 @@ function validateFunctionComponentInDev(workInProgress, Component) {
typeof Component.contextType === "object" &&
Component.contextType !== null
) {
- var _componentName3 = getComponentName(Component) || "Unknown";
+ var _componentName4 = getComponentName(Component) || "Unknown";
- if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
+ if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
error(
"%s: Function components do not support contextType.",
- _componentName3
+ _componentName4
);
- didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
+ didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
}
}
}
@@ -12777,24 +13387,51 @@ function validateFunctionComponentInDev(workInProgress, Component) {
var SUSPENDED_MARKER = {
dehydrated: null,
- retryTime: NoWork
+ retryLane: NoLane
};
-function shouldRemainOnFallback(suspenseContext, current, workInProgress) {
- // If the context is telling us that we should show a fallback, and we're not
- // already showing content, then we should show the fallback instead.
- return (
- hasSuspenseContext(suspenseContext, ForceSuspenseFallback) &&
- (current === null || current.memoizedState !== null)
- );
+function mountSuspenseOffscreenState(renderLanes) {
+ return {
+ baseLanes: renderLanes
+ };
+}
+
+function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
+ return {
+ baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes)
+ };
}
-function updateSuspenseComponent(
+function shouldRemainOnFallback(
+ suspenseContext,
current,
workInProgress,
- renderExpirationTime
+ renderLanes
) {
- var mode = workInProgress.mode;
+ // If we're already showing a fallback, there are cases where we need to
+ // remain on that fallback regardless of whether the content has resolved.
+ // For example, SuspenseList coordinates when nested content appears.
+ if (current !== null) {
+ var suspenseState = current.memoizedState;
+
+ if (suspenseState === null) {
+ // Currently showing content. Don't hide it, even if ForceSuspenseFallack
+ // is true. More precise name might be "ForceRemainSuspenseFallback".
+ // Note: This is a factoring smell. Can't remain on a fallback if there's
+ // no fallback to remain on.
+ return false;
+ }
+ } // Not currently showing content. Consult the Suspense context.
+
+ return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
+}
+
+function getRemainingWorkInPrimaryTree(current, renderLanes) {
+ // TODO: Should not remove render lanes that were pinged during this render
+ return removeLanes(current.childLanes, renderLanes);
+}
+
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
{
@@ -12804,13 +13441,13 @@ function updateSuspenseComponent(
}
var suspenseContext = suspenseStackCursor.current;
- var nextDidTimeout = false;
+ var showFallback = false;
var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
// Something in this boundary's subtree already suspended. Switch to
// rendering the fallback children.
- nextDidTimeout = true;
+ showFallback = true;
workInProgress.effectTag &= ~DidCapture;
} else {
// Attempting the main content
@@ -12833,290 +13470,380 @@ function updateSuspenseComponent(
}
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
- pushSuspenseContext(workInProgress, suspenseContext); // This next part is a bit confusing. If the children timeout, we switch to
- // showing the fallback children in place of the "primary" children.
- // However, we don't want to delete the primary children because then their
- // state will be lost (both the React state and the host state, e.g.
- // uncontrolled form inputs). Instead we keep them mounted and hide them.
- // Both the fallback children AND the primary children are rendered at the
- // same time. Once the primary children are un-suspended, we can delete
- // the fallback children — don't need to preserve their state.
+ pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense
+ // boundary's children. This involves some custom reconcilation logic. Two
+ // main reasons this is so complicated.
//
- // The two sets of children are siblings in the host environment, but
- // semantically, for purposes of reconciliation, they are two separate sets.
- // So we store them using two fragment fibers.
+ // First, Legacy Mode has different semantics for backwards compatibility. The
+ // primary tree will commit in an inconsistent state, so when we do the
+ // second pass to render the fallback, we do some exceedingly, uh, clever
+ // hacks to make that not totally break. Like transferring effects and
+ // deletions from hidden tree. In Concurrent Mode, it's much simpler,
+ // because we bailout on the primary tree completely and leave it in its old
+ // state, no effects. Same as what we do for Offscreen (except that
+ // Offscreen doesn't have the first render pass).
//
- // However, we want to avoid allocating extra fibers for every placeholder.
- // They're only necessary when the children time out, because that's the
- // only time when both sets are mounted.
+ // Second is hydration. During hydration, the Suspense fiber has a slightly
+ // different layout, where the child points to a dehydrated fragment, which
+ // contains the DOM rendered by the server.
//
- // So, the extra fragment fibers are only used if the children time out.
- // Otherwise, we render the primary children directly. This requires some
- // custom reconciliation logic to preserve the state of the primary
- // children. It's essentially a very basic form of re-parenting.
+ // Third, even if you set all that aside, Suspense is like error boundaries in
+ // that we first we try to render one tree, and if that fails, we render again
+ // and switch to a different tree. Like a try/catch block. So we have to track
+ // which branch we're currently rendering. Ideally we would model this using
+ // a stack.
if (current === null) {
+ // Initial mount
// If we're currently hydrating, try to hydrate this boundary.
// But only if this has a fallback.
- if (nextProps.fallback !== undefined); // This is the initial mount. This branch is pretty simple because there's
- // no previous state that needs to be preserved.
+ if (nextProps.fallback !== undefined);
- if (nextDidTimeout) {
- // Mount separate fragments for primary and fallback children.
+ if (showFallback) {
+ var nextPrimaryChildren = nextProps.children;
var nextFallbackChildren = nextProps.fallback;
- var primaryChildFragment = createFiberFromFragment(
- null,
- mode,
- NoWork,
- null
- );
- primaryChildFragment.return = workInProgress;
-
- if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, we commit the effects from the
- // partially completed, timed-out tree, too.
- var progressedState = workInProgress.memoizedState;
- var progressedPrimaryChild =
- progressedState !== null
- ? workInProgress.child.child
- : workInProgress.child;
- primaryChildFragment.child = progressedPrimaryChild;
- var progressedChild = progressedPrimaryChild;
-
- while (progressedChild !== null) {
- progressedChild.return = primaryChildFragment;
- progressedChild = progressedChild.sibling;
- }
- }
-
- var fallbackChildFragment = createFiberFromFragment(
+ var fallbackFragment = mountSuspenseFallbackChildren(
+ workInProgress,
+ nextPrimaryChildren,
nextFallbackChildren,
- mode,
- renderExpirationTime,
- null
+ renderLanes
+ );
+ var primaryChildFragment = workInProgress.child;
+ primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
+ renderLanes
);
- fallbackChildFragment.return = workInProgress;
- primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the
- // fallback children.
-
workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = primaryChildFragment;
- return fallbackChildFragment;
+ return fallbackFragment;
} else {
- // Mount the primary children without an intermediate fragment fiber.
- var nextPrimaryChildren = nextProps.children;
- workInProgress.memoizedState = null;
- return (workInProgress.child = mountChildFibers(
+ var _nextPrimaryChildren = nextProps.children;
+ return mountSuspensePrimaryChildren(
workInProgress,
- null,
- nextPrimaryChildren,
- renderExpirationTime
- ));
+ _nextPrimaryChildren,
+ renderLanes
+ );
}
} else {
- // This is an update. This branch is more complicated because we need to
- // ensure the state of the primary children is preserved.
+ // This is an update.
+ // If the current fiber has a SuspenseState, that means it's already showing
+ // a fallback.
var prevState = current.memoizedState;
if (prevState !== null) {
- // wrapped in a fragment fiber.
-
- var currentPrimaryChildFragment = current.child;
- var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
-
- if (nextDidTimeout) {
- // Still timed out. Reuse the current primary children by cloning
- // its fragment. We're going to skip over these entirely.
+ if (showFallback) {
var _nextFallbackChildren2 = nextProps.fallback;
+ var _nextPrimaryChildren3 = nextProps.children;
- var _primaryChildFragment2 = createWorkInProgress(
- currentPrimaryChildFragment,
- currentPrimaryChildFragment.pendingProps
+ var _fallbackChildFragment = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren3,
+ _nextFallbackChildren2,
+ renderLanes
);
- _primaryChildFragment2.return = workInProgress;
-
- if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, we commit the effects from the
- // partially completed, timed-out tree, too.
- var _progressedState = workInProgress.memoizedState;
-
- var _progressedPrimaryChild =
- _progressedState !== null
- ? workInProgress.child.child
- : workInProgress.child;
-
- if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
- _primaryChildFragment2.child = _progressedPrimaryChild;
- var _progressedChild2 = _progressedPrimaryChild;
-
- while (_progressedChild2 !== null) {
- _progressedChild2.return = _primaryChildFragment2;
- _progressedChild2 = _progressedChild2.sibling;
- }
- }
- } // Because primaryChildFragment is a new fiber that we're inserting as the
- // parent of a new tree, we need to set its treeBaseDuration.
-
- if (workInProgress.mode & ProfileMode) {
- // treeBaseDuration is the sum of all the child tree base durations.
- var _treeBaseDuration = 0;
- var _hiddenChild = _primaryChildFragment2.child;
+ var _primaryChildFragment2 = workInProgress.child;
+ var prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment2.memoizedState =
+ prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
+ _primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ );
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return _fallbackChildFragment;
+ } else {
+ var _nextPrimaryChildren4 = nextProps.children;
- while (_hiddenChild !== null) {
- _treeBaseDuration += _hiddenChild.treeBaseDuration;
- _hiddenChild = _hiddenChild.sibling;
- }
+ var _primaryChildFragment3 = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren4,
+ renderLanes
+ );
- _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
- } // Clone the fallback child fragment, too. These we'll continue
- // working on.
+ workInProgress.memoizedState = null;
+ return _primaryChildFragment3;
+ }
+ } else {
+ // The current tree is not already showing a fallback.
+ if (showFallback) {
+ // Timed out.
+ var _nextFallbackChildren3 = nextProps.fallback;
+ var _nextPrimaryChildren5 = nextProps.children;
- var _fallbackChildFragment2 = createWorkInProgress(
- currentFallbackChildFragment,
- _nextFallbackChildren2
+ var _fallbackChildFragment2 = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren5,
+ _nextFallbackChildren3,
+ renderLanes
);
- _fallbackChildFragment2.return = workInProgress;
- _primaryChildFragment2.sibling = _fallbackChildFragment2;
- _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
+ var _primaryChildFragment4 = workInProgress.child;
+ var _prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment4.memoizedState =
+ _prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
+ _primaryChildFragment4.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ ); // Skip the primary children, and continue working on the
// fallback children.
workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = _primaryChildFragment2;
return _fallbackChildFragment2;
} else {
- // No longer suspended. Switch back to showing the primary children,
- // and remove the intermediate fragment fiber.
- var _nextPrimaryChildren = nextProps.children;
- var currentPrimaryChild = currentPrimaryChildFragment.child;
- var primaryChild = reconcileChildFibers(
+ // Still haven't timed out. Continue rendering the children, like we
+ // normally do.
+ var _nextPrimaryChildren6 = nextProps.children;
+
+ var _primaryChildFragment5 = updateSuspensePrimaryChildren(
+ current,
workInProgress,
- currentPrimaryChild,
- _nextPrimaryChildren,
- renderExpirationTime
- ); // If this render doesn't suspend, we need to delete the fallback
- // children. Wait until the complete phase, after we've confirmed the
- // fallback is no longer needed.
- // TODO: Would it be better to store the fallback fragment on
- // the stateNode?
- // Continue rendering the children, like we normally do.
+ _nextPrimaryChildren6,
+ renderLanes
+ );
workInProgress.memoizedState = null;
- return (workInProgress.child = primaryChild);
+ return _primaryChildFragment5;
}
- } else {
- // The current tree has not already timed out. That means the primary
- // children are not wrapped in a fragment fiber.
- var _currentPrimaryChild = current.child;
+ }
+ }
+}
- if (nextDidTimeout) {
- // Timed out. Wrap the children in a fragment fiber to keep them
- // separate from the fallback children.
- var _nextFallbackChildren3 = nextProps.fallback;
+function mountSuspensePrimaryChildren(
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var primaryChildProps = {
+ mode: "visible",
+ children: primaryChildren
+ };
+ var primaryChildFragment = createFiberFromOffscreen(
+ primaryChildProps,
+ mode,
+ renderLanes,
+ null
+ );
+ primaryChildFragment.return = workInProgress;
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
+}
- var _primaryChildFragment3 = createFiberFromFragment(
- // It shouldn't matter what the pending props are because we aren't
- // going to render this fragment.
- null,
- mode,
- NoWork,
- null
- );
+function mountSuspenseFallbackChildren(
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var progressedPrimaryFragment = workInProgress.child;
+ var primaryChildProps = {
+ mode: "hidden",
+ children: primaryChildren
+ };
+ var primaryChildFragment;
+ var fallbackChildFragment;
+
+ if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) {
+ // In legacy mode, we commit the primary tree as if it successfully
+ // completed, even though it's in an inconsistent state.
+ primaryChildFragment = progressedPrimaryFragment;
+ primaryChildFragment.childLanes = NoLanes;
+ primaryChildFragment.pendingProps = primaryChildProps;
+
+ if (workInProgress.mode & ProfileMode) {
+ // Reset the durations from the first pass so they aren't included in the
+ // final amounts. This seems counterintuitive, since we're intentionally
+ // not measuring part of the render phase, but this makes it match what we
+ // do in Concurrent Mode.
+ primaryChildFragment.actualDuration = 0;
+ primaryChildFragment.actualStartTime = -1;
+ primaryChildFragment.selfBaseDuration = 0;
+ primaryChildFragment.treeBaseDuration = 0;
+ }
+
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ } else {
+ primaryChildFragment = createFiberFromOffscreen(
+ primaryChildProps,
+ mode,
+ NoLanes,
+ null
+ );
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ }
- _primaryChildFragment3.return = workInProgress;
- _primaryChildFragment3.child = _currentPrimaryChild;
+ primaryChildFragment.return = workInProgress;
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
+}
- if (_currentPrimaryChild !== null) {
- _currentPrimaryChild.return = _primaryChildFragment3;
- } // Even though we're creating a new fiber, there are no new children,
- // because we're reusing an already mounted tree. So we don't need to
- // schedule a placement.
- // primaryChildFragment.effectTag |= Placement;
+function createWorkInProgressOffscreenFiber(current, offscreenProps) {
+ // The props argument to `createWorkInProgress` is `any` typed, so we use this
+ // wrapper function to constrain it.
+ return createWorkInProgress(current, offscreenProps);
+}
- if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, we commit the effects from the
- // partially completed, timed-out tree, too.
- var _progressedState2 = workInProgress.memoizedState;
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
+ var primaryChildFragment = createWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
+ {
+ mode: "visible",
+ children: primaryChildren
+ }
+ );
- var _progressedPrimaryChild2 =
- _progressedState2 !== null
- ? workInProgress.child.child
- : workInProgress.child;
+ if ((workInProgress.mode & BlockingMode) === NoMode) {
+ primaryChildFragment.lanes = renderLanes;
+ }
- _primaryChildFragment3.child = _progressedPrimaryChild2;
- var _progressedChild3 = _progressedPrimaryChild2;
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = null;
- while (_progressedChild3 !== null) {
- _progressedChild3.return = _primaryChildFragment3;
- _progressedChild3 = _progressedChild3.sibling;
- }
- } // Because primaryChildFragment is a new fiber that we're inserting as the
- // parent of a new tree, we need to set its treeBaseDuration.
+ if (currentFallbackChildFragment !== null) {
+ // Delete the fallback child fragment
+ currentFallbackChildFragment.nextEffect = null;
+ currentFallbackChildFragment.effectTag = Deletion;
+ workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment;
+ }
- if (workInProgress.mode & ProfileMode) {
- // treeBaseDuration is the sum of all the child tree base durations.
- var _treeBaseDuration2 = 0;
- var _hiddenChild2 = _primaryChildFragment3.child;
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
+}
- while (_hiddenChild2 !== null) {
- _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
- _hiddenChild2 = _hiddenChild2.sibling;
- }
+function updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var currentPrimaryChildFragment = current.child;
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
+ var primaryChildProps = {
+ mode: "hidden",
+ children: primaryChildren
+ };
+ var primaryChildFragment;
- _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
- } // Create a fragment from the fallback children, too.
+ if (
+ // In legacy mode, we commit the primary tree as if it successfully
+ // completed, even though it's in an inconsistent state.
+ (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was
+ // already cloned. In legacy mode, the only case where this isn't true is
+ // when DevTools forces us to display a fallback; we skip the first render
+ // pass entirely and go straight to rendering the fallback. (In Concurrent
+ // Mode, SuspenseList can also trigger this scenario, but this is a legacy-
+ // only codepath.)
+ workInProgress.child !== currentPrimaryChildFragment
+ ) {
+ var progressedPrimaryFragment = workInProgress.child;
+ primaryChildFragment = progressedPrimaryFragment;
+ primaryChildFragment.childLanes = NoLanes;
+ primaryChildFragment.pendingProps = primaryChildProps;
+
+ if (workInProgress.mode & ProfileMode) {
+ // Reset the durations from the first pass so they aren't included in the
+ // final amounts. This seems counterintuitive, since we're intentionally
+ // not measuring part of the render phase, but this makes it match what we
+ // do in Concurrent Mode.
+ primaryChildFragment.actualDuration = 0;
+ primaryChildFragment.actualStartTime = -1;
+ primaryChildFragment.selfBaseDuration =
+ currentPrimaryChildFragment.selfBaseDuration;
+ primaryChildFragment.treeBaseDuration =
+ currentPrimaryChildFragment.treeBaseDuration;
+ } // The fallback fiber was added as a deletion effect during the first pass.
+ // However, since we're going to remain on the fallback, we no longer want
+ // to delete it. So we need to remove it from the list. Deletions are stored
+ // on the same list as effects. We want to keep the effects from the primary
+ // tree. So we copy the primary child fragment's effect list, which does not
+ // include the fallback deletion effect.
+
+ var progressedLastEffect = primaryChildFragment.lastEffect;
+
+ if (progressedLastEffect !== null) {
+ workInProgress.firstEffect = primaryChildFragment.firstEffect;
+ workInProgress.lastEffect = progressedLastEffect;
+ progressedLastEffect.nextEffect = null;
+ } else {
+ // TODO: Reset this somewhere else? Lol legacy mode is so weird.
+ workInProgress.firstEffect = workInProgress.lastEffect = null;
+ }
+ } else {
+ primaryChildFragment = createWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ );
+ }
- var _fallbackChildFragment3 = createFiberFromFragment(
- _nextFallbackChildren3,
- mode,
- renderExpirationTime,
- null
- );
+ var fallbackChildFragment;
- _fallbackChildFragment3.return = workInProgress;
- _primaryChildFragment3.sibling = _fallbackChildFragment3;
- _fallbackChildFragment3.effectTag |= Placement;
- _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
- // fallback children.
+ if (currentFallbackChildFragment !== null) {
+ fallbackChildFragment = createWorkInProgress(
+ currentFallbackChildFragment,
+ fallbackChildren
+ );
+ } else {
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ ); // Needs a placement effect because the parent (the Suspense boundary) already
+ // mounted but this is a new fiber.
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = _primaryChildFragment3;
- return _fallbackChildFragment3;
- } else {
- // Still haven't timed out. Continue rendering the children, like we
- // normally do.
- workInProgress.memoizedState = null;
- var _nextPrimaryChildren2 = nextProps.children;
- return (workInProgress.child = reconcileChildFibers(
- workInProgress,
- _currentPrimaryChild,
- _nextPrimaryChildren2,
- renderExpirationTime
- ));
- }
- }
+ fallbackChildFragment.effectTag |= Placement;
}
-}
-function scheduleWorkOnFiber(fiber, renderExpirationTime) {
- if (fiber.expirationTime < renderExpirationTime) {
- fiber.expirationTime = renderExpirationTime;
- }
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
+}
+function scheduleWorkOnFiber(fiber, renderLanes) {
+ fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
var alternate = fiber.alternate;
- if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
- alternate.expirationTime = renderExpirationTime;
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
}
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
+ scheduleWorkOnParentPath(fiber.return, renderLanes);
}
function propagateSuspenseContextChange(
workInProgress,
firstChild,
- renderExpirationTime
+ renderLanes
) {
// Mark any Suspense boundaries with fallbacks as having work to do.
// If they were previously forced into fallbacks, they may now be able
@@ -13128,7 +13855,7 @@ function propagateSuspenseContextChange(
var state = node.memoizedState;
if (state !== null) {
- scheduleWorkOnFiber(node, renderExpirationTime);
+ scheduleWorkOnFiber(node, renderLanes);
}
} else if (node.tag === SuspenseListComponent) {
// If the tail is hidden there might not be an Suspense boundaries
@@ -13136,7 +13863,7 @@ function propagateSuspenseContextChange(
// list itself.
// We don't have to traverse to the children of the list since
// the list will propagate the change when it rerenders.
- scheduleWorkOnFiber(node, renderExpirationTime);
+ scheduleWorkOnFiber(node, renderLanes);
} else if (node.child !== null) {
node.child.return = node;
node = node.child;
@@ -13378,11 +14105,7 @@ function initSuspenseListRenderState(
// in fallback state. Then we render each row in the tail one-by-one.
// That happens in the completeWork phase without going back to beginWork.
-function updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps;
var revealOrder = nextProps.revealOrder;
var tailMode = nextProps.tail;
@@ -13390,7 +14113,7 @@ function updateSuspenseListComponent(
validateRevealOrder(revealOrder);
validateTailOptions(tailMode, revealOrder);
validateSuspenseListChildren(newChildren, revealOrder);
- reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
var suspenseContext = suspenseStackCursor.current;
var shouldForceFallback = hasSuspenseContext(
suspenseContext,
@@ -13414,7 +14137,7 @@ function updateSuspenseListComponent(
propagateSuspenseContextChange(
workInProgress,
workInProgress.child,
- renderExpirationTime
+ renderLanes
);
}
@@ -13424,7 +14147,7 @@ function updateSuspenseListComponent(
pushSuspenseContext(workInProgress, suspenseContext);
if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, SuspenseList doesn't work so we just
+ // In legacy mode, SuspenseList doesn't work so we just
// use make it a noop by treating it as the default revealOrder.
workInProgress.memoizedState = null;
} else {
@@ -13514,7 +14237,7 @@ function updateSuspenseListComponent(
return workInProgress.child;
}
-function updatePortalComponent(current, workInProgress, renderExpirationTime) {
+function updatePortalComponent(current, workInProgress, renderLanes) {
pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
var nextChildren = workInProgress.pendingProps;
@@ -13528,21 +14251,18 @@ function updatePortalComponent(current, workInProgress, renderExpirationTime) {
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
} else {
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
}
return workInProgress.child;
}
-function updateContextProvider(current, workInProgress, renderExpirationTime) {
+var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
+
+function updateContextProvider(current, workInProgress, renderLanes) {
var providerType = workInProgress.type;
var context = providerType._context;
var newProps = workInProgress.pendingProps;
@@ -13550,6 +14270,16 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) {
var newValue = newProps.value;
{
+ if (!("value" in newProps)) {
+ if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
+ hasWarnedAboutUsingNoValuePropOnContextProvider = true;
+
+ error(
+ "The `value` prop is required for the ``. Did you misspell it or forget to pass it?"
+ );
+ }
+ }
+
var providerPropTypes = workInProgress.type.propTypes;
if (providerPropTypes) {
@@ -13569,29 +14299,24 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) {
return bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
}
} else {
// The context value changed. Search for matching consumers and schedule
// them to update.
- propagateContextChange(
- workInProgress,
- context,
- changedBits,
- renderExpirationTime
- );
+ propagateContextChange(workInProgress, context, changedBits, renderLanes);
}
}
var newChildren = newProps.children;
- reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
return workInProgress.child;
}
var hasWarnedAboutUsingContextAsConsumer = false;
-function updateContextConsumer(current, workInProgress, renderExpirationTime) {
+function updateContextConsumer(current, workInProgress, renderLanes) {
var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
// DEV mode, we create a separate object for Context.Consumer that acts
// like a proxy to Context. This proxy object adds unnecessary code in PROD
@@ -13634,7 +14359,7 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) {
}
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
var newValue = readContext(context, newProps.unstable_observedBits);
var newChildren;
@@ -13646,7 +14371,7 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) {
} // React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
- reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
return workInProgress.child;
}
@@ -13654,13 +14379,7 @@ function markWorkInProgressReceivedUpdate() {
didReceiveUpdate = true;
}
-function bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
-) {
- cancelWorkTimer(workInProgress);
-
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
if (current !== null) {
// Reuse previous dependencies
workInProgress.dependencies = current.dependencies;
@@ -13671,15 +14390,9 @@ function bailoutOnAlreadyFinishedWork(
stopProfilerTimerIfRunning();
}
- var updateExpirationTime = workInProgress.expirationTime;
-
- if (updateExpirationTime !== NoWork) {
- markUnprocessedUpdateTime(updateExpirationTime);
- } // Check if the children have any pending work.
-
- var childExpirationTime = workInProgress.childExpirationTime;
+ markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.
- if (childExpirationTime < renderExpirationTime) {
+ if (!includesSomeLane(renderLanes, workInProgress.childLanes)) {
// The children don't have any work either. We can skip them.
// TODO: Once we add back resuming, we should check if the children are
// a work-in-progress set. If so, we need to transfer their effects.
@@ -13747,8 +14460,8 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
}
}
-function beginWork(current, workInProgress, renderExpirationTime) {
- var updateExpirationTime = workInProgress.expirationTime;
+function beginWork(current, workInProgress, renderLanes) {
+ var updateLanes = workInProgress.lanes;
{
if (workInProgress._debugNeedsRemount && current !== null) {
@@ -13762,7 +14475,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress.pendingProps,
workInProgress._debugOwner || null,
workInProgress.mode,
- workInProgress.expirationTime
+ workInProgress.lanes
)
);
}
@@ -13780,7 +14493,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// If props or context changed, mark the fiber as having performed work.
// This may be unset if the props are determined to be equal later (memo).
didReceiveUpdate = true;
- } else if (updateExpirationTime < renderExpirationTime) {
+ } else if (!includesSomeLane(renderLanes, updateLanes)) {
didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
// the begin phase. There's still some bookkeeping we that needs to be done
// in this optimized path, mostly pushing stuff onto the stack.
@@ -13792,20 +14505,6 @@ function beginWork(current, workInProgress, renderExpirationTime) {
case HostComponent:
pushHostContext(workInProgress);
-
- if (
- workInProgress.mode & ConcurrentMode &&
- renderExpirationTime !== Never &&
- shouldDeprioritizeSubtree(workInProgress.type)
- ) {
- {
- markSpawnedWork(Never);
- } // Schedule this fiber to re-render at offscreen priority. Then bailout.
-
- workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
- return null;
- }
-
break;
case ClassComponent: {
@@ -13834,8 +14533,10 @@ function beginWork(current, workInProgress, renderExpirationTime) {
case Profiler:
{
// Profiler should only call onRender when one of its descendants actually rendered.
- var hasChildWork =
- workInProgress.childExpirationTime >= renderExpirationTime;
+ var hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
if (hasChildWork) {
workInProgress.effectTag |= Update;
@@ -13858,21 +14559,19 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// child fragment.
var primaryChildFragment = workInProgress.child;
- var primaryChildExpirationTime =
- primaryChildFragment.childExpirationTime;
+ var primaryChildLanes = primaryChildFragment.childLanes;
- if (
- primaryChildExpirationTime !== NoWork &&
- primaryChildExpirationTime >= renderExpirationTime
- ) {
+ if (includesSomeLane(renderLanes, primaryChildLanes)) {
// The primary children have pending work. Use the normal path
// to attempt to render the primary children again.
return updateSuspenseComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
} else {
+ // The primary child fragment does not have pending work marked
+ // on it
pushSuspenseContext(
workInProgress,
setDefaultShallowSuspenseContext(suspenseStackCursor.current)
@@ -13882,7 +14581,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
var child = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
if (child !== null) {
@@ -13906,8 +14605,10 @@ function beginWork(current, workInProgress, renderExpirationTime) {
case SuspenseListComponent: {
var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect;
- var _hasChildWork =
- workInProgress.childExpirationTime >= renderExpirationTime;
+ var _hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
if (didSuspendBefore) {
if (_hasChildWork) {
@@ -13919,7 +14620,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
return updateSuspenseListComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
} // If none of the children had any work, that means that none of
// them got retried so they'll still be blocked in the same way
@@ -13937,6 +14638,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// update in the past but didn't complete it.
renderState.rendering = null;
renderState.tail = null;
+ renderState.lastEffect = null;
}
pushSuspenseContext(workInProgress, suspenseStackCursor.current);
@@ -13950,19 +14652,35 @@ function beginWork(current, workInProgress, renderExpirationTime) {
return null;
}
}
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ // Need to check if the tree still needs to be deferred. This is
+ // almost identical to the logic used in the normal update path,
+ // so we'll just enter that. The only difference is we'll bail out
+ // at the next level instead of this one, because the child props
+ // have not changed. Which is fine.
+ // TODO: Probably should refactor `beginWork` to split the bailout
+ // path from the normal path. I'm tempted to do a labeled break here
+ // but I won't :)
+ workInProgress.lanes = NoLanes;
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ }
}
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
} else {
- // An update was scheduled on this fiber, but there are no new props
- // nor legacy context. Set this to false. If an update queue or context
- // consumer produces a changed value, it will set this to true. Otherwise,
- // the component will assume the children have not changed and bail out.
- didReceiveUpdate = false;
+ if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) {
+ // This is a special case that only exists for legacy mode.
+ // See https://github.com/facebook/react/pull/19216.
+ didReceiveUpdate = true;
+ } else {
+ // An update was scheduled on this fiber, but there are no new props
+ // nor legacy context. Set this to false. If an update queue or context
+ // consumer produces a changed value, it will set this to true. Otherwise,
+ // the component will assume the children have not changed and bail out.
+ didReceiveUpdate = false;
+ }
}
} else {
didReceiveUpdate = false;
@@ -13972,7 +14690,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// sometimes bails out later in the begin phase. This indicates that we should
// move this assignment out of the common path and into each branch.
- workInProgress.expirationTime = NoWork;
+ workInProgress.lanes = NoLanes;
switch (workInProgress.tag) {
case IndeterminateComponent: {
@@ -13980,7 +14698,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.type,
- renderExpirationTime
+ renderLanes
);
}
@@ -13990,8 +14708,8 @@ function beginWork(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
elementType,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -14007,7 +14725,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
_Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
}
@@ -14025,32 +14743,24 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
_Component2,
_resolvedProps,
- renderExpirationTime
+ renderLanes
);
}
case HostRoot:
- return updateHostRoot(current, workInProgress, renderExpirationTime);
+ return updateHostRoot(current, workInProgress, renderLanes);
case HostComponent:
- return updateHostComponent(current, workInProgress, renderExpirationTime);
+ return updateHostComponent(current, workInProgress, renderLanes);
case HostText:
return updateHostText();
case SuspenseComponent:
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
case HostPortal:
- return updatePortalComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updatePortalComponent(current, workInProgress, renderLanes);
case ForwardRef: {
var type = workInProgress.type;
@@ -14066,32 +14776,24 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
type,
_resolvedProps2,
- renderExpirationTime
+ renderLanes
);
}
case Fragment:
- return updateFragment(current, workInProgress, renderExpirationTime);
+ return updateFragment(current, workInProgress, renderLanes);
case Mode:
- return updateMode(current, workInProgress, renderExpirationTime);
+ return updateMode(current, workInProgress, renderLanes);
case Profiler:
- return updateProfiler(current, workInProgress, renderExpirationTime);
+ return updateProfiler(current, workInProgress, renderLanes);
case ContextProvider:
- return updateContextProvider(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateContextProvider(current, workInProgress, renderLanes);
case ContextConsumer:
- return updateContextConsumer(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateContextConsumer(current, workInProgress, renderLanes);
case MemoComponent: {
var _type2 = workInProgress.type;
@@ -14120,8 +14822,8 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
_type2,
_resolvedProps3,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -14131,8 +14833,8 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -14150,16 +14852,32 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
_Component3,
_resolvedProps4,
- renderExpirationTime
+ renderLanes
);
}
case SuspenseListComponent: {
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
+ }
+
+ case FundamentalComponent: {
+ break;
+ }
+
+ case ScopeComponent: {
+ break;
+ }
+
+ case Block: {
+ break;
+ }
+
+ case OffscreenComponent: {
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ }
+
+ case LegacyHiddenComponent: {
+ return updateLegacyHiddenComponent(current, workInProgress, renderLanes);
}
}
@@ -14549,7 +15267,7 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
}
}
-function completeWork(current, workInProgress, renderExpirationTime) {
+function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
@@ -14578,6 +15296,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
case HostRoot: {
popHostContainer(workInProgress);
popTopLevelContextObject(workInProgress);
+ resetWorkInProgressVersions();
var fiberRoot = workInProgress.stateNode;
if (fiberRoot.pendingContext) {
@@ -14594,6 +15313,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
// If we hydrated, then we'll need to schedule an update for
// the commit side-effects on the root.
markUpdate(workInProgress);
+ } else if (!fiberRoot.hydrate) {
+ // Schedule an effect to clear this container at the start of the next commit.
+ // This handles the case of React rendering into a container with previous children.
+ // It's also safe to do for updates too, because current.child would only be null
+ // if the previous render was null (so the the container would already be empty).
+ workInProgress.effectTag |= Snapshot;
}
}
@@ -14712,7 +15437,11 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
// Something suspended. Re-render with the fallback children.
- workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list.
+ workInProgress.lanes = renderLanes; // Do not reset the effect list.
+
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ }
return workInProgress;
}
@@ -14720,34 +15449,11 @@ function completeWork(current, workInProgress, renderExpirationTime) {
var nextDidTimeout = nextState !== null;
var prevDidTimeout = false;
- if (current === null) {
- if (workInProgress.memoizedProps.fallback !== undefined);
- } else {
- var prevState = current.memoizedState;
- prevDidTimeout = prevState !== null;
-
- if (!nextDidTimeout && prevState !== null) {
- // We just switched from the fallback to the normal children.
- // Delete the fallback.
- // TODO: Would it be better to store the fallback fragment on
- // the stateNode during the begin phase?
- var currentFallbackChild = current.child.sibling;
-
- if (currentFallbackChild !== null) {
- // Deletions go at the beginning of the return fiber's effect list
- var first = workInProgress.firstEffect;
-
- if (first !== null) {
- workInProgress.firstEffect = currentFallbackChild;
- currentFallbackChild.nextEffect = first;
- } else {
- workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
- currentFallbackChild.nextEffect = null;
- }
-
- currentFallbackChild.effectTag = Deletion;
- }
- }
+ if (current === null) {
+ if (workInProgress.memoizedProps.fallback !== undefined);
+ } else {
+ var prevState = current.memoizedState;
+ prevDidTimeout = prevState !== null;
}
if (nextDidTimeout && !prevDidTimeout) {
@@ -14802,6 +15508,11 @@ function completeWork(current, workInProgress, renderExpirationTime) {
case HostPortal:
popHostContainer(workInProgress);
updateHostContainer(workInProgress);
+
+ if (current === null) {
+ preparePortalMount(workInProgress.stateNode.containerInfo);
+ }
+
return null;
case ContextProvider:
@@ -14888,7 +15599,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state.
- resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately
+ resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
// rerender the children.
pushSuspenseContext(
@@ -14929,7 +15640,8 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if (
renderState.tail === null &&
renderState.tailMode === "hidden" &&
- !renderedTail.alternate
+ !renderedTail.alternate &&
+ !getIsHydrating() // We don't cut it if we're hydrating.
) {
// We need to delete the row we just rendered.
// Reset the effect list to what it was before we rendered this
@@ -14948,7 +15660,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
// the expiration.
now() * 2 - renderState.renderingStartTime >
renderState.tailExpiration &&
- renderExpirationTime > Never
+ renderLanes !== OffscreenLane
) {
// We have now passed our CPU deadline and we'll just give up further
// attempts to render the main content and only render fallbacks.
@@ -14961,11 +15673,10 @@ function completeWork(current, workInProgress, renderExpirationTime) {
// So we'll pick it back up the very next render pass once we've had
// an opportunity to yield for paint.
- var nextPriority = renderExpirationTime - 1;
- workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
+ workInProgress.lanes = renderLanes;
{
- markSpawnedWork(nextPriority);
+ markSpawnedWork(renderLanes);
}
}
}
@@ -15032,6 +15743,38 @@ function completeWork(current, workInProgress, renderExpirationTime) {
return null;
}
+
+ case FundamentalComponent: {
+ break;
+ }
+
+ case ScopeComponent: {
+ break;
+ }
+
+ case Block:
+ break;
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ popRenderLanes(workInProgress);
+
+ if (current !== null) {
+ var _nextState = workInProgress.memoizedState;
+ var _prevState = current.memoizedState;
+ var prevIsHidden = _prevState !== null;
+ var nextIsHidden = _nextState !== null;
+
+ if (
+ prevIsHidden !== nextIsHidden &&
+ newProps.mode !== "unstable-defer-without-hiding"
+ ) {
+ workInProgress.effectTag |= Update;
+ }
+ }
+
+ return null;
+ }
}
{
@@ -15043,220 +15786,580 @@ function completeWork(current, workInProgress, renderExpirationTime) {
}
}
-function unwindWork(workInProgress, renderExpirationTime) {
+function unwindWork(workInProgress, renderLanes) {
switch (workInProgress.tag) {
case ClassComponent: {
var Component = workInProgress.type;
- if (isContextProvider(Component)) {
- popContext(workInProgress);
+ if (isContextProvider(Component)) {
+ popContext(workInProgress);
+ }
+
+ var effectTag = workInProgress.effectTag;
+
+ if (effectTag & ShouldCapture) {
+ workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture;
+
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ }
+
+ return workInProgress;
+ }
+
+ return null;
+ }
+
+ case HostRoot: {
+ popHostContainer(workInProgress);
+ popTopLevelContextObject(workInProgress);
+ resetWorkInProgressVersions();
+ var _effectTag = workInProgress.effectTag;
+
+ if (!((_effectTag & DidCapture) === NoEffect)) {
+ throw Error(
+ "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
+ );
+ }
+
+ workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture;
+ return workInProgress;
+ }
+
+ case HostComponent: {
+ // TODO: popHydrationState
+ popHostContext(workInProgress);
+ return null;
+ }
+
+ case SuspenseComponent: {
+ popSuspenseContext(workInProgress);
+
+ var _effectTag2 = workInProgress.effectTag;
+
+ if (_effectTag2 & ShouldCapture) {
+ workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary.
+
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ }
+
+ return workInProgress;
+ }
+
+ return null;
+ }
+
+ case SuspenseListComponent: {
+ popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
+ // caught by a nested boundary. If not, it should bubble through.
+
+ return null;
+ }
+
+ case HostPortal:
+ popHostContainer(workInProgress);
+ return null;
+
+ case ContextProvider:
+ popProvider(workInProgress);
+ return null;
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent:
+ popRenderLanes(workInProgress);
+ return null;
+
+ default:
+ return null;
+ }
+}
+
+function unwindInterruptedWork(interruptedWork) {
+ switch (interruptedWork.tag) {
+ case ClassComponent: {
+ var childContextTypes = interruptedWork.type.childContextTypes;
+
+ if (childContextTypes !== null && childContextTypes !== undefined) {
+ popContext(interruptedWork);
+ }
+
+ break;
+ }
+
+ case HostRoot: {
+ popHostContainer(interruptedWork);
+ popTopLevelContextObject(interruptedWork);
+ resetWorkInProgressVersions();
+ break;
+ }
+
+ case HostComponent: {
+ popHostContext(interruptedWork);
+ break;
+ }
+
+ case HostPortal:
+ popHostContainer(interruptedWork);
+ break;
+
+ case SuspenseComponent:
+ popSuspenseContext(interruptedWork);
+ break;
+
+ case SuspenseListComponent:
+ popSuspenseContext(interruptedWork);
+ break;
+
+ case ContextProvider:
+ popProvider(interruptedWork);
+ break;
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent:
+ popRenderLanes(interruptedWork);
+ break;
+ }
+}
+
+function createCapturedValue(value, source) {
+ // If the value is an error, call this function immediately after it is thrown
+ // so the stack is accurate.
+ return {
+ value: value,
+ source: source,
+ stack: getStackByFiberInDevAndProd(source)
+ };
+}
+
+if (
+ !(
+ typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog ===
+ "function"
+ )
+) {
+ throw Error(
+ "Expected ReactFiberErrorDialog.showErrorDialog to be a function."
+ );
+}
+
+function showErrorDialog(boundary, errorInfo) {
+ var capturedError = {
+ componentStack: errorInfo.stack !== null ? errorInfo.stack : "",
+ error: errorInfo.value,
+ errorBoundary:
+ boundary !== null && boundary.tag === ClassComponent
+ ? boundary.stateNode
+ : null
+ };
+ return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
+ capturedError
+ );
+}
+
+function logCapturedError(boundary, errorInfo) {
+ try {
+ var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging.
+ // This enables renderers like ReactNative to better manage redbox behavior.
+
+ if (logError === false) {
+ return;
+ }
+
+ var error = errorInfo.value;
+
+ if (true) {
+ var source = errorInfo.source;
+ var stack = errorInfo.stack;
+ var componentStack = stack !== null ? stack : ""; // Browsers support silencing uncaught errors by calling
+ // `preventDefault()` in window `error` handler.
+ // We record this information as an expando on the error.
+
+ if (error != null && error._suppressLogging) {
+ if (boundary.tag === ClassComponent) {
+ // The error is recoverable and was silenced.
+ // Ignore it and don't print the stack addendum.
+ // This is handy for testing error boundaries without noise.
+ return;
+ } // The error is fatal. Since the silencing might have
+ // been accidental, we'll surface it anyway.
+ // However, the browser would have silenced the original error
+ // so we'll print it first, and then print the stack addendum.
+
+ console["error"](error); // Don't transform to our wrapper
+ // For a more detailed description of this block, see:
+ // https://github.com/facebook/react/pull/13384
+ }
+
+ var componentName = source ? getComponentName(source.type) : null;
+ var componentNameMessage = componentName
+ ? "The above error occurred in the <" + componentName + "> component:"
+ : "The above error occurred in one of your React components:";
+ var errorBoundaryMessage;
+ var errorBoundaryName = getComponentName(boundary.type);
+
+ if (errorBoundaryName) {
+ errorBoundaryMessage =
+ "React will try to recreate this component tree from scratch " +
+ ("using the error boundary you provided, " + errorBoundaryName + ".");
+ } else {
+ errorBoundaryMessage =
+ "Consider adding an error boundary to your tree to customize error handling behavior.\n" +
+ "Visit https://fb.me/react-error-boundaries to learn more about error boundaries.";
+ }
+
+ var combinedMessage =
+ componentNameMessage +
+ "\n" +
+ componentStack +
+ "\n\n" +
+ ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
+ // We don't include the original error message and JS stack because the browser
+ // has already printed it. Even if the application swallows the error, it is still
+ // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
+
+ console["error"](combinedMessage); // Don't transform to our wrapper
+ } else {
+ // In production, we print the error directly.
+ // This will include the message, the JS stack, and anything the browser wants to show.
+ // We pass the error object instead of custom message so that the browser displays the error natively.
+ console["error"](error); // Don't transform to our wrapper
+ }
+ } catch (e) {
+ // This method must not throw, or React internal state will get messed up.
+ // If console.error is overridden, or logCapturedError() shows a dialog that throws,
+ // we want to report this error outside of the normal stack as a last resort.
+ // https://github.com/facebook/react/issues/13188
+ setTimeout(function() {
+ throw e;
+ });
+ }
+}
+
+var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map;
+
+function createRootErrorUpdate(fiber, errorInfo, lane) {
+ var update = createUpdate(NoTimestamp, lane, null); // Unmount the root by rendering null.
+
+ update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
+ // being called "element".
+
+ update.payload = {
+ element: null
+ };
+ var error = errorInfo.value;
+
+ update.callback = function() {
+ onUncaughtError(error);
+ logCapturedError(fiber, errorInfo);
+ };
+
+ return update;
+}
+
+function createClassErrorUpdate(fiber, errorInfo, lane) {
+ var update = createUpdate(NoTimestamp, lane, null);
+ update.tag = CaptureUpdate;
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+
+ if (typeof getDerivedStateFromError === "function") {
+ var error$1 = errorInfo.value;
+
+ update.payload = function() {
+ logCapturedError(fiber, errorInfo);
+ return getDerivedStateFromError(error$1);
+ };
+ }
+
+ var inst = fiber.stateNode;
+
+ if (inst !== null && typeof inst.componentDidCatch === "function") {
+ update.callback = function callback() {
+ {
+ markFailedErrorBoundaryForHotReloading(fiber);
+ }
+
+ if (typeof getDerivedStateFromError !== "function") {
+ // To preserve the preexisting retry behavior of error boundaries,
+ // we keep track of which ones already failed during this batch.
+ // This gets reset before we yield back to the browser.
+ // TODO: Warn in strict mode if getDerivedStateFromError is
+ // not defined.
+ markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
+
+ logCapturedError(fiber, errorInfo);
}
- var effectTag = workInProgress.effectTag;
+ var error$1 = errorInfo.value;
+ var stack = errorInfo.stack;
+ this.componentDidCatch(error$1, {
+ componentStack: stack !== null ? stack : ""
+ });
- if (effectTag & ShouldCapture) {
- workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture;
- return workInProgress;
+ {
+ if (typeof getDerivedStateFromError !== "function") {
+ // If componentDidCatch is the only error boundary method defined,
+ // then it needs to call setState to recover from errors.
+ // If no state update is scheduled then the boundary will swallow the error.
+ if (!includesSomeLane(fiber.lanes, SyncLane)) {
+ error(
+ "%s: Error boundaries should implement getDerivedStateFromError(). " +
+ "In that method, return a state update to display an error message or fallback UI.",
+ getComponentName(fiber.type) || "Unknown"
+ );
+ }
+ }
}
+ };
+ } else {
+ update.callback = function() {
+ markFailedErrorBoundaryForHotReloading(fiber);
+ };
+ }
- return null;
- }
-
- case HostRoot: {
- popHostContainer(workInProgress);
- popTopLevelContextObject(workInProgress);
- var _effectTag = workInProgress.effectTag;
+ return update;
+}
- if (!((_effectTag & DidCapture) === NoEffect)) {
- throw Error(
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
- );
- }
+function attachPingListener(root, wakeable, lanes) {
+ // Attach a listener to the promise to "ping" the root and retry. But only if
+ // one does not already exist for the lanes we're currently rendering (which
+ // acts like a "thread ID" here).
+ var pingCache = root.pingCache;
+ var threadIDs;
- workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture;
- return workInProgress;
- }
+ if (pingCache === null) {
+ pingCache = root.pingCache = new PossiblyWeakMap$1();
+ threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
+ } else {
+ threadIDs = pingCache.get(wakeable);
- case HostComponent: {
- // TODO: popHydrationState
- popHostContext(workInProgress);
- return null;
+ if (threadIDs === undefined) {
+ threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
}
+ }
- case SuspenseComponent: {
- popSuspenseContext(workInProgress);
-
- var _effectTag2 = workInProgress.effectTag;
+ if (!threadIDs.has(lanes)) {
+ // Memoize using the thread ID to prevent redundant listeners.
+ threadIDs.add(lanes);
+ var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes);
+ wakeable.then(ping, ping);
+ }
+}
- if (_effectTag2 & ShouldCapture) {
- workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary.
+function throwException(
+ root,
+ returnFiber,
+ sourceFiber,
+ value,
+ rootRenderLanes
+) {
+ // The source fiber did not complete.
+ sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
- return workInProgress;
- }
+ sourceFiber.firstEffect = sourceFiber.lastEffect = null;
- return null;
- }
+ if (
+ value !== null &&
+ typeof value === "object" &&
+ typeof value.then === "function"
+ ) {
+ // This is a wakeable.
+ var wakeable = value;
- case SuspenseListComponent: {
- popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
- // caught by a nested boundary. If not, it should bubble through.
+ if ((sourceFiber.mode & BlockingMode) === NoMode) {
+ // Reset the memoizedState to what it was before we attempted
+ // to render it.
+ var currentSource = sourceFiber.alternate;
- return null;
+ if (currentSource) {
+ sourceFiber.updateQueue = currentSource.updateQueue;
+ sourceFiber.memoizedState = currentSource.memoizedState;
+ sourceFiber.lanes = currentSource.lanes;
+ } else {
+ sourceFiber.updateQueue = null;
+ sourceFiber.memoizedState = null;
+ }
}
- case HostPortal:
- popHostContainer(workInProgress);
- return null;
+ var hasInvisibleParentBoundary = hasSuspenseContext(
+ suspenseStackCursor.current,
+ InvisibleParentSuspenseContext
+ ); // Schedule the nearest Suspense to re-render the timed out view.
- case ContextProvider:
- popProvider(workInProgress);
- return null;
+ var _workInProgress = returnFiber;
- default:
- return null;
- }
-}
+ do {
+ if (
+ _workInProgress.tag === SuspenseComponent &&
+ shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)
+ ) {
+ // Found the nearest boundary.
+ // Stash the promise on the boundary fiber. If the boundary times out, we'll
+ // attach another listener to flip the boundary back to its normal state.
+ var wakeables = _workInProgress.updateQueue;
-function unwindInterruptedWork(interruptedWork) {
- switch (interruptedWork.tag) {
- case ClassComponent: {
- var childContextTypes = interruptedWork.type.childContextTypes;
+ if (wakeables === null) {
+ var updateQueue = new Set();
+ updateQueue.add(wakeable);
+ _workInProgress.updateQueue = updateQueue;
+ } else {
+ wakeables.add(wakeable);
+ } // If the boundary is outside of blocking mode, we should *not*
+ // suspend the commit. Pretend as if the suspended component rendered
+ // null and keep rendering. In the commit phase, we'll schedule a
+ // subsequent synchronous update to re-render the Suspense.
+ //
+ // Note: It doesn't matter whether the component that suspended was
+ // inside a blocking mode tree. If the Suspense is outside of it, we
+ // should *not* suspend the commit.
- if (childContextTypes !== null && childContextTypes !== undefined) {
- popContext(interruptedWork);
- }
+ if ((_workInProgress.mode & BlockingMode) === NoMode) {
+ _workInProgress.effectTag |= DidCapture;
+ sourceFiber.effectTag |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete.
+ // But we shouldn't call any lifecycle methods or callbacks. Remove
+ // all lifecycle effect tags.
- break;
- }
+ sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
- case HostRoot: {
- popHostContainer(interruptedWork);
- popTopLevelContextObject(interruptedWork);
- break;
- }
+ if (sourceFiber.tag === ClassComponent) {
+ var currentSourceFiber = sourceFiber.alternate;
- case HostComponent: {
- popHostContext(interruptedWork);
- break;
- }
+ if (currentSourceFiber === null) {
+ // This is a new mount. Change the tag so it's not mistaken for a
+ // completed class component. For example, we should not call
+ // componentWillUnmount if it is deleted.
+ sourceFiber.tag = IncompleteClassComponent;
+ } else {
+ // When we try rendering again, we should not reuse the current fiber,
+ // since it's known to be in an inconsistent state. Use a force update to
+ // prevent a bail out.
+ var update = createUpdate(NoTimestamp, SyncLane, null);
+ update.tag = ForceUpdate;
+ enqueueUpdate(sourceFiber, update);
+ }
+ } // The source fiber did not complete. Mark it with Sync priority to
+ // indicate that it still has pending work.
- case HostPortal:
- popHostContainer(interruptedWork);
- break;
+ sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending.
- case SuspenseComponent:
- popSuspenseContext(interruptedWork);
- break;
+ return;
+ } // Confirmed that the boundary is in a concurrent mode tree. Continue
+ // with the normal suspend path.
+ //
+ // After this we'll use a set of heuristics to determine whether this
+ // render pass will run to completion or restart or "suspend" the commit.
+ // The actual logic for this is spread out in different places.
+ //
+ // This first principle is that if we're going to suspend when we complete
+ // a root, then we should also restart if we get an update or ping that
+ // might unsuspend it, and vice versa. The only reason to suspend is
+ // because you think you might want to restart before committing. However,
+ // it doesn't make sense to restart only while in the period we're suspended.
+ //
+ // Restarting too aggressively is also not good because it starves out any
+ // intermediate loading state. So we use heuristics to determine when.
+ // Suspense Heuristics
+ //
+ // If nothing threw a Promise or all the same fallbacks are already showing,
+ // then don't suspend/restart.
+ //
+ // If this is an initial render of a new tree of Suspense boundaries and
+ // those trigger a fallback, then don't suspend/restart. We want to ensure
+ // that we can show the initial loading state as quickly as possible.
+ //
+ // If we hit a "Delayed" case, such as when we'd switch from content back into
+ // a fallback, then we should always suspend/restart. SuspenseConfig applies to
+ // this case. If none is defined, JND is used instead.
+ //
+ // If we're already showing a fallback and it gets "retried", allowing us to show
+ // another level, but there's still an inner boundary that would show a fallback,
+ // then we suspend/restart for 500ms since the last time we showed a fallback
+ // anywhere in the tree. This effectively throttles progressive loading into a
+ // consistent train of commits. This also gives us an opportunity to restart to
+ // get to the completed state slightly earlier.
+ //
+ // If there's ambiguity due to batching it's resolved in preference of:
+ // 1) "delayed", 2) "initial render", 3) "retry".
+ //
+ // We want to ensure that a "busy" state doesn't get force committed. We want to
+ // ensure that new initial loading states can commit as soon as possible.
- case SuspenseListComponent:
- popSuspenseContext(interruptedWork);
- break;
+ attachPingListener(root, wakeable, rootRenderLanes);
+ _workInProgress.effectTag |= ShouldCapture;
+ _workInProgress.lanes = rootRenderLanes;
+ return;
+ } // This boundary already captured during this render. Continue to the next
+ // boundary.
- case ContextProvider:
- popProvider(interruptedWork);
- break;
- }
-}
+ _workInProgress = _workInProgress.return;
+ } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
+ // TODO: Use invariant so the message is stripped in prod?
-function createCapturedValue(value, source) {
- // If the value is an error, call this function immediately after it is thrown
- // so the stack is accurate.
- return {
- value: value,
- source: source,
- stack: getStackByFiberInDevAndProd(source)
- };
-}
+ value = new Error(
+ (getComponentName(sourceFiber.type) || "A React component") +
+ " suspended while rendering, but no fallback UI was specified.\n" +
+ "\n" +
+ "Add a component higher in the tree to " +
+ "provide a loading indicator or placeholder to display."
+ );
+ } // We didn't find a boundary that could handle this type of exception. Start
+ // over and traverse parent path again, this time treating the exception
+ // as an error.
-// Module provided by RN:
+ renderDidError();
+ value = createCapturedValue(value, sourceFiber);
+ var workInProgress = returnFiber;
-if (
- !(
- typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog ===
- "function"
- )
-) {
- throw Error(
- "Expected ReactFiberErrorDialog.showErrorDialog to be a function."
- );
-}
+ do {
+ switch (workInProgress.tag) {
+ case HostRoot: {
+ var _errorInfo = value;
+ workInProgress.effectTag |= ShouldCapture;
+ var lane = pickArbitraryLane(rootRenderLanes);
+ workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
-function showErrorDialog(capturedError) {
- return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
- capturedError
- );
-}
+ var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
-function logCapturedError(capturedError) {
- var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging.
- // This enables renderers like ReactNative to better manage redbox behavior.
+ enqueueCapturedUpdate(workInProgress, _update);
+ return;
+ }
- if (logError === false) {
- return;
- }
+ case ClassComponent:
+ // Capture and retry
+ var errorInfo = value;
+ var ctor = workInProgress.type;
+ var instance = workInProgress.stateNode;
+
+ if (
+ (workInProgress.effectTag & DidCapture) === NoEffect &&
+ (typeof ctor.getDerivedStateFromError === "function" ||
+ (instance !== null &&
+ typeof instance.componentDidCatch === "function" &&
+ !isAlreadyFailedLegacyErrorBoundary(instance)))
+ ) {
+ workInProgress.effectTag |= ShouldCapture;
- var error = capturedError.error;
+ var _lane = pickArbitraryLane(rootRenderLanes);
- {
- var componentName = capturedError.componentName,
- componentStack = capturedError.componentStack,
- errorBoundaryName = capturedError.errorBoundaryName,
- errorBoundaryFound = capturedError.errorBoundaryFound,
- willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
- // `preventDefault()` in window `error` handler.
- // We record this information as an expando on the error.
-
- if (error != null && error._suppressLogging) {
- if (errorBoundaryFound && willRetry) {
- // The error is recoverable and was silenced.
- // Ignore it and don't print the stack addendum.
- // This is handy for testing error boundaries without noise.
- return;
- } // The error is fatal. Since the silencing might have
- // been accidental, we'll surface it anyway.
- // However, the browser would have silenced the original error
- // so we'll print it first, and then print the stack addendum.
+ workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state
- console["error"](error); // Don't transform to our wrapper
- // For a more detailed description of this block, see:
- // https://github.com/facebook/react/pull/13384
- }
+ var _update2 = createClassErrorUpdate(
+ workInProgress,
+ errorInfo,
+ _lane
+ );
- var componentNameMessage = componentName
- ? "The above error occurred in the <" + componentName + "> component:"
- : "The above error occurred in one of your React components:";
- var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
+ enqueueCapturedUpdate(workInProgress, _update2);
+ return;
+ }
- if (errorBoundaryFound && errorBoundaryName) {
- if (willRetry) {
- errorBoundaryMessage =
- "React will try to recreate this component tree from scratch " +
- ("using the error boundary you provided, " + errorBoundaryName + ".");
- } else {
- errorBoundaryMessage =
- "This error was initially handled by the error boundary " +
- errorBoundaryName +
- ".\n" +
- "Recreating the tree from scratch failed so React will unmount the tree.";
- }
- } else {
- errorBoundaryMessage =
- "Consider adding an error boundary to your tree to customize error handling behavior.\n" +
- "Visit https://fb.me/react-error-boundaries to learn more about error boundaries.";
+ break;
}
- var combinedMessage =
- "" +
- componentNameMessage +
- componentStack +
- "\n\n" +
- ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
- // We don't include the original error message and JS stack because the browser
- // has already printed it. Even if the application swallows the error, it is still
- // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
-
- console["error"](combinedMessage); // Don't transform to our wrapper
- }
+ workInProgress = workInProgress.return;
+ } while (workInProgress !== null);
}
var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
@@ -15266,54 +16369,14 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
}
var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set;
-function logError(boundary, errorInfo) {
- var source = errorInfo.source;
- var stack = errorInfo.stack;
-
- if (stack === null && source !== null) {
- stack = getStackByFiberInDevAndProd(source);
- }
-
- var capturedError = {
- componentName: source !== null ? getComponentName(source.type) : null,
- componentStack: stack !== null ? stack : "",
- error: errorInfo.value,
- errorBoundary: null,
- errorBoundaryName: null,
- errorBoundaryFound: false,
- willRetry: false
- };
-
- if (boundary !== null && boundary.tag === ClassComponent) {
- capturedError.errorBoundary = boundary.stateNode;
- capturedError.errorBoundaryName = getComponentName(boundary.type);
- capturedError.errorBoundaryFound = true;
- capturedError.willRetry = true;
- }
-
- try {
- logCapturedError(capturedError);
- } catch (e) {
- // This method must not throw, or React internal state will get messed up.
- // If console.error is overridden, or logCapturedError() shows a dialog that throws,
- // we want to report this error outside of the normal stack as a last resort.
- // https://github.com/facebook/react/issues/13188
- setTimeout(function() {
- throw e;
- });
- }
-}
var callComponentWillUnmountWithTimer = function(current, instance) {
- startPhaseTimer(current, "componentWillUnmount");
instance.props = current.memoizedProps;
instance.state = current.memoizedState;
{
instance.componentWillUnmount();
}
-
- stopPhaseTimer();
}; // Capture errors so they don't interrupt unmounting.
function safelyCallComponentWillUnmount(current, instance) {
@@ -15377,7 +16440,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
if (current !== null) {
var prevProps = current.memoizedProps;
var prevState = current.memoizedState;
- startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate");
var instance = finishedWork.stateNode; // We could update instance props and state here,
// but instead we rely on them being set during last render.
// TODO: revisit this when we implement resuming.
@@ -15433,14 +16495,16 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
}
instance.__reactInternalSnapshotBeforeUpdate = snapshot;
- stopPhaseTimer();
}
}
return;
}
- case HostRoot:
+ case HostRoot: {
+ return;
+ }
+
case HostComponent:
case HostText:
case HostPortal:
@@ -15524,9 +16588,8 @@ function commitHookEffectListMount(tag, finishedWork) {
error(
"An effect function must not return anything besides a function, " +
- "which is used for clean-up.%s%s",
- addendum,
- getStackByFiberInDevAndProd(finishedWork)
+ "which is used for clean-up.%s",
+ addendum
);
}
}
@@ -15537,33 +16600,33 @@ function commitHookEffectListMount(tag, finishedWork) {
}
}
-function commitPassiveHookEffects(finishedWork) {
- if ((finishedWork.effectTag & Passive) !== NoEffect) {
- switch (finishedWork.tag) {
- case FunctionComponent:
- case ForwardRef:
- case SimpleMemoComponent:
- case Block: {
- // TODO (#17945) We should call all passive destroy functions (for all fibers)
- // before calling any create functions. The current approach only serializes
- // these for a single fiber.
- {
- commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork);
- commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
- }
+function schedulePassiveEffects(finishedWork) {
+ var updateQueue = finishedWork.updateQueue;
+ var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
- break;
+ if (lastEffect !== null) {
+ var firstEffect = lastEffect.next;
+ var effect = firstEffect;
+
+ do {
+ var _effect = effect,
+ next = _effect.next,
+ tag = _effect.tag;
+
+ if (
+ (tag & Passive$1) !== NoEffect$1 &&
+ (tag & HasEffect) !== NoEffect$1
+ ) {
+ enqueuePendingPassiveHookEffectUnmount(finishedWork, effect);
+ enqueuePendingPassiveHookEffectMount(finishedWork, effect);
}
- }
+
+ effect = next;
+ } while (effect !== firstEffect);
}
}
-function commitLifeCycles(
- finishedRoot,
- current,
- finishedWork,
- committedExpirationTime
-) {
+function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) {
switch (finishedWork.tag) {
case FunctionComponent:
case ForwardRef:
@@ -15577,6 +16640,7 @@ function commitLifeCycles(
commitHookEffectListMount(Layout | HasEffect, finishedWork);
}
+ schedulePassiveEffects(finishedWork);
return;
}
@@ -15585,10 +16649,9 @@ function commitLifeCycles(
if (finishedWork.effectTag & Update) {
if (current === null) {
- startPhaseTimer(finishedWork, "componentDidMount"); // We could update instance props and state here,
+ // We could update instance props and state here,
// but instead we rely on them being set during last render.
// TODO: revisit this when we implement resuming.
-
{
if (
finishedWork.type === finishedWork.elementType &&
@@ -15621,15 +16684,12 @@ function commitLifeCycles(
{
instance.componentDidMount();
}
-
- stopPhaseTimer();
} else {
var prevProps =
finishedWork.elementType === finishedWork.type
? current.memoizedProps
: resolveDefaultProps(finishedWork.type, current.memoizedProps);
- var prevState = current.memoizedState;
- startPhaseTimer(finishedWork, "componentDidUpdate"); // We could update instance props and state here,
+ var prevState = current.memoizedState; // We could update instance props and state here,
// but instead we rely on them being set during last render.
// TODO: revisit this when we implement resuming.
@@ -15669,10 +16729,9 @@ function commitLifeCycles(
instance.__reactInternalSnapshotBeforeUpdate
);
}
-
- stopPhaseTimer();
}
- }
+ } // TODO: I think this is now always non-null by the time it reaches the
+ // commit phase. Consider removing the type check.
var updateQueue = finishedWork.updateQueue;
@@ -15715,6 +16774,8 @@ function commitLifeCycles(
}
case HostRoot: {
+ // TODO: I think this is now always non-null by the time it reaches the
+ // commit phase. Consider removing the type check.
var _updateQueue = finishedWork.updateQueue;
if (_updateQueue !== null) {
@@ -15797,6 +16858,8 @@ function commitLifeCycles(
case IncompleteClassComponent:
case FundamentalComponent:
case ScopeComponent:
+ case OffscreenComponent:
+ case LegacyHiddenComponent:
return;
}
@@ -15830,9 +16893,8 @@ function commitAttachRef(finishedWork) {
if (!ref.hasOwnProperty("current")) {
error(
"Unexpected ref object provided for %s. " +
- "Use either a ref-setter function or React.createRef().%s",
- getComponentName(finishedWork.type),
- getStackByFiberInDevAndProd(finishedWork)
+ "Use either a ref-setter function or React.createRef().",
+ getComponentName(finishedWork.type)
);
}
}
@@ -15872,42 +16934,25 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) {
if (lastEffect !== null) {
var firstEffect = lastEffect.next;
+ var effect = firstEffect;
- {
- // When the owner fiber is deleted, the destroy function of a passive
- // effect hook is called during the synchronous commit phase. This is
- // a concession to implementation complexity. Calling it in the
- // passive effect phase (like they usually are, when dependencies
- // change during an update) would require either traversing the
- // children of the deleted fiber again, or including unmount effects
- // as part of the fiber effect list.
- //
- // Because this is during the sync commit phase, we need to change
- // the priority.
- //
- // TODO: Reconsider this implementation trade off.
- var priorityLevel =
- renderPriorityLevel > NormalPriority
- ? NormalPriority
- : renderPriorityLevel;
- runWithPriority(priorityLevel, function() {
- var effect = firstEffect;
-
- do {
- var _effect3 = effect,
- _destroy = _effect3.destroy,
- _tag = _effect3.tag;
-
- if (_destroy !== undefined) {
- {
- safelyCallDestroy(current, _destroy);
- }
+ do {
+ var _effect2 = effect,
+ destroy = _effect2.destroy,
+ tag = _effect2.tag;
+
+ if (destroy !== undefined) {
+ if ((tag & Passive$1) !== NoEffect$1) {
+ enqueuePendingPassiveHookEffectUnmount(current, effect);
+ } else {
+ {
+ safelyCallDestroy(current, destroy);
}
+ }
+ }
- effect = effect.next;
- } while (effect !== firstEffect);
- });
- }
+ effect = effect.next;
+ } while (effect !== firstEffect);
}
}
@@ -15964,7 +17009,7 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
var node = root;
while (true) {
- commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes.
+ commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes.
// Skip portals because commitUnmount() currently visits them recursively.
if (
@@ -15994,27 +17039,30 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
}
}
-function detachFiber(current) {
- var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we
+function detachFiberMutation(fiber) {
+ // Cut off the return pointers to disconnect it from the tree. Ideally, we
// should clear the child pointer of the parent alternate to let this
// get GC:ed but we don't know which for sure which parent is the current
// one so we'll settle for GC:ing the subtree of this child. This child
// itself will be GC:ed when the parent updates the next time.
+ // Note: we cannot null out sibling here, otherwise it can cause issues
+ // with findDOMNode and how it requires the sibling field to carry out
+ // traversal in a later effect. See PR #16820. We now clear the sibling
+ // field after effects, see: detachFiberAfterEffects.
+ fiber.alternate = null;
+ fiber.child = null;
+ fiber.dependencies = null;
+ fiber.firstEffect = null;
+ fiber.lastEffect = null;
+ fiber.memoizedProps = null;
+ fiber.memoizedState = null;
+ fiber.pendingProps = null;
+ fiber.return = null;
+ fiber.stateNode = null;
+ fiber.updateQueue = null;
- current.return = null;
- current.child = null;
- current.memoizedState = null;
- current.updateQueue = null;
- current.dependencies = null;
- current.alternate = null;
- current.firstEffect = null;
- current.lastEffect = null;
- current.pendingProps = null;
- current.memoizedProps = null;
- current.stateNode = null;
-
- if (alternate !== null) {
- detachFiber(alternate);
+ {
+ fiber._debugOwner = null;
}
}
@@ -16052,10 +17100,15 @@ function commitContainer(finishedWork) {
function commitDeletion(finishedRoot, current, renderPriorityLevel) {
{
// Detach refs and call componentWillUnmount() on the whole subtree.
- commitNestedUnmounts(finishedRoot, current, renderPriorityLevel);
+ commitNestedUnmounts(finishedRoot, current);
}
- detachFiber(current);
+ var alternate = current.alternate;
+ detachFiberMutation(current);
+
+ if (alternate !== null) {
+ detachFiberMutation(alternate);
+ }
}
function commitWork(current, finishedWork) {
@@ -16088,3026 +17141,3254 @@ function commitWork(current, finishedWork) {
return;
}
- case SuspenseListComponent: {
- attachSuspenseRetryListeners(finishedWork);
- return;
- }
- }
+ case SuspenseListComponent: {
+ attachSuspenseRetryListeners(finishedWork);
+ return;
+ }
+
+ case HostRoot: {
+ break;
+ }
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ return;
+ }
+ }
+
+ commitContainer(finishedWork);
+ return;
+ }
+}
+
+function commitSuspenseComponent(finishedWork) {
+ var newState = finishedWork.memoizedState;
+
+ if (newState !== null) {
+ markCommitTimeOfFallback();
+ }
+}
+
+function attachSuspenseRetryListeners(finishedWork) {
+ // If this boundary just timed out, then it will have a set of wakeables.
+ // For each wakeable, attach a listener so that when it resolves, React
+ // attempts to re-render the boundary in the primary (pre-timeout) state.
+ var wakeables = finishedWork.updateQueue;
+
+ if (wakeables !== null) {
+ finishedWork.updateQueue = null;
+ var retryCache = finishedWork.stateNode;
+
+ if (retryCache === null) {
+ retryCache = finishedWork.stateNode = new PossiblyWeakSet();
+ }
+
+ wakeables.forEach(function(wakeable) {
+ // Memoize using the boundary fiber to prevent redundant listeners.
+ var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
+
+ if (!retryCache.has(wakeable)) {
+ {
+ if (wakeable.__reactDoNotTraceInteractions !== true) {
+ retry = tracing.unstable_wrap(retry);
+ }
+ }
+
+ retryCache.add(wakeable);
+ wakeable.then(retry, retry);
+ }
+ });
+ }
+} // This function detects when a Suspense boundary goes from visible to hidden.
+// It returns false if the boundary is already hidden.
+// TODO: Use an effect tag.
+
+function isSuspenseBoundaryBeingHidden(current, finishedWork) {
+ if (current !== null) {
+ var oldState = current.memoizedState;
+
+ if (oldState === null || oldState.dehydrated !== null) {
+ var newState = finishedWork.memoizedState;
+ return newState !== null && newState.dehydrated === null;
+ }
+ }
+
+ return false;
+}
+
+var COMPONENT_TYPE = 0;
+var HAS_PSEUDO_CLASS_TYPE = 1;
+var ROLE_TYPE = 2;
+var TEST_NAME_TYPE = 3;
+var TEXT_TYPE = 4;
+
+if (typeof Symbol === "function" && Symbol.for) {
+ var symbolFor$1 = Symbol.for;
+ COMPONENT_TYPE = symbolFor$1("selector.component");
+ HAS_PSEUDO_CLASS_TYPE = symbolFor$1("selector.has_pseudo_class");
+ ROLE_TYPE = symbolFor$1("selector.role");
+ TEST_NAME_TYPE = symbolFor$1("selector.test_id");
+ TEXT_TYPE = symbolFor$1("selector.text");
+}
+
+var ceil = Math.ceil;
+var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
+ ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
+ IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
+var NoContext =
+ /* */
+ 0;
+var BatchedContext =
+ /* */
+ 1;
+var DiscreteEventContext =
+ /* */
+ 4;
+var LegacyUnbatchedContext =
+ /* */
+ 8;
+var RenderContext =
+ /* */
+ 16;
+var CommitContext =
+ /* */
+ 32;
+var RetryAfterError =
+ /* */
+ 64;
+var RootIncomplete = 0;
+var RootFatalErrored = 1;
+var RootErrored = 2;
+var RootSuspended = 3;
+var RootSuspendedWithDelay = 4;
+var RootCompleted = 5; // Describes where we are in the React execution stack
+
+var executionContext = NoContext; // The root we're working on
+
+var workInProgressRoot = null; // The fiber we're working on
+
+var workInProgress = null; // The lanes we're rendering
+
+var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree
+// This is a superset of the lanes we started working on at the root. The only
+// case where it's different from `workInProgressRootRenderLanes` is when we
+// enter a subtree that is hidden and needs to be unhidden: Suspense and
+// Offscreen component.
+//
+// Most things in the work loop should deal with workInProgressRootRenderLanes.
+// Most things in begin/complete phases should deal with subtreeRenderLanes.
+
+var subtreeRenderLanes = NoLanes;
+var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc.
+
+var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
+
+var workInProgressRootFatalError = null;
+var workInProgressRootLatestSuspenseTimeout = NoTimestamp;
+var workInProgressRootCanSuspendUsingConfig = null; // "Included" lanes refer to lanes that were worked on during this render. It's
+// slightly different than `renderLanes` because `renderLanes` can change as you
+// enter and exit an Offscreen tree. This value is the combination of all render
+// lanes for the entire render phase.
+
+var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only
+// includes unprocessed updates, not work in bailed out children.
+
+var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render.
+
+var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render.
+
+var workInProgressRootPingedLanes = NoLanes;
+var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train
+// model where we don't commit new loading states in too quick succession.
+
+var globalMostRecentFallbackTime = 0;
+var FALLBACK_THROTTLE_MS = 500;
+var DEFAULT_TIMEOUT_MS = 5000;
+var nextEffect = null;
+var hasUncaughtError = false;
+var firstUncaughtError = null;
+var legacyErrorBoundariesThatAlreadyFailed = null;
+var rootDoesHavePassiveEffects = false;
+var rootWithPendingPassiveEffects = null;
+var pendingPassiveEffectsRenderPriority = NoPriority$1;
+var pendingPassiveEffectsLanes = NoLanes;
+var pendingPassiveHookEffectsMount = [];
+var pendingPassiveHookEffectsUnmount = [];
+var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
+
+var NESTED_UPDATE_LIMIT = 50;
+var nestedUpdateCount = 0;
+var rootWithNestedUpdates = null;
+var NESTED_PASSIVE_UPDATE_LIMIT = 50;
+var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes
+// during the commit phase. This enables them to be traced across components
+// that spawn new work during render. E.g. hidden boundaries, suspended SSR
+// hydration or SuspenseList.
+// TODO: Can use a bitmask instead of an array
+
+var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their
+// event times as simultaneous, even if the actual clock time has advanced
+// between the first and second call.
- commitContainer(finishedWork);
- return;
- }
+var currentEventTime = NoTimestamp;
+var currentEventWipLanes = NoLanes;
+var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed.
+// We warn about state updates for unmounted components differently in this case.
+
+var isFlushingPassiveEffects = false;
+var focusedInstanceHandle = null;
+var shouldFireAfterActiveInstanceBlur = false;
+function getWorkInProgressRoot() {
+ return workInProgressRoot;
}
+function requestEventTime() {
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ // We're inside React, so it's fine to read the actual time.
+ return now();
+ } // We're not inside React, so we may be in the middle of a browser event.
-function commitSuspenseComponent(finishedWork) {
- var newState = finishedWork.memoizedState;
- var primaryChildParent = finishedWork;
+ if (currentEventTime !== NoTimestamp) {
+ // Use the same start time for all updates until we enter React again.
+ return currentEventTime;
+ } // This is the first update since React yielded. Compute a new start time.
- if (newState === null);
- else {
- primaryChildParent = finishedWork.child;
- markCommitTimeOfFallback();
- }
+ currentEventTime = now();
+ return currentEventTime;
}
+function requestUpdateLane(fiber, suspenseConfig) {
+ // Special cases
+ var mode = fiber.mode;
-function attachSuspenseRetryListeners(finishedWork) {
- // If this boundary just timed out, then it will have a set of thenables.
- // For each thenable, attach a listener so that when it resolves, React
- // attempts to re-render the boundary in the primary (pre-timeout) state.
- var thenables = finishedWork.updateQueue;
+ if ((mode & BlockingMode) === NoMode) {
+ return SyncLane;
+ } else if ((mode & ConcurrentMode) === NoMode) {
+ return getCurrentPriorityLevel() === ImmediatePriority$1
+ ? SyncLane
+ : SyncBatchedLane;
+ } // The algorithm for assigning an update to a lane should be stable for all
+ // updates at the same priority within the same event. To do this, the inputs
+ // to the algorithm must be the same. For example, we use the `renderLanes`
+ // to avoid choosing a lane that is already in the middle of rendering.
+ //
+ // However, the "included" lanes could be mutated in between updates in the
+ // same event, like if you perform an update inside `flushSync`. Or any other
+ // code path that might call `prepareFreshStack`.
+ //
+ // The trick we use is to cache the first of each of these inputs within an
+ // event. Then reset the cached values once we can be sure the event is over.
+ // Our heuristic for that is whenever we enter a concurrent work loop.
+ //
+ // We'll do the same for `currentEventPendingLanes` below.
- if (thenables !== null) {
- finishedWork.updateQueue = null;
- var retryCache = finishedWork.stateNode;
+ if (currentEventWipLanes === NoLanes) {
+ currentEventWipLanes = workInProgressRootIncludedLanes;
+ }
- if (retryCache === null) {
- retryCache = finishedWork.stateNode = new PossiblyWeakSet();
- }
+ if (suspenseConfig !== null) {
+ // Use the size of the timeout as a heuristic to prioritize shorter
+ // transitions over longer ones.
+ // TODO: This will coerce numbers larger than 31 bits to 0.
+ var timeoutMs = suspenseConfig.timeoutMs;
+ var transitionLanePriority =
+ timeoutMs === undefined || (timeoutMs | 0) < 10000
+ ? TransitionShortLanePriority
+ : TransitionLongLanePriority;
+
+ if (currentEventPendingLanes !== NoLanes) {
+ currentEventPendingLanes =
+ mostRecentlyUpdatedRoot !== null
+ ? mostRecentlyUpdatedRoot.pendingLanes
+ : NoLanes;
+ }
+
+ return findTransitionLane(
+ transitionLanePriority,
+ currentEventWipLanes,
+ currentEventPendingLanes
+ );
+ } // TODO: Remove this dependency on the Scheduler priority.
+ // To do that, we're replacing it with an update lane priority.
- thenables.forEach(function(thenable) {
- // Memoize using the boundary fiber to prevent redundant listeners.
- var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
+ var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler.
+ // This couples React to the Scheduler internals, so we're replacing it
+ // with the currentUpdateLanePriority above. As an example of how this
+ // could be problematic, if we're not inside `Scheduler.runWithPriority`,
+ // then we'll get the priority of the current running Scheduler task,
+ // which is probably not what we want.
- if (!retryCache.has(thenable)) {
- {
- if (thenable.__reactDoNotTraceInteractions !== true) {
- retry = tracing.unstable_wrap(retry);
- }
- }
+ var lane;
- retryCache.add(thenable);
- thenable.then(retry, retry);
- }
- });
- }
-}
+ if (
+ // TODO: Temporary. We're removing the concept of discrete updates.
+ (executionContext & DiscreteEventContext) !== NoContext &&
+ schedulerPriority === UserBlockingPriority$1
+ ) {
+ lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes);
+ } else {
+ var schedulerLanePriority = schedulerPriorityToLanePriority(
+ schedulerPriority
+ );
-var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
+ lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes);
+ }
-function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
- var update = createUpdate(expirationTime, null); // Unmount the root by rendering null.
+ return lane;
+}
- update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
- // being called "element".
+function requestRetryLane(fiber) {
+ // This is a fork of `requestUpdateLane` designed specifically for Suspense
+ // "retries" — a special update that attempts to flip a Suspense boundary
+ // from its placeholder state to its primary/resolved state.
+ // Special cases
+ var mode = fiber.mode;
- update.payload = {
- element: null
- };
- var error = errorInfo.value;
+ if ((mode & BlockingMode) === NoMode) {
+ return SyncLane;
+ } else if ((mode & ConcurrentMode) === NoMode) {
+ return getCurrentPriorityLevel() === ImmediatePriority$1
+ ? SyncLane
+ : SyncBatchedLane;
+ } // See `requestUpdateLane` for explanation of `currentEventWipLanes`
- update.callback = function() {
- onUncaughtError(error);
- logError(fiber, errorInfo);
- };
+ if (currentEventWipLanes === NoLanes) {
+ currentEventWipLanes = workInProgressRootIncludedLanes;
+ }
- return update;
+ return findRetryLane(currentEventWipLanes);
}
-function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
- var update = createUpdate(expirationTime, null);
- update.tag = CaptureUpdate;
- var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+function scheduleUpdateOnFiber(fiber, lane, eventTime) {
+ checkForNestedUpdates();
+ warnAboutRenderPhaseUpdatesInDEV(fiber);
+ var root = markUpdateLaneFromFiberToRoot(fiber, lane);
- if (typeof getDerivedStateFromError === "function") {
- var error$1 = errorInfo.value;
+ if (root === null) {
+ warnAboutUpdateOnUnmountedFiberInDEV(fiber);
+ return null;
+ } // Mark that the root has a pending update.
- update.payload = function() {
- logError(fiber, errorInfo);
- return getDerivedStateFromError(error$1);
- };
- }
+ markRootUpdated(root, lane, eventTime);
- var inst = fiber.stateNode;
+ if (root === workInProgressRoot) {
+ // Received an update to a tree that's in the middle of rendering. Mark
+ // that there was an interleaved update work on this root. Unless the
+ // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render
+ // phase update. In that case, we don't treat render phase updates as if
+ // they were interleaved, for backwards compat reasons.
+ {
+ workInProgressRootUpdatedLanes = mergeLanes(
+ workInProgressRootUpdatedLanes,
+ lane
+ );
+ }
- if (inst !== null && typeof inst.componentDidCatch === "function") {
- update.callback = function callback() {
- {
- markFailedErrorBoundaryForHotReloading(fiber);
- }
+ if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
+ // The root already suspended with a delay, which means this render
+ // definitely won't finish. Since we have a new update, let's mark it as
+ // suspended now, right before marking the incoming update. This has the
+ // effect of interrupting the current render and switching to the update.
+ // TODO: Make sure this doesn't override pings that happen while we've
+ // already started rendering.
+ markRootSuspended$1(root, workInProgressRootRenderLanes);
+ }
+ } // TODO: requestUpdateLanePriority also reads the priority. Pass the
+ // priority as an argument to that function and this one.
- if (typeof getDerivedStateFromError !== "function") {
- // To preserve the preexisting retry behavior of error boundaries,
- // we keep track of which ones already failed during this batch.
- // This gets reset before we yield back to the browser.
- // TODO: Warn in strict mode if getDerivedStateFromError is
- // not defined.
- markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
+ var priorityLevel = getCurrentPriorityLevel();
- logError(fiber, errorInfo);
- }
+ if (lane === SyncLane) {
+ if (
+ // Check if we're inside unbatchedUpdates
+ (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
+ (executionContext & (RenderContext | CommitContext)) === NoContext
+ ) {
+ // Register pending interactions on the root to avoid losing traced interaction data.
+ schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
+ // root inside of batchedUpdates should be synchronous, but layout updates
+ // should be deferred until the end of the batch.
- var error$1 = errorInfo.value;
- var stack = errorInfo.stack;
- this.componentDidCatch(error$1, {
- componentStack: stack !== null ? stack : ""
- });
+ performSyncWorkOnRoot(root);
+ } else {
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, lane);
- {
- if (typeof getDerivedStateFromError !== "function") {
- // If componentDidCatch is the only error boundary method defined,
- // then it needs to call setState to recover from errors.
- // If no state update is scheduled then the boundary will swallow the error.
- if (fiber.expirationTime !== Sync) {
- error(
- "%s: Error boundaries should implement getDerivedStateFromError(). " +
- "In that method, return a state update to display an error message or fallback UI.",
- getComponentName(fiber.type) || "Unknown"
- );
- }
- }
+ if (executionContext === NoContext) {
+ // Flush the synchronous work now, unless we're already working or inside
+ // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
+ // scheduleCallbackForFiber to preserve the ability to schedule a callback
+ // without immediately flushing it. We only do this for user-initiated
+ // updates, to preserve historical behavior of legacy mode.
+ flushSyncCallbackQueue();
}
- };
+ }
} else {
- update.callback = function() {
- markFailedErrorBoundaryForHotReloading(fiber);
- };
+ // Schedule a discrete update but only if it's not Sync.
+ if (
+ (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered
+ // discrete, even inside a discrete event.
+ (priorityLevel === UserBlockingPriority$1 ||
+ priorityLevel === ImmediatePriority$1)
+ ) {
+ // This is the result of a discrete event. Track the lowest priority
+ // discrete update per root so we can flush them early, if needed.
+ if (rootsWithPendingDiscreteUpdates === null) {
+ rootsWithPendingDiscreteUpdates = new Set([root]);
+ } else {
+ rootsWithPendingDiscreteUpdates.add(root);
+ }
+ } // Schedule other updates after in case the callback is sync.
+
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, lane);
+ } // We use this when assigning a lane for a transition inside
+ // `requestUpdateLane`. We assume it's the same as the root being updated,
+ // since in the common case of a single root app it probably is. If it's not
+ // the same root, then it's not a huge deal, we just might batch more stuff
+ // together more than necessary.
+
+ mostRecentlyUpdatedRoot = root;
+} // This is split into a separate function so we can mark a fiber with pending
+// work without treating it as a typical update that originates from an event;
+// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
+// on a fiber.
+
+function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
+ // Update the source fiber's lanes
+ sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane);
+ var alternate = sourceFiber.alternate;
+
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, lane);
}
- return update;
-}
+ {
+ if (
+ alternate === null &&
+ (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect
+ ) {
+ warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
+ }
+ } // Walk the parent path to the root and update the child expiration time.
-function attachPingListener(root, renderExpirationTime, thenable) {
- // Attach a listener to the promise to "ping" the root and retry. But
- // only if one does not already exist for the current render expiration
- // time (which acts like a "thread ID" here).
- var pingCache = root.pingCache;
- var threadIDs;
+ var node = sourceFiber;
+ var parent = sourceFiber.return;
- if (pingCache === null) {
- pingCache = root.pingCache = new PossiblyWeakMap();
- threadIDs = new Set();
- pingCache.set(thenable, threadIDs);
- } else {
- threadIDs = pingCache.get(thenable);
+ while (parent !== null) {
+ parent.childLanes = mergeLanes(parent.childLanes, lane);
+ alternate = parent.alternate;
- if (threadIDs === undefined) {
- threadIDs = new Set();
- pingCache.set(thenable, threadIDs);
+ if (alternate !== null) {
+ alternate.childLanes = mergeLanes(alternate.childLanes, lane);
+ } else {
+ {
+ if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) {
+ warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
+ }
+ }
}
+
+ node = parent;
+ parent = parent.return;
}
- if (!threadIDs.has(renderExpirationTime)) {
- // Memoize using the thread ID to prevent redundant listeners.
- threadIDs.add(renderExpirationTime);
- var ping = pingSuspendedRoot.bind(
- null,
- root,
- thenable,
- renderExpirationTime
- );
- thenable.then(ping, ping);
+ if (node.tag === HostRoot) {
+ var root = node.stateNode;
+ return root;
+ } else {
+ return null;
}
-}
+} // Use this function to schedule a task for a root. There's only one task per
+// root; if a task was already scheduled, we'll check to make sure the priority
+// of the existing task is the same as the priority of the next level that the
+// root has work on. This function is called on every update, and right before
+// exiting a task.
-function throwException(
- root,
- returnFiber,
- sourceFiber,
- value,
- renderExpirationTime
-) {
- // The source fiber did not complete.
- sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
+function ensureRootIsScheduled(root, currentTime) {
+ var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as
+ // expired so we know to work on those next.
- sourceFiber.firstEffect = sourceFiber.lastEffect = null;
+ markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority.
- if (
- value !== null &&
- typeof value === "object" &&
- typeof value.then === "function"
- ) {
- // This is a thenable.
- var thenable = value;
+ var nextLanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes
+ ); // This returns the priority level computed during the `getNextLanes` call.
- if ((sourceFiber.mode & BlockingMode) === NoMode) {
- // Reset the memoizedState to what it was before we attempted
- // to render it.
- var currentSource = sourceFiber.alternate;
+ var newCallbackPriority = returnNextLanesPriority();
- if (currentSource) {
- sourceFiber.updateQueue = currentSource.updateQueue;
- sourceFiber.memoizedState = currentSource.memoizedState;
- sourceFiber.expirationTime = currentSource.expirationTime;
- } else {
- sourceFiber.updateQueue = null;
- sourceFiber.memoizedState = null;
- }
+ if (nextLanes === NoLanes) {
+ // Special case: There's nothing to work on.
+ if (existingCallbackNode !== null) {
+ cancelCallback(existingCallbackNode);
+ root.callbackNode = null;
+ root.callbackPriority = NoLanePriority;
}
- var hasInvisibleParentBoundary = hasSuspenseContext(
- suspenseStackCursor.current,
- InvisibleParentSuspenseContext
- ); // Schedule the nearest Suspense to re-render the timed out view.
+ return;
+ } // Check if there's an existing task. We may be able to reuse it.
- var _workInProgress = returnFiber;
+ if (existingCallbackNode !== null) {
+ var existingCallbackPriority = root.callbackPriority;
- do {
- if (
- _workInProgress.tag === SuspenseComponent &&
- shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)
- ) {
- // Found the nearest boundary.
- // Stash the promise on the boundary fiber. If the boundary times out, we'll
- // attach another listener to flip the boundary back to its normal state.
- var thenables = _workInProgress.updateQueue;
+ if (existingCallbackPriority === newCallbackPriority) {
+ // The priority hasn't changed. We can reuse the existing task. Exit.
+ return;
+ } // The priority changed. Cancel the existing callback. We'll schedule a new
+ // one below.
- if (thenables === null) {
- var updateQueue = new Set();
- updateQueue.add(thenable);
- _workInProgress.updateQueue = updateQueue;
- } else {
- thenables.add(thenable);
- } // If the boundary is outside of blocking mode, we should *not*
- // suspend the commit. Pretend as if the suspended component rendered
- // null and keep rendering. In the commit phase, we'll schedule a
- // subsequent synchronous update to re-render the Suspense.
- //
- // Note: It doesn't matter whether the component that suspended was
- // inside a blocking mode tree. If the Suspense is outside of it, we
- // should *not* suspend the commit.
+ cancelCallback(existingCallbackNode);
+ } // Schedule a new callback.
- if ((_workInProgress.mode & BlockingMode) === NoMode) {
- _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete.
- // But we shouldn't call any lifecycle methods or callbacks. Remove
- // all lifecycle effect tags.
+ var newCallbackNode;
- sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
+ if (newCallbackPriority === SyncLanePriority) {
+ // Special case: Sync React callbacks are scheduled on a special
+ // internal queue
+ newCallbackNode = scheduleSyncCallback(
+ performSyncWorkOnRoot.bind(null, root)
+ );
+ } else if (newCallbackPriority === SyncBatchedLanePriority) {
+ newCallbackNode = scheduleCallback(
+ ImmediatePriority$1,
+ performSyncWorkOnRoot.bind(null, root)
+ );
+ } else {
+ var schedulerPriorityLevel = lanePriorityToSchedulerPriority(
+ newCallbackPriority
+ );
+ newCallbackNode = scheduleCallback(
+ schedulerPriorityLevel,
+ performConcurrentWorkOnRoot.bind(null, root)
+ );
+ }
- if (sourceFiber.tag === ClassComponent) {
- var currentSourceFiber = sourceFiber.alternate;
+ root.callbackPriority = newCallbackPriority;
+ root.callbackNode = newCallbackNode;
+} // This is the entry point for every concurrent task, i.e. anything that
+// goes through Scheduler.
+
+function performConcurrentWorkOnRoot(root, didTimeout) {
+ // Since we know we're in a React event, we can clear the current
+ // event time. The next update will compute a new event time.
+ currentEventTime = NoTimestamp;
+ currentEventWipLanes = NoLanes;
+ currentEventPendingLanes = NoLanes;
+
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Should not already be working.");
+ } // Flush any pending passive effects before deciding which lanes to work on,
+ // in case they schedule additional work.
- if (currentSourceFiber === null) {
- // This is a new mount. Change the tag so it's not mistaken for a
- // completed class component. For example, we should not call
- // componentWillUnmount if it is deleted.
- sourceFiber.tag = IncompleteClassComponent;
- } else {
- // When we try rendering again, we should not reuse the current fiber,
- // since it's known to be in an inconsistent state. Use a force update to
- // prevent a bail out.
- var update = createUpdate(Sync, null);
- update.tag = ForceUpdate;
- enqueueUpdate(sourceFiber, update);
- }
- } // The source fiber did not complete. Mark it with Sync priority to
- // indicate that it still has pending work.
+ var originalCallbackNode = root.callbackNode;
+ var didFlushPassiveEffects = flushPassiveEffects();
+
+ if (didFlushPassiveEffects) {
+ // Something in the passive effect phase may have canceled the current task.
+ // Check if the task node for this root was changed.
+ if (root.callbackNode !== originalCallbackNode) {
+ // The current task was canceled. Exit. We don't need to call
+ // `ensureRootIsScheduled` because the check above implies either that
+ // there's a new task, or that there's no remaining work on this root.
+ return null;
+ }
+ } // Determine the next expiration time to work on, using the fields stored
+ // on the root.
- sourceFiber.expirationTime = Sync; // Exit without suspending.
+ var lanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes
+ );
- return;
- } // Confirmed that the boundary is in a concurrent mode tree. Continue
- // with the normal suspend path.
- //
- // After this we'll use a set of heuristics to determine whether this
- // render pass will run to completion or restart or "suspend" the commit.
- // The actual logic for this is spread out in different places.
- //
- // This first principle is that if we're going to suspend when we complete
- // a root, then we should also restart if we get an update or ping that
- // might unsuspend it, and vice versa. The only reason to suspend is
- // because you think you might want to restart before committing. However,
- // it doesn't make sense to restart only while in the period we're suspended.
- //
- // Restarting too aggressively is also not good because it starves out any
- // intermediate loading state. So we use heuristics to determine when.
- // Suspense Heuristics
- //
- // If nothing threw a Promise or all the same fallbacks are already showing,
- // then don't suspend/restart.
- //
- // If this is an initial render of a new tree of Suspense boundaries and
- // those trigger a fallback, then don't suspend/restart. We want to ensure
- // that we can show the initial loading state as quickly as possible.
- //
- // If we hit a "Delayed" case, such as when we'd switch from content back into
- // a fallback, then we should always suspend/restart. SuspenseConfig applies to
- // this case. If none is defined, JND is used instead.
- //
- // If we're already showing a fallback and it gets "retried", allowing us to show
- // another level, but there's still an inner boundary that would show a fallback,
- // then we suspend/restart for 500ms since the last time we showed a fallback
- // anywhere in the tree. This effectively throttles progressive loading into a
- // consistent train of commits. This also gives us an opportunity to restart to
- // get to the completed state slightly earlier.
- //
- // If there's ambiguity due to batching it's resolved in preference of:
- // 1) "delayed", 2) "initial render", 3) "retry".
- //
- // We want to ensure that a "busy" state doesn't get force committed. We want to
- // ensure that new initial loading states can commit as soon as possible.
+ if (lanes === NoLanes) {
+ // Defensive coding. This is never expected to happen.
+ return null;
+ } // TODO: We only check `didTimeout` defensively, to account for a Scheduler
+ // bug where `shouldYield` sometimes returns `true` even if `didTimeout` is
+ // true, which leads to an infinite loop. Once the bug in Scheduler is
+ // fixed, we can remove this, since we track expiration ourselves.
- attachPingListener(root, renderExpirationTime, thenable);
- _workInProgress.effectTag |= ShouldCapture;
- _workInProgress.expirationTime = renderExpirationTime;
- return;
- } // This boundary already captured during this render. Continue to the next
- // boundary.
+ if (didTimeout) {
+ // Something expired. Flush synchronously until there's no expired
+ // work left.
+ markRootExpired(root, lanes); // This will schedule a synchronous callback.
- _workInProgress = _workInProgress.return;
- } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
- // TODO: Use invariant so the message is stripped in prod?
+ ensureRootIsScheduled(root, now());
+ return null;
+ }
- value = new Error(
- (getComponentName(sourceFiber.type) || "A React component") +
- " suspended while rendering, but no fallback UI was specified.\n" +
- "\n" +
- "Add a component higher in the tree to " +
- "provide a loading indicator or placeholder to display." +
- getStackByFiberInDevAndProd(sourceFiber)
- );
- } // We didn't find a boundary that could handle this type of exception. Start
- // over and traverse parent path again, this time treating the exception
- // as an error.
+ var exitStatus = renderRootConcurrent(root, lanes);
- renderDidError();
- value = createCapturedValue(value, sourceFiber);
- var workInProgress = returnFiber;
+ if (
+ includesSomeLane(
+ workInProgressRootIncludedLanes,
+ workInProgressRootUpdatedLanes
+ )
+ ) {
+ // The render included lanes that were updated during the render phase.
+ // For example, when unhiding a hidden tree, we include all the lanes
+ // that were previously skipped when the tree was hidden. That set of
+ // lanes is a superset of the lanes we started rendering with.
+ //
+ // So we'll throw out the current work and restart.
+ prepareFreshStack(root, NoLanes);
+ } else if (exitStatus !== RootIncomplete) {
+ if (exitStatus === RootErrored) {
+ executionContext |= RetryAfterError; // If an error occurred during hydration,
+ // discard server response and fall back to client side render.
- do {
- switch (workInProgress.tag) {
- case HostRoot: {
- var _errorInfo = value;
- workInProgress.effectTag |= ShouldCapture;
- workInProgress.expirationTime = renderExpirationTime;
+ if (root.hydrate) {
+ root.hydrate = false;
+ clearContainer(root.containerInfo);
+ } // If something threw an error, try rendering one more time. We'll render
+ // synchronously to block concurrent data mutations, and we'll includes
+ // all pending updates are included. If it still fails after the second
+ // attempt, we'll give up and commit the resulting tree.
- var _update = createRootErrorUpdate(
- workInProgress,
- _errorInfo,
- renderExpirationTime
- );
+ lanes = getLanesToRetrySynchronouslyOnError(root);
- enqueueCapturedUpdate(workInProgress, _update);
- return;
+ if (lanes !== NoLanes) {
+ exitStatus = renderRootSync(root, lanes);
}
+ }
- case ClassComponent:
- // Capture and retry
- var errorInfo = value;
- var ctor = workInProgress.type;
- var instance = workInProgress.stateNode;
-
- if (
- (workInProgress.effectTag & DidCapture) === NoEffect &&
- (typeof ctor.getDerivedStateFromError === "function" ||
- (instance !== null &&
- typeof instance.componentDidCatch === "function" &&
- !isAlreadyFailedLegacyErrorBoundary(instance)))
- ) {
- workInProgress.effectTag |= ShouldCapture;
- workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state
+ if (exitStatus === RootFatalErrored) {
+ var fatalError = workInProgressRootFatalError;
+ prepareFreshStack(root, NoLanes);
+ markRootSuspended$1(root, lanes);
+ ensureRootIsScheduled(root, now());
+ throw fatalError;
+ } // We now have a consistent tree. The next step is either to commit it,
+ // or, if something suspended, wait to commit it after a timeout.
- var _update2 = createClassErrorUpdate(
- workInProgress,
- errorInfo,
- renderExpirationTime
- );
+ var finishedWork = root.current.alternate;
+ root.finishedWork = finishedWork;
+ root.finishedLanes = lanes;
+ finishConcurrentRender(root, finishedWork, exitStatus, lanes);
+ }
- enqueueCapturedUpdate(workInProgress, _update2);
- return;
- }
+ ensureRootIsScheduled(root, now());
- break;
- }
+ if (root.callbackNode === originalCallbackNode) {
+ // The task node scheduled for this root is the same one that's
+ // currently executed. Need to return a continuation.
+ return performConcurrentWorkOnRoot.bind(null, root);
+ }
- workInProgress = workInProgress.return;
- } while (workInProgress !== null);
+ return null;
}
-var ceil = Math.ceil;
-var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
- ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
- IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
-var NoContext =
- /* */
- 0;
-var BatchedContext =
- /* */
- 1;
-var DiscreteEventContext =
- /* */
- 4;
-var LegacyUnbatchedContext =
- /* */
- 8;
-var RenderContext =
- /* */
- 16;
-var CommitContext =
- /* */
- 32;
-var RootIncomplete = 0;
-var RootFatalErrored = 1;
-var RootErrored = 2;
-var RootSuspended = 3;
-var RootSuspendedWithDelay = 4;
-var RootCompleted = 5;
-// Describes where we are in the React execution stack
-var executionContext = NoContext; // The root we're working on
-
-var workInProgressRoot = null; // The fiber we're working on
+function finishConcurrentRender(root, finishedWork, exitStatus, lanes) {
+ switch (exitStatus) {
+ case RootIncomplete:
+ case RootFatalErrored: {
+ {
+ throw Error("Root did not complete. This is a bug in React.");
+ }
+ }
+ // Flow knows about invariant, so it complains if I add a break
+ // statement, but eslint doesn't know about invariant, so it complains
+ // if I do. eslint-disable-next-line no-fallthrough
-var workInProgress = null; // The expiration time we're rendering
+ case RootErrored: {
+ // We should have already attempted to retry this tree. If we reached
+ // this point, it errored again. Commit it.
+ commitRoot(root);
+ break;
+ }
-var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc.
+ case RootSuspended: {
+ markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we
+ // should immediately commit it or wait a bit.
-var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
+ if (
+ includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope
+ !shouldForceFlushFallbacksInDEV()
+ ) {
+ // This render only included retries, no updates. Throttle committing
+ // retries so that we don't show too many loading states too quickly.
+ var msUntilTimeout =
+ globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
-var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render.
-// This is conceptually a time stamp but expressed in terms of an ExpirationTime
-// because we deal mostly with expiration times in the hot path, so this avoids
-// the conversion happening in the hot path.
+ if (msUntilTimeout > 10) {
+ var nextLanes = getNextLanes(root, NoLanes);
-var workInProgressRootLatestProcessedExpirationTime = Sync;
-var workInProgressRootLatestSuspenseTimeout = Sync;
-var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only
-// includes unprocessed updates, not work in bailed out children.
+ if (nextLanes !== NoLanes) {
+ // There's additional work on this root.
+ break;
+ }
-var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately.
-// This flag determines if it might be worthwhile to restart if an opportunity
-// happens latere.
+ var suspendedLanes = root.suspendedLanes;
-var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train
-// model where we don't commit new loading states in too quick succession.
+ if (!isSubsetOfLanes(suspendedLanes, lanes)) {
+ // We should prefer to render the fallback of at the last
+ // suspended level. Ping the last suspended level to try
+ // rendering it again.
+ // FIXME: What if the suspended lanes are Idle? Should not restart.
+ var eventTime = requestEventTime();
+ markRootPinged(root, suspendedLanes);
+ break;
+ } // The render is suspended, it hasn't timed out, and there's no
+ // lower priority work to do. Instead of committing the fallback
+ // immediately, wait for more data to arrive.
-var globalMostRecentFallbackTime = 0;
-var FALLBACK_THROTTLE_MS = 500;
-var nextEffect = null;
-var hasUncaughtError = false;
-var firstUncaughtError = null;
-var legacyErrorBoundariesThatAlreadyFailed = null;
-var rootDoesHavePassiveEffects = false;
-var rootWithPendingPassiveEffects = null;
-var pendingPassiveEffectsRenderPriority = NoPriority;
-var pendingPassiveEffectsExpirationTime = NoWork;
-var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ msUntilTimeout
+ );
+ break;
+ }
+ } // The work expired. Commit immediately.
-var NESTED_UPDATE_LIMIT = 50;
-var nestedUpdateCount = 0;
-var rootWithNestedUpdates = null;
-var NESTED_PASSIVE_UPDATE_LIMIT = 50;
-var nestedPassiveUpdateCount = 0;
-var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times
-// during the commit phase. This enables them to be traced across components
-// that spawn new work during render. E.g. hidden boundaries, suspended SSR
-// hydration or SuspenseList.
+ commitRoot(root);
+ break;
+ }
-var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start
-// time). However, if two updates are scheduled within the same event, we
-// should treat their start times as simultaneous, even if the actual clock
-// time has advanced between the first and second call.
-// In other words, because expiration times determine how updates are batched,
-// we want all updates of like priority that occur within the same event to
-// receive the same expiration time. Otherwise we get tearing.
+ case RootSuspendedWithDelay: {
+ markRootSuspended$1(root, lanes);
-var currentEventTime = NoWork;
-function requestCurrentTimeForUpdate() {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
- // We're inside React, so it's fine to read the actual time.
- return msToExpirationTime(now());
- } // We're not inside React, so we may be in the middle of a browser event.
+ if (
+ // do not delay if we're inside an act() scope
+ !shouldForceFlushFallbacksInDEV()
+ ) {
+ // We're suspended in a state that should be avoided. We'll try to
+ // avoid committing it for as long as the timeouts let us.
+ var _nextLanes = getNextLanes(root, NoLanes);
- if (currentEventTime !== NoWork) {
- // Use the same start time for all updates until we enter React again.
- return currentEventTime;
- } // This is the first update since React yielded. Compute a new start time.
+ if (_nextLanes !== NoLanes) {
+ // There's additional work on this root.
+ break;
+ }
- currentEventTime = msToExpirationTime(now());
- return currentEventTime;
-}
-function getCurrentTime() {
- return msToExpirationTime(now());
-}
-function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
- var mode = fiber.mode;
+ var _suspendedLanes = root.suspendedLanes;
- if ((mode & BlockingMode) === NoMode) {
- return Sync;
- }
+ if (!isSubsetOfLanes(_suspendedLanes, lanes)) {
+ // We should prefer to render the fallback of at the last
+ // suspended level. Ping the last suspended level to try
+ // rendering it again.
+ // FIXME: What if the suspended lanes are Idle? Should not restart.
+ var _eventTime = requestEventTime();
- var priorityLevel = getCurrentPriorityLevel();
+ markRootPinged(root, _suspendedLanes);
+ break;
+ }
- if ((mode & ConcurrentMode) === NoMode) {
- return priorityLevel === ImmediatePriority ? Sync : Batched;
- }
+ var mostRecentEventTime = getMostRecentEventTime(root, lanes);
- if ((executionContext & RenderContext) !== NoContext) {
- // Use whatever time we're already rendering
- // TODO: Should there be a way to opt out, like with `runWithPriority`?
- return renderExpirationTime$1;
- }
+ var _msUntilTimeout;
- var expirationTime;
+ if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) {
+ // We have processed a suspense config whose expiration time we
+ // can use as the timeout.
+ _msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now();
+ } else if (mostRecentEventTime === NoTimestamp) {
+ // This should never normally happen because only new updates
+ // cause delayed states, so we should have processed something.
+ // However, this could also happen in an offscreen tree.
+ _msUntilTimeout = 0;
+ } else {
+ // If we didn't process a suspense config, compute a JND based on
+ // the amount of time elapsed since the most recent event time.
+ var eventTimeMs = mostRecentEventTime;
+ var timeElapsedMs = now() - eventTimeMs;
+ _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs;
+ } // Don't bother with a very short suspense time.
- if (suspenseConfig !== null) {
- // Compute an expiration time based on the Suspense timeout.
- expirationTime = computeSuspenseExpiration(
- currentTime,
- suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION
- );
- } else {
- // Compute an expiration time based on the Scheduler priority.
- switch (priorityLevel) {
- case ImmediatePriority:
- expirationTime = Sync;
- break;
+ if (_msUntilTimeout > 10) {
+ // The render is suspended, it hasn't timed out, and there's no
+ // lower priority work to do. Instead of committing the fallback
+ // immediately, wait for more data to arrive.
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ _msUntilTimeout
+ );
+ break;
+ }
+ } // The work expired. Commit immediately.
- case UserBlockingPriority:
- // TODO: Rename this to computeUserBlockingExpiration
- expirationTime = computeInteractiveExpiration(currentTime);
- break;
+ commitRoot(root);
+ break;
+ }
- case NormalPriority:
- case LowPriority:
- // TODO: Handle LowPriority
- // TODO: Rename this to... something better.
- expirationTime = computeAsyncExpiration(currentTime);
- break;
+ case RootCompleted: {
+ // The work completed. Ready to commit.
+ var _mostRecentEventTime = getMostRecentEventTime(root, lanes);
- case IdlePriority:
- expirationTime = Idle;
- break;
+ if (
+ // do not delay if we're inside an act() scope
+ !shouldForceFlushFallbacksInDEV() &&
+ _mostRecentEventTime !== NoTimestamp &&
+ workInProgressRootCanSuspendUsingConfig !== null
+ ) {
+ // If we have exceeded the minimum loading delay, which probably
+ // means we have shown a spinner already, we might have to suspend
+ // a bit longer to ensure that the spinner is shown for
+ // enough time.
+ var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(
+ _mostRecentEventTime,
+ workInProgressRootCanSuspendUsingConfig
+ );
- default: {
- throw Error("Expected a valid priority level");
+ if (_msUntilTimeout2 > 10) {
+ markRootSuspended$1(root, lanes);
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ _msUntilTimeout2
+ );
+ break;
+ }
}
+
+ commitRoot(root);
+ break;
}
- } // If we're in the middle of rendering a tree, do not update at the same
- // expiration time that is already rendering.
- // TODO: We shouldn't have to do this if the update is on a different root.
- // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
- // the root when we check for this condition.
- if (
- workInProgressRoot !== null &&
- expirationTime === renderExpirationTime$1
- ) {
- // This is a trick to move this update into a separate batch
- expirationTime -= 1;
+ default: {
+ {
+ throw Error("Unknown root exit status.");
+ }
+ }
}
-
- return expirationTime;
}
-function scheduleUpdateOnFiber(fiber, expirationTime) {
- checkForNestedUpdates();
- warnAboutRenderPhaseUpdatesInDEV(fiber);
- var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
- if (root === null) {
- warnAboutUpdateOnUnmountedFiberInDEV(fiber);
- return;
+function markRootSuspended$1(root, suspendedLanes) {
+ // When suspending, we should always exclude lanes that were pinged or (more
+ // rarely, since we try to avoid it) updated during the render phase.
+ // TODO: Lol maybe there's a better way to factor this besides this
+ // obnoxiously named function :)
+ suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes);
+ suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes);
+ markRootSuspended(root, suspendedLanes);
+} // This is the entry point for synchronous tasks that don't go
+// through Scheduler
+
+function performSyncWorkOnRoot(root) {
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Should not already be working.");
}
- checkForInterruption(fiber, expirationTime);
- recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
- // priority as an argument to that function and this one.
+ flushPassiveEffects();
+ var lanes;
+ var exitStatus;
- var priorityLevel = getCurrentPriorityLevel();
+ if (
+ root === workInProgressRoot &&
+ includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes)
+ ) {
+ // There's a partial tree, and at least one of its lanes has expired. Finish
+ // rendering it before rendering the rest of the expired work.
+ lanes = workInProgressRootRenderLanes;
+ exitStatus = renderRootSync(root, lanes);
- if (expirationTime === Sync) {
if (
- // Check if we're inside unbatchedUpdates
- (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
- (executionContext & (RenderContext | CommitContext)) === NoContext
+ includesSomeLane(
+ workInProgressRootIncludedLanes,
+ workInProgressRootUpdatedLanes
+ )
) {
- // Register pending interactions on the root to avoid losing traced interaction data.
- schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
- // root inside of batchedUpdates should be synchronous, but layout updates
- // should be deferred until the end of the batch.
-
- performSyncWorkOnRoot(root);
- } else {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, expirationTime);
-
- if (executionContext === NoContext) {
- // Flush the synchronous work now, unless we're already working or inside
- // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
- // scheduleCallbackForFiber to preserve the ability to schedule a callback
- // without immediately flushing it. We only do this for user-initiated
- // updates, to preserve historical behavior of legacy mode.
- flushSyncCallbackQueue();
- }
+ // The render included lanes that were updated during the render phase.
+ // For example, when unhiding a hidden tree, we include all the lanes
+ // that were previously skipped when the tree was hidden. That set of
+ // lanes is a superset of the lanes we started rendering with.
+ //
+ // Note that this only happens when part of the tree is rendered
+ // concurrently. If the whole tree is rendered synchronously, then there
+ // are no interleaved events.
+ lanes = getNextLanes(root, lanes);
+ exitStatus = renderRootSync(root, lanes);
}
} else {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, expirationTime);
+ lanes = getNextLanes(root, NoLanes);
+ exitStatus = renderRootSync(root, lanes);
}
- if (
- (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered
- // discrete, even inside a discrete event.
- (priorityLevel === UserBlockingPriority ||
- priorityLevel === ImmediatePriority)
- ) {
- // This is the result of a discrete event. Track the lowest priority
- // discrete update per root so we can flush them early, if needed.
- if (rootsWithPendingDiscreteUpdates === null) {
- rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
- } else {
- var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
-
- if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
- rootsWithPendingDiscreteUpdates.set(root, expirationTime);
- }
- }
- }
-}
-var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending
-// work without treating it as a typical update that originates from an event;
-// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
-// on a fiber.
+ if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
+ executionContext |= RetryAfterError; // If an error occurred during hydration,
+ // discard server response and fall back to client side render.
-function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
- // Update the source fiber's expiration time
- if (fiber.expirationTime < expirationTime) {
- fiber.expirationTime = expirationTime;
- }
+ if (root.hydrate) {
+ root.hydrate = false;
+ clearContainer(root.containerInfo);
+ } // If something threw an error, try rendering one more time. We'll render
+ // synchronously to block concurrent data mutations, and we'll includes
+ // all pending updates are included. If it still fails after the second
+ // attempt, we'll give up and commit the resulting tree.
- var alternate = fiber.alternate;
+ lanes = getLanesToRetrySynchronouslyOnError(root);
- if (alternate !== null && alternate.expirationTime < expirationTime) {
- alternate.expirationTime = expirationTime;
- } // Walk the parent path to the root and update the child expiration time.
+ if (lanes !== NoLanes) {
+ exitStatus = renderRootSync(root, lanes);
+ }
+ }
- var node = fiber.return;
- var root = null;
+ if (exitStatus === RootFatalErrored) {
+ var fatalError = workInProgressRootFatalError;
+ prepareFreshStack(root, NoLanes);
+ markRootSuspended$1(root, lanes);
+ ensureRootIsScheduled(root, now());
+ throw fatalError;
+ } // We now have a consistent tree. Because this is a sync render, we
+ // will commit it even if something suspended.
- if (node === null && fiber.tag === HostRoot) {
- root = fiber.stateNode;
- } else {
- while (node !== null) {
- alternate = node.alternate;
+ var finishedWork = root.current.alternate;
+ root.finishedWork = finishedWork;
+ root.finishedLanes = lanes;
+ commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next
+ // pending level.
- if (node.childExpirationTime < expirationTime) {
- node.childExpirationTime = expirationTime;
+ ensureRootIsScheduled(root, now());
+ return null;
+}
- if (
- alternate !== null &&
- alternate.childExpirationTime < expirationTime
- ) {
- alternate.childExpirationTime = expirationTime;
- }
- } else if (
- alternate !== null &&
- alternate.childExpirationTime < expirationTime
- ) {
- alternate.childExpirationTime = expirationTime;
- }
+function batchedUpdates$1(fn, a) {
+ var prevExecutionContext = executionContext;
+ executionContext |= BatchedContext;
- if (node.return === null && node.tag === HostRoot) {
- root = node.stateNode;
- break;
- }
+ try {
+ return fn(a);
+ } finally {
+ executionContext = prevExecutionContext;
- node = node.return;
+ if (executionContext === NoContext) {
+ // Flush the immediate callbacks that were scheduled during this batch
+ flushSyncCallbackQueue();
}
}
-
- if (root !== null) {
- if (workInProgressRoot === root) {
- // Received an update to a tree that's in the middle of rendering. Mark
- // that's unprocessed work on this root.
- markUnprocessedUpdateTime(expirationTime);
-
- if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
- // The root already suspended with a delay, which means this render
- // definitely won't finish. Since we have a new update, let's mark it as
- // suspended now, right before marking the incoming update. This has the
- // effect of interrupting the current render and switching to the update.
- // TODO: This happens to work when receiving an update during the render
- // phase, because of the trick inside computeExpirationForFiber to
- // subtract 1 from `renderExpirationTime` to move it into a
- // separate bucket. But we should probably model it with an exception,
- // using the same mechanism we use to force hydration of a subtree.
- // TODO: This does not account for low pri updates that were already
- // scheduled before the root started rendering. Need to track the next
- // pending expiration time (perhaps by backtracking the return path) and
- // then trigger a restart in the `renderDidSuspendDelayIfPossible` path.
- markRootSuspendedAtTime(root, renderExpirationTime$1);
- }
- } // Mark that the root has a pending update.
-
- markRootUpdatedAtTime(root, expirationTime);
- }
-
- return root;
}
+function flushSync(fn, a) {
+ var prevExecutionContext = executionContext;
-function getNextRootExpirationTimeToWorkOn(root) {
- // Determines the next expiration time that the root should render, taking
- // into account levels that may be suspended, or levels that may have
- // received a ping.
- var lastExpiredTime = root.lastExpiredTime;
-
- if (lastExpiredTime !== NoWork) {
- return lastExpiredTime;
- } // "Pending" refers to any update that hasn't committed yet, including if it
- // suspended. The "suspended" range is therefore a subset.
+ if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) {
+ {
+ error(
+ "flushSync was called from inside a lifecycle method. React cannot " +
+ "flush when React is already rendering. Consider moving this call to " +
+ "a scheduler task or micro task."
+ );
+ }
- var firstPendingTime = root.firstPendingTime;
+ return fn(a);
+ }
- if (!isRootSuspendedAtTime(root, firstPendingTime)) {
- // The highest priority pending time is not suspended. Let's work on that.
- return firstPendingTime;
- } // If the first pending time is suspended, check if there's a lower priority
- // pending level that we know about. Or check if we received a ping. Work
- // on whichever is higher priority.
+ executionContext |= BatchedContext;
- var lastPingedTime = root.lastPingedTime;
- var nextKnownPendingLevel = root.nextKnownPendingLevel;
- var nextLevel =
- lastPingedTime > nextKnownPendingLevel
- ? lastPingedTime
- : nextKnownPendingLevel;
+ try {
+ setCurrentUpdateLanePriority(SyncLanePriority);
- if (nextLevel <= Idle && firstPendingTime !== nextLevel) {
- // Don't work on Idle/Never priority unless everything else is committed.
- return NoWork;
- }
+ if (fn) {
+ return runWithPriority(ImmediatePriority$1, fn.bind(null, a));
+ } else {
+ return undefined;
+ }
+ } finally {
+ executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
+ // Note that this will happen even if batchedUpdates is higher up
+ // the stack.
- return nextLevel;
-} // Use this function to schedule a task for a root. There's only one task per
-// root; if a task was already scheduled, we'll check to make sure the
-// expiration time of the existing task is the same as the expiration time of
-// the next level that the root has work on. This function is called on every
-// update, and right before exiting a task.
-
-function ensureRootIsScheduled(root) {
- var lastExpiredTime = root.lastExpiredTime;
-
- if (lastExpiredTime !== NoWork) {
- // Special case: Expired work should flush synchronously.
- root.callbackExpirationTime = Sync;
- root.callbackPriority = ImmediatePriority;
- root.callbackNode = scheduleSyncCallback(
- performSyncWorkOnRoot.bind(null, root)
- );
- return;
+ flushSyncCallbackQueue();
}
+}
+function pushRenderLanes(fiber, lanes) {
+ push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber);
+ subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes);
+ workInProgressRootIncludedLanes = mergeLanes(
+ workInProgressRootIncludedLanes,
+ lanes
+ );
+}
+function popRenderLanes(fiber) {
+ subtreeRenderLanes = subtreeRenderLanesCursor.current;
+ pop(subtreeRenderLanesCursor, fiber);
+}
- var expirationTime = getNextRootExpirationTimeToWorkOn(root);
- var existingCallbackNode = root.callbackNode;
+function prepareFreshStack(root, lanes) {
+ root.finishedWork = null;
+ root.finishedLanes = NoLanes;
+ var timeoutHandle = root.timeoutHandle;
- if (expirationTime === NoWork) {
- // There's nothing to work on.
- if (existingCallbackNode !== null) {
- root.callbackNode = null;
- root.callbackExpirationTime = NoWork;
- root.callbackPriority = NoPriority;
- }
+ if (timeoutHandle !== noTimeout) {
+ // The root previous suspended and scheduled a timeout to commit a fallback
+ // state. Now that we have additional work, cancel the timeout.
+ root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
- return;
- } // TODO: If this is an update, we already read the current time. Pass the
- // time as an argument.
+ cancelTimeout(timeoutHandle);
+ }
- var currentTime = requestCurrentTimeForUpdate();
- var priorityLevel = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- ); // If there's an existing render task, confirm it has the correct priority and
- // expiration time. Otherwise, we'll cancel it and schedule a new one.
+ if (workInProgress !== null) {
+ var interruptedWork = workInProgress.return;
- if (existingCallbackNode !== null) {
- var existingCallbackPriority = root.callbackPriority;
- var existingCallbackExpirationTime = root.callbackExpirationTime;
+ while (interruptedWork !== null) {
+ unwindInterruptedWork(interruptedWork);
+ interruptedWork = interruptedWork.return;
+ }
+ }
- if (
- // Callback must have the exact same expiration time.
- existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority.
- existingCallbackPriority >= priorityLevel
- ) {
- // Existing callback is sufficient.
- return;
- } // Need to schedule a new task.
- // TODO: Instead of scheduling a new task, we should be able to change the
- // priority of the existing one.
+ workInProgressRoot = root;
+ workInProgress = createWorkInProgress(root.current, null);
+ workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
+ workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootFatalError = null;
+ workInProgressRootLatestSuspenseTimeout = NoTimestamp;
+ workInProgressRootCanSuspendUsingConfig = null;
+ workInProgressRootSkippedLanes = NoLanes;
+ workInProgressRootUpdatedLanes = NoLanes;
+ workInProgressRootPingedLanes = NoLanes;
- cancelCallback(existingCallbackNode);
+ {
+ spawnedWorkDuringRender = null;
}
- root.callbackExpirationTime = expirationTime;
- root.callbackPriority = priorityLevel;
- var callbackNode;
-
- if (expirationTime === Sync) {
- // Sync React callbacks are scheduled on a special internal queue
- callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
- } else {
- callbackNode = scheduleCallback(
- priorityLevel,
- performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects
- // ordering because tasks are processed in timeout order.
- {
- timeout: expirationTimeToMs(expirationTime) - now()
- }
- );
+ {
+ ReactStrictModeWarnings.discardPendingWarnings();
}
+}
- root.callbackNode = callbackNode;
-} // This is the entry point for every concurrent task, i.e. anything that
-// goes through Scheduler.
+function handleError(root, thrownValue) {
+ do {
+ var erroredWork = workInProgress;
-function performConcurrentWorkOnRoot(root, didTimeout) {
- // Since we know we're in a React event, we can clear the current
- // event time. The next update will compute a new event time.
- currentEventTime = NoWork; // Check if the render expired.
+ try {
+ // Reset module-level state that was set during the render phase.
+ resetContextDependencies();
+ resetHooksAfterThrow();
+ resetCurrentFiber(); // TODO: I found and added this missing line while investigating a
+ // separate issue. Write a regression test using string refs.
- if (didTimeout) {
- // The render task took too long to complete. Mark the current time as
- // expired to synchronously render all expired work in a single batch.
- var currentTime = requestCurrentTimeForUpdate();
- markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback.
+ ReactCurrentOwner$2.current = null;
- ensureRootIsScheduled(root);
- return null;
- } // Determine the next expiration time to work on, using the fields stored
- // on the root.
+ if (erroredWork === null || erroredWork.return === null) {
+ // Expected to be working on a non-root fiber. This is a fatal error
+ // because there's no ancestor that can handle it; the root is
+ // supposed to capture all errors that weren't caught by an error
+ // boundary.
+ workInProgressRootExitStatus = RootFatalErrored;
+ workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next
+ // sibling, or the parent if there are no siblings. But since the root
+ // has no siblings nor a parent, we set it to null. Usually this is
+ // handled by `completeUnitOfWork` or `unwindWork`, but since we're
+ // intentionally not calling those, we need set it here.
+ // TODO: Consider calling `unwindWork` to pop the contexts.
- var expirationTime = getNextRootExpirationTimeToWorkOn(root);
+ workInProgress = null;
+ return;
+ }
- if (expirationTime === NoWork) {
- return null;
- }
+ if (enableProfilerTimer && erroredWork.mode & ProfileMode) {
+ // Record the time spent rendering before an error was thrown. This
+ // avoids inaccurate Profiler durations in the case of a
+ // suspended render.
+ stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
+ }
- var originalCallbackNode = root.callbackNode;
+ throwException(
+ root,
+ erroredWork.return,
+ erroredWork,
+ thrownValue,
+ workInProgressRootRenderLanes
+ );
+ completeUnitOfWork(erroredWork);
+ } catch (yetAnotherThrownValue) {
+ // Something in the return path also threw.
+ thrownValue = yetAnotherThrownValue;
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
- }
+ if (workInProgress === erroredWork && erroredWork !== null) {
+ // If this boundary has already errored, then we had trouble processing
+ // the error. Bubble it to the next boundary.
+ erroredWork = erroredWork.return;
+ workInProgress = erroredWork;
+ } else {
+ erroredWork = workInProgress;
+ }
- flushPassiveEffects();
- var exitStatus = renderRootConcurrent(root, expirationTime);
+ continue;
+ } // Return to the normal work loop.
- if (exitStatus !== RootIncomplete) {
- if (exitStatus === RootErrored) {
- // If something threw an error, try rendering one more time. We'll
- // render synchronously to block concurrent data mutations, and we'll
- // render at Idle (or lower) so that all pending updates are included.
- // If it still fails after the second attempt, we'll give up and commit
- // the resulting tree.
- expirationTime = expirationTime > Idle ? Idle : expirationTime;
- exitStatus = renderRootSync(root, expirationTime);
- }
+ return;
+ } while (true);
+}
- if (exitStatus === RootFatalErrored) {
- var fatalError = workInProgressRootFatalError;
- prepareFreshStack(root, expirationTime);
- markRootSuspendedAtTime(root, expirationTime);
- ensureRootIsScheduled(root);
- throw fatalError;
- } // We now have a consistent tree. The next step is either to commit it,
- // or, if something suspended, wait to commit it after a timeout.
+function pushDispatcher(root) {
+ var prevDispatcher = ReactCurrentDispatcher$2.current;
+ ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
- var finishedWork = (root.finishedWork = root.current.alternate);
- root.finishedExpirationTime = expirationTime;
- finishConcurrentRender(root, finishedWork, exitStatus, expirationTime);
+ if (prevDispatcher === null) {
+ // The React isomorphic package does not include a default dispatcher.
+ // Instead the first renderer will lazily attach one, in order to give
+ // nicer error messages.
+ return ContextOnlyDispatcher;
+ } else {
+ return prevDispatcher;
}
+}
- ensureRootIsScheduled(root);
+function popDispatcher(prevDispatcher) {
+ ReactCurrentDispatcher$2.current = prevDispatcher;
+}
- if (root.callbackNode === originalCallbackNode) {
- // The task node scheduled for this root is the same one that's
- // currently executed. Need to return a continuation.
- return performConcurrentWorkOnRoot.bind(null, root);
+function pushInteractions(root) {
+ {
+ var prevInteractions = tracing.__interactionsRef.current;
+ tracing.__interactionsRef.current = root.memoizedInteractions;
+ return prevInteractions;
}
-
- return null;
}
-function finishConcurrentRender(
- root,
- finishedWork,
- exitStatus,
- expirationTime
-) {
- switch (exitStatus) {
- case RootIncomplete:
- case RootFatalErrored: {
- {
- throw Error("Root did not complete. This is a bug in React.");
- }
- }
- // Flow knows about invariant, so it complains if I add a break
- // statement, but eslint doesn't know about invariant, so it complains
- // if I do. eslint-disable-next-line no-fallthrough
+function popInteractions(prevInteractions) {
+ {
+ tracing.__interactionsRef.current = prevInteractions;
+ }
+}
- case RootErrored: {
- // We should have already attempted to retry this tree. If we reached
- // this point, it errored again. Commit it.
- commitRoot(root);
- break;
+function markCommitTimeOfFallback() {
+ globalMostRecentFallbackTime = now();
+}
+function markRenderEventTimeAndConfig(eventTime, suspenseConfig) {
+ // Track the largest/latest timeout deadline in this batch.
+ // TODO: If there are two transitions in the same batch, shouldn't we
+ // choose the smaller one? Maybe this is because when an intermediate
+ // transition is superseded, we should ignore its suspense config, but
+ // we don't currently.
+ if (suspenseConfig !== null) {
+ // If `timeoutMs` is not specified, we default to 5 seconds. We have to
+ // resolve this default here because `suspenseConfig` is owned
+ // by userspace.
+ // TODO: Store this on the root instead (transition -> timeoutMs)
+ // TODO: Should this default to a JND instead?
+ var timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS;
+ var timeoutTime = eventTime + timeoutMs;
+
+ if (timeoutTime > workInProgressRootLatestSuspenseTimeout) {
+ workInProgressRootLatestSuspenseTimeout = timeoutTime;
+ workInProgressRootCanSuspendUsingConfig = suspenseConfig;
}
+ }
+}
+function markSkippedUpdateLanes(lane) {
+ workInProgressRootSkippedLanes = mergeLanes(
+ lane,
+ workInProgressRootSkippedLanes
+ );
+}
+function renderDidSuspend() {
+ if (workInProgressRootExitStatus === RootIncomplete) {
+ workInProgressRootExitStatus = RootSuspended;
+ }
+}
+function renderDidSuspendDelayIfPossible() {
+ if (
+ workInProgressRootExitStatus === RootIncomplete ||
+ workInProgressRootExitStatus === RootSuspended
+ ) {
+ workInProgressRootExitStatus = RootSuspendedWithDelay;
+ } // Check if there are updates that we skipped tree that might have unblocked
+ // this render.
- case RootSuspended: {
- markRootSuspendedAtTime(root, expirationTime);
- var lastSuspendedTime = root.lastSuspendedTime;
-
- if (expirationTime === lastSuspendedTime) {
- root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
- } // We have an acceptable loading state. We need to figure out if we
- // should immediately commit it or wait a bit.
- // If we have processed new updates during this render, we may now
- // have a new loading state ready. We want to ensure that we commit
- // that as soon as possible.
-
- var hasNotProcessedNewUpdates =
- workInProgressRootLatestProcessedExpirationTime === Sync;
-
- if (
- hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
- !IsThisRendererActing.current
- ) {
- // If we have not processed any new updates during this pass, then
- // this is either a retry of an existing fallback state or a
- // hidden tree. Hidden trees shouldn't be batched with other work
- // and after that's fixed it can only be a retry. We're going to
- // throttle committing retries so that we don't show too many
- // loading states too quickly.
- var msUntilTimeout =
- globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
-
- if (msUntilTimeout > 10) {
- if (workInProgressRootHasPendingPing) {
- var lastPingedTime = root.lastPingedTime;
-
- if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
- // This render was pinged but we didn't get to restart
- // earlier so try restarting now instead.
- root.lastPingedTime = expirationTime;
- prepareFreshStack(root, expirationTime);
- break;
- }
- }
+ if (
+ workInProgressRoot !== null &&
+ (includesNonIdleWork(workInProgressRootSkippedLanes) ||
+ includesNonIdleWork(workInProgressRootUpdatedLanes))
+ ) {
+ // Mark the current render as suspended so that we switch to working on
+ // the updates that were skipped. Usually we only suspend at the end of
+ // the render phase.
+ // TODO: We should probably always mark the root as suspended immediately
+ // (inside this function), since by suspending at the end of the render
+ // phase introduces a potential mistake where we suspend lanes that were
+ // pinged or updated while we were rendering.
+ markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
+ }
+}
+function renderDidError() {
+ if (workInProgressRootExitStatus !== RootCompleted) {
+ workInProgressRootExitStatus = RootErrored;
+ }
+} // Called during render to determine if anything has suspended.
+// Returns false if we're not sure.
- var nextTime = getNextRootExpirationTimeToWorkOn(root);
+function renderHasNotSuspendedYet() {
+ // If something errored or completed, we can't really be sure,
+ // so those are false.
+ return workInProgressRootExitStatus === RootIncomplete;
+}
- if (nextTime !== NoWork && nextTime !== expirationTime) {
- // There's additional work on this root.
- break;
- }
+function renderRootSync(root, lanes) {
+ var prevExecutionContext = executionContext;
+ executionContext |= RenderContext;
+ var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack
+ // and prepare a fresh one. Otherwise we'll continue where we left off.
- if (
- lastSuspendedTime !== NoWork &&
- lastSuspendedTime !== expirationTime
- ) {
- // We should prefer to render the fallback of at the last
- // suspended level. Ping the last suspended level to try
- // rendering it again.
- root.lastPingedTime = lastSuspendedTime;
- break;
- } // The render is suspended, it hasn't timed out, and there's no
- // lower priority work to do. Instead of committing the fallback
- // immediately, wait for more data to arrive.
+ if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
+ prepareFreshStack(root, lanes);
+ startWorkOnPendingInteractions(root, lanes);
+ }
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- msUntilTimeout
- );
- break;
- }
- } // The work expired. Commit immediately.
+ var prevInteractions = pushInteractions(root);
- commitRoot(root);
+ do {
+ try {
+ workLoopSync();
break;
+ } catch (thrownValue) {
+ handleError(root, thrownValue);
}
+ } while (true);
- case RootSuspendedWithDelay: {
- markRootSuspendedAtTime(root, expirationTime);
- var _lastSuspendedTime = root.lastSuspendedTime;
-
- if (expirationTime === _lastSuspendedTime) {
- root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
- }
+ resetContextDependencies();
- {
- // We're suspended in a state that should be avoided. We'll try to
- // avoid committing it for as long as the timeouts let us.
- if (workInProgressRootHasPendingPing) {
- var _lastPingedTime = root.lastPingedTime;
-
- if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
- // This render was pinged but we didn't get to restart earlier
- // so try restarting now instead.
- root.lastPingedTime = expirationTime;
- prepareFreshStack(root, expirationTime);
- break;
- }
- }
+ {
+ popInteractions(prevInteractions);
+ }
- var _nextTime = getNextRootExpirationTimeToWorkOn(root);
+ executionContext = prevExecutionContext;
+ popDispatcher(prevDispatcher);
- if (_nextTime !== NoWork && _nextTime !== expirationTime) {
- // There's additional work on this root.
- break;
- }
+ if (workInProgress !== null) {
+ // This is a sync render, so we should have finished the whole tree.
+ {
+ throw Error(
+ "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
+ }
- if (
- _lastSuspendedTime !== NoWork &&
- _lastSuspendedTime !== expirationTime
- ) {
- // We should prefer to render the fallback of at the last
- // suspended level. Ping the last suspended level to try
- // rendering it again.
- root.lastPingedTime = _lastSuspendedTime;
- break;
- }
+ workInProgressRoot = null;
+ workInProgressRootRenderLanes = NoLanes;
+ return workInProgressRootExitStatus;
+} // The work loop is an extremely hot path. Tell Closure not to inline it.
- var _msUntilTimeout;
+/** @noinline */
- if (workInProgressRootLatestSuspenseTimeout !== Sync) {
- // We have processed a suspense config whose expiration time we
- // can use as the timeout.
- _msUntilTimeout =
- expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
- } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
- // This should never normally happen because only new updates
- // cause delayed states, so we should have processed something.
- // However, this could also happen in an offscreen tree.
- _msUntilTimeout = 0;
- } else {
- // If we don't have a suspense config, we're going to use a
- // heuristic to determine how long we can suspend.
- var eventTimeMs = inferTimeFromExpirationTime(
- workInProgressRootLatestProcessedExpirationTime
- );
- var currentTimeMs = now();
- var timeUntilExpirationMs =
- expirationTimeToMs(expirationTime) - currentTimeMs;
- var timeElapsed = currentTimeMs - eventTimeMs;
-
- if (timeElapsed < 0) {
- // We get this wrong some time since we estimate the time.
- timeElapsed = 0;
- }
+function workLoopSync() {
+ // Already timed out, so perform work without checking if we need to yield.
+ while (workInProgress !== null) {
+ performUnitOfWork(workInProgress);
+ }
+}
- _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the
- // event time is exact instead of inferred from expiration time
- // we don't need this.
+function renderRootConcurrent(root, lanes) {
+ var prevExecutionContext = executionContext;
+ executionContext |= RenderContext;
+ var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack
+ // and prepare a fresh one. Otherwise we'll continue where we left off.
- if (timeUntilExpirationMs < _msUntilTimeout) {
- _msUntilTimeout = timeUntilExpirationMs;
- }
- } // Don't bother with a very short suspense time.
+ if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
+ prepareFreshStack(root, lanes);
+ startWorkOnPendingInteractions(root, lanes);
+ }
- if (_msUntilTimeout > 10) {
- // The render is suspended, it hasn't timed out, and there's no
- // lower priority work to do. Instead of committing the fallback
- // immediately, wait for more data to arrive.
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- _msUntilTimeout
- );
- break;
- }
- } // The work expired. Commit immediately.
+ var prevInteractions = pushInteractions(root);
- commitRoot(root);
+ do {
+ try {
+ workLoopConcurrent();
break;
+ } catch (thrownValue) {
+ handleError(root, thrownValue);
}
+ } while (true);
- case RootCompleted: {
- // The work completed. Ready to commit.
- if (
- // do not delay if we're inside an act() scope
- workInProgressRootLatestProcessedExpirationTime !== Sync &&
- workInProgressRootCanSuspendUsingConfig !== null
- ) {
- // If we have exceeded the minimum loading delay, which probably
- // means we have shown a spinner already, we might have to suspend
- // a bit longer to ensure that the spinner is shown for
- // enough time.
- var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(
- workInProgressRootLatestProcessedExpirationTime,
- expirationTime,
- workInProgressRootCanSuspendUsingConfig
- );
+ resetContextDependencies();
- if (_msUntilTimeout2 > 10) {
- markRootSuspendedAtTime(root, expirationTime);
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- _msUntilTimeout2
- );
- break;
- }
- }
+ {
+ popInteractions(prevInteractions);
+ }
- commitRoot(root);
- break;
- }
+ popDispatcher(prevDispatcher);
+ executionContext = prevExecutionContext;
- default: {
- {
- throw Error("Unknown root exit status.");
- }
- }
+ if (workInProgress !== null) {
+ return RootIncomplete;
+ } else {
+ workInProgressRoot = null;
+ workInProgressRootRenderLanes = NoLanes; // Return the final exit status.
+
+ return workInProgressRootExitStatus;
}
-} // This is the entry point for synchronous tasks that don't go
-// through Scheduler
+}
+/** @noinline */
-function performSyncWorkOnRoot(root) {
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+function workLoopConcurrent() {
+ // Perform work until Scheduler asks us to yield
+ while (workInProgress !== null && !shouldYield()) {
+ performUnitOfWork(workInProgress);
}
+}
- flushPassiveEffects();
- var lastExpiredTime = root.lastExpiredTime;
- var expirationTime;
+function performUnitOfWork(unitOfWork) {
+ // The current, flushed, state of this fiber is the alternate. Ideally
+ // nothing should rely on this, but relying on it here means that we don't
+ // need an additional field on the work in progress.
+ var current = unitOfWork.alternate;
+ setCurrentFiber(unitOfWork);
+ var next;
- if (lastExpiredTime !== NoWork) {
- // There's expired work on this root. Check if we have a partial tree
- // that we can reuse.
- if (
- root === workInProgressRoot &&
- renderExpirationTime$1 >= lastExpiredTime
- ) {
- // There's a partial tree with equal or greater than priority than the
- // expired level. Finish rendering it before rendering the rest of the
- // expired work.
- expirationTime = renderExpirationTime$1;
- } else {
- // Start a fresh tree.
- expirationTime = lastExpiredTime;
- }
+ if ((unitOfWork.mode & ProfileMode) !== NoMode) {
+ startProfilerTimer(unitOfWork);
+ next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
+ stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
} else {
- // There's no expired work. This must be a new, synchronous render.
- expirationTime = Sync;
+ next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
}
- var exitStatus = renderRootSync(root, expirationTime);
+ resetCurrentFiber();
+ unitOfWork.memoizedProps = unitOfWork.pendingProps;
- if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
- // If something threw an error, try rendering one more time. We'll
- // render synchronously to block concurrent data mutations, and we'll
- // render at Idle (or lower) so that all pending updates are included.
- // If it still fails after the second attempt, we'll give up and commit
- // the resulting tree.
- expirationTime = expirationTime > Idle ? Idle : expirationTime;
- exitStatus = renderRootSync(root, expirationTime);
+ if (next === null) {
+ // If this doesn't spawn new work, complete the current work.
+ completeUnitOfWork(unitOfWork);
+ } else {
+ workInProgress = next;
}
- if (exitStatus === RootFatalErrored) {
- var fatalError = workInProgressRootFatalError;
- prepareFreshStack(root, expirationTime);
- markRootSuspendedAtTime(root, expirationTime);
- ensureRootIsScheduled(root);
- throw fatalError;
- } // We now have a consistent tree. Because this is a sync render, we
- // will commit it even if something suspended.
+ ReactCurrentOwner$2.current = null;
+}
- root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = expirationTime;
- commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next
- // pending level.
+function completeUnitOfWork(unitOfWork) {
+ // Attempt to complete the current unit of work, then move to the next
+ // sibling. If there are no more siblings, return to the parent fiber.
+ var completedWork = unitOfWork;
- ensureRootIsScheduled(root);
- return null;
-}
-function syncUpdates(fn, a, b, c) {
- return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c));
-}
+ do {
+ // The current, flushed, state of this fiber is the alternate. Ideally
+ // nothing should rely on this, but relying on it here means that we don't
+ // need an additional field on the work in progress.
+ var current = completedWork.alternate;
+ var returnFiber = completedWork.return; // Check if the work completed or if something threw.
-function batchedUpdates$1(fn, a) {
- var prevExecutionContext = executionContext;
- executionContext |= BatchedContext;
+ if ((completedWork.effectTag & Incomplete) === NoEffect) {
+ setCurrentFiber(completedWork);
+ var next = void 0;
- try {
- return fn(a);
- } finally {
- executionContext = prevExecutionContext;
+ if ((completedWork.mode & ProfileMode) === NoMode) {
+ next = completeWork(current, completedWork, subtreeRenderLanes);
+ } else {
+ startProfilerTimer(completedWork);
+ next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error.
- if (executionContext === NoContext) {
- // Flush the immediate callbacks that were scheduled during this batch
- flushSyncCallbackQueue();
- }
- }
-}
-function flushSync(fn, a) {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
- {
- throw Error(
- "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering."
- );
- }
- }
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
+ }
- var prevExecutionContext = executionContext;
- executionContext |= BatchedContext;
+ resetCurrentFiber();
- try {
- return runWithPriority(ImmediatePriority, fn.bind(null, a));
- } finally {
- executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
- // Note that this will happen even if batchedUpdates is higher up
- // the stack.
+ if (next !== null) {
+ // Completing this fiber spawned new work. Work on that next.
+ workInProgress = next;
+ return;
+ }
- flushSyncCallbackQueue();
- }
-}
+ resetChildLanes(completedWork);
-function prepareFreshStack(root, expirationTime) {
- root.finishedWork = null;
- root.finishedExpirationTime = NoWork;
- var timeoutHandle = root.timeoutHandle;
+ if (
+ returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
+ (returnFiber.effectTag & Incomplete) === NoEffect
+ ) {
+ // Append all the effects of the subtree and this fiber onto the effect
+ // list of the parent. The completion order of the children affects the
+ // side-effect order.
+ if (returnFiber.firstEffect === null) {
+ returnFiber.firstEffect = completedWork.firstEffect;
+ }
- if (timeoutHandle !== noTimeout) {
- // The root previous suspended and scheduled a timeout to commit a fallback
- // state. Now that we have additional work, cancel the timeout.
- root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
+ if (completedWork.lastEffect !== null) {
+ if (returnFiber.lastEffect !== null) {
+ returnFiber.lastEffect.nextEffect = completedWork.firstEffect;
+ }
- cancelTimeout(timeoutHandle);
- }
+ returnFiber.lastEffect = completedWork.lastEffect;
+ } // If this fiber had side-effects, we append it AFTER the children's
+ // side-effects. We can perform certain side-effects earlier if needed,
+ // by doing multiple passes over the effect list. We don't want to
+ // schedule our own side-effect on our own list because if end up
+ // reusing children we'll schedule this effect onto itself since we're
+ // at the end.
- if (workInProgress !== null) {
- var interruptedWork = workInProgress.return;
+ var effectTag = completedWork.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
+ // list. PerformedWork effect is read by React DevTools but shouldn't be
+ // committed.
- while (interruptedWork !== null) {
- unwindInterruptedWork(interruptedWork);
- interruptedWork = interruptedWork.return;
+ if (effectTag > PerformedWork) {
+ if (returnFiber.lastEffect !== null) {
+ returnFiber.lastEffect.nextEffect = completedWork;
+ } else {
+ returnFiber.firstEffect = completedWork;
+ }
+
+ returnFiber.lastEffect = completedWork;
+ }
+ }
+ } else {
+ // This fiber did not complete because something threw. Pop values off
+ // the stack without entering the complete phase. If this is a boundary,
+ // capture values if possible.
+ var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time.
+
+ if (_next !== null) {
+ // If completing this work spawned new work, do that next. We'll come
+ // back here again.
+ // Since we're restarting, remove anything that is not a host effect
+ // from the effect tag.
+ _next.effectTag &= HostEffectMask;
+ workInProgress = _next;
+ return;
+ }
+
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // Record the render duration for the fiber that errored.
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing.
+
+ var actualDuration = completedWork.actualDuration;
+ var child = completedWork.child;
+
+ while (child !== null) {
+ actualDuration += child.actualDuration;
+ child = child.sibling;
+ }
+
+ completedWork.actualDuration = actualDuration;
+ }
+
+ if (returnFiber !== null) {
+ // Mark the parent fiber as incomplete and clear its effect list.
+ returnFiber.firstEffect = returnFiber.lastEffect = null;
+ returnFiber.effectTag |= Incomplete;
+ }
}
- }
- workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
- renderExpirationTime$1 = expirationTime;
- workInProgressRootExitStatus = RootIncomplete;
- workInProgressRootFatalError = null;
- workInProgressRootLatestProcessedExpirationTime = Sync;
- workInProgressRootLatestSuspenseTimeout = Sync;
- workInProgressRootCanSuspendUsingConfig = null;
- workInProgressRootNextUnprocessedUpdateTime = NoWork;
- workInProgressRootHasPendingPing = false;
+ var siblingFiber = completedWork.sibling;
- {
- spawnedWorkDuringRender = null;
- }
+ if (siblingFiber !== null) {
+ // If there is more work to do in this returnFiber, do that next.
+ workInProgress = siblingFiber;
+ return;
+ } // Otherwise, return to the parent
- {
- ReactStrictModeWarnings.discardPendingWarnings();
+ completedWork = returnFiber; // Update the next thing we're working on in case something throws.
+
+ workInProgress = completedWork;
+ } while (completedWork !== null); // We've reached the root.
+
+ if (workInProgressRootExitStatus === RootIncomplete) {
+ workInProgressRootExitStatus = RootCompleted;
}
}
-function handleError(root, thrownValue) {
- do {
- try {
- // Reset module-level state that was set during the render phase.
- resetContextDependencies();
- resetHooksAfterThrow();
- resetCurrentFiber();
+function resetChildLanes(completedWork) {
+ if (
+ // TODO: Move this check out of the hot path by moving `resetChildLanes`
+ // to switch statement in `completeWork`.
+ (completedWork.tag === LegacyHiddenComponent ||
+ completedWork.tag === OffscreenComponent) &&
+ completedWork.memoizedState !== null &&
+ !includesSomeLane(subtreeRenderLanes, OffscreenLane) &&
+ (completedWork.mode & ConcurrentMode) !== NoLanes
+ ) {
+ // The children of this component are hidden. Don't bubble their
+ // expiration times.
+ return;
+ }
- if (workInProgress === null || workInProgress.return === null) {
- // Expected to be working on a non-root fiber. This is a fatal error
- // because there's no ancestor that can handle it; the root is
- // supposed to capture all errors that weren't caught by an error
- // boundary.
- workInProgressRootExitStatus = RootFatalErrored;
- workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next
- // sibling, or the parent if there are no siblings. But since the root
- // has no siblings nor a parent, we set it to null. Usually this is
- // handled by `completeUnitOfWork` or `unwindWork`, but since we're
- // interntionally not calling those, we need set it here.
- // TODO: Consider calling `unwindWork` to pop the contexts.
+ var newChildLanes = NoLanes; // Bubble up the earliest expiration time.
- workInProgress = null;
- return null;
- }
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // In profiling mode, resetChildExpirationTime is also used to reset
+ // profiler durations.
+ var actualDuration = completedWork.actualDuration;
+ var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
+ // only be updated if work is done on the fiber (i.e. it doesn't bailout).
+ // When work is done, it should bubble to the parent's actualDuration. If
+ // the fiber has not been cloned though, (meaning no work was done), then
+ // this value will reflect the amount of time spent working on a previous
+ // render. In that case it should not bubble. We determine whether it was
+ // cloned by comparing the child pointer.
- if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
- // Record the time spent rendering before an error was thrown. This
- // avoids inaccurate Profiler durations in the case of a
- // suspended render.
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
- }
+ var shouldBubbleActualDurations =
+ completedWork.alternate === null ||
+ completedWork.child !== completedWork.alternate.child;
+ var child = completedWork.child;
- throwException(
- root,
- workInProgress.return,
- workInProgress,
- thrownValue,
- renderExpirationTime$1
+ while (child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(child.lanes, child.childLanes)
);
- workInProgress = completeUnitOfWork(workInProgress);
- } catch (yetAnotherThrownValue) {
- // Something in the return path also threw.
- thrownValue = yetAnotherThrownValue;
- continue;
- } // Return to the normal work loop.
- return;
- } while (true);
-}
+ if (shouldBubbleActualDurations) {
+ actualDuration += child.actualDuration;
+ }
-function pushDispatcher(root) {
- var prevDispatcher = ReactCurrentDispatcher$1.current;
- ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ treeBaseDuration += child.treeBaseDuration;
+ child = child.sibling;
+ }
+
+ var isTimedOutSuspense =
+ completedWork.tag === SuspenseComponent &&
+ completedWork.memoizedState !== null;
+
+ if (isTimedOutSuspense) {
+ // Don't count time spent in a timed out Suspense subtree as part of the base duration.
+ var primaryChildFragment = completedWork.child;
+
+ if (primaryChildFragment !== null) {
+ treeBaseDuration -= primaryChildFragment.treeBaseDuration;
+ }
+ }
- if (prevDispatcher === null) {
- // The React isomorphic package does not include a default dispatcher.
- // Instead the first renderer will lazily attach one, in order to give
- // nicer error messages.
- return ContextOnlyDispatcher;
+ completedWork.actualDuration = actualDuration;
+ completedWork.treeBaseDuration = treeBaseDuration;
} else {
- return prevDispatcher;
+ var _child = completedWork.child;
+
+ while (_child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child.lanes, _child.childLanes)
+ );
+ _child = _child.sibling;
+ }
}
-}
-function popDispatcher(prevDispatcher) {
- ReactCurrentDispatcher$1.current = prevDispatcher;
+ completedWork.childLanes = newChildLanes;
}
-function pushInteractions(root) {
- {
- var prevInteractions = tracing.__interactionsRef.current;
- tracing.__interactionsRef.current = root.memoizedInteractions;
- return prevInteractions;
- }
+function commitRoot(root) {
+ var renderPriorityLevel = getCurrentPriorityLevel();
+ runWithPriority(
+ ImmediatePriority$1,
+ commitRootImpl.bind(null, root, renderPriorityLevel)
+ );
+ return null;
}
-function popInteractions(prevInteractions) {
- {
- tracing.__interactionsRef.current = prevInteractions;
- }
-}
+function commitRootImpl(root, renderPriorityLevel) {
+ do {
+ // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
+ // means `flushPassiveEffects` will sometimes result in additional
+ // passive effects. So we need to keep flushing in a loop until there are
+ // no more pending effects.
+ // TODO: Might be better if `flushPassiveEffects` did not automatically
+ // flush synchronous work at the end, to avoid factoring hazards like this.
+ flushPassiveEffects();
+ } while (rootWithPendingPassiveEffects !== null);
-function markCommitTimeOfFallback() {
- globalMostRecentFallbackTime = now();
-}
-function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
- if (
- expirationTime < workInProgressRootLatestProcessedExpirationTime &&
- expirationTime > Idle
- ) {
- workInProgressRootLatestProcessedExpirationTime = expirationTime;
+ flushRenderPhaseStrictModeWarningsInDEV();
+
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Should not already be working.");
}
- if (suspenseConfig !== null) {
- if (
- expirationTime < workInProgressRootLatestSuspenseTimeout &&
- expirationTime > Idle
- ) {
- workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad.
+ var finishedWork = root.finishedWork;
+ var lanes = root.finishedLanes;
- workInProgressRootCanSuspendUsingConfig = suspenseConfig;
- }
- }
-}
-function markUnprocessedUpdateTime(expirationTime) {
- if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
- workInProgressRootNextUnprocessedUpdateTime = expirationTime;
- }
-}
-function renderDidSuspend() {
- if (workInProgressRootExitStatus === RootIncomplete) {
- workInProgressRootExitStatus = RootSuspended;
+ if (finishedWork === null) {
+ return null;
}
-}
-function renderDidSuspendDelayIfPossible() {
- if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
- ) {
- workInProgressRootExitStatus = RootSuspendedWithDelay;
- } // Check if there's a lower priority update somewhere else in the tree.
- if (
- workInProgressRootNextUnprocessedUpdateTime !== NoWork &&
- workInProgressRoot !== null
- ) {
- // Mark the current render as suspended, and then mark that there's a
- // pending update.
- // TODO: This should immediately interrupt the current render, instead
- // of waiting until the next time we yield.
- markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1);
- markRootUpdatedAtTime(
- workInProgressRoot,
- workInProgressRootNextUnprocessedUpdateTime
+ root.finishedWork = null;
+ root.finishedLanes = NoLanes;
+
+ if (!(finishedWork !== root.current)) {
+ throw Error(
+ "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
);
- }
-}
-function renderDidError() {
- if (workInProgressRootExitStatus !== RootCompleted) {
- workInProgressRootExitStatus = RootErrored;
- }
-} // Called during render to determine if anything has suspended.
-// Returns false if we're not sure.
+ } // commitRoot never returns a continuation; it always finishes synchronously.
+ // So we can clear these now to allow a new callback to be scheduled.
-function renderHasNotSuspendedYet() {
- // If something errored or completed, we can't really be sure,
- // so those are false.
- return workInProgressRootExitStatus === RootIncomplete;
-}
+ root.callbackNode = null; // Update the first and last pending times on this root. The new first
+ // pending time is whatever is left on the root fiber.
-function inferTimeFromExpirationTime(expirationTime) {
- // We don't know exactly when the update was scheduled, but we can infer an
- // approximate start time from the expiration time.
- var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
- return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
-}
+ var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes);
+ markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of
+ // `flushDiscreteUpdates` starts a useless render pass which may cancels
+ // a scheduled timeout.
-function inferTimeFromExpirationTimeWithSuspenseConfig(
- expirationTime,
- suspenseConfig
-) {
- // We don't know exactly when the update was scheduled, but we can infer an
- // approximate start time from the expiration time by subtracting the timeout
- // that was added to the event time.
- var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
- return (
- earliestExpirationTimeMs -
- (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION)
- );
-}
+ if (rootsWithPendingDiscreteUpdates !== null) {
+ if (
+ !hasDiscreteLanes(remainingLanes) &&
+ rootsWithPendingDiscreteUpdates.has(root)
+ ) {
+ rootsWithPendingDiscreteUpdates.delete(root);
+ }
+ }
-function renderRootSync(root, expirationTime) {
- var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
- var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack
- // and prepare a fresh one. Otherwise we'll continue where we left off.
+ if (root === workInProgressRoot) {
+ // We can reset these now that they are finished.
+ workInProgressRoot = null;
+ workInProgress = null;
+ workInProgressRootRenderLanes = NoLanes;
+ } // This indicates that the last root we worked on is not the same one that
+ // we're committing now. This most commonly happens when a suspended root
+ // times out.
+ // Get the list of effects.
- if (
- root !== workInProgressRoot ||
- expirationTime !== renderExpirationTime$1
- ) {
- prepareFreshStack(root, expirationTime);
- startWorkOnPendingInteractions(root, expirationTime);
+ var firstEffect;
+
+ if (finishedWork.effectTag > PerformedWork) {
+ // A fiber's effect list consists only of its children, not itself. So if
+ // the root has an effect, we need to add it to the end of the list. The
+ // resulting list is the set that would belong to the root's parent, if it
+ // had one; that is, all the effects in the tree including the root.
+ if (finishedWork.lastEffect !== null) {
+ finishedWork.lastEffect.nextEffect = finishedWork;
+ firstEffect = finishedWork.firstEffect;
+ } else {
+ firstEffect = finishedWork;
+ }
+ } else {
+ // There is no effect on the root.
+ firstEffect = finishedWork.firstEffect;
}
- var prevInteractions = pushInteractions(root);
- startWorkLoopTimer(workInProgress);
+ if (firstEffect !== null) {
+ var prevExecutionContext = executionContext;
+ executionContext |= CommitContext;
+ var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
- do {
- try {
- workLoopSync();
- break;
- } catch (thrownValue) {
- handleError(root, thrownValue);
- }
- } while (true);
+ ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
+ // of the effect list for each phase: all mutation effects come before all
+ // layout effects, and so on.
+ // The first phase a "before mutation" phase. We use this phase to read the
+ // state of the host tree right before we mutate it. This is where
+ // getSnapshotBeforeUpdate is called.
- resetContextDependencies();
+ focusedInstanceHandle = prepareForCommit(root.containerInfo);
+ shouldFireAfterActiveInstanceBlur = false;
+ nextEffect = firstEffect;
- {
- popInteractions(prevInteractions);
- }
+ do {
+ {
+ invokeGuardedCallback(null, commitBeforeMutationEffects, null);
- executionContext = prevExecutionContext;
- popDispatcher(prevDispatcher);
+ if (hasCaughtError()) {
+ if (!(nextEffect !== null)) {
+ throw Error("Should be working on an effect.");
+ }
- if (workInProgress !== null) {
- // This is a sync render, so we should have finished the whole tree.
- {
- throw Error(
- "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
- );
- }
- }
+ var error = clearCaughtError();
+ captureCommitPhaseError(nextEffect, error);
+ nextEffect = nextEffect.nextEffect;
+ }
+ }
+ } while (nextEffect !== null); // We no longer need to track the active instance fiber
- stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render.
+ focusedInstanceHandle = null;
- workInProgressRoot = null;
- return workInProgressRootExitStatus;
-} // The work loop is an extremely hot path. Tell Closure not to inline it.
+ {
+ // Mark the current commit time to be shared by all Profilers in this
+ // batch. This enables them to be grouped later.
+ recordCommitTime();
+ } // The next phase is the mutation phase, where we mutate the host tree.
-/** @noinline */
+ nextEffect = firstEffect;
-function workLoopSync() {
- // Already timed out, so perform work without checking if we need to yield.
- while (workInProgress !== null) {
- workInProgress = performUnitOfWork(workInProgress);
- }
-}
+ do {
+ {
+ invokeGuardedCallback(
+ null,
+ commitMutationEffects,
+ null,
+ root,
+ renderPriorityLevel
+ );
-function renderRootConcurrent(root, expirationTime) {
- var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
- var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack
- // and prepare a fresh one. Otherwise we'll continue where we left off.
+ if (hasCaughtError()) {
+ if (!(nextEffect !== null)) {
+ throw Error("Should be working on an effect.");
+ }
- if (
- root !== workInProgressRoot ||
- expirationTime !== renderExpirationTime$1
- ) {
- prepareFreshStack(root, expirationTime);
- startWorkOnPendingInteractions(root, expirationTime);
- }
+ var _error = clearCaughtError();
- var prevInteractions = pushInteractions(root);
- startWorkLoopTimer(workInProgress);
+ captureCommitPhaseError(nextEffect, _error);
+ nextEffect = nextEffect.nextEffect;
+ }
+ }
+ } while (nextEffect !== null);
- do {
- try {
- workLoopConcurrent();
- break;
- } catch (thrownValue) {
- handleError(root, thrownValue);
- }
- } while (true);
+ resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
+ // the mutation phase, so that the previous tree is still current during
+ // componentWillUnmount, but before the layout phase, so that the finished
+ // work is current during componentDidMount/Update.
- resetContextDependencies();
+ root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
+ // the host tree after it's been mutated. The idiomatic use case for this is
+ // layout, but class component lifecycles also fire here for legacy reasons.
- {
- popInteractions(prevInteractions);
- }
+ nextEffect = firstEffect;
- popDispatcher(prevDispatcher);
- executionContext = prevExecutionContext; // Check if the tree has completed.
+ do {
+ {
+ invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes);
- if (workInProgress !== null) {
- // Still work remaining.
- stopInterruptedWorkLoopTimer();
- return RootIncomplete;
- } else {
- // Completed the tree.
- stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render.
+ if (hasCaughtError()) {
+ if (!(nextEffect !== null)) {
+ throw Error("Should be working on an effect.");
+ }
+
+ var _error2 = clearCaughtError();
- workInProgressRoot = null; // Return the final exit status.
+ captureCommitPhaseError(nextEffect, _error2);
+ nextEffect = nextEffect.nextEffect;
+ }
+ }
+ } while (nextEffect !== null);
- return workInProgressRootExitStatus;
- }
-}
-/** @noinline */
+ nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
+ // opportunity to paint.
-function workLoopConcurrent() {
- // Perform work until Scheduler asks us to yield
- while (workInProgress !== null && !shouldYield()) {
- workInProgress = performUnitOfWork(workInProgress);
- }
-}
+ requestPaint();
-function performUnitOfWork(unitOfWork) {
- // The current, flushed, state of this fiber is the alternate. Ideally
- // nothing should rely on this, but relying on it here means that we don't
- // need an additional field on the work in progress.
- var current = unitOfWork.alternate;
- startWorkTimer(unitOfWork);
- setCurrentFiber(unitOfWork);
- var next;
+ {
+ popInteractions(prevInteractions);
+ }
- if ((unitOfWork.mode & ProfileMode) !== NoMode) {
- startProfilerTimer(unitOfWork);
- next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
- stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
+ executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value.
} else {
- next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
- }
-
- resetCurrentFiber();
- unitOfWork.memoizedProps = unitOfWork.pendingProps;
+ // No effects.
+ root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
+ // no effects.
+ // TODO: Maybe there's a better way to report this.
- if (next === null) {
- // If this doesn't spawn new work, complete the current work.
- next = completeUnitOfWork(unitOfWork);
+ {
+ recordCommitTime();
+ }
}
- ReactCurrentOwner$2.current = null;
- return next;
-}
-
-function completeUnitOfWork(unitOfWork) {
- // Attempt to complete the current unit of work, then move to the next
- // sibling. If there are no more siblings, return to the parent fiber.
- workInProgress = unitOfWork;
-
- do {
- // The current, flushed, state of this fiber is the alternate. Ideally
- // nothing should rely on this, but relying on it here means that we don't
- // need an additional field on the work in progress.
- var current = workInProgress.alternate;
- var returnFiber = workInProgress.return; // Check if the work completed or if something threw.
+ var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
- if ((workInProgress.effectTag & Incomplete) === NoEffect) {
- setCurrentFiber(workInProgress);
- var next = void 0;
+ if (rootDoesHavePassiveEffects) {
+ // This commit has passive effects. Stash a reference to them. But don't
+ // schedule a callback until after flushing layout work.
+ rootDoesHavePassiveEffects = false;
+ rootWithPendingPassiveEffects = root;
+ pendingPassiveEffectsLanes = lanes;
+ pendingPassiveEffectsRenderPriority = renderPriorityLevel;
+ } else {
+ // We are done with the effect chain at this point so let's clear the
+ // nextEffect pointers to assist with GC. If we have passive effects, we'll
+ // clear this in flushPassiveEffects.
+ nextEffect = firstEffect;
- if ((workInProgress.mode & ProfileMode) === NoMode) {
- next = completeWork(current, workInProgress, renderExpirationTime$1);
- } else {
- startProfilerTimer(workInProgress);
- next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error.
+ while (nextEffect !== null) {
+ var nextNextEffect = nextEffect.nextEffect;
+ nextEffect.nextEffect = null;
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
+ if (nextEffect.effectTag & Deletion) {
+ detachFiberAfterEffects(nextEffect);
}
- stopWorkTimer(workInProgress);
- resetCurrentFiber();
- resetChildExpirationTime(workInProgress);
+ nextEffect = nextNextEffect;
+ }
+ } // Read this again, since an effect might have updated it
- if (next !== null) {
- // Completing this fiber spawned new work. Work on that next.
- return next;
- }
+ remainingLanes = root.pendingLanes; // Check if there's remaining work on this root
- if (
- returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
- (returnFiber.effectTag & Incomplete) === NoEffect
- ) {
- // Append all the effects of the subtree and this fiber onto the effect
- // list of the parent. The completion order of the children affects the
- // side-effect order.
- if (returnFiber.firstEffect === null) {
- returnFiber.firstEffect = workInProgress.firstEffect;
+ if (remainingLanes !== NoLanes) {
+ {
+ if (spawnedWorkDuringRender !== null) {
+ var expirationTimes = spawnedWorkDuringRender;
+ spawnedWorkDuringRender = null;
+
+ for (var i = 0; i < expirationTimes.length; i++) {
+ scheduleInteractions(
+ root,
+ expirationTimes[i],
+ root.memoizedInteractions
+ );
}
+ }
- if (workInProgress.lastEffect !== null) {
- if (returnFiber.lastEffect !== null) {
- returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
- }
+ schedulePendingInteractions(root, remainingLanes);
+ }
+ } else {
+ // If there's no remaining work, we can clear the set of already failed
+ // error boundaries.
+ legacyErrorBoundariesThatAlreadyFailed = null;
+ }
- returnFiber.lastEffect = workInProgress.lastEffect;
- } // If this fiber had side-effects, we append it AFTER the children's
- // side-effects. We can perform certain side-effects earlier if needed,
- // by doing multiple passes over the effect list. We don't want to
- // schedule our own side-effect on our own list because if end up
- // reusing children we'll schedule this effect onto itself since we're
- // at the end.
+ {
+ if (!rootDidHavePassiveEffects) {
+ // If there are no passive effects, then we can complete the pending interactions.
+ // Otherwise, we'll wait until after the passive effects are flushed.
+ // Wait to do this until after remaining work has been scheduled,
+ // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
+ finishPendingInteractions(root, lanes);
+ }
+ }
- var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
- // list. PerformedWork effect is read by React DevTools but shouldn't be
- // committed.
+ if (remainingLanes === SyncLane) {
+ // Count the number of times the root synchronously re-renders without
+ // finishing. If there are too many, it indicates an infinite update loop.
+ if (root === rootWithNestedUpdates) {
+ nestedUpdateCount++;
+ } else {
+ nestedUpdateCount = 0;
+ rootWithNestedUpdates = root;
+ }
+ } else {
+ nestedUpdateCount = 0;
+ }
- if (effectTag > PerformedWork) {
- if (returnFiber.lastEffect !== null) {
- returnFiber.lastEffect.nextEffect = workInProgress;
- } else {
- returnFiber.firstEffect = workInProgress;
- }
+ onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
+ // additional work on this root is scheduled.
- returnFiber.lastEffect = workInProgress;
- }
- }
- } else {
- // This fiber did not complete because something threw. Pop values off
- // the stack without entering the complete phase. If this is a boundary,
- // capture values if possible.
- var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time.
+ ensureRootIsScheduled(root, now());
- if ((workInProgress.mode & ProfileMode) !== NoMode) {
- // Record the render duration for the fiber that errored.
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing.
+ if (hasUncaughtError) {
+ hasUncaughtError = false;
+ var _error3 = firstUncaughtError;
+ firstUncaughtError = null;
+ throw _error3;
+ }
- var actualDuration = workInProgress.actualDuration;
- var child = workInProgress.child;
+ if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
+ // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
+ // synchronously, but layout updates should be deferred until the end
+ // of the batch.
- while (child !== null) {
- actualDuration += child.actualDuration;
- child = child.sibling;
- }
+ return null;
+ } // If layout work was scheduled, flush it now.
- workInProgress.actualDuration = actualDuration;
- }
+ flushSyncCallbackQueue();
- if (_next !== null) {
- // If completing this work spawned new work, do that next. We'll come
- // back here again.
- // Since we're restarting, remove anything that is not a host effect
- // from the effect tag.
- // TODO: The name stopFailedWorkTimer is misleading because Suspense
- // also captures and restarts.
- stopFailedWorkTimer(workInProgress);
- _next.effectTag &= HostEffectMask;
- return _next;
- }
+ return null;
+}
- stopWorkTimer(workInProgress);
+function commitBeforeMutationEffects() {
+ while (nextEffect !== null) {
+ var current = nextEffect.alternate;
- if (returnFiber !== null) {
- // Mark the parent fiber as incomplete and clear its effect list.
- returnFiber.firstEffect = returnFiber.lastEffect = null;
- returnFiber.effectTag |= Incomplete;
+ if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) {
+ if ((nextEffect.effectTag & Deletion) !== NoEffect) {
+ if (doesFiberContain(nextEffect, focusedInstanceHandle)) {
+ shouldFireAfterActiveInstanceBlur = true;
+ }
+ } else {
+ // TODO: Move this out of the hot path using a dedicated effect tag.
+ if (
+ nextEffect.tag === SuspenseComponent &&
+ isSuspenseBoundaryBeingHidden(current, nextEffect) &&
+ doesFiberContain(nextEffect, focusedInstanceHandle)
+ ) {
+ shouldFireAfterActiveInstanceBlur = true;
+ }
}
}
- var siblingFiber = workInProgress.sibling;
+ var effectTag = nextEffect.effectTag;
- if (siblingFiber !== null) {
- // If there is more work to do in this returnFiber, do that next.
- return siblingFiber;
- } // Otherwise, return to the parent
+ if ((effectTag & Snapshot) !== NoEffect) {
+ setCurrentFiber(nextEffect);
+ commitBeforeMutationLifeCycles(current, nextEffect);
+ resetCurrentFiber();
+ }
- workInProgress = returnFiber;
- } while (workInProgress !== null); // We've reached the root.
+ if ((effectTag & Passive) !== NoEffect) {
+ // If there are passive effects, schedule a callback to flush at
+ // the earliest opportunity.
+ if (!rootDoesHavePassiveEffects) {
+ rootDoesHavePassiveEffects = true;
+ scheduleCallback(NormalPriority$1, function() {
+ flushPassiveEffects();
+ return null;
+ });
+ }
+ }
- if (workInProgressRootExitStatus === RootIncomplete) {
- workInProgressRootExitStatus = RootCompleted;
+ nextEffect = nextEffect.nextEffect;
}
-
- return null;
}
-function getRemainingExpirationTime(fiber) {
- var updateExpirationTime = fiber.expirationTime;
- var childExpirationTime = fiber.childExpirationTime;
- return updateExpirationTime > childExpirationTime
- ? updateExpirationTime
- : childExpirationTime;
-}
+function commitMutationEffects(root, renderPriorityLevel) {
+ // TODO: Should probably move the bulk of this function to commitWork.
+ while (nextEffect !== null) {
+ setCurrentFiber(nextEffect);
+ var effectTag = nextEffect.effectTag;
-function resetChildExpirationTime(completedWork) {
- if (
- renderExpirationTime$1 !== Never &&
- completedWork.childExpirationTime === Never
- ) {
- // The children of this component are hidden. Don't bubble their
- // expiration times.
- return;
- }
+ if (effectTag & Ref) {
+ var current = nextEffect.alternate;
+
+ if (current !== null) {
+ commitDetachRef(current);
+ }
+ } // The following switch statement is only concerned about placement,
+ // updates, and deletions. To avoid needing to add a case for every possible
+ // bitmap value, we remove the secondary effects from the effect tag and
+ // switch on that value.
- var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time.
+ var primaryEffectTag =
+ effectTag & (Placement | Update | Deletion | Hydrating);
- if ((completedWork.mode & ProfileMode) !== NoMode) {
- // In profiling mode, resetChildExpirationTime is also used to reset
- // profiler durations.
- var actualDuration = completedWork.actualDuration;
- var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
- // only be updated if work is done on the fiber (i.e. it doesn't bailout).
- // When work is done, it should bubble to the parent's actualDuration. If
- // the fiber has not been cloned though, (meaning no work was done), then
- // this value will reflect the amount of time spent working on a previous
- // render. In that case it should not bubble. We determine whether it was
- // cloned by comparing the child pointer.
+ switch (primaryEffectTag) {
+ case Placement: {
+ // inserted, before any life-cycles like componentDidMount gets called.
+ // TODO: findDOMNode doesn't rely on this any more but isMounted does
+ // and isMounted is deprecated anyway so we should be able to kill this.
- var shouldBubbleActualDurations =
- completedWork.alternate === null ||
- completedWork.child !== completedWork.alternate.child;
- var child = completedWork.child;
+ nextEffect.effectTag &= ~Placement;
+ break;
+ }
- while (child !== null) {
- var childUpdateExpirationTime = child.expirationTime;
- var childChildExpirationTime = child.childExpirationTime;
+ case PlacementAndUpdate: {
+ // inserted, before any life-cycles like componentDidMount gets called.
- if (childUpdateExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = childUpdateExpirationTime;
- }
+ nextEffect.effectTag &= ~Placement; // Update
- if (childChildExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = childChildExpirationTime;
+ var _current = nextEffect.alternate;
+ commitWork(_current, nextEffect);
+ break;
}
- if (shouldBubbleActualDurations) {
- actualDuration += child.actualDuration;
+ case Hydrating: {
+ nextEffect.effectTag &= ~Hydrating;
+ break;
}
- treeBaseDuration += child.treeBaseDuration;
- child = child.sibling;
- }
-
- completedWork.actualDuration = actualDuration;
- completedWork.treeBaseDuration = treeBaseDuration;
- } else {
- var _child = completedWork.child;
-
- while (_child !== null) {
- var _childUpdateExpirationTime = _child.expirationTime;
- var _childChildExpirationTime = _child.childExpirationTime;
+ case HydratingAndUpdate: {
+ nextEffect.effectTag &= ~Hydrating; // Update
- if (_childUpdateExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = _childUpdateExpirationTime;
+ var _current2 = nextEffect.alternate;
+ commitWork(_current2, nextEffect);
+ break;
}
- if (_childChildExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = _childChildExpirationTime;
+ case Update: {
+ var _current3 = nextEffect.alternate;
+ commitWork(_current3, nextEffect);
+ break;
}
- _child = _child.sibling;
+ case Deletion: {
+ commitDeletion(root, nextEffect);
+ break;
+ }
}
- }
- completedWork.childExpirationTime = newChildExpirationTime;
+ resetCurrentFiber();
+ nextEffect = nextEffect.nextEffect;
+ }
}
-function commitRoot(root) {
- var renderPriorityLevel = getCurrentPriorityLevel();
- runWithPriority(
- ImmediatePriority,
- commitRootImpl.bind(null, root, renderPriorityLevel)
- );
- return null;
-}
+function commitLayoutEffects(root, committedLanes) {
+ while (nextEffect !== null) {
+ setCurrentFiber(nextEffect);
+ var effectTag = nextEffect.effectTag;
-function commitRootImpl(root, renderPriorityLevel) {
- do {
- // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
- // means `flushPassiveEffects` will sometimes result in additional
- // passive effects. So we need to keep flushing in a loop until there are
- // no more pending effects.
- // TODO: Might be better if `flushPassiveEffects` did not automatically
- // flush synchronous work at the end, to avoid factoring hazards like this.
- flushPassiveEffects();
- } while (rootWithPendingPassiveEffects !== null);
+ if (effectTag & (Update | Callback)) {
+ var current = nextEffect.alternate;
+ commitLifeCycles(root, current, nextEffect);
+ }
- flushRenderPhaseStrictModeWarningsInDEV();
+ {
+ if (effectTag & Ref) {
+ commitAttachRef(nextEffect);
+ }
+ }
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ resetCurrentFiber();
+ nextEffect = nextEffect.nextEffect;
}
+}
- var finishedWork = root.finishedWork;
- var expirationTime = root.finishedExpirationTime;
+function flushPassiveEffects() {
+ // Returns whether passive effects were flushed.
+ if (pendingPassiveEffectsRenderPriority !== NoPriority$1) {
+ var priorityLevel =
+ pendingPassiveEffectsRenderPriority > NormalPriority$1
+ ? NormalPriority$1
+ : pendingPassiveEffectsRenderPriority;
+ pendingPassiveEffectsRenderPriority = NoPriority$1;
- if (finishedWork === null) {
- return null;
+ try {
+ setCurrentUpdateLanePriority(
+ schedulerPriorityToLanePriority(priorityLevel)
+ );
+ return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
+ } finally {
+ }
}
- root.finishedWork = null;
- root.finishedExpirationTime = NoWork;
-
- if (!(finishedWork !== root.current)) {
- throw Error(
- "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
- );
- } // commitRoot never returns a continuation; it always finishes synchronously.
- // So we can clear these now to allow a new callback to be scheduled.
-
- root.callbackNode = null;
- root.callbackExpirationTime = NoWork;
- root.callbackPriority = NoPriority;
- root.nextKnownPendingLevel = NoWork;
- startCommitTimer(); // Update the first and last pending times on this root. The new first
- // pending time is whatever is left on the root fiber.
-
- var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(
- finishedWork
- );
- markRootFinishedAtTime(
- root,
- expirationTime,
- remainingExpirationTimeBeforeCommit
- );
+ return false;
+}
+function enqueuePendingPassiveHookEffectMount(fiber, effect) {
+ pendingPassiveHookEffectsMount.push(effect, fiber);
- if (root === workInProgressRoot) {
- // We can reset these now that they are finished.
- workInProgressRoot = null;
- workInProgress = null;
- renderExpirationTime$1 = NoWork;
- } // This indicates that the last root we worked on is not the same one that
- // we're committing now. This most commonly happens when a suspended root
- // times out.
- // Get the list of effects.
+ if (!rootDoesHavePassiveEffects) {
+ rootDoesHavePassiveEffects = true;
+ scheduleCallback(NormalPriority$1, function() {
+ flushPassiveEffects();
+ return null;
+ });
+ }
+}
+function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
+ pendingPassiveHookEffectsUnmount.push(effect, fiber);
- var firstEffect;
+ {
+ fiber.effectTag |= PassiveUnmountPendingDev;
+ var alternate = fiber.alternate;
- if (finishedWork.effectTag > PerformedWork) {
- // A fiber's effect list consists only of its children, not itself. So if
- // the root has an effect, we need to add it to the end of the list. The
- // resulting list is the set that would belong to the root's parent, if it
- // had one; that is, all the effects in the tree including the root.
- if (finishedWork.lastEffect !== null) {
- finishedWork.lastEffect.nextEffect = finishedWork;
- firstEffect = finishedWork.firstEffect;
- } else {
- firstEffect = finishedWork;
+ if (alternate !== null) {
+ alternate.effectTag |= PassiveUnmountPendingDev;
}
- } else {
- // There is no effect on the root.
- firstEffect = finishedWork.firstEffect;
}
- if (firstEffect !== null) {
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
+ if (!rootDoesHavePassiveEffects) {
+ rootDoesHavePassiveEffects = true;
+ scheduleCallback(NormalPriority$1, function() {
+ flushPassiveEffects();
+ return null;
+ });
+ }
+}
- ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
- // of the effect list for each phase: all mutation effects come before all
- // layout effects, and so on.
- // The first phase a "before mutation" phase. We use this phase to read the
- // state of the host tree right before we mutate it. This is where
- // getSnapshotBeforeUpdate is called.
+function invokePassiveEffectCreate(effect) {
+ var create = effect.create;
+ effect.destroy = create();
+}
- startCommitSnapshotEffectsTimer();
- prepareForCommit(root.containerInfo);
- nextEffect = firstEffect;
+function flushPassiveEffectsImpl() {
+ if (rootWithPendingPassiveEffects === null) {
+ return false;
+ }
- do {
- {
- invokeGuardedCallback(null, commitBeforeMutationEffects, null);
+ var root = rootWithPendingPassiveEffects;
+ var lanes = pendingPassiveEffectsLanes;
+ rootWithPendingPassiveEffects = null;
+ pendingPassiveEffectsLanes = NoLanes;
- if (hasCaughtError()) {
- if (!(nextEffect !== null)) {
- throw Error("Should be working on an effect.");
- }
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Cannot flush passive effects while already rendering.");
+ }
- var error = clearCaughtError();
- captureCommitPhaseError(nextEffect, error);
- nextEffect = nextEffect.nextEffect;
- }
- }
- } while (nextEffect !== null);
+ {
+ isFlushingPassiveEffects = true;
+ }
- stopCommitSnapshotEffectsTimer();
+ var prevExecutionContext = executionContext;
+ executionContext |= CommitContext;
+ var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called
+ // before ANY passive effect create functions are called.
+ // Otherwise effects in sibling components might interfere with each other.
+ // e.g. a destroy function in one component may unintentionally override a ref
+ // value set by a create function in another component.
+ // Layout effects have the same constraint.
+ // First pass: Destroy stale passive effects.
+
+ var unmountEffects = pendingPassiveHookEffectsUnmount;
+ pendingPassiveHookEffectsUnmount = [];
+
+ for (var i = 0; i < unmountEffects.length; i += 2) {
+ var _effect = unmountEffects[i];
+ var fiber = unmountEffects[i + 1];
+ var destroy = _effect.destroy;
+ _effect.destroy = undefined;
{
- // Mark the current commit time to be shared by all Profilers in this
- // batch. This enables them to be grouped later.
- recordCommitTime();
- } // The next phase is the mutation phase, where we mutate the host tree.
+ fiber.effectTag &= ~PassiveUnmountPendingDev;
+ var alternate = fiber.alternate;
- startCommitHostEffectsTimer();
- nextEffect = firstEffect;
+ if (alternate !== null) {
+ alternate.effectTag &= ~PassiveUnmountPendingDev;
+ }
+ }
- do {
+ if (typeof destroy === "function") {
{
- invokeGuardedCallback(
- null,
- commitMutationEffects,
- null,
- root,
- renderPriorityLevel
- );
-
- if (hasCaughtError()) {
- if (!(nextEffect !== null)) {
- throw Error("Should be working on an effect.");
- }
+ setCurrentFiber(fiber);
- var _error = clearCaughtError();
-
- captureCommitPhaseError(nextEffect, _error);
- nextEffect = nextEffect.nextEffect;
+ {
+ invokeGuardedCallback(null, destroy, null);
}
- }
- } while (nextEffect !== null);
-
- stopCommitHostEffectsTimer();
- resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
- // the mutation phase, so that the previous tree is still current during
- // componentWillUnmount, but before the layout phase, so that the finished
- // work is current during componentDidMount/Update.
-
- root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
- // the host tree after it's been mutated. The idiomatic use case for this is
- // layout, but class component lifecycles also fire here for legacy reasons.
-
- startCommitLifeCyclesTimer();
- nextEffect = firstEffect;
-
- do {
- {
- invokeGuardedCallback(
- null,
- commitLayoutEffects,
- null,
- root,
- expirationTime
- );
if (hasCaughtError()) {
- if (!(nextEffect !== null)) {
+ if (!(fiber !== null)) {
throw Error("Should be working on an effect.");
}
- var _error2 = clearCaughtError();
-
- captureCommitPhaseError(nextEffect, _error2);
- nextEffect = nextEffect.nextEffect;
+ var error = clearCaughtError();
+ captureCommitPhaseError(fiber, error);
}
- }
- } while (nextEffect !== null);
-
- stopCommitLifeCyclesTimer();
- nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
- // opportunity to paint.
-
- requestPaint();
- {
- popInteractions(prevInteractions);
+ resetCurrentFiber();
+ }
}
+ } // Second pass: Create new passive effects.
- executionContext = prevExecutionContext;
- } else {
- // No effects.
- root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
- // no effects.
- // TODO: Maybe there's a better way to report this.
+ var mountEffects = pendingPassiveHookEffectsMount;
+ pendingPassiveHookEffectsMount = [];
- startCommitSnapshotEffectsTimer();
- stopCommitSnapshotEffectsTimer();
+ for (var _i = 0; _i < mountEffects.length; _i += 2) {
+ var _effect2 = mountEffects[_i];
+ var _fiber = mountEffects[_i + 1];
{
- recordCommitTime();
- }
+ setCurrentFiber(_fiber);
- startCommitHostEffectsTimer();
- stopCommitHostEffectsTimer();
- startCommitLifeCyclesTimer();
- stopCommitLifeCyclesTimer();
- }
+ {
+ invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2);
+ }
- stopCommitTimer();
- var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
+ if (hasCaughtError()) {
+ if (!(_fiber !== null)) {
+ throw Error("Should be working on an effect.");
+ }
- if (rootDoesHavePassiveEffects) {
- // This commit has passive effects. Stash a reference to them. But don't
- // schedule a callback until after flushing layout work.
- rootDoesHavePassiveEffects = false;
- rootWithPendingPassiveEffects = root;
- pendingPassiveEffectsExpirationTime = expirationTime;
- pendingPassiveEffectsRenderPriority = renderPriorityLevel;
- } else {
- // We are done with the effect chain at this point so let's clear the
- // nextEffect pointers to assist with GC. If we have passive effects, we'll
- // clear this in flushPassiveEffects.
- nextEffect = firstEffect;
+ var _error4 = clearCaughtError();
- while (nextEffect !== null) {
- var nextNextEffect = nextEffect.nextEffect;
- nextEffect.nextEffect = null;
- nextEffect = nextNextEffect;
+ captureCommitPhaseError(_fiber, _error4);
+ }
+
+ resetCurrentFiber();
}
- } // Check if there's remaining work on this root
+ } // Note: This currently assumes there are no passive effects on the root fiber
+ // because the root is not part of its own effect list.
+ // This could change in the future.
- var remainingExpirationTime = root.firstPendingTime;
+ var effect = root.current.firstEffect;
- if (remainingExpirationTime !== NoWork) {
- {
- if (spawnedWorkDuringRender !== null) {
- var expirationTimes = spawnedWorkDuringRender;
- spawnedWorkDuringRender = null;
+ while (effect !== null) {
+ var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
- for (var i = 0; i < expirationTimes.length; i++) {
- scheduleInteractions(
- root,
- expirationTimes[i],
- root.memoizedInteractions
- );
- }
- }
+ effect.nextEffect = null;
- schedulePendingInteractions(root, remainingExpirationTime);
+ if (effect.effectTag & Deletion) {
+ detachFiberAfterEffects(effect);
}
- } else {
- // If there's no remaining work, we can clear the set of already failed
- // error boundaries.
- legacyErrorBoundariesThatAlreadyFailed = null;
+
+ effect = nextNextEffect;
}
{
- if (!rootDidHavePassiveEffects) {
- // If there are no passive effects, then we can complete the pending interactions.
- // Otherwise, we'll wait until after the passive effects are flushed.
- // Wait to do this until after remaining work has been scheduled,
- // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
- finishPendingInteractions(root, expirationTime);
- }
+ popInteractions(prevInteractions);
+ finishPendingInteractions(root, lanes);
}
- if (remainingExpirationTime === Sync) {
- // Count the number of times the root synchronously re-renders without
- // finishing. If there are too many, it indicates an infinite update loop.
- if (root === rootWithNestedUpdates) {
- nestedUpdateCount++;
- } else {
- nestedUpdateCount = 0;
- rootWithNestedUpdates = root;
- }
- } else {
- nestedUpdateCount = 0;
+ {
+ isFlushingPassiveEffects = false;
}
- onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any
- // additional work on this root is scheduled.
+ executionContext = prevExecutionContext;
+ flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
+ // exceeds the limit, we'll fire a warning.
- ensureRootIsScheduled(root);
+ nestedPassiveUpdateCount =
+ rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
+ return true;
+}
- if (hasUncaughtError) {
- hasUncaughtError = false;
- var _error3 = firstUncaughtError;
- firstUncaughtError = null;
- throw _error3;
+function isAlreadyFailedLegacyErrorBoundary(instance) {
+ return (
+ legacyErrorBoundariesThatAlreadyFailed !== null &&
+ legacyErrorBoundariesThatAlreadyFailed.has(instance)
+ );
+}
+function markLegacyErrorBoundaryAsFailed(instance) {
+ if (legacyErrorBoundariesThatAlreadyFailed === null) {
+ legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
+ } else {
+ legacyErrorBoundariesThatAlreadyFailed.add(instance);
}
+}
- if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
- // This is a legacy edge case. We just committed the initial mount of
- // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
- // synchronously, but layout updates should be deferred until the end
- // of the batch.
- return null;
- } // If layout work was scheduled, flush it now.
+function prepareToThrowUncaughtError(error) {
+ if (!hasUncaughtError) {
+ hasUncaughtError = true;
+ firstUncaughtError = error;
+ }
+}
- flushSyncCallbackQueue();
- return null;
+var onUncaughtError = prepareToThrowUncaughtError;
+
+function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
+ var errorInfo = createCapturedValue(error, sourceFiber);
+ var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane);
+ enqueueUpdate(rootFiber, update);
+ var eventTime = requestEventTime();
+ var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane);
+
+ if (root !== null) {
+ markRootUpdated(root, SyncLane, eventTime);
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, SyncLane);
+ }
}
-function commitBeforeMutationEffects() {
- while (nextEffect !== null) {
- var effectTag = nextEffect.effectTag;
+function captureCommitPhaseError(sourceFiber, error) {
+ if (sourceFiber.tag === HostRoot) {
+ // Error was thrown at the root. There is no parent, so the root
+ // itself should capture it.
+ captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
+ return;
+ }
- if ((effectTag & Snapshot) !== NoEffect) {
- setCurrentFiber(nextEffect);
- recordEffect();
- var current = nextEffect.alternate;
- commitBeforeMutationLifeCycles(current, nextEffect);
- resetCurrentFiber();
- }
+ var fiber = sourceFiber.return;
- if ((effectTag & Passive) !== NoEffect) {
- // If there are passive effects, schedule a callback to flush at
- // the earliest opportunity.
- if (!rootDoesHavePassiveEffects) {
- rootDoesHavePassiveEffects = true;
- scheduleCallback(NormalPriority, function() {
- flushPassiveEffects();
- return null;
- });
+ while (fiber !== null) {
+ if (fiber.tag === HostRoot) {
+ captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
+ return;
+ } else if (fiber.tag === ClassComponent) {
+ var ctor = fiber.type;
+ var instance = fiber.stateNode;
+
+ if (
+ typeof ctor.getDerivedStateFromError === "function" ||
+ (typeof instance.componentDidCatch === "function" &&
+ !isAlreadyFailedLegacyErrorBoundary(instance))
+ ) {
+ var errorInfo = createCapturedValue(error, sourceFiber);
+ var update = createClassErrorUpdate(fiber, errorInfo, SyncLane);
+ enqueueUpdate(fiber, update);
+ var eventTime = requestEventTime();
+ var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane);
+
+ if (root !== null) {
+ markRootUpdated(root, SyncLane, eventTime);
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, SyncLane);
+ }
+
+ return;
}
}
- nextEffect = nextEffect.nextEffect;
+ fiber = fiber.return;
}
}
+function pingSuspendedRoot(root, wakeable, pingedLanes) {
+ var pingCache = root.pingCache;
-function commitMutationEffects(root, renderPriorityLevel) {
- // TODO: Should probably move the bulk of this function to commitWork.
- while (nextEffect !== null) {
- setCurrentFiber(nextEffect);
- var effectTag = nextEffect.effectTag;
+ if (pingCache !== null) {
+ // The wakeable resolved, so we no longer need to memoize, because it will
+ // never be thrown again.
+ pingCache.delete(wakeable);
+ }
- if (effectTag & Ref) {
- var current = nextEffect.alternate;
+ var eventTime = requestEventTime();
+ markRootPinged(root, pingedLanes);
- if (current !== null) {
- commitDetachRef(current);
- }
- } // The following switch statement is only concerned about placement,
- // updates, and deletions. To avoid needing to add a case for every possible
- // bitmap value, we remove the secondary effects from the effect tag and
- // switch on that value.
+ if (
+ workInProgressRoot === root &&
+ isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)
+ ) {
+ // Received a ping at the same priority level at which we're currently
+ // rendering. We might want to restart this render. This should mirror
+ // the logic of whether or not a root suspends once it completes.
+ // TODO: If we're rendering sync either due to Sync, Batched or expired,
+ // we should probably never restart.
+ // If we're suspended with delay, or if it's a retry, we'll always suspend
+ // so we can always restart.
+ if (
+ workInProgressRootExitStatus === RootSuspendedWithDelay ||
+ (workInProgressRootExitStatus === RootSuspended &&
+ includesOnlyRetries(workInProgressRootRenderLanes) &&
+ now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
+ ) {
+ // Restart from the root.
+ prepareFreshStack(root, NoLanes);
+ } else {
+ // Even though we can't restart right now, we might get an
+ // opportunity later. So we mark this render as having a ping.
+ workInProgressRootPingedLanes = mergeLanes(
+ workInProgressRootPingedLanes,
+ pingedLanes
+ );
+ }
+ }
- var primaryEffectTag =
- effectTag & (Placement | Update | Deletion | Hydrating);
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, pingedLanes);
+}
- switch (primaryEffectTag) {
- case Placement: {
- // inserted, before any life-cycles like componentDidMount gets called.
- // TODO: findDOMNode doesn't rely on this any more but isMounted does
- // and isMounted is deprecated anyway so we should be able to kill this.
+function retryTimedOutBoundary(boundaryFiber, retryLane) {
+ // The boundary fiber (a Suspense component or SuspenseList component)
+ // previously was rendered in its fallback state. One of the promises that
+ // suspended it has resolved, which means at least part of the tree was
+ // likely unblocked. Try rendering again, at a new expiration time.
+ if (retryLane === NoLane) {
+ retryLane = requestRetryLane(boundaryFiber);
+ } // TODO: Special case idle priority?
- nextEffect.effectTag &= ~Placement;
- break;
- }
+ var eventTime = requestEventTime();
+ var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane);
- case PlacementAndUpdate: {
- // inserted, before any life-cycles like componentDidMount gets called.
+ if (root !== null) {
+ markRootUpdated(root, retryLane, eventTime);
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, retryLane);
+ }
+}
+function resolveRetryWakeable(boundaryFiber, wakeable) {
+ var retryLane = NoLane; // Default
- nextEffect.effectTag &= ~Placement; // Update
+ var retryCache;
- var _current = nextEffect.alternate;
- commitWork(_current, nextEffect);
- break;
- }
+ {
+ retryCache = boundaryFiber.stateNode;
+ }
- case Hydrating: {
- nextEffect.effectTag &= ~Hydrating;
- break;
- }
+ if (retryCache !== null) {
+ // The wakeable resolved, so we no longer need to memoize, because it will
+ // never be thrown again.
+ retryCache.delete(wakeable);
+ }
- case HydratingAndUpdate: {
- nextEffect.effectTag &= ~Hydrating; // Update
+ retryTimedOutBoundary(boundaryFiber, retryLane);
+} // Computes the next Just Noticeable Difference (JND) boundary.
+// The theory is that a person can't tell the difference between small differences in time.
+// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
+// difference in the experience. However, waiting for longer might mean that we can avoid
+// showing an intermediate loading state. The longer we have already waited, the harder it
+// is to tell small differences in time. Therefore, the longer we've already waited,
+// the longer we can wait additionally. At some point we have to give up though.
+// We pick a train model where the next boundary commits at a consistent schedule.
+// These particular numbers are vague estimates. We expect to adjust them based on research.
- var _current2 = nextEffect.alternate;
- commitWork(_current2, nextEffect);
- break;
- }
+function jnd(timeElapsed) {
+ return timeElapsed < 120
+ ? 120
+ : timeElapsed < 480
+ ? 480
+ : timeElapsed < 1080
+ ? 1080
+ : timeElapsed < 1920
+ ? 1920
+ : timeElapsed < 3000
+ ? 3000
+ : timeElapsed < 4320
+ ? 4320
+ : ceil(timeElapsed / 1960) * 1960;
+}
- case Update: {
- var _current3 = nextEffect.alternate;
- commitWork(_current3, nextEffect);
- break;
- }
+function computeMsUntilSuspenseLoadingDelay(
+ mostRecentEventTime,
+ suspenseConfig
+) {
+ var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
- case Deletion: {
- commitDeletion(root, nextEffect, renderPriorityLevel);
- break;
- }
- } // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
+ if (busyMinDurationMs <= 0) {
+ return 0;
+ }
+
+ var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
- recordEffect();
- resetCurrentFiber();
- nextEffect = nextEffect.nextEffect;
+ var currentTimeMs = now();
+ var eventTimeMs = mostRecentEventTime;
+ var timeElapsed = currentTimeMs - eventTimeMs;
+
+ if (timeElapsed <= busyDelayMs) {
+ // If we haven't yet waited longer than the initial delay, we don't
+ // have to wait any additional time.
+ return 0;
}
+
+ var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
+
+ return msUntilTimeout;
}
-function commitLayoutEffects(root, committedExpirationTime) {
- // TODO: Should probably move the bulk of this function to commitWork.
- while (nextEffect !== null) {
- setCurrentFiber(nextEffect);
- var effectTag = nextEffect.effectTag;
+function checkForNestedUpdates() {
+ if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
+ nestedUpdateCount = 0;
+ rootWithNestedUpdates = null;
- if (effectTag & (Update | Callback)) {
- recordEffect();
- var current = nextEffect.alternate;
- commitLifeCycles(root, current, nextEffect);
+ {
+ throw Error(
+ "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
+ );
}
+ }
- if (effectTag & Ref) {
- recordEffect();
- commitAttachRef(nextEffect);
- }
+ {
+ if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
+ nestedPassiveUpdateCount = 0;
- resetCurrentFiber();
- nextEffect = nextEffect.nextEffect;
+ error(
+ "Maximum update depth exceeded. This can happen when a component " +
+ "calls setState inside useEffect, but useEffect either doesn't " +
+ "have a dependency array, or one of the dependencies changes on " +
+ "every render."
+ );
+ }
}
}
-function flushPassiveEffects() {
- if (pendingPassiveEffectsRenderPriority !== NoPriority) {
- var priorityLevel =
- pendingPassiveEffectsRenderPriority > NormalPriority
- ? NormalPriority
- : pendingPassiveEffectsRenderPriority;
- pendingPassiveEffectsRenderPriority = NoPriority;
- return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
+function flushRenderPhaseStrictModeWarningsInDEV() {
+ {
+ ReactStrictModeWarnings.flushLegacyContextWarning();
+
+ {
+ ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
+ }
}
}
-function flushPassiveEffectsImpl() {
- if (rootWithPendingPassiveEffects === null) {
- return false;
- }
+var didWarnStateUpdateForNotYetMountedComponent = null;
- var root = rootWithPendingPassiveEffects;
- var expirationTime = pendingPassiveEffectsExpirationTime;
- rootWithPendingPassiveEffects = null;
- pendingPassiveEffectsExpirationTime = NoWork;
+function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
+ {
+ if ((executionContext & RenderContext) !== NoContext) {
+ // We let the other warning about render phase updates deal with this one.
+ return;
+ }
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Cannot flush passive effects while already rendering.");
- }
+ if (!(fiber.mode & (BlockingMode | ConcurrentMode))) {
+ return;
+ }
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- var prevInteractions = pushInteractions(root);
+ var tag = fiber.tag;
- {
- // Note: This currently assumes there are no passive effects on the root fiber
- // because the root is not part of its own effect list.
- // This could change in the future.
- var _effect2 = root.current.firstEffect;
+ if (
+ tag !== IndeterminateComponent &&
+ tag !== HostRoot &&
+ tag !== ClassComponent &&
+ tag !== FunctionComponent &&
+ tag !== ForwardRef &&
+ tag !== MemoComponent &&
+ tag !== SimpleMemoComponent &&
+ tag !== Block
+ ) {
+ // Only warn for user-defined components, not internal ones like Suspense.
+ return;
+ } // We show the whole stack but dedupe on the top component's name because
+ // the problematic code almost always lies inside that component.
- while (_effect2 !== null) {
- {
- setCurrentFiber(_effect2);
- invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2);
+ var componentName = getComponentName(fiber.type) || "ReactComponent";
- if (hasCaughtError()) {
- if (!(_effect2 !== null)) {
- throw Error("Should be working on an effect.");
- }
+ if (didWarnStateUpdateForNotYetMountedComponent !== null) {
+ if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
+ return;
+ }
- var _error5 = clearCaughtError();
+ didWarnStateUpdateForNotYetMountedComponent.add(componentName);
+ } else {
+ didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
+ }
- captureCommitPhaseError(_effect2, _error5);
- }
+ var previousFiber = current;
+ try {
+ setCurrentFiber(fiber);
+
+ error(
+ "Can't perform a React state update on a component that hasn't mounted yet. " +
+ "This indicates that you have a side-effect in your render function that " +
+ "asynchronously later calls tries to update the component. Move this work to " +
+ "useEffect instead."
+ );
+ } finally {
+ if (previousFiber) {
+ setCurrentFiber(fiber);
+ } else {
resetCurrentFiber();
}
-
- var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC
-
- _effect2.nextEffect = null;
- _effect2 = nextNextEffect;
}
}
+}
+
+var didWarnStateUpdateForUnmountedComponent = null;
+function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
{
- popInteractions(prevInteractions);
- finishPendingInteractions(root, expirationTime);
- }
+ var tag = fiber.tag;
- executionContext = prevExecutionContext;
- flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
- // exceeds the limit, we'll fire a warning.
+ if (
+ tag !== HostRoot &&
+ tag !== ClassComponent &&
+ tag !== FunctionComponent &&
+ tag !== ForwardRef &&
+ tag !== MemoComponent &&
+ tag !== SimpleMemoComponent &&
+ tag !== Block
+ ) {
+ // Only warn for user-defined components, not internal ones like Suspense.
+ return;
+ } // If there are pending passive effects unmounts for this Fiber,
+ // we can assume that they would have prevented this update.
- nestedPassiveUpdateCount =
- rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
- return true;
-}
+ if ((fiber.effectTag & PassiveUnmountPendingDev) !== NoEffect) {
+ return;
+ } // We show the whole stack but dedupe on the top component's name because
+ // the problematic code almost always lies inside that component.
-function isAlreadyFailedLegacyErrorBoundary(instance) {
- return (
- legacyErrorBoundariesThatAlreadyFailed !== null &&
- legacyErrorBoundariesThatAlreadyFailed.has(instance)
- );
-}
-function markLegacyErrorBoundaryAsFailed(instance) {
- if (legacyErrorBoundariesThatAlreadyFailed === null) {
- legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
- } else {
- legacyErrorBoundariesThatAlreadyFailed.add(instance);
- }
-}
+ var componentName = getComponentName(fiber.type) || "ReactComponent";
-function prepareToThrowUncaughtError(error) {
- if (!hasUncaughtError) {
- hasUncaughtError = true;
- firstUncaughtError = error;
- }
-}
+ if (didWarnStateUpdateForUnmountedComponent !== null) {
+ if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
+ return;
+ }
-var onUncaughtError = prepareToThrowUncaughtError;
+ didWarnStateUpdateForUnmountedComponent.add(componentName);
+ } else {
+ didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
+ }
-function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
- var errorInfo = createCapturedValue(error, sourceFiber);
- var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
- enqueueUpdate(rootFiber, update);
- var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
+ if (isFlushingPassiveEffects);
+ else {
+ var previousFiber = current;
- if (root !== null) {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, Sync);
+ try {
+ setCurrentFiber(fiber);
+
+ error(
+ "Can't perform a React state update on an unmounted component. This " +
+ "is a no-op, but it indicates a memory leak in your application. To " +
+ "fix, cancel all subscriptions and asynchronous tasks in %s.",
+ tag === ClassComponent
+ ? "the componentWillUnmount method"
+ : "a useEffect cleanup function"
+ );
+ } finally {
+ if (previousFiber) {
+ setCurrentFiber(fiber);
+ } else {
+ resetCurrentFiber();
+ }
+ }
+ }
}
}
-function captureCommitPhaseError(sourceFiber, error) {
- if (sourceFiber.tag === HostRoot) {
- // Error was thrown at the root. There is no parent, so the root
- // itself should capture it.
- captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
- return;
- }
+var beginWork$1;
- var fiber = sourceFiber.return;
+{
+ var dummyFiber = null;
- while (fiber !== null) {
- if (fiber.tag === HostRoot) {
- captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
- return;
- } else if (fiber.tag === ClassComponent) {
- var ctor = fiber.type;
- var instance = fiber.stateNode;
+ beginWork$1 = function(current, unitOfWork, lanes) {
+ // If a component throws an error, we replay it again in a synchronously
+ // dispatched event, so that the debugger will treat it as an uncaught
+ // error See ReactErrorUtils for more information.
+ // Before entering the begin phase, copy the work-in-progress onto a dummy
+ // fiber. If beginWork throws, we'll use this to reset the state.
+ var originalWorkInProgressCopy = assignFiberPropertiesInDEV(
+ dummyFiber,
+ unitOfWork
+ );
+ try {
+ return beginWork(current, unitOfWork, lanes);
+ } catch (originalError) {
if (
- typeof ctor.getDerivedStateFromError === "function" ||
- (typeof instance.componentDidCatch === "function" &&
- !isAlreadyFailedLegacyErrorBoundary(instance))
+ originalError !== null &&
+ typeof originalError === "object" &&
+ typeof originalError.then === "function"
) {
- var errorInfo = createCapturedValue(error, sourceFiber);
- var update = createClassErrorUpdate(
- fiber,
- errorInfo, // TODO: This is always sync
- Sync
- );
- enqueueUpdate(fiber, update);
- var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
+ // Don't replay promises. Treat everything else like an error.
+ throw originalError;
+ } // Keep this code in sync with handleError; any changes here must have
+ // corresponding changes there.
+
+ resetContextDependencies();
+ resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the
+ // same fiber again.
+ // Unwind the failed stack frame
+
+ unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
+
+ assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
+
+ if (unitOfWork.mode & ProfileMode) {
+ // Reset the profiler timer.
+ startProfilerTimer(unitOfWork);
+ } // Run beginWork again.
+
+ invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes);
+
+ if (hasCaughtError()) {
+ var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
+ // Rethrow this error instead of the original one.
+
+ throw replayError;
+ } else {
+ // This branch is reachable if the render phase is impure.
+ throw originalError;
+ }
+ }
+ };
+}
+
+var didWarnAboutUpdateInRender = false;
+var didWarnAboutUpdateInRenderForAnotherComponent;
+
+{
+ didWarnAboutUpdateInRenderForAnotherComponent = new Set();
+}
+
+function warnAboutRenderPhaseUpdatesInDEV(fiber) {
+ {
+ if (
+ isRendering &&
+ (executionContext & RenderContext) !== NoContext &&
+ !getIsUpdatingOpaqueValueInRenderPhaseInDEV()
+ ) {
+ switch (fiber.tag) {
+ case FunctionComponent:
+ case ForwardRef:
+ case SimpleMemoComponent: {
+ var renderingComponentName =
+ (workInProgress && getComponentName(workInProgress.type)) ||
+ "Unknown"; // Dedupe by the rendering component because it's the one that needs to be fixed.
- if (root !== null) {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, Sync);
+ var dedupeKey = renderingComponentName;
+
+ if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
+ didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
+ var setStateComponentName =
+ getComponentName(fiber.type) || "Unknown";
+
+ error(
+ "Cannot update a component (`%s`) while rendering a " +
+ "different component (`%s`). To locate the bad setState() call inside `%s`, " +
+ "follow the stack trace as described in https://fb.me/setstate-in-render",
+ setStateComponentName,
+ renderingComponentName,
+ renderingComponentName
+ );
+ }
+
+ break;
}
- return;
+ case ClassComponent: {
+ if (!didWarnAboutUpdateInRender) {
+ error(
+ "Cannot update during an existing state transition (such as " +
+ "within `render`). Render methods should be a pure " +
+ "function of props and state."
+ );
+
+ didWarnAboutUpdateInRender = true;
+ }
+
+ break;
+ }
}
}
-
- fiber = fiber.return;
}
-}
-function pingSuspendedRoot(root, thenable, suspendedTime) {
- var pingCache = root.pingCache;
+} // a 'shared' variable that changes when act() opens/closes in tests.
- if (pingCache !== null) {
- // The thenable resolved, so we no longer need to memoize, because it will
- // never be thrown again.
- pingCache.delete(thenable);
- }
+var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
+// scheduler is the actual recommendation. The alternative could be a testing build,
+// a new lib, or whatever; we dunno just yet. This message is for early adopters
+// to get their tests right.
- if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) {
- // Received a ping at the same priority level at which we're currently
- // rendering. We might want to restart this render. This should mirror
- // the logic of whether or not a root suspends once it completes.
- // TODO: If we're rendering sync either due to Sync, Batched or expired,
- // we should probably never restart.
- // If we're suspended with delay, we'll always suspend so we can always
- // restart. If we're suspended without any updates, it might be a retry.
- // If it's early in the retry we can restart. We can't know for sure
- // whether we'll eventually process an update during this render pass,
- // but it's somewhat unlikely that we get to a ping before that, since
- // getting to the root most update is usually very fast.
+function warnIfUnmockedScheduler(fiber) {
+ {
if (
- workInProgressRootExitStatus === RootSuspendedWithDelay ||
- (workInProgressRootExitStatus === RootSuspended &&
- workInProgressRootLatestProcessedExpirationTime === Sync &&
- now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
+ didWarnAboutUnmockedScheduler === false &&
+ Scheduler.unstable_flushAllWithoutAsserting === undefined
) {
- // Restart from the root. Don't need to schedule a ping because
- // we're already working on this tree.
- prepareFreshStack(root, renderExpirationTime$1);
- } else {
- // Even though we can't restart right now, we might get an
- // opportunity later. So we mark this render as having a ping.
- workInProgressRootHasPendingPing = true;
- }
+ if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
+ didWarnAboutUnmockedScheduler = true;
- return;
+ error(
+ 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
+ "to guarantee consistent behaviour across tests and browsers. " +
+ "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
+ "jest.mock('scheduler', () => require" +
+ "('scheduler/unstable_mock'));\n\n" +
+ "For more info, visit https://fb.me/react-mock-scheduler"
+ );
+ } else {
+ didWarnAboutUnmockedScheduler = true;
+
+ error(
+ 'Starting from React v18, the "scheduler" module will need to be mocked ' +
+ "to guarantee consistent behaviour across tests and browsers. " +
+ "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
+ "jest.mock('scheduler', () => require" +
+ "('scheduler/unstable_mock'));\n\n" +
+ "For more info, visit https://fb.me/react-mock-scheduler"
+ );
+ }
+ }
}
+}
- if (!isRootSuspendedAtTime(root, suspendedTime)) {
- // The root is no longer suspended at this time.
- return;
+function computeThreadID(root, lane) {
+ // Interaction threads are unique per root and expiration time.
+ // NOTE: Intentionally unsound cast. All that matters is that it's a number
+ // and it represents a batch of work. Could make a helper function instead,
+ // but meh this is fine for now.
+ return lane * 1000 + root.interactionThreadID;
+}
+
+function markSpawnedWork(lane) {
+ if (spawnedWorkDuringRender === null) {
+ spawnedWorkDuringRender = [lane];
+ } else {
+ spawnedWorkDuringRender.push(lane);
}
+}
- var lastPingedTime = root.lastPingedTime;
+function scheduleInteractions(root, lane, interactions) {
+ if (interactions.size > 0) {
+ var pendingInteractionMap = root.pendingInteractionMap;
+ var pendingInteractions = pendingInteractionMap.get(lane);
- if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
- // There's already a lower priority ping scheduled.
- return;
- } // Mark the time at which this ping was scheduled.
+ if (pendingInteractions != null) {
+ interactions.forEach(function(interaction) {
+ if (!pendingInteractions.has(interaction)) {
+ // Update the pending async work count for previously unscheduled interaction.
+ interaction.__count++;
+ }
- root.lastPingedTime = suspendedTime;
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, suspendedTime);
-}
+ pendingInteractions.add(interaction);
+ });
+ } else {
+ pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions.
-function retryTimedOutBoundary(boundaryFiber, retryTime) {
- // The boundary fiber (a Suspense component or SuspenseList component)
- // previously was rendered in its fallback state. One of the promises that
- // suspended it has resolved, which means at least part of the tree was
- // likely unblocked. Try rendering again, at a new expiration time.
- if (retryTime === NoWork) {
- var suspenseConfig = null; // Retries don't carry over the already committed update.
-
- var currentTime = requestCurrentTimeForUpdate();
- retryTime = computeExpirationForFiber(
- currentTime,
- boundaryFiber,
- suspenseConfig
- );
- } // TODO: Special case idle priority?
+ interactions.forEach(function(interaction) {
+ interaction.__count++;
+ });
+ }
- var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
+ var subscriber = tracing.__subscriberRef.current;
- if (root !== null) {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, retryTime);
+ if (subscriber !== null) {
+ var threadID = computeThreadID(root, lane);
+ subscriber.onWorkScheduled(interactions, threadID);
+ }
}
}
-function resolveRetryThenable(boundaryFiber, thenable) {
- var retryTime = NoWork; // Default
- var retryCache;
+function schedulePendingInteractions(root, lane) {
+ scheduleInteractions(root, lane, tracing.__interactionsRef.current);
+}
- {
- retryCache = boundaryFiber.stateNode;
- }
+function startWorkOnPendingInteractions(root, lanes) {
+ // we can accurately attribute time spent working on it, And so that cascading
+ // work triggered during the render phase will be associated with it.
- if (retryCache !== null) {
- // The thenable resolved, so we no longer need to memoize, because it will
- // never be thrown again.
- retryCache.delete(thenable);
- }
+ var interactions = new Set();
+ root.pendingInteractionMap.forEach(function(
+ scheduledInteractions,
+ scheduledLane
+ ) {
+ if (includesSomeLane(lanes, scheduledLane)) {
+ scheduledInteractions.forEach(function(interaction) {
+ return interactions.add(interaction);
+ });
+ }
+ }); // Store the current set of interactions on the FiberRoot for a few reasons:
+ // We can re-use it in hot functions like performConcurrentWorkOnRoot()
+ // without having to recalculate it. We will also use it in commitWork() to
+ // pass to any Profiler onRender() hooks. This also provides DevTools with a
+ // way to access it when the onCommitRoot() hook is called.
- retryTimedOutBoundary(boundaryFiber, retryTime);
-} // Computes the next Just Noticeable Difference (JND) boundary.
-// The theory is that a person can't tell the difference between small differences in time.
-// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
-// difference in the experience. However, waiting for longer might mean that we can avoid
-// showing an intermediate loading state. The longer we have already waited, the harder it
-// is to tell small differences in time. Therefore, the longer we've already waited,
-// the longer we can wait additionally. At some point we have to give up though.
-// We pick a train model where the next boundary commits at a consistent schedule.
-// These particular numbers are vague estimates. We expect to adjust them based on research.
+ root.memoizedInteractions = interactions;
-function jnd(timeElapsed) {
- return timeElapsed < 120
- ? 120
- : timeElapsed < 480
- ? 480
- : timeElapsed < 1080
- ? 1080
- : timeElapsed < 1920
- ? 1920
- : timeElapsed < 3000
- ? 3000
- : timeElapsed < 4320
- ? 4320
- : ceil(timeElapsed / 1960) * 1960;
-}
+ if (interactions.size > 0) {
+ var subscriber = tracing.__subscriberRef.current;
-function computeMsUntilSuspenseLoadingDelay(
- mostRecentEventTime,
- committedExpirationTime,
- suspenseConfig
-) {
- var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
+ if (subscriber !== null) {
+ var threadID = computeThreadID(root, lanes);
- if (busyMinDurationMs <= 0) {
- return 0;
+ try {
+ subscriber.onWorkStarted(interactions, threadID);
+ } catch (error) {
+ // If the subscriber throws, rethrow it in a separate task
+ scheduleCallback(ImmediatePriority$1, function() {
+ throw error;
+ });
+ }
+ }
}
+}
- var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
+function finishPendingInteractions(root, committedLanes) {
+ var remainingLanesAfterCommit = root.pendingLanes;
+ var subscriber;
- var currentTimeMs = now();
- var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(
- mostRecentEventTime,
- suspenseConfig
- );
- var timeElapsed = currentTimeMs - eventTimeMs;
+ try {
+ subscriber = tracing.__subscriberRef.current;
- if (timeElapsed <= busyDelayMs) {
- // If we haven't yet waited longer than the initial delay, we don't
- // have to wait any additional time.
- return 0;
+ if (subscriber !== null && root.memoizedInteractions.size > 0) {
+ // FIXME: More than one lane can finish in a single commit.
+ var threadID = computeThreadID(root, committedLanes);
+ subscriber.onWorkStopped(root.memoizedInteractions, threadID);
+ }
+ } catch (error) {
+ // If the subscriber throws, rethrow it in a separate task
+ scheduleCallback(ImmediatePriority$1, function() {
+ throw error;
+ });
+ } finally {
+ // Clear completed interactions from the pending Map.
+ // Unless the render was suspended or cascading work was scheduled,
+ // In which case– leave pending interactions until the subsequent render.
+ var pendingInteractionMap = root.pendingInteractionMap;
+ pendingInteractionMap.forEach(function(scheduledInteractions, lane) {
+ // Only decrement the pending interaction count if we're done.
+ // If there's still work at the current priority,
+ // That indicates that we are waiting for suspense data.
+ if (!includesSomeLane(remainingLanesAfterCommit, lane)) {
+ pendingInteractionMap.delete(lane);
+ scheduledInteractions.forEach(function(interaction) {
+ interaction.__count--;
+
+ if (subscriber !== null && interaction.__count === 0) {
+ try {
+ subscriber.onInteractionScheduledWorkCompleted(interaction);
+ } catch (error) {
+ // If the subscriber throws, rethrow it in a separate task
+ scheduleCallback(ImmediatePriority$1, function() {
+ throw error;
+ });
+ }
+ }
+ });
+ }
+ });
}
+} // `act` testing API
+//
+// TODO: This is mostly a copy-paste from the legacy `act`, which does not have
+// access to the same internals that we do here. Some trade offs in the
+// implementation no longer make sense.
- var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
+var isFlushingAct = false;
- return msUntilTimeout;
+function shouldForceFlushFallbacksInDEV() {
+ return isFlushingAct;
}
-function checkForNestedUpdates() {
- if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
- nestedUpdateCount = 0;
- rootWithNestedUpdates = null;
+function detachFiberAfterEffects(fiber) {
+ fiber.sibling = null;
+}
- {
- throw Error(
- "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
- );
- }
- }
+var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
+var failedBoundaries = null;
+var setRefreshHandler = function(handler) {
{
- if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
- nestedPassiveUpdateCount = 0;
-
- error(
- "Maximum update depth exceeded. This can happen when a component " +
- "calls setState inside useEffect, but useEffect either doesn't " +
- "have a dependency array, or one of the dependencies changes on " +
- "every render."
- );
- }
+ resolveFamily = handler;
}
-}
-
-function flushRenderPhaseStrictModeWarningsInDEV() {
+};
+function resolveFunctionForHotReloading(type) {
{
- ReactStrictModeWarnings.flushLegacyContextWarning();
-
- {
- ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return type;
}
- }
-}
-function stopFinishedWorkLoopTimer() {
- var didCompleteRoot = true;
- stopWorkLoopTimer(interruptedBy, didCompleteRoot);
- interruptedBy = null;
-}
+ var family = resolveFamily(type);
-function stopInterruptedWorkLoopTimer() {
- // TODO: Track which fiber caused the interruption.
- var didCompleteRoot = false;
- stopWorkLoopTimer(interruptedBy, didCompleteRoot);
- interruptedBy = null;
-}
+ if (family === undefined) {
+ return type;
+ } // Use the latest known implementation.
-function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
- if (
- workInProgressRoot !== null &&
- updateExpirationTime > renderExpirationTime$1
- ) {
- interruptedBy = fiberThatReceivedUpdate;
+ return family.current;
}
}
+function resolveClassForHotReloading(type) {
+ // No implementation differences.
+ return resolveFunctionForHotReloading(type);
+}
+function resolveForwardRefForHotReloading(type) {
+ {
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return type;
+ }
-var didWarnStateUpdateForUnmountedComponent = null;
+ var family = resolveFamily(type);
-function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
- {
- var tag = fiber.tag;
+ if (family === undefined) {
+ // Check if we're dealing with a real forwardRef. Don't want to crash early.
+ if (
+ type !== null &&
+ type !== undefined &&
+ typeof type.render === "function"
+ ) {
+ // ForwardRef is special because its resolved .type is an object,
+ // but it's possible that we only have its inner render function in the map.
+ // If that inner render function is different, we'll build a new forwardRef type.
+ var currentRender = resolveFunctionForHotReloading(type.render);
- if (
- tag !== HostRoot &&
- tag !== ClassComponent &&
- tag !== FunctionComponent &&
- tag !== ForwardRef &&
- tag !== MemoComponent &&
- tag !== SimpleMemoComponent &&
- tag !== Block
- ) {
- // Only warn for user-defined components, not internal ones like Suspense.
- return;
- }
- // the problematic code almost always lies inside that component.
+ if (type.render !== currentRender) {
+ var syntheticType = {
+ $$typeof: REACT_FORWARD_REF_TYPE,
+ render: currentRender
+ };
- var componentName = getComponentName(fiber.type) || "ReactComponent";
+ if (type.displayName !== undefined) {
+ syntheticType.displayName = type.displayName;
+ }
- if (didWarnStateUpdateForUnmountedComponent !== null) {
- if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
- return;
+ return syntheticType;
+ }
}
- didWarnStateUpdateForUnmountedComponent.add(componentName);
- } else {
- didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
- }
+ return type;
+ } // Use the latest known implementation.
- error(
- "Can't perform a React state update on an unmounted component. This " +
- "is a no-op, but it indicates a memory leak in your application. To " +
- "fix, cancel all subscriptions and asynchronous tasks in %s.%s",
- tag === ClassComponent
- ? "the componentWillUnmount method"
- : "a useEffect cleanup function",
- getStackByFiberInDevAndProd(fiber)
- );
+ return family.current;
}
}
+function isCompatibleFamilyForHotReloading(fiber, element) {
+ {
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return false;
+ }
-var beginWork$1;
+ var prevType = fiber.elementType;
+ var nextType = element.type; // If we got here, we know types aren't === equal.
-{
- var dummyFiber = null;
+ var needsCompareFamilies = false;
+ var $$typeofNextType =
+ typeof nextType === "object" && nextType !== null
+ ? nextType.$$typeof
+ : null;
- beginWork$1 = function(current, unitOfWork, expirationTime) {
- // If a component throws an error, we replay it again in a synchronously
- // dispatched event, so that the debugger will treat it as an uncaught
- // error See ReactErrorUtils for more information.
- // Before entering the begin phase, copy the work-in-progress onto a dummy
- // fiber. If beginWork throws, we'll use this to reset the state.
- var originalWorkInProgressCopy = assignFiberPropertiesInDEV(
- dummyFiber,
- unitOfWork
- );
+ switch (fiber.tag) {
+ case ClassComponent: {
+ if (typeof nextType === "function") {
+ needsCompareFamilies = true;
+ }
- try {
- return beginWork(current, unitOfWork, expirationTime);
- } catch (originalError) {
- if (
- originalError !== null &&
- typeof originalError === "object" &&
- typeof originalError.then === "function"
- ) {
- // Don't replay promises. Treat everything else like an error.
- throw originalError;
- } // Keep this code in sync with handleError; any changes here must have
- // corresponding changes there.
+ break;
+ }
- resetContextDependencies();
- resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the
- // same fiber again.
- // Unwind the failed stack frame
+ case FunctionComponent: {
+ if (typeof nextType === "function") {
+ needsCompareFamilies = true;
+ } else if ($$typeofNextType === REACT_LAZY_TYPE) {
+ // We don't know the inner type yet.
+ // We're going to assume that the lazy inner type is stable,
+ // and so it is sufficient to avoid reconciling it away.
+ // We're not going to unwrap or actually use the new lazy type.
+ needsCompareFamilies = true;
+ }
- unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
+ break;
+ }
- assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
+ case ForwardRef: {
+ if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
+ needsCompareFamilies = true;
+ } else if ($$typeofNextType === REACT_LAZY_TYPE) {
+ needsCompareFamilies = true;
+ }
- if (unitOfWork.mode & ProfileMode) {
- // Reset the profiler timer.
- startProfilerTimer(unitOfWork);
- } // Run beginWork again.
+ break;
+ }
- invokeGuardedCallback(
- null,
- beginWork,
- null,
- current,
- unitOfWork,
- expirationTime
- );
+ case MemoComponent:
+ case SimpleMemoComponent: {
+ if ($$typeofNextType === REACT_MEMO_TYPE) {
+ // TODO: if it was but can no longer be simple,
+ // we shouldn't set this.
+ needsCompareFamilies = true;
+ } else if ($$typeofNextType === REACT_LAZY_TYPE) {
+ needsCompareFamilies = true;
+ }
- if (hasCaughtError()) {
- var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
- // Rethrow this error instead of the original one.
+ break;
+ }
- throw replayError;
- } else {
- // This branch is reachable if the render phase is impure.
- throw originalError;
+ default:
+ return false;
+ } // Check if both types have a family and it's the same one.
+
+ if (needsCompareFamilies) {
+ // Note: memo() and forwardRef() we'll compare outer rather than inner type.
+ // This means both of them need to be registered to preserve state.
+ // If we unwrapped and compared the inner types for wrappers instead,
+ // then we would risk falsely saying two separate memo(Foo)
+ // calls are equivalent because they wrap the same Foo function.
+ var prevFamily = resolveFamily(prevType);
+
+ if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
+ return true;
}
}
- };
-}
-
-var didWarnAboutUpdateInRender = false;
-function warnAboutRenderPhaseUpdatesInDEV(fiber) {
+ return false;
+ }
+}
+function markFailedErrorBoundaryForHotReloading(fiber) {
{
- if ((executionContext & RenderContext) !== NoContext) {
- switch (fiber.tag) {
- case FunctionComponent:
- case ForwardRef:
- case SimpleMemoComponent: {
- error(
- "Cannot update a component from inside the function body of a " +
- "different component."
- );
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return;
+ }
- break;
- }
+ if (typeof WeakSet !== "function") {
+ return;
+ }
- case ClassComponent: {
- if (isRendering && !didWarnAboutUpdateInRender) {
- error(
- "Cannot update during an existing state transition (such as " +
- "within `render`). Render methods should be a pure " +
- "function of props and state."
- );
+ if (failedBoundaries === null) {
+ failedBoundaries = new WeakSet();
+ }
- didWarnAboutUpdateInRender = true;
- break;
- }
- }
- }
+ failedBoundaries.add(fiber);
+ }
+}
+var scheduleRefresh = function(root, update) {
+ {
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return;
+ }
+
+ var staleFamilies = update.staleFamilies,
+ updatedFamilies = update.updatedFamilies;
+ flushPassiveEffects();
+ flushSync(function() {
+ scheduleFibersWithFamiliesRecursively(
+ root.current,
+ updatedFamilies,
+ staleFamilies
+ );
+ });
+ }
+};
+var scheduleRoot = function(root, element) {
+ {
+ if (root.context !== emptyContextObject) {
+ // Super edge case: root has a legacy _renderSubtree context
+ // but we don't know the parentComponent so we can't pass it.
+ // Just ignore. We'll delete this with _renderSubtree code path later.
+ return;
}
+
+ flushPassiveEffects();
+ flushSync(function() {
+ updateContainer(element, root, null, null);
+ });
}
-} // a 'shared' variable that changes when act() opens/closes in tests.
-
-var IsThisRendererActing = {
- current: false
};
-var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
-// scheduler is the actual recommendation. The alternative could be a testing build,
-// a new lib, or whatever; we dunno just yet. This message is for early adopters
-// to get their tests right.
-
-function warnIfUnmockedScheduler(fiber) {
+function scheduleFibersWithFamiliesRecursively(
+ fiber,
+ updatedFamilies,
+ staleFamilies
+) {
{
- if (
- didWarnAboutUnmockedScheduler === false &&
- Scheduler.unstable_flushAllWithoutAsserting === undefined
- ) {
- if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
- didWarnAboutUnmockedScheduler = true;
+ var alternate = fiber.alternate,
+ child = fiber.child,
+ sibling = fiber.sibling,
+ tag = fiber.tag,
+ type = fiber.type;
+ var candidateType = null;
- error(
- 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
- "to guarantee consistent behaviour across tests and browsers. " +
- "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
- "jest.mock('scheduler', () => require" +
- "('scheduler/unstable_mock'));\n\n" +
- "For more info, visit https://fb.me/react-mock-scheduler"
- );
- } else {
- didWarnAboutUnmockedScheduler = true;
+ switch (tag) {
+ case FunctionComponent:
+ case SimpleMemoComponent:
+ case ClassComponent:
+ candidateType = type;
+ break;
- error(
- 'Starting from React v17, the "scheduler" module will need to be mocked ' +
- "to guarantee consistent behaviour across tests and browsers. " +
- "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
- "jest.mock('scheduler', () => require" +
- "('scheduler/unstable_mock'));\n\n" +
- "For more info, visit https://fb.me/react-mock-scheduler"
- );
- }
+ case ForwardRef:
+ candidateType = type.render;
+ break;
}
- }
-}
-function computeThreadID(root, expirationTime) {
- // Interaction threads are unique per root and expiration time.
- return expirationTime * 1000 + root.interactionThreadID;
-}
+ if (resolveFamily === null) {
+ throw new Error("Expected resolveFamily to be set during hot reload.");
+ }
-function markSpawnedWork(expirationTime) {
- if (spawnedWorkDuringRender === null) {
- spawnedWorkDuringRender = [expirationTime];
- } else {
- spawnedWorkDuringRender.push(expirationTime);
- }
-}
+ var needsRender = false;
+ var needsRemount = false;
-function scheduleInteractions(root, expirationTime, interactions) {
- if (interactions.size > 0) {
- var pendingInteractionMap = root.pendingInteractionMap;
- var pendingInteractions = pendingInteractionMap.get(expirationTime);
+ if (candidateType !== null) {
+ var family = resolveFamily(candidateType);
- if (pendingInteractions != null) {
- interactions.forEach(function(interaction) {
- if (!pendingInteractions.has(interaction)) {
- // Update the pending async work count for previously unscheduled interaction.
- interaction.__count++;
+ if (family !== undefined) {
+ if (staleFamilies.has(family)) {
+ needsRemount = true;
+ } else if (updatedFamilies.has(family)) {
+ if (tag === ClassComponent) {
+ needsRemount = true;
+ } else {
+ needsRender = true;
+ }
}
+ }
+ }
- pendingInteractions.add(interaction);
- });
- } else {
- pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions.
+ if (failedBoundaries !== null) {
+ if (
+ failedBoundaries.has(fiber) ||
+ (alternate !== null && failedBoundaries.has(alternate))
+ ) {
+ needsRemount = true;
+ }
+ }
- interactions.forEach(function(interaction) {
- interaction.__count++;
- });
+ if (needsRemount) {
+ fiber._debugNeedsRemount = true;
}
- var subscriber = tracing.__subscriberRef.current;
+ if (needsRemount || needsRender) {
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
+ }
- if (subscriber !== null) {
- var threadID = computeThreadID(root, expirationTime);
- subscriber.onWorkScheduled(interactions, threadID);
+ if (child !== null && !needsRemount) {
+ scheduleFibersWithFamiliesRecursively(
+ child,
+ updatedFamilies,
+ staleFamilies
+ );
}
- }
-}
-function schedulePendingInteractions(root, expirationTime) {
- scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
+ if (sibling !== null) {
+ scheduleFibersWithFamiliesRecursively(
+ sibling,
+ updatedFamilies,
+ staleFamilies
+ );
+ }
+ }
}
-function startWorkOnPendingInteractions(root, expirationTime) {
- // we can accurately attribute time spent working on it, And so that cascading
- // work triggered during the render phase will be associated with it.
+var findHostInstancesForRefresh = function(root, families) {
+ {
+ var hostInstances = new Set();
+ var types = new Set(
+ families.map(function(family) {
+ return family.current;
+ })
+ );
+ findHostInstancesForMatchingFibersRecursively(
+ root.current,
+ types,
+ hostInstances
+ );
+ return hostInstances;
+ }
+};
- var interactions = new Set();
- root.pendingInteractionMap.forEach(function(
- scheduledInteractions,
- scheduledExpirationTime
- ) {
- if (scheduledExpirationTime >= expirationTime) {
- scheduledInteractions.forEach(function(interaction) {
- return interactions.add(interaction);
- });
- }
- }); // Store the current set of interactions on the FiberRoot for a few reasons:
- // We can re-use it in hot functions like performConcurrentWorkOnRoot()
- // without having to recalculate it. We will also use it in commitWork() to
- // pass to any Profiler onRender() hooks. This also provides DevTools with a
- // way to access it when the onCommitRoot() hook is called.
+function findHostInstancesForMatchingFibersRecursively(
+ fiber,
+ types,
+ hostInstances
+) {
+ {
+ var child = fiber.child,
+ sibling = fiber.sibling,
+ tag = fiber.tag,
+ type = fiber.type;
+ var candidateType = null;
- root.memoizedInteractions = interactions;
+ switch (tag) {
+ case FunctionComponent:
+ case SimpleMemoComponent:
+ case ClassComponent:
+ candidateType = type;
+ break;
- if (interactions.size > 0) {
- var subscriber = tracing.__subscriberRef.current;
+ case ForwardRef:
+ candidateType = type.render;
+ break;
+ }
- if (subscriber !== null) {
- var threadID = computeThreadID(root, expirationTime);
+ var didMatch = false;
- try {
- subscriber.onWorkStarted(interactions, threadID);
- } catch (error) {
- // If the subscriber throws, rethrow it in a separate task
- scheduleCallback(ImmediatePriority, function() {
- throw error;
- });
+ if (candidateType !== null) {
+ if (types.has(candidateType)) {
+ didMatch = true;
}
}
- }
-}
-function finishPendingInteractions(root, committedExpirationTime) {
- var earliestRemainingTimeAfterCommit = root.firstPendingTime;
- var subscriber;
-
- try {
- subscriber = tracing.__subscriberRef.current;
-
- if (subscriber !== null && root.memoizedInteractions.size > 0) {
- var threadID = computeThreadID(root, committedExpirationTime);
- subscriber.onWorkStopped(root.memoizedInteractions, threadID);
+ if (didMatch) {
+ // We have a match. This only drills down to the closest host components.
+ // There's no need to search deeper because for the purpose of giving
+ // visual feedback, "flashing" outermost parent rectangles is sufficient.
+ findHostInstancesForFiberShallowly(fiber, hostInstances);
+ } else {
+ // If there's no match, maybe there will be one further down in the child tree.
+ if (child !== null) {
+ findHostInstancesForMatchingFibersRecursively(
+ child,
+ types,
+ hostInstances
+ );
+ }
}
- } catch (error) {
- // If the subscriber throws, rethrow it in a separate task
- scheduleCallback(ImmediatePriority, function() {
- throw error;
- });
- } finally {
- // Clear completed interactions from the pending Map.
- // Unless the render was suspended or cascading work was scheduled,
- // In which case– leave pending interactions until the subsequent render.
- var pendingInteractionMap = root.pendingInteractionMap;
- pendingInteractionMap.forEach(function(
- scheduledInteractions,
- scheduledExpirationTime
- ) {
- // Only decrement the pending interaction count if we're done.
- // If there's still work at the current priority,
- // That indicates that we are waiting for suspense data.
- if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
- pendingInteractionMap.delete(scheduledExpirationTime);
- scheduledInteractions.forEach(function(interaction) {
- interaction.__count--;
- if (subscriber !== null && interaction.__count === 0) {
- try {
- subscriber.onInteractionScheduledWorkCompleted(interaction);
- } catch (error) {
- // If the subscriber throws, rethrow it in a separate task
- scheduleCallback(ImmediatePriority, function() {
- throw error;
- });
- }
- }
- });
- }
- });
+ if (sibling !== null) {
+ findHostInstancesForMatchingFibersRecursively(
+ sibling,
+ types,
+ hostInstances
+ );
+ }
}
}
-var onScheduleFiberRoot = null;
-var onCommitFiberRoot = null;
-var onCommitFiberUnmount = null;
-var hasLoggedError = false;
-var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
-function injectInternals(internals) {
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") {
- // No DevTools
- return false;
- }
+function findHostInstancesForFiberShallowly(fiber, hostInstances) {
+ {
+ var foundHostInstances = findChildHostInstancesForFiberShallowly(
+ fiber,
+ hostInstances
+ );
- var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ if (foundHostInstances) {
+ return;
+ } // If we didn't find any host children, fallback to closest host parent.
- if (hook.isDisabled) {
- // This isn't a real property on the hook, but it can be set to opt out
- // of DevTools integration and associated warnings and logs.
- // https://github.com/facebook/react/issues/3877
- return true;
- }
+ var node = fiber;
- if (!hook.supportsFiber) {
- {
- error(
- "The installed version of React DevTools is too old and will not work " +
- "with the current version of React. Please update React DevTools. " +
- "https://fb.me/react-devtools"
- );
- } // DevTools exists, even though it doesn't support Fiber.
+ while (true) {
+ switch (node.tag) {
+ case HostComponent:
+ hostInstances.add(node.stateNode);
+ return;
- return true;
- }
+ case HostPortal:
+ hostInstances.add(node.stateNode.containerInfo);
+ return;
- try {
- var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
+ case HostRoot:
+ hostInstances.add(node.stateNode.containerInfo);
+ return;
+ }
- if (true) {
- // Only used by Fast Refresh
- if (typeof hook.onScheduleFiberRoot === "function") {
- onScheduleFiberRoot = function(root, children) {
- try {
- hook.onScheduleFiberRoot(rendererID, root, children);
- } catch (err) {
- if (true && !hasLoggedError) {
- hasLoggedError = true;
-
- error("React instrumentation encountered an error: %s", err);
- }
- }
- };
+ if (node.return === null) {
+ throw new Error("Expected to reach root first.");
}
- }
- onCommitFiberRoot = function(root, expirationTime) {
- try {
- var didError = (root.current.effectTag & DidCapture) === DidCapture;
+ node = node.return;
+ }
+ }
+}
- if (enableProfilerTimer) {
- var currentTime = getCurrentTime();
- var priorityLevel = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- );
- hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
- } else {
- hook.onCommitFiberRoot(rendererID, root, undefined, didError);
- }
- } catch (err) {
- if (true) {
- if (!hasLoggedError) {
- hasLoggedError = true;
+function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
+ {
+ var node = fiber;
+ var foundHostInstances = false;
- error("React instrumentation encountered an error: %s", err);
- }
- }
+ while (true) {
+ if (node.tag === HostComponent) {
+ // We got a match.
+ foundHostInstances = true;
+ hostInstances.add(node.stateNode); // There may still be more, so keep searching.
+ } else if (node.child !== null) {
+ node.child.return = node;
+ node = node.child;
+ continue;
}
- };
- onCommitFiberUnmount = function(fiber) {
- try {
- hook.onCommitFiberUnmount(rendererID, fiber);
- } catch (err) {
- if (true) {
- if (!hasLoggedError) {
- hasLoggedError = true;
+ if (node === fiber) {
+ return foundHostInstances;
+ }
- error("React instrumentation encountered an error: %s", err);
- }
+ while (node.sibling === null) {
+ if (node.return === null || node.return === fiber) {
+ return foundHostInstances;
}
+
+ node = node.return;
}
- };
- } catch (err) {
- // Catch all errors because it is unsafe to throw during initialization.
- {
- error("React instrumentation encountered an error: %s.", err);
- }
- } // DevTools exists
- return true;
-}
-function onScheduleRoot(root, children) {
- if (typeof onScheduleFiberRoot === "function") {
- onScheduleFiberRoot(root, children);
- }
-}
-function onCommitRoot(root, expirationTime) {
- if (typeof onCommitFiberRoot === "function") {
- onCommitFiberRoot(root, expirationTime);
- }
-}
-function onCommitUnmount(fiber) {
- if (typeof onCommitFiberUnmount === "function") {
- onCommitFiberUnmount(fiber);
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
}
+
+ return false;
}
var hasBadMapPolyfill;
@@ -19117,13 +20398,11 @@ var hasBadMapPolyfill;
try {
var nonExtensibleObject = Object.preventExtensions({});
- var testMap = new Map([[nonExtensibleObject, null]]);
- var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused.
- // https://github.com/rollup/rollup/issues/1771
- // TODO: we can remove these if Rollup fixes the bug.
+ /* eslint-disable no-new */
- testMap.set(0, 0);
- testSet.add(0);
+ new Map([[nonExtensibleObject, null]]);
+ new Set([nonExtensibleObject]);
+ /* eslint-enable no-new */
} catch (e) {
// TODO: Consider warning about bad polyfills
hasBadMapPolyfill = true;
@@ -19156,8 +20435,8 @@ function FiberNode(tag, pendingProps, key, mode) {
this.nextEffect = null;
this.firstEffect = null;
this.lastEffect = null;
- this.expirationTime = NoWork;
- this.childExpirationTime = NoWork;
+ this.lanes = NoLanes;
+ this.childLanes = NoLanes;
this.alternate = null;
{
@@ -19184,15 +20463,11 @@ function FiberNode(tag, pendingProps, key, mode) {
this.actualStartTime = -1;
this.selfBaseDuration = 0;
this.treeBaseDuration = 0;
- } // This is normally DEV-only except www when it adds listeners.
- // TODO: remove the User Timing integration in favor of Root Events.
-
- {
- this._debugID = debugCounter++;
- this._debugIsCurrentlyTiming = false;
}
{
+ // This isn't directly used but is handy for debugging internals:
+ this._debugID = debugCounter++;
this._debugSource = null;
this._debugOwner = null;
this._debugNeedsRemount = false;
@@ -19272,10 +20547,7 @@ function createWorkInProgress(current, pendingProps) {
{
// DEV-only fields
- {
- workInProgress._debugID = current._debugID;
- }
-
+ workInProgress._debugID = current._debugID;
workInProgress._debugSource = current._debugSource;
workInProgress._debugOwner = current._debugOwner;
workInProgress._debugHookTypes = current._debugHookTypes;
@@ -19284,7 +20556,9 @@ function createWorkInProgress(current, pendingProps) {
workInProgress.alternate = current;
current.alternate = workInProgress;
} else {
- workInProgress.pendingProps = pendingProps; // We already have an alternate.
+ workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type.
+
+ workInProgress.type = current.type; // We already have an alternate.
// Reset the effect tag.
workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
@@ -19303,21 +20577,8 @@ function createWorkInProgress(current, pendingProps) {
}
}
- {
- // Trying to debug a mysterious internal-only production failure.
- // See D20130868 and t62461245.
- // This is only on for RN FB builds.
- if (current == null) {
- throw Error("current is " + current + " but it can't be");
- }
-
- if (workInProgress == null) {
- throw Error("workInProgress is " + workInProgress + " but it can't be");
- }
- }
-
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
@@ -19329,7 +20590,7 @@ function createWorkInProgress(current, pendingProps) {
currentDependencies === null
? null
: {
- expirationTime: currentDependencies.expirationTime,
+ lanes: currentDependencies.lanes,
firstContext: currentDependencies.firstContext,
responders: currentDependencies.responders
}; // These will be overridden during the parent's reconciliation
@@ -19366,7 +20627,7 @@ function createWorkInProgress(current, pendingProps) {
return workInProgress;
} // Used to reuse a Fiber for a second pass.
-function resetWorkInProgress(workInProgress, renderExpirationTime) {
+function resetWorkInProgress(workInProgress, renderLanes) {
// This resets the Fiber to what createFiber or createWorkInProgress would
// have set the values to before during the first pass. Ideally this wouldn't
// be necessary but unfortunately many code paths reads from the workInProgress
@@ -19384,13 +20645,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) {
if (current === null) {
// Reset to createFiber's initial values.
- workInProgress.childExpirationTime = NoWork;
- workInProgress.expirationTime = renderExpirationTime;
+ workInProgress.childLanes = NoLanes;
+ workInProgress.lanes = renderLanes;
workInProgress.child = null;
workInProgress.memoizedProps = null;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
workInProgress.dependencies = null;
+ workInProgress.stateNode = null;
{
// Note: We don't reset the actualTime counts. It's useful to accumulate
@@ -19400,12 +20662,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) {
}
} else {
// Reset to the cloned values that createWorkInProgress would've.
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
- workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
+ workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type.
+
+ workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so
// it cannot be shared with the current fiber.
var currentDependencies = current.dependencies;
@@ -19413,7 +20677,7 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) {
currentDependencies === null
? null
: {
- expirationTime: currentDependencies.expirationTime,
+ lanes: currentDependencies.lanes,
firstContext: currentDependencies.firstContext,
responders: currentDependencies.responders
};
@@ -19454,9 +20718,8 @@ function createFiberFromTypeAndProps(
pendingProps,
owner,
mode,
- expirationTime
+ lanes
) {
- var fiber;
var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
var resolvedType = type;
@@ -19478,16 +20741,11 @@ function createFiberFromTypeAndProps(
} else {
getTag: switch (type) {
case REACT_FRAGMENT_TYPE:
- return createFiberFromFragment(
- pendingProps.children,
- mode,
- expirationTime,
- key
- );
+ return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_CONCURRENT_MODE_TYPE:
+ case REACT_DEBUG_TRACING_MODE_TYPE:
fiberTag = Mode;
- mode |= ConcurrentMode | BlockingMode | StrictMode;
+ mode |= DebugTracingMode;
break;
case REACT_STRICT_MODE_TYPE:
@@ -19496,18 +20754,23 @@ function createFiberFromTypeAndProps(
break;
case REACT_PROFILER_TYPE:
- return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
+ return createFiberFromProfiler(pendingProps, mode, lanes, key);
case REACT_SUSPENSE_TYPE:
- return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
+ return createFiberFromSuspense(pendingProps, mode, lanes, key);
case REACT_SUSPENSE_LIST_TYPE:
- return createFiberFromSuspenseList(
- pendingProps,
- mode,
- expirationTime,
- key
- );
+ return createFiberFromSuspenseList(pendingProps, mode, lanes, key);
+
+ case REACT_OFFSCREEN_TYPE:
+ return createFiberFromOffscreen(pendingProps, mode, lanes, key);
+
+ case REACT_LEGACY_HIDDEN_TYPE:
+ return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
+
+ case REACT_SCOPE_TYPE:
+
+ // eslint-disable-next-line no-fallthrough
default: {
if (typeof type === "object" && type !== null) {
@@ -19579,13 +20842,13 @@ function createFiberFromTypeAndProps(
}
}
- fiber = createFiber(fiberTag, pendingProps, key, mode);
+ var fiber = createFiber(fiberTag, pendingProps, key, mode);
fiber.elementType = type;
fiber.type = resolvedType;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromElement(element, mode, expirationTime) {
+function createFiberFromElement(element, mode, lanes) {
var owner = null;
{
@@ -19601,7 +20864,7 @@ function createFiberFromElement(element, mode, expirationTime) {
pendingProps,
owner,
mode,
- expirationTime
+ lanes
);
{
@@ -19611,13 +20874,13 @@ function createFiberFromElement(element, mode, expirationTime) {
return fiber;
}
-function createFiberFromFragment(elements, mode, expirationTime, key) {
+function createFiberFromFragment(elements, mode, lanes, key) {
var fiber = createFiber(Fragment, elements, key, mode);
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
+function createFiberFromProfiler(pendingProps, mode, lanes, key) {
{
if (typeof pendingProps.id !== "string") {
error('Profiler must specify an "id" as a prop');
@@ -19628,7 +20891,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
fiber.elementType = REACT_PROFILER_TYPE;
fiber.type = REACT_PROFILER_TYPE;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
{
fiber.stateNode = {
@@ -19640,17 +20903,17 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
return fiber;
}
-function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
+function createFiberFromSuspense(pendingProps, mode, lanes, key) {
var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
// This needs to be fixed in getComponentName so that it relies on the tag
// instead.
fiber.type = REACT_SUSPENSE_TYPE;
fiber.elementType = REACT_SUSPENSE_TYPE;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
+function createFiberFromSuspenseList(pendingProps, mode, lanes, key) {
var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
{
@@ -19661,18 +20924,44 @@ function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
}
fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
+ return fiber;
+}
+function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
+ var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag.
+ // This needs to be fixed in getComponentName so that it relies on the tag
+ // instead.
+
+ {
+ fiber.type = REACT_OFFSCREEN_TYPE;
+ }
+
+ fiber.elementType = REACT_OFFSCREEN_TYPE;
+ fiber.lanes = lanes;
+ return fiber;
+}
+function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) {
+ var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag.
+ // This needs to be fixed in getComponentName so that it relies on the tag
+ // instead.
+
+ {
+ fiber.type = REACT_LEGACY_HIDDEN_TYPE;
+ }
+
+ fiber.elementType = REACT_LEGACY_HIDDEN_TYPE;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromText(content, mode, expirationTime) {
+function createFiberFromText(content, mode, lanes) {
var fiber = createFiber(HostText, content, null, mode);
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromPortal(portal, mode, expirationTime) {
+function createFiberFromPortal(portal, mode, lanes) {
var pendingProps = portal.children !== null ? portal.children : [];
var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
fiber.stateNode = {
containerInfo: portal.containerInfo,
pendingChildren: null,
@@ -19713,8 +21002,8 @@ function assignFiberPropertiesInDEV(target, source) {
target.nextEffect = source.nextEffect;
target.firstEffect = source.firstEffect;
target.lastEffect = source.lastEffect;
- target.expirationTime = source.expirationTime;
- target.childExpirationTime = source.childExpirationTime;
+ target.lanes = source.lanes;
+ target.childLanes = source.childLanes;
target.alternate = source.alternate;
{
@@ -19724,11 +21013,7 @@ function assignFiberPropertiesInDEV(target, source) {
target.treeBaseDuration = source.treeBaseDuration;
}
- {
- target._debugID = source._debugID;
- target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
- }
-
+ target._debugID = source._debugID;
target._debugSource = source._debugSource;
target._debugOwner = source._debugOwner;
target._debugNeedsRemount = source._debugNeedsRemount;
@@ -19738,30 +21023,49 @@ function assignFiberPropertiesInDEV(target, source) {
function FiberRootNode(containerInfo, tag, hydrate) {
this.tag = tag;
- this.current = null;
this.containerInfo = containerInfo;
this.pendingChildren = null;
+ this.current = null;
this.pingCache = null;
- this.finishedExpirationTime = NoWork;
this.finishedWork = null;
this.timeoutHandle = noTimeout;
this.context = null;
this.pendingContext = null;
this.hydrate = hydrate;
this.callbackNode = null;
- this.callbackPriority = NoPriority;
- this.firstPendingTime = NoWork;
- this.firstSuspendedTime = NoWork;
- this.lastSuspendedTime = NoWork;
- this.nextKnownPendingLevel = NoWork;
- this.lastPingedTime = NoWork;
- this.lastExpiredTime = NoWork;
+ this.callbackPriority = NoLanePriority;
+ this.eventTimes = createLaneMap(NoLanes);
+ this.expirationTimes = createLaneMap(NoTimestamp);
+ this.pendingLanes = NoLanes;
+ this.suspendedLanes = NoLanes;
+ this.pingedLanes = NoLanes;
+ this.expiredLanes = NoLanes;
+ this.mutableReadLanes = NoLanes;
+ this.finishedLanes = NoLanes;
+ this.entangledLanes = NoLanes;
+ this.entanglements = createLaneMap(NoLanes);
{
this.interactionThreadID = tracing.unstable_getThreadID();
this.memoizedInteractions = new Set();
this.pendingInteractionMap = new Map();
}
+
+ {
+ switch (tag) {
+ case BlockingRoot:
+ this._debugRootType = "createBlockingRoot()";
+ break;
+
+ case ConcurrentRoot:
+ this._debugRootType = "createRoot()";
+ break;
+
+ case LegacyRoot:
+ this._debugRootType = "createLegacyRoot()";
+ break;
+ }
+ }
}
function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
@@ -19774,95 +21078,22 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
initializeUpdateQueue(uninitializedFiber);
return root;
}
-function isRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- var lastSuspendedTime = root.lastSuspendedTime;
- return (
- firstSuspendedTime !== NoWork &&
- firstSuspendedTime >= expirationTime &&
- lastSuspendedTime <= expirationTime
- );
-}
-function markRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- var lastSuspendedTime = root.lastSuspendedTime;
-
- if (firstSuspendedTime < expirationTime) {
- root.firstSuspendedTime = expirationTime;
- }
-
- if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
- root.lastSuspendedTime = expirationTime;
- }
-
- if (expirationTime <= root.lastPingedTime) {
- root.lastPingedTime = NoWork;
- }
-
- if (expirationTime <= root.lastExpiredTime) {
- root.lastExpiredTime = NoWork;
- }
-}
-function markRootUpdatedAtTime(root, expirationTime) {
- // Update the range of pending times
- var firstPendingTime = root.firstPendingTime;
-
- if (expirationTime > firstPendingTime) {
- root.firstPendingTime = expirationTime;
- } // Update the range of suspended times. Treat everything lower priority or
- // equal to this update as unsuspended.
-
- var firstSuspendedTime = root.firstSuspendedTime;
-
- if (firstSuspendedTime !== NoWork) {
- if (expirationTime >= firstSuspendedTime) {
- // The entire suspended range is now unsuspended.
- root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
- } else if (expirationTime >= root.lastSuspendedTime) {
- root.lastSuspendedTime = expirationTime + 1;
- } // This is a pending level. Check if it's higher priority than the next
- // known pending level.
- if (expirationTime > root.nextKnownPendingLevel) {
- root.nextKnownPendingLevel = expirationTime;
- }
- }
-}
-function markRootFinishedAtTime(
- root,
- finishedExpirationTime,
- remainingExpirationTime
+function createPortal(
+ children,
+ containerInfo, // TODO: figure out the API for cross-renderer implementation.
+ implementation
) {
- // Update the range of pending times
- root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or
- // equal to this update as unsuspended.
-
- if (finishedExpirationTime <= root.lastSuspendedTime) {
- // The entire suspended range is now unsuspended.
- root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
- } else if (finishedExpirationTime <= root.firstSuspendedTime) {
- // Part of the suspended range is now unsuspended. Narrow the range to
- // include everything between the unsuspended time (non-inclusive) and the
- // last suspended time.
- root.firstSuspendedTime = finishedExpirationTime - 1;
- }
-
- if (finishedExpirationTime <= root.lastPingedTime) {
- // Clear the pinged time
- root.lastPingedTime = NoWork;
- }
-
- if (finishedExpirationTime <= root.lastExpiredTime) {
- // Clear the expired time
- root.lastExpiredTime = NoWork;
- }
-}
-function markRootExpiredAtTime(root, expirationTime) {
- var lastExpiredTime = root.lastExpiredTime;
-
- if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
- root.lastExpiredTime = expirationTime;
- }
+ var key =
+ arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
+ return {
+ // This tag allow us to uniquely identify this as a React Portal
+ $$typeof: REACT_PORTAL_TYPE,
+ key: key == null ? null : "" + key,
+ children: children,
+ containerInfo: containerInfo,
+ implementation: implementation
+ };
}
var didWarnAboutNestedUpdates;
@@ -19922,31 +21153,42 @@ function findHostInstanceWithWarning(component, methodName) {
if (!didWarnAboutFindNodeInStrictMode[componentName]) {
didWarnAboutFindNodeInStrictMode[componentName] = true;
+ var previousFiber = current;
- if (fiber.mode & StrictMode) {
- error(
- "%s is deprecated in StrictMode. " +
- "%s was passed an instance of %s which is inside StrictMode. " +
- "Instead, add a ref directly to the element you want to reference. " +
- "Learn more about using refs safely here: " +
- "https://fb.me/react-strict-mode-find-node%s",
- methodName,
- methodName,
- componentName,
- getStackByFiberInDevAndProd(hostFiber)
- );
- } else {
- error(
- "%s is deprecated in StrictMode. " +
- "%s was passed an instance of %s which renders StrictMode children. " +
- "Instead, add a ref directly to the element you want to reference. " +
- "Learn more about using refs safely here: " +
- "https://fb.me/react-strict-mode-find-node%s",
- methodName,
- methodName,
- componentName,
- getStackByFiberInDevAndProd(hostFiber)
- );
+ try {
+ setCurrentFiber(hostFiber);
+
+ if (fiber.mode & StrictMode) {
+ error(
+ "%s is deprecated in StrictMode. " +
+ "%s was passed an instance of %s which is inside StrictMode. " +
+ "Instead, add a ref directly to the element you want to reference. " +
+ "Learn more about using refs safely here: " +
+ "https://fb.me/react-strict-mode-find-node",
+ methodName,
+ methodName,
+ componentName
+ );
+ } else {
+ error(
+ "%s is deprecated in StrictMode. " +
+ "%s was passed an instance of %s which renders StrictMode children. " +
+ "Instead, add a ref directly to the element you want to reference. " +
+ "Learn more about using refs safely here: " +
+ "https://fb.me/react-strict-mode-find-node",
+ methodName,
+ methodName,
+ componentName
+ );
+ }
+ } finally {
+ // Ideally this should reset to previous but this shouldn't be called in
+ // render and there's another warning for that anyway.
+ if (previousFiber) {
+ setCurrentFiber(previousFiber);
+ } else {
+ resetCurrentFiber();
+ }
}
}
}
@@ -19964,7 +21206,7 @@ function updateContainer(element, container, parentComponent, callback) {
}
var current$1 = container.current;
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
{
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
@@ -19974,11 +21216,8 @@ function updateContainer(element, container, parentComponent, callback) {
}
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- current$1,
- suspenseConfig
- );
+ var lane = requestUpdateLane(current$1, suspenseConfig);
+
var context = getContextForSubtree(parentComponent);
if (container.context === null) {
@@ -20001,7 +21240,7 @@ function updateContainer(element, container, parentComponent, callback) {
}
}
- var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property
+ var update = createUpdate(eventTime, lane, suspenseConfig); // Caution: React DevTools currently depends on this property
// being called "element".
update.payload = {
@@ -20024,8 +21263,8 @@ function updateContainer(element, container, parentComponent, callback) {
}
enqueueUpdate(current$1, update);
- scheduleWork(current$1, expirationTime);
- return expirationTime;
+ scheduleUpdateOnFiber(current$1, lane, eventTime);
+ return lane;
}
function getPublicRootInstance(container) {
var containerFiber = container.current;
@@ -20092,7 +21331,7 @@ var setSuspenseHandler = null;
// Shallow cloning props works as a workaround for now to bypass the bailout check.
fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
- scheduleWork(fiber, Sync);
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
}; // Support DevTools props for function components, forwardRef, memo, host components, etc.
@@ -20103,11 +21342,11 @@ var setSuspenseHandler = null;
fiber.alternate.pendingProps = fiber.pendingProps;
}
- scheduleWork(fiber, Sync);
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
};
scheduleUpdate = function(fiber) {
- scheduleWork(fiber, Sync);
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
};
setSuspenseHandler = function(newShouldSuspendImpl) {
@@ -20115,6 +21354,24 @@ var setSuspenseHandler = null;
};
}
+function findHostInstanceByFiber(fiber) {
+ var hostFiber = findCurrentHostFiber(fiber);
+
+ if (hostFiber === null) {
+ return null;
+ }
+
+ return hostFiber.stateNode;
+}
+
+function emptyFindFiberByHostInstance(instance) {
+ return null;
+}
+
+function getCurrentFiberForDevTools() {
+ return current;
+}
+
function injectIntoDevTools(devToolsConfig) {
var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
@@ -20128,55 +21385,21 @@ function injectIntoDevTools(devToolsConfig) {
setSuspenseHandler: setSuspenseHandler,
scheduleUpdate: scheduleUpdate,
currentDispatcherRef: ReactCurrentDispatcher,
- findHostInstanceByFiber: function(fiber) {
- var hostFiber = findCurrentHostFiber(fiber);
-
- if (hostFiber === null) {
- return null;
- }
-
- return hostFiber.stateNode;
- },
- findFiberByHostInstance: function(instance) {
- if (!findFiberByHostInstance) {
- // Might not be implemented by the renderer.
- return null;
- }
-
- return findFiberByHostInstance(instance);
- },
+ findHostInstanceByFiber: findHostInstanceByFiber,
+ findFiberByHostInstance:
+ findFiberByHostInstance || emptyFindFiberByHostInstance,
// React Refresh
findHostInstancesForRefresh: findHostInstancesForRefresh,
scheduleRefresh: scheduleRefresh,
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
// Enables DevTools to append owner stacks to error messages in DEV mode.
- getCurrentFiber: function() {
- return current;
- }
+ getCurrentFiber: getCurrentFiberForDevTools
});
}
-var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing;
-
-function createPortal(
- children,
- containerInfo, // TODO: figure out the API for cross-renderer implementation.
- implementation
-) {
- var key =
- arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
- return {
- // This tag allow us to uniquely identify this as a React Portal
- $$typeof: REACT_PORTAL_TYPE,
- key: key == null ? null : "" + key,
- children: children,
- containerInfo: containerInfo,
- implementation: implementation
- };
-}
// TODO: this is special because it gets imported during build.
-var ReactVersion = "16.13.0";
+var ReactVersion = "17.0.0-alpha.0";
var instanceCache = new Map();
@@ -20413,7 +21636,7 @@ var getInspectorDataForViewAtPoint;
);
} else {
error(
- "getInspectorDataForViewAtPoint expects to receieve a host component"
+ "getInspectorDataForViewAtPoint expects to receive a host component"
);
return;
diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js
index 278eba5fa3c464..d8543ccecd0b3d 100644
--- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js
+++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js
@@ -15,16 +15,6 @@ require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore");
var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"),
React = require("react"),
Scheduler = require("scheduler");
-function getParent(inst) {
- do inst = inst.return;
- while (inst && 5 !== inst.tag);
- return inst ? inst : null;
-}
-function traverseTwoPhase(inst, fn, arg) {
- for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
- for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
- for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
-}
function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) {
var funcArgs = Array.prototype.slice.call(arguments, 3);
try {
@@ -95,109 +85,6 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
-function getListener(inst, registrationName) {
- var listener = inst.stateNode;
- if (!listener) return null;
- var props = getFiberCurrentPropsFromNode(listener);
- if (!props) return null;
- listener = props[registrationName];
- a: switch (registrationName) {
- case "onClick":
- case "onClickCapture":
- case "onDoubleClick":
- case "onDoubleClickCapture":
- case "onMouseDown":
- case "onMouseDownCapture":
- case "onMouseMove":
- case "onMouseMoveCapture":
- case "onMouseUp":
- case "onMouseUpCapture":
- case "onMouseEnter":
- (props = !props.disabled) ||
- ((inst = inst.type),
- (props = !(
- "button" === inst ||
- "input" === inst ||
- "select" === inst ||
- "textarea" === inst
- )));
- inst = !props;
- break a;
- default:
- inst = !1;
- }
- if (inst) return null;
- if (listener && "function" !== typeof listener)
- throw Error(
- "Expected `" +
- registrationName +
- "` listener to be a function, instead got a value of `" +
- typeof listener +
- "` type."
- );
- return listener;
-}
-function accumulateInto(current, next) {
- if (null == next)
- throw Error(
- "accumulateInto(...): Accumulated items must not be null or undefined."
- );
- if (null == current) return next;
- if (Array.isArray(current)) {
- if (Array.isArray(next)) return current.push.apply(current, next), current;
- current.push(next);
- return current;
- }
- return Array.isArray(next) ? [current].concat(next) : [current, next];
-}
-function forEachAccumulated(arr, cb, scope) {
- Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
-}
-function accumulateDirectionalDispatches(inst, phase, event) {
- if (
- (phase = getListener(
- inst,
- event.dispatchConfig.phasedRegistrationNames[phase]
- ))
- )
- (event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- phase
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- ));
-}
-function accumulateTwoPhaseDispatchesSingle(event) {
- event &&
- event.dispatchConfig.phasedRegistrationNames &&
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
-}
-function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- var targetInst = event._targetInst;
- targetInst = targetInst ? getParent(targetInst) : null;
- traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
- }
-}
-function accumulateDirectDispatchesSingle(event) {
- if (event && event.dispatchConfig.registrationName) {
- var inst = event._targetInst;
- if (inst && event && event.dispatchConfig.registrationName) {
- var listener = getListener(inst, event.dispatchConfig.registrationName);
- listener &&
- ((event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- )));
- }
- }
-}
function functionThatReturnsTrue() {
return !0;
}
@@ -213,6 +100,7 @@ function SyntheticEvent(
this.dispatchConfig = dispatchConfig;
this._targetInst = targetInst;
this.nativeEvent = nativeEvent;
+ this._dispatchInstances = this._dispatchListeners = null;
dispatchConfig = this.constructor.Interface;
for (var propName in dispatchConfig)
dispatchConfig.hasOwnProperty(propName) &&
@@ -292,7 +180,12 @@ SyntheticEvent.extend = function(Interface) {
return Class;
};
addEventPoolingTo(SyntheticEvent);
-function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
+function createOrGetPooledEvent(
+ dispatchConfig,
+ targetInst,
+ nativeEvent,
+ nativeInst
+) {
if (this.eventPool.length) {
var instance = this.eventPool.pop();
this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
@@ -309,8 +202,8 @@ function releasePooledEvent(event) {
10 > this.eventPool.length && this.eventPool.push(event);
}
function addEventPoolingTo(EventConstructor) {
+ EventConstructor.getPooled = createOrGetPooledEvent;
EventConstructor.eventPool = [];
- EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}
var ResponderSyntheticEvent = SyntheticEvent.extend({
@@ -438,6 +331,22 @@ function accumulate(current, next) {
? [current].concat(next)
: [current, next];
}
+function accumulateInto(current, next) {
+ if (null == next)
+ throw Error(
+ "accumulateInto(...): Accumulated items must not be null or undefined."
+ );
+ if (null == current) return next;
+ if (Array.isArray(current)) {
+ if (Array.isArray(next)) return current.push.apply(current, next), current;
+ current.push(next);
+ return current;
+ }
+ return Array.isArray(next) ? [current].concat(next) : [current, next];
+}
+function forEachAccumulated(arr, cb, scope) {
+ Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
+}
var responderInst = null,
trackedTouchCount = 0;
function changeResponder(nextResponderInst, blockHostResponder) {
@@ -451,65 +360,132 @@ function changeResponder(nextResponderInst, blockHostResponder) {
);
}
var eventTypes = {
- startShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onStartShouldSetResponder",
- captured: "onStartShouldSetResponderCapture"
- },
- dependencies: startDependencies
- },
- scrollShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onScrollShouldSetResponder",
- captured: "onScrollShouldSetResponderCapture"
- },
- dependencies: ["topScroll"]
- },
- selectionChangeShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onSelectionChangeShouldSetResponder",
- captured: "onSelectionChangeShouldSetResponderCapture"
- },
- dependencies: ["topSelectionChange"]
- },
- moveShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onMoveShouldSetResponder",
- captured: "onMoveShouldSetResponderCapture"
- },
- dependencies: moveDependencies
- },
- responderStart: {
- registrationName: "onResponderStart",
- dependencies: startDependencies
- },
- responderMove: {
- registrationName: "onResponderMove",
- dependencies: moveDependencies
- },
- responderEnd: {
- registrationName: "onResponderEnd",
- dependencies: endDependencies
+ startShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onStartShouldSetResponder",
+ captured: "onStartShouldSetResponderCapture"
},
- responderRelease: {
- registrationName: "onResponderRelease",
- dependencies: endDependencies
+ dependencies: startDependencies
+ },
+ scrollShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onScrollShouldSetResponder",
+ captured: "onScrollShouldSetResponderCapture"
},
- responderTerminationRequest: {
- registrationName: "onResponderTerminationRequest",
- dependencies: []
+ dependencies: ["topScroll"]
+ },
+ selectionChangeShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onSelectionChangeShouldSetResponder",
+ captured: "onSelectionChangeShouldSetResponderCapture"
},
- responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
- responderReject: {
- registrationName: "onResponderReject",
- dependencies: []
+ dependencies: ["topSelectionChange"]
+ },
+ moveShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onMoveShouldSetResponder",
+ captured: "onMoveShouldSetResponderCapture"
},
- responderTerminate: {
- registrationName: "onResponderTerminate",
- dependencies: []
- }
+ dependencies: moveDependencies
+ },
+ responderStart: {
+ registrationName: "onResponderStart",
+ dependencies: startDependencies
+ },
+ responderMove: {
+ registrationName: "onResponderMove",
+ dependencies: moveDependencies
+ },
+ responderEnd: {
+ registrationName: "onResponderEnd",
+ dependencies: endDependencies
+ },
+ responderRelease: {
+ registrationName: "onResponderRelease",
+ dependencies: endDependencies
},
- ResponderEventPlugin = {
+ responderTerminationRequest: {
+ registrationName: "onResponderTerminationRequest",
+ dependencies: []
+ },
+ responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
+ responderReject: { registrationName: "onResponderReject", dependencies: [] },
+ responderTerminate: {
+ registrationName: "onResponderTerminate",
+ dependencies: []
+ }
+};
+function getParent(inst) {
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ return inst ? inst : null;
+}
+function traverseTwoPhase(inst, fn, arg) {
+ for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
+}
+function getListener(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+function accumulateDirectionalDispatches(inst, phase, event) {
+ if (
+ (phase = getListener(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateDirectDispatchesSingle(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
+function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ var targetInst = event._targetInst;
+ targetInst = targetInst ? getParent(targetInst) : null;
+ traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
+ }
+}
+function accumulateTwoPhaseDispatchesSingle(event) {
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
+}
+var ResponderEventPlugin = {
_getResponder: function() {
return responderInst;
},
@@ -570,68 +546,70 @@ var eventTypes = {
JSCompiler_temp = null;
}
else JSCompiler_temp = targetInst;
- targetInst = JSCompiler_temp === responderInst;
- JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ targetInst = JSCompiler_temp;
+ JSCompiler_temp = targetInst === responderInst;
+ shouldSetEventType = ResponderSyntheticEvent.getPooled(
shouldSetEventType,
- JSCompiler_temp,
+ targetInst,
nativeEvent,
nativeEventTarget
);
- JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory;
- targetInst
+ shouldSetEventType.touchHistory =
+ ResponderTouchHistoryStore.touchHistory;
+ JSCompiler_temp
? forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingleSkipTarget
)
: forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingle
);
b: {
- shouldSetEventType = JSCompiler_temp._dispatchListeners;
- targetInst = JSCompiler_temp._dispatchInstances;
- if (Array.isArray(shouldSetEventType))
+ JSCompiler_temp = shouldSetEventType._dispatchListeners;
+ targetInst = shouldSetEventType._dispatchInstances;
+ if (Array.isArray(JSCompiler_temp))
for (
depthA = 0;
- depthA < shouldSetEventType.length &&
- !JSCompiler_temp.isPropagationStopped();
+ depthA < JSCompiler_temp.length &&
+ !shouldSetEventType.isPropagationStopped();
depthA++
) {
if (
- shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA])
+ JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA])
) {
- shouldSetEventType = targetInst[depthA];
+ JSCompiler_temp = targetInst[depthA];
break b;
}
}
else if (
- shouldSetEventType &&
- shouldSetEventType(JSCompiler_temp, targetInst)
+ JSCompiler_temp &&
+ JSCompiler_temp(shouldSetEventType, targetInst)
) {
- shouldSetEventType = targetInst;
+ JSCompiler_temp = targetInst;
break b;
}
- shouldSetEventType = null;
+ JSCompiler_temp = null;
}
- JSCompiler_temp._dispatchInstances = null;
- JSCompiler_temp._dispatchListeners = null;
- JSCompiler_temp.isPersistent() ||
- JSCompiler_temp.constructor.release(JSCompiler_temp);
- if (shouldSetEventType && shouldSetEventType !== responderInst)
+ shouldSetEventType._dispatchInstances = null;
+ shouldSetEventType._dispatchListeners = null;
+ shouldSetEventType.isPersistent() ||
+ shouldSetEventType.constructor.release(shouldSetEventType);
+ if (JSCompiler_temp && JSCompiler_temp !== responderInst)
if (
- ((JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ ((shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderGrant,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
- (JSCompiler_temp.touchHistory =
+ (shouldSetEventType.touchHistory =
ResponderTouchHistoryStore.touchHistory),
forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateDirectDispatchesSingle
),
- (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)),
+ (targetInst = !0 === executeDirectDispatch(shouldSetEventType)),
responderInst)
)
if (
@@ -658,13 +636,13 @@ var eventTypes = {
forEachAccumulated(depthA, accumulateDirectDispatchesSingle);
var JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- [JSCompiler_temp, depthA]
+ [shouldSetEventType, depthA]
);
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
} else
(shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderReject,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
@@ -681,9 +659,9 @@ var eventTypes = {
else
(JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- JSCompiler_temp
+ shouldSetEventType
)),
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
else JSCompiler_temp$jscomp$0 = null;
} else JSCompiler_temp$jscomp$0 = null;
shouldSetEventType = responderInst && isStartish(topLevelType);
@@ -811,7 +789,6 @@ function recomputePluginOrdering() {
for (var eventName in pluginIndex) {
var JSCompiler_inline_result = void 0;
var dispatchConfig = pluginIndex[eventName],
- pluginModule$jscomp$0 = pluginModule,
eventName$jscomp$0 = eventName;
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
@@ -828,7 +805,7 @@ function recomputePluginOrdering() {
) &&
publishRegistrationName(
phasedRegistrationNames[JSCompiler_inline_result],
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
);
JSCompiler_inline_result = !0;
@@ -836,7 +813,7 @@ function recomputePluginOrdering() {
dispatchConfig.registrationName
? (publishRegistrationName(
dispatchConfig.registrationName,
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
),
(JSCompiler_inline_result = !0))
@@ -864,13 +841,75 @@ function publishRegistrationName(registrationName, pluginModule) {
}
var plugins = [],
eventNameDispatchConfigs = {},
- registrationNameModules = {},
- customBubblingEventTypes =
+ registrationNameModules = {};
+function getListener$1(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customBubblingEventTypes,
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateDirectionalDispatches$1(inst, phase, event) {
+ if (
+ (phase = getListener$1(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateTwoPhaseDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ for (var inst = event._targetInst, path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; )
+ accumulateDirectionalDispatches$1(path[inst], "captured", event);
+ for (inst = 0; inst < path.length; inst++)
+ accumulateDirectionalDispatches$1(path[inst], "bubbled", event);
+ }
+}
+function accumulateDirectDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener$1(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
if (eventPluginOrder)
throw Error(
"EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."
@@ -880,7 +919,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_92 = {
+var injectedNamesToPlugins$jscomp$inline_225 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -904,42 +943,45 @@ var injectedNamesToPlugins$jscomp$inline_92 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle);
+ forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
- forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle);
+ forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
return topLevelType;
}
}
},
- isOrderingDirty$jscomp$inline_93 = !1,
- pluginName$jscomp$inline_94;
-for (pluginName$jscomp$inline_94 in injectedNamesToPlugins$jscomp$inline_92)
+ isOrderingDirty$jscomp$inline_226 = !1,
+ pluginName$jscomp$inline_227;
+for (pluginName$jscomp$inline_227 in injectedNamesToPlugins$jscomp$inline_225)
if (
- injectedNamesToPlugins$jscomp$inline_92.hasOwnProperty(
- pluginName$jscomp$inline_94
+ injectedNamesToPlugins$jscomp$inline_225.hasOwnProperty(
+ pluginName$jscomp$inline_227
)
) {
- var pluginModule$jscomp$inline_95 =
- injectedNamesToPlugins$jscomp$inline_92[pluginName$jscomp$inline_94];
+ var pluginModule$jscomp$inline_228 =
+ injectedNamesToPlugins$jscomp$inline_225[pluginName$jscomp$inline_227];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_94) ||
- namesToPlugins[pluginName$jscomp$inline_94] !==
- pluginModule$jscomp$inline_95
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_227) ||
+ namesToPlugins[pluginName$jscomp$inline_227] !==
+ pluginModule$jscomp$inline_228
) {
- if (namesToPlugins[pluginName$jscomp$inline_94])
+ if (namesToPlugins[pluginName$jscomp$inline_227])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_94 +
+ pluginName$jscomp$inline_227 +
"`."
);
namesToPlugins[
- pluginName$jscomp$inline_94
- ] = pluginModule$jscomp$inline_95;
- isOrderingDirty$jscomp$inline_93 = !0;
+ pluginName$jscomp$inline_227
+ ] = pluginModule$jscomp$inline_228;
+ isOrderingDirty$jscomp$inline_226 = !0;
}
}
-isOrderingDirty$jscomp$inline_93 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_226 && recomputePluginOrdering();
function getInstanceFromInstance(instanceHandle) {
return instanceHandle;
}
@@ -963,31 +1005,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
}
});
var ReactSharedInternals =
- React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") ||
- (ReactSharedInternals.ReactCurrentDispatcher = { current: null });
-ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") ||
- (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null });
-var hasSymbol = "function" === typeof Symbol && Symbol.for,
- REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103,
- REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106,
- REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107,
- REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108,
- REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114,
- REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109,
- REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110,
- REACT_CONCURRENT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.concurrent_mode")
- : 60111,
- REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112,
- REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113,
- REACT_SUSPENSE_LIST_TYPE = hasSymbol
- ? Symbol.for("react.suspense_list")
- : 60120,
- REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115,
- REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116,
- REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121,
- MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ REACT_ELEMENT_TYPE = 60103,
+ REACT_PORTAL_TYPE = 60106,
+ REACT_FRAGMENT_TYPE = 60107,
+ REACT_STRICT_MODE_TYPE = 60108,
+ REACT_PROFILER_TYPE = 60114,
+ REACT_PROVIDER_TYPE = 60109,
+ REACT_CONTEXT_TYPE = 60110,
+ REACT_FORWARD_REF_TYPE = 60112,
+ REACT_SUSPENSE_TYPE = 60113,
+ REACT_SUSPENSE_LIST_TYPE = 60120,
+ REACT_MEMO_TYPE = 60115,
+ REACT_LAZY_TYPE = 60116,
+ REACT_BLOCK_TYPE = 60121,
+ REACT_DEBUG_TRACING_MODE_TYPE = 60129,
+ REACT_OFFSCREEN_TYPE = 60130,
+ REACT_LEGACY_HIDDEN_TYPE = 60131;
+if ("function" === typeof Symbol && Symbol.for) {
+ var symbolFor = Symbol.for;
+ REACT_ELEMENT_TYPE = symbolFor("react.element");
+ REACT_PORTAL_TYPE = symbolFor("react.portal");
+ REACT_FRAGMENT_TYPE = symbolFor("react.fragment");
+ REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
+ REACT_PROFILER_TYPE = symbolFor("react.profiler");
+ REACT_PROVIDER_TYPE = symbolFor("react.provider");
+ REACT_CONTEXT_TYPE = symbolFor("react.context");
+ REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
+ REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
+ REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
+ REACT_MEMO_TYPE = symbolFor("react.memo");
+ REACT_LAZY_TYPE = symbolFor("react.lazy");
+ REACT_BLOCK_TYPE = symbolFor("react.block");
+ symbolFor("react.scope");
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
+ REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
+}
+var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -995,27 +1050,6 @@ function getIteratorFn(maybeIterable) {
maybeIterable["@@iterator"];
return "function" === typeof maybeIterable ? maybeIterable : null;
}
-function initializeLazyComponentType(lazyComponent) {
- if (-1 === lazyComponent._status) {
- var ctor = lazyComponent._result;
- ctor || (ctor = lazyComponent._ctor);
- ctor = ctor();
- lazyComponent._status = 0;
- lazyComponent._result = ctor;
- ctor.then(
- function(moduleObject) {
- 0 === lazyComponent._status &&
- ((moduleObject = moduleObject.default),
- (lazyComponent._status = 1),
- (lazyComponent._result = moduleObject));
- },
- function(error) {
- 0 === lazyComponent._status &&
- ((lazyComponent._status = 2), (lazyComponent._result = error));
- }
- );
- }
-}
function getComponentName(type) {
if (null == type) return null;
if ("function" === typeof type) return type.displayName || type.name || null;
@@ -1050,10 +1084,13 @@ function getComponentName(type) {
case REACT_MEMO_TYPE:
return getComponentName(type.type);
case REACT_BLOCK_TYPE:
- return getComponentName(type.render);
+ return getComponentName(type._render);
case REACT_LAZY_TYPE:
- if ((type = 1 === type._status ? type._result : null))
- return getComponentName(type);
+ innerType = type._payload;
+ type = type._init;
+ try {
+ return getComponentName(type(innerType));
+ } catch (x) {}
}
return null;
}
@@ -1105,36 +1142,36 @@ function findCurrentFiberUsingSlowPath(fiber) {
}
if (a.return !== b.return) (a = parentA), (b = parentB);
else {
- for (var didFindChild = !1, _child = parentA.child; _child; ) {
- if (_child === a) {
+ for (var didFindChild = !1, child$0 = parentA.child; child$0; ) {
+ if (child$0 === a) {
didFindChild = !0;
a = parentA;
b = parentB;
break;
}
- if (_child === b) {
+ if (child$0 === b) {
didFindChild = !0;
b = parentA;
a = parentB;
break;
}
- _child = _child.sibling;
+ child$0 = child$0.sibling;
}
if (!didFindChild) {
- for (_child = parentB.child; _child; ) {
- if (_child === a) {
+ for (child$0 = parentB.child; child$0; ) {
+ if (child$0 === a) {
didFindChild = !0;
a = parentB;
b = parentA;
break;
}
- if (_child === b) {
+ if (child$0 === b) {
didFindChild = !0;
b = parentB;
a = parentA;
break;
}
- _child = _child.sibling;
+ child$0 = child$0.sibling;
}
if (!didFindChild)
throw Error(
@@ -1169,6 +1206,18 @@ function findCurrentHostFiber(parent) {
}
return null;
}
+function doesFiberContain(parentFiber, childFiber) {
+ for (
+ var parentFiberAlternate = parentFiber.alternate;
+ null !== childFiber;
+
+ ) {
+ if (childFiber === parentFiber || childFiber === parentFiberAlternate)
+ return !0;
+ childFiber = childFiber.return;
+ }
+ return !1;
+}
function mountSafeCallback_NOT_REALLY_SAFE(context, callback) {
return function() {
if (
@@ -1382,19 +1431,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
),
(removedKeys = null));
}
- for (var _propKey in prevProps)
- void 0 === nextProps[_propKey] &&
- (!(attributeConfig = validAttributes[_propKey]) ||
- (updatePayload && void 0 !== updatePayload[_propKey]) ||
- ((prevProp = prevProps[_propKey]),
+ for (var propKey$2 in prevProps)
+ void 0 === nextProps[propKey$2] &&
+ (!(attributeConfig = validAttributes[propKey$2]) ||
+ (updatePayload && void 0 !== updatePayload[propKey$2]) ||
+ ((prevProp = prevProps[propKey$2]),
void 0 !== prevProp &&
("object" !== typeof attributeConfig ||
"function" === typeof attributeConfig.diff ||
"function" === typeof attributeConfig.process
- ? (((updatePayload || (updatePayload = {}))[_propKey] = null),
+ ? (((updatePayload || (updatePayload = {}))[propKey$2] = null),
removedKeys || (removedKeys = {}),
- removedKeys[_propKey] ||
- ((removedKeys[_propKey] = !0), removedKeyCount++))
+ removedKeys[propKey$2] ||
+ ((removedKeys[propKey$2] = !0), removedKeyCount++))
: (updatePayload = clearNestedProperty(
updatePayload,
prevProp,
@@ -1442,37 +1491,49 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
null != stateNode && (eventTarget = stateNode.canonical);
}
batchedUpdates(function() {
- var events = eventTarget;
- for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) {
- var possiblePlugin = plugins[i];
+ var JSCompiler_inline_result = eventTarget;
+ for (
+ var events = null, legacyPlugins = plugins, i = 0;
+ i < legacyPlugins.length;
+ i++
+ ) {
+ var possiblePlugin = legacyPlugins[i];
possiblePlugin &&
(possiblePlugin = possiblePlugin.extractEvents(
topLevelType,
target,
nativeEvent,
- events,
- 1
+ JSCompiler_inline_result
)) &&
- (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin));
+ (events = accumulateInto(events, possiblePlugin));
}
- events = events$jscomp$0;
- null !== events && (eventQueue = accumulateInto(eventQueue, events));
- events = eventQueue;
+ JSCompiler_inline_result = events;
+ null !== JSCompiler_inline_result &&
+ (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result));
+ JSCompiler_inline_result = eventQueue;
eventQueue = null;
- if (events) {
- forEachAccumulated(events, executeDispatchesAndReleaseTopLevel);
+ if (JSCompiler_inline_result) {
+ forEachAccumulated(
+ JSCompiler_inline_result,
+ executeDispatchesAndReleaseTopLevel
+ );
if (eventQueue)
throw Error(
"processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
);
if (hasRethrowError)
- throw ((events = rethrowError),
+ throw ((JSCompiler_inline_result = rethrowError),
(hasRethrowError = !1),
(rethrowError = null),
- events);
+ JSCompiler_inline_result);
}
});
}
+function shim() {
+ throw Error(
+ "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue."
+ );
+}
function shim$1() {
throw Error(
"The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue."
@@ -1565,19 +1626,32 @@ var scheduleTimeout = setTimeout,
cancelTimeout = clearTimeout;
function cloneHiddenInstance(instance) {
var node = instance.node;
- var updatePayload = diffProperties(
+ var JSCompiler_inline_result = diffProperties(
null,
emptyObject,
{ style: { display: "none" } },
instance.canonical.viewConfig.validAttributes
);
return {
- node: cloneNodeWithNewProps(node, updatePayload),
+ node: cloneNodeWithNewProps(node, JSCompiler_inline_result),
canonical: instance.canonical
};
}
-var valueStack = [],
+function describeComponentFrame(name, source, ownerName) {
+ source = "";
+ ownerName && (source = " (created by " + ownerName + ")");
+ return "\n in " + (name || "Unknown") + source;
+}
+function describeFunctionComponentFrame(fn, source) {
+ return fn
+ ? describeComponentFrame(fn.displayName || fn.name || null, source, null)
+ : "";
+}
+var valueStack = [],
index = -1;
+function createCursor(defaultValue) {
+ return { current: defaultValue };
+}
function pop(cursor) {
0 > index ||
((cursor.current = valueStack[index]), (valueStack[index] = null), index--);
@@ -1588,8 +1662,8 @@ function push(cursor, value) {
cursor.current = value;
}
var emptyContextObject = {},
- contextStackCursor = { current: emptyContextObject },
- didPerformWorkStackCursor = { current: !1 },
+ contextStackCursor = createCursor(emptyContextObject),
+ didPerformWorkStackCursor = createCursor(!1),
previousContext = emptyContextObject;
function getMaskedContext(workInProgress, unmaskedContext) {
var contextTypes = workInProgress.type.contextTypes;
@@ -1669,11 +1743,220 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
+var rendererID = null,
+ injectedHook = null,
+ Scheduler_now = Scheduler.unstable_now;
+Scheduler_now();
+var return_highestLanePriority = 10;
+function getHighestPriorityLanes(lanes) {
+ if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1;
+ if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2;
+ if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4;
+ var inputDiscreteLanes = 24 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 14), inputDiscreteLanes;
+ if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32;
+ inputDiscreteLanes = 192 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 12), inputDiscreteLanes;
+ if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256;
+ inputDiscreteLanes = 3584 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 10), inputDiscreteLanes;
+ if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096;
+ inputDiscreteLanes = 122880 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 8), inputDiscreteLanes;
+ if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072;
+ inputDiscreteLanes = 3932160 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 6), inputDiscreteLanes;
+ inputDiscreteLanes = 62914560 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 5), inputDiscreteLanes;
+ if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864;
+ if (0 !== (lanes & 134217728))
+ return (return_highestLanePriority = 3), 134217728;
+ inputDiscreteLanes = 805306368 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 2), inputDiscreteLanes;
+ if (0 !== (1073741824 & lanes))
+ return (return_highestLanePriority = 1), 1073741824;
+ return_highestLanePriority = 10;
+ return lanes;
+}
+function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
+ switch (schedulerPriorityLevel) {
+ case 99:
+ return 17;
+ case 98:
+ return 12;
+ case 97:
+ case 96:
+ return 10;
+ case 95:
+ return 2;
+ default:
+ return 0;
+ }
+}
+function lanePriorityToSchedulerPriority(lanePriority) {
+ switch (lanePriority) {
+ case 17:
+ case 16:
+ return 99;
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ return 98;
+ case 11:
+ case 10:
+ case 9:
+ case 8:
+ case 7:
+ case 6:
+ case 4:
+ case 5:
+ return 97;
+ case 3:
+ case 2:
+ case 1:
+ return 95;
+ case 0:
+ return 90;
+ default:
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+ }
+}
+function getNextLanes(root, wipLanes) {
+ var pendingLanes = root.pendingLanes;
+ if (0 === pendingLanes) return (return_highestLanePriority = 0);
+ var nextLanes = 0,
+ nextLanePriority = 0,
+ expiredLanes = root.expiredLanes,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes;
+ if (0 !== expiredLanes)
+ (nextLanes = expiredLanes),
+ (nextLanePriority = return_highestLanePriority = 17);
+ else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) {
+ var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes;
+ 0 !== nonIdleUnblockedLanes
+ ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : ((pingedLanes &= expiredLanes),
+ 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority)));
+ } else
+ (expiredLanes = pendingLanes & ~suspendedLanes),
+ 0 !== expiredLanes
+ ? ((nextLanes = getHighestPriorityLanes(expiredLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority));
+ if (0 === nextLanes) return 0;
+ nextLanes = 31 - clz32(nextLanes);
+ nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1);
+ if (
+ 0 !== wipLanes &&
+ wipLanes !== nextLanes &&
+ 0 === (wipLanes & suspendedLanes)
+ ) {
+ getHighestPriorityLanes(wipLanes);
+ if (nextLanePriority <= return_highestLanePriority) return wipLanes;
+ return_highestLanePriority = nextLanePriority;
+ }
+ wipLanes = root.entangledLanes;
+ if (0 !== wipLanes)
+ for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; )
+ (pendingLanes = 31 - clz32(wipLanes)),
+ (nextLanePriority = 1 << pendingLanes),
+ (nextLanes |= root[pendingLanes]),
+ (wipLanes &= ~nextLanePriority);
+ return nextLanes;
+}
+function getMostRecentEventTime(root, lanes) {
+ root = root.eventTimes;
+ for (var mostRecentEventTime = -1; 0 < lanes; ) {
+ var index$4 = 31 - clz32(lanes),
+ lane = 1 << index$4;
+ index$4 = root[index$4];
+ index$4 > mostRecentEventTime && (mostRecentEventTime = index$4);
+ lanes &= ~lane;
+ }
+ return mostRecentEventTime;
+}
+function getLanesToRetrySynchronouslyOnError(root) {
+ root = root.pendingLanes & -1073741825;
+ return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0;
+}
+function findUpdateLane(lanePriority, wipLanes) {
+ switch (lanePriority) {
+ case 17:
+ return 1;
+ case 16:
+ return 2;
+ case 14:
+ return (
+ (lanePriority = getHighestPriorityLane(24 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority
+ );
+ case 12:
+ return (
+ (lanePriority = getHighestPriorityLane(192 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority
+ );
+ case 10:
+ return (
+ (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)),
+ 0 === lanePriority &&
+ ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)),
+ 0 === lanePriority && (lanePriority = 512)),
+ lanePriority
+ );
+ case 2:
+ return (
+ (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)),
+ 0 === wipLanes && (wipLanes = 268435456),
+ wipLanes
+ );
+ }
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+}
+function getHighestPriorityLane(lanes) {
+ return lanes & -lanes;
+}
+function pickArbitraryLane(lanes) {
+ return lanes & -lanes;
+}
+function markRootUpdated(root, updateLane, eventTime) {
+ root.pendingLanes |= updateLane;
+ var higherPriorityLanes = updateLane - 1;
+ root.suspendedLanes &= higherPriorityLanes;
+ root.pingedLanes &= higherPriorityLanes;
+ root = root.eventTimes;
+ updateLane = 31 - clz32(updateLane);
+ root[updateLane] = eventTime;
+}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(lanes) {
+ return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0;
+}
var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
+ Scheduler_shouldYield = Scheduler.unstable_shouldYield,
Scheduler_requestPaint = Scheduler.unstable_requestPaint,
- Scheduler_now = Scheduler.unstable_now,
+ Scheduler_now$1 = Scheduler.unstable_now,
Scheduler_getCurrentPriorityLevel =
Scheduler.unstable_getCurrentPriorityLevel,
Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
@@ -1682,18 +1965,17 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
Scheduler_LowPriority = Scheduler.unstable_LowPriority,
Scheduler_IdlePriority = Scheduler.unstable_IdlePriority,
fakeCallbackNode = {},
- shouldYield = Scheduler.unstable_shouldYield,
requestPaint =
void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {},
syncQueue = null,
immediateQueueCallbackNode = null,
isFlushingSyncQueue = !1,
- initialTimeMs = Scheduler_now(),
+ initialTimeMs$1 = Scheduler_now$1(),
now =
- 1e4 > initialTimeMs
- ? Scheduler_now
+ 1e4 > initialTimeMs$1
+ ? Scheduler_now$1
: function() {
- return Scheduler_now() - initialTimeMs;
+ return Scheduler_now$1() - initialTimeMs$1;
};
function getCurrentPriorityLevel() {
switch (Scheduler_getCurrentPriorityLevel()) {
@@ -1735,16 +2017,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) {
reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
return Scheduler_scheduleCallback(reactPriorityLevel, callback, options);
}
-function scheduleSyncCallback(callback) {
- null === syncQueue
- ? ((syncQueue = [callback]),
- (immediateQueueCallbackNode = Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueueImpl
- )))
- : syncQueue.push(callback);
- return fakeCallbackNode;
-}
function flushSyncCallbackQueue() {
if (null !== immediateQueueCallbackNode) {
var node = immediateQueueCallbackNode;
@@ -1779,6 +2051,30 @@ function flushSyncCallbackQueueImpl() {
}
}
}
+function describeFiber(fiber) {
+ switch (fiber.tag) {
+ case 5:
+ return describeComponentFrame(fiber.type, null, null);
+ case 16:
+ return describeComponentFrame("Lazy", null, null);
+ case 13:
+ return describeComponentFrame("Suspense", null, null);
+ case 19:
+ return describeComponentFrame("SuspenseList", null, null);
+ case 0:
+ case 2:
+ case 15:
+ return describeFunctionComponentFrame(fiber.type, null);
+ case 11:
+ return describeFunctionComponentFrame(fiber.type.render, null);
+ case 22:
+ return describeFunctionComponentFrame(fiber.type._render, null);
+ case 1:
+ return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber;
+ default:
+ return "";
+ }
+}
function is(x, y) {
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
}
@@ -1804,43 +2100,6 @@ function shallowEqual(objA, objB) {
return !1;
return !0;
}
-var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
-function getStackByFiberInDevAndProd(workInProgress) {
- var info = "";
- do {
- a: switch (workInProgress.tag) {
- case 3:
- case 4:
- case 6:
- case 7:
- case 10:
- case 9:
- var JSCompiler_inline_result = "";
- break a;
- default:
- var owner = workInProgress._debugOwner,
- source = workInProgress._debugSource,
- name = getComponentName(workInProgress.type);
- JSCompiler_inline_result = null;
- owner && (JSCompiler_inline_result = getComponentName(owner.type));
- owner = name;
- name = "";
- source
- ? (name =
- " (at " +
- source.fileName.replace(BEFORE_SLASH_RE, "") +
- ":" +
- source.lineNumber +
- ")")
- : JSCompiler_inline_result &&
- (name = " (created by " + JSCompiler_inline_result + ")");
- JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name;
- }
- info += JSCompiler_inline_result;
- workInProgress = workInProgress.return;
- } while (workInProgress);
- return info;
-}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
baseProps = Object.assign({}, baseProps);
@@ -1848,10 +2107,11 @@ function resolveDefaultProps(Component, baseProps) {
for (var propName in Component)
void 0 === baseProps[propName] &&
(baseProps[propName] = Component[propName]);
+ return baseProps;
}
return baseProps;
}
-var valueCursor = { current: null },
+var valueCursor = createCursor(null),
currentlyRenderingFiber = null,
lastContextDependency = null,
lastContextWithAllBitsObserved = null;
@@ -1863,31 +2123,29 @@ function popProvider(providerFiber) {
pop(valueCursor);
providerFiber.type._context._currentValue2 = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderExpirationTime) {
+function scheduleWorkOnParentPath(parent, renderLanes) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- if (parent.childExpirationTime < renderExpirationTime)
- (parent.childExpirationTime = renderExpirationTime),
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime &&
- (alternate.childExpirationTime = renderExpirationTime);
- else if (
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime
- )
- alternate.childExpirationTime = renderExpirationTime;
- else break;
+ if ((parent.childLanes & renderLanes) === renderLanes)
+ if (
+ null === alternate ||
+ (alternate.childLanes & renderLanes) === renderLanes
+ )
+ break;
+ else alternate.childLanes |= renderLanes;
+ else
+ (parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes);
parent = parent.return;
}
}
-function prepareToReadContext(workInProgress, renderExpirationTime) {
+function prepareToReadContext(workInProgress, renderLanes) {
currentlyRenderingFiber = workInProgress;
lastContextWithAllBitsObserved = lastContextDependency = null;
workInProgress = workInProgress.dependencies;
null !== workInProgress &&
null !== workInProgress.firstContext &&
- (workInProgress.expirationTime >= renderExpirationTime &&
- (didReceiveUpdate = !0),
+ (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0),
(workInProgress.firstContext = null));
}
function readContext(context, observedBits) {
@@ -1906,7 +2164,7 @@ function readContext(context, observedBits) {
);
lastContextDependency = observedBits;
currentlyRenderingFiber.dependencies = {
- expirationTime: 0,
+ lanes: 0,
firstContext: observedBits,
responders: null
};
@@ -1918,7 +2176,8 @@ var hasForceUpdate = !1;
function initializeUpdateQueue(fiber) {
fiber.updateQueue = {
baseState: fiber.memoizedState,
- baseQueue: null,
+ firstBaseUpdate: null,
+ lastBaseUpdate: null,
shared: { pending: null },
effects: null
};
@@ -1928,21 +2187,22 @@ function cloneUpdateQueue(current, workInProgress) {
workInProgress.updateQueue === current &&
(workInProgress.updateQueue = {
baseState: current.baseState,
- baseQueue: current.baseQueue,
+ firstBaseUpdate: current.firstBaseUpdate,
+ lastBaseUpdate: current.lastBaseUpdate,
shared: current.shared,
effects: current.effects
});
}
-function createUpdate(expirationTime, suspenseConfig) {
- expirationTime = {
- expirationTime: expirationTime,
+function createUpdate(eventTime, lane, suspenseConfig) {
+ return {
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
tag: 0,
payload: null,
callback: null,
next: null
};
- return (expirationTime.next = expirationTime);
}
function enqueueUpdate(fiber, update) {
fiber = fiber.updateQueue;
@@ -1955,132 +2215,185 @@ function enqueueUpdate(fiber, update) {
fiber.pending = update;
}
}
-function enqueueCapturedUpdate(workInProgress, update) {
- var current = workInProgress.alternate;
- null !== current && cloneUpdateQueue(current, workInProgress);
- workInProgress = workInProgress.updateQueue;
- current = workInProgress.baseQueue;
- null === current
- ? ((workInProgress.baseQueue = update.next = update),
- (update.next = update))
- : ((update.next = current.next), (current.next = update));
+function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
+ var queue = workInProgress.updateQueue,
+ current = workInProgress.alternate;
+ if (
+ null !== current &&
+ ((current = current.updateQueue), queue === current)
+ ) {
+ var newFirst = null,
+ newLast = null;
+ queue = queue.firstBaseUpdate;
+ if (null !== queue) {
+ do {
+ var clone = {
+ eventTime: queue.eventTime,
+ lane: queue.lane,
+ suspenseConfig: queue.suspenseConfig,
+ tag: queue.tag,
+ payload: queue.payload,
+ callback: queue.callback,
+ next: null
+ };
+ null === newLast
+ ? (newFirst = newLast = clone)
+ : (newLast = newLast.next = clone);
+ queue = queue.next;
+ } while (null !== queue);
+ null === newLast
+ ? (newFirst = newLast = capturedUpdate)
+ : (newLast = newLast.next = capturedUpdate);
+ } else newFirst = newLast = capturedUpdate;
+ queue = {
+ baseState: current.baseState,
+ firstBaseUpdate: newFirst,
+ lastBaseUpdate: newLast,
+ shared: current.shared,
+ effects: current.effects
+ };
+ workInProgress.updateQueue = queue;
+ return;
+ }
+ workInProgress = queue.lastBaseUpdate;
+ null === workInProgress
+ ? (queue.firstBaseUpdate = capturedUpdate)
+ : (workInProgress.next = capturedUpdate);
+ queue.lastBaseUpdate = capturedUpdate;
}
function processUpdateQueue(
workInProgress$jscomp$0,
props,
instance,
- renderExpirationTime
+ renderLanes
) {
var queue = workInProgress$jscomp$0.updateQueue;
hasForceUpdate = !1;
- var baseQueue = queue.baseQueue,
+ var firstBaseUpdate = queue.firstBaseUpdate,
+ lastBaseUpdate = queue.lastBaseUpdate,
pendingQueue = queue.shared.pending;
if (null !== pendingQueue) {
- if (null !== baseQueue) {
- var baseFirst = baseQueue.next;
- baseQueue.next = pendingQueue.next;
- pendingQueue.next = baseFirst;
- }
- baseQueue = pendingQueue;
queue.shared.pending = null;
- baseFirst = workInProgress$jscomp$0.alternate;
- null !== baseFirst &&
- ((baseFirst = baseFirst.updateQueue),
- null !== baseFirst && (baseFirst.baseQueue = pendingQueue));
+ var lastPendingUpdate = pendingQueue,
+ firstPendingUpdate = lastPendingUpdate.next;
+ lastPendingUpdate.next = null;
+ null === lastBaseUpdate
+ ? (firstBaseUpdate = firstPendingUpdate)
+ : (lastBaseUpdate.next = firstPendingUpdate);
+ lastBaseUpdate = lastPendingUpdate;
+ var current = workInProgress$jscomp$0.alternate;
+ if (null !== current) {
+ current = current.updateQueue;
+ var currentLastBaseUpdate = current.lastBaseUpdate;
+ currentLastBaseUpdate !== lastBaseUpdate &&
+ (null === currentLastBaseUpdate
+ ? (current.firstBaseUpdate = firstPendingUpdate)
+ : (currentLastBaseUpdate.next = firstPendingUpdate),
+ (current.lastBaseUpdate = lastPendingUpdate));
+ }
}
- if (null !== baseQueue) {
- baseFirst = baseQueue.next;
- var newState = queue.baseState,
- newExpirationTime = 0,
- newBaseState = null,
- newBaseQueueFirst = null,
- newBaseQueueLast = null;
- if (null !== baseFirst) {
- var update = baseFirst;
- do {
- pendingQueue = update.expirationTime;
- if (pendingQueue < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
+ if (null !== firstBaseUpdate) {
+ currentLastBaseUpdate = queue.baseState;
+ lastBaseUpdate = 0;
+ current = firstPendingUpdate = lastPendingUpdate = null;
+ do {
+ pendingQueue = firstBaseUpdate.lane;
+ var updateEventTime = firstBaseUpdate.eventTime;
+ if ((renderLanes & pendingQueue) === pendingQueue) {
+ null !== current &&
+ (current = current.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
next: null
- };
- null === newBaseQueueLast
- ? ((newBaseQueueFirst = newBaseQueueLast = clone),
- (newBaseState = newState))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- pendingQueue > newExpirationTime &&
- (newExpirationTime = pendingQueue);
- } else {
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
- next: null
- });
- markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig);
- a: {
- var workInProgress = workInProgress$jscomp$0,
- update$jscomp$0 = update;
- pendingQueue = props;
- clone = instance;
- switch (update$jscomp$0.tag) {
- case 1:
- workInProgress = update$jscomp$0.payload;
- if ("function" === typeof workInProgress) {
- newState = workInProgress.call(clone, newState, pendingQueue);
- break a;
- }
- newState = workInProgress;
- break a;
- case 3:
- workInProgress.effectTag =
- (workInProgress.effectTag & -4097) | 64;
- case 0:
- workInProgress = update$jscomp$0.payload;
- pendingQueue =
- "function" === typeof workInProgress
- ? workInProgress.call(clone, newState, pendingQueue)
- : workInProgress;
- if (null === pendingQueue || void 0 === pendingQueue) break a;
- newState = Object.assign({}, newState, pendingQueue);
+ });
+ markRenderEventTimeAndConfig(
+ updateEventTime,
+ firstBaseUpdate.suspenseConfig
+ );
+ a: {
+ var workInProgress = workInProgress$jscomp$0,
+ update = firstBaseUpdate;
+ pendingQueue = props;
+ updateEventTime = instance;
+ switch (update.tag) {
+ case 1:
+ workInProgress = update.payload;
+ if ("function" === typeof workInProgress) {
+ currentLastBaseUpdate = workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ );
break a;
- case 2:
- hasForceUpdate = !0;
- }
+ }
+ currentLastBaseUpdate = workInProgress;
+ break a;
+ case 3:
+ workInProgress.effectTag =
+ (workInProgress.effectTag & -4097) | 64;
+ case 0:
+ workInProgress = update.payload;
+ pendingQueue =
+ "function" === typeof workInProgress
+ ? workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ )
+ : workInProgress;
+ if (null === pendingQueue || void 0 === pendingQueue) break a;
+ currentLastBaseUpdate = Object.assign(
+ {},
+ currentLastBaseUpdate,
+ pendingQueue
+ );
+ break a;
+ case 2:
+ hasForceUpdate = !0;
}
- null !== update.callback &&
- ((workInProgress$jscomp$0.effectTag |= 32),
- (pendingQueue = queue.effects),
- null === pendingQueue
- ? (queue.effects = [update])
- : pendingQueue.push(update));
}
- update = update.next;
- if (null === update || update === baseFirst)
- if (((pendingQueue = queue.shared.pending), null === pendingQueue))
- break;
- else
- (update = baseQueue.next = pendingQueue.next),
- (pendingQueue.next = baseFirst),
- (queue.baseQueue = baseQueue = pendingQueue),
- (queue.shared.pending = null);
- } while (1);
- }
- null === newBaseQueueLast
- ? (newBaseState = newState)
- : (newBaseQueueLast.next = newBaseQueueFirst);
- queue.baseState = newBaseState;
- queue.baseQueue = newBaseQueueLast;
- markUnprocessedUpdateTime(newExpirationTime);
- workInProgress$jscomp$0.expirationTime = newExpirationTime;
- workInProgress$jscomp$0.memoizedState = newState;
+ null !== firstBaseUpdate.callback &&
+ ((workInProgress$jscomp$0.effectTag |= 32),
+ (pendingQueue = queue.effects),
+ null === pendingQueue
+ ? (queue.effects = [firstBaseUpdate])
+ : pendingQueue.push(firstBaseUpdate));
+ } else
+ (updateEventTime = {
+ eventTime: updateEventTime,
+ lane: pendingQueue,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
+ next: null
+ }),
+ null === current
+ ? ((firstPendingUpdate = current = updateEventTime),
+ (lastPendingUpdate = currentLastBaseUpdate))
+ : (current = current.next = updateEventTime),
+ (lastBaseUpdate |= pendingQueue);
+ firstBaseUpdate = firstBaseUpdate.next;
+ if (null === firstBaseUpdate)
+ if (((pendingQueue = queue.shared.pending), null === pendingQueue))
+ break;
+ else
+ (firstBaseUpdate = pendingQueue.next),
+ (pendingQueue.next = null),
+ (queue.lastBaseUpdate = pendingQueue),
+ (queue.shared.pending = null);
+ } while (1);
+ null === current && (lastPendingUpdate = currentLastBaseUpdate);
+ queue.baseState = lastPendingUpdate;
+ queue.firstBaseUpdate = firstPendingUpdate;
+ queue.lastBaseUpdate = current;
+ workInProgressRootSkippedLanes |= lastBaseUpdate;
+ workInProgress$jscomp$0.lanes = lastBaseUpdate;
+ workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate;
}
}
function commitUpdateQueue(finishedWork, finishedQueue, instance) {
@@ -2120,54 +2433,54 @@ function applyDerivedStateFromProps(
? ctor
: Object.assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
- 0 === workInProgress.expirationTime &&
+ 0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
}
var classComponentUpdater = {
isMounted: function(component) {
- return (component = component._reactInternalFiber)
+ return (component = component._reactInternals)
? getNearestMountedFiber(component) === component
: !1;
},
enqueueSetState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueReplaceState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 1;
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueForceUpdate: function(inst, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 2;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
}
};
function checkShouldComponentUpdate(
@@ -2205,7 +2518,7 @@ function constructClassInstance(workInProgress, ctor, props) {
null !== ctor.state && void 0 !== ctor.state ? ctor.state : null;
ctor.updater = classComponentUpdater;
workInProgress.stateNode = ctor;
- ctor._reactInternalFiber = workInProgress;
+ ctor._reactInternals = workInProgress;
isLegacyContextConsumer &&
((workInProgress = workInProgress.stateNode),
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
@@ -2226,12 +2539,7 @@ function callComponentWillReceiveProps(
instance.state !== workInProgress &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
}
-function mountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;
@@ -2244,7 +2552,7 @@ function mountClassInstance(
? previousContext
: contextStackCursor.current),
(instance.context = getMaskedContext(workInProgress, contextType)));
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
contextType = ctor.getDerivedStateFromProps;
"function" === typeof contextType &&
@@ -2261,12 +2569,7 @@ function mountClassInstance(
instance.UNSAFE_componentWillMount(),
ctor !== instance.state &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null),
- processUpdateQueue(
- workInProgress,
- newProps,
- instance,
- renderExpirationTime
- ),
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes),
(instance.state = workInProgress.memoizedState));
"function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4);
@@ -2330,7 +2633,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) {
("[object Object]" === Object.prototype.toString.call(newChild)
? "object with keys {" + Object.keys(newChild).join(", ") + "}"
: newChild) +
- ")."
+ "). If you meant to render a collection of children, use an array instead."
);
}
function ChildReconciler(shouldTrackSideEffects) {
@@ -2386,14 +2689,10 @@ function ChildReconciler(shouldTrackSideEffects) {
(newFiber.effectTag = 2);
return newFiber;
}
- function updateTextNode(returnFiber, current, textContent, expirationTime) {
+ function updateTextNode(returnFiber, current, textContent, lanes) {
if (null === current || 6 !== current.tag)
return (
- (current = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromText(textContent, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2401,27 +2700,27 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateElement(returnFiber, current, element, expirationTime) {
+ function updateElement(returnFiber, current, element, lanes) {
if (null !== current && current.elementType === element.type)
return (
- (expirationTime = useFiber(current, element.props)),
- (expirationTime.ref = coerceRef(returnFiber, current, element)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes = useFiber(current, element.props)),
+ (lanes.ref = coerceRef(returnFiber, current, element)),
+ (lanes.return = returnFiber),
+ lanes
);
- expirationTime = createFiberFromTypeAndProps(
+ lanes = createFiberFromTypeAndProps(
element.type,
element.key,
element.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
);
- expirationTime.ref = coerceRef(returnFiber, current, element);
- expirationTime.return = returnFiber;
- return expirationTime;
+ lanes.ref = coerceRef(returnFiber, current, element);
+ lanes.return = returnFiber;
+ return lanes;
}
- function updatePortal(returnFiber, current, portal, expirationTime) {
+ function updatePortal(returnFiber, current, portal, lanes) {
if (
null === current ||
4 !== current.tag ||
@@ -2429,11 +2728,7 @@ function ChildReconciler(shouldTrackSideEffects) {
current.stateNode.implementation !== portal.implementation
)
return (
- (current = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromPortal(portal, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2441,13 +2736,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateFragment(returnFiber, current, fragment, expirationTime, key) {
+ function updateFragment(returnFiber, current, fragment, lanes, key) {
if (null === current || 7 !== current.tag)
return (
(current = createFiberFromFragment(
fragment,
returnFiber.mode,
- expirationTime,
+ lanes,
key
)),
(current.return = returnFiber),
@@ -2457,13 +2752,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function createChild(returnFiber, newChild, expirationTime) {
+ function createChild(returnFiber, newChild, lanes) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(newChild = createFiberFromText(
"" + newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2472,24 +2767,24 @@ function ChildReconciler(shouldTrackSideEffects) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
return (
- (expirationTime = createFiberFromTypeAndProps(
+ (lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(returnFiber, null, newChild)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes.ref = coerceRef(returnFiber, null, newChild)),
+ (lanes.return = returnFiber),
+ lanes
);
case REACT_PORTAL_TYPE:
return (
(newChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2500,7 +2795,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(newChild = createFiberFromFragment(
newChild,
returnFiber.mode,
- expirationTime,
+ lanes,
null
)),
(newChild.return = returnFiber),
@@ -2510,12 +2805,12 @@ function ChildReconciler(shouldTrackSideEffects) {
}
return null;
}
- function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
+ function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
if ("string" === typeof newChild || "number" === typeof newChild)
return null !== key
? null
- : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime);
+ : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
@@ -2525,26 +2820,20 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChild.props.children,
- expirationTime,
+ lanes,
key
)
- : updateElement(returnFiber, oldFiber, newChild, expirationTime)
+ : updateElement(returnFiber, oldFiber, newChild, lanes)
: null;
case REACT_PORTAL_TYPE:
return newChild.key === key
- ? updatePortal(returnFiber, oldFiber, newChild, expirationTime)
+ ? updatePortal(returnFiber, oldFiber, newChild, lanes)
: null;
}
if (isArray(newChild) || getIteratorFn(newChild))
return null !== key
? null
- : updateFragment(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime,
- null
- );
+ : updateFragment(returnFiber, oldFiber, newChild, lanes, null);
throwOnInvalidObjectType(returnFiber, newChild);
}
return null;
@@ -2554,17 +2843,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChild,
- expirationTime
+ lanes
) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateTextNode(
- returnFiber,
- existingChildren,
- "" + newChild,
- expirationTime
- )
+ updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
@@ -2579,15 +2863,10 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
existingChildren,
newChild.props.children,
- expirationTime,
+ lanes,
newChild.key
)
- : updateElement(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ : updateElement(returnFiber, existingChildren, newChild, lanes)
);
case REACT_PORTAL_TYPE:
return (
@@ -2595,24 +2874,13 @@ function ChildReconciler(shouldTrackSideEffects) {
existingChildren.get(
null === newChild.key ? newIdx : newChild.key
) || null),
- updatePortal(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ updatePortal(returnFiber, existingChildren, newChild, lanes)
);
}
if (isArray(newChild) || getIteratorFn(newChild))
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateFragment(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime,
- null
- )
+ updateFragment(returnFiber, existingChildren, newChild, lanes, null)
);
throwOnInvalidObjectType(returnFiber, newChild);
}
@@ -2622,7 +2890,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildren,
- expirationTime
+ lanes
) {
for (
var resultingFirstChild = null,
@@ -2640,7 +2908,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
@@ -2663,11 +2931,7 @@ function ChildReconciler(shouldTrackSideEffects) {
);
if (null === oldFiber) {
for (; newIdx < newChildren.length; newIdx++)
- (oldFiber = createChild(
- returnFiber,
- newChildren[newIdx],
- expirationTime
- )),
+ (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)),
null !== oldFiber &&
((currentFirstChild = placeChild(
oldFiber,
@@ -2690,7 +2954,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChildren[newIdx],
- expirationTime
+ lanes
)),
null !== nextOldFiber &&
(shouldTrackSideEffects &&
@@ -2717,7 +2981,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildrenIterable,
- expirationTime
+ lanes
) {
var iteratorFn = getIteratorFn(newChildrenIterable);
if ("function" !== typeof iteratorFn)
@@ -2739,12 +3003,7 @@ function ChildReconciler(shouldTrackSideEffects) {
oldFiber.index > newIdx
? ((nextOldFiber = oldFiber), (oldFiber = null))
: (nextOldFiber = oldFiber.sibling);
- var newFiber = updateSlot(
- returnFiber,
- oldFiber,
- step.value,
- expirationTime
- );
+ var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
break;
@@ -2764,7 +3023,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn;
if (null === oldFiber) {
for (; !step.done; newIdx++, step = newChildrenIterable.next())
- (step = createChild(returnFiber, step.value, expirationTime)),
+ (step = createChild(returnFiber, step.value, lanes)),
null !== step &&
((currentFirstChild = placeChild(step, currentFirstChild, newIdx)),
null === previousNewFiber
@@ -2778,13 +3037,7 @@ function ChildReconciler(shouldTrackSideEffects) {
!step.done;
newIdx++, step = newChildrenIterable.next()
)
- (step = updateFromMap(
- oldFiber,
- returnFiber,
- newIdx,
- step.value,
- expirationTime
- )),
+ (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)),
null !== step &&
(shouldTrackSideEffects &&
null !== step.alternate &&
@@ -2800,7 +3053,7 @@ function ChildReconciler(shouldTrackSideEffects) {
});
return iteratorFn;
}
- return function(returnFiber, currentFirstChild, newChild, expirationTime) {
+ return function(returnFiber, currentFirstChild, newChild, lanes) {
var isUnkeyedTopLevelFragment =
"object" === typeof newChild &&
null !== newChild &&
@@ -2866,26 +3119,26 @@ function ChildReconciler(shouldTrackSideEffects) {
? ((currentFirstChild = createFiberFromFragment(
newChild.props.children,
returnFiber.mode,
- expirationTime,
+ lanes,
newChild.key
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild))
- : ((expirationTime = createFiberFromTypeAndProps(
+ : ((lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(
+ (lanes.ref = coerceRef(
returnFiber,
currentFirstChild,
newChild
)),
- (expirationTime.return = returnFiber),
- (returnFiber = expirationTime));
+ (lanes.return = returnFiber),
+ (returnFiber = lanes));
}
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
@@ -2924,7 +3177,7 @@ function ChildReconciler(shouldTrackSideEffects) {
currentFirstChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
@@ -2943,7 +3196,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(currentFirstChild = createFiberFromText(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
@@ -2954,14 +3207,14 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
if (getIteratorFn(newChild))
return reconcileChildrenIterator(
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
isObject && throwOnInvalidObjectType(returnFiber, newChild);
if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
@@ -2980,9 +3233,9 @@ function ChildReconciler(shouldTrackSideEffects) {
var reconcileChildFibers = ChildReconciler(!0),
mountChildFibers = ChildReconciler(!1),
NO_CONTEXT = {},
- contextStackCursor$1 = { current: NO_CONTEXT },
- contextFiberStackCursor = { current: NO_CONTEXT },
- rootInstanceStackCursor = { current: NO_CONTEXT };
+ contextStackCursor$1 = createCursor(NO_CONTEXT),
+ contextFiberStackCursor = createCursor(NO_CONTEXT),
+ rootInstanceStackCursor = createCursor(NO_CONTEXT);
function requiredContext(c) {
if (c === NO_CONTEXT)
throw Error(
@@ -3005,26 +3258,26 @@ function popHostContainer() {
function pushHostContext(fiber) {
requiredContext(rootInstanceStackCursor.current);
var context = requiredContext(contextStackCursor$1.current);
- var nextContext = fiber.type;
- nextContext =
- "AndroidTextInput" === nextContext ||
- "RCTMultilineTextInputView" === nextContext ||
- "RCTSinglelineTextInputView" === nextContext ||
- "RCTText" === nextContext ||
- "RCTVirtualText" === nextContext;
- nextContext =
- context.isInAParentText !== nextContext
- ? { isInAParentText: nextContext }
+ var JSCompiler_inline_result = fiber.type;
+ JSCompiler_inline_result =
+ "AndroidTextInput" === JSCompiler_inline_result ||
+ "RCTMultilineTextInputView" === JSCompiler_inline_result ||
+ "RCTSinglelineTextInputView" === JSCompiler_inline_result ||
+ "RCTText" === JSCompiler_inline_result ||
+ "RCTVirtualText" === JSCompiler_inline_result;
+ JSCompiler_inline_result =
+ context.isInAParentText !== JSCompiler_inline_result
+ ? { isInAParentText: JSCompiler_inline_result }
: context;
- context !== nextContext &&
+ context !== JSCompiler_inline_result &&
(push(contextFiberStackCursor, fiber),
- push(contextStackCursor$1, nextContext));
+ push(contextStackCursor$1, JSCompiler_inline_result));
}
function popHostContext(fiber) {
contextFiberStackCursor.current === fiber &&
(pop(contextStackCursor$1), pop(contextFiberStackCursor));
}
-var suspenseStackCursor = { current: 0 };
+var suspenseStackCursor = createCursor(0);
function findFirstSuspended(row) {
for (var node = row; null !== node; ) {
if (13 === node.tag) {
@@ -3051,13 +3304,20 @@ function findFirstSuspended(row) {
function createDeprecatedResponderListener(responder, props) {
return { responder: responder, props: props };
}
-var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
+var workInProgressSources = [];
+function resetWorkInProgressVersions() {
+ for (var i = 0; i < workInProgressSources.length; i++)
+ workInProgressSources[i]._workInProgressVersionSecondary = null;
+ workInProgressSources.length = 0;
+}
+var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig,
- renderExpirationTime = 0,
+ renderLanes = 0,
currentlyRenderingFiber$1 = null,
currentHook = null,
workInProgressHook = null,
- didScheduleRenderPhaseUpdate = !1;
+ didScheduleRenderPhaseUpdate = !1,
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
function throwInvalidHookError() {
throw Error(
"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."
@@ -3075,36 +3335,36 @@ function renderWithHooks(
Component,
props,
secondArg,
- nextRenderExpirationTime
+ nextRenderLanes
) {
- renderExpirationTime = nextRenderExpirationTime;
+ renderLanes = nextRenderLanes;
currentlyRenderingFiber$1 = workInProgress;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- workInProgress.expirationTime = 0;
- ReactCurrentDispatcher.current =
+ workInProgress.lanes = 0;
+ ReactCurrentDispatcher$1.current =
null === current || null === current.memoizedState
? HooksDispatcherOnMount
: HooksDispatcherOnUpdate;
current = Component(props, secondArg);
- if (workInProgress.expirationTime === renderExpirationTime) {
- nextRenderExpirationTime = 0;
+ if (didScheduleRenderPhaseUpdateDuringThisPass) {
+ nextRenderLanes = 0;
do {
- workInProgress.expirationTime = 0;
- if (!(25 > nextRenderExpirationTime))
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ if (!(25 > nextRenderLanes))
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
- nextRenderExpirationTime += 1;
+ nextRenderLanes += 1;
workInProgressHook = currentHook = null;
workInProgress.updateQueue = null;
- ReactCurrentDispatcher.current = HooksDispatcherOnRerender;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender;
current = Component(props, secondArg);
- } while (workInProgress.expirationTime === renderExpirationTime);
+ } while (didScheduleRenderPhaseUpdateDuringThisPass);
}
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
workInProgress = null !== currentHook && null !== currentHook.next;
- renderExpirationTime = 0;
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
didScheduleRenderPhaseUpdate = !1;
if (workInProgress)
@@ -3185,40 +3445,40 @@ function updateReducer(reducer) {
var newBaseQueueLast = (baseFirst = pendingQueue = null),
update = baseQueue;
do {
- var updateExpirationTime = update.expirationTime;
- if (updateExpirationTime < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- action: update.action,
- eagerReducer: update.eagerReducer,
- eagerState: update.eagerState,
- next: null
- };
- null === newBaseQueueLast
- ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- updateExpirationTime > currentlyRenderingFiber$1.expirationTime &&
- ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime),
- markUnprocessedUpdateTime(updateExpirationTime));
- } else
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
+ var suspenseConfig = update.suspenseConfig,
+ updateLane = update.lane,
+ updateEventTime = update.eventTime;
+ (renderLanes & updateLane) === updateLane
+ ? (null !== newBaseQueueLast &&
+ (newBaseQueueLast = newBaseQueueLast.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: update.suspenseConfig,
+ action: update.action,
+ eagerReducer: update.eagerReducer,
+ eagerState: update.eagerState,
+ next: null
+ }),
+ markRenderEventTimeAndConfig(updateEventTime, suspenseConfig),
+ (current =
+ update.eagerReducer === reducer
+ ? update.eagerState
+ : reducer(current, update.action)))
+ : ((suspenseConfig = {
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
next: null
}),
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ null === newBaseQueueLast
+ ? ((baseFirst = newBaseQueueLast = suspenseConfig),
+ (pendingQueue = current))
+ : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig),
+ (currentlyRenderingFiber$1.lanes |= updateLane),
+ (workInProgressRootSkippedLanes |= updateLane));
update = update.next;
} while (null !== update && update !== baseQueue);
null === newBaseQueueLast
@@ -3255,6 +3515,117 @@ function rerenderReducer(reducer) {
}
return [newState, dispatch];
}
+function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+ var getVersion = source._getVersion;
+ getVersion = getVersion(source._source);
+ var JSCompiler_inline_result = source._workInProgressVersionSecondary;
+ if (null !== JSCompiler_inline_result)
+ root = JSCompiler_inline_result === getVersion;
+ else if (
+ ((root = root.mutableReadLanes), (root = (renderLanes & root) === root))
+ )
+ (source._workInProgressVersionSecondary = getVersion),
+ workInProgressSources.push(source);
+ if (root) return getSnapshot(source._source);
+ workInProgressSources.push(source);
+ throw Error(
+ "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
+ );
+}
+function useMutableSource(hook, source, getSnapshot, subscribe) {
+ var root = workInProgressRoot;
+ if (null === root)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ var getVersion = source._getVersion,
+ version = getVersion(source._source),
+ dispatcher = ReactCurrentDispatcher$1.current,
+ _dispatcher$useState = dispatcher.useState(function() {
+ return readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ }),
+ setSnapshot = _dispatcher$useState[1],
+ snapshot = _dispatcher$useState[0];
+ _dispatcher$useState = workInProgressHook;
+ var memoizedState = hook.memoizedState,
+ refs = memoizedState.refs,
+ prevGetSnapshot = refs.getSnapshot,
+ prevSource = memoizedState.source;
+ memoizedState = memoizedState.subscribe;
+ var fiber = currentlyRenderingFiber$1;
+ hook.memoizedState = { refs: refs, source: source, subscribe: subscribe };
+ dispatcher.useEffect(
+ function() {
+ refs.getSnapshot = getSnapshot;
+ refs.setSnapshot = setSnapshot;
+ var maybeNewVersion = getVersion(source._source);
+ if (!objectIs(version, maybeNewVersion)) {
+ maybeNewVersion = getSnapshot(source._source);
+ objectIs(snapshot, maybeNewVersion) ||
+ (setSnapshot(maybeNewVersion),
+ (maybeNewVersion = requestUpdateLane(
+ fiber,
+ ReactCurrentBatchConfig.suspense
+ )),
+ (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes));
+ maybeNewVersion = root.mutableReadLanes;
+ root.entangledLanes |= maybeNewVersion;
+ for (
+ var entanglements = root.entanglements, lanes = maybeNewVersion;
+ 0 < lanes;
+
+ ) {
+ var index$12 = 31 - clz32(lanes),
+ lane = 1 << index$12;
+ entanglements[index$12] |= maybeNewVersion;
+ lanes &= ~lane;
+ }
+ }
+ },
+ [getSnapshot, source, subscribe]
+ );
+ dispatcher.useEffect(
+ function() {
+ return subscribe(source._source, function() {
+ var latestGetSnapshot = refs.getSnapshot,
+ latestSetSnapshot = refs.setSnapshot;
+ try {
+ latestSetSnapshot(latestGetSnapshot(source._source));
+ var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense);
+ root.mutableReadLanes |= lane & root.pendingLanes;
+ } catch (error) {
+ latestSetSnapshot(function() {
+ throw error;
+ });
+ }
+ });
+ },
+ [source, subscribe]
+ );
+ (objectIs(prevGetSnapshot, getSnapshot) &&
+ objectIs(prevSource, source) &&
+ objectIs(memoizedState, subscribe)) ||
+ ((hook = {
+ pending: null,
+ dispatch: null,
+ lastRenderedReducer: basicStateReducer,
+ lastRenderedState: snapshot
+ }),
+ (hook.dispatch = setSnapshot = dispatchAction.bind(
+ null,
+ currentlyRenderingFiber$1,
+ hook
+ )),
+ (_dispatcher$useState.queue = hook),
+ (_dispatcher$useState.baseQueue = null),
+ (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)),
+ (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot));
+ return snapshot;
+}
+function updateMutableSource(source, getSnapshot, subscribe) {
+ var hook = updateWorkInProgressHook();
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
@@ -3403,11 +3774,12 @@ function startTransition(setPending, config, callback) {
});
}
function dispatchAction(fiber, queue, action) {
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(fiber, suspenseConfig);
suspenseConfig = {
- expirationTime: currentTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
action: action,
eagerReducer: null,
@@ -3424,13 +3796,11 @@ function dispatchAction(fiber, queue, action) {
fiber === currentlyRenderingFiber$1 ||
(null !== pending && pending === currentlyRenderingFiber$1)
)
- (didScheduleRenderPhaseUpdate = !0),
- (suspenseConfig.expirationTime = renderExpirationTime),
- (currentlyRenderingFiber$1.expirationTime = renderExpirationTime);
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
else {
if (
- 0 === fiber.expirationTime &&
- (null === pending || 0 === pending.expirationTime) &&
+ 0 === fiber.lanes &&
+ (null === pending || 0 === pending.lanes) &&
((pending = queue.lastRenderedReducer), null !== pending)
)
try {
@@ -3442,10 +3812,9 @@ function dispatchAction(fiber, queue, action) {
} catch (error) {
} finally {
}
- scheduleWork(fiber, currentTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
}
-function updateEventListener() {}
var ContextOnlyDispatcher = {
readContext: readContext,
useCallback: throwInvalidHookError,
@@ -3461,7 +3830,9 @@ var ContextOnlyDispatcher = {
useResponder: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
- useEvent: throwInvalidHookError
+ useMutableSource: throwInvalidHookError,
+ useOpaqueIdentifier: throwInvalidHookError,
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
readContext: readContext,
@@ -3543,7 +3914,19 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: function() {}
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ var hook = mountWorkInProgressHook();
+ hook.memoizedState = {
+ refs: { getSnapshot: getSnapshot, setSnapshot: null },
+ source: source,
+ subscribe: subscribe
+ };
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ throw Error("Not yet implemented");
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnUpdate = {
readContext: readContext,
@@ -3591,7 +3974,11 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return updateReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
readContext: readContext,
@@ -3639,29 +4026,23 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return rerenderReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
didReceiveUpdate = !1;
-function reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
-) {
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
workInProgress.child =
null === current
- ? mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderExpirationTime
- )
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
: reconcileChildFibers(
workInProgress,
current.child,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
function updateForwardRef(
@@ -3669,33 +4050,28 @@ function updateForwardRef(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
Component = Component.render;
var ref = workInProgress.ref;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
nextProps = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, nextProps, renderExpirationTime);
+ reconcileChildren(current, workInProgress, nextProps, renderLanes);
return workInProgress.child;
}
function updateMemoComponent(
@@ -3703,8 +4079,8 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (null === current) {
var type = Component.type;
@@ -3723,8 +4099,8 @@ function updateMemoComponent(
workInProgress,
type,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
current = createFiberFromTypeAndProps(
@@ -3733,7 +4109,7 @@ function updateMemoComponent(
nextProps,
null,
workInProgress.mode,
- renderExpirationTime
+ renderLanes
);
current.ref = workInProgress.ref;
current.return = workInProgress;
@@ -3741,18 +4117,13 @@ function updateMemoComponent(
}
type = current.child;
if (
- updateExpirationTime < renderExpirationTime &&
- ((updateExpirationTime = type.memoizedProps),
+ 0 === (updateLanes & renderLanes) &&
+ ((updateLanes = type.memoizedProps),
(Component = Component.compare),
(Component = null !== Component ? Component : shallowEqual),
- Component(updateExpirationTime, nextProps) &&
- current.ref === workInProgress.ref)
+ Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
)
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
workInProgress.effectTag |= 1;
current = createWorkInProgress(type, nextProps);
current.ref = workInProgress.ref;
@@ -3764,29 +4135,66 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
- return null !== current &&
+ if (
+ null !== current &&
shallowEqual(current.memoizedProps, nextProps) &&
- current.ref === workInProgress.ref &&
- ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime)
- ? ((workInProgress.expirationTime = current.expirationTime),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- ))
- : updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
+ current.ref === workInProgress.ref
+ )
+ if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes)))
+ 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0);
+ else
+ return (
+ (workInProgress.lanes = current.lanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
-}
-function markRef(current, workInProgress) {
- var ref = workInProgress.ref;
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
+}
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
+ nextChildren = nextProps.children,
+ prevState = null !== current ? current.memoizedState : null;
+ if (
+ "hidden" === nextProps.mode ||
+ "unstable-defer-without-hiding" === nextProps.mode
+ )
+ if (0 === (workInProgress.mode & 4))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(workInProgress, renderLanes);
+ else if (0 !== (renderLanes & 1073741824))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(
+ workInProgress,
+ null !== prevState ? prevState.baseLanes : renderLanes
+ );
+ else
+ return (
+ (current =
+ null !== prevState ? prevState.baseLanes | renderLanes : renderLanes),
+ (workInProgress.lanes = workInProgress.childLanes = 1073741824),
+ (workInProgress.memoizedState = { baseLanes: current }),
+ pushRenderLanes(workInProgress, current),
+ null
+ );
+ else
+ null !== prevState
+ ? ((nextProps = prevState.baseLanes | renderLanes),
+ (workInProgress.memoizedState = null))
+ : (nextProps = renderLanes),
+ pushRenderLanes(workInProgress, nextProps);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
+function markRef(current, workInProgress) {
+ var ref = workInProgress.ref;
if (
(null === current && null !== ref) ||
(null !== current && current.ref !== ref)
@@ -3798,35 +4206,30 @@ function updateFunctionComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
var context = isContextProvider(Component)
? previousContext
: contextStackCursor.current;
context = getMaskedContext(workInProgress, context);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
Component = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, Component, renderExpirationTime);
+ reconcileChildren(current, workInProgress, Component, renderLanes);
return workInProgress.child;
}
function updateClassComponent(
@@ -3834,25 +4237,20 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
if (null === workInProgress.stateNode)
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
constructClassInstance(workInProgress, Component, nextProps),
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- ),
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes),
(nextProps = !0);
else if (null === current) {
var instance = workInProgress.stateNode,
@@ -3883,12 +4281,7 @@ function updateClassComponent(
hasForceUpdate = !1;
var oldState = workInProgress.memoizedState;
instance.state = oldState;
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- );
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
oldContext = workInProgress.memoizedState;
oldProps !== nextProps ||
oldState !== oldContext ||
@@ -3933,117 +4326,111 @@ function updateClassComponent(
: ("function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4),
(nextProps = !1));
- } else
- (instance = workInProgress.stateNode),
- cloneUpdateQueue(current, workInProgress),
- (oldProps = workInProgress.memoizedProps),
- (instance.props =
- workInProgress.type === workInProgress.elementType
- ? oldProps
- : resolveDefaultProps(workInProgress.type, oldProps)),
- (oldContext = instance.context),
- (contextType = Component.contextType),
- "object" === typeof contextType && null !== contextType
- ? (contextType = readContext(contextType))
- : ((contextType = isContextProvider(Component)
- ? previousContext
- : contextStackCursor.current),
- (contextType = getMaskedContext(workInProgress, contextType))),
- (getDerivedStateFromProps = Component.getDerivedStateFromProps),
- (hasNewLifecycles =
- "function" === typeof getDerivedStateFromProps ||
- "function" === typeof instance.getSnapshotBeforeUpdate) ||
- ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
- "function" !== typeof instance.componentWillReceiveProps) ||
- ((oldProps !== nextProps || oldContext !== contextType) &&
- callComponentWillReceiveProps(
+ } else {
+ instance = workInProgress.stateNode;
+ cloneUpdateQueue(current, workInProgress);
+ oldProps = workInProgress.memoizedProps;
+ contextType =
+ workInProgress.type === workInProgress.elementType
+ ? oldProps
+ : resolveDefaultProps(workInProgress.type, oldProps);
+ instance.props = contextType;
+ hasNewLifecycles = workInProgress.pendingProps;
+ oldState = instance.context;
+ oldContext = Component.contextType;
+ "object" === typeof oldContext && null !== oldContext
+ ? (oldContext = readContext(oldContext))
+ : ((oldContext = isContextProvider(Component)
+ ? previousContext
+ : contextStackCursor.current),
+ (oldContext = getMaskedContext(workInProgress, oldContext)));
+ var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps;
+ (getDerivedStateFromProps =
+ "function" === typeof getDerivedStateFromProps$jscomp$0 ||
+ "function" === typeof instance.getSnapshotBeforeUpdate) ||
+ ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
+ "function" !== typeof instance.componentWillReceiveProps) ||
+ ((oldProps !== hasNewLifecycles || oldState !== oldContext) &&
+ callComponentWillReceiveProps(
+ workInProgress,
+ instance,
+ nextProps,
+ oldContext
+ ));
+ hasForceUpdate = !1;
+ oldState = workInProgress.memoizedState;
+ instance.state = oldState;
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
+ var newState = workInProgress.memoizedState;
+ oldProps !== hasNewLifecycles ||
+ oldState !== newState ||
+ didPerformWorkStackCursor.current ||
+ hasForceUpdate
+ ? ("function" === typeof getDerivedStateFromProps$jscomp$0 &&
+ (applyDerivedStateFromProps(
workInProgress,
- instance,
+ Component,
+ getDerivedStateFromProps$jscomp$0,
+ nextProps
+ ),
+ (newState = workInProgress.memoizedState)),
+ (contextType =
+ hasForceUpdate ||
+ checkShouldComponentUpdate(
+ workInProgress,
+ Component,
+ contextType,
nextProps,
- contextType
- )),
- (hasForceUpdate = !1),
- (oldContext = workInProgress.memoizedState),
- (instance.state = oldContext),
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- ),
- (oldState = workInProgress.memoizedState),
- oldProps !== nextProps ||
- oldContext !== oldState ||
- didPerformWorkStackCursor.current ||
- hasForceUpdate
- ? ("function" === typeof getDerivedStateFromProps &&
- (applyDerivedStateFromProps(
- workInProgress,
- Component,
- getDerivedStateFromProps,
- nextProps
- ),
- (oldState = workInProgress.memoizedState)),
- (getDerivedStateFromProps =
- hasForceUpdate ||
- checkShouldComponentUpdate(
- workInProgress,
- Component,
- oldProps,
- nextProps,
- oldContext,
- oldState,
- contextType
- ))
- ? (hasNewLifecycles ||
- ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
- "function" !== typeof instance.componentWillUpdate) ||
- ("function" === typeof instance.componentWillUpdate &&
- instance.componentWillUpdate(
- nextProps,
- oldState,
- contextType
- ),
- "function" === typeof instance.UNSAFE_componentWillUpdate &&
- instance.UNSAFE_componentWillUpdate(
- nextProps,
- oldState,
- contextType
- )),
- "function" === typeof instance.componentDidUpdate &&
- (workInProgress.effectTag |= 4),
- "function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.effectTag |= 256))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (workInProgress.memoizedProps = nextProps),
- (workInProgress.memoizedState = oldState)),
- (instance.props = nextProps),
- (instance.state = oldState),
- (instance.context = contextType),
- (nextProps = getDerivedStateFromProps))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (nextProps = !1));
+ oldState,
+ newState,
+ oldContext
+ ))
+ ? (getDerivedStateFromProps ||
+ ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
+ "function" !== typeof instance.componentWillUpdate) ||
+ ("function" === typeof instance.componentWillUpdate &&
+ instance.componentWillUpdate(nextProps, newState, oldContext),
+ "function" === typeof instance.UNSAFE_componentWillUpdate &&
+ instance.UNSAFE_componentWillUpdate(
+ nextProps,
+ newState,
+ oldContext
+ )),
+ "function" === typeof instance.componentDidUpdate &&
+ (workInProgress.effectTag |= 4),
+ "function" === typeof instance.getSnapshotBeforeUpdate &&
+ (workInProgress.effectTag |= 256))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (workInProgress.memoizedProps = nextProps),
+ (workInProgress.memoizedState = newState)),
+ (instance.props = nextProps),
+ (instance.state = newState),
+ (instance.context = oldContext),
+ (nextProps = contextType))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (nextProps = !1));
+ }
return finishClassComponent(
current,
workInProgress,
Component,
nextProps,
hasContext,
- renderExpirationTime
+ renderLanes
);
}
function finishClassComponent(
@@ -4052,18 +4439,14 @@ function finishClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
) {
markRef(current, workInProgress);
var didCaptureError = 0 !== (workInProgress.effectTag & 64);
if (!shouldUpdate && !didCaptureError)
return (
hasContext && invalidateContextProvider(workInProgress, Component, !1),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
shouldUpdate = workInProgress.stateNode;
ReactCurrentOwner$1.current = workInProgress;
@@ -4077,20 +4460,15 @@ function finishClassComponent(
workInProgress,
current.child,
null,
- renderExpirationTime
+ renderLanes
)),
(workInProgress.child = reconcileChildFibers(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
)))
- : reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ : reconcileChildren(current, workInProgress, nextChildren, renderLanes);
workInProgress.memoizedState = shouldUpdate.state;
hasContext && invalidateContextProvider(workInProgress, Component, !0);
return workInProgress.child;
@@ -4107,155 +4485,186 @@ function pushHostRootContext(workInProgress) {
pushTopLevelContextObject(workInProgress, root.context, !1);
pushHostContainer(workInProgress, root.containerInfo);
}
-var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 };
-function updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
- var mode = workInProgress.mode,
- nextProps = workInProgress.pendingProps,
+var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
suspenseContext = suspenseStackCursor.current,
- nextDidTimeout = !1,
+ showFallback = !1,
JSCompiler_temp;
(JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) ||
(JSCompiler_temp =
- 0 !== (suspenseContext & 2) &&
- (null === current || null !== current.memoizedState));
+ null !== current && null === current.memoizedState
+ ? !1
+ : 0 !== (suspenseContext & 2));
JSCompiler_temp
- ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65))
+ ? ((showFallback = !0), (workInProgress.effectTag &= -65))
: (null !== current && null === current.memoizedState) ||
void 0 === nextProps.fallback ||
!0 === nextProps.unstable_avoidThisFallback ||
(suspenseContext |= 1);
push(suspenseStackCursor, suspenseContext & 1);
if (null === current) {
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (current = nextProps.fallback),
+ (suspenseContext = workInProgress.mode),
+ (showFallback = workInProgress.child),
+ (nextProps = { mode: "hidden", children: nextProps.children }),
+ 0 === (suspenseContext & 2) && null !== showFallback
+ ? ((showFallback.childLanes = 0),
+ (showFallback.pendingProps = nextProps))
+ : (showFallback = createFiberFromOffscreen(
+ nextProps,
+ suspenseContext,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
+ current,
+ suspenseContext,
+ renderLanes,
+ null
+ )),
+ (showFallback.return = workInProgress),
+ (current.return = workInProgress),
+ (showFallback.sibling = current),
+ (workInProgress.child = showFallback),
+ (workInProgress.child.memoizedState = { baseLanes: renderLanes }),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ current
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- mode = nextProps.children;
- workInProgress.memoizedState = null;
- return (workInProgress.child = mountChildFibers(
- workInProgress,
- null,
- mode,
- renderExpirationTime
- ));
+ renderLanes = createFiberFromOffscreen(
+ { mode: "visible", children: nextProps.children },
+ workInProgress.mode,
+ renderLanes,
+ null
+ );
+ renderLanes.return = workInProgress;
+ return (workInProgress.child = renderLanes);
}
if (null !== current.memoizedState) {
- current = current.child;
- mode = current.sibling;
- if (nextDidTimeout) {
- nextProps = nextProps.fallback;
- renderExpirationTime = createWorkInProgress(
- current,
- current.pendingProps
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- if (
- 0 === (workInProgress.mode & 2) &&
- ((nextDidTimeout =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child),
- nextDidTimeout !== current.child)
- )
- for (
- renderExpirationTime.child = nextDidTimeout;
- null !== nextDidTimeout;
-
- )
- (nextDidTimeout.return = renderExpirationTime),
- (nextDidTimeout = nextDidTimeout.sibling);
- mode = createWorkInProgress(mode, nextProps);
- mode.return = workInProgress;
- renderExpirationTime.sibling = mode;
- renderExpirationTime.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = renderExpirationTime;
- return mode;
- }
- renderExpirationTime = reconcileChildFibers(
+ renderLanes = updateSuspensePrimaryChildren(
+ current,
workInProgress,
- current.child,
nextProps.children,
- renderExpirationTime
+ renderLanes
);
workInProgress.memoizedState = null;
- return (workInProgress.child = renderExpirationTime);
+ return renderLanes;
}
- current = current.child;
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- nextProps.child = current;
- null !== current && (current.return = nextProps);
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- renderExpirationTime.effectTag |= 2;
- nextProps.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- workInProgress.memoizedState = null;
- return (workInProgress.child = reconcileChildFibers(
- workInProgress,
+ renderLanes = updateSuspensePrimaryChildren(
current,
+ workInProgress,
nextProps.children,
- renderExpirationTime
- ));
+ renderLanes
+ );
+ workInProgress.memoizedState = null;
+ return renderLanes;
}
-function scheduleWorkOnFiber(fiber, renderExpirationTime) {
- fiber.expirationTime < renderExpirationTime &&
- (fiber.expirationTime = renderExpirationTime);
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ primaryChildren = createWorkInProgress(currentPrimaryChildFragment, {
+ mode: "visible",
+ children: primaryChildren
+ });
+ 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes);
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = null;
+ null !== current &&
+ ((current.nextEffect = null),
+ (current.effectTag = 8),
+ (workInProgress.firstEffect = workInProgress.lastEffect = current));
+ return (workInProgress.child = primaryChildren);
+}
+function updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode,
+ currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ var primaryChildProps = { mode: "hidden", children: primaryChildren };
+ 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment
+ ? ((primaryChildren = workInProgress.child),
+ (primaryChildren.childLanes = 0),
+ (primaryChildren.pendingProps = primaryChildProps),
+ (currentPrimaryChildFragment = primaryChildren.lastEffect),
+ null !== currentPrimaryChildFragment
+ ? ((workInProgress.firstEffect = primaryChildren.firstEffect),
+ (workInProgress.lastEffect = currentPrimaryChildFragment),
+ (currentPrimaryChildFragment.nextEffect = null))
+ : (workInProgress.firstEffect = workInProgress.lastEffect = null))
+ : (primaryChildren = createWorkInProgress(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ ));
+ null !== current
+ ? (fallbackChildren = createWorkInProgress(current, fallbackChildren))
+ : ((fallbackChildren = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ )),
+ (fallbackChildren.effectTag |= 2));
+ fallbackChildren.return = workInProgress;
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = fallbackChildren;
+ workInProgress.child = primaryChildren;
+ return fallbackChildren;
+}
+function scheduleWorkOnFiber(fiber, renderLanes) {
+ fiber.lanes |= renderLanes;
var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < renderExpirationTime &&
- (alternate.expirationTime = renderExpirationTime);
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
+ null !== alternate && (alternate.lanes |= renderLanes);
+ scheduleWorkOnParentPath(fiber.return, renderLanes);
}
function initSuspenseListRenderState(
workInProgress,
@@ -4286,20 +4695,11 @@ function initSuspenseListRenderState(
(renderState.tailMode = tailMode),
(renderState.lastEffect = lastEffectBeforeRendering));
}
-function updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps,
revealOrder = nextProps.revealOrder,
tailMode = nextProps.tail;
- reconcileChildren(
- current,
- workInProgress,
- nextProps.children,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
nextProps = suspenseStackCursor.current;
if (0 !== (nextProps & 2))
(nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64);
@@ -4308,9 +4708,8 @@ function updateSuspenseListComponent(
a: for (current = workInProgress.child; null !== current; ) {
if (13 === current.tag)
null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderExpirationTime);
- else if (19 === current.tag)
- scheduleWorkOnFiber(current, renderExpirationTime);
+ scheduleWorkOnFiber(current, renderLanes);
+ else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
else if (null !== current.child) {
current.child.return = current;
current = current.child;
@@ -4332,30 +4731,29 @@ function updateSuspenseListComponent(
else
switch (revealOrder) {
case "forwards":
- renderExpirationTime = workInProgress.child;
- for (revealOrder = null; null !== renderExpirationTime; )
- (current = renderExpirationTime.alternate),
+ renderLanes = workInProgress.child;
+ for (revealOrder = null; null !== renderLanes; )
+ (current = renderLanes.alternate),
null !== current &&
null === findFirstSuspended(current) &&
- (revealOrder = renderExpirationTime),
- (renderExpirationTime = renderExpirationTime.sibling);
- renderExpirationTime = revealOrder;
- null === renderExpirationTime
+ (revealOrder = renderLanes),
+ (renderLanes = renderLanes.sibling);
+ renderLanes = revealOrder;
+ null === renderLanes
? ((revealOrder = workInProgress.child),
(workInProgress.child = null))
- : ((revealOrder = renderExpirationTime.sibling),
- (renderExpirationTime.sibling = null));
+ : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
initSuspenseListRenderState(
workInProgress,
!1,
revealOrder,
- renderExpirationTime,
+ renderLanes,
tailMode,
workInProgress.lastEffect
);
break;
case "backwards":
- renderExpirationTime = null;
+ renderLanes = null;
revealOrder = workInProgress.child;
for (workInProgress.child = null; null !== revealOrder; ) {
current = revealOrder.alternate;
@@ -4364,14 +4762,14 @@ function updateSuspenseListComponent(
break;
}
current = revealOrder.sibling;
- revealOrder.sibling = renderExpirationTime;
- renderExpirationTime = revealOrder;
+ revealOrder.sibling = renderLanes;
+ renderLanes = revealOrder;
revealOrder = current;
}
initSuspenseListRenderState(
workInProgress,
!0,
- renderExpirationTime,
+ renderLanes,
null,
tailMode,
workInProgress.lastEffect
@@ -4392,35 +4790,28 @@ function updateSuspenseListComponent(
}
return workInProgress.child;
}
-function bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
null !== current && (workInProgress.dependencies = current.dependencies);
- var updateExpirationTime = workInProgress.expirationTime;
- 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime);
- if (workInProgress.childExpirationTime < renderExpirationTime) return null;
- if (null !== current && workInProgress.child !== current.child)
- throw Error("Resuming work not yet implemented.");
- if (null !== workInProgress.child) {
- current = workInProgress.child;
- renderExpirationTime = createWorkInProgress(current, current.pendingProps);
- workInProgress.child = renderExpirationTime;
- for (
- renderExpirationTime.return = workInProgress;
- null !== current.sibling;
-
- )
- (current = current.sibling),
- (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress(
- current,
- current.pendingProps
- )),
- (renderExpirationTime.return = workInProgress);
- renderExpirationTime.sibling = null;
+ workInProgressRootSkippedLanes |= workInProgress.lanes;
+ if (0 !== (renderLanes & workInProgress.childLanes)) {
+ if (null !== current && workInProgress.child !== current.child)
+ throw Error("Resuming work not yet implemented.");
+ if (null !== workInProgress.child) {
+ current = workInProgress.child;
+ renderLanes = createWorkInProgress(current, current.pendingProps);
+ workInProgress.child = renderLanes;
+ for (renderLanes.return = workInProgress; null !== current.sibling; )
+ (current = current.sibling),
+ (renderLanes = renderLanes.sibling = createWorkInProgress(
+ current,
+ current.pendingProps
+ )),
+ (renderLanes.return = workInProgress);
+ renderLanes.sibling = null;
+ }
+ return workInProgress.child;
}
- return workInProgress.child;
+ return null;
}
var appendAllChildren,
updateHostContainer,
@@ -4613,17 +5004,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
break;
case "collapsed":
lastTailNode = renderState.tail;
- for (var _lastTailNode = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (_lastTailNode = lastTailNode),
+ for (var lastTailNode$64 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode),
(lastTailNode = lastTailNode.sibling);
- null === _lastTailNode
+ null === lastTailNode$64
? hasRenderedATailFallback || null === renderState.tail
? (renderState.tail = null)
: (renderState.tail.sibling = null)
- : (_lastTailNode.sibling = null);
+ : (lastTailNode$64.sibling = null);
}
}
-function completeWork(current, workInProgress, renderExpirationTime) {
+function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
case 2:
@@ -4644,10 +5035,14 @@ function completeWork(current, workInProgress, renderExpirationTime) {
popHostContainer(),
pop(didPerformWorkStackCursor),
pop(contextStackCursor),
- (current = workInProgress.stateNode),
- current.pendingContext &&
- ((current.context = current.pendingContext),
- (current.pendingContext = null)),
+ resetWorkInProgressVersions(),
+ (newProps = workInProgress.stateNode),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ newProps.hydrate ||
+ (workInProgress.effectTag |= 256),
updateHostContainer(workInProgress),
null
);
@@ -4656,12 +5051,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
var rootContainerInstance = requiredContext(
rootInstanceStackCursor.current
);
- renderExpirationTime = workInProgress.type;
+ renderLanes = workInProgress.type;
if (null !== current && null != workInProgress.stateNode)
updateHostComponent$1(
current,
workInProgress,
- renderExpirationTime,
+ renderLanes,
newProps,
rootContainerInstance
),
@@ -4678,23 +5073,23 @@ function completeWork(current, workInProgress, renderExpirationTime) {
requiredContext(contextStackCursor$1.current);
current = nextReactTag;
nextReactTag += 2;
- renderExpirationTime = getViewConfigForType(renderExpirationTime);
+ renderLanes = getViewConfigForType(renderLanes);
var updatePayload = diffProperties(
null,
emptyObject,
newProps,
- renderExpirationTime.validAttributes
+ renderLanes.validAttributes
);
rootContainerInstance = createNode(
current,
- renderExpirationTime.uiViewClassName,
+ renderLanes.uiViewClassName,
rootContainerInstance,
updatePayload,
workInProgress
);
current = new ReactFabricHostComponent(
current,
- renderExpirationTime,
+ renderLanes,
newProps,
workInProgress
);
@@ -4731,49 +5126,32 @@ function completeWork(current, workInProgress, renderExpirationTime) {
pop(suspenseStackCursor);
newProps = workInProgress.memoizedState;
if (0 !== (workInProgress.effectTag & 64))
- return (
- (workInProgress.expirationTime = renderExpirationTime), workInProgress
- );
+ return (workInProgress.lanes = renderLanes), workInProgress;
newProps = null !== newProps;
rootContainerInstance = !1;
null !== current &&
- ((renderExpirationTime = current.memoizedState),
- (rootContainerInstance = null !== renderExpirationTime),
- newProps ||
- null === renderExpirationTime ||
- ((renderExpirationTime = current.child.sibling),
- null !== renderExpirationTime &&
- ((updatePayload = workInProgress.firstEffect),
- null !== updatePayload
- ? ((workInProgress.firstEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = updatePayload))
- : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = null)),
- (renderExpirationTime.effectTag = 8))));
+ (rootContainerInstance = null !== current.memoizedState);
if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2))
if (
(null === current &&
!0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
0 !== (suspenseStackCursor.current & 1)
)
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootSuspended);
+ 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3);
else {
if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus
)
- workInProgressRootExitStatus = RootSuspendedWithDelay;
- 0 !== workInProgressRootNextUnprocessedUpdateTime &&
- null !== workInProgressRoot &&
- (markRootSuspendedAtTime(
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 134217727) &&
+ 0 === (workInProgressRootUpdatedLanes & 134217727)) ||
+ markRootSuspended$1(
workInProgressRoot,
- renderExpirationTime$1
- ),
- markRootUpdatedAtTime(
- workInProgressRoot,
- workInProgressRootNextUnprocessedUpdateTime
- ));
+ workInProgressRootRenderLanes
+ );
}
newProps && (workInProgress.effectTag |= 4);
return null;
@@ -4793,7 +5171,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1);
else {
if (
- workInProgressRootExitStatus !== RootIncomplete ||
+ 0 !== workInProgressRootExitStatus ||
(null !== current && 0 !== (current.effectTag & 64))
)
for (current = workInProgress.child; null !== current; ) {
@@ -4808,27 +5186,27 @@ function completeWork(current, workInProgress, renderExpirationTime) {
null === newProps.lastEffect &&
(workInProgress.firstEffect = null);
workInProgress.lastEffect = newProps.lastEffect;
- current = renderExpirationTime;
+ current = renderLanes;
for (newProps = workInProgress.child; null !== newProps; )
(rootContainerInstance = newProps),
- (renderExpirationTime = current),
+ (renderLanes = current),
(rootContainerInstance.effectTag &= 2),
(rootContainerInstance.nextEffect = null),
(rootContainerInstance.firstEffect = null),
(rootContainerInstance.lastEffect = null),
(updatePayload = rootContainerInstance.alternate),
null === updatePayload
- ? ((rootContainerInstance.childExpirationTime = 0),
- (rootContainerInstance.expirationTime = renderExpirationTime),
+ ? ((rootContainerInstance.childLanes = 0),
+ (rootContainerInstance.lanes = renderLanes),
(rootContainerInstance.child = null),
(rootContainerInstance.memoizedProps = null),
(rootContainerInstance.memoizedState = null),
(rootContainerInstance.updateQueue = null),
- (rootContainerInstance.dependencies = null))
- : ((rootContainerInstance.childExpirationTime =
- updatePayload.childExpirationTime),
- (rootContainerInstance.expirationTime =
- updatePayload.expirationTime),
+ (rootContainerInstance.dependencies = null),
+ (rootContainerInstance.stateNode = null))
+ : ((rootContainerInstance.childLanes =
+ updatePayload.childLanes),
+ (rootContainerInstance.lanes = updatePayload.lanes),
(rootContainerInstance.child = updatePayload.child),
(rootContainerInstance.memoizedProps =
updatePayload.memoizedProps),
@@ -4836,15 +5214,15 @@ function completeWork(current, workInProgress, renderExpirationTime) {
updatePayload.memoizedState),
(rootContainerInstance.updateQueue =
updatePayload.updateQueue),
- (renderExpirationTime = updatePayload.dependencies),
+ (rootContainerInstance.type = updatePayload.type),
+ (renderLanes = updatePayload.dependencies),
(rootContainerInstance.dependencies =
- null === renderExpirationTime
+ null === renderLanes
? null
: {
- expirationTime:
- renderExpirationTime.expirationTime,
- firstContext: renderExpirationTime.firstContext,
- responders: renderExpirationTime.responders
+ lanes: renderLanes.lanes,
+ firstContext: renderLanes.firstContext,
+ responders: renderLanes.responders
})),
(newProps = newProps.sibling);
push(
@@ -4881,12 +5259,11 @@ function completeWork(current, workInProgress, renderExpirationTime) {
);
} else
2 * now() - newProps.renderingStartTime > newProps.tailExpiration &&
- 1 < renderExpirationTime &&
+ 1073741824 !== renderLanes &&
((workInProgress.effectTag |= 64),
(rootContainerInstance = !0),
cutOffTailIfNeeded(newProps, !1),
- (workInProgress.expirationTime = workInProgress.childExpirationTime =
- renderExpirationTime - 1));
+ (workInProgress.lanes = renderLanes));
newProps.isBackwards
? ((updatePayload.sibling = workInProgress.child),
(workInProgress.child = updatePayload))
@@ -4914,6 +5291,17 @@ function completeWork(current, workInProgress, renderExpirationTime) {
),
current)
: null;
+ case 23:
+ case 24:
+ return (
+ popRenderLanes(),
+ null !== current &&
+ (null !== current.memoizedState) !==
+ (null !== workInProgress.memoizedState) &&
+ "unstable-defer-without-hiding" !== newProps.mode &&
+ (workInProgress.effectTag |= 4),
+ null
+ );
}
throw Error(
"Unknown unit of work tag (" +
@@ -4934,6 +5322,7 @@ function unwindWork(workInProgress) {
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
effectTag = workInProgress.effectTag;
if (0 !== (effectTag & 64))
throw Error(
@@ -4958,16 +5347,25 @@ function unwindWork(workInProgress) {
return popHostContainer(), null;
case 10:
return popProvider(workInProgress), null;
+ case 23:
+ case 24:
+ return popRenderLanes(), null;
default:
return null;
}
}
function createCapturedValue(value, source) {
- return {
- value: value,
- source: source,
- stack: getStackByFiberInDevAndProd(source)
- };
+ try {
+ var info = "",
+ node = source;
+ do (info += describeFiber(node)), (node = node.return);
+ while (node);
+ var JSCompiler_inline_result = info;
+ } catch (x) {
+ JSCompiler_inline_result =
+ "\nError generating stack: " + x.message + "\n" + x.stack;
+ }
+ return { value: value, source: source, stack: JSCompiler_inline_result };
}
if (
"function" !==
@@ -4976,51 +5374,61 @@ if (
throw Error(
"Expected ReactFiberErrorDialog.showErrorDialog to be a function."
);
-function logCapturedError(capturedError) {
- !1 !==
- ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
- capturedError
- ) && console.error(capturedError.error);
-}
-var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
-function logError(boundary, errorInfo) {
- var source = errorInfo.source,
- stack = errorInfo.stack;
- null === stack &&
- null !== source &&
- (stack = getStackByFiberInDevAndProd(source));
- errorInfo = {
- componentName: null !== source ? getComponentName(source.type) : null,
- componentStack: null !== stack ? stack : "",
- error: errorInfo.value,
- errorBoundary: null,
- errorBoundaryName: null,
- errorBoundaryFound: !1,
- willRetry: !1
- };
- null !== boundary &&
- 1 === boundary.tag &&
- ((errorInfo.errorBoundary = boundary.stateNode),
- (errorInfo.errorBoundaryName = getComponentName(boundary.type)),
- (errorInfo.errorBoundaryFound = !0),
- (errorInfo.willRetry = !0));
+function logCapturedError(boundary, errorInfo) {
try {
- logCapturedError(errorInfo);
+ !1 !==
+ ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({
+ componentStack: null !== errorInfo.stack ? errorInfo.stack : "",
+ error: errorInfo.value,
+ errorBoundary:
+ null !== boundary && 1 === boundary.tag ? boundary.stateNode : null
+ }) && console.error(errorInfo.value);
} catch (e) {
setTimeout(function() {
throw e;
});
}
}
-function safelyCallComponentWillUnmount(current, instance) {
- try {
- (instance.props = current.memoizedProps),
- (instance.state = current.memoizedState),
- instance.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(current, unmountError);
+var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
+function createRootErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ lane.payload = { element: null };
+ var error = errorInfo.value;
+ lane.callback = function() {
+ hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
+ logCapturedError(fiber, errorInfo);
+ };
+ return lane;
+}
+function createClassErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+ if ("function" === typeof getDerivedStateFromError) {
+ var error = errorInfo.value;
+ lane.payload = function() {
+ logCapturedError(fiber, errorInfo);
+ return getDerivedStateFromError(error);
+ };
}
+ var inst = fiber.stateNode;
+ null !== inst &&
+ "function" === typeof inst.componentDidCatch &&
+ (lane.callback = function() {
+ "function" !== typeof getDerivedStateFromError &&
+ (null === legacyErrorBoundariesThatAlreadyFailed
+ ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
+ : legacyErrorBoundariesThatAlreadyFailed.add(this),
+ logCapturedError(fiber, errorInfo));
+ var stack = errorInfo.stack;
+ this.componentDidCatch(errorInfo.value, {
+ componentStack: null !== stack ? stack : ""
+ });
+ });
+ return lane;
}
+var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
function safelyDetachRef(current) {
var ref = current.ref;
if (null !== ref)
@@ -5054,6 +5462,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
}
return;
case 3:
+ return;
case 5:
case 6:
case 4:
@@ -5064,58 +5473,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitHookEffectListUnmount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var destroy = effect.destroy;
- effect.destroy = void 0;
- void 0 !== destroy && destroy();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
-function commitHookEffectListMount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var create = effect.create;
- effect.destroy = create();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
function commitLifeCycles(finishedRoot, current, finishedWork) {
switch (finishedWork.tag) {
case 0:
case 11:
case 15:
case 22:
- commitHookEffectListMount(3, finishedWork);
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ if (3 === (finishedRoot.tag & 3)) {
+ var create$81 = finishedRoot.create;
+ finishedRoot.destroy = create$81();
+ }
+ finishedRoot = finishedRoot.next;
+ } while (finishedRoot !== current);
+ }
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ var _effect = finishedRoot;
+ create$81 = _effect.next;
+ _effect = _effect.tag;
+ 0 !== (_effect & 4) &&
+ 0 !== (_effect & 1) &&
+ (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot),
+ enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot));
+ finishedRoot = create$81;
+ } while (finishedRoot !== current);
+ }
return;
case 1:
finishedRoot = finishedWork.stateNode;
- if (finishedWork.effectTag & 4)
- if (null === current) finishedRoot.componentDidMount();
- else {
- var prevProps =
- finishedWork.elementType === finishedWork.type
- ? current.memoizedProps
- : resolveDefaultProps(finishedWork.type, current.memoizedProps);
- finishedRoot.componentDidUpdate(
- prevProps,
- current.memoizedState,
- finishedRoot.__reactInternalSnapshotBeforeUpdate
- );
- }
+ finishedWork.effectTag & 4 &&
+ (null === current
+ ? finishedRoot.componentDidMount()
+ : ((create$81 =
+ finishedWork.elementType === finishedWork.type
+ ? current.memoizedProps
+ : resolveDefaultProps(
+ finishedWork.type,
+ current.memoizedProps
+ )),
+ finishedRoot.componentDidUpdate(
+ create$81,
+ current.memoizedState,
+ finishedRoot.__reactInternalSnapshotBeforeUpdate
+ )));
current = finishedWork.updateQueue;
null !== current &&
commitUpdateQueue(finishedWork, current, finishedRoot);
@@ -5136,10 +5544,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) {
}
return;
case 5:
- if (null === current && finishedWork.effectTag & 4)
- throw Error(
- "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue."
- );
+ null === current && finishedWork.effectTag & 4 && shim();
return;
case 6:
return;
@@ -5153,74 +5558,26 @@ function commitLifeCycles(finishedRoot, current, finishedWork) {
case 17:
case 20:
case 21:
+ case 23:
+ case 24:
return;
}
throw Error(
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) {
- "function" === typeof onCommitFiberUnmount &&
- onCommitFiberUnmount(current$jscomp$0);
- switch (current$jscomp$0.tag) {
- case 0:
- case 11:
- case 14:
- case 15:
- case 22:
- finishedRoot = current$jscomp$0.updateQueue;
- if (
- null !== finishedRoot &&
- ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot)
- ) {
- var firstEffect = finishedRoot.next;
- runWithPriority(
- 97 < renderPriorityLevel ? 97 : renderPriorityLevel,
- function() {
- var effect = firstEffect;
- do {
- var _destroy = effect.destroy;
- if (void 0 !== _destroy) {
- var current = current$jscomp$0;
- try {
- _destroy();
- } catch (error) {
- captureCommitPhaseError(current, error);
- }
- }
- effect = effect.next;
- } while (effect !== firstEffect);
- }
- );
- }
- break;
- case 1:
- safelyDetachRef(current$jscomp$0);
- renderPriorityLevel = current$jscomp$0.stateNode;
- "function" === typeof renderPriorityLevel.componentWillUnmount &&
- safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel);
- break;
- case 5:
- safelyDetachRef(current$jscomp$0);
- break;
- case 4:
- createChildNodeSet(current$jscomp$0.stateNode.containerInfo);
- }
-}
-function detachFiber(current) {
- var alternate = current.alternate;
- current.return = null;
- current.child = null;
- current.memoizedState = null;
- current.updateQueue = null;
- current.dependencies = null;
- current.alternate = null;
- current.firstEffect = null;
- current.lastEffect = null;
- current.pendingProps = null;
- current.memoizedProps = null;
- current.stateNode = null;
- null !== alternate && detachFiber(alternate);
+function detachFiberMutation(fiber) {
+ fiber.alternate = null;
+ fiber.child = null;
+ fiber.dependencies = null;
+ fiber.firstEffect = null;
+ fiber.lastEffect = null;
+ fiber.memoizedProps = null;
+ fiber.memoizedState = null;
+ fiber.pendingProps = null;
+ fiber.return = null;
+ fiber.stateNode = null;
+ fiber.updateQueue = null;
}
function commitWork(current, finishedWork) {
switch (finishedWork.tag) {
@@ -5229,7 +5586,19 @@ function commitWork(current, finishedWork) {
case 14:
case 15:
case 22:
- commitHookEffectListUnmount(3, finishedWork);
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedWork = current = current.next;
+ do {
+ if (3 === (finishedWork.tag & 3)) {
+ var destroy = finishedWork.destroy;
+ finishedWork.destroy = void 0;
+ void 0 !== destroy && destroy();
+ }
+ finishedWork = finishedWork.next;
+ } while (finishedWork !== current);
+ }
return;
case 12:
return;
@@ -5241,6 +5610,9 @@ function commitWork(current, finishedWork) {
case 19:
attachSuspenseRetryListeners(finishedWork);
return;
+ case 23:
+ case 24:
+ return;
}
a: {
switch (finishedWork.tag) {
@@ -5259,84 +5631,46 @@ function commitWork(current, finishedWork) {
}
}
function attachSuspenseRetryListeners(finishedWork) {
- var thenables = finishedWork.updateQueue;
- if (null !== thenables) {
+ var wakeables = finishedWork.updateQueue;
+ if (null !== wakeables) {
finishedWork.updateQueue = null;
var retryCache = finishedWork.stateNode;
null === retryCache &&
(retryCache = finishedWork.stateNode = new PossiblyWeakSet());
- thenables.forEach(function(thenable) {
- var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
- retryCache.has(thenable) ||
- (retryCache.add(thenable), thenable.then(retry, retry));
+ wakeables.forEach(function(wakeable) {
+ var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
+ retryCache.has(wakeable) ||
+ (retryCache.add(wakeable), wakeable.then(retry, retry));
});
}
}
-var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
-function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- expirationTime.payload = { element: null };
- var error = errorInfo.value;
- expirationTime.callback = function() {
- hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
- logError(fiber, errorInfo);
- };
- return expirationTime;
-}
-function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
- if ("function" === typeof getDerivedStateFromError) {
- var error = errorInfo.value;
- expirationTime.payload = function() {
- logError(fiber, errorInfo);
- return getDerivedStateFromError(error);
- };
- }
- var inst = fiber.stateNode;
- null !== inst &&
- "function" === typeof inst.componentDidCatch &&
- (expirationTime.callback = function() {
- "function" !== typeof getDerivedStateFromError &&
- (null === legacyErrorBoundariesThatAlreadyFailed
- ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logError(fiber, errorInfo));
- var stack = errorInfo.stack;
- this.componentDidCatch(errorInfo.value, {
- componentStack: null !== stack ? stack : ""
- });
- });
- return expirationTime;
+function isSuspenseBoundaryBeingHidden(current, finishedWork) {
+ return null !== current &&
+ ((current = current.memoizedState),
+ null === current || null !== current.dehydrated)
+ ? ((finishedWork = finishedWork.memoizedState),
+ null !== finishedWork && null === finishedWork.dehydrated)
+ : !1;
}
var ceil = Math.ceil,
- ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
+ ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
- NoContext = 0,
- LegacyUnbatchedContext = 8,
- RenderContext = 16,
- CommitContext = 32,
- RootIncomplete = 0,
- RootFatalErrored = 1,
- RootErrored = 2,
- RootSuspended = 3,
- RootSuspendedWithDelay = 4,
- RootCompleted = 5,
- executionContext = NoContext,
+ executionContext = 0,
workInProgressRoot = null,
workInProgress = null,
- renderExpirationTime$1 = 0,
- workInProgressRootExitStatus = RootIncomplete,
+ workInProgressRootRenderLanes = 0,
+ subtreeRenderLanes = 0,
+ subtreeRenderLanesCursor = createCursor(0),
+ workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
- workInProgressRootLatestProcessedExpirationTime = 1073741823,
- workInProgressRootLatestSuspenseTimeout = 1073741823,
+ workInProgressRootLatestSuspenseTimeout = -1,
workInProgressRootCanSuspendUsingConfig = null,
- workInProgressRootNextUnprocessedUpdateTime = 0,
- workInProgressRootHasPendingPing = !1,
+ workInProgressRootIncludedLanes = 0,
+ workInProgressRootSkippedLanes = 0,
+ workInProgressRootUpdatedLanes = 0,
+ workInProgressRootPingedLanes = 0,
+ mostRecentlyUpdatedRoot = null,
globalMostRecentFallbackTime = 0,
- FALLBACK_THROTTLE_MS = 500,
nextEffect = null,
hasUncaughtError = !1,
firstUncaughtError = null,
@@ -5344,205 +5678,200 @@ var ceil = Math.ceil,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsRenderPriority = 90,
+ pendingPassiveHookEffectsMount = [],
+ pendingPassiveHookEffectsUnmount = [],
rootsWithPendingDiscreteUpdates = null,
nestedUpdateCount = 0,
rootWithNestedUpdates = null,
- currentEventTime = 0;
-function requestCurrentTimeForUpdate() {
- return (executionContext & (RenderContext | CommitContext)) !== NoContext
- ? 1073741821 - ((now() / 10) | 0)
- : 0 !== currentEventTime
+ currentEventTime = -1,
+ currentEventWipLanes = 0,
+ currentEventPendingLanes = 0,
+ focusedInstanceHandle = null,
+ shouldFireAfterActiveInstanceBlur = !1;
+function requestEventTime() {
+ return 0 !== (executionContext & 48)
+ ? now()
+ : -1 !== currentEventTime
? currentEventTime
- : (currentEventTime = 1073741821 - ((now() / 10) | 0));
+ : (currentEventTime = now());
}
-function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
+function requestUpdateLane(fiber, suspenseConfig) {
fiber = fiber.mode;
- if (0 === (fiber & 2)) return 1073741823;
- var priorityLevel = getCurrentPriorityLevel();
- if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822;
- if ((executionContext & RenderContext) !== NoContext)
- return renderExpirationTime$1;
- if (null !== suspenseConfig)
- currentTime =
- 1073741821 -
- 25 *
- ((((1073741821 -
- currentTime +
- (suspenseConfig.timeoutMs | 0 || 5e3) / 10) /
- 25) |
- 0) +
- 1);
- else
- switch (priorityLevel) {
- case 99:
- currentTime = 1073741823;
- break;
- case 98:
- currentTime =
- 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1);
- break;
- case 97:
- case 96:
- currentTime =
- 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1);
- break;
- case 95:
- currentTime = 2;
- break;
- default:
- throw Error("Expected a valid priority level");
- }
- null !== workInProgressRoot &&
- currentTime === renderExpirationTime$1 &&
- --currentTime;
- return currentTime;
-}
-function scheduleWork(fiber, expirationTime) {
+ if (0 === (fiber & 2)) return 1;
+ if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2;
+ 0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes);
+ if (null !== suspenseConfig) {
+ suspenseConfig = suspenseConfig.timeoutMs;
+ fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6;
+ 0 !== currentEventPendingLanes &&
+ (currentEventPendingLanes =
+ null !== mostRecentlyUpdatedRoot
+ ? mostRecentlyUpdatedRoot.pendingLanes
+ : 0);
+ suspenseConfig = currentEventWipLanes;
+ var pendingLanes = currentEventPendingLanes;
+ if (8 === fiber)
+ (fiber = pickArbitraryLane(122880 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 8192)),
+ (suspenseConfig = fiber);
+ else if (6 === fiber)
+ (fiber = pickArbitraryLane(3932160 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 262144)),
+ (suspenseConfig = fiber);
+ else
+ throw Error(
+ "Invalid transition priority: " + fiber + ". This is a bug in React."
+ );
+ return suspenseConfig;
+ }
+ suspenseConfig = getCurrentPriorityLevel();
+ 0 !== (executionContext & 4) && 98 === suspenseConfig
+ ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes))
+ : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)),
+ (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes)));
+ return suspenseConfig;
+}
+function scheduleUpdateOnFiber(fiber, lane, eventTime) {
if (50 < nestedUpdateCount)
throw ((nestedUpdateCount = 0),
(rootWithNestedUpdates = null),
Error(
- "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
- ));
- fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
- if (null !== fiber) {
- var priorityLevel = getCurrentPriorityLevel();
- 1073741823 === expirationTime
- ? (executionContext & LegacyUnbatchedContext) !== NoContext &&
- (executionContext & (RenderContext | CommitContext)) === NoContext
- ? performSyncWorkOnRoot(fiber)
- : (ensureRootIsScheduled(fiber),
- executionContext === NoContext && flushSyncCallbackQueue())
- : ensureRootIsScheduled(fiber);
- (executionContext & 4) === NoContext ||
- (98 !== priorityLevel && 99 !== priorityLevel) ||
- (null === rootsWithPendingDiscreteUpdates
- ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]))
- : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)),
- (void 0 === priorityLevel || priorityLevel > expirationTime) &&
- rootsWithPendingDiscreteUpdates.set(fiber, expirationTime)));
- }
-}
-function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
- fiber.expirationTime < expirationTime &&
- (fiber.expirationTime = expirationTime);
- var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < expirationTime &&
- (alternate.expirationTime = expirationTime);
- var node = fiber.return,
- root = null;
- if (null === node && 3 === fiber.tag) root = fiber.stateNode;
- else
- for (; null !== node; ) {
- alternate = node.alternate;
- node.childExpirationTime < expirationTime &&
- (node.childExpirationTime = expirationTime);
- null !== alternate &&
- alternate.childExpirationTime < expirationTime &&
- (alternate.childExpirationTime = expirationTime);
- if (null === node.return && 3 === node.tag) {
- root = node.stateNode;
- break;
+ "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
+ ));
+ fiber = markUpdateLaneFromFiberToRoot(fiber, lane);
+ if (null === fiber) return null;
+ markRootUpdated(fiber, lane, eventTime);
+ fiber === workInProgressRoot &&
+ ((workInProgressRootUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(fiber, workInProgressRootRenderLanes));
+ var priorityLevel = getCurrentPriorityLevel();
+ 1 === lane
+ ? 0 !== (executionContext & 8) && 0 === (executionContext & 48)
+ ? performSyncWorkOnRoot(fiber)
+ : (ensureRootIsScheduled(fiber, eventTime),
+ 0 === executionContext && flushSyncCallbackQueue())
+ : (0 === (executionContext & 4) ||
+ (98 !== priorityLevel && 99 !== priorityLevel) ||
+ (null === rootsWithPendingDiscreteUpdates
+ ? (rootsWithPendingDiscreteUpdates = new Set([fiber]))
+ : rootsWithPendingDiscreteUpdates.add(fiber)),
+ ensureRootIsScheduled(fiber, eventTime));
+ mostRecentlyUpdatedRoot = fiber;
+}
+function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
+ sourceFiber.lanes |= lane;
+ var alternate = sourceFiber.alternate;
+ null !== alternate && (alternate.lanes |= lane);
+ alternate = sourceFiber;
+ for (sourceFiber = sourceFiber.return; null !== sourceFiber; )
+ (sourceFiber.childLanes |= lane),
+ (alternate = sourceFiber.alternate),
+ null !== alternate && (alternate.childLanes |= lane),
+ (alternate = sourceFiber),
+ (sourceFiber = sourceFiber.return);
+ return 3 === alternate.tag ? alternate.stateNode : null;
+}
+function ensureRootIsScheduled(root, currentTime) {
+ for (
+ var existingCallbackNode = root.callbackNode,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes,
+ expirationTimes = root.expirationTimes,
+ lanes = root.pendingLanes;
+ 0 < lanes;
+
+ ) {
+ var index$5 = 31 - clz32(lanes),
+ lane = 1 << index$5,
+ expirationTime = expirationTimes[index$5];
+ if (-1 === expirationTime) {
+ if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) {
+ expirationTime = currentTime;
+ getHighestPriorityLanes(lane);
+ var priority = return_highestLanePriority;
+ expirationTimes[index$5] =
+ 12 <= priority
+ ? expirationTime + 1e3
+ : 6 <= priority
+ ? expirationTime + 5e3
+ : -1;
}
- node = node.return;
- }
- null !== root &&
- (workInProgressRoot === root &&
- (markUnprocessedUpdateTime(expirationTime),
- workInProgressRootExitStatus === RootSuspendedWithDelay &&
- markRootSuspendedAtTime(root, renderExpirationTime$1)),
- markRootUpdatedAtTime(root, expirationTime));
- return root;
-}
-function getNextRootExpirationTimeToWorkOn(root) {
- var lastExpiredTime = root.lastExpiredTime;
- if (0 !== lastExpiredTime) return lastExpiredTime;
- lastExpiredTime = root.firstPendingTime;
- if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime;
- var lastPingedTime = root.lastPingedTime;
- root = root.nextKnownPendingLevel;
- root = lastPingedTime > root ? lastPingedTime : root;
- return 2 >= root && lastExpiredTime !== root ? 0 : root;
-}
-function ensureRootIsScheduled(root) {
- if (0 !== root.lastExpiredTime)
- (root.callbackExpirationTime = 1073741823),
- (root.callbackPriority = 99),
- (root.callbackNode = scheduleSyncCallback(
- performSyncWorkOnRoot.bind(null, root)
- ));
+ } else expirationTime <= currentTime && (root.expiredLanes |= lane);
+ lanes &= ~lane;
+ }
+ suspendedLanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ currentTime = return_highestLanePriority;
+ if (0 === suspendedLanes)
+ null !== existingCallbackNode &&
+ (existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode),
+ (root.callbackNode = null),
+ (root.callbackPriority = 0));
else {
- var expirationTime = getNextRootExpirationTimeToWorkOn(root),
- existingCallbackNode = root.callbackNode;
- if (0 === expirationTime)
- null !== existingCallbackNode &&
- ((root.callbackNode = null),
- (root.callbackExpirationTime = 0),
- (root.callbackPriority = 90));
- else {
- var priorityLevel = requestCurrentTimeForUpdate();
- 1073741823 === expirationTime
- ? (priorityLevel = 99)
- : 1 === expirationTime || 2 === expirationTime
- ? (priorityLevel = 95)
- : ((priorityLevel =
- 10 * (1073741821 - expirationTime) -
- 10 * (1073741821 - priorityLevel)),
- (priorityLevel =
- 0 >= priorityLevel
- ? 99
- : 250 >= priorityLevel
- ? 98
- : 5250 >= priorityLevel
- ? 97
- : 95));
- if (null !== existingCallbackNode) {
- var existingCallbackPriority = root.callbackPriority;
- if (
- root.callbackExpirationTime === expirationTime &&
- existingCallbackPriority >= priorityLevel
- )
- return;
- existingCallbackNode !== fakeCallbackNode &&
- Scheduler_cancelCallback(existingCallbackNode);
- }
- root.callbackExpirationTime = expirationTime;
- root.callbackPriority = priorityLevel;
- expirationTime =
- 1073741823 === expirationTime
- ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root))
- : scheduleCallback(
- priorityLevel,
- performConcurrentWorkOnRoot.bind(null, root),
- { timeout: 10 * (1073741821 - expirationTime) - now() }
- );
- root.callbackNode = expirationTime;
+ if (null !== existingCallbackNode) {
+ if (root.callbackPriority === currentTime) return;
+ existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode);
}
+ 17 === currentTime
+ ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)),
+ null === syncQueue
+ ? ((syncQueue = [existingCallbackNode]),
+ (immediateQueueCallbackNode = Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueueImpl
+ )))
+ : syncQueue.push(existingCallbackNode),
+ (existingCallbackNode = fakeCallbackNode))
+ : 16 === currentTime
+ ? (existingCallbackNode = scheduleCallback(
+ 99,
+ performSyncWorkOnRoot.bind(null, root)
+ ))
+ : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)),
+ (existingCallbackNode = scheduleCallback(
+ existingCallbackNode,
+ performConcurrentWorkOnRoot.bind(null, root)
+ )));
+ root.callbackPriority = currentTime;
+ root.callbackNode = existingCallbackNode;
}
}
function performConcurrentWorkOnRoot(root, didTimeout) {
- currentEventTime = 0;
- if (didTimeout) {
- didTimeout = requestCurrentTimeForUpdate();
- var lastExpiredTime = root.lastExpiredTime;
- if (0 === lastExpiredTime || lastExpiredTime > didTimeout)
- root.lastExpiredTime = didTimeout;
- ensureRootIsScheduled(root);
- return null;
- }
- lastExpiredTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 === lastExpiredTime) return null;
- didTimeout = root.callbackNode;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ currentEventTime = -1;
+ currentEventPendingLanes = currentEventWipLanes = 0;
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- flushPassiveEffects();
- var expirationTime = lastExpiredTime;
- var exitStatus = executionContext;
- executionContext |= RenderContext;
+ var originalCallbackNode = root.callbackNode;
+ if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
+ return null;
+ var lanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ if (0 === lanes) return null;
+ if (didTimeout)
+ return (
+ (root.expiredLanes |= lanes & root.pendingLanes),
+ ensureRootIsScheduled(root, now()),
+ null
+ );
+ didTimeout = lanes;
+ var prevExecutionContext = executionContext;
+ executionContext |= 16;
var prevDispatcher = pushDispatcher();
- (root === workInProgressRoot && expirationTime === renderExpirationTime$1) ||
- prepareFreshStack(root, expirationTime);
+ (workInProgressRoot === root &&
+ workInProgressRootRenderLanes === didTimeout) ||
+ prepareFreshStack(root, didTimeout);
do
try {
workLoopConcurrent();
@@ -5552,156 +5881,120 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
}
while (1);
resetContextDependencies();
- ReactCurrentDispatcher$1.current = prevDispatcher;
- executionContext = exitStatus;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
+ executionContext = prevExecutionContext;
null !== workInProgress
- ? (exitStatus = RootIncomplete)
+ ? (didTimeout = 0)
: ((workInProgressRoot = null),
- (exitStatus = workInProgressRootExitStatus));
- if (exitStatus !== RootIncomplete) {
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
- throw ((didTimeout = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
- didTimeout);
- expirationTime = root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
- switch (exitStatus) {
- case RootIncomplete:
- case RootFatalErrored:
+ (workInProgressRootRenderLanes = 0),
+ (didTimeout = workInProgressRootExitStatus));
+ if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes))
+ prepareFreshStack(root, 0);
+ else if (0 !== didTimeout) {
+ 2 === didTimeout &&
+ ((executionContext |= 64),
+ root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (didTimeout = renderRootSync(root, lanes)));
+ if (1 === didTimeout)
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = root.current.alternate;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
throw Error("Root did not complete. This is a bug in React.");
- case RootErrored:
+ case 2:
commitRoot(root);
break;
- case RootSuspended:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- expirationTime
- ));
+ case 3:
+ markRootSuspended$1(root, lanes);
if (
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- ((expirationTime =
- globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()),
- 10 < expirationTime)
+ (lanes & 62914560) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
) {
- if (
- workInProgressRootHasPendingPing &&
- ((prevDispatcher = root.lastPingedTime),
- 0 === prevDispatcher || prevDispatcher >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- prevDispatcher = getNextRootExpirationTimeToWorkOn(root);
- if (0 !== prevDispatcher && prevDispatcher !== lastExpiredTime) break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ if (0 !== getNextLanes(root, 0)) break;
+ prevExecutionContext = root.suspendedLanes;
+ if ((prevExecutionContext & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & prevExecutionContext;
break;
}
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- expirationTime
+ didTimeout
);
break;
}
commitRoot(root);
break;
- case RootSuspendedWithDelay:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- expirationTime
- ));
- if (
- workInProgressRootHasPendingPing &&
- ((expirationTime = root.lastPingedTime),
- 0 === expirationTime || expirationTime >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- expirationTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 !== expirationTime && expirationTime !== lastExpiredTime) break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if (0 !== getNextLanes(root, 0)) break;
+ didTimeout = root.suspendedLanes;
+ if ((didTimeout & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & didTimeout;
break;
}
- 1073741823 !== workInProgressRootLatestSuspenseTimeout
- ? (expirationTime =
- 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) -
- now())
- : 1073741823 === workInProgressRootLatestProcessedExpirationTime
- ? (expirationTime = 0)
- : ((expirationTime =
- 10 *
- (1073741821 - workInProgressRootLatestProcessedExpirationTime) -
- 5e3),
- (exitStatus = now()),
- (lastExpiredTime =
- 10 * (1073741821 - lastExpiredTime) - exitStatus),
- (expirationTime = exitStatus - expirationTime),
- 0 > expirationTime && (expirationTime = 0),
- (expirationTime =
- (120 > expirationTime
+ lanes = getMostRecentEventTime(root, lanes);
+ -1 !== workInProgressRootLatestSuspenseTimeout
+ ? (lanes = workInProgressRootLatestSuspenseTimeout - now())
+ : -1 === lanes
+ ? (lanes = 0)
+ : ((lanes = now() - lanes),
+ (lanes =
+ (120 > lanes
? 120
- : 480 > expirationTime
+ : 480 > lanes
? 480
- : 1080 > expirationTime
+ : 1080 > lanes
? 1080
- : 1920 > expirationTime
+ : 1920 > lanes
? 1920
- : 3e3 > expirationTime
+ : 3e3 > lanes
? 3e3
- : 4320 > expirationTime
+ : 4320 > lanes
? 4320
- : 1960 * ceil(expirationTime / 1960)) - expirationTime),
- lastExpiredTime < expirationTime &&
- (expirationTime = lastExpiredTime));
- if (10 < expirationTime) {
+ : 1960 * ceil(lanes / 1960)) - lanes));
+ if (10 < lanes) {
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- expirationTime
+ lanes
);
break;
}
commitRoot(root);
break;
- case RootCompleted:
+ case 5:
+ prevDispatcher = getMostRecentEventTime(root, lanes);
if (
- 1073741823 !== workInProgressRootLatestProcessedExpirationTime &&
- null !== workInProgressRootCanSuspendUsingConfig
- ) {
- prevDispatcher = workInProgressRootLatestProcessedExpirationTime;
- var suspenseConfig = workInProgressRootCanSuspendUsingConfig;
- expirationTime = suspenseConfig.busyMinDurationMs | 0;
- 0 >= expirationTime
- ? (expirationTime = 0)
- : ((exitStatus = suspenseConfig.busyDelayMs | 0),
- (prevDispatcher =
- now() -
- (10 * (1073741821 - prevDispatcher) -
- (suspenseConfig.timeoutMs | 0 || 5e3))),
- (expirationTime =
- prevDispatcher <= exitStatus
+ -1 !== prevDispatcher &&
+ null !== workInProgressRootCanSuspendUsingConfig &&
+ ((didTimeout =
+ workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0),
+ 0 >= didTimeout
+ ? (didTimeout = 0)
+ : ((prevExecutionContext =
+ workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0),
+ (prevDispatcher = now() - prevDispatcher),
+ (didTimeout =
+ prevDispatcher <= prevExecutionContext
? 0
- : exitStatus + expirationTime - prevDispatcher));
- if (10 < expirationTime) {
- markRootSuspendedAtTime(root, lastExpiredTime);
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- expirationTime
- );
- break;
- }
+ : prevExecutionContext + didTimeout - prevDispatcher)),
+ 10 < didTimeout)
+ ) {
+ markRootSuspended$1(root, lanes);
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ didTimeout
+ );
+ break;
}
commitRoot(root);
break;
@@ -5709,42 +6002,68 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
throw Error("Unknown root exit status.");
}
}
- ensureRootIsScheduled(root);
- return root.callbackNode === didTimeout
+ ensureRootIsScheduled(root, now());
+ return root.callbackNode === originalCallbackNode
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function markRootSuspended$1(root, suspendedLanes) {
+ suspendedLanes &= ~workInProgressRootPingedLanes;
+ suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ root.suspendedLanes |= suspendedLanes;
+ root.pingedLanes &= ~suspendedLanes;
+ for (root = root.expirationTimes; 0 < suspendedLanes; ) {
+ var index$10 = 31 - clz32(suspendedLanes),
+ lane = 1 << index$10;
+ root[index$10] = -1;
+ suspendedLanes &= ~lane;
+ }
+}
function performSyncWorkOnRoot(root) {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
flushPassiveEffects();
- var lastExpiredTime = root.lastExpiredTime;
- lastExpiredTime =
- 0 !== lastExpiredTime
- ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime
- ? renderExpirationTime$1
- : lastExpiredTime
- : 1073741823;
- var exitStatus = renderRootSync(root, lastExpiredTime);
+ if (
+ root === workInProgressRoot &&
+ 0 !== (root.expiredLanes & workInProgressRootRenderLanes)
+ ) {
+ var lanes = workInProgressRootRenderLanes;
+ var exitStatus = renderRootSync(root, lanes);
+ 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) &&
+ ((lanes = getNextLanes(root, lanes)),
+ (exitStatus = renderRootSync(root, lanes)));
+ } else
+ (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes));
0 !== root.tag &&
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
+ 2 === exitStatus &&
+ ((executionContext |= 64),
+ root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (exitStatus = renderRootSync(root, lanes)));
+ if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
exitStatus);
root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
+ root.finishedLanes = lanes;
commitRoot(root);
- ensureRootIsScheduled(root);
+ ensureRootIsScheduled(root, now());
return null;
}
-function prepareFreshStack(root, expirationTime) {
+function pushRenderLanes(fiber, lanes) {
+ push(subtreeRenderLanesCursor, subtreeRenderLanes);
+ subtreeRenderLanes |= lanes;
+ workInProgressRootIncludedLanes |= lanes;
+}
+function popRenderLanes() {
+ subtreeRenderLanes = subtreeRenderLanesCursor.current;
+ pop(subtreeRenderLanesCursor);
+}
+function prepareFreshStack(root, lanes) {
root.finishedWork = null;
- root.finishedExpirationTime = 0;
+ root.finishedLanes = 0;
var timeoutHandle = root.timeoutHandle;
-1 !== timeoutHandle &&
((root.timeoutHandle = -1), cancelTimeout(timeoutHandle));
@@ -5762,6 +6081,7 @@ function prepareFreshStack(root, expirationTime) {
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
break;
case 5:
popHostContext(interruptedWork);
@@ -5777,25 +6097,29 @@ function prepareFreshStack(root, expirationTime) {
break;
case 10:
popProvider(interruptedWork);
+ break;
+ case 23:
+ case 24:
+ popRenderLanes();
}
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
workInProgress = createWorkInProgress(root.current, null);
- renderExpirationTime$1 = expirationTime;
- workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
+ workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823;
+ workInProgressRootLatestSuspenseTimeout = -1;
workInProgressRootCanSuspendUsingConfig = null;
- workInProgressRootNextUnprocessedUpdateTime = 0;
- workInProgressRootHasPendingPing = !1;
+ workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
}
function handleError(root$jscomp$0, thrownValue) {
do {
+ var erroredWork = workInProgress;
try {
resetContextDependencies();
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
- if (didScheduleRenderPhaseUpdate)
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ if (didScheduleRenderPhaseUpdate) {
for (
var hook = currentlyRenderingFiber$1.memoizedState;
null !== hook;
@@ -5805,21 +6129,24 @@ function handleError(root$jscomp$0, thrownValue) {
null !== queue && (queue.pending = null);
hook = hook.next;
}
- renderExpirationTime = 0;
+ didScheduleRenderPhaseUpdate = !1;
+ }
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
- didScheduleRenderPhaseUpdate = !1;
- if (null === workInProgress || null === workInProgress.return)
- return (
- (workInProgressRootExitStatus = RootFatalErrored),
- (workInProgressRootFatalError = thrownValue),
- (workInProgress = null)
- );
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ ReactCurrentOwner$2.current = null;
+ if (null === erroredWork || null === erroredWork.return) {
+ workInProgressRootExitStatus = 1;
+ workInProgressRootFatalError = thrownValue;
+ workInProgress = null;
+ break;
+ }
a: {
var root = root$jscomp$0,
- returnFiber = workInProgress.return,
- sourceFiber = workInProgress,
+ returnFiber = erroredWork.return,
+ sourceFiber = erroredWork,
value = thrownValue;
- thrownValue = renderExpirationTime$1;
+ thrownValue = workInProgressRootRenderLanes;
sourceFiber.effectTag |= 2048;
sourceFiber.firstEffect = sourceFiber.lastEffect = null;
if (
@@ -5827,27 +6154,27 @@ function handleError(root$jscomp$0, thrownValue) {
"object" === typeof value &&
"function" === typeof value.then
) {
- var thenable = value;
+ var wakeable = value;
if (0 === (sourceFiber.mode & 2)) {
var currentSource = sourceFiber.alternate;
currentSource
? ((sourceFiber.updateQueue = currentSource.updateQueue),
(sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.expirationTime = currentSource.expirationTime))
+ (sourceFiber.lanes = currentSource.lanes))
: ((sourceFiber.updateQueue = null),
(sourceFiber.memoizedState = null));
}
var hasInvisibleParentBoundary =
0 !== (suspenseStackCursor.current & 1),
- _workInProgress = returnFiber;
+ workInProgress$76 = returnFiber;
do {
var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === _workInProgress.tag)) {
- var nextState = _workInProgress.memoizedState;
+ if ((JSCompiler_temp = 13 === workInProgress$76.tag)) {
+ var nextState = workInProgress$76.memoizedState;
if (null !== nextState)
JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
else {
- var props = _workInProgress.memoizedProps;
+ var props = workInProgress$76.memoizedProps;
JSCompiler_temp =
void 0 === props.fallback
? !1
@@ -5859,23 +6186,24 @@ function handleError(root$jscomp$0, thrownValue) {
}
}
if (JSCompiler_temp) {
- var thenables = _workInProgress.updateQueue;
- if (null === thenables) {
+ var wakeables = workInProgress$76.updateQueue;
+ if (null === wakeables) {
var updateQueue = new Set();
- updateQueue.add(thenable);
- _workInProgress.updateQueue = updateQueue;
- } else thenables.add(thenable);
- if (0 === (_workInProgress.mode & 2)) {
- _workInProgress.effectTag |= 64;
+ updateQueue.add(wakeable);
+ workInProgress$76.updateQueue = updateQueue;
+ } else wakeables.add(wakeable);
+ if (0 === (workInProgress$76.mode & 2)) {
+ workInProgress$76.effectTag |= 64;
+ sourceFiber.effectTag |= 16384;
sourceFiber.effectTag &= -2981;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
- var update = createUpdate(1073741823, null);
+ var update = createUpdate(-1, 1, null);
update.tag = 2;
enqueueUpdate(sourceFiber, update);
}
- sourceFiber.expirationTime = 1073741823;
+ sourceFiber.lanes |= 1;
break a;
}
value = void 0;
@@ -5884,108 +6212,105 @@ function handleError(root$jscomp$0, thrownValue) {
null === pingCache
? ((pingCache = root.pingCache = new PossiblyWeakMap()),
(value = new Set()),
- pingCache.set(thenable, value))
- : ((value = pingCache.get(thenable)),
+ pingCache.set(wakeable, value))
+ : ((value = pingCache.get(wakeable)),
void 0 === value &&
- ((value = new Set()), pingCache.set(thenable, value)));
+ ((value = new Set()), pingCache.set(wakeable, value)));
if (!value.has(sourceFiber)) {
value.add(sourceFiber);
var ping = pingSuspendedRoot.bind(
null,
root,
- thenable,
+ wakeable,
sourceFiber
);
- thenable.then(ping, ping);
+ wakeable.then(ping, ping);
}
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
+ workInProgress$76.effectTag |= 4096;
+ workInProgress$76.lanes = thrownValue;
break a;
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$76 = workInProgress$76.return;
+ } while (null !== workInProgress$76);
value = Error(
(getComponentName(sourceFiber.type) || "A React component") +
- " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." +
- getStackByFiberInDevAndProd(sourceFiber)
+ " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display."
);
}
- workInProgressRootExitStatus !== RootCompleted &&
- (workInProgressRootExitStatus = RootErrored);
+ 5 !== workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 2);
value = createCapturedValue(value, sourceFiber);
- _workInProgress = returnFiber;
+ workInProgress$76 = returnFiber;
do {
- switch (_workInProgress.tag) {
+ switch (workInProgress$76.tag) {
case 3:
- thenable = value;
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update = createRootErrorUpdate(
- _workInProgress,
- thenable,
+ root = value;
+ workInProgress$76.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$76.lanes |= thrownValue;
+ var update$77 = createRootErrorUpdate(
+ workInProgress$76,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update);
+ enqueueCapturedUpdate(workInProgress$76, update$77);
break a;
case 1:
- thenable = value;
- var ctor = _workInProgress.type,
- instance = _workInProgress.stateNode;
+ root = value;
+ var ctor = workInProgress$76.type,
+ instance = workInProgress$76.stateNode;
if (
- 0 === (_workInProgress.effectTag & 64) &&
+ 0 === (workInProgress$76.effectTag & 64) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update2 = createClassErrorUpdate(
- _workInProgress,
- thenable,
+ workInProgress$76.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$76.lanes |= thrownValue;
+ var update$80 = createClassErrorUpdate(
+ workInProgress$76,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update2);
+ enqueueCapturedUpdate(workInProgress$76, update$80);
break a;
}
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$76 = workInProgress$76.return;
+ } while (null !== workInProgress$76);
}
- workInProgress = completeUnitOfWork(workInProgress);
+ completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
thrownValue = yetAnotherThrownValue;
+ workInProgress === erroredWork &&
+ null !== erroredWork &&
+ (workInProgress = erroredWork = erroredWork.return);
continue;
}
break;
} while (1);
}
function pushDispatcher() {
- var prevDispatcher = ReactCurrentDispatcher$1.current;
- ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ var prevDispatcher = ReactCurrentDispatcher$2.current;
+ ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
-function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
- expirationTime < workInProgressRootLatestProcessedExpirationTime &&
- 2 < expirationTime &&
- (workInProgressRootLatestProcessedExpirationTime = expirationTime);
+function markRenderEventTimeAndConfig(eventTime, suspenseConfig) {
null !== suspenseConfig &&
- expirationTime < workInProgressRootLatestSuspenseTimeout &&
- 2 < expirationTime &&
- ((workInProgressRootLatestSuspenseTimeout = expirationTime),
- (workInProgressRootCanSuspendUsingConfig = suspenseConfig));
+ ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3),
+ eventTime > workInProgressRootLatestSuspenseTimeout &&
+ ((workInProgressRootLatestSuspenseTimeout = eventTime),
+ (workInProgressRootCanSuspendUsingConfig = suspenseConfig)));
}
-function markUnprocessedUpdateTime(expirationTime) {
- expirationTime > workInProgressRootNextUnprocessedUpdateTime &&
- (workInProgressRootNextUnprocessedUpdateTime = expirationTime);
-}
-function renderRootSync(root, expirationTime) {
+function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
+ executionContext |= 16;
var prevDispatcher = pushDispatcher();
- (root === workInProgressRoot && expirationTime === renderExpirationTime$1) ||
- prepareFreshStack(root, expirationTime);
+ (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) ||
+ prepareFreshStack(root, lanes);
do
try {
workLoopSync();
@@ -5996,142 +6321,144 @@ function renderRootSync(root, expirationTime) {
while (1);
resetContextDependencies();
executionContext = prevExecutionContext;
- ReactCurrentDispatcher$1.current = prevDispatcher;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
if (null !== workInProgress)
throw Error(
"Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
);
workInProgressRoot = null;
+ workInProgressRootRenderLanes = 0;
return workInProgressRootExitStatus;
}
function workLoopSync() {
- for (; null !== workInProgress; )
- workInProgress = performUnitOfWork(workInProgress);
+ for (; null !== workInProgress; ) performUnitOfWork(workInProgress);
}
function workLoopConcurrent() {
- for (; null !== workInProgress && !shouldYield(); )
- workInProgress = performUnitOfWork(workInProgress);
+ for (; null !== workInProgress && !Scheduler_shouldYield(); )
+ performUnitOfWork(workInProgress);
}
function performUnitOfWork(unitOfWork) {
- var next = beginWork$1(
- unitOfWork.alternate,
- unitOfWork,
- renderExpirationTime$1
- );
+ var next = beginWork$1(unitOfWork.alternate, unitOfWork, subtreeRenderLanes);
unitOfWork.memoizedProps = unitOfWork.pendingProps;
- null === next && (next = completeUnitOfWork(unitOfWork));
+ null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next);
ReactCurrentOwner$2.current = null;
- return next;
}
function completeUnitOfWork(unitOfWork) {
- workInProgress = unitOfWork;
+ var completedWork = unitOfWork;
do {
- var current = workInProgress.alternate;
- unitOfWork = workInProgress.return;
- if (0 === (workInProgress.effectTag & 2048)) {
- current = completeWork(current, workInProgress, renderExpirationTime$1);
+ var current = completedWork.alternate;
+ unitOfWork = completedWork.return;
+ if (0 === (completedWork.effectTag & 2048)) {
+ current = completeWork(current, completedWork, subtreeRenderLanes);
+ if (null !== current) {
+ workInProgress = current;
+ return;
+ }
+ current = completedWork;
if (
- 1 === renderExpirationTime$1 ||
- 1 !== workInProgress.childExpirationTime
+ (24 !== current.tag && 23 !== current.tag) ||
+ null === current.memoizedState ||
+ 0 !== (subtreeRenderLanes & 1073741824) ||
+ 0 === (current.mode & 4)
) {
- for (
- var newChildExpirationTime = 0, _child = workInProgress.child;
- null !== _child;
-
- ) {
- var _childUpdateExpirationTime = _child.expirationTime,
- _childChildExpirationTime = _child.childExpirationTime;
- _childUpdateExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = _childUpdateExpirationTime);
- _childChildExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = _childChildExpirationTime);
- _child = _child.sibling;
- }
- workInProgress.childExpirationTime = newChildExpirationTime;
+ for (var newChildLanes = 0, child = current.child; null !== child; )
+ (newChildLanes |= child.lanes | child.childLanes),
+ (child = child.sibling);
+ current.childLanes = newChildLanes;
}
- if (null !== current) return current;
null !== unitOfWork &&
0 === (unitOfWork.effectTag & 2048) &&
(null === unitOfWork.firstEffect &&
- (unitOfWork.firstEffect = workInProgress.firstEffect),
- null !== workInProgress.lastEffect &&
+ (unitOfWork.firstEffect = completedWork.firstEffect),
+ null !== completedWork.lastEffect &&
(null !== unitOfWork.lastEffect &&
- (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect),
- (unitOfWork.lastEffect = workInProgress.lastEffect)),
- 1 < workInProgress.effectTag &&
+ (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect),
+ (unitOfWork.lastEffect = completedWork.lastEffect)),
+ 1 < completedWork.effectTag &&
(null !== unitOfWork.lastEffect
- ? (unitOfWork.lastEffect.nextEffect = workInProgress)
- : (unitOfWork.firstEffect = workInProgress),
- (unitOfWork.lastEffect = workInProgress)));
+ ? (unitOfWork.lastEffect.nextEffect = completedWork)
+ : (unitOfWork.firstEffect = completedWork),
+ (unitOfWork.lastEffect = completedWork)));
} else {
- current = unwindWork(workInProgress);
- if (null !== current) return (current.effectTag &= 2047), current;
+ current = unwindWork(completedWork);
+ if (null !== current) {
+ current.effectTag &= 2047;
+ workInProgress = current;
+ return;
+ }
null !== unitOfWork &&
((unitOfWork.firstEffect = unitOfWork.lastEffect = null),
(unitOfWork.effectTag |= 2048));
}
- current = workInProgress.sibling;
- if (null !== current) return current;
- workInProgress = unitOfWork;
- } while (null !== workInProgress);
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootCompleted);
- return null;
-}
-function getRemainingExpirationTime(fiber) {
- var updateExpirationTime = fiber.expirationTime;
- fiber = fiber.childExpirationTime;
- return updateExpirationTime > fiber ? updateExpirationTime : fiber;
+ completedWork = completedWork.sibling;
+ if (null !== completedWork) {
+ workInProgress = completedWork;
+ return;
+ }
+ workInProgress = completedWork = unitOfWork;
+ } while (null !== completedWork);
+ 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
function commitRoot(root) {
var renderPriorityLevel = getCurrentPriorityLevel();
runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel));
return null;
}
-function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
+function commitRootImpl(root, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- var finishedWork = root$jscomp$1.finishedWork,
- expirationTime = root$jscomp$1.finishedExpirationTime;
+ var finishedWork = root.finishedWork;
if (null === finishedWork) return null;
- root$jscomp$1.finishedWork = null;
- root$jscomp$1.finishedExpirationTime = 0;
- if (finishedWork === root$jscomp$1.current)
+ root.finishedWork = null;
+ root.finishedLanes = 0;
+ if (finishedWork === root.current)
throw Error(
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
);
- root$jscomp$1.callbackNode = null;
- root$jscomp$1.callbackExpirationTime = 0;
- root$jscomp$1.callbackPriority = 90;
- root$jscomp$1.nextKnownPendingLevel = 0;
- var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(
- finishedWork
- );
- root$jscomp$1.firstPendingTime = remainingExpirationTimeBeforeCommit;
- expirationTime <= root$jscomp$1.lastSuspendedTime
- ? (root$jscomp$1.firstSuspendedTime = root$jscomp$1.lastSuspendedTime = root$jscomp$1.nextKnownPendingLevel = 0)
- : expirationTime <= root$jscomp$1.firstSuspendedTime &&
- (root$jscomp$1.firstSuspendedTime = expirationTime - 1);
- expirationTime <= root$jscomp$1.lastPingedTime &&
- (root$jscomp$1.lastPingedTime = 0);
- expirationTime <= root$jscomp$1.lastExpiredTime &&
- (root$jscomp$1.lastExpiredTime = 0);
- root$jscomp$1 === workInProgressRoot &&
+ root.callbackNode = null;
+ var remainingLanes = finishedWork.lanes | finishedWork.childLanes,
+ remainingLanes$jscomp$0 = remainingLanes,
+ noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0;
+ root.pendingLanes = remainingLanes$jscomp$0;
+ root.suspendedLanes = 0;
+ root.pingedLanes = 0;
+ root.expiredLanes &= remainingLanes$jscomp$0;
+ root.mutableReadLanes &= remainingLanes$jscomp$0;
+ root.entangledLanes &= remainingLanes$jscomp$0;
+ remainingLanes$jscomp$0 = root.entanglements;
+ for (
+ var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes;
+ 0 < noLongerPendingLanes;
+
+ ) {
+ var index$11 = 31 - clz32(noLongerPendingLanes),
+ lane = 1 << index$11;
+ remainingLanes$jscomp$0[index$11] = 0;
+ eventTimes[index$11] = -1;
+ expirationTimes[index$11] = -1;
+ noLongerPendingLanes &= ~lane;
+ }
+ null !== rootsWithPendingDiscreteUpdates &&
+ 0 === (remainingLanes & 24) &&
+ rootsWithPendingDiscreteUpdates.has(root) &&
+ rootsWithPendingDiscreteUpdates.delete(root);
+ root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
- (renderExpirationTime$1 = 0));
+ (workInProgressRootRenderLanes = 0));
1 < finishedWork.effectTag
? null !== finishedWork.lastEffect
? ((finishedWork.lastEffect.nextEffect = finishedWork),
- (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect))
- : (remainingExpirationTimeBeforeCommit = finishedWork)
- : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect);
- if (null !== remainingExpirationTimeBeforeCommit) {
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- ReactCurrentOwner$2.current = null;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ (remainingLanes = finishedWork.firstEffect))
+ : (remainingLanes = finishedWork)
+ : (remainingLanes = finishedWork.firstEffect);
+ if (null !== remainingLanes) {
+ remainingLanes$jscomp$0 = executionContext;
+ executionContext |= 32;
+ focusedInstanceHandle = ReactCurrentOwner$2.current = null;
+ shouldFireAfterActiveInstanceBlur = !1;
+ nextEffect = remainingLanes;
do
try {
commitBeforeMutationEffects();
@@ -6141,15 +6468,11 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
- nextEffect = remainingExpirationTimeBeforeCommit;
+ focusedInstanceHandle = null;
+ nextEffect = remainingLanes;
do
try {
- for (
- var root = root$jscomp$1,
- renderPriorityLevel = renderPriorityLevel$jscomp$1;
- null !== nextEffect;
-
- ) {
+ for (; null !== nextEffect; ) {
var effectTag = nextEffect.effectTag;
if (effectTag & 128) {
var current = nextEffect.alternate;
@@ -6180,49 +6503,106 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
commitWork(nextEffect.alternate, nextEffect);
break;
case 8:
- var current$jscomp$0 = nextEffect;
- a: for (
- var finishedRoot = root,
- root$jscomp$0 = current$jscomp$0,
- renderPriorityLevel$jscomp$0 = renderPriorityLevel,
- node = root$jscomp$0;
- ;
-
- )
+ eventTimes = nextEffect;
+ a: for (noLongerPendingLanes = expirationTimes = eventTimes; ; ) {
+ index$11 = noLongerPendingLanes;
if (
- (commitUnmount(
- finishedRoot,
- node,
- renderPriorityLevel$jscomp$0
- ),
- null !== node.child)
+ injectedHook &&
+ "function" === typeof injectedHook.onCommitFiberUnmount
)
- (node.child.return = node), (node = node.child);
+ try {
+ injectedHook.onCommitFiberUnmount(rendererID, index$11);
+ } catch (err) {}
+ switch (index$11.tag) {
+ case 0:
+ case 11:
+ case 14:
+ case 15:
+ case 22:
+ var updateQueue = index$11.updateQueue;
+ if (null !== updateQueue) {
+ var lastEffect = updateQueue.lastEffect;
+ if (null !== lastEffect) {
+ var firstEffect = lastEffect.next;
+ lane = firstEffect;
+ do {
+ var _effect2 = lane,
+ destroy = _effect2.destroy,
+ tag = _effect2.tag;
+ if (void 0 !== destroy)
+ if (0 !== (tag & 4))
+ enqueuePendingPassiveHookEffectUnmount(
+ index$11,
+ lane
+ );
+ else {
+ _effect2 = index$11;
+ try {
+ destroy();
+ } catch (error) {
+ captureCommitPhaseError(_effect2, error);
+ }
+ }
+ lane = lane.next;
+ } while (lane !== firstEffect);
+ }
+ }
+ break;
+ case 1:
+ safelyDetachRef(index$11);
+ var instance = index$11.stateNode;
+ if ("function" === typeof instance.componentWillUnmount)
+ try {
+ (lane = index$11),
+ (_effect2 = instance),
+ (_effect2.props = lane.memoizedProps),
+ (_effect2.state = lane.memoizedState),
+ _effect2.componentWillUnmount();
+ } catch (unmountError) {
+ captureCommitPhaseError(index$11, unmountError);
+ }
+ break;
+ case 5:
+ safelyDetachRef(index$11);
+ break;
+ case 4:
+ createChildNodeSet(index$11.stateNode.containerInfo);
+ }
+ if (null !== noLongerPendingLanes.child)
+ (noLongerPendingLanes.child.return = noLongerPendingLanes),
+ (noLongerPendingLanes = noLongerPendingLanes.child);
else {
- if (node === root$jscomp$0) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === root$jscomp$0)
+ if (noLongerPendingLanes === expirationTimes) break;
+ for (; null === noLongerPendingLanes.sibling; ) {
+ if (
+ null === noLongerPendingLanes.return ||
+ noLongerPendingLanes.return === expirationTimes
+ )
break a;
- node = node.return;
+ noLongerPendingLanes = noLongerPendingLanes.return;
}
- node.sibling.return = node.return;
- node = node.sibling;
+ noLongerPendingLanes.sibling.return =
+ noLongerPendingLanes.return;
+ noLongerPendingLanes = noLongerPendingLanes.sibling;
}
- detachFiber(current$jscomp$0);
+ }
+ var alternate = eventTimes.alternate;
+ detachFiberMutation(eventTimes);
+ null !== alternate && detachFiberMutation(alternate);
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$92) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$92);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
- root$jscomp$1.current = finishedWork;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ root.current = finishedWork;
+ nextEffect = remainingLanes;
do
try {
- for (effectTag = root$jscomp$1; null !== nextEffect; ) {
+ for (effectTag = root; null !== nextEffect; ) {
var effectTag$jscomp$0 = nextEffect.effectTag;
effectTag$jscomp$0 & 36 &&
commitLifeCycles(effectTag, nextEffect.alternate, nextEffect);
@@ -6230,13 +6610,13 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
current = void 0;
var ref = nextEffect.ref;
if (null !== ref) {
- var instance = nextEffect.stateNode;
+ var instance$jscomp$0 = nextEffect.stateNode;
switch (nextEffect.tag) {
case 5:
- current = instance.canonical;
+ current = instance$jscomp$0.canonical;
break;
default:
- current = instance;
+ current = instance$jscomp$0;
}
"function" === typeof ref
? ref(current)
@@ -6245,54 +6625,68 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$93) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$93);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
nextEffect = null;
requestPaint();
- executionContext = prevExecutionContext;
- } else root$jscomp$1.current = finishedWork;
+ executionContext = remainingLanes$jscomp$0;
+ } else root.current = finishedWork;
if (rootDoesHavePassiveEffects)
(rootDoesHavePassiveEffects = !1),
- (rootWithPendingPassiveEffects = root$jscomp$1),
- (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$1);
+ (rootWithPendingPassiveEffects = root),
+ (pendingPassiveEffectsRenderPriority = renderPriorityLevel);
else
- for (
- nextEffect = remainingExpirationTimeBeforeCommit;
- null !== nextEffect;
-
- )
- (renderPriorityLevel$jscomp$1 = nextEffect.nextEffect),
+ for (nextEffect = remainingLanes; null !== nextEffect; )
+ (renderPriorityLevel = nextEffect.nextEffect),
(nextEffect.nextEffect = null),
- (nextEffect = renderPriorityLevel$jscomp$1);
- renderPriorityLevel$jscomp$1 = root$jscomp$1.firstPendingTime;
- 0 === renderPriorityLevel$jscomp$1 &&
- (legacyErrorBoundariesThatAlreadyFailed = null);
- 1073741823 === renderPriorityLevel$jscomp$1
- ? root$jscomp$1 === rootWithNestedUpdates
+ nextEffect.effectTag & 8 && (nextEffect.sibling = null),
+ (nextEffect = renderPriorityLevel);
+ remainingLanes = root.pendingLanes;
+ 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
+ 1 === remainingLanes
+ ? root === rootWithNestedUpdates
? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$1))
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
: (nestedUpdateCount = 0);
- "function" === typeof onCommitFiberRoot &&
- onCommitFiberRoot(finishedWork.stateNode, expirationTime);
- ensureRootIsScheduled(root$jscomp$1);
+ finishedWork = finishedWork.stateNode;
+ if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot)
+ try {
+ injectedHook.onCommitFiberRoot(
+ rendererID,
+ finishedWork,
+ void 0,
+ 64 === (finishedWork.current.effectTag & 64)
+ );
+ } catch (err) {}
+ ensureRootIsScheduled(root, now());
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
- (root$jscomp$1 = firstUncaughtError),
+ (root = firstUncaughtError),
(firstUncaughtError = null),
- root$jscomp$1);
- if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null;
+ root);
+ if (0 !== (executionContext & 8)) return null;
flushSyncCallbackQueue();
return null;
}
function commitBeforeMutationEffects() {
for (; null !== nextEffect; ) {
+ var current = nextEffect.alternate;
+ shouldFireAfterActiveInstanceBlur ||
+ null === focusedInstanceHandle ||
+ (0 !== (nextEffect.effectTag & 8)
+ ? doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0)
+ : 13 === nextEffect.tag &&
+ isSuspenseBoundaryBeingHidden(current, nextEffect) &&
+ doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0));
var effectTag = nextEffect.effectTag;
0 !== (effectTag & 256) &&
- commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect);
+ commitBeforeMutationLifeCycles(current, nextEffect);
0 === (effectTag & 512) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
@@ -6310,47 +6704,83 @@ function flushPassiveEffects() {
? 97
: pendingPassiveEffectsRenderPriority;
pendingPassiveEffectsRenderPriority = 90;
+ schedulerPriorityToLanePriority(priorityLevel);
return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
}
+ return !1;
+}
+function enqueuePendingPassiveHookEffectMount(fiber, effect) {
+ pendingPassiveHookEffectsMount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
+}
+function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
+ pendingPassiveHookEffectsUnmount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
}
function flushPassiveEffectsImpl() {
if (null === rootWithPendingPassiveEffects) return !1;
var root = rootWithPendingPassiveEffects;
rootWithPendingPassiveEffects = null;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- for (root = root.current.firstEffect; null !== root; ) {
+ executionContext |= 32;
+ var unmountEffects = pendingPassiveHookEffectsUnmount;
+ pendingPassiveHookEffectsUnmount = [];
+ for (var i = 0; i < unmountEffects.length; i += 2) {
+ var effect$98 = unmountEffects[i],
+ fiber = unmountEffects[i + 1],
+ destroy = effect$98.destroy;
+ effect$98.destroy = void 0;
+ if ("function" === typeof destroy)
+ try {
+ destroy();
+ } catch (error) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error);
+ }
+ }
+ unmountEffects = pendingPassiveHookEffectsMount;
+ pendingPassiveHookEffectsMount = [];
+ for (i = 0; i < unmountEffects.length; i += 2) {
+ effect$98 = unmountEffects[i];
+ fiber = unmountEffects[i + 1];
try {
- var finishedWork = root;
- if (0 !== (finishedWork.effectTag & 512))
- switch (finishedWork.tag) {
- case 0:
- case 11:
- case 15:
- case 22:
- commitHookEffectListUnmount(5, finishedWork),
- commitHookEffectListMount(5, finishedWork);
- }
- } catch (error) {
- if (null === root) throw Error("Should be working on an effect.");
- captureCommitPhaseError(root, error);
+ var create$102 = effect$98.create;
+ effect$98.destroy = create$102();
+ } catch (error$103) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error$103);
}
- finishedWork = root.nextEffect;
- root.nextEffect = null;
- root = finishedWork;
}
+ for (root = root.current.firstEffect; null !== root; )
+ (create$102 = root.nextEffect),
+ (root.nextEffect = null),
+ root.effectTag & 8 && (root.sibling = null),
+ (root = create$102);
executionContext = prevExecutionContext;
flushSyncCallbackQueue();
return !0;
}
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823);
+ sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1);
enqueueUpdate(rootFiber, sourceFiber);
- rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823);
- null !== rootFiber && ensureRootIsScheduled(rootFiber);
+ sourceFiber = requestEventTime();
+ rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1);
+ null !== rootFiber &&
+ (markRootUpdated(rootFiber, 1, sourceFiber),
+ ensureRootIsScheduled(rootFiber, sourceFiber));
}
function captureCommitPhaseError(sourceFiber, error) {
if (3 === sourceFiber.tag)
@@ -6369,143 +6799,156 @@ function captureCommitPhaseError(sourceFiber, error) {
!legacyErrorBoundariesThatAlreadyFailed.has(instance)))
) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823);
+ sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1);
enqueueUpdate(fiber, sourceFiber);
- fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823);
- null !== fiber && ensureRootIsScheduled(fiber);
+ sourceFiber = requestEventTime();
+ fiber = markUpdateLaneFromFiberToRoot(fiber, 1);
+ null !== fiber &&
+ (markRootUpdated(fiber, 1, sourceFiber),
+ ensureRootIsScheduled(fiber, sourceFiber));
break;
}
}
fiber = fiber.return;
}
}
-function pingSuspendedRoot(root, thenable, suspendedTime) {
+function pingSuspendedRoot(root, wakeable, pingedLanes) {
var pingCache = root.pingCache;
- null !== pingCache && pingCache.delete(thenable);
- workInProgressRoot === root && renderExpirationTime$1 === suspendedTime
- ? workInProgressRootExitStatus === RootSuspendedWithDelay ||
- (workInProgressRootExitStatus === RootSuspended &&
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
- ? prepareFreshStack(root, renderExpirationTime$1)
- : (workInProgressRootHasPendingPing = !0)
- : isRootSuspendedAtTime(root, suspendedTime) &&
- ((thenable = root.lastPingedTime),
- (0 !== thenable && thenable < suspendedTime) ||
- ((root.lastPingedTime = suspendedTime), ensureRootIsScheduled(root)));
-}
-function resolveRetryThenable(boundaryFiber, thenable) {
+ null !== pingCache && pingCache.delete(wakeable);
+ wakeable = requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & pingedLanes;
+ workInProgressRoot === root &&
+ (workInProgressRootRenderLanes & pingedLanes) === pingedLanes &&
+ (4 === workInProgressRootExitStatus ||
+ (3 === workInProgressRootExitStatus &&
+ (workInProgressRootRenderLanes & 62914560) ===
+ workInProgressRootRenderLanes &&
+ 500 > now() - globalMostRecentFallbackTime)
+ ? prepareFreshStack(root, 0)
+ : (workInProgressRootPingedLanes |= pingedLanes));
+ ensureRootIsScheduled(root, wakeable);
+}
+function resolveRetryWakeable(boundaryFiber, wakeable) {
var retryCache = boundaryFiber.stateNode;
- null !== retryCache && retryCache.delete(thenable);
- thenable = 0;
- 0 === thenable &&
- ((thenable = requestCurrentTimeForUpdate()),
- (thenable = computeExpirationForFiber(thenable, boundaryFiber, null)));
- boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable);
- null !== boundaryFiber && ensureRootIsScheduled(boundaryFiber);
+ null !== retryCache && retryCache.delete(wakeable);
+ wakeable = 0;
+ 0 === wakeable &&
+ ((wakeable = boundaryFiber.mode),
+ 0 === (wakeable & 2)
+ ? (wakeable = 1)
+ : 0 === (wakeable & 4)
+ ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2)
+ : (0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes),
+ (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)),
+ 0 === wakeable && (wakeable = 4194304)));
+ retryCache = requestEventTime();
+ boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable);
+ null !== boundaryFiber &&
+ (markRootUpdated(boundaryFiber, wakeable, retryCache),
+ ensureRootIsScheduled(boundaryFiber, retryCache));
}
var beginWork$1;
-beginWork$1 = function(current, workInProgress, renderExpirationTime) {
- var updateExpirationTime = workInProgress.expirationTime;
+beginWork$1 = function(current, workInProgress, renderLanes) {
+ var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
didPerformWorkStackCursor.current
)
didReceiveUpdate = !0;
+ else if (0 !== (renderLanes & updateLanes))
+ didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1;
else {
- if (updateExpirationTime < renderExpirationTime) {
- didReceiveUpdate = !1;
- switch (workInProgress.tag) {
- case 3:
- pushHostRootContext(workInProgress);
- break;
- case 5:
- pushHostContext(workInProgress);
- break;
- case 1:
- isContextProvider(workInProgress.type) &&
- pushContextProvider(workInProgress);
- break;
- case 4:
- pushHostContainer(
+ didReceiveUpdate = !1;
+ switch (workInProgress.tag) {
+ case 3:
+ pushHostRootContext(workInProgress);
+ break;
+ case 5:
+ pushHostContext(workInProgress);
+ break;
+ case 1:
+ isContextProvider(workInProgress.type) &&
+ pushContextProvider(workInProgress);
+ break;
+ case 4:
+ pushHostContainer(
+ workInProgress,
+ workInProgress.stateNode.containerInfo
+ );
+ break;
+ case 10:
+ updateLanes = workInProgress.memoizedProps.value;
+ var context = workInProgress.type._context;
+ push(valueCursor, context._currentValue2);
+ context._currentValue2 = updateLanes;
+ break;
+ case 13:
+ if (null !== workInProgress.memoizedState) {
+ if (0 !== (renderLanes & workInProgress.child.childLanes))
+ return updateSuspenseComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ workInProgress = bailoutOnAlreadyFinishedWork(
+ current,
workInProgress,
- workInProgress.stateNode.containerInfo
+ renderLanes
);
- break;
- case 10:
- updateExpirationTime = workInProgress.memoizedProps.value;
- var context = workInProgress.type._context;
- push(valueCursor, context._currentValue2);
- context._currentValue2 = updateExpirationTime;
- break;
- case 13:
- if (null !== workInProgress.memoizedState) {
- updateExpirationTime = workInProgress.child.childExpirationTime;
- if (
- 0 !== updateExpirationTime &&
- updateExpirationTime >= renderExpirationTime
- )
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- workInProgress = bailoutOnAlreadyFinishedWork(
+ return null !== workInProgress ? workInProgress.sibling : null;
+ }
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
+ case 19:
+ updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.effectTag & 64)) {
+ if (updateLanes)
+ return updateSuspenseListComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateExpirationTime =
- workInProgress.childExpirationTime >= renderExpirationTime;
- if (0 !== (current.effectTag & 64)) {
- if (updateExpirationTime)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- workInProgress.effectTag |= 64;
- }
- context = workInProgress.memoizedState;
- null !== context &&
- ((context.rendering = null), (context.tail = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (!updateExpirationTime) return null;
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ workInProgress.effectTag |= 64;
+ }
+ context = workInProgress.memoizedState;
+ null !== context &&
+ ((context.rendering = null),
+ (context.tail = null),
+ (context.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (updateLanes) break;
+ else return null;
+ case 23:
+ case 24:
+ return (
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
+ );
}
- didReceiveUpdate = !1;
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
else didReceiveUpdate = !1;
- workInProgress.expirationTime = 0;
+ workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateExpirationTime = workInProgress.type;
+ updateLanes = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
context = getMaskedContext(workInProgress, contextStackCursor.current);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
context = renderWithHooks(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
current,
context,
- renderExpirationTime
+ renderLanes
);
workInProgress.effectTag |= 1;
if (
@@ -6517,7 +6960,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateExpirationTime)) {
+ if (isContextProvider(updateLanes)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
@@ -6526,53 +6969,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
? context.state
: null;
initializeUpdateQueue(workInProgress);
- var getDerivedStateFromProps =
- updateExpirationTime.getDerivedStateFromProps;
+ var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps;
"function" === typeof getDerivedStateFromProps &&
applyDerivedStateFromProps(
workInProgress,
- updateExpirationTime,
+ updateLanes,
getDerivedStateFromProps,
current
);
context.updater = classComponentUpdater;
workInProgress.stateNode = context;
- context._reactInternalFiber = workInProgress;
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- current,
- renderExpirationTime
- );
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, updateLanes, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
hasContext,
- renderExpirationTime
+ renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(
- null,
- workInProgress,
- context,
- renderExpirationTime
- ),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
+ context = workInProgress.elementType;
a: {
- context = workInProgress.elementType;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
- initializeLazyComponentType(context);
- if (1 !== context._status) throw context._result;
- context = context._result;
+ hasContext = context._init;
+ context = hasContext(context._payload);
workInProgress.type = context;
hasContext = workInProgress.tag = resolveLazyComponentTag(context);
current = resolveDefaultProps(context, current);
@@ -6583,7 +7014,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 1:
@@ -6592,7 +7023,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 11:
@@ -6601,7 +7032,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 14:
@@ -6610,8 +7041,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
resolveDefaultProps(context.type, current),
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
break a;
}
@@ -6624,126 +7055,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return workInProgress;
case 0:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateFunctionComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 1:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateClassComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- updateExpirationTime = workInProgress.updateQueue;
- if (null === current || null === updateExpirationTime)
+ updateLanes = workInProgress.updateQueue;
+ if (null === current || null === updateLanes)
throw Error(
"If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."
);
- updateExpirationTime = workInProgress.pendingProps;
+ updateLanes = workInProgress.pendingProps;
context = workInProgress.memoizedState;
context = null !== context ? context.element : null;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(
- workInProgress,
- updateExpirationTime,
- null,
- renderExpirationTime
- );
- updateExpirationTime = workInProgress.memoizedState.element;
- updateExpirationTime === context
+ processUpdateQueue(workInProgress, updateLanes, null, renderLanes);
+ updateLanes = workInProgress.memoizedState.element;
+ updateLanes === context
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
))
- : (reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ : (reconcileChildren(current, workInProgress, updateLanes, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateExpirationTime = workInProgress.pendingProps.children),
+ (updateLanes = workInProgress.pendingProps.children),
markRef(current, workInProgress),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
- (workInProgress = workInProgress.child),
- workInProgress
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ workInProgress.child
);
case 6:
return null;
case 13:
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
case 4:
return (
pushHostContainer(
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateExpirationTime = workInProgress.pendingProps),
+ (updateLanes = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
))
: reconcileChildren(
current,
workInProgress,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
),
workInProgress.child
);
case 11:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateForwardRef(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 7:
@@ -6752,7 +7163,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
@@ -6762,7 +7173,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
@@ -6772,13 +7183,13 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
case 10:
a: {
- updateExpirationTime = workInProgress.type._context;
+ updateLanes = workInProgress.type._context;
context = workInProgress.pendingProps;
getDerivedStateFromProps = workInProgress.memoizedProps;
hasContext = context.value;
@@ -6790,9 +7201,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
((context$jscomp$0 = getDerivedStateFromProps.value),
(hasContext = objectIs(context$jscomp$0, hasContext)
? 0
- : ("function" ===
- typeof updateExpirationTime._calculateChangedBits
- ? updateExpirationTime._calculateChangedBits(
+ : ("function" === typeof updateLanes._calculateChangedBits
+ ? updateLanes._calculateChangedBits(
context$jscomp$0,
hasContext
)
@@ -6806,7 +7216,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
break a;
}
@@ -6827,25 +7237,25 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
) {
if (
- dependency.context === updateExpirationTime &&
+ dependency.context === updateLanes &&
0 !== (dependency.observedBits & hasContext)
) {
1 === context$jscomp$0.tag &&
- ((dependency = createUpdate(renderExpirationTime, null)),
+ ((dependency = createUpdate(
+ -1,
+ renderLanes & -renderLanes,
+ null
+ )),
(dependency.tag = 2),
enqueueUpdate(context$jscomp$0, dependency));
- context$jscomp$0.expirationTime < renderExpirationTime &&
- (context$jscomp$0.expirationTime = renderExpirationTime);
+ context$jscomp$0.lanes |= renderLanes;
dependency = context$jscomp$0.alternate;
- null !== dependency &&
- dependency.expirationTime < renderExpirationTime &&
- (dependency.expirationTime = renderExpirationTime);
+ null !== dependency && (dependency.lanes |= renderLanes);
scheduleWorkOnParentPath(
context$jscomp$0.return,
- renderExpirationTime
+ renderLanes
);
- list.expirationTime < renderExpirationTime &&
- (list.expirationTime = renderExpirationTime);
+ list.lanes |= renderLanes;
break;
}
dependency = dependency.next;
@@ -6883,7 +7293,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
context.children,
- renderExpirationTime
+ renderLanes
);
workInProgress = workInProgress.child;
}
@@ -6892,17 +7302,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return (
(context = workInProgress.type),
(hasContext = workInProgress.pendingProps),
- (updateExpirationTime = hasContext.children),
- prepareToReadContext(workInProgress, renderExpirationTime),
+ (updateLanes = hasContext.children),
+ prepareToReadContext(workInProgress, renderLanes),
(context = readContext(context, hasContext.unstable_observedBits)),
- (updateExpirationTime = updateExpirationTime(context)),
+ (updateLanes = updateLanes(context)),
(workInProgress.effectTag |= 1),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
workInProgress.child
);
case 14:
@@ -6918,8 +7323,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
hasContext,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
case 15:
@@ -6928,48 +7333,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
case 17:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateExpirationTime)
+ isContextProvider(updateLanes)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
- prepareToReadContext(workInProgress, renderExpirationTime),
- constructClassInstance(workInProgress, updateExpirationTime, context),
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- context,
- renderExpirationTime
- ),
+ prepareToReadContext(workInProgress, renderLanes),
+ constructClassInstance(workInProgress, updateLanes, context),
+ mountClassInstance(workInProgress, updateLanes, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
current,
- renderExpirationTime
+ renderLanes
)
);
case 19:
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
+ case 23:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ case 24:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -6977,32 +7377,6 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
"). This error is likely caused by a bug in React. Please file an issue."
);
};
-var onCommitFiberRoot = null,
- onCommitFiberUnmount = null;
-function injectInternals(internals) {
- if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1;
- var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
- if (hook.isDisabled || !hook.supportsFiber) return !0;
- try {
- var rendererID = hook.inject(internals);
- onCommitFiberRoot = function(root) {
- try {
- hook.onCommitFiberRoot(
- rendererID,
- root,
- void 0,
- 64 === (root.current.effectTag & 64)
- );
- } catch (err) {}
- };
- onCommitFiberUnmount = function(fiber) {
- try {
- hook.onCommitFiberUnmount(rendererID, fiber);
- } catch (err) {}
- };
- } catch (err) {}
- return !0;
-}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -7014,9 +7388,12 @@ function FiberNode(tag, pendingProps, key, mode) {
this.mode = mode;
this.effectTag = 0;
this.lastEffect = this.firstEffect = this.nextEffect = null;
- this.childExpirationTime = this.expirationTime = 0;
+ this.childLanes = this.lanes = 0;
this.alternate = null;
}
+function createFiber(tag, pendingProps, key, mode) {
+ return new FiberNode(tag, pendingProps, key, mode);
+}
function shouldConstruct(Component) {
Component = Component.prototype;
return !(!Component || !Component.isReactComponent);
@@ -7034,7 +7411,7 @@ function resolveLazyComponentTag(Component) {
function createWorkInProgress(current, pendingProps) {
var workInProgress = current.alternate;
null === workInProgress
- ? ((workInProgress = new FiberNode(
+ ? ((workInProgress = createFiber(
current.tag,
pendingProps,
current.key,
@@ -7046,16 +7423,13 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.alternate = current),
(current.alternate = workInProgress))
: ((workInProgress.pendingProps = pendingProps),
+ (workInProgress.type = current.type),
(workInProgress.effectTag = 0),
(workInProgress.nextEffect = null),
(workInProgress.firstEffect = null),
(workInProgress.lastEffect = null));
- if (null == current)
- throw Error("current is " + current + " but it can't be");
- if (null == workInProgress)
- throw Error("workInProgress is " + workInProgress + " but it can't be");
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
@@ -7065,7 +7439,7 @@ function createWorkInProgress(current, pendingProps) {
null === pendingProps
? null
: {
- expirationTime: pendingProps.expirationTime,
+ lanes: pendingProps.lanes,
firstContext: pendingProps.firstContext,
responders: pendingProps.responders
};
@@ -7080,7 +7454,7 @@ function createFiberFromTypeAndProps(
pendingProps,
owner,
mode,
- expirationTime
+ lanes
) {
var fiberTag = 2;
owner = type;
@@ -7089,15 +7463,10 @@ function createFiberFromTypeAndProps(
else
a: switch (type) {
case REACT_FRAGMENT_TYPE:
- return createFiberFromFragment(
- pendingProps.children,
- mode,
- expirationTime,
- key
- );
- case REACT_CONCURRENT_MODE_TYPE:
+ return createFiberFromFragment(pendingProps.children, mode, lanes, key);
+ case REACT_DEBUG_TRACING_MODE_TYPE:
fiberTag = 8;
- mode |= 7;
+ mode |= 16;
break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
@@ -7105,25 +7474,34 @@ function createFiberFromTypeAndProps(
break;
case REACT_PROFILER_TYPE:
return (
- (type = new FiberNode(12, pendingProps, key, mode | 8)),
+ (type = createFiber(12, pendingProps, key, mode | 8)),
(type.elementType = REACT_PROFILER_TYPE),
(type.type = REACT_PROFILER_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
type
);
case REACT_SUSPENSE_TYPE:
return (
- (type = new FiberNode(13, pendingProps, key, mode)),
+ (type = createFiber(13, pendingProps, key, mode)),
(type.type = REACT_SUSPENSE_TYPE),
(type.elementType = REACT_SUSPENSE_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
type
);
case REACT_SUSPENSE_LIST_TYPE:
return (
- (type = new FiberNode(19, pendingProps, key, mode)),
+ (type = createFiber(19, pendingProps, key, mode)),
(type.elementType = REACT_SUSPENSE_LIST_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
+ type
+ );
+ case REACT_OFFSCREEN_TYPE:
+ return createFiberFromOffscreen(pendingProps, mode, lanes, key);
+ case REACT_LEGACY_HIDDEN_TYPE:
+ return (
+ (type = createFiber(24, pendingProps, key, mode)),
+ (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
+ (type.lanes = lanes),
type
);
default:
@@ -7155,30 +7533,36 @@ function createFiberFromTypeAndProps(
"."
);
}
- key = new FiberNode(fiberTag, pendingProps, key, mode);
+ key = createFiber(fiberTag, pendingProps, key, mode);
key.elementType = type;
key.type = owner;
- key.expirationTime = expirationTime;
+ key.lanes = lanes;
return key;
}
-function createFiberFromFragment(elements, mode, expirationTime, key) {
- elements = new FiberNode(7, elements, key, mode);
- elements.expirationTime = expirationTime;
+function createFiberFromFragment(elements, mode, lanes, key) {
+ elements = createFiber(7, elements, key, mode);
+ elements.lanes = lanes;
return elements;
}
-function createFiberFromText(content, mode, expirationTime) {
- content = new FiberNode(6, content, null, mode);
- content.expirationTime = expirationTime;
+function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
+ pendingProps = createFiber(23, pendingProps, key, mode);
+ pendingProps.elementType = REACT_OFFSCREEN_TYPE;
+ pendingProps.lanes = lanes;
+ return pendingProps;
+}
+function createFiberFromText(content, mode, lanes) {
+ content = createFiber(6, content, null, mode);
+ content.lanes = lanes;
return content;
}
-function createFiberFromPortal(portal, mode, expirationTime) {
- mode = new FiberNode(
+function createFiberFromPortal(portal, mode, lanes) {
+ mode = createFiber(
4,
null !== portal.children ? portal.children : [],
portal.key,
mode
);
- mode.expirationTime = expirationTime;
+ mode.lanes = lanes;
mode.stateNode = {
containerInfo: portal.containerInfo,
pendingChildren: null,
@@ -7188,51 +7572,31 @@ function createFiberFromPortal(portal, mode, expirationTime) {
}
function FiberRootNode(containerInfo, tag, hydrate) {
this.tag = tag;
- this.current = null;
this.containerInfo = containerInfo;
- this.pingCache = this.pendingChildren = null;
- this.finishedExpirationTime = 0;
- this.finishedWork = null;
+ this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
this.pendingContext = this.context = null;
this.hydrate = hydrate;
this.callbackNode = null;
- this.callbackPriority = 90;
- this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0;
-}
-function isRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- root = root.lastSuspendedTime;
- return (
- 0 !== firstSuspendedTime &&
- firstSuspendedTime >= expirationTime &&
- root <= expirationTime
- );
+ this.callbackPriority = 0;
+ this.eventTimes = Array(31).fill(0);
+ this.expirationTimes = Array(31).fill(-1);
+ this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
+ this.entanglements = Array(31).fill(0);
}
-function markRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime,
- lastSuspendedTime = root.lastSuspendedTime;
- firstSuspendedTime < expirationTime &&
- (root.firstSuspendedTime = expirationTime);
- if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime)
- root.lastSuspendedTime = expirationTime;
- expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0);
- expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0);
-}
-function markRootUpdatedAtTime(root, expirationTime) {
- expirationTime > root.firstPendingTime &&
- (root.firstPendingTime = expirationTime);
- var firstSuspendedTime = root.firstSuspendedTime;
- 0 !== firstSuspendedTime &&
- (expirationTime >= firstSuspendedTime
- ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0)
- : expirationTime >= root.lastSuspendedTime &&
- (root.lastSuspendedTime = expirationTime + 1),
- expirationTime > root.nextKnownPendingLevel &&
- (root.nextKnownPendingLevel = expirationTime));
+function createPortal(children, containerInfo, implementation) {
+ var key =
+ 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
+ return {
+ $$typeof: REACT_PORTAL_TYPE,
+ key: null == key ? null : "" + key,
+ children: children,
+ containerInfo: containerInfo,
+ implementation: implementation
+ };
}
function findHostInstance(component) {
- var fiber = component._reactInternalFiber;
+ var fiber = component._reactInternals;
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
@@ -7246,11 +7610,11 @@ function findHostInstance(component) {
}
function updateContainer(element, container, parentComponent, callback) {
var current = container.current,
- currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig);
+ eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(current, suspenseConfig);
a: if (parentComponent) {
- parentComponent = parentComponent._reactInternalFiber;
+ parentComponent = parentComponent._reactInternals;
b: {
if (
getNearestMountedFiber(parentComponent) !== parentComponent ||
@@ -7259,22 +7623,23 @@ function updateContainer(element, container, parentComponent, callback) {
throw Error(
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
);
- var parentContext = parentComponent;
+ var JSCompiler_inline_result = parentComponent;
do {
- switch (parentContext.tag) {
+ switch (JSCompiler_inline_result.tag) {
case 3:
- parentContext = parentContext.stateNode.context;
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode.context;
break b;
case 1:
- if (isContextProvider(parentContext.type)) {
- parentContext =
- parentContext.stateNode
+ if (isContextProvider(JSCompiler_inline_result.type)) {
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode
.__reactInternalMemoizedMergedChildContext;
break b;
}
}
- parentContext = parentContext.return;
- } while (null !== parentContext);
+ JSCompiler_inline_result = JSCompiler_inline_result.return;
+ } while (null !== JSCompiler_inline_result);
throw Error(
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
);
@@ -7285,34 +7650,26 @@ function updateContainer(element, container, parentComponent, callback) {
parentComponent = processChildContext(
parentComponent,
Component,
- parentContext
+ JSCompiler_inline_result
);
break a;
}
}
- parentComponent = parentContext;
+ parentComponent = JSCompiler_inline_result;
} else parentComponent = emptyContextObject;
null === container.context
? (container.context = parentComponent)
: (container.pendingContext = parentComponent);
- container = createUpdate(currentTime, suspenseConfig);
+ container = createUpdate(eventTime, lane, suspenseConfig);
container.payload = { element: element };
callback = void 0 === callback ? null : callback;
null !== callback && (container.callback = callback);
enqueueUpdate(current, container);
- scheduleWork(current, currentTime);
- return currentTime;
+ scheduleUpdateOnFiber(current, lane, eventTime);
+ return lane;
}
-function createPortal(children, containerInfo, implementation) {
- var key =
- 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
- return {
- $$typeof: REACT_PORTAL_TYPE,
- key: null == key ? null : "" + key,
- children: children,
- containerInfo: containerInfo,
- implementation: implementation
- };
+function emptyFindFiberByHostInstance() {
+ return null;
}
function findNodeHandle(componentOrHandle) {
if (null == componentOrHandle) return null;
@@ -7334,53 +7691,64 @@ batchedUpdatesImpl = function(fn, a) {
return fn(a);
} finally {
(executionContext = prevExecutionContext),
- executionContext === NoContext && flushSyncCallbackQueue();
+ 0 === executionContext && flushSyncCallbackQueue();
}
};
-var roots = new Map();
-(function(devToolsConfig) {
- var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
- return injectInternals({
- bundleType: devToolsConfig.bundleType,
- version: devToolsConfig.version,
- rendererPackageName: devToolsConfig.rendererPackageName,
- rendererConfig: devToolsConfig.rendererConfig,
- overrideHookState: null,
- overrideProps: null,
- setSuspenseHandler: null,
- scheduleUpdate: null,
- currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
- findHostInstanceByFiber: function(fiber) {
- fiber = findCurrentHostFiber(fiber);
- return null === fiber ? null : fiber.stateNode;
- },
- findFiberByHostInstance: function(instance) {
- return findFiberByHostInstance ? findFiberByHostInstance(instance) : null;
- },
- findHostInstancesForRefresh: null,
- scheduleRefresh: null,
- scheduleRoot: null,
- setRefreshHandler: null,
- getCurrentFiber: null
- });
-})({
- findFiberByHostInstance: getInstanceFromInstance,
- bundleType: 0,
- version: "16.13.0",
- rendererPackageName: "react-native-renderer",
- rendererConfig: {
- getInspectorDataForViewTag: function() {
- throw Error(
- "getInspectorDataForViewTag() is not available in production"
- );
- },
- getInspectorDataForViewAtPoint: function() {
- throw Error(
- "getInspectorDataForViewAtPoint() is not available in production."
- );
- }.bind(null, findNodeHandle)
- }
-});
+var roots = new Map(),
+ devToolsConfig$jscomp$inline_891 = {
+ findFiberByHostInstance: getInstanceFromInstance,
+ bundleType: 0,
+ version: "17.0.0-alpha.0",
+ rendererPackageName: "react-native-renderer",
+ rendererConfig: {
+ getInspectorDataForViewTag: function() {
+ throw Error(
+ "getInspectorDataForViewTag() is not available in production"
+ );
+ },
+ getInspectorDataForViewAtPoint: function() {
+ throw Error(
+ "getInspectorDataForViewAtPoint() is not available in production."
+ );
+ }.bind(null, findNodeHandle)
+ }
+ };
+var internals$jscomp$inline_1074 = {
+ bundleType: devToolsConfig$jscomp$inline_891.bundleType,
+ version: devToolsConfig$jscomp$inline_891.version,
+ rendererPackageName: devToolsConfig$jscomp$inline_891.rendererPackageName,
+ rendererConfig: devToolsConfig$jscomp$inline_891.rendererConfig,
+ overrideHookState: null,
+ overrideProps: null,
+ setSuspenseHandler: null,
+ scheduleUpdate: null,
+ currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
+ findHostInstanceByFiber: function(fiber) {
+ fiber = findCurrentHostFiber(fiber);
+ return null === fiber ? null : fiber.stateNode;
+ },
+ findFiberByHostInstance:
+ devToolsConfig$jscomp$inline_891.findFiberByHostInstance ||
+ emptyFindFiberByHostInstance,
+ findHostInstancesForRefresh: null,
+ scheduleRefresh: null,
+ scheduleRoot: null,
+ setRefreshHandler: null,
+ getCurrentFiber: null
+};
+if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
+ var hook$jscomp$inline_1075 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ if (
+ !hook$jscomp$inline_1075.isDisabled &&
+ hook$jscomp$inline_1075.supportsFiber
+ )
+ try {
+ (rendererID = hook$jscomp$inline_1075.inject(
+ internals$jscomp$inline_1074
+ )),
+ (injectedHook = hook$jscomp$inline_1075);
+ } catch (err) {}
+}
exports.createPortal = function(children, containerTag) {
return createPortal(
children,
@@ -7420,7 +7788,7 @@ exports.render = function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
root = new FiberRootNode(containerTag, 0, !1);
- var uninitializedFiber = new FiberNode(3, null, null, 0);
+ var uninitializedFiber = createFiber(3, null, null, 0);
root.current = uninitializedFiber;
uninitializedFiber.stateNode = root;
initializeUpdateQueue(uninitializedFiber);
diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js
index be0ac55a7b83dc..5e573f43cf15aa 100644
--- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js
+++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js
@@ -16,16 +16,6 @@ var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/R
React = require("react"),
Scheduler = require("scheduler"),
tracing = require("scheduler/tracing");
-function getParent(inst) {
- do inst = inst.return;
- while (inst && 5 !== inst.tag);
- return inst ? inst : null;
-}
-function traverseTwoPhase(inst, fn, arg) {
- for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
- for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
- for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
-}
function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) {
var funcArgs = Array.prototype.slice.call(arguments, 3);
try {
@@ -96,109 +86,6 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
-function getListener(inst, registrationName) {
- var listener = inst.stateNode;
- if (!listener) return null;
- var props = getFiberCurrentPropsFromNode(listener);
- if (!props) return null;
- listener = props[registrationName];
- a: switch (registrationName) {
- case "onClick":
- case "onClickCapture":
- case "onDoubleClick":
- case "onDoubleClickCapture":
- case "onMouseDown":
- case "onMouseDownCapture":
- case "onMouseMove":
- case "onMouseMoveCapture":
- case "onMouseUp":
- case "onMouseUpCapture":
- case "onMouseEnter":
- (props = !props.disabled) ||
- ((inst = inst.type),
- (props = !(
- "button" === inst ||
- "input" === inst ||
- "select" === inst ||
- "textarea" === inst
- )));
- inst = !props;
- break a;
- default:
- inst = !1;
- }
- if (inst) return null;
- if (listener && "function" !== typeof listener)
- throw Error(
- "Expected `" +
- registrationName +
- "` listener to be a function, instead got a value of `" +
- typeof listener +
- "` type."
- );
- return listener;
-}
-function accumulateInto(current, next) {
- if (null == next)
- throw Error(
- "accumulateInto(...): Accumulated items must not be null or undefined."
- );
- if (null == current) return next;
- if (Array.isArray(current)) {
- if (Array.isArray(next)) return current.push.apply(current, next), current;
- current.push(next);
- return current;
- }
- return Array.isArray(next) ? [current].concat(next) : [current, next];
-}
-function forEachAccumulated(arr, cb, scope) {
- Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
-}
-function accumulateDirectionalDispatches(inst, phase, event) {
- if (
- (phase = getListener(
- inst,
- event.dispatchConfig.phasedRegistrationNames[phase]
- ))
- )
- (event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- phase
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- ));
-}
-function accumulateTwoPhaseDispatchesSingle(event) {
- event &&
- event.dispatchConfig.phasedRegistrationNames &&
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
-}
-function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- var targetInst = event._targetInst;
- targetInst = targetInst ? getParent(targetInst) : null;
- traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
- }
-}
-function accumulateDirectDispatchesSingle(event) {
- if (event && event.dispatchConfig.registrationName) {
- var inst = event._targetInst;
- if (inst && event && event.dispatchConfig.registrationName) {
- var listener = getListener(inst, event.dispatchConfig.registrationName);
- listener &&
- ((event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- )));
- }
- }
-}
function functionThatReturnsTrue() {
return !0;
}
@@ -214,6 +101,7 @@ function SyntheticEvent(
this.dispatchConfig = dispatchConfig;
this._targetInst = targetInst;
this.nativeEvent = nativeEvent;
+ this._dispatchInstances = this._dispatchListeners = null;
dispatchConfig = this.constructor.Interface;
for (var propName in dispatchConfig)
dispatchConfig.hasOwnProperty(propName) &&
@@ -293,7 +181,12 @@ SyntheticEvent.extend = function(Interface) {
return Class;
};
addEventPoolingTo(SyntheticEvent);
-function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
+function createOrGetPooledEvent(
+ dispatchConfig,
+ targetInst,
+ nativeEvent,
+ nativeInst
+) {
if (this.eventPool.length) {
var instance = this.eventPool.pop();
this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
@@ -310,8 +203,8 @@ function releasePooledEvent(event) {
10 > this.eventPool.length && this.eventPool.push(event);
}
function addEventPoolingTo(EventConstructor) {
+ EventConstructor.getPooled = createOrGetPooledEvent;
EventConstructor.eventPool = [];
- EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}
var ResponderSyntheticEvent = SyntheticEvent.extend({
@@ -439,6 +332,22 @@ function accumulate(current, next) {
? [current].concat(next)
: [current, next];
}
+function accumulateInto(current, next) {
+ if (null == next)
+ throw Error(
+ "accumulateInto(...): Accumulated items must not be null or undefined."
+ );
+ if (null == current) return next;
+ if (Array.isArray(current)) {
+ if (Array.isArray(next)) return current.push.apply(current, next), current;
+ current.push(next);
+ return current;
+ }
+ return Array.isArray(next) ? [current].concat(next) : [current, next];
+}
+function forEachAccumulated(arr, cb, scope) {
+ Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
+}
var responderInst = null,
trackedTouchCount = 0;
function changeResponder(nextResponderInst, blockHostResponder) {
@@ -452,65 +361,132 @@ function changeResponder(nextResponderInst, blockHostResponder) {
);
}
var eventTypes = {
- startShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onStartShouldSetResponder",
- captured: "onStartShouldSetResponderCapture"
- },
- dependencies: startDependencies
- },
- scrollShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onScrollShouldSetResponder",
- captured: "onScrollShouldSetResponderCapture"
- },
- dependencies: ["topScroll"]
- },
- selectionChangeShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onSelectionChangeShouldSetResponder",
- captured: "onSelectionChangeShouldSetResponderCapture"
- },
- dependencies: ["topSelectionChange"]
- },
- moveShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onMoveShouldSetResponder",
- captured: "onMoveShouldSetResponderCapture"
- },
- dependencies: moveDependencies
- },
- responderStart: {
- registrationName: "onResponderStart",
- dependencies: startDependencies
- },
- responderMove: {
- registrationName: "onResponderMove",
- dependencies: moveDependencies
- },
- responderEnd: {
- registrationName: "onResponderEnd",
- dependencies: endDependencies
+ startShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onStartShouldSetResponder",
+ captured: "onStartShouldSetResponderCapture"
},
- responderRelease: {
- registrationName: "onResponderRelease",
- dependencies: endDependencies
+ dependencies: startDependencies
+ },
+ scrollShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onScrollShouldSetResponder",
+ captured: "onScrollShouldSetResponderCapture"
},
- responderTerminationRequest: {
- registrationName: "onResponderTerminationRequest",
- dependencies: []
+ dependencies: ["topScroll"]
+ },
+ selectionChangeShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onSelectionChangeShouldSetResponder",
+ captured: "onSelectionChangeShouldSetResponderCapture"
},
- responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
- responderReject: {
- registrationName: "onResponderReject",
- dependencies: []
+ dependencies: ["topSelectionChange"]
+ },
+ moveShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onMoveShouldSetResponder",
+ captured: "onMoveShouldSetResponderCapture"
},
- responderTerminate: {
- registrationName: "onResponderTerminate",
- dependencies: []
- }
+ dependencies: moveDependencies
+ },
+ responderStart: {
+ registrationName: "onResponderStart",
+ dependencies: startDependencies
+ },
+ responderMove: {
+ registrationName: "onResponderMove",
+ dependencies: moveDependencies
+ },
+ responderEnd: {
+ registrationName: "onResponderEnd",
+ dependencies: endDependencies
+ },
+ responderRelease: {
+ registrationName: "onResponderRelease",
+ dependencies: endDependencies
},
- ResponderEventPlugin = {
+ responderTerminationRequest: {
+ registrationName: "onResponderTerminationRequest",
+ dependencies: []
+ },
+ responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
+ responderReject: { registrationName: "onResponderReject", dependencies: [] },
+ responderTerminate: {
+ registrationName: "onResponderTerminate",
+ dependencies: []
+ }
+};
+function getParent(inst) {
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ return inst ? inst : null;
+}
+function traverseTwoPhase(inst, fn, arg) {
+ for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
+}
+function getListener(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+function accumulateDirectionalDispatches(inst, phase, event) {
+ if (
+ (phase = getListener(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateDirectDispatchesSingle(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
+function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ var targetInst = event._targetInst;
+ targetInst = targetInst ? getParent(targetInst) : null;
+ traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
+ }
+}
+function accumulateTwoPhaseDispatchesSingle(event) {
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
+}
+var ResponderEventPlugin = {
_getResponder: function() {
return responderInst;
},
@@ -571,68 +547,70 @@ var eventTypes = {
JSCompiler_temp = null;
}
else JSCompiler_temp = targetInst;
- targetInst = JSCompiler_temp === responderInst;
- JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ targetInst = JSCompiler_temp;
+ JSCompiler_temp = targetInst === responderInst;
+ shouldSetEventType = ResponderSyntheticEvent.getPooled(
shouldSetEventType,
- JSCompiler_temp,
+ targetInst,
nativeEvent,
nativeEventTarget
);
- JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory;
- targetInst
+ shouldSetEventType.touchHistory =
+ ResponderTouchHistoryStore.touchHistory;
+ JSCompiler_temp
? forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingleSkipTarget
)
: forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingle
);
b: {
- shouldSetEventType = JSCompiler_temp._dispatchListeners;
- targetInst = JSCompiler_temp._dispatchInstances;
- if (Array.isArray(shouldSetEventType))
+ JSCompiler_temp = shouldSetEventType._dispatchListeners;
+ targetInst = shouldSetEventType._dispatchInstances;
+ if (Array.isArray(JSCompiler_temp))
for (
depthA = 0;
- depthA < shouldSetEventType.length &&
- !JSCompiler_temp.isPropagationStopped();
+ depthA < JSCompiler_temp.length &&
+ !shouldSetEventType.isPropagationStopped();
depthA++
) {
if (
- shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA])
+ JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA])
) {
- shouldSetEventType = targetInst[depthA];
+ JSCompiler_temp = targetInst[depthA];
break b;
}
}
else if (
- shouldSetEventType &&
- shouldSetEventType(JSCompiler_temp, targetInst)
+ JSCompiler_temp &&
+ JSCompiler_temp(shouldSetEventType, targetInst)
) {
- shouldSetEventType = targetInst;
+ JSCompiler_temp = targetInst;
break b;
}
- shouldSetEventType = null;
+ JSCompiler_temp = null;
}
- JSCompiler_temp._dispatchInstances = null;
- JSCompiler_temp._dispatchListeners = null;
- JSCompiler_temp.isPersistent() ||
- JSCompiler_temp.constructor.release(JSCompiler_temp);
- if (shouldSetEventType && shouldSetEventType !== responderInst)
+ shouldSetEventType._dispatchInstances = null;
+ shouldSetEventType._dispatchListeners = null;
+ shouldSetEventType.isPersistent() ||
+ shouldSetEventType.constructor.release(shouldSetEventType);
+ if (JSCompiler_temp && JSCompiler_temp !== responderInst)
if (
- ((JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ ((shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderGrant,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
- (JSCompiler_temp.touchHistory =
+ (shouldSetEventType.touchHistory =
ResponderTouchHistoryStore.touchHistory),
forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateDirectDispatchesSingle
),
- (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)),
+ (targetInst = !0 === executeDirectDispatch(shouldSetEventType)),
responderInst)
)
if (
@@ -659,13 +637,13 @@ var eventTypes = {
forEachAccumulated(depthA, accumulateDirectDispatchesSingle);
var JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- [JSCompiler_temp, depthA]
+ [shouldSetEventType, depthA]
);
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
} else
(shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderReject,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
@@ -682,9 +660,9 @@ var eventTypes = {
else
(JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- JSCompiler_temp
+ shouldSetEventType
)),
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
else JSCompiler_temp$jscomp$0 = null;
} else JSCompiler_temp$jscomp$0 = null;
shouldSetEventType = responderInst && isStartish(topLevelType);
@@ -812,7 +790,6 @@ function recomputePluginOrdering() {
for (var eventName in pluginIndex) {
var JSCompiler_inline_result = void 0;
var dispatchConfig = pluginIndex[eventName],
- pluginModule$jscomp$0 = pluginModule,
eventName$jscomp$0 = eventName;
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
@@ -829,7 +806,7 @@ function recomputePluginOrdering() {
) &&
publishRegistrationName(
phasedRegistrationNames[JSCompiler_inline_result],
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
);
JSCompiler_inline_result = !0;
@@ -837,7 +814,7 @@ function recomputePluginOrdering() {
dispatchConfig.registrationName
? (publishRegistrationName(
dispatchConfig.registrationName,
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
),
(JSCompiler_inline_result = !0))
@@ -865,13 +842,75 @@ function publishRegistrationName(registrationName, pluginModule) {
}
var plugins = [],
eventNameDispatchConfigs = {},
- registrationNameModules = {},
- customBubblingEventTypes =
+ registrationNameModules = {};
+function getListener$1(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customBubblingEventTypes,
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateDirectionalDispatches$1(inst, phase, event) {
+ if (
+ (phase = getListener$1(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateTwoPhaseDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ for (var inst = event._targetInst, path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; )
+ accumulateDirectionalDispatches$1(path[inst], "captured", event);
+ for (inst = 0; inst < path.length; inst++)
+ accumulateDirectionalDispatches$1(path[inst], "bubbled", event);
+ }
+}
+function accumulateDirectDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener$1(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
if (eventPluginOrder)
throw Error(
"EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."
@@ -881,7 +920,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_92 = {
+var injectedNamesToPlugins$jscomp$inline_229 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -905,42 +944,45 @@ var injectedNamesToPlugins$jscomp$inline_92 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle);
+ forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
- forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle);
+ forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
return topLevelType;
}
}
},
- isOrderingDirty$jscomp$inline_93 = !1,
- pluginName$jscomp$inline_94;
-for (pluginName$jscomp$inline_94 in injectedNamesToPlugins$jscomp$inline_92)
+ isOrderingDirty$jscomp$inline_230 = !1,
+ pluginName$jscomp$inline_231;
+for (pluginName$jscomp$inline_231 in injectedNamesToPlugins$jscomp$inline_229)
if (
- injectedNamesToPlugins$jscomp$inline_92.hasOwnProperty(
- pluginName$jscomp$inline_94
+ injectedNamesToPlugins$jscomp$inline_229.hasOwnProperty(
+ pluginName$jscomp$inline_231
)
) {
- var pluginModule$jscomp$inline_95 =
- injectedNamesToPlugins$jscomp$inline_92[pluginName$jscomp$inline_94];
+ var pluginModule$jscomp$inline_232 =
+ injectedNamesToPlugins$jscomp$inline_229[pluginName$jscomp$inline_231];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_94) ||
- namesToPlugins[pluginName$jscomp$inline_94] !==
- pluginModule$jscomp$inline_95
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_231) ||
+ namesToPlugins[pluginName$jscomp$inline_231] !==
+ pluginModule$jscomp$inline_232
) {
- if (namesToPlugins[pluginName$jscomp$inline_94])
+ if (namesToPlugins[pluginName$jscomp$inline_231])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_94 +
+ pluginName$jscomp$inline_231 +
"`."
);
namesToPlugins[
- pluginName$jscomp$inline_94
- ] = pluginModule$jscomp$inline_95;
- isOrderingDirty$jscomp$inline_93 = !0;
+ pluginName$jscomp$inline_231
+ ] = pluginModule$jscomp$inline_232;
+ isOrderingDirty$jscomp$inline_230 = !0;
}
}
-isOrderingDirty$jscomp$inline_93 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_230 && recomputePluginOrdering();
function getInstanceFromInstance(instanceHandle) {
return instanceHandle;
}
@@ -964,31 +1006,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
}
});
var ReactSharedInternals =
- React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") ||
- (ReactSharedInternals.ReactCurrentDispatcher = { current: null });
-ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") ||
- (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null });
-var hasSymbol = "function" === typeof Symbol && Symbol.for,
- REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103,
- REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106,
- REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107,
- REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108,
- REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114,
- REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109,
- REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110,
- REACT_CONCURRENT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.concurrent_mode")
- : 60111,
- REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112,
- REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113,
- REACT_SUSPENSE_LIST_TYPE = hasSymbol
- ? Symbol.for("react.suspense_list")
- : 60120,
- REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115,
- REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116,
- REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121,
- MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ REACT_ELEMENT_TYPE = 60103,
+ REACT_PORTAL_TYPE = 60106,
+ REACT_FRAGMENT_TYPE = 60107,
+ REACT_STRICT_MODE_TYPE = 60108,
+ REACT_PROFILER_TYPE = 60114,
+ REACT_PROVIDER_TYPE = 60109,
+ REACT_CONTEXT_TYPE = 60110,
+ REACT_FORWARD_REF_TYPE = 60112,
+ REACT_SUSPENSE_TYPE = 60113,
+ REACT_SUSPENSE_LIST_TYPE = 60120,
+ REACT_MEMO_TYPE = 60115,
+ REACT_LAZY_TYPE = 60116,
+ REACT_BLOCK_TYPE = 60121,
+ REACT_DEBUG_TRACING_MODE_TYPE = 60129,
+ REACT_OFFSCREEN_TYPE = 60130,
+ REACT_LEGACY_HIDDEN_TYPE = 60131;
+if ("function" === typeof Symbol && Symbol.for) {
+ var symbolFor = Symbol.for;
+ REACT_ELEMENT_TYPE = symbolFor("react.element");
+ REACT_PORTAL_TYPE = symbolFor("react.portal");
+ REACT_FRAGMENT_TYPE = symbolFor("react.fragment");
+ REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
+ REACT_PROFILER_TYPE = symbolFor("react.profiler");
+ REACT_PROVIDER_TYPE = symbolFor("react.provider");
+ REACT_CONTEXT_TYPE = symbolFor("react.context");
+ REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
+ REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
+ REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
+ REACT_MEMO_TYPE = symbolFor("react.memo");
+ REACT_LAZY_TYPE = symbolFor("react.lazy");
+ REACT_BLOCK_TYPE = symbolFor("react.block");
+ symbolFor("react.scope");
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
+ REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
+}
+var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -996,27 +1051,6 @@ function getIteratorFn(maybeIterable) {
maybeIterable["@@iterator"];
return "function" === typeof maybeIterable ? maybeIterable : null;
}
-function initializeLazyComponentType(lazyComponent) {
- if (-1 === lazyComponent._status) {
- var ctor = lazyComponent._result;
- ctor || (ctor = lazyComponent._ctor);
- ctor = ctor();
- lazyComponent._status = 0;
- lazyComponent._result = ctor;
- ctor.then(
- function(moduleObject) {
- 0 === lazyComponent._status &&
- ((moduleObject = moduleObject.default),
- (lazyComponent._status = 1),
- (lazyComponent._result = moduleObject));
- },
- function(error) {
- 0 === lazyComponent._status &&
- ((lazyComponent._status = 2), (lazyComponent._result = error));
- }
- );
- }
-}
function getComponentName(type) {
if (null == type) return null;
if ("function" === typeof type) return type.displayName || type.name || null;
@@ -1051,10 +1085,13 @@ function getComponentName(type) {
case REACT_MEMO_TYPE:
return getComponentName(type.type);
case REACT_BLOCK_TYPE:
- return getComponentName(type.render);
+ return getComponentName(type._render);
case REACT_LAZY_TYPE:
- if ((type = 1 === type._status ? type._result : null))
- return getComponentName(type);
+ innerType = type._payload;
+ type = type._init;
+ try {
+ return getComponentName(type(innerType));
+ } catch (x) {}
}
return null;
}
@@ -1106,36 +1143,36 @@ function findCurrentFiberUsingSlowPath(fiber) {
}
if (a.return !== b.return) (a = parentA), (b = parentB);
else {
- for (var didFindChild = !1, _child = parentA.child; _child; ) {
- if (_child === a) {
+ for (var didFindChild = !1, child$0 = parentA.child; child$0; ) {
+ if (child$0 === a) {
didFindChild = !0;
a = parentA;
b = parentB;
break;
}
- if (_child === b) {
+ if (child$0 === b) {
didFindChild = !0;
b = parentA;
a = parentB;
break;
}
- _child = _child.sibling;
+ child$0 = child$0.sibling;
}
if (!didFindChild) {
- for (_child = parentB.child; _child; ) {
- if (_child === a) {
+ for (child$0 = parentB.child; child$0; ) {
+ if (child$0 === a) {
didFindChild = !0;
a = parentB;
b = parentA;
break;
}
- if (_child === b) {
+ if (child$0 === b) {
didFindChild = !0;
b = parentB;
a = parentA;
break;
}
- _child = _child.sibling;
+ child$0 = child$0.sibling;
}
if (!didFindChild)
throw Error(
@@ -1170,6 +1207,18 @@ function findCurrentHostFiber(parent) {
}
return null;
}
+function doesFiberContain(parentFiber, childFiber) {
+ for (
+ var parentFiberAlternate = parentFiber.alternate;
+ null !== childFiber;
+
+ ) {
+ if (childFiber === parentFiber || childFiber === parentFiberAlternate)
+ return !0;
+ childFiber = childFiber.return;
+ }
+ return !1;
+}
function mountSafeCallback_NOT_REALLY_SAFE(context, callback) {
return function() {
if (
@@ -1383,19 +1432,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
),
(removedKeys = null));
}
- for (var _propKey in prevProps)
- void 0 === nextProps[_propKey] &&
- (!(attributeConfig = validAttributes[_propKey]) ||
- (updatePayload && void 0 !== updatePayload[_propKey]) ||
- ((prevProp = prevProps[_propKey]),
+ for (var propKey$2 in prevProps)
+ void 0 === nextProps[propKey$2] &&
+ (!(attributeConfig = validAttributes[propKey$2]) ||
+ (updatePayload && void 0 !== updatePayload[propKey$2]) ||
+ ((prevProp = prevProps[propKey$2]),
void 0 !== prevProp &&
("object" !== typeof attributeConfig ||
"function" === typeof attributeConfig.diff ||
"function" === typeof attributeConfig.process
- ? (((updatePayload || (updatePayload = {}))[_propKey] = null),
+ ? (((updatePayload || (updatePayload = {}))[propKey$2] = null),
removedKeys || (removedKeys = {}),
- removedKeys[_propKey] ||
- ((removedKeys[_propKey] = !0), removedKeyCount++))
+ removedKeys[propKey$2] ||
+ ((removedKeys[propKey$2] = !0), removedKeyCount++))
: (updatePayload = clearNestedProperty(
updatePayload,
prevProp,
@@ -1443,37 +1492,49 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
null != stateNode && (eventTarget = stateNode.canonical);
}
batchedUpdates(function() {
- var events = eventTarget;
- for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) {
- var possiblePlugin = plugins[i];
+ var JSCompiler_inline_result = eventTarget;
+ for (
+ var events = null, legacyPlugins = plugins, i = 0;
+ i < legacyPlugins.length;
+ i++
+ ) {
+ var possiblePlugin = legacyPlugins[i];
possiblePlugin &&
(possiblePlugin = possiblePlugin.extractEvents(
topLevelType,
target,
nativeEvent,
- events,
- 1
+ JSCompiler_inline_result
)) &&
- (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin));
+ (events = accumulateInto(events, possiblePlugin));
}
- events = events$jscomp$0;
- null !== events && (eventQueue = accumulateInto(eventQueue, events));
- events = eventQueue;
+ JSCompiler_inline_result = events;
+ null !== JSCompiler_inline_result &&
+ (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result));
+ JSCompiler_inline_result = eventQueue;
eventQueue = null;
- if (events) {
- forEachAccumulated(events, executeDispatchesAndReleaseTopLevel);
+ if (JSCompiler_inline_result) {
+ forEachAccumulated(
+ JSCompiler_inline_result,
+ executeDispatchesAndReleaseTopLevel
+ );
if (eventQueue)
throw Error(
"processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
);
if (hasRethrowError)
- throw ((events = rethrowError),
+ throw ((JSCompiler_inline_result = rethrowError),
(hasRethrowError = !1),
(rethrowError = null),
- events);
+ JSCompiler_inline_result);
}
});
}
+function shim() {
+ throw Error(
+ "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue."
+ );
+}
function shim$1() {
throw Error(
"The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue."
@@ -1566,19 +1627,32 @@ var scheduleTimeout = setTimeout,
cancelTimeout = clearTimeout;
function cloneHiddenInstance(instance) {
var node = instance.node;
- var updatePayload = diffProperties(
+ var JSCompiler_inline_result = diffProperties(
null,
emptyObject,
{ style: { display: "none" } },
instance.canonical.viewConfig.validAttributes
);
return {
- node: cloneNodeWithNewProps(node, updatePayload),
+ node: cloneNodeWithNewProps(node, JSCompiler_inline_result),
canonical: instance.canonical
};
}
+function describeComponentFrame(name, source, ownerName) {
+ source = "";
+ ownerName && (source = " (created by " + ownerName + ")");
+ return "\n in " + (name || "Unknown") + source;
+}
+function describeFunctionComponentFrame(fn, source) {
+ return fn
+ ? describeComponentFrame(fn.displayName || fn.name || null, source, null)
+ : "";
+}
var valueStack = [],
index = -1;
+function createCursor(defaultValue) {
+ return { current: defaultValue };
+}
function pop(cursor) {
0 > index ||
((cursor.current = valueStack[index]), (valueStack[index] = null), index--);
@@ -1589,8 +1663,8 @@ function push(cursor, value) {
cursor.current = value;
}
var emptyContextObject = {},
- contextStackCursor = { current: emptyContextObject },
- didPerformWorkStackCursor = { current: !1 },
+ contextStackCursor = createCursor(emptyContextObject),
+ didPerformWorkStackCursor = createCursor(!1),
previousContext = emptyContextObject;
function getMaskedContext(workInProgress, unmaskedContext) {
var contextTypes = workInProgress.type.contextTypes;
@@ -1670,12 +1744,228 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
+var rendererID = null,
+ injectedHook = null,
+ isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__,
+ Scheduler_now = Scheduler.unstable_now;
+if (
+ null == tracing.__interactionsRef ||
+ null == tracing.__interactionsRef.current
+)
+ throw Error(
+ "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling"
+ );
+Scheduler_now();
+var return_highestLanePriority = 10;
+function getHighestPriorityLanes(lanes) {
+ if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1;
+ if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2;
+ if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4;
+ var inputDiscreteLanes = 24 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 14), inputDiscreteLanes;
+ if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32;
+ inputDiscreteLanes = 192 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 12), inputDiscreteLanes;
+ if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256;
+ inputDiscreteLanes = 3584 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 10), inputDiscreteLanes;
+ if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096;
+ inputDiscreteLanes = 122880 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 8), inputDiscreteLanes;
+ if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072;
+ inputDiscreteLanes = 3932160 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 6), inputDiscreteLanes;
+ inputDiscreteLanes = 62914560 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 5), inputDiscreteLanes;
+ if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864;
+ if (0 !== (lanes & 134217728))
+ return (return_highestLanePriority = 3), 134217728;
+ inputDiscreteLanes = 805306368 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 2), inputDiscreteLanes;
+ if (0 !== (1073741824 & lanes))
+ return (return_highestLanePriority = 1), 1073741824;
+ return_highestLanePriority = 10;
+ return lanes;
+}
+function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
+ switch (schedulerPriorityLevel) {
+ case 99:
+ return 17;
+ case 98:
+ return 12;
+ case 97:
+ case 96:
+ return 10;
+ case 95:
+ return 2;
+ default:
+ return 0;
+ }
+}
+function lanePriorityToSchedulerPriority(lanePriority) {
+ switch (lanePriority) {
+ case 17:
+ case 16:
+ return 99;
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ return 98;
+ case 11:
+ case 10:
+ case 9:
+ case 8:
+ case 7:
+ case 6:
+ case 4:
+ case 5:
+ return 97;
+ case 3:
+ case 2:
+ case 1:
+ return 95;
+ case 0:
+ return 90;
+ default:
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+ }
+}
+function getNextLanes(root, wipLanes) {
+ var pendingLanes = root.pendingLanes;
+ if (0 === pendingLanes) return (return_highestLanePriority = 0);
+ var nextLanes = 0,
+ nextLanePriority = 0,
+ expiredLanes = root.expiredLanes,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes;
+ if (0 !== expiredLanes)
+ (nextLanes = expiredLanes),
+ (nextLanePriority = return_highestLanePriority = 17);
+ else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) {
+ var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes;
+ 0 !== nonIdleUnblockedLanes
+ ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : ((pingedLanes &= expiredLanes),
+ 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority)));
+ } else
+ (expiredLanes = pendingLanes & ~suspendedLanes),
+ 0 !== expiredLanes
+ ? ((nextLanes = getHighestPriorityLanes(expiredLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority));
+ if (0 === nextLanes) return 0;
+ nextLanes = 31 - clz32(nextLanes);
+ nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1);
+ if (
+ 0 !== wipLanes &&
+ wipLanes !== nextLanes &&
+ 0 === (wipLanes & suspendedLanes)
+ ) {
+ getHighestPriorityLanes(wipLanes);
+ if (nextLanePriority <= return_highestLanePriority) return wipLanes;
+ return_highestLanePriority = nextLanePriority;
+ }
+ wipLanes = root.entangledLanes;
+ if (0 !== wipLanes)
+ for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; )
+ (pendingLanes = 31 - clz32(wipLanes)),
+ (nextLanePriority = 1 << pendingLanes),
+ (nextLanes |= root[pendingLanes]),
+ (wipLanes &= ~nextLanePriority);
+ return nextLanes;
+}
+function getMostRecentEventTime(root, lanes) {
+ root = root.eventTimes;
+ for (var mostRecentEventTime = -1; 0 < lanes; ) {
+ var index$4 = 31 - clz32(lanes),
+ lane = 1 << index$4;
+ index$4 = root[index$4];
+ index$4 > mostRecentEventTime && (mostRecentEventTime = index$4);
+ lanes &= ~lane;
+ }
+ return mostRecentEventTime;
+}
+function getLanesToRetrySynchronouslyOnError(root) {
+ root = root.pendingLanes & -1073741825;
+ return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0;
+}
+function findUpdateLane(lanePriority, wipLanes) {
+ switch (lanePriority) {
+ case 17:
+ return 1;
+ case 16:
+ return 2;
+ case 14:
+ return (
+ (lanePriority = getHighestPriorityLane(24 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority
+ );
+ case 12:
+ return (
+ (lanePriority = getHighestPriorityLane(192 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority
+ );
+ case 10:
+ return (
+ (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)),
+ 0 === lanePriority &&
+ ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)),
+ 0 === lanePriority && (lanePriority = 512)),
+ lanePriority
+ );
+ case 2:
+ return (
+ (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)),
+ 0 === wipLanes && (wipLanes = 268435456),
+ wipLanes
+ );
+ }
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+}
+function getHighestPriorityLane(lanes) {
+ return lanes & -lanes;
+}
+function pickArbitraryLane(lanes) {
+ return lanes & -lanes;
+}
+function markRootUpdated(root, updateLane, eventTime) {
+ root.pendingLanes |= updateLane;
+ var higherPriorityLanes = updateLane - 1;
+ root.suspendedLanes &= higherPriorityLanes;
+ root.pingedLanes &= higherPriorityLanes;
+ root = root.eventTimes;
+ updateLane = 31 - clz32(updateLane);
+ root[updateLane] = eventTime;
+}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(lanes) {
+ return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0;
+}
var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
Scheduler_shouldYield = Scheduler.unstable_shouldYield,
Scheduler_requestPaint = Scheduler.unstable_requestPaint,
- Scheduler_now = Scheduler.unstable_now,
+ Scheduler_now$1 = Scheduler.unstable_now,
Scheduler_getCurrentPriorityLevel =
Scheduler.unstable_getCurrentPriorityLevel,
Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
@@ -1696,12 +1986,12 @@ var fakeCallbackNode = {},
syncQueue = null,
immediateQueueCallbackNode = null,
isFlushingSyncQueue = !1,
- initialTimeMs = Scheduler_now(),
+ initialTimeMs$1 = Scheduler_now$1(),
now =
- 1e4 > initialTimeMs
- ? Scheduler_now
+ 1e4 > initialTimeMs$1
+ ? Scheduler_now$1
: function() {
- return Scheduler_now() - initialTimeMs;
+ return Scheduler_now$1() - initialTimeMs$1;
};
function getCurrentPriorityLevel() {
switch (Scheduler_getCurrentPriorityLevel()) {
@@ -1743,16 +2033,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) {
reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
return Scheduler_scheduleCallback(reactPriorityLevel, callback, options);
}
-function scheduleSyncCallback(callback) {
- null === syncQueue
- ? ((syncQueue = [callback]),
- (immediateQueueCallbackNode = Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueueImpl
- )))
- : syncQueue.push(callback);
- return fakeCallbackNode;
-}
function flushSyncCallbackQueue() {
if (null !== immediateQueueCallbackNode) {
var node = immediateQueueCallbackNode;
@@ -1787,18 +2067,29 @@ function flushSyncCallbackQueueImpl() {
}
}
}
-function inferPriorityFromExpirationTime(currentTime, expirationTime) {
- if (1073741823 === expirationTime) return 99;
- if (1 === expirationTime || 2 === expirationTime) return 95;
- currentTime =
- 10 * (1073741821 - expirationTime) - 10 * (1073741821 - currentTime);
- return 0 >= currentTime
- ? 99
- : 250 >= currentTime
- ? 98
- : 5250 >= currentTime
- ? 97
- : 95;
+function describeFiber(fiber) {
+ switch (fiber.tag) {
+ case 5:
+ return describeComponentFrame(fiber.type, null, null);
+ case 16:
+ return describeComponentFrame("Lazy", null, null);
+ case 13:
+ return describeComponentFrame("Suspense", null, null);
+ case 19:
+ return describeComponentFrame("SuspenseList", null, null);
+ case 0:
+ case 2:
+ case 15:
+ return describeFunctionComponentFrame(fiber.type, null);
+ case 11:
+ return describeFunctionComponentFrame(fiber.type.render, null);
+ case 22:
+ return describeFunctionComponentFrame(fiber.type._render, null);
+ case 1:
+ return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber;
+ default:
+ return "";
+ }
}
function is(x, y) {
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
@@ -1825,43 +2116,6 @@ function shallowEqual(objA, objB) {
return !1;
return !0;
}
-var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
-function getStackByFiberInDevAndProd(workInProgress) {
- var info = "";
- do {
- a: switch (workInProgress.tag) {
- case 3:
- case 4:
- case 6:
- case 7:
- case 10:
- case 9:
- var JSCompiler_inline_result = "";
- break a;
- default:
- var owner = workInProgress._debugOwner,
- source = workInProgress._debugSource,
- name = getComponentName(workInProgress.type);
- JSCompiler_inline_result = null;
- owner && (JSCompiler_inline_result = getComponentName(owner.type));
- owner = name;
- name = "";
- source
- ? (name =
- " (at " +
- source.fileName.replace(BEFORE_SLASH_RE, "") +
- ":" +
- source.lineNumber +
- ")")
- : JSCompiler_inline_result &&
- (name = " (created by " + JSCompiler_inline_result + ")");
- JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name;
- }
- info += JSCompiler_inline_result;
- workInProgress = workInProgress.return;
- } while (workInProgress);
- return info;
-}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
baseProps = Object.assign({}, baseProps);
@@ -1869,10 +2123,11 @@ function resolveDefaultProps(Component, baseProps) {
for (var propName in Component)
void 0 === baseProps[propName] &&
(baseProps[propName] = Component[propName]);
+ return baseProps;
}
return baseProps;
}
-var valueCursor = { current: null },
+var valueCursor = createCursor(null),
currentlyRenderingFiber = null,
lastContextDependency = null,
lastContextWithAllBitsObserved = null;
@@ -1884,31 +2139,29 @@ function popProvider(providerFiber) {
pop(valueCursor);
providerFiber.type._context._currentValue2 = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderExpirationTime) {
+function scheduleWorkOnParentPath(parent, renderLanes) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- if (parent.childExpirationTime < renderExpirationTime)
- (parent.childExpirationTime = renderExpirationTime),
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime &&
- (alternate.childExpirationTime = renderExpirationTime);
- else if (
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime
- )
- alternate.childExpirationTime = renderExpirationTime;
- else break;
+ if ((parent.childLanes & renderLanes) === renderLanes)
+ if (
+ null === alternate ||
+ (alternate.childLanes & renderLanes) === renderLanes
+ )
+ break;
+ else alternate.childLanes |= renderLanes;
+ else
+ (parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes);
parent = parent.return;
}
}
-function prepareToReadContext(workInProgress, renderExpirationTime) {
+function prepareToReadContext(workInProgress, renderLanes) {
currentlyRenderingFiber = workInProgress;
lastContextWithAllBitsObserved = lastContextDependency = null;
workInProgress = workInProgress.dependencies;
null !== workInProgress &&
null !== workInProgress.firstContext &&
- (workInProgress.expirationTime >= renderExpirationTime &&
- (didReceiveUpdate = !0),
+ (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0),
(workInProgress.firstContext = null));
}
function readContext(context, observedBits) {
@@ -1927,7 +2180,7 @@ function readContext(context, observedBits) {
);
lastContextDependency = observedBits;
currentlyRenderingFiber.dependencies = {
- expirationTime: 0,
+ lanes: 0,
firstContext: observedBits,
responders: null
};
@@ -1939,7 +2192,8 @@ var hasForceUpdate = !1;
function initializeUpdateQueue(fiber) {
fiber.updateQueue = {
baseState: fiber.memoizedState,
- baseQueue: null,
+ firstBaseUpdate: null,
+ lastBaseUpdate: null,
shared: { pending: null },
effects: null
};
@@ -1949,21 +2203,22 @@ function cloneUpdateQueue(current, workInProgress) {
workInProgress.updateQueue === current &&
(workInProgress.updateQueue = {
baseState: current.baseState,
- baseQueue: current.baseQueue,
+ firstBaseUpdate: current.firstBaseUpdate,
+ lastBaseUpdate: current.lastBaseUpdate,
shared: current.shared,
effects: current.effects
});
}
-function createUpdate(expirationTime, suspenseConfig) {
- expirationTime = {
- expirationTime: expirationTime,
+function createUpdate(eventTime, lane, suspenseConfig) {
+ return {
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
tag: 0,
payload: null,
callback: null,
next: null
};
- return (expirationTime.next = expirationTime);
}
function enqueueUpdate(fiber, update) {
fiber = fiber.updateQueue;
@@ -1976,132 +2231,185 @@ function enqueueUpdate(fiber, update) {
fiber.pending = update;
}
}
-function enqueueCapturedUpdate(workInProgress, update) {
- var current = workInProgress.alternate;
- null !== current && cloneUpdateQueue(current, workInProgress);
- workInProgress = workInProgress.updateQueue;
- current = workInProgress.baseQueue;
- null === current
- ? ((workInProgress.baseQueue = update.next = update),
- (update.next = update))
- : ((update.next = current.next), (current.next = update));
+function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
+ var queue = workInProgress.updateQueue,
+ current = workInProgress.alternate;
+ if (
+ null !== current &&
+ ((current = current.updateQueue), queue === current)
+ ) {
+ var newFirst = null,
+ newLast = null;
+ queue = queue.firstBaseUpdate;
+ if (null !== queue) {
+ do {
+ var clone = {
+ eventTime: queue.eventTime,
+ lane: queue.lane,
+ suspenseConfig: queue.suspenseConfig,
+ tag: queue.tag,
+ payload: queue.payload,
+ callback: queue.callback,
+ next: null
+ };
+ null === newLast
+ ? (newFirst = newLast = clone)
+ : (newLast = newLast.next = clone);
+ queue = queue.next;
+ } while (null !== queue);
+ null === newLast
+ ? (newFirst = newLast = capturedUpdate)
+ : (newLast = newLast.next = capturedUpdate);
+ } else newFirst = newLast = capturedUpdate;
+ queue = {
+ baseState: current.baseState,
+ firstBaseUpdate: newFirst,
+ lastBaseUpdate: newLast,
+ shared: current.shared,
+ effects: current.effects
+ };
+ workInProgress.updateQueue = queue;
+ return;
+ }
+ workInProgress = queue.lastBaseUpdate;
+ null === workInProgress
+ ? (queue.firstBaseUpdate = capturedUpdate)
+ : (workInProgress.next = capturedUpdate);
+ queue.lastBaseUpdate = capturedUpdate;
}
function processUpdateQueue(
workInProgress$jscomp$0,
props,
instance,
- renderExpirationTime
+ renderLanes
) {
var queue = workInProgress$jscomp$0.updateQueue;
hasForceUpdate = !1;
- var baseQueue = queue.baseQueue,
+ var firstBaseUpdate = queue.firstBaseUpdate,
+ lastBaseUpdate = queue.lastBaseUpdate,
pendingQueue = queue.shared.pending;
if (null !== pendingQueue) {
- if (null !== baseQueue) {
- var baseFirst = baseQueue.next;
- baseQueue.next = pendingQueue.next;
- pendingQueue.next = baseFirst;
- }
- baseQueue = pendingQueue;
queue.shared.pending = null;
- baseFirst = workInProgress$jscomp$0.alternate;
- null !== baseFirst &&
- ((baseFirst = baseFirst.updateQueue),
- null !== baseFirst && (baseFirst.baseQueue = pendingQueue));
+ var lastPendingUpdate = pendingQueue,
+ firstPendingUpdate = lastPendingUpdate.next;
+ lastPendingUpdate.next = null;
+ null === lastBaseUpdate
+ ? (firstBaseUpdate = firstPendingUpdate)
+ : (lastBaseUpdate.next = firstPendingUpdate);
+ lastBaseUpdate = lastPendingUpdate;
+ var current = workInProgress$jscomp$0.alternate;
+ if (null !== current) {
+ current = current.updateQueue;
+ var currentLastBaseUpdate = current.lastBaseUpdate;
+ currentLastBaseUpdate !== lastBaseUpdate &&
+ (null === currentLastBaseUpdate
+ ? (current.firstBaseUpdate = firstPendingUpdate)
+ : (currentLastBaseUpdate.next = firstPendingUpdate),
+ (current.lastBaseUpdate = lastPendingUpdate));
+ }
}
- if (null !== baseQueue) {
- baseFirst = baseQueue.next;
- var newState = queue.baseState,
- newExpirationTime = 0,
- newBaseState = null,
- newBaseQueueFirst = null,
- newBaseQueueLast = null;
- if (null !== baseFirst) {
- var update = baseFirst;
- do {
- pendingQueue = update.expirationTime;
- if (pendingQueue < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
+ if (null !== firstBaseUpdate) {
+ currentLastBaseUpdate = queue.baseState;
+ lastBaseUpdate = 0;
+ current = firstPendingUpdate = lastPendingUpdate = null;
+ do {
+ pendingQueue = firstBaseUpdate.lane;
+ var updateEventTime = firstBaseUpdate.eventTime;
+ if ((renderLanes & pendingQueue) === pendingQueue) {
+ null !== current &&
+ (current = current.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
next: null
- };
- null === newBaseQueueLast
- ? ((newBaseQueueFirst = newBaseQueueLast = clone),
- (newBaseState = newState))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- pendingQueue > newExpirationTime &&
- (newExpirationTime = pendingQueue);
- } else {
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
- next: null
- });
- markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig);
- a: {
- var workInProgress = workInProgress$jscomp$0,
- update$jscomp$0 = update;
- pendingQueue = props;
- clone = instance;
- switch (update$jscomp$0.tag) {
- case 1:
- workInProgress = update$jscomp$0.payload;
- if ("function" === typeof workInProgress) {
- newState = workInProgress.call(clone, newState, pendingQueue);
- break a;
- }
- newState = workInProgress;
- break a;
- case 3:
- workInProgress.effectTag =
- (workInProgress.effectTag & -4097) | 64;
- case 0:
- workInProgress = update$jscomp$0.payload;
- pendingQueue =
- "function" === typeof workInProgress
- ? workInProgress.call(clone, newState, pendingQueue)
- : workInProgress;
- if (null === pendingQueue || void 0 === pendingQueue) break a;
- newState = Object.assign({}, newState, pendingQueue);
+ });
+ markRenderEventTimeAndConfig(
+ updateEventTime,
+ firstBaseUpdate.suspenseConfig
+ );
+ a: {
+ var workInProgress = workInProgress$jscomp$0,
+ update = firstBaseUpdate;
+ pendingQueue = props;
+ updateEventTime = instance;
+ switch (update.tag) {
+ case 1:
+ workInProgress = update.payload;
+ if ("function" === typeof workInProgress) {
+ currentLastBaseUpdate = workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ );
break a;
- case 2:
- hasForceUpdate = !0;
- }
+ }
+ currentLastBaseUpdate = workInProgress;
+ break a;
+ case 3:
+ workInProgress.effectTag =
+ (workInProgress.effectTag & -4097) | 64;
+ case 0:
+ workInProgress = update.payload;
+ pendingQueue =
+ "function" === typeof workInProgress
+ ? workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ )
+ : workInProgress;
+ if (null === pendingQueue || void 0 === pendingQueue) break a;
+ currentLastBaseUpdate = Object.assign(
+ {},
+ currentLastBaseUpdate,
+ pendingQueue
+ );
+ break a;
+ case 2:
+ hasForceUpdate = !0;
}
- null !== update.callback &&
- ((workInProgress$jscomp$0.effectTag |= 32),
- (pendingQueue = queue.effects),
- null === pendingQueue
- ? (queue.effects = [update])
- : pendingQueue.push(update));
}
- update = update.next;
- if (null === update || update === baseFirst)
- if (((pendingQueue = queue.shared.pending), null === pendingQueue))
- break;
- else
- (update = baseQueue.next = pendingQueue.next),
- (pendingQueue.next = baseFirst),
- (queue.baseQueue = baseQueue = pendingQueue),
- (queue.shared.pending = null);
- } while (1);
- }
- null === newBaseQueueLast
- ? (newBaseState = newState)
- : (newBaseQueueLast.next = newBaseQueueFirst);
- queue.baseState = newBaseState;
- queue.baseQueue = newBaseQueueLast;
- markUnprocessedUpdateTime(newExpirationTime);
- workInProgress$jscomp$0.expirationTime = newExpirationTime;
- workInProgress$jscomp$0.memoizedState = newState;
+ null !== firstBaseUpdate.callback &&
+ ((workInProgress$jscomp$0.effectTag |= 32),
+ (pendingQueue = queue.effects),
+ null === pendingQueue
+ ? (queue.effects = [firstBaseUpdate])
+ : pendingQueue.push(firstBaseUpdate));
+ } else
+ (updateEventTime = {
+ eventTime: updateEventTime,
+ lane: pendingQueue,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
+ next: null
+ }),
+ null === current
+ ? ((firstPendingUpdate = current = updateEventTime),
+ (lastPendingUpdate = currentLastBaseUpdate))
+ : (current = current.next = updateEventTime),
+ (lastBaseUpdate |= pendingQueue);
+ firstBaseUpdate = firstBaseUpdate.next;
+ if (null === firstBaseUpdate)
+ if (((pendingQueue = queue.shared.pending), null === pendingQueue))
+ break;
+ else
+ (firstBaseUpdate = pendingQueue.next),
+ (pendingQueue.next = null),
+ (queue.lastBaseUpdate = pendingQueue),
+ (queue.shared.pending = null);
+ } while (1);
+ null === current && (lastPendingUpdate = currentLastBaseUpdate);
+ queue.baseState = lastPendingUpdate;
+ queue.firstBaseUpdate = firstPendingUpdate;
+ queue.lastBaseUpdate = current;
+ workInProgressRootSkippedLanes |= lastBaseUpdate;
+ workInProgress$jscomp$0.lanes = lastBaseUpdate;
+ workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate;
}
}
function commitUpdateQueue(finishedWork, finishedQueue, instance) {
@@ -2141,54 +2449,54 @@ function applyDerivedStateFromProps(
? ctor
: Object.assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
- 0 === workInProgress.expirationTime &&
+ 0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
}
var classComponentUpdater = {
isMounted: function(component) {
- return (component = component._reactInternalFiber)
+ return (component = component._reactInternals)
? getNearestMountedFiber(component) === component
: !1;
},
enqueueSetState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueReplaceState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 1;
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueForceUpdate: function(inst, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 2;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
}
};
function checkShouldComponentUpdate(
@@ -2226,7 +2534,7 @@ function constructClassInstance(workInProgress, ctor, props) {
null !== ctor.state && void 0 !== ctor.state ? ctor.state : null;
ctor.updater = classComponentUpdater;
workInProgress.stateNode = ctor;
- ctor._reactInternalFiber = workInProgress;
+ ctor._reactInternals = workInProgress;
isLegacyContextConsumer &&
((workInProgress = workInProgress.stateNode),
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
@@ -2247,12 +2555,7 @@ function callComponentWillReceiveProps(
instance.state !== workInProgress &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
}
-function mountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;
@@ -2265,7 +2568,7 @@ function mountClassInstance(
? previousContext
: contextStackCursor.current),
(instance.context = getMaskedContext(workInProgress, contextType)));
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
contextType = ctor.getDerivedStateFromProps;
"function" === typeof contextType &&
@@ -2282,12 +2585,7 @@ function mountClassInstance(
instance.UNSAFE_componentWillMount(),
ctor !== instance.state &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null),
- processUpdateQueue(
- workInProgress,
- newProps,
- instance,
- renderExpirationTime
- ),
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes),
(instance.state = workInProgress.memoizedState));
"function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4);
@@ -2351,7 +2649,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) {
("[object Object]" === Object.prototype.toString.call(newChild)
? "object with keys {" + Object.keys(newChild).join(", ") + "}"
: newChild) +
- ")."
+ "). If you meant to render a collection of children, use an array instead."
);
}
function ChildReconciler(shouldTrackSideEffects) {
@@ -2407,14 +2705,10 @@ function ChildReconciler(shouldTrackSideEffects) {
(newFiber.effectTag = 2);
return newFiber;
}
- function updateTextNode(returnFiber, current, textContent, expirationTime) {
+ function updateTextNode(returnFiber, current, textContent, lanes) {
if (null === current || 6 !== current.tag)
return (
- (current = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromText(textContent, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2422,27 +2716,27 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateElement(returnFiber, current, element, expirationTime) {
+ function updateElement(returnFiber, current, element, lanes) {
if (null !== current && current.elementType === element.type)
return (
- (expirationTime = useFiber(current, element.props)),
- (expirationTime.ref = coerceRef(returnFiber, current, element)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes = useFiber(current, element.props)),
+ (lanes.ref = coerceRef(returnFiber, current, element)),
+ (lanes.return = returnFiber),
+ lanes
);
- expirationTime = createFiberFromTypeAndProps(
+ lanes = createFiberFromTypeAndProps(
element.type,
element.key,
element.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
);
- expirationTime.ref = coerceRef(returnFiber, current, element);
- expirationTime.return = returnFiber;
- return expirationTime;
+ lanes.ref = coerceRef(returnFiber, current, element);
+ lanes.return = returnFiber;
+ return lanes;
}
- function updatePortal(returnFiber, current, portal, expirationTime) {
+ function updatePortal(returnFiber, current, portal, lanes) {
if (
null === current ||
4 !== current.tag ||
@@ -2450,11 +2744,7 @@ function ChildReconciler(shouldTrackSideEffects) {
current.stateNode.implementation !== portal.implementation
)
return (
- (current = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromPortal(portal, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2462,13 +2752,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateFragment(returnFiber, current, fragment, expirationTime, key) {
+ function updateFragment(returnFiber, current, fragment, lanes, key) {
if (null === current || 7 !== current.tag)
return (
(current = createFiberFromFragment(
fragment,
returnFiber.mode,
- expirationTime,
+ lanes,
key
)),
(current.return = returnFiber),
@@ -2478,13 +2768,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function createChild(returnFiber, newChild, expirationTime) {
+ function createChild(returnFiber, newChild, lanes) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(newChild = createFiberFromText(
"" + newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2493,24 +2783,24 @@ function ChildReconciler(shouldTrackSideEffects) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
return (
- (expirationTime = createFiberFromTypeAndProps(
+ (lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(returnFiber, null, newChild)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes.ref = coerceRef(returnFiber, null, newChild)),
+ (lanes.return = returnFiber),
+ lanes
);
case REACT_PORTAL_TYPE:
return (
(newChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2521,7 +2811,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(newChild = createFiberFromFragment(
newChild,
returnFiber.mode,
- expirationTime,
+ lanes,
null
)),
(newChild.return = returnFiber),
@@ -2531,12 +2821,12 @@ function ChildReconciler(shouldTrackSideEffects) {
}
return null;
}
- function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
+ function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
if ("string" === typeof newChild || "number" === typeof newChild)
return null !== key
? null
- : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime);
+ : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
@@ -2546,26 +2836,20 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChild.props.children,
- expirationTime,
+ lanes,
key
)
- : updateElement(returnFiber, oldFiber, newChild, expirationTime)
+ : updateElement(returnFiber, oldFiber, newChild, lanes)
: null;
case REACT_PORTAL_TYPE:
return newChild.key === key
- ? updatePortal(returnFiber, oldFiber, newChild, expirationTime)
+ ? updatePortal(returnFiber, oldFiber, newChild, lanes)
: null;
}
if (isArray(newChild) || getIteratorFn(newChild))
return null !== key
? null
- : updateFragment(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime,
- null
- );
+ : updateFragment(returnFiber, oldFiber, newChild, lanes, null);
throwOnInvalidObjectType(returnFiber, newChild);
}
return null;
@@ -2575,17 +2859,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChild,
- expirationTime
+ lanes
) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateTextNode(
- returnFiber,
- existingChildren,
- "" + newChild,
- expirationTime
- )
+ updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
@@ -2600,15 +2879,10 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
existingChildren,
newChild.props.children,
- expirationTime,
+ lanes,
newChild.key
)
- : updateElement(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ : updateElement(returnFiber, existingChildren, newChild, lanes)
);
case REACT_PORTAL_TYPE:
return (
@@ -2616,24 +2890,13 @@ function ChildReconciler(shouldTrackSideEffects) {
existingChildren.get(
null === newChild.key ? newIdx : newChild.key
) || null),
- updatePortal(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ updatePortal(returnFiber, existingChildren, newChild, lanes)
);
}
if (isArray(newChild) || getIteratorFn(newChild))
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateFragment(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime,
- null
- )
+ updateFragment(returnFiber, existingChildren, newChild, lanes, null)
);
throwOnInvalidObjectType(returnFiber, newChild);
}
@@ -2643,7 +2906,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildren,
- expirationTime
+ lanes
) {
for (
var resultingFirstChild = null,
@@ -2661,7 +2924,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
@@ -2684,11 +2947,7 @@ function ChildReconciler(shouldTrackSideEffects) {
);
if (null === oldFiber) {
for (; newIdx < newChildren.length; newIdx++)
- (oldFiber = createChild(
- returnFiber,
- newChildren[newIdx],
- expirationTime
- )),
+ (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)),
null !== oldFiber &&
((currentFirstChild = placeChild(
oldFiber,
@@ -2711,7 +2970,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChildren[newIdx],
- expirationTime
+ lanes
)),
null !== nextOldFiber &&
(shouldTrackSideEffects &&
@@ -2738,7 +2997,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildrenIterable,
- expirationTime
+ lanes
) {
var iteratorFn = getIteratorFn(newChildrenIterable);
if ("function" !== typeof iteratorFn)
@@ -2760,12 +3019,7 @@ function ChildReconciler(shouldTrackSideEffects) {
oldFiber.index > newIdx
? ((nextOldFiber = oldFiber), (oldFiber = null))
: (nextOldFiber = oldFiber.sibling);
- var newFiber = updateSlot(
- returnFiber,
- oldFiber,
- step.value,
- expirationTime
- );
+ var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
break;
@@ -2785,7 +3039,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn;
if (null === oldFiber) {
for (; !step.done; newIdx++, step = newChildrenIterable.next())
- (step = createChild(returnFiber, step.value, expirationTime)),
+ (step = createChild(returnFiber, step.value, lanes)),
null !== step &&
((currentFirstChild = placeChild(step, currentFirstChild, newIdx)),
null === previousNewFiber
@@ -2799,13 +3053,7 @@ function ChildReconciler(shouldTrackSideEffects) {
!step.done;
newIdx++, step = newChildrenIterable.next()
)
- (step = updateFromMap(
- oldFiber,
- returnFiber,
- newIdx,
- step.value,
- expirationTime
- )),
+ (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)),
null !== step &&
(shouldTrackSideEffects &&
null !== step.alternate &&
@@ -2821,7 +3069,7 @@ function ChildReconciler(shouldTrackSideEffects) {
});
return iteratorFn;
}
- return function(returnFiber, currentFirstChild, newChild, expirationTime) {
+ return function(returnFiber, currentFirstChild, newChild, lanes) {
var isUnkeyedTopLevelFragment =
"object" === typeof newChild &&
null !== newChild &&
@@ -2887,26 +3135,26 @@ function ChildReconciler(shouldTrackSideEffects) {
? ((currentFirstChild = createFiberFromFragment(
newChild.props.children,
returnFiber.mode,
- expirationTime,
+ lanes,
newChild.key
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild))
- : ((expirationTime = createFiberFromTypeAndProps(
+ : ((lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(
+ (lanes.ref = coerceRef(
returnFiber,
currentFirstChild,
newChild
)),
- (expirationTime.return = returnFiber),
- (returnFiber = expirationTime));
+ (lanes.return = returnFiber),
+ (returnFiber = lanes));
}
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
@@ -2945,7 +3193,7 @@ function ChildReconciler(shouldTrackSideEffects) {
currentFirstChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
@@ -2964,7 +3212,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(currentFirstChild = createFiberFromText(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
@@ -2975,14 +3223,14 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
if (getIteratorFn(newChild))
return reconcileChildrenIterator(
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
isObject && throwOnInvalidObjectType(returnFiber, newChild);
if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
@@ -3001,9 +3249,9 @@ function ChildReconciler(shouldTrackSideEffects) {
var reconcileChildFibers = ChildReconciler(!0),
mountChildFibers = ChildReconciler(!1),
NO_CONTEXT = {},
- contextStackCursor$1 = { current: NO_CONTEXT },
- contextFiberStackCursor = { current: NO_CONTEXT },
- rootInstanceStackCursor = { current: NO_CONTEXT };
+ contextStackCursor$1 = createCursor(NO_CONTEXT),
+ contextFiberStackCursor = createCursor(NO_CONTEXT),
+ rootInstanceStackCursor = createCursor(NO_CONTEXT);
function requiredContext(c) {
if (c === NO_CONTEXT)
throw Error(
@@ -3026,26 +3274,26 @@ function popHostContainer() {
function pushHostContext(fiber) {
requiredContext(rootInstanceStackCursor.current);
var context = requiredContext(contextStackCursor$1.current);
- var nextContext = fiber.type;
- nextContext =
- "AndroidTextInput" === nextContext ||
- "RCTMultilineTextInputView" === nextContext ||
- "RCTSinglelineTextInputView" === nextContext ||
- "RCTText" === nextContext ||
- "RCTVirtualText" === nextContext;
- nextContext =
- context.isInAParentText !== nextContext
- ? { isInAParentText: nextContext }
+ var JSCompiler_inline_result = fiber.type;
+ JSCompiler_inline_result =
+ "AndroidTextInput" === JSCompiler_inline_result ||
+ "RCTMultilineTextInputView" === JSCompiler_inline_result ||
+ "RCTSinglelineTextInputView" === JSCompiler_inline_result ||
+ "RCTText" === JSCompiler_inline_result ||
+ "RCTVirtualText" === JSCompiler_inline_result;
+ JSCompiler_inline_result =
+ context.isInAParentText !== JSCompiler_inline_result
+ ? { isInAParentText: JSCompiler_inline_result }
: context;
- context !== nextContext &&
+ context !== JSCompiler_inline_result &&
(push(contextFiberStackCursor, fiber),
- push(contextStackCursor$1, nextContext));
+ push(contextStackCursor$1, JSCompiler_inline_result));
}
function popHostContext(fiber) {
contextFiberStackCursor.current === fiber &&
(pop(contextStackCursor$1), pop(contextFiberStackCursor));
}
-var suspenseStackCursor = { current: 0 };
+var suspenseStackCursor = createCursor(0);
function findFirstSuspended(row) {
for (var node = row; null !== node; ) {
if (13 === node.tag) {
@@ -3072,13 +3320,20 @@ function findFirstSuspended(row) {
function createDeprecatedResponderListener(responder, props) {
return { responder: responder, props: props };
}
-var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
+var workInProgressSources = [];
+function resetWorkInProgressVersions() {
+ for (var i = 0; i < workInProgressSources.length; i++)
+ workInProgressSources[i]._workInProgressVersionSecondary = null;
+ workInProgressSources.length = 0;
+}
+var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig,
- renderExpirationTime = 0,
+ renderLanes = 0,
currentlyRenderingFiber$1 = null,
currentHook = null,
workInProgressHook = null,
- didScheduleRenderPhaseUpdate = !1;
+ didScheduleRenderPhaseUpdate = !1,
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
function throwInvalidHookError() {
throw Error(
"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."
@@ -3096,36 +3351,36 @@ function renderWithHooks(
Component,
props,
secondArg,
- nextRenderExpirationTime
+ nextRenderLanes
) {
- renderExpirationTime = nextRenderExpirationTime;
+ renderLanes = nextRenderLanes;
currentlyRenderingFiber$1 = workInProgress;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- workInProgress.expirationTime = 0;
- ReactCurrentDispatcher.current =
+ workInProgress.lanes = 0;
+ ReactCurrentDispatcher$1.current =
null === current || null === current.memoizedState
? HooksDispatcherOnMount
: HooksDispatcherOnUpdate;
current = Component(props, secondArg);
- if (workInProgress.expirationTime === renderExpirationTime) {
- nextRenderExpirationTime = 0;
+ if (didScheduleRenderPhaseUpdateDuringThisPass) {
+ nextRenderLanes = 0;
do {
- workInProgress.expirationTime = 0;
- if (!(25 > nextRenderExpirationTime))
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ if (!(25 > nextRenderLanes))
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
- nextRenderExpirationTime += 1;
+ nextRenderLanes += 1;
workInProgressHook = currentHook = null;
workInProgress.updateQueue = null;
- ReactCurrentDispatcher.current = HooksDispatcherOnRerender;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender;
current = Component(props, secondArg);
- } while (workInProgress.expirationTime === renderExpirationTime);
+ } while (didScheduleRenderPhaseUpdateDuringThisPass);
}
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
workInProgress = null !== currentHook && null !== currentHook.next;
- renderExpirationTime = 0;
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
didScheduleRenderPhaseUpdate = !1;
if (workInProgress)
@@ -3206,40 +3461,40 @@ function updateReducer(reducer) {
var newBaseQueueLast = (baseFirst = pendingQueue = null),
update = baseQueue;
do {
- var updateExpirationTime = update.expirationTime;
- if (updateExpirationTime < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- action: update.action,
- eagerReducer: update.eagerReducer,
- eagerState: update.eagerState,
- next: null
- };
- null === newBaseQueueLast
- ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- updateExpirationTime > currentlyRenderingFiber$1.expirationTime &&
- ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime),
- markUnprocessedUpdateTime(updateExpirationTime));
- } else
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
+ var suspenseConfig = update.suspenseConfig,
+ updateLane = update.lane,
+ updateEventTime = update.eventTime;
+ (renderLanes & updateLane) === updateLane
+ ? (null !== newBaseQueueLast &&
+ (newBaseQueueLast = newBaseQueueLast.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: update.suspenseConfig,
+ action: update.action,
+ eagerReducer: update.eagerReducer,
+ eagerState: update.eagerState,
+ next: null
+ }),
+ markRenderEventTimeAndConfig(updateEventTime, suspenseConfig),
+ (current =
+ update.eagerReducer === reducer
+ ? update.eagerState
+ : reducer(current, update.action)))
+ : ((suspenseConfig = {
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
next: null
}),
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ null === newBaseQueueLast
+ ? ((baseFirst = newBaseQueueLast = suspenseConfig),
+ (pendingQueue = current))
+ : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig),
+ (currentlyRenderingFiber$1.lanes |= updateLane),
+ (workInProgressRootSkippedLanes |= updateLane));
update = update.next;
} while (null !== update && update !== baseQueue);
null === newBaseQueueLast
@@ -3276,6 +3531,117 @@ function rerenderReducer(reducer) {
}
return [newState, dispatch];
}
+function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+ var getVersion = source._getVersion;
+ getVersion = getVersion(source._source);
+ var JSCompiler_inline_result = source._workInProgressVersionSecondary;
+ if (null !== JSCompiler_inline_result)
+ root = JSCompiler_inline_result === getVersion;
+ else if (
+ ((root = root.mutableReadLanes), (root = (renderLanes & root) === root))
+ )
+ (source._workInProgressVersionSecondary = getVersion),
+ workInProgressSources.push(source);
+ if (root) return getSnapshot(source._source);
+ workInProgressSources.push(source);
+ throw Error(
+ "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
+ );
+}
+function useMutableSource(hook, source, getSnapshot, subscribe) {
+ var root = workInProgressRoot;
+ if (null === root)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ var getVersion = source._getVersion,
+ version = getVersion(source._source),
+ dispatcher = ReactCurrentDispatcher$1.current,
+ _dispatcher$useState = dispatcher.useState(function() {
+ return readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ }),
+ setSnapshot = _dispatcher$useState[1],
+ snapshot = _dispatcher$useState[0];
+ _dispatcher$useState = workInProgressHook;
+ var memoizedState = hook.memoizedState,
+ refs = memoizedState.refs,
+ prevGetSnapshot = refs.getSnapshot,
+ prevSource = memoizedState.source;
+ memoizedState = memoizedState.subscribe;
+ var fiber = currentlyRenderingFiber$1;
+ hook.memoizedState = { refs: refs, source: source, subscribe: subscribe };
+ dispatcher.useEffect(
+ function() {
+ refs.getSnapshot = getSnapshot;
+ refs.setSnapshot = setSnapshot;
+ var maybeNewVersion = getVersion(source._source);
+ if (!objectIs(version, maybeNewVersion)) {
+ maybeNewVersion = getSnapshot(source._source);
+ objectIs(snapshot, maybeNewVersion) ||
+ (setSnapshot(maybeNewVersion),
+ (maybeNewVersion = requestUpdateLane(
+ fiber,
+ ReactCurrentBatchConfig.suspense
+ )),
+ (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes));
+ maybeNewVersion = root.mutableReadLanes;
+ root.entangledLanes |= maybeNewVersion;
+ for (
+ var entanglements = root.entanglements, lanes = maybeNewVersion;
+ 0 < lanes;
+
+ ) {
+ var index$12 = 31 - clz32(lanes),
+ lane = 1 << index$12;
+ entanglements[index$12] |= maybeNewVersion;
+ lanes &= ~lane;
+ }
+ }
+ },
+ [getSnapshot, source, subscribe]
+ );
+ dispatcher.useEffect(
+ function() {
+ return subscribe(source._source, function() {
+ var latestGetSnapshot = refs.getSnapshot,
+ latestSetSnapshot = refs.setSnapshot;
+ try {
+ latestSetSnapshot(latestGetSnapshot(source._source));
+ var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense);
+ root.mutableReadLanes |= lane & root.pendingLanes;
+ } catch (error) {
+ latestSetSnapshot(function() {
+ throw error;
+ });
+ }
+ });
+ },
+ [source, subscribe]
+ );
+ (objectIs(prevGetSnapshot, getSnapshot) &&
+ objectIs(prevSource, source) &&
+ objectIs(memoizedState, subscribe)) ||
+ ((hook = {
+ pending: null,
+ dispatch: null,
+ lastRenderedReducer: basicStateReducer,
+ lastRenderedState: snapshot
+ }),
+ (hook.dispatch = setSnapshot = dispatchAction.bind(
+ null,
+ currentlyRenderingFiber$1,
+ hook
+ )),
+ (_dispatcher$useState.queue = hook),
+ (_dispatcher$useState.baseQueue = null),
+ (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)),
+ (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot));
+ return snapshot;
+}
+function updateMutableSource(source, getSnapshot, subscribe) {
+ var hook = updateWorkInProgressHook();
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
@@ -3424,11 +3790,12 @@ function startTransition(setPending, config, callback) {
});
}
function dispatchAction(fiber, queue, action) {
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(fiber, suspenseConfig);
suspenseConfig = {
- expirationTime: currentTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
action: action,
eagerReducer: null,
@@ -3445,13 +3812,11 @@ function dispatchAction(fiber, queue, action) {
fiber === currentlyRenderingFiber$1 ||
(null !== pending && pending === currentlyRenderingFiber$1)
)
- (didScheduleRenderPhaseUpdate = !0),
- (suspenseConfig.expirationTime = renderExpirationTime),
- (currentlyRenderingFiber$1.expirationTime = renderExpirationTime);
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
else {
if (
- 0 === fiber.expirationTime &&
- (null === pending || 0 === pending.expirationTime) &&
+ 0 === fiber.lanes &&
+ (null === pending || 0 === pending.lanes) &&
((pending = queue.lastRenderedReducer), null !== pending)
)
try {
@@ -3463,10 +3828,9 @@ function dispatchAction(fiber, queue, action) {
} catch (error) {
} finally {
}
- scheduleWork(fiber, currentTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
}
-function updateEventListener() {}
var ContextOnlyDispatcher = {
readContext: readContext,
useCallback: throwInvalidHookError,
@@ -3482,7 +3846,9 @@ var ContextOnlyDispatcher = {
useResponder: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
- useEvent: throwInvalidHookError
+ useMutableSource: throwInvalidHookError,
+ useOpaqueIdentifier: throwInvalidHookError,
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
readContext: readContext,
@@ -3564,7 +3930,19 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: function() {}
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ var hook = mountWorkInProgressHook();
+ hook.memoizedState = {
+ refs: { getSnapshot: getSnapshot, setSnapshot: null },
+ source: source,
+ subscribe: subscribe
+ };
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ throw Error("Not yet implemented");
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnUpdate = {
readContext: readContext,
@@ -3612,7 +3990,11 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return updateReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
readContext: readContext,
@@ -3660,7 +4042,11 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return rerenderReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
now$1 = Scheduler.unstable_now,
commitTime = 0,
@@ -3673,27 +4059,21 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
profilerStartTime = -1;
}
}
+function transferActualDuration(fiber) {
+ for (var child = fiber.child; child; )
+ (fiber.actualDuration += child.actualDuration), (child = child.sibling);
+}
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
didReceiveUpdate = !1;
-function reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
-) {
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
workInProgress.child =
null === current
- ? mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderExpirationTime
- )
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
: reconcileChildFibers(
workInProgress,
current.child,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
function updateForwardRef(
@@ -3701,33 +4081,28 @@ function updateForwardRef(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
Component = Component.render;
var ref = workInProgress.ref;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
nextProps = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, nextProps, renderExpirationTime);
+ reconcileChildren(current, workInProgress, nextProps, renderLanes);
return workInProgress.child;
}
function updateMemoComponent(
@@ -3735,8 +4110,8 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (null === current) {
var type = Component.type;
@@ -3755,8 +4130,8 @@ function updateMemoComponent(
workInProgress,
type,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
current = createFiberFromTypeAndProps(
@@ -3765,7 +4140,7 @@ function updateMemoComponent(
nextProps,
null,
workInProgress.mode,
- renderExpirationTime
+ renderLanes
);
current.ref = workInProgress.ref;
current.return = workInProgress;
@@ -3773,18 +4148,13 @@ function updateMemoComponent(
}
type = current.child;
if (
- updateExpirationTime < renderExpirationTime &&
- ((updateExpirationTime = type.memoizedProps),
+ 0 === (updateLanes & renderLanes) &&
+ ((updateLanes = type.memoizedProps),
(Component = Component.compare),
(Component = null !== Component ? Component : shallowEqual),
- Component(updateExpirationTime, nextProps) &&
- current.ref === workInProgress.ref)
+ Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
)
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
workInProgress.effectTag |= 1;
current = createWorkInProgress(type, nextProps);
current.ref = workInProgress.ref;
@@ -3796,26 +4166,66 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
- return null !== current &&
+ if (
+ null !== current &&
shallowEqual(current.memoizedProps, nextProps) &&
- current.ref === workInProgress.ref &&
- ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime)
- ? ((workInProgress.expirationTime = current.expirationTime),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- ))
- : updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
+ current.ref === workInProgress.ref
+ )
+ if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes)))
+ 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0);
+ else
+ return (
+ (workInProgress.lanes = current.lanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
+ );
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
+}
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
+ nextChildren = nextProps.children,
+ prevState = null !== current ? current.memoizedState : null;
+ if (
+ "hidden" === nextProps.mode ||
+ "unstable-defer-without-hiding" === nextProps.mode
+ )
+ if (0 === (workInProgress.mode & 4))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(workInProgress, renderLanes);
+ else if (0 !== (renderLanes & 1073741824))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(
+ workInProgress,
+ null !== prevState ? prevState.baseLanes : renderLanes
+ );
+ else
+ return (
+ (current =
+ null !== prevState ? prevState.baseLanes | renderLanes : renderLanes),
+ null === spawnedWorkDuringRender
+ ? (spawnedWorkDuringRender = [1073741824])
+ : spawnedWorkDuringRender.push(1073741824),
+ (workInProgress.lanes = workInProgress.childLanes = 1073741824),
+ (workInProgress.memoizedState = { baseLanes: current }),
+ pushRenderLanes(workInProgress, current),
+ null
);
+ else
+ null !== prevState
+ ? ((nextProps = prevState.baseLanes | renderLanes),
+ (workInProgress.memoizedState = null))
+ : (nextProps = renderLanes),
+ pushRenderLanes(workInProgress, nextProps);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
}
function markRef(current, workInProgress) {
var ref = workInProgress.ref;
@@ -3830,35 +4240,30 @@ function updateFunctionComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
var context = isContextProvider(Component)
? previousContext
: contextStackCursor.current;
context = getMaskedContext(workInProgress, context);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
Component = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, Component, renderExpirationTime);
+ reconcileChildren(current, workInProgress, Component, renderLanes);
return workInProgress.child;
}
function updateClassComponent(
@@ -3866,25 +4271,20 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
if (null === workInProgress.stateNode)
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
constructClassInstance(workInProgress, Component, nextProps),
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- ),
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes),
(nextProps = !0);
else if (null === current) {
var instance = workInProgress.stateNode,
@@ -3915,12 +4315,7 @@ function updateClassComponent(
hasForceUpdate = !1;
var oldState = workInProgress.memoizedState;
instance.state = oldState;
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- );
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
oldContext = workInProgress.memoizedState;
oldProps !== nextProps ||
oldState !== oldContext ||
@@ -3965,117 +4360,111 @@ function updateClassComponent(
: ("function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4),
(nextProps = !1));
- } else
- (instance = workInProgress.stateNode),
- cloneUpdateQueue(current, workInProgress),
- (oldProps = workInProgress.memoizedProps),
- (instance.props =
- workInProgress.type === workInProgress.elementType
- ? oldProps
- : resolveDefaultProps(workInProgress.type, oldProps)),
- (oldContext = instance.context),
- (contextType = Component.contextType),
- "object" === typeof contextType && null !== contextType
- ? (contextType = readContext(contextType))
- : ((contextType = isContextProvider(Component)
- ? previousContext
- : contextStackCursor.current),
- (contextType = getMaskedContext(workInProgress, contextType))),
- (getDerivedStateFromProps = Component.getDerivedStateFromProps),
- (hasNewLifecycles =
- "function" === typeof getDerivedStateFromProps ||
- "function" === typeof instance.getSnapshotBeforeUpdate) ||
- ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
- "function" !== typeof instance.componentWillReceiveProps) ||
- ((oldProps !== nextProps || oldContext !== contextType) &&
- callComponentWillReceiveProps(
+ } else {
+ instance = workInProgress.stateNode;
+ cloneUpdateQueue(current, workInProgress);
+ oldProps = workInProgress.memoizedProps;
+ contextType =
+ workInProgress.type === workInProgress.elementType
+ ? oldProps
+ : resolveDefaultProps(workInProgress.type, oldProps);
+ instance.props = contextType;
+ hasNewLifecycles = workInProgress.pendingProps;
+ oldState = instance.context;
+ oldContext = Component.contextType;
+ "object" === typeof oldContext && null !== oldContext
+ ? (oldContext = readContext(oldContext))
+ : ((oldContext = isContextProvider(Component)
+ ? previousContext
+ : contextStackCursor.current),
+ (oldContext = getMaskedContext(workInProgress, oldContext)));
+ var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps;
+ (getDerivedStateFromProps =
+ "function" === typeof getDerivedStateFromProps$jscomp$0 ||
+ "function" === typeof instance.getSnapshotBeforeUpdate) ||
+ ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
+ "function" !== typeof instance.componentWillReceiveProps) ||
+ ((oldProps !== hasNewLifecycles || oldState !== oldContext) &&
+ callComponentWillReceiveProps(
+ workInProgress,
+ instance,
+ nextProps,
+ oldContext
+ ));
+ hasForceUpdate = !1;
+ oldState = workInProgress.memoizedState;
+ instance.state = oldState;
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
+ var newState = workInProgress.memoizedState;
+ oldProps !== hasNewLifecycles ||
+ oldState !== newState ||
+ didPerformWorkStackCursor.current ||
+ hasForceUpdate
+ ? ("function" === typeof getDerivedStateFromProps$jscomp$0 &&
+ (applyDerivedStateFromProps(
+ workInProgress,
+ Component,
+ getDerivedStateFromProps$jscomp$0,
+ nextProps
+ ),
+ (newState = workInProgress.memoizedState)),
+ (contextType =
+ hasForceUpdate ||
+ checkShouldComponentUpdate(
workInProgress,
- instance,
+ Component,
+ contextType,
nextProps,
- contextType
- )),
- (hasForceUpdate = !1),
- (oldContext = workInProgress.memoizedState),
- (instance.state = oldContext),
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- ),
- (oldState = workInProgress.memoizedState),
- oldProps !== nextProps ||
- oldContext !== oldState ||
- didPerformWorkStackCursor.current ||
- hasForceUpdate
- ? ("function" === typeof getDerivedStateFromProps &&
- (applyDerivedStateFromProps(
- workInProgress,
- Component,
- getDerivedStateFromProps,
- nextProps
- ),
- (oldState = workInProgress.memoizedState)),
- (getDerivedStateFromProps =
- hasForceUpdate ||
- checkShouldComponentUpdate(
- workInProgress,
- Component,
- oldProps,
- nextProps,
- oldContext,
- oldState,
- contextType
- ))
- ? (hasNewLifecycles ||
- ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
- "function" !== typeof instance.componentWillUpdate) ||
- ("function" === typeof instance.componentWillUpdate &&
- instance.componentWillUpdate(
- nextProps,
- oldState,
- contextType
- ),
- "function" === typeof instance.UNSAFE_componentWillUpdate &&
- instance.UNSAFE_componentWillUpdate(
- nextProps,
- oldState,
- contextType
- )),
- "function" === typeof instance.componentDidUpdate &&
- (workInProgress.effectTag |= 4),
- "function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.effectTag |= 256))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (workInProgress.memoizedProps = nextProps),
- (workInProgress.memoizedState = oldState)),
- (instance.props = nextProps),
- (instance.state = oldState),
- (instance.context = contextType),
- (nextProps = getDerivedStateFromProps))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (nextProps = !1));
+ oldState,
+ newState,
+ oldContext
+ ))
+ ? (getDerivedStateFromProps ||
+ ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
+ "function" !== typeof instance.componentWillUpdate) ||
+ ("function" === typeof instance.componentWillUpdate &&
+ instance.componentWillUpdate(nextProps, newState, oldContext),
+ "function" === typeof instance.UNSAFE_componentWillUpdate &&
+ instance.UNSAFE_componentWillUpdate(
+ nextProps,
+ newState,
+ oldContext
+ )),
+ "function" === typeof instance.componentDidUpdate &&
+ (workInProgress.effectTag |= 4),
+ "function" === typeof instance.getSnapshotBeforeUpdate &&
+ (workInProgress.effectTag |= 256))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (workInProgress.memoizedProps = nextProps),
+ (workInProgress.memoizedState = newState)),
+ (instance.props = nextProps),
+ (instance.state = newState),
+ (instance.context = oldContext),
+ (nextProps = contextType))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (nextProps = !1));
+ }
return finishClassComponent(
current,
workInProgress,
Component,
nextProps,
hasContext,
- renderExpirationTime
+ renderLanes
);
}
function finishClassComponent(
@@ -4084,18 +4473,14 @@ function finishClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
) {
markRef(current, workInProgress);
var didCaptureError = 0 !== (workInProgress.effectTag & 64);
if (!shouldUpdate && !didCaptureError)
return (
hasContext && invalidateContextProvider(workInProgress, Component, !1),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
shouldUpdate = workInProgress.stateNode;
ReactCurrentOwner$1.current = workInProgress;
@@ -4113,20 +4498,15 @@ function finishClassComponent(
workInProgress,
current.child,
null,
- renderExpirationTime
+ renderLanes
)),
(workInProgress.child = reconcileChildFibers(
workInProgress,
null,
didCaptureError,
- renderExpirationTime
+ renderLanes
)))
- : reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ : reconcileChildren(current, workInProgress, nextChildren, renderLanes);
workInProgress.memoizedState = shouldUpdate.state;
hasContext && invalidateContextProvider(workInProgress, Component, !0);
return workInProgress.child;
@@ -4143,169 +4523,198 @@ function pushHostRootContext(workInProgress) {
pushTopLevelContextObject(workInProgress, root.context, !1);
pushHostContainer(workInProgress, root.containerInfo);
}
-var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 };
-function updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
- var mode = workInProgress.mode,
- nextProps = workInProgress.pendingProps,
+var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
suspenseContext = suspenseStackCursor.current,
- nextDidTimeout = !1,
+ showFallback = !1,
JSCompiler_temp;
(JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) ||
(JSCompiler_temp =
- 0 !== (suspenseContext & 2) &&
- (null === current || null !== current.memoizedState));
+ null !== current && null === current.memoizedState
+ ? !1
+ : 0 !== (suspenseContext & 2));
JSCompiler_temp
- ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65))
+ ? ((showFallback = !0), (workInProgress.effectTag &= -65))
: (null !== current && null === current.memoizedState) ||
void 0 === nextProps.fallback ||
!0 === nextProps.unstable_avoidThisFallback ||
(suspenseContext |= 1);
push(suspenseStackCursor, suspenseContext & 1);
if (null === current) {
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (current = nextProps.fallback),
+ (suspenseContext = workInProgress.mode),
+ (showFallback = workInProgress.child),
+ (nextProps = { mode: "hidden", children: nextProps.children }),
+ 0 === (suspenseContext & 2) && null !== showFallback
+ ? ((showFallback.childLanes = 0),
+ (showFallback.pendingProps = nextProps),
+ workInProgress.mode & 8 &&
+ ((showFallback.actualDuration = 0),
+ (showFallback.actualStartTime = -1),
+ (showFallback.selfBaseDuration = 0),
+ (showFallback.treeBaseDuration = 0)))
+ : (showFallback = createFiberFromOffscreen(
+ nextProps,
+ suspenseContext,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
+ current,
+ suspenseContext,
+ renderLanes,
+ null
+ )),
+ (showFallback.return = workInProgress),
+ (current.return = workInProgress),
+ (showFallback.sibling = current),
+ (workInProgress.child = showFallback),
+ (workInProgress.child.memoizedState = { baseLanes: renderLanes }),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ current
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- mode = nextProps.children;
- workInProgress.memoizedState = null;
- return (workInProgress.child = mountChildFibers(
- workInProgress,
- null,
- mode,
- renderExpirationTime
- ));
+ renderLanes = createFiberFromOffscreen(
+ { mode: "visible", children: nextProps.children },
+ workInProgress.mode,
+ renderLanes,
+ null
+ );
+ renderLanes.return = workInProgress;
+ return (workInProgress.child = renderLanes);
}
if (null !== current.memoizedState) {
- current = current.child;
- mode = current.sibling;
- if (nextDidTimeout) {
- nextProps = nextProps.fallback;
- renderExpirationTime = createWorkInProgress(
- current,
- current.pendingProps
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- if (
- 0 === (workInProgress.mode & 2) &&
- ((nextDidTimeout =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child),
- nextDidTimeout !== current.child)
- )
- for (
- renderExpirationTime.child = nextDidTimeout;
- null !== nextDidTimeout;
-
- )
- (nextDidTimeout.return = renderExpirationTime),
- (nextDidTimeout = nextDidTimeout.sibling);
- if (workInProgress.mode & 8) {
- nextDidTimeout = 0;
- for (current = renderExpirationTime.child; null !== current; )
- (nextDidTimeout += current.treeBaseDuration),
- (current = current.sibling);
- renderExpirationTime.treeBaseDuration = nextDidTimeout;
- }
- mode = createWorkInProgress(mode, nextProps);
- mode.return = workInProgress;
- renderExpirationTime.sibling = mode;
- renderExpirationTime.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = renderExpirationTime;
- return mode;
- }
- renderExpirationTime = reconcileChildFibers(
+ renderLanes = updateSuspensePrimaryChildren(
+ current,
workInProgress,
- current.child,
nextProps.children,
- renderExpirationTime
+ renderLanes
);
workInProgress.memoizedState = null;
- return (workInProgress.child = renderExpirationTime);
+ return renderLanes;
}
- current = current.child;
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- nextProps.child = current;
- null !== current && (current.return = nextProps);
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- if (workInProgress.mode & 8) {
- current = 0;
- for (suspenseContext = nextProps.child; null !== suspenseContext; )
- (current += suspenseContext.treeBaseDuration),
- (suspenseContext = suspenseContext.sibling);
- nextProps.treeBaseDuration = current;
- }
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- renderExpirationTime.effectTag |= 2;
- nextProps.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- workInProgress.memoizedState = null;
- return (workInProgress.child = reconcileChildFibers(
- workInProgress,
+ renderLanes = updateSuspensePrimaryChildren(
current,
+ workInProgress,
nextProps.children,
- renderExpirationTime
- ));
+ renderLanes
+ );
+ workInProgress.memoizedState = null;
+ return renderLanes;
}
-function scheduleWorkOnFiber(fiber, renderExpirationTime) {
- fiber.expirationTime < renderExpirationTime &&
- (fiber.expirationTime = renderExpirationTime);
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ primaryChildren = createWorkInProgress(currentPrimaryChildFragment, {
+ mode: "visible",
+ children: primaryChildren
+ });
+ 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes);
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = null;
+ null !== current &&
+ ((current.nextEffect = null),
+ (current.effectTag = 8),
+ (workInProgress.firstEffect = workInProgress.lastEffect = current));
+ return (workInProgress.child = primaryChildren);
+}
+function updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode,
+ currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ var primaryChildProps = { mode: "hidden", children: primaryChildren };
+ 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment
+ ? ((primaryChildren = workInProgress.child),
+ (primaryChildren.childLanes = 0),
+ (primaryChildren.pendingProps = primaryChildProps),
+ workInProgress.mode & 8 &&
+ ((primaryChildren.actualDuration = 0),
+ (primaryChildren.actualStartTime = -1),
+ (primaryChildren.selfBaseDuration =
+ currentPrimaryChildFragment.selfBaseDuration),
+ (primaryChildren.treeBaseDuration =
+ currentPrimaryChildFragment.treeBaseDuration)),
+ (currentPrimaryChildFragment = primaryChildren.lastEffect),
+ null !== currentPrimaryChildFragment
+ ? ((workInProgress.firstEffect = primaryChildren.firstEffect),
+ (workInProgress.lastEffect = currentPrimaryChildFragment),
+ (currentPrimaryChildFragment.nextEffect = null))
+ : (workInProgress.firstEffect = workInProgress.lastEffect = null))
+ : (primaryChildren = createWorkInProgress(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ ));
+ null !== current
+ ? (fallbackChildren = createWorkInProgress(current, fallbackChildren))
+ : ((fallbackChildren = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ )),
+ (fallbackChildren.effectTag |= 2));
+ fallbackChildren.return = workInProgress;
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = fallbackChildren;
+ workInProgress.child = primaryChildren;
+ return fallbackChildren;
+}
+function scheduleWorkOnFiber(fiber, renderLanes) {
+ fiber.lanes |= renderLanes;
var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < renderExpirationTime &&
- (alternate.expirationTime = renderExpirationTime);
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
+ null !== alternate && (alternate.lanes |= renderLanes);
+ scheduleWorkOnParentPath(fiber.return, renderLanes);
}
function initSuspenseListRenderState(
workInProgress,
@@ -4336,20 +4745,11 @@ function initSuspenseListRenderState(
(renderState.tailMode = tailMode),
(renderState.lastEffect = lastEffectBeforeRendering));
}
-function updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps,
revealOrder = nextProps.revealOrder,
tailMode = nextProps.tail;
- reconcileChildren(
- current,
- workInProgress,
- nextProps.children,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
nextProps = suspenseStackCursor.current;
if (0 !== (nextProps & 2))
(nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64);
@@ -4358,9 +4758,8 @@ function updateSuspenseListComponent(
a: for (current = workInProgress.child; null !== current; ) {
if (13 === current.tag)
null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderExpirationTime);
- else if (19 === current.tag)
- scheduleWorkOnFiber(current, renderExpirationTime);
+ scheduleWorkOnFiber(current, renderLanes);
+ else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
else if (null !== current.child) {
current.child.return = current;
current = current.child;
@@ -4382,30 +4781,29 @@ function updateSuspenseListComponent(
else
switch (revealOrder) {
case "forwards":
- renderExpirationTime = workInProgress.child;
- for (revealOrder = null; null !== renderExpirationTime; )
- (current = renderExpirationTime.alternate),
+ renderLanes = workInProgress.child;
+ for (revealOrder = null; null !== renderLanes; )
+ (current = renderLanes.alternate),
null !== current &&
null === findFirstSuspended(current) &&
- (revealOrder = renderExpirationTime),
- (renderExpirationTime = renderExpirationTime.sibling);
- renderExpirationTime = revealOrder;
- null === renderExpirationTime
+ (revealOrder = renderLanes),
+ (renderLanes = renderLanes.sibling);
+ renderLanes = revealOrder;
+ null === renderLanes
? ((revealOrder = workInProgress.child),
(workInProgress.child = null))
- : ((revealOrder = renderExpirationTime.sibling),
- (renderExpirationTime.sibling = null));
+ : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
initSuspenseListRenderState(
workInProgress,
!1,
revealOrder,
- renderExpirationTime,
+ renderLanes,
tailMode,
workInProgress.lastEffect
);
break;
case "backwards":
- renderExpirationTime = null;
+ renderLanes = null;
revealOrder = workInProgress.child;
for (workInProgress.child = null; null !== revealOrder; ) {
current = revealOrder.alternate;
@@ -4414,14 +4812,14 @@ function updateSuspenseListComponent(
break;
}
current = revealOrder.sibling;
- revealOrder.sibling = renderExpirationTime;
- renderExpirationTime = revealOrder;
+ revealOrder.sibling = renderLanes;
+ renderLanes = revealOrder;
revealOrder = current;
}
initSuspenseListRenderState(
workInProgress,
!0,
- renderExpirationTime,
+ renderLanes,
null,
tailMode,
workInProgress.lastEffect
@@ -4442,36 +4840,29 @@ function updateSuspenseListComponent(
}
return workInProgress.child;
}
-function bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
null !== current && (workInProgress.dependencies = current.dependencies);
profilerStartTime = -1;
- var updateExpirationTime = workInProgress.expirationTime;
- 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime);
- if (workInProgress.childExpirationTime < renderExpirationTime) return null;
- if (null !== current && workInProgress.child !== current.child)
- throw Error("Resuming work not yet implemented.");
- if (null !== workInProgress.child) {
- current = workInProgress.child;
- renderExpirationTime = createWorkInProgress(current, current.pendingProps);
- workInProgress.child = renderExpirationTime;
- for (
- renderExpirationTime.return = workInProgress;
- null !== current.sibling;
-
- )
- (current = current.sibling),
- (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress(
- current,
- current.pendingProps
- )),
- (renderExpirationTime.return = workInProgress);
- renderExpirationTime.sibling = null;
+ workInProgressRootSkippedLanes |= workInProgress.lanes;
+ if (0 !== (renderLanes & workInProgress.childLanes)) {
+ if (null !== current && workInProgress.child !== current.child)
+ throw Error("Resuming work not yet implemented.");
+ if (null !== workInProgress.child) {
+ current = workInProgress.child;
+ renderLanes = createWorkInProgress(current, current.pendingProps);
+ workInProgress.child = renderLanes;
+ for (renderLanes.return = workInProgress; null !== current.sibling; )
+ (current = current.sibling),
+ (renderLanes = renderLanes.sibling = createWorkInProgress(
+ current,
+ current.pendingProps
+ )),
+ (renderLanes.return = workInProgress);
+ renderLanes.sibling = null;
+ }
+ return workInProgress.child;
}
- return workInProgress.child;
+ return null;
}
var appendAllChildren,
updateHostContainer,
@@ -4664,17 +5055,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
break;
case "collapsed":
lastTailNode = renderState.tail;
- for (var _lastTailNode = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (_lastTailNode = lastTailNode),
+ for (var lastTailNode$65 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode),
(lastTailNode = lastTailNode.sibling);
- null === _lastTailNode
+ null === lastTailNode$65
? hasRenderedATailFallback || null === renderState.tail
? (renderState.tail = null)
: (renderState.tail.sibling = null)
- : (_lastTailNode.sibling = null);
+ : (lastTailNode$65.sibling = null);
}
}
-function completeWork(current, workInProgress, renderExpirationTime) {
+function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
case 2:
@@ -4695,10 +5086,14 @@ function completeWork(current, workInProgress, renderExpirationTime) {
popHostContainer(),
pop(didPerformWorkStackCursor),
pop(contextStackCursor),
- (current = workInProgress.stateNode),
- current.pendingContext &&
- ((current.context = current.pendingContext),
- (current.pendingContext = null)),
+ resetWorkInProgressVersions(),
+ (newProps = workInProgress.stateNode),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ newProps.hydrate ||
+ (workInProgress.effectTag |= 256),
updateHostContainer(workInProgress),
null
);
@@ -4707,12 +5102,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
var rootContainerInstance = requiredContext(
rootInstanceStackCursor.current
);
- renderExpirationTime = workInProgress.type;
+ renderLanes = workInProgress.type;
if (null !== current && null != workInProgress.stateNode)
updateHostComponent$1(
current,
workInProgress,
- renderExpirationTime,
+ renderLanes,
newProps,
rootContainerInstance
),
@@ -4729,23 +5124,23 @@ function completeWork(current, workInProgress, renderExpirationTime) {
requiredContext(contextStackCursor$1.current);
current = nextReactTag;
nextReactTag += 2;
- renderExpirationTime = getViewConfigForType(renderExpirationTime);
+ renderLanes = getViewConfigForType(renderLanes);
var updatePayload = diffProperties(
null,
emptyObject,
newProps,
- renderExpirationTime.validAttributes
+ renderLanes.validAttributes
);
rootContainerInstance = createNode(
current,
- renderExpirationTime.uiViewClassName,
+ renderLanes.uiViewClassName,
rootContainerInstance,
updatePayload,
workInProgress
);
current = new ReactFabricHostComponent(
current,
- renderExpirationTime,
+ renderLanes,
newProps,
workInProgress
);
@@ -4783,48 +5178,36 @@ function completeWork(current, workInProgress, renderExpirationTime) {
newProps = workInProgress.memoizedState;
if (0 !== (workInProgress.effectTag & 64))
return (
- (workInProgress.expirationTime = renderExpirationTime), workInProgress
+ (workInProgress.lanes = renderLanes),
+ 0 !== (workInProgress.mode & 8) &&
+ transferActualDuration(workInProgress),
+ workInProgress
);
newProps = null !== newProps;
rootContainerInstance = !1;
null !== current &&
- ((renderExpirationTime = current.memoizedState),
- (rootContainerInstance = null !== renderExpirationTime),
- newProps ||
- null === renderExpirationTime ||
- ((renderExpirationTime = current.child.sibling),
- null !== renderExpirationTime &&
- ((updatePayload = workInProgress.firstEffect),
- null !== updatePayload
- ? ((workInProgress.firstEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = updatePayload))
- : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = null)),
- (renderExpirationTime.effectTag = 8))));
+ (rootContainerInstance = null !== current.memoizedState);
if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2))
if (
(null === current &&
!0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
0 !== (suspenseStackCursor.current & 1)
)
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootSuspended);
+ 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3);
else {
if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus
)
- workInProgressRootExitStatus = RootSuspendedWithDelay;
- 0 !== workInProgressRootNextUnprocessedUpdateTime &&
- null !== workInProgressRoot &&
- (markRootSuspendedAtTime(
- workInProgressRoot,
- renderExpirationTime$1
- ),
- markRootUpdatedAtTime(
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 134217727) &&
+ 0 === (workInProgressRootUpdatedLanes & 134217727)) ||
+ markRootSuspended$1(
workInProgressRoot,
- workInProgressRootNextUnprocessedUpdateTime
- ));
+ workInProgressRootRenderLanes
+ );
}
newProps && (workInProgress.effectTag |= 4);
return null;
@@ -4844,7 +5227,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1);
else {
if (
- workInProgressRootExitStatus !== RootIncomplete ||
+ 0 !== workInProgressRootExitStatus ||
(null !== current && 0 !== (current.effectTag & 64))
)
for (current = workInProgress.child; null !== current; ) {
@@ -4859,7 +5242,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
null === newProps.lastEffect &&
(workInProgress.firstEffect = null);
workInProgress.lastEffect = newProps.lastEffect;
- current = renderExpirationTime;
+ current = renderLanes;
for (newProps = workInProgress.child; null !== newProps; )
(rootContainerInstance = newProps),
(updatePayload = current),
@@ -4867,42 +5250,42 @@ function completeWork(current, workInProgress, renderExpirationTime) {
(rootContainerInstance.nextEffect = null),
(rootContainerInstance.firstEffect = null),
(rootContainerInstance.lastEffect = null),
- (renderExpirationTime = rootContainerInstance.alternate),
- null === renderExpirationTime
- ? ((rootContainerInstance.childExpirationTime = 0),
- (rootContainerInstance.expirationTime = updatePayload),
+ (renderLanes = rootContainerInstance.alternate),
+ null === renderLanes
+ ? ((rootContainerInstance.childLanes = 0),
+ (rootContainerInstance.lanes = updatePayload),
(rootContainerInstance.child = null),
(rootContainerInstance.memoizedProps = null),
(rootContainerInstance.memoizedState = null),
(rootContainerInstance.updateQueue = null),
(rootContainerInstance.dependencies = null),
+ (rootContainerInstance.stateNode = null),
(rootContainerInstance.selfBaseDuration = 0),
(rootContainerInstance.treeBaseDuration = 0))
- : ((rootContainerInstance.childExpirationTime =
- renderExpirationTime.childExpirationTime),
- (rootContainerInstance.expirationTime =
- renderExpirationTime.expirationTime),
- (rootContainerInstance.child =
- renderExpirationTime.child),
+ : ((rootContainerInstance.childLanes =
+ renderLanes.childLanes),
+ (rootContainerInstance.lanes = renderLanes.lanes),
+ (rootContainerInstance.child = renderLanes.child),
(rootContainerInstance.memoizedProps =
- renderExpirationTime.memoizedProps),
+ renderLanes.memoizedProps),
(rootContainerInstance.memoizedState =
- renderExpirationTime.memoizedState),
+ renderLanes.memoizedState),
(rootContainerInstance.updateQueue =
- renderExpirationTime.updateQueue),
- (updatePayload = renderExpirationTime.dependencies),
+ renderLanes.updateQueue),
+ (rootContainerInstance.type = renderLanes.type),
+ (updatePayload = renderLanes.dependencies),
(rootContainerInstance.dependencies =
null === updatePayload
? null
: {
- expirationTime: updatePayload.expirationTime,
+ lanes: updatePayload.lanes,
firstContext: updatePayload.firstContext,
responders: updatePayload.responders
}),
(rootContainerInstance.selfBaseDuration =
- renderExpirationTime.selfBaseDuration),
+ renderLanes.selfBaseDuration),
(rootContainerInstance.treeBaseDuration =
- renderExpirationTime.treeBaseDuration)),
+ renderLanes.treeBaseDuration)),
(newProps = newProps.sibling);
push(
suspenseStackCursor,
@@ -4938,15 +5321,14 @@ function completeWork(current, workInProgress, renderExpirationTime) {
);
} else
2 * now() - newProps.renderingStartTime > newProps.tailExpiration &&
- 1 < renderExpirationTime &&
+ 1073741824 !== renderLanes &&
((workInProgress.effectTag |= 64),
(rootContainerInstance = !0),
cutOffTailIfNeeded(newProps, !1),
- (current = renderExpirationTime - 1),
- (workInProgress.expirationTime = workInProgress.childExpirationTime = current),
+ (workInProgress.lanes = renderLanes),
null === spawnedWorkDuringRender
- ? (spawnedWorkDuringRender = [current])
- : spawnedWorkDuringRender.push(current));
+ ? (spawnedWorkDuringRender = [renderLanes])
+ : spawnedWorkDuringRender.push(renderLanes));
newProps.isBackwards
? ((updatePayload.sibling = workInProgress.child),
(workInProgress.child = updatePayload))
@@ -4974,6 +5356,17 @@ function completeWork(current, workInProgress, renderExpirationTime) {
),
current)
: null;
+ case 23:
+ case 24:
+ return (
+ popRenderLanes(),
+ null !== current &&
+ (null !== current.memoizedState) !==
+ (null !== workInProgress.memoizedState) &&
+ "unstable-defer-without-hiding" !== newProps.mode &&
+ (workInProgress.effectTag |= 4),
+ null
+ );
}
throw Error(
"Unknown unit of work tag (" +
@@ -4988,12 +5381,15 @@ function unwindWork(workInProgress) {
var effectTag = workInProgress.effectTag;
return effectTag & 4096
? ((workInProgress.effectTag = (effectTag & -4097) | 64),
+ 0 !== (workInProgress.mode & 8) &&
+ transferActualDuration(workInProgress),
workInProgress)
: null;
case 3:
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
effectTag = workInProgress.effectTag;
if (0 !== (effectTag & 64))
throw Error(
@@ -5009,6 +5405,8 @@ function unwindWork(workInProgress) {
(effectTag = workInProgress.effectTag),
effectTag & 4096
? ((workInProgress.effectTag = (effectTag & -4097) | 64),
+ 0 !== (workInProgress.mode & 8) &&
+ transferActualDuration(workInProgress),
workInProgress)
: null
);
@@ -5018,16 +5416,25 @@ function unwindWork(workInProgress) {
return popHostContainer(), null;
case 10:
return popProvider(workInProgress), null;
+ case 23:
+ case 24:
+ return popRenderLanes(), null;
default:
return null;
}
}
function createCapturedValue(value, source) {
- return {
- value: value,
- source: source,
- stack: getStackByFiberInDevAndProd(source)
- };
+ try {
+ var info = "",
+ node = source;
+ do (info += describeFiber(node)), (node = node.return);
+ while (node);
+ var JSCompiler_inline_result = info;
+ } catch (x) {
+ JSCompiler_inline_result =
+ "\nError generating stack: " + x.message + "\n" + x.stack;
+ }
+ return { value: value, source: source, stack: JSCompiler_inline_result };
}
if (
"function" !==
@@ -5036,51 +5443,61 @@ if (
throw Error(
"Expected ReactFiberErrorDialog.showErrorDialog to be a function."
);
-function logCapturedError(capturedError) {
- !1 !==
- ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
- capturedError
- ) && console.error(capturedError.error);
-}
-var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
-function logError(boundary, errorInfo) {
- var source = errorInfo.source,
- stack = errorInfo.stack;
- null === stack &&
- null !== source &&
- (stack = getStackByFiberInDevAndProd(source));
- errorInfo = {
- componentName: null !== source ? getComponentName(source.type) : null,
- componentStack: null !== stack ? stack : "",
- error: errorInfo.value,
- errorBoundary: null,
- errorBoundaryName: null,
- errorBoundaryFound: !1,
- willRetry: !1
- };
- null !== boundary &&
- 1 === boundary.tag &&
- ((errorInfo.errorBoundary = boundary.stateNode),
- (errorInfo.errorBoundaryName = getComponentName(boundary.type)),
- (errorInfo.errorBoundaryFound = !0),
- (errorInfo.willRetry = !0));
+function logCapturedError(boundary, errorInfo) {
try {
- logCapturedError(errorInfo);
+ !1 !==
+ ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({
+ componentStack: null !== errorInfo.stack ? errorInfo.stack : "",
+ error: errorInfo.value,
+ errorBoundary:
+ null !== boundary && 1 === boundary.tag ? boundary.stateNode : null
+ }) && console.error(errorInfo.value);
} catch (e) {
setTimeout(function() {
throw e;
});
}
}
-function safelyCallComponentWillUnmount(current, instance) {
- try {
- (instance.props = current.memoizedProps),
- (instance.state = current.memoizedState),
- instance.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(current, unmountError);
+var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
+function createRootErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ lane.payload = { element: null };
+ var error = errorInfo.value;
+ lane.callback = function() {
+ hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
+ logCapturedError(fiber, errorInfo);
+ };
+ return lane;
+}
+function createClassErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+ if ("function" === typeof getDerivedStateFromError) {
+ var error = errorInfo.value;
+ lane.payload = function() {
+ logCapturedError(fiber, errorInfo);
+ return getDerivedStateFromError(error);
+ };
}
+ var inst = fiber.stateNode;
+ null !== inst &&
+ "function" === typeof inst.componentDidCatch &&
+ (lane.callback = function() {
+ "function" !== typeof getDerivedStateFromError &&
+ (null === legacyErrorBoundariesThatAlreadyFailed
+ ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
+ : legacyErrorBoundariesThatAlreadyFailed.add(this),
+ logCapturedError(fiber, errorInfo));
+ var stack = errorInfo.stack;
+ this.componentDidCatch(errorInfo.value, {
+ componentStack: null !== stack ? stack : ""
+ });
+ });
+ return lane;
}
+var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
function safelyDetachRef(current) {
var ref = current.ref;
if (null !== ref)
@@ -5114,6 +5531,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
}
return;
case 3:
+ return;
case 5:
case 6:
case 4:
@@ -5124,58 +5542,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitHookEffectListUnmount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var destroy = effect.destroy;
- effect.destroy = void 0;
- void 0 !== destroy && destroy();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
-function commitHookEffectListMount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var create = effect.create;
- effect.destroy = create();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
function commitLifeCycles(finishedRoot, current, finishedWork) {
switch (finishedWork.tag) {
case 0:
case 11:
case 15:
case 22:
- commitHookEffectListMount(3, finishedWork);
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ if (3 === (finishedRoot.tag & 3)) {
+ var create$82 = finishedRoot.create;
+ finishedRoot.destroy = create$82();
+ }
+ finishedRoot = finishedRoot.next;
+ } while (finishedRoot !== current);
+ }
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ var _effect = finishedRoot;
+ create$82 = _effect.next;
+ _effect = _effect.tag;
+ 0 !== (_effect & 4) &&
+ 0 !== (_effect & 1) &&
+ (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot),
+ enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot));
+ finishedRoot = create$82;
+ } while (finishedRoot !== current);
+ }
return;
case 1:
finishedRoot = finishedWork.stateNode;
- if (finishedWork.effectTag & 4)
- if (null === current) finishedRoot.componentDidMount();
- else {
- var prevProps =
- finishedWork.elementType === finishedWork.type
- ? current.memoizedProps
- : resolveDefaultProps(finishedWork.type, current.memoizedProps);
- finishedRoot.componentDidUpdate(
- prevProps,
- current.memoizedState,
- finishedRoot.__reactInternalSnapshotBeforeUpdate
- );
- }
+ finishedWork.effectTag & 4 &&
+ (null === current
+ ? finishedRoot.componentDidMount()
+ : ((create$82 =
+ finishedWork.elementType === finishedWork.type
+ ? current.memoizedProps
+ : resolveDefaultProps(
+ finishedWork.type,
+ current.memoizedProps
+ )),
+ finishedRoot.componentDidUpdate(
+ create$82,
+ current.memoizedState,
+ finishedRoot.__reactInternalSnapshotBeforeUpdate
+ )));
current = finishedWork.updateQueue;
null !== current &&
commitUpdateQueue(finishedWork, current, finishedRoot);
@@ -5196,26 +5613,23 @@ function commitLifeCycles(finishedRoot, current, finishedWork) {
}
return;
case 5:
- if (null === current && finishedWork.effectTag & 4)
- throw Error(
- "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue."
- );
+ null === current && finishedWork.effectTag & 4 && shim();
return;
case 6:
return;
case 4:
return;
case 12:
- prevProps = finishedWork.memoizedProps.onRender;
- var commitTime$jscomp$0 = commitTime;
- "function" === typeof prevProps &&
- prevProps(
+ create$82 = finishedWork.memoizedProps.onRender;
+ _effect = commitTime;
+ "function" === typeof create$82 &&
+ create$82(
finishedWork.memoizedProps.id,
null === current ? "mount" : "update",
finishedWork.actualDuration,
finishedWork.treeBaseDuration,
finishedWork.actualStartTime,
- commitTime$jscomp$0,
+ _effect,
finishedRoot.memoizedInteractions
);
return;
@@ -5225,74 +5639,26 @@ function commitLifeCycles(finishedRoot, current, finishedWork) {
case 17:
case 20:
case 21:
+ case 23:
+ case 24:
return;
}
throw Error(
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) {
- "function" === typeof onCommitFiberUnmount &&
- onCommitFiberUnmount(current$jscomp$0);
- switch (current$jscomp$0.tag) {
- case 0:
- case 11:
- case 14:
- case 15:
- case 22:
- finishedRoot = current$jscomp$0.updateQueue;
- if (
- null !== finishedRoot &&
- ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot)
- ) {
- var firstEffect = finishedRoot.next;
- runWithPriority(
- 97 < renderPriorityLevel ? 97 : renderPriorityLevel,
- function() {
- var effect = firstEffect;
- do {
- var _destroy = effect.destroy;
- if (void 0 !== _destroy) {
- var current = current$jscomp$0;
- try {
- _destroy();
- } catch (error) {
- captureCommitPhaseError(current, error);
- }
- }
- effect = effect.next;
- } while (effect !== firstEffect);
- }
- );
- }
- break;
- case 1:
- safelyDetachRef(current$jscomp$0);
- renderPriorityLevel = current$jscomp$0.stateNode;
- "function" === typeof renderPriorityLevel.componentWillUnmount &&
- safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel);
- break;
- case 5:
- safelyDetachRef(current$jscomp$0);
- break;
- case 4:
- createChildNodeSet(current$jscomp$0.stateNode.containerInfo);
- }
-}
-function detachFiber(current) {
- var alternate = current.alternate;
- current.return = null;
- current.child = null;
- current.memoizedState = null;
- current.updateQueue = null;
- current.dependencies = null;
- current.alternate = null;
- current.firstEffect = null;
- current.lastEffect = null;
- current.pendingProps = null;
- current.memoizedProps = null;
- current.stateNode = null;
- null !== alternate && detachFiber(alternate);
+function detachFiberMutation(fiber) {
+ fiber.alternate = null;
+ fiber.child = null;
+ fiber.dependencies = null;
+ fiber.firstEffect = null;
+ fiber.lastEffect = null;
+ fiber.memoizedProps = null;
+ fiber.memoizedState = null;
+ fiber.pendingProps = null;
+ fiber.return = null;
+ fiber.stateNode = null;
+ fiber.updateQueue = null;
}
function commitWork(current, finishedWork) {
switch (finishedWork.tag) {
@@ -5301,7 +5667,19 @@ function commitWork(current, finishedWork) {
case 14:
case 15:
case 22:
- commitHookEffectListUnmount(3, finishedWork);
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedWork = current = current.next;
+ do {
+ if (3 === (finishedWork.tag & 3)) {
+ var destroy = finishedWork.destroy;
+ finishedWork.destroy = void 0;
+ void 0 !== destroy && destroy();
+ }
+ finishedWork = finishedWork.next;
+ } while (finishedWork !== current);
+ }
return;
case 12:
return;
@@ -5313,6 +5691,9 @@ function commitWork(current, finishedWork) {
case 19:
attachSuspenseRetryListeners(finishedWork);
return;
+ case 23:
+ case 24:
+ return;
}
a: {
switch (finishedWork.tag) {
@@ -5331,87 +5712,49 @@ function commitWork(current, finishedWork) {
}
}
function attachSuspenseRetryListeners(finishedWork) {
- var thenables = finishedWork.updateQueue;
- if (null !== thenables) {
+ var wakeables = finishedWork.updateQueue;
+ if (null !== wakeables) {
finishedWork.updateQueue = null;
var retryCache = finishedWork.stateNode;
null === retryCache &&
(retryCache = finishedWork.stateNode = new PossiblyWeakSet());
- thenables.forEach(function(thenable) {
- var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
- retryCache.has(thenable) ||
- (!0 !== thenable.__reactDoNotTraceInteractions &&
+ wakeables.forEach(function(wakeable) {
+ var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
+ retryCache.has(wakeable) ||
+ (!0 !== wakeable.__reactDoNotTraceInteractions &&
(retry = tracing.unstable_wrap(retry)),
- retryCache.add(thenable),
- thenable.then(retry, retry));
+ retryCache.add(wakeable),
+ wakeable.then(retry, retry));
});
}
}
-var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
-function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- expirationTime.payload = { element: null };
- var error = errorInfo.value;
- expirationTime.callback = function() {
- hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
- logError(fiber, errorInfo);
- };
- return expirationTime;
-}
-function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
- if ("function" === typeof getDerivedStateFromError) {
- var error = errorInfo.value;
- expirationTime.payload = function() {
- logError(fiber, errorInfo);
- return getDerivedStateFromError(error);
- };
- }
- var inst = fiber.stateNode;
- null !== inst &&
- "function" === typeof inst.componentDidCatch &&
- (expirationTime.callback = function() {
- "function" !== typeof getDerivedStateFromError &&
- (null === legacyErrorBoundariesThatAlreadyFailed
- ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logError(fiber, errorInfo));
- var stack = errorInfo.stack;
- this.componentDidCatch(errorInfo.value, {
- componentStack: null !== stack ? stack : ""
- });
- });
- return expirationTime;
+function isSuspenseBoundaryBeingHidden(current, finishedWork) {
+ return null !== current &&
+ ((current = current.memoizedState),
+ null === current || null !== current.dehydrated)
+ ? ((finishedWork = finishedWork.memoizedState),
+ null !== finishedWork && null === finishedWork.dehydrated)
+ : !1;
}
var ceil = Math.ceil,
- ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
+ ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
- NoContext = 0,
- LegacyUnbatchedContext = 8,
- RenderContext = 16,
- CommitContext = 32,
- RootIncomplete = 0,
- RootFatalErrored = 1,
- RootErrored = 2,
- RootSuspended = 3,
- RootSuspendedWithDelay = 4,
- RootCompleted = 5,
- executionContext = NoContext,
+ executionContext = 0,
workInProgressRoot = null,
workInProgress = null,
- renderExpirationTime$1 = 0,
- workInProgressRootExitStatus = RootIncomplete,
+ workInProgressRootRenderLanes = 0,
+ subtreeRenderLanes = 0,
+ subtreeRenderLanesCursor = createCursor(0),
+ workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
- workInProgressRootLatestProcessedExpirationTime = 1073741823,
- workInProgressRootLatestSuspenseTimeout = 1073741823,
+ workInProgressRootLatestSuspenseTimeout = -1,
workInProgressRootCanSuspendUsingConfig = null,
- workInProgressRootNextUnprocessedUpdateTime = 0,
- workInProgressRootHasPendingPing = !1,
+ workInProgressRootIncludedLanes = 0,
+ workInProgressRootSkippedLanes = 0,
+ workInProgressRootUpdatedLanes = 0,
+ workInProgressRootPingedLanes = 0,
+ mostRecentlyUpdatedRoot = null,
globalMostRecentFallbackTime = 0,
- FALLBACK_THROTTLE_MS = 500,
nextEffect = null,
hasUncaughtError = !1,
firstUncaughtError = null,
@@ -5419,201 +5762,208 @@ var ceil = Math.ceil,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsRenderPriority = 90,
- pendingPassiveEffectsExpirationTime = 0,
+ pendingPassiveEffectsLanes = 0,
+ pendingPassiveHookEffectsMount = [],
+ pendingPassiveHookEffectsUnmount = [],
rootsWithPendingDiscreteUpdates = null,
nestedUpdateCount = 0,
rootWithNestedUpdates = null,
spawnedWorkDuringRender = null,
- currentEventTime = 0;
-function requestCurrentTimeForUpdate() {
- return (executionContext & (RenderContext | CommitContext)) !== NoContext
- ? 1073741821 - ((now() / 10) | 0)
- : 0 !== currentEventTime
+ currentEventTime = -1,
+ currentEventWipLanes = 0,
+ currentEventPendingLanes = 0,
+ focusedInstanceHandle = null,
+ shouldFireAfterActiveInstanceBlur = !1;
+function requestEventTime() {
+ return 0 !== (executionContext & 48)
+ ? now()
+ : -1 !== currentEventTime
? currentEventTime
- : (currentEventTime = 1073741821 - ((now() / 10) | 0));
+ : (currentEventTime = now());
}
-function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
+function requestUpdateLane(fiber, suspenseConfig) {
fiber = fiber.mode;
- if (0 === (fiber & 2)) return 1073741823;
- var priorityLevel = getCurrentPriorityLevel();
- if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822;
- if ((executionContext & RenderContext) !== NoContext)
- return renderExpirationTime$1;
- if (null !== suspenseConfig)
- currentTime =
- 1073741821 -
- 25 *
- ((((1073741821 -
- currentTime +
- (suspenseConfig.timeoutMs | 0 || 5e3) / 10) /
- 25) |
- 0) +
- 1);
- else
- switch (priorityLevel) {
- case 99:
- currentTime = 1073741823;
- break;
- case 98:
- currentTime =
- 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1);
- break;
- case 97:
- case 96:
- currentTime =
- 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1);
- break;
- case 95:
- currentTime = 2;
- break;
- default:
- throw Error("Expected a valid priority level");
- }
- null !== workInProgressRoot &&
- currentTime === renderExpirationTime$1 &&
- --currentTime;
- return currentTime;
-}
-function scheduleWork(fiber, expirationTime) {
+ if (0 === (fiber & 2)) return 1;
+ if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2;
+ 0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes);
+ if (null !== suspenseConfig) {
+ suspenseConfig = suspenseConfig.timeoutMs;
+ fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6;
+ 0 !== currentEventPendingLanes &&
+ (currentEventPendingLanes =
+ null !== mostRecentlyUpdatedRoot
+ ? mostRecentlyUpdatedRoot.pendingLanes
+ : 0);
+ suspenseConfig = currentEventWipLanes;
+ var pendingLanes = currentEventPendingLanes;
+ if (8 === fiber)
+ (fiber = pickArbitraryLane(122880 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 8192)),
+ (suspenseConfig = fiber);
+ else if (6 === fiber)
+ (fiber = pickArbitraryLane(3932160 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 262144)),
+ (suspenseConfig = fiber);
+ else
+ throw Error(
+ "Invalid transition priority: " + fiber + ". This is a bug in React."
+ );
+ return suspenseConfig;
+ }
+ suspenseConfig = getCurrentPriorityLevel();
+ 0 !== (executionContext & 4) && 98 === suspenseConfig
+ ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes))
+ : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)),
+ (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes)));
+ return suspenseConfig;
+}
+function scheduleUpdateOnFiber(fiber, lane, eventTime) {
if (50 < nestedUpdateCount)
throw ((nestedUpdateCount = 0),
(rootWithNestedUpdates = null),
Error(
"Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
));
- fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
- if (null !== fiber) {
- var priorityLevel = getCurrentPriorityLevel();
- 1073741823 === expirationTime
- ? (executionContext & LegacyUnbatchedContext) !== NoContext &&
- (executionContext & (RenderContext | CommitContext)) === NoContext
- ? (schedulePendingInteractions(fiber, expirationTime),
- performSyncWorkOnRoot(fiber))
- : (ensureRootIsScheduled(fiber),
- schedulePendingInteractions(fiber, expirationTime),
- executionContext === NoContext && flushSyncCallbackQueue())
- : (ensureRootIsScheduled(fiber),
- schedulePendingInteractions(fiber, expirationTime));
- (executionContext & 4) === NoContext ||
- (98 !== priorityLevel && 99 !== priorityLevel) ||
- (null === rootsWithPendingDiscreteUpdates
- ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]))
- : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)),
- (void 0 === priorityLevel || priorityLevel > expirationTime) &&
- rootsWithPendingDiscreteUpdates.set(fiber, expirationTime)));
- }
-}
-function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
- fiber.expirationTime < expirationTime &&
- (fiber.expirationTime = expirationTime);
- var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < expirationTime &&
- (alternate.expirationTime = expirationTime);
- var node = fiber.return,
- root = null;
- if (null === node && 3 === fiber.tag) root = fiber.stateNode;
- else
- for (; null !== node; ) {
- alternate = node.alternate;
- node.childExpirationTime < expirationTime &&
- (node.childExpirationTime = expirationTime);
- null !== alternate &&
- alternate.childExpirationTime < expirationTime &&
- (alternate.childExpirationTime = expirationTime);
- if (null === node.return && 3 === node.tag) {
- root = node.stateNode;
- break;
+ fiber = markUpdateLaneFromFiberToRoot(fiber, lane);
+ if (null === fiber) return null;
+ markRootUpdated(fiber, lane, eventTime);
+ fiber === workInProgressRoot &&
+ ((workInProgressRootUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(fiber, workInProgressRootRenderLanes));
+ var priorityLevel = getCurrentPriorityLevel();
+ 1 === lane
+ ? 0 !== (executionContext & 8) && 0 === (executionContext & 48)
+ ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber))
+ : (ensureRootIsScheduled(fiber, eventTime),
+ schedulePendingInteractions(fiber, lane),
+ 0 === executionContext && flushSyncCallbackQueue())
+ : (0 === (executionContext & 4) ||
+ (98 !== priorityLevel && 99 !== priorityLevel) ||
+ (null === rootsWithPendingDiscreteUpdates
+ ? (rootsWithPendingDiscreteUpdates = new Set([fiber]))
+ : rootsWithPendingDiscreteUpdates.add(fiber)),
+ ensureRootIsScheduled(fiber, eventTime),
+ schedulePendingInteractions(fiber, lane));
+ mostRecentlyUpdatedRoot = fiber;
+}
+function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
+ sourceFiber.lanes |= lane;
+ var alternate = sourceFiber.alternate;
+ null !== alternate && (alternate.lanes |= lane);
+ alternate = sourceFiber;
+ for (sourceFiber = sourceFiber.return; null !== sourceFiber; )
+ (sourceFiber.childLanes |= lane),
+ (alternate = sourceFiber.alternate),
+ null !== alternate && (alternate.childLanes |= lane),
+ (alternate = sourceFiber),
+ (sourceFiber = sourceFiber.return);
+ return 3 === alternate.tag ? alternate.stateNode : null;
+}
+function ensureRootIsScheduled(root, currentTime) {
+ for (
+ var existingCallbackNode = root.callbackNode,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes,
+ expirationTimes = root.expirationTimes,
+ lanes = root.pendingLanes;
+ 0 < lanes;
+
+ ) {
+ var index$5 = 31 - clz32(lanes),
+ lane = 1 << index$5,
+ expirationTime = expirationTimes[index$5];
+ if (-1 === expirationTime) {
+ if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) {
+ expirationTime = currentTime;
+ getHighestPriorityLanes(lane);
+ var priority = return_highestLanePriority;
+ expirationTimes[index$5] =
+ 12 <= priority
+ ? expirationTime + 1e3
+ : 6 <= priority
+ ? expirationTime + 5e3
+ : -1;
}
- node = node.return;
- }
- null !== root &&
- (workInProgressRoot === root &&
- (markUnprocessedUpdateTime(expirationTime),
- workInProgressRootExitStatus === RootSuspendedWithDelay &&
- markRootSuspendedAtTime(root, renderExpirationTime$1)),
- markRootUpdatedAtTime(root, expirationTime));
- return root;
-}
-function getNextRootExpirationTimeToWorkOn(root) {
- var lastExpiredTime = root.lastExpiredTime;
- if (0 !== lastExpiredTime) return lastExpiredTime;
- lastExpiredTime = root.firstPendingTime;
- if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime;
- var lastPingedTime = root.lastPingedTime;
- root = root.nextKnownPendingLevel;
- root = lastPingedTime > root ? lastPingedTime : root;
- return 2 >= root && lastExpiredTime !== root ? 0 : root;
-}
-function ensureRootIsScheduled(root) {
- if (0 !== root.lastExpiredTime)
- (root.callbackExpirationTime = 1073741823),
- (root.callbackPriority = 99),
- (root.callbackNode = scheduleSyncCallback(
- performSyncWorkOnRoot.bind(null, root)
- ));
+ } else expirationTime <= currentTime && (root.expiredLanes |= lane);
+ lanes &= ~lane;
+ }
+ suspendedLanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ currentTime = return_highestLanePriority;
+ if (0 === suspendedLanes)
+ null !== existingCallbackNode &&
+ (existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode),
+ (root.callbackNode = null),
+ (root.callbackPriority = 0));
else {
- var expirationTime = getNextRootExpirationTimeToWorkOn(root),
- existingCallbackNode = root.callbackNode;
- if (0 === expirationTime)
- null !== existingCallbackNode &&
- ((root.callbackNode = null),
- (root.callbackExpirationTime = 0),
- (root.callbackPriority = 90));
- else {
- var currentTime = requestCurrentTimeForUpdate();
- currentTime = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- );
- if (null !== existingCallbackNode) {
- var existingCallbackPriority = root.callbackPriority;
- if (
- root.callbackExpirationTime === expirationTime &&
- existingCallbackPriority >= currentTime
- )
- return;
- existingCallbackNode !== fakeCallbackNode &&
- Scheduler_cancelCallback(existingCallbackNode);
- }
- root.callbackExpirationTime = expirationTime;
- root.callbackPriority = currentTime;
- expirationTime =
- 1073741823 === expirationTime
- ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root))
- : scheduleCallback(
- currentTime,
- performConcurrentWorkOnRoot.bind(null, root),
- { timeout: 10 * (1073741821 - expirationTime) - now() }
- );
- root.callbackNode = expirationTime;
+ if (null !== existingCallbackNode) {
+ if (root.callbackPriority === currentTime) return;
+ existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode);
}
+ 17 === currentTime
+ ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)),
+ null === syncQueue
+ ? ((syncQueue = [existingCallbackNode]),
+ (immediateQueueCallbackNode = Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueueImpl
+ )))
+ : syncQueue.push(existingCallbackNode),
+ (existingCallbackNode = fakeCallbackNode))
+ : 16 === currentTime
+ ? (existingCallbackNode = scheduleCallback(
+ 99,
+ performSyncWorkOnRoot.bind(null, root)
+ ))
+ : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)),
+ (existingCallbackNode = scheduleCallback(
+ existingCallbackNode,
+ performConcurrentWorkOnRoot.bind(null, root)
+ )));
+ root.callbackPriority = currentTime;
+ root.callbackNode = existingCallbackNode;
}
}
function performConcurrentWorkOnRoot(root, didTimeout) {
- currentEventTime = 0;
- if (didTimeout) {
- didTimeout = requestCurrentTimeForUpdate();
- var lastExpiredTime = root.lastExpiredTime;
- if (0 === lastExpiredTime || lastExpiredTime > didTimeout)
- root.lastExpiredTime = didTimeout;
- ensureRootIsScheduled(root);
- return null;
- }
- lastExpiredTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 === lastExpiredTime) return null;
- didTimeout = root.callbackNode;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ currentEventTime = -1;
+ currentEventPendingLanes = currentEventWipLanes = 0;
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- flushPassiveEffects();
- var expirationTime = lastExpiredTime,
- prevExecutionContext = executionContext;
- executionContext |= RenderContext;
- var exitStatus = pushDispatcher();
- if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1)
- prepareFreshStack(root, expirationTime),
- startWorkOnPendingInteractions(root, expirationTime);
- expirationTime = pushInteractions(root);
+ var originalCallbackNode = root.callbackNode;
+ if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
+ return null;
+ var lanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ if (0 === lanes) return null;
+ if (didTimeout)
+ return (
+ (root.expiredLanes |= lanes & root.pendingLanes),
+ ensureRootIsScheduled(root, now()),
+ null
+ );
+ var lanes$jscomp$0 = lanes;
+ didTimeout = executionContext;
+ executionContext |= 16;
+ var prevDispatcher = pushDispatcher();
+ if (
+ workInProgressRoot !== root ||
+ workInProgressRootRenderLanes !== lanes$jscomp$0
+ )
+ prepareFreshStack(root, lanes$jscomp$0),
+ startWorkOnPendingInteractions(root, lanes$jscomp$0);
+ lanes$jscomp$0 = pushInteractions(root);
do
try {
workLoopConcurrent();
@@ -5623,162 +5973,121 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
}
while (1);
resetContextDependencies();
- tracing.__interactionsRef.current = expirationTime;
- ReactCurrentDispatcher$1.current = exitStatus;
- executionContext = prevExecutionContext;
+ tracing.__interactionsRef.current = lanes$jscomp$0;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
+ executionContext = didTimeout;
null !== workInProgress
- ? (exitStatus = RootIncomplete)
+ ? (didTimeout = 0)
: ((workInProgressRoot = null),
- (exitStatus = workInProgressRootExitStatus));
- if (exitStatus !== RootIncomplete) {
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
- throw ((didTimeout = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
- didTimeout);
- prevExecutionContext = root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
- switch (exitStatus) {
- case RootIncomplete:
- case RootFatalErrored:
+ (workInProgressRootRenderLanes = 0),
+ (didTimeout = workInProgressRootExitStatus));
+ if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes))
+ prepareFreshStack(root, 0);
+ else if (0 !== didTimeout) {
+ 2 === didTimeout &&
+ ((executionContext |= 64),
+ root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (didTimeout = renderRootSync(root, lanes)));
+ if (1 === didTimeout)
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = root.current.alternate;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
throw Error("Root did not complete. This is a bug in React.");
- case RootErrored:
+ case 2:
commitRoot(root);
break;
- case RootSuspended:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- prevExecutionContext
- ));
+ case 3:
+ markRootSuspended$1(root, lanes);
if (
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- ((prevExecutionContext =
- globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()),
- 10 < prevExecutionContext)
+ (lanes & 62914560) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
) {
- if (
- workInProgressRootHasPendingPing &&
- ((expirationTime = root.lastPingedTime),
- 0 === expirationTime || expirationTime >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- expirationTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 !== expirationTime && expirationTime !== lastExpiredTime) break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ if (0 !== getNextLanes(root, 0)) break;
+ prevDispatcher = root.suspendedLanes;
+ if ((prevDispatcher & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & prevDispatcher;
break;
}
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- prevExecutionContext
+ didTimeout
);
break;
}
commitRoot(root);
break;
- case RootSuspendedWithDelay:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- prevExecutionContext
- ));
- if (
- workInProgressRootHasPendingPing &&
- ((prevExecutionContext = root.lastPingedTime),
- 0 === prevExecutionContext || prevExecutionContext >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- prevExecutionContext = getNextRootExpirationTimeToWorkOn(root);
- if (
- 0 !== prevExecutionContext &&
- prevExecutionContext !== lastExpiredTime
- )
- break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if (0 !== getNextLanes(root, 0)) break;
+ didTimeout = root.suspendedLanes;
+ if ((didTimeout & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & didTimeout;
break;
}
- 1073741823 !== workInProgressRootLatestSuspenseTimeout
- ? (prevExecutionContext =
- 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) -
- now())
- : 1073741823 === workInProgressRootLatestProcessedExpirationTime
- ? (prevExecutionContext = 0)
- : ((prevExecutionContext =
- 10 *
- (1073741821 - workInProgressRootLatestProcessedExpirationTime) -
- 5e3),
- (exitStatus = now()),
- (lastExpiredTime =
- 10 * (1073741821 - lastExpiredTime) - exitStatus),
- (prevExecutionContext = exitStatus - prevExecutionContext),
- 0 > prevExecutionContext && (prevExecutionContext = 0),
- (prevExecutionContext =
- (120 > prevExecutionContext
+ lanes = getMostRecentEventTime(root, lanes);
+ -1 !== workInProgressRootLatestSuspenseTimeout
+ ? (lanes = workInProgressRootLatestSuspenseTimeout - now())
+ : -1 === lanes
+ ? (lanes = 0)
+ : ((lanes = now() - lanes),
+ (lanes =
+ (120 > lanes
? 120
- : 480 > prevExecutionContext
+ : 480 > lanes
? 480
- : 1080 > prevExecutionContext
+ : 1080 > lanes
? 1080
- : 1920 > prevExecutionContext
+ : 1920 > lanes
? 1920
- : 3e3 > prevExecutionContext
+ : 3e3 > lanes
? 3e3
- : 4320 > prevExecutionContext
+ : 4320 > lanes
? 4320
- : 1960 * ceil(prevExecutionContext / 1960)) -
- prevExecutionContext),
- lastExpiredTime < prevExecutionContext &&
- (prevExecutionContext = lastExpiredTime));
- if (10 < prevExecutionContext) {
+ : 1960 * ceil(lanes / 1960)) - lanes));
+ if (10 < lanes) {
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- prevExecutionContext
+ lanes
);
break;
}
commitRoot(root);
break;
- case RootCompleted:
+ case 5:
+ lanes$jscomp$0 = getMostRecentEventTime(root, lanes);
if (
- 1073741823 !== workInProgressRootLatestProcessedExpirationTime &&
- null !== workInProgressRootCanSuspendUsingConfig
- ) {
- expirationTime = workInProgressRootLatestProcessedExpirationTime;
- var suspenseConfig = workInProgressRootCanSuspendUsingConfig;
- prevExecutionContext = suspenseConfig.busyMinDurationMs | 0;
- 0 >= prevExecutionContext
- ? (prevExecutionContext = 0)
- : ((exitStatus = suspenseConfig.busyDelayMs | 0),
- (expirationTime =
- now() -
- (10 * (1073741821 - expirationTime) -
- (suspenseConfig.timeoutMs | 0 || 5e3))),
- (prevExecutionContext =
- expirationTime <= exitStatus
+ -1 !== lanes$jscomp$0 &&
+ null !== workInProgressRootCanSuspendUsingConfig &&
+ ((didTimeout =
+ workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0),
+ 0 >= didTimeout
+ ? (didTimeout = 0)
+ : ((prevDispatcher =
+ workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0),
+ (lanes$jscomp$0 = now() - lanes$jscomp$0),
+ (didTimeout =
+ lanes$jscomp$0 <= prevDispatcher
? 0
- : exitStatus + prevExecutionContext - expirationTime));
- if (10 < prevExecutionContext) {
- markRootSuspendedAtTime(root, lastExpiredTime);
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- prevExecutionContext
- );
- break;
- }
+ : prevDispatcher + didTimeout - lanes$jscomp$0)),
+ 10 < didTimeout)
+ ) {
+ markRootSuspended$1(root, lanes);
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ didTimeout
+ );
+ break;
}
commitRoot(root);
break;
@@ -5786,42 +6095,68 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
throw Error("Unknown root exit status.");
}
}
- ensureRootIsScheduled(root);
- return root.callbackNode === didTimeout
+ ensureRootIsScheduled(root, now());
+ return root.callbackNode === originalCallbackNode
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function markRootSuspended$1(root, suspendedLanes) {
+ suspendedLanes &= ~workInProgressRootPingedLanes;
+ suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ root.suspendedLanes |= suspendedLanes;
+ root.pingedLanes &= ~suspendedLanes;
+ for (root = root.expirationTimes; 0 < suspendedLanes; ) {
+ var index$10 = 31 - clz32(suspendedLanes),
+ lane = 1 << index$10;
+ root[index$10] = -1;
+ suspendedLanes &= ~lane;
+ }
+}
function performSyncWorkOnRoot(root) {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
flushPassiveEffects();
- var lastExpiredTime = root.lastExpiredTime;
- lastExpiredTime =
- 0 !== lastExpiredTime
- ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime
- ? renderExpirationTime$1
- : lastExpiredTime
- : 1073741823;
- var exitStatus = renderRootSync(root, lastExpiredTime);
+ if (
+ root === workInProgressRoot &&
+ 0 !== (root.expiredLanes & workInProgressRootRenderLanes)
+ ) {
+ var lanes = workInProgressRootRenderLanes;
+ var exitStatus = renderRootSync(root, lanes);
+ 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) &&
+ ((lanes = getNextLanes(root, lanes)),
+ (exitStatus = renderRootSync(root, lanes)));
+ } else
+ (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes));
0 !== root.tag &&
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
+ 2 === exitStatus &&
+ ((executionContext |= 64),
+ root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (exitStatus = renderRootSync(root, lanes)));
+ if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
exitStatus);
root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
+ root.finishedLanes = lanes;
commitRoot(root);
- ensureRootIsScheduled(root);
+ ensureRootIsScheduled(root, now());
return null;
}
-function prepareFreshStack(root, expirationTime) {
+function pushRenderLanes(fiber, lanes) {
+ push(subtreeRenderLanesCursor, subtreeRenderLanes);
+ subtreeRenderLanes |= lanes;
+ workInProgressRootIncludedLanes |= lanes;
+}
+function popRenderLanes() {
+ subtreeRenderLanes = subtreeRenderLanesCursor.current;
+ pop(subtreeRenderLanesCursor);
+}
+function prepareFreshStack(root, lanes) {
root.finishedWork = null;
- root.finishedExpirationTime = 0;
+ root.finishedLanes = 0;
var timeoutHandle = root.timeoutHandle;
-1 !== timeoutHandle &&
((root.timeoutHandle = -1), cancelTimeout(timeoutHandle));
@@ -5839,6 +6174,7 @@ function prepareFreshStack(root, expirationTime) {
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
break;
case 5:
popHostContext(interruptedWork);
@@ -5854,26 +6190,30 @@ function prepareFreshStack(root, expirationTime) {
break;
case 10:
popProvider(interruptedWork);
+ break;
+ case 23:
+ case 24:
+ popRenderLanes();
}
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
workInProgress = createWorkInProgress(root.current, null);
- renderExpirationTime$1 = expirationTime;
- workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
+ workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823;
+ workInProgressRootLatestSuspenseTimeout = -1;
workInProgressRootCanSuspendUsingConfig = null;
- workInProgressRootNextUnprocessedUpdateTime = 0;
- workInProgressRootHasPendingPing = !1;
+ workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
spawnedWorkDuringRender = null;
}
function handleError(root$jscomp$0, thrownValue) {
do {
+ var erroredWork = workInProgress;
try {
resetContextDependencies();
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
- if (didScheduleRenderPhaseUpdate)
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ if (didScheduleRenderPhaseUpdate) {
for (
var hook = currentlyRenderingFiber$1.memoizedState;
null !== hook;
@@ -5883,23 +6223,26 @@ function handleError(root$jscomp$0, thrownValue) {
null !== queue && (queue.pending = null);
hook = hook.next;
}
- renderExpirationTime = 0;
+ didScheduleRenderPhaseUpdate = !1;
+ }
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
- didScheduleRenderPhaseUpdate = !1;
- if (null === workInProgress || null === workInProgress.return)
- return (
- (workInProgressRootExitStatus = RootFatalErrored),
- (workInProgressRootFatalError = thrownValue),
- (workInProgress = null)
- );
- workInProgress.mode & 8 &&
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0);
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ ReactCurrentOwner$2.current = null;
+ if (null === erroredWork || null === erroredWork.return) {
+ workInProgressRootExitStatus = 1;
+ workInProgressRootFatalError = thrownValue;
+ workInProgress = null;
+ break;
+ }
+ erroredWork.mode & 8 &&
+ stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0);
a: {
var root = root$jscomp$0,
- returnFiber = workInProgress.return,
- sourceFiber = workInProgress,
+ returnFiber = erroredWork.return,
+ sourceFiber = erroredWork,
value = thrownValue;
- thrownValue = renderExpirationTime$1;
+ thrownValue = workInProgressRootRenderLanes;
sourceFiber.effectTag |= 2048;
sourceFiber.firstEffect = sourceFiber.lastEffect = null;
if (
@@ -5907,27 +6250,27 @@ function handleError(root$jscomp$0, thrownValue) {
"object" === typeof value &&
"function" === typeof value.then
) {
- var thenable = value;
+ var wakeable = value;
if (0 === (sourceFiber.mode & 2)) {
var currentSource = sourceFiber.alternate;
currentSource
? ((sourceFiber.updateQueue = currentSource.updateQueue),
(sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.expirationTime = currentSource.expirationTime))
+ (sourceFiber.lanes = currentSource.lanes))
: ((sourceFiber.updateQueue = null),
(sourceFiber.memoizedState = null));
}
var hasInvisibleParentBoundary =
0 !== (suspenseStackCursor.current & 1),
- _workInProgress = returnFiber;
+ workInProgress$77 = returnFiber;
do {
var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === _workInProgress.tag)) {
- var nextState = _workInProgress.memoizedState;
+ if ((JSCompiler_temp = 13 === workInProgress$77.tag)) {
+ var nextState = workInProgress$77.memoizedState;
if (null !== nextState)
JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
else {
- var props = _workInProgress.memoizedProps;
+ var props = workInProgress$77.memoizedProps;
JSCompiler_temp =
void 0 === props.fallback
? !1
@@ -5939,23 +6282,24 @@ function handleError(root$jscomp$0, thrownValue) {
}
}
if (JSCompiler_temp) {
- var thenables = _workInProgress.updateQueue;
- if (null === thenables) {
+ var wakeables = workInProgress$77.updateQueue;
+ if (null === wakeables) {
var updateQueue = new Set();
- updateQueue.add(thenable);
- _workInProgress.updateQueue = updateQueue;
- } else thenables.add(thenable);
- if (0 === (_workInProgress.mode & 2)) {
- _workInProgress.effectTag |= 64;
+ updateQueue.add(wakeable);
+ workInProgress$77.updateQueue = updateQueue;
+ } else wakeables.add(wakeable);
+ if (0 === (workInProgress$77.mode & 2)) {
+ workInProgress$77.effectTag |= 64;
+ sourceFiber.effectTag |= 16384;
sourceFiber.effectTag &= -2981;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
- var update = createUpdate(1073741823, null);
+ var update = createUpdate(-1, 1, null);
update.tag = 2;
enqueueUpdate(sourceFiber, update);
}
- sourceFiber.expirationTime = 1073741823;
+ sourceFiber.lanes |= 1;
break a;
}
value = void 0;
@@ -5964,86 +6308,90 @@ function handleError(root$jscomp$0, thrownValue) {
null === pingCache
? ((pingCache = root.pingCache = new PossiblyWeakMap()),
(value = new Set()),
- pingCache.set(thenable, value))
- : ((value = pingCache.get(thenable)),
+ pingCache.set(wakeable, value))
+ : ((value = pingCache.get(wakeable)),
void 0 === value &&
- ((value = new Set()), pingCache.set(thenable, value)));
+ ((value = new Set()), pingCache.set(wakeable, value)));
if (!value.has(sourceFiber)) {
value.add(sourceFiber);
var ping = pingSuspendedRoot.bind(
null,
root,
- thenable,
+ wakeable,
sourceFiber
);
- thenable.then(ping, ping);
+ wakeable.then(ping, ping);
}
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
+ workInProgress$77.effectTag |= 4096;
+ workInProgress$77.lanes = thrownValue;
break a;
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$77 = workInProgress$77.return;
+ } while (null !== workInProgress$77);
value = Error(
(getComponentName(sourceFiber.type) || "A React component") +
- " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." +
- getStackByFiberInDevAndProd(sourceFiber)
+ " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display."
);
}
- workInProgressRootExitStatus !== RootCompleted &&
- (workInProgressRootExitStatus = RootErrored);
+ 5 !== workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 2);
value = createCapturedValue(value, sourceFiber);
- _workInProgress = returnFiber;
+ workInProgress$77 = returnFiber;
do {
- switch (_workInProgress.tag) {
+ switch (workInProgress$77.tag) {
case 3:
- thenable = value;
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update = createRootErrorUpdate(
- _workInProgress,
- thenable,
+ root = value;
+ workInProgress$77.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$77.lanes |= thrownValue;
+ var update$78 = createRootErrorUpdate(
+ workInProgress$77,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update);
+ enqueueCapturedUpdate(workInProgress$77, update$78);
break a;
case 1:
- thenable = value;
- var ctor = _workInProgress.type,
- instance = _workInProgress.stateNode;
+ root = value;
+ var ctor = workInProgress$77.type,
+ instance = workInProgress$77.stateNode;
if (
- 0 === (_workInProgress.effectTag & 64) &&
+ 0 === (workInProgress$77.effectTag & 64) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update2 = createClassErrorUpdate(
- _workInProgress,
- thenable,
+ workInProgress$77.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$77.lanes |= thrownValue;
+ var update$81 = createClassErrorUpdate(
+ workInProgress$77,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update2);
+ enqueueCapturedUpdate(workInProgress$77, update$81);
break a;
}
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$77 = workInProgress$77.return;
+ } while (null !== workInProgress$77);
}
- workInProgress = completeUnitOfWork(workInProgress);
+ completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
thrownValue = yetAnotherThrownValue;
+ workInProgress === erroredWork &&
+ null !== erroredWork &&
+ (workInProgress = erroredWork = erroredWork.return);
continue;
}
break;
} while (1);
}
function pushDispatcher() {
- var prevDispatcher = ReactCurrentDispatcher$1.current;
- ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ var prevDispatcher = ReactCurrentDispatcher$2.current;
+ ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
function pushInteractions(root) {
@@ -6051,28 +6399,20 @@ function pushInteractions(root) {
tracing.__interactionsRef.current = root.memoizedInteractions;
return prevInteractions;
}
-function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
- expirationTime < workInProgressRootLatestProcessedExpirationTime &&
- 2 < expirationTime &&
- (workInProgressRootLatestProcessedExpirationTime = expirationTime);
+function markRenderEventTimeAndConfig(eventTime, suspenseConfig) {
null !== suspenseConfig &&
- expirationTime < workInProgressRootLatestSuspenseTimeout &&
- 2 < expirationTime &&
- ((workInProgressRootLatestSuspenseTimeout = expirationTime),
- (workInProgressRootCanSuspendUsingConfig = suspenseConfig));
-}
-function markUnprocessedUpdateTime(expirationTime) {
- expirationTime > workInProgressRootNextUnprocessedUpdateTime &&
- (workInProgressRootNextUnprocessedUpdateTime = expirationTime);
+ ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3),
+ eventTime > workInProgressRootLatestSuspenseTimeout &&
+ ((workInProgressRootLatestSuspenseTimeout = eventTime),
+ (workInProgressRootCanSuspendUsingConfig = suspenseConfig)));
}
-function renderRootSync(root, expirationTime) {
+function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
+ executionContext |= 16;
var prevDispatcher = pushDispatcher();
- if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1)
- prepareFreshStack(root, expirationTime),
- startWorkOnPendingInteractions(root, expirationTime);
- expirationTime = pushInteractions(root);
+ if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes)
+ prepareFreshStack(root, lanes), startWorkOnPendingInteractions(root, lanes);
+ lanes = pushInteractions(root);
do
try {
workLoopSync();
@@ -6082,187 +6422,197 @@ function renderRootSync(root, expirationTime) {
}
while (1);
resetContextDependencies();
- tracing.__interactionsRef.current = expirationTime;
+ tracing.__interactionsRef.current = lanes;
executionContext = prevExecutionContext;
- ReactCurrentDispatcher$1.current = prevDispatcher;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
if (null !== workInProgress)
throw Error(
"Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
);
workInProgressRoot = null;
+ workInProgressRootRenderLanes = 0;
return workInProgressRootExitStatus;
}
function workLoopSync() {
- for (; null !== workInProgress; )
- workInProgress = performUnitOfWork(workInProgress);
+ for (; null !== workInProgress; ) performUnitOfWork(workInProgress);
}
function workLoopConcurrent() {
for (; null !== workInProgress && !Scheduler_shouldYield(); )
- workInProgress = performUnitOfWork(workInProgress);
+ performUnitOfWork(workInProgress);
}
function performUnitOfWork(unitOfWork) {
var current = unitOfWork.alternate;
0 !== (unitOfWork.mode & 8)
? ((profilerStartTime = now$1()),
0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()),
- (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)),
+ (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)),
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0))
- : (current = beginWork$1(current, unitOfWork, renderExpirationTime$1));
+ : (current = beginWork$1(current, unitOfWork, subtreeRenderLanes));
unitOfWork.memoizedProps = unitOfWork.pendingProps;
- null === current && (current = completeUnitOfWork(unitOfWork));
+ null === current
+ ? completeUnitOfWork(unitOfWork)
+ : (workInProgress = current);
ReactCurrentOwner$2.current = null;
- return current;
}
function completeUnitOfWork(unitOfWork) {
- workInProgress = unitOfWork;
+ var completedWork = unitOfWork;
do {
- var current = workInProgress.alternate;
- unitOfWork = workInProgress.return;
- if (0 === (workInProgress.effectTag & 2048)) {
- if (0 === (workInProgress.mode & 8))
- current = completeWork(current, workInProgress, renderExpirationTime$1);
+ var current = completedWork.alternate;
+ unitOfWork = completedWork.return;
+ if (0 === (completedWork.effectTag & 2048)) {
+ if (0 === (completedWork.mode & 8))
+ current = completeWork(current, completedWork, subtreeRenderLanes);
else {
- var fiber = workInProgress;
+ var fiber = completedWork;
profilerStartTime = now$1();
0 > fiber.actualStartTime && (fiber.actualStartTime = now$1());
- current = completeWork(current, workInProgress, renderExpirationTime$1);
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1);
+ current = completeWork(current, completedWork, subtreeRenderLanes);
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1);
}
- fiber = workInProgress;
- if (1 === renderExpirationTime$1 || 1 !== fiber.childExpirationTime) {
- var newChildExpirationTime = 0;
- if (0 !== (fiber.mode & 8)) {
+ if (null !== current) {
+ workInProgress = current;
+ return;
+ }
+ current = completedWork;
+ if (
+ (24 !== current.tag && 23 !== current.tag) ||
+ null === current.memoizedState ||
+ 0 !== (subtreeRenderLanes & 1073741824) ||
+ 0 === (current.mode & 4)
+ ) {
+ fiber = 0;
+ if (0 !== (current.mode & 8)) {
for (
- var actualDuration = fiber.actualDuration,
- treeBaseDuration = fiber.selfBaseDuration,
+ var actualDuration = current.actualDuration,
+ treeBaseDuration = current.selfBaseDuration,
shouldBubbleActualDurations =
- null === fiber.alternate ||
- fiber.child !== fiber.alternate.child,
- child = fiber.child;
+ null === current.alternate ||
+ current.child !== current.alternate.child,
+ child = current.child;
null !== child;
- ) {
- var childUpdateExpirationTime = child.expirationTime,
- childChildExpirationTime = child.childExpirationTime;
- childUpdateExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = childUpdateExpirationTime);
- childChildExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = childChildExpirationTime);
- shouldBubbleActualDurations &&
- (actualDuration += child.actualDuration);
- treeBaseDuration += child.treeBaseDuration;
- child = child.sibling;
- }
- fiber.actualDuration = actualDuration;
- fiber.treeBaseDuration = treeBaseDuration;
+ )
+ (fiber |= child.lanes | child.childLanes),
+ shouldBubbleActualDurations &&
+ (actualDuration += child.actualDuration),
+ (treeBaseDuration += child.treeBaseDuration),
+ (child = child.sibling);
+ 13 === current.tag &&
+ null !== current.memoizedState &&
+ ((shouldBubbleActualDurations = current.child),
+ null !== shouldBubbleActualDurations &&
+ (treeBaseDuration -=
+ shouldBubbleActualDurations.treeBaseDuration));
+ current.actualDuration = actualDuration;
+ current.treeBaseDuration = treeBaseDuration;
} else
- for (actualDuration = fiber.child; null !== actualDuration; )
- (treeBaseDuration = actualDuration.expirationTime),
- (shouldBubbleActualDurations =
- actualDuration.childExpirationTime),
- treeBaseDuration > newChildExpirationTime &&
- (newChildExpirationTime = treeBaseDuration),
- shouldBubbleActualDurations > newChildExpirationTime &&
- (newChildExpirationTime = shouldBubbleActualDurations),
+ for (actualDuration = current.child; null !== actualDuration; )
+ (fiber |= actualDuration.lanes | actualDuration.childLanes),
(actualDuration = actualDuration.sibling);
- fiber.childExpirationTime = newChildExpirationTime;
+ current.childLanes = fiber;
}
- if (null !== current) return current;
null !== unitOfWork &&
0 === (unitOfWork.effectTag & 2048) &&
(null === unitOfWork.firstEffect &&
- (unitOfWork.firstEffect = workInProgress.firstEffect),
- null !== workInProgress.lastEffect &&
+ (unitOfWork.firstEffect = completedWork.firstEffect),
+ null !== completedWork.lastEffect &&
(null !== unitOfWork.lastEffect &&
- (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect),
- (unitOfWork.lastEffect = workInProgress.lastEffect)),
- 1 < workInProgress.effectTag &&
+ (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect),
+ (unitOfWork.lastEffect = completedWork.lastEffect)),
+ 1 < completedWork.effectTag &&
(null !== unitOfWork.lastEffect
- ? (unitOfWork.lastEffect.nextEffect = workInProgress)
- : (unitOfWork.firstEffect = workInProgress),
- (unitOfWork.lastEffect = workInProgress)));
+ ? (unitOfWork.lastEffect.nextEffect = completedWork)
+ : (unitOfWork.firstEffect = completedWork),
+ (unitOfWork.lastEffect = completedWork)));
} else {
- current = unwindWork(workInProgress);
- if (0 !== (workInProgress.mode & 8)) {
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1);
- fiber = workInProgress.actualDuration;
- for (
- newChildExpirationTime = workInProgress.child;
- null !== newChildExpirationTime;
-
- )
- (fiber += newChildExpirationTime.actualDuration),
- (newChildExpirationTime = newChildExpirationTime.sibling);
- workInProgress.actualDuration = fiber;
+ current = unwindWork(completedWork);
+ if (null !== current) {
+ current.effectTag &= 2047;
+ workInProgress = current;
+ return;
+ }
+ if (0 !== (completedWork.mode & 8)) {
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1);
+ current = completedWork.actualDuration;
+ for (fiber = completedWork.child; null !== fiber; )
+ (current += fiber.actualDuration), (fiber = fiber.sibling);
+ completedWork.actualDuration = current;
}
- if (null !== current) return (current.effectTag &= 2047), current;
null !== unitOfWork &&
((unitOfWork.firstEffect = unitOfWork.lastEffect = null),
(unitOfWork.effectTag |= 2048));
}
- current = workInProgress.sibling;
- if (null !== current) return current;
- workInProgress = unitOfWork;
- } while (null !== workInProgress);
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootCompleted);
- return null;
-}
-function getRemainingExpirationTime(fiber) {
- var updateExpirationTime = fiber.expirationTime;
- fiber = fiber.childExpirationTime;
- return updateExpirationTime > fiber ? updateExpirationTime : fiber;
+ completedWork = completedWork.sibling;
+ if (null !== completedWork) {
+ workInProgress = completedWork;
+ return;
+ }
+ workInProgress = completedWork = unitOfWork;
+ } while (null !== completedWork);
+ 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
function commitRoot(root) {
var renderPriorityLevel = getCurrentPriorityLevel();
runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel));
return null;
}
-function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
+function commitRootImpl(root, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- var finishedWork = root$jscomp$1.finishedWork,
- expirationTime = root$jscomp$1.finishedExpirationTime;
+ var finishedWork = root.finishedWork,
+ lanes = root.finishedLanes;
if (null === finishedWork) return null;
- root$jscomp$1.finishedWork = null;
- root$jscomp$1.finishedExpirationTime = 0;
- if (finishedWork === root$jscomp$1.current)
+ root.finishedWork = null;
+ root.finishedLanes = 0;
+ if (finishedWork === root.current)
throw Error(
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
);
- root$jscomp$1.callbackNode = null;
- root$jscomp$1.callbackExpirationTime = 0;
- root$jscomp$1.callbackPriority = 90;
- root$jscomp$1.nextKnownPendingLevel = 0;
- var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(
- finishedWork
- );
- root$jscomp$1.firstPendingTime = remainingExpirationTimeBeforeCommit;
- expirationTime <= root$jscomp$1.lastSuspendedTime
- ? (root$jscomp$1.firstSuspendedTime = root$jscomp$1.lastSuspendedTime = root$jscomp$1.nextKnownPendingLevel = 0)
- : expirationTime <= root$jscomp$1.firstSuspendedTime &&
- (root$jscomp$1.firstSuspendedTime = expirationTime - 1);
- expirationTime <= root$jscomp$1.lastPingedTime &&
- (root$jscomp$1.lastPingedTime = 0);
- expirationTime <= root$jscomp$1.lastExpiredTime &&
- (root$jscomp$1.lastExpiredTime = 0);
- root$jscomp$1 === workInProgressRoot &&
+ root.callbackNode = null;
+ var remainingLanes = finishedWork.lanes | finishedWork.childLanes,
+ remainingLanes$jscomp$0 = remainingLanes,
+ noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0;
+ root.pendingLanes = remainingLanes$jscomp$0;
+ root.suspendedLanes = 0;
+ root.pingedLanes = 0;
+ root.expiredLanes &= remainingLanes$jscomp$0;
+ root.mutableReadLanes &= remainingLanes$jscomp$0;
+ root.entangledLanes &= remainingLanes$jscomp$0;
+ remainingLanes$jscomp$0 = root.entanglements;
+ for (
+ var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes;
+ 0 < noLongerPendingLanes;
+
+ ) {
+ var index$11 = 31 - clz32(noLongerPendingLanes),
+ lane = 1 << index$11;
+ remainingLanes$jscomp$0[index$11] = 0;
+ eventTimes[index$11] = -1;
+ expirationTimes[index$11] = -1;
+ noLongerPendingLanes &= ~lane;
+ }
+ null !== rootsWithPendingDiscreteUpdates &&
+ 0 === (remainingLanes & 24) &&
+ rootsWithPendingDiscreteUpdates.has(root) &&
+ rootsWithPendingDiscreteUpdates.delete(root);
+ root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
- (renderExpirationTime$1 = 0));
+ (workInProgressRootRenderLanes = 0));
1 < finishedWork.effectTag
? null !== finishedWork.lastEffect
? ((finishedWork.lastEffect.nextEffect = finishedWork),
- (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect))
- : (remainingExpirationTimeBeforeCommit = finishedWork)
- : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect);
- if (null !== remainingExpirationTimeBeforeCommit) {
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- var prevInteractions = pushInteractions(root$jscomp$1);
- ReactCurrentOwner$2.current = null;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ (remainingLanes = finishedWork.firstEffect))
+ : (remainingLanes = finishedWork)
+ : (remainingLanes = finishedWork.firstEffect);
+ if (null !== remainingLanes) {
+ remainingLanes$jscomp$0 = executionContext;
+ executionContext |= 32;
+ eventTimes = pushInteractions(root);
+ focusedInstanceHandle = ReactCurrentOwner$2.current = null;
+ shouldFireAfterActiveInstanceBlur = !1;
+ nextEffect = remainingLanes;
do
try {
commitBeforeMutationEffects();
@@ -6272,16 +6622,12 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
+ focusedInstanceHandle = null;
commitTime = now$1();
- nextEffect = remainingExpirationTimeBeforeCommit;
+ nextEffect = remainingLanes;
do
try {
- for (
- var root = root$jscomp$1,
- renderPriorityLevel = renderPriorityLevel$jscomp$1;
- null !== nextEffect;
-
- ) {
+ for (; null !== nextEffect; ) {
var effectTag = nextEffect.effectTag;
if (effectTag & 128) {
var current = nextEffect.alternate;
@@ -6312,49 +6658,105 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
commitWork(nextEffect.alternate, nextEffect);
break;
case 8:
- var current$jscomp$0 = nextEffect;
- a: for (
- var finishedRoot = root,
- root$jscomp$0 = current$jscomp$0,
- renderPriorityLevel$jscomp$0 = renderPriorityLevel,
- node = root$jscomp$0;
- ;
-
- )
+ expirationTimes = nextEffect;
+ a: for (index$11 = noLongerPendingLanes = expirationTimes; ; ) {
+ lane = index$11;
if (
- (commitUnmount(
- finishedRoot,
- node,
- renderPriorityLevel$jscomp$0
- ),
- null !== node.child)
+ injectedHook &&
+ "function" === typeof injectedHook.onCommitFiberUnmount
)
- (node.child.return = node), (node = node.child);
+ try {
+ injectedHook.onCommitFiberUnmount(rendererID, lane);
+ } catch (err) {}
+ switch (lane.tag) {
+ case 0:
+ case 11:
+ case 14:
+ case 15:
+ case 22:
+ var updateQueue = lane.updateQueue;
+ if (null !== updateQueue) {
+ var lastEffect = updateQueue.lastEffect;
+ if (null !== lastEffect) {
+ var firstEffect = lastEffect.next,
+ effect = firstEffect;
+ do {
+ var _effect2 = effect,
+ destroy = _effect2.destroy,
+ tag = _effect2.tag;
+ if (void 0 !== destroy)
+ if (0 !== (tag & 4))
+ enqueuePendingPassiveHookEffectUnmount(
+ lane,
+ effect
+ );
+ else {
+ _effect2 = lane;
+ try {
+ destroy();
+ } catch (error) {
+ captureCommitPhaseError(_effect2, error);
+ }
+ }
+ effect = effect.next;
+ } while (effect !== firstEffect);
+ }
+ }
+ break;
+ case 1:
+ safelyDetachRef(lane);
+ var instance = lane.stateNode;
+ if ("function" === typeof instance.componentWillUnmount)
+ try {
+ (effect = lane),
+ (_effect2 = instance),
+ (_effect2.props = effect.memoizedProps),
+ (_effect2.state = effect.memoizedState),
+ _effect2.componentWillUnmount();
+ } catch (unmountError) {
+ captureCommitPhaseError(lane, unmountError);
+ }
+ break;
+ case 5:
+ safelyDetachRef(lane);
+ break;
+ case 4:
+ createChildNodeSet(lane.stateNode.containerInfo);
+ }
+ if (null !== index$11.child)
+ (index$11.child.return = index$11),
+ (index$11 = index$11.child);
else {
- if (node === root$jscomp$0) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === root$jscomp$0)
+ if (index$11 === noLongerPendingLanes) break;
+ for (; null === index$11.sibling; ) {
+ if (
+ null === index$11.return ||
+ index$11.return === noLongerPendingLanes
+ )
break a;
- node = node.return;
+ index$11 = index$11.return;
}
- node.sibling.return = node.return;
- node = node.sibling;
+ index$11.sibling.return = index$11.return;
+ index$11 = index$11.sibling;
}
- detachFiber(current$jscomp$0);
+ }
+ var alternate = expirationTimes.alternate;
+ detachFiberMutation(expirationTimes);
+ null !== alternate && detachFiberMutation(alternate);
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$95) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$95);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
- root$jscomp$1.current = finishedWork;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ root.current = finishedWork;
+ nextEffect = remainingLanes;
do
try {
- for (effectTag = root$jscomp$1; null !== nextEffect; ) {
+ for (effectTag = root; null !== nextEffect; ) {
var effectTag$jscomp$0 = nextEffect.effectTag;
effectTag$jscomp$0 & 36 &&
commitLifeCycles(effectTag, nextEffect.alternate, nextEffect);
@@ -6362,13 +6764,13 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
current = void 0;
var ref = nextEffect.ref;
if (null !== ref) {
- var instance = nextEffect.stateNode;
+ var instance$jscomp$0 = nextEffect.stateNode;
switch (nextEffect.tag) {
case 5:
- current = instance.canonical;
+ current = instance$jscomp$0.canonical;
break;
default:
- current = instance;
+ current = instance$jscomp$0;
}
"function" === typeof ref
? ref(current)
@@ -6377,72 +6779,86 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) {
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$96) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$96);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
nextEffect = null;
requestPaint();
- tracing.__interactionsRef.current = prevInteractions;
- executionContext = prevExecutionContext;
- } else (root$jscomp$1.current = finishedWork), (commitTime = now$1());
+ tracing.__interactionsRef.current = eventTimes;
+ executionContext = remainingLanes$jscomp$0;
+ } else (root.current = finishedWork), (commitTime = now$1());
if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects))
(rootDoesHavePassiveEffects = !1),
- (rootWithPendingPassiveEffects = root$jscomp$1),
- (pendingPassiveEffectsExpirationTime = expirationTime),
- (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$1);
+ (rootWithPendingPassiveEffects = root),
+ (pendingPassiveEffectsLanes = lanes),
+ (pendingPassiveEffectsRenderPriority = renderPriorityLevel);
else
- for (
- nextEffect = remainingExpirationTimeBeforeCommit;
- null !== nextEffect;
-
- )
- (renderPriorityLevel$jscomp$1 = nextEffect.nextEffect),
+ for (nextEffect = remainingLanes; null !== nextEffect; )
+ (ref = nextEffect.nextEffect),
(nextEffect.nextEffect = null),
- (nextEffect = renderPriorityLevel$jscomp$1);
- renderPriorityLevel$jscomp$1 = root$jscomp$1.firstPendingTime;
- if (0 !== renderPriorityLevel$jscomp$1) {
+ nextEffect.effectTag & 8 && (nextEffect.sibling = null),
+ (nextEffect = ref);
+ remainingLanes = root.pendingLanes;
+ if (0 !== remainingLanes) {
if (null !== spawnedWorkDuringRender)
for (
- remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender,
+ ref = spawnedWorkDuringRender,
spawnedWorkDuringRender = null,
- ref = 0;
- ref < remainingExpirationTimeBeforeCommit.length;
- ref++
+ instance$jscomp$0 = 0;
+ instance$jscomp$0 < ref.length;
+ instance$jscomp$0++
)
scheduleInteractions(
- root$jscomp$1,
- remainingExpirationTimeBeforeCommit[ref],
- root$jscomp$1.memoizedInteractions
+ root,
+ ref[instance$jscomp$0],
+ root.memoizedInteractions
);
- schedulePendingInteractions(root$jscomp$1, renderPriorityLevel$jscomp$1);
+ schedulePendingInteractions(root, remainingLanes);
} else legacyErrorBoundariesThatAlreadyFailed = null;
- effectTag$jscomp$0 ||
- finishPendingInteractions(root$jscomp$1, expirationTime);
- 1073741823 === renderPriorityLevel$jscomp$1
- ? root$jscomp$1 === rootWithNestedUpdates
+ effectTag$jscomp$0 || finishPendingInteractions(root, lanes);
+ 1 === remainingLanes
+ ? root === rootWithNestedUpdates
? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$1))
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
: (nestedUpdateCount = 0);
- "function" === typeof onCommitFiberRoot &&
- onCommitFiberRoot(finishedWork.stateNode, expirationTime);
- ensureRootIsScheduled(root$jscomp$1);
+ finishedWork = finishedWork.stateNode;
+ if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot)
+ try {
+ injectedHook.onCommitFiberRoot(
+ rendererID,
+ finishedWork,
+ renderPriorityLevel,
+ 64 === (finishedWork.current.effectTag & 64)
+ );
+ } catch (err) {}
+ ensureRootIsScheduled(root, now());
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
- (root$jscomp$1 = firstUncaughtError),
+ (root = firstUncaughtError),
(firstUncaughtError = null),
- root$jscomp$1);
- if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null;
+ root);
+ if (0 !== (executionContext & 8)) return null;
flushSyncCallbackQueue();
return null;
}
function commitBeforeMutationEffects() {
for (; null !== nextEffect; ) {
+ var current = nextEffect.alternate;
+ shouldFireAfterActiveInstanceBlur ||
+ null === focusedInstanceHandle ||
+ (0 !== (nextEffect.effectTag & 8)
+ ? doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0)
+ : 13 === nextEffect.tag &&
+ isSuspenseBoundaryBeingHidden(current, nextEffect) &&
+ doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0));
var effectTag = nextEffect.effectTag;
0 !== (effectTag & 256) &&
- commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect);
+ commitBeforeMutationLifeCycles(current, nextEffect);
0 === (effectTag & 512) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
@@ -6460,58 +6876,89 @@ function flushPassiveEffects() {
? 97
: pendingPassiveEffectsRenderPriority;
pendingPassiveEffectsRenderPriority = 90;
+ schedulerPriorityToLanePriority(priorityLevel);
return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
}
+ return !1;
+}
+function enqueuePendingPassiveHookEffectMount(fiber, effect) {
+ pendingPassiveHookEffectsMount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
+}
+function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
+ pendingPassiveHookEffectsUnmount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
}
function flushPassiveEffectsImpl() {
if (null === rootWithPendingPassiveEffects) return !1;
var root = rootWithPendingPassiveEffects,
- expirationTime = pendingPassiveEffectsExpirationTime;
+ lanes = pendingPassiveEffectsLanes;
rootWithPendingPassiveEffects = null;
- pendingPassiveEffectsExpirationTime = 0;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ pendingPassiveEffectsLanes = 0;
+ if (0 !== (executionContext & 48))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- for (
- var prevInteractions = pushInteractions(root),
- _effect2 = root.current.firstEffect;
- null !== _effect2;
-
- ) {
+ executionContext |= 32;
+ var prevInteractions = pushInteractions(root),
+ unmountEffects = pendingPassiveHookEffectsUnmount;
+ pendingPassiveHookEffectsUnmount = [];
+ for (var i = 0; i < unmountEffects.length; i += 2) {
+ var effect$101 = unmountEffects[i],
+ fiber = unmountEffects[i + 1],
+ destroy = effect$101.destroy;
+ effect$101.destroy = void 0;
+ if ("function" === typeof destroy)
+ try {
+ destroy();
+ } catch (error) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error);
+ }
+ }
+ unmountEffects = pendingPassiveHookEffectsMount;
+ pendingPassiveHookEffectsMount = [];
+ for (i = 0; i < unmountEffects.length; i += 2) {
+ effect$101 = unmountEffects[i];
+ fiber = unmountEffects[i + 1];
try {
- var finishedWork = _effect2;
- if (0 !== (finishedWork.effectTag & 512))
- switch (finishedWork.tag) {
- case 0:
- case 11:
- case 15:
- case 22:
- commitHookEffectListUnmount(5, finishedWork),
- commitHookEffectListMount(5, finishedWork);
- }
- } catch (error) {
- if (null === _effect2) throw Error("Should be working on an effect.");
- captureCommitPhaseError(_effect2, error);
+ var create$105 = effect$101.create;
+ effect$101.destroy = create$105();
+ } catch (error$106) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error$106);
}
- finishedWork = _effect2.nextEffect;
- _effect2.nextEffect = null;
- _effect2 = finishedWork;
}
+ for (create$105 = root.current.firstEffect; null !== create$105; )
+ (unmountEffects = create$105.nextEffect),
+ (create$105.nextEffect = null),
+ create$105.effectTag & 8 && (create$105.sibling = null),
+ (create$105 = unmountEffects);
tracing.__interactionsRef.current = prevInteractions;
- finishPendingInteractions(root, expirationTime);
+ finishPendingInteractions(root, lanes);
executionContext = prevExecutionContext;
flushSyncCallbackQueue();
return !0;
}
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823);
+ sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1);
enqueueUpdate(rootFiber, sourceFiber);
- rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823);
+ sourceFiber = requestEventTime();
+ rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1);
null !== rootFiber &&
- (ensureRootIsScheduled(rootFiber),
- schedulePendingInteractions(rootFiber, 1073741823));
+ (markRootUpdated(rootFiber, 1, sourceFiber),
+ ensureRootIsScheduled(rootFiber, sourceFiber),
+ schedulePendingInteractions(rootFiber, 1));
}
function captureCommitPhaseError(sourceFiber, error) {
if (3 === sourceFiber.tag)
@@ -6530,156 +6977,166 @@ function captureCommitPhaseError(sourceFiber, error) {
!legacyErrorBoundariesThatAlreadyFailed.has(instance)))
) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823);
+ sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1);
enqueueUpdate(fiber, sourceFiber);
- fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823);
+ sourceFiber = requestEventTime();
+ fiber = markUpdateLaneFromFiberToRoot(fiber, 1);
null !== fiber &&
- (ensureRootIsScheduled(fiber),
- schedulePendingInteractions(fiber, 1073741823));
+ (markRootUpdated(fiber, 1, sourceFiber),
+ ensureRootIsScheduled(fiber, sourceFiber),
+ schedulePendingInteractions(fiber, 1));
break;
}
}
fiber = fiber.return;
}
}
-function pingSuspendedRoot(root, thenable, suspendedTime) {
+function pingSuspendedRoot(root, wakeable, pingedLanes) {
var pingCache = root.pingCache;
- null !== pingCache && pingCache.delete(thenable);
- workInProgressRoot === root && renderExpirationTime$1 === suspendedTime
- ? workInProgressRootExitStatus === RootSuspendedWithDelay ||
- (workInProgressRootExitStatus === RootSuspended &&
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
- ? prepareFreshStack(root, renderExpirationTime$1)
- : (workInProgressRootHasPendingPing = !0)
- : isRootSuspendedAtTime(root, suspendedTime) &&
- ((thenable = root.lastPingedTime),
- (0 !== thenable && thenable < suspendedTime) ||
- ((root.lastPingedTime = suspendedTime),
- ensureRootIsScheduled(root),
- schedulePendingInteractions(root, suspendedTime)));
-}
-function resolveRetryThenable(boundaryFiber, thenable) {
+ null !== pingCache && pingCache.delete(wakeable);
+ wakeable = requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & pingedLanes;
+ workInProgressRoot === root &&
+ (workInProgressRootRenderLanes & pingedLanes) === pingedLanes &&
+ (4 === workInProgressRootExitStatus ||
+ (3 === workInProgressRootExitStatus &&
+ (workInProgressRootRenderLanes & 62914560) ===
+ workInProgressRootRenderLanes &&
+ 500 > now() - globalMostRecentFallbackTime)
+ ? prepareFreshStack(root, 0)
+ : (workInProgressRootPingedLanes |= pingedLanes));
+ ensureRootIsScheduled(root, wakeable);
+ schedulePendingInteractions(root, pingedLanes);
+}
+function resolveRetryWakeable(boundaryFiber, wakeable) {
var retryCache = boundaryFiber.stateNode;
- null !== retryCache && retryCache.delete(thenable);
- thenable = 0;
- 0 === thenable &&
- ((thenable = requestCurrentTimeForUpdate()),
- (thenable = computeExpirationForFiber(thenable, boundaryFiber, null)));
- boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable);
+ null !== retryCache && retryCache.delete(wakeable);
+ wakeable = 0;
+ 0 === wakeable &&
+ ((wakeable = boundaryFiber.mode),
+ 0 === (wakeable & 2)
+ ? (wakeable = 1)
+ : 0 === (wakeable & 4)
+ ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2)
+ : (0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes),
+ (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)),
+ 0 === wakeable && (wakeable = 4194304)));
+ retryCache = requestEventTime();
+ boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable);
null !== boundaryFiber &&
- (ensureRootIsScheduled(boundaryFiber),
- schedulePendingInteractions(boundaryFiber, thenable));
+ (markRootUpdated(boundaryFiber, wakeable, retryCache),
+ ensureRootIsScheduled(boundaryFiber, retryCache),
+ schedulePendingInteractions(boundaryFiber, wakeable));
}
var beginWork$1;
-beginWork$1 = function(current, workInProgress, renderExpirationTime) {
- var updateExpirationTime = workInProgress.expirationTime;
+beginWork$1 = function(current, workInProgress, renderLanes) {
+ var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
didPerformWorkStackCursor.current
)
didReceiveUpdate = !0;
+ else if (0 !== (renderLanes & updateLanes))
+ didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1;
else {
- if (updateExpirationTime < renderExpirationTime) {
- didReceiveUpdate = !1;
- switch (workInProgress.tag) {
- case 3:
- pushHostRootContext(workInProgress);
- break;
- case 5:
- pushHostContext(workInProgress);
- break;
- case 1:
- isContextProvider(workInProgress.type) &&
- pushContextProvider(workInProgress);
- break;
- case 4:
- pushHostContainer(
+ didReceiveUpdate = !1;
+ switch (workInProgress.tag) {
+ case 3:
+ pushHostRootContext(workInProgress);
+ break;
+ case 5:
+ pushHostContext(workInProgress);
+ break;
+ case 1:
+ isContextProvider(workInProgress.type) &&
+ pushContextProvider(workInProgress);
+ break;
+ case 4:
+ pushHostContainer(
+ workInProgress,
+ workInProgress.stateNode.containerInfo
+ );
+ break;
+ case 10:
+ updateLanes = workInProgress.memoizedProps.value;
+ var context = workInProgress.type._context;
+ push(valueCursor, context._currentValue2);
+ context._currentValue2 = updateLanes;
+ break;
+ case 12:
+ 0 !== (renderLanes & workInProgress.childLanes) &&
+ (workInProgress.effectTag |= 4);
+ updateLanes = workInProgress.stateNode;
+ updateLanes.effectDuration = 0;
+ updateLanes.passiveEffectDuration = 0;
+ break;
+ case 13:
+ if (null !== workInProgress.memoizedState) {
+ if (0 !== (renderLanes & workInProgress.child.childLanes))
+ return updateSuspenseComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ workInProgress = bailoutOnAlreadyFinishedWork(
+ current,
workInProgress,
- workInProgress.stateNode.containerInfo
+ renderLanes
);
- break;
- case 10:
- updateExpirationTime = workInProgress.memoizedProps.value;
- var context = workInProgress.type._context;
- push(valueCursor, context._currentValue2);
- context._currentValue2 = updateExpirationTime;
- break;
- case 12:
- workInProgress.childExpirationTime >= renderExpirationTime &&
- (workInProgress.effectTag |= 4);
- updateExpirationTime = workInProgress.stateNode;
- updateExpirationTime.effectDuration = 0;
- updateExpirationTime.passiveEffectDuration = 0;
- break;
- case 13:
- if (null !== workInProgress.memoizedState) {
- updateExpirationTime = workInProgress.child.childExpirationTime;
- if (
- 0 !== updateExpirationTime &&
- updateExpirationTime >= renderExpirationTime
- )
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- workInProgress = bailoutOnAlreadyFinishedWork(
+ return null !== workInProgress ? workInProgress.sibling : null;
+ }
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
+ case 19:
+ updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.effectTag & 64)) {
+ if (updateLanes)
+ return updateSuspenseListComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateExpirationTime =
- workInProgress.childExpirationTime >= renderExpirationTime;
- if (0 !== (current.effectTag & 64)) {
- if (updateExpirationTime)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- workInProgress.effectTag |= 64;
- }
- context = workInProgress.memoizedState;
- null !== context &&
- ((context.rendering = null), (context.tail = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (!updateExpirationTime) return null;
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ workInProgress.effectTag |= 64;
+ }
+ context = workInProgress.memoizedState;
+ null !== context &&
+ ((context.rendering = null),
+ (context.tail = null),
+ (context.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (updateLanes) break;
+ else return null;
+ case 23:
+ case 24:
+ return (
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
+ );
}
- didReceiveUpdate = !1;
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
else didReceiveUpdate = !1;
- workInProgress.expirationTime = 0;
+ workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateExpirationTime = workInProgress.type;
+ updateLanes = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
context = getMaskedContext(workInProgress, contextStackCursor.current);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
context = renderWithHooks(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
current,
context,
- renderExpirationTime
+ renderLanes
);
workInProgress.effectTag |= 1;
if (
@@ -6691,7 +7148,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateExpirationTime)) {
+ if (isContextProvider(updateLanes)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
@@ -6700,53 +7157,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
? context.state
: null;
initializeUpdateQueue(workInProgress);
- var getDerivedStateFromProps =
- updateExpirationTime.getDerivedStateFromProps;
+ var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps;
"function" === typeof getDerivedStateFromProps &&
applyDerivedStateFromProps(
workInProgress,
- updateExpirationTime,
+ updateLanes,
getDerivedStateFromProps,
current
);
context.updater = classComponentUpdater;
workInProgress.stateNode = context;
- context._reactInternalFiber = workInProgress;
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- current,
- renderExpirationTime
- );
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, updateLanes, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
hasContext,
- renderExpirationTime
+ renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(
- null,
- workInProgress,
- context,
- renderExpirationTime
- ),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
+ context = workInProgress.elementType;
a: {
- context = workInProgress.elementType;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
- initializeLazyComponentType(context);
- if (1 !== context._status) throw context._result;
- context = context._result;
+ hasContext = context._init;
+ context = hasContext(context._payload);
workInProgress.type = context;
hasContext = workInProgress.tag = resolveLazyComponentTag(context);
current = resolveDefaultProps(context, current);
@@ -6757,7 +7202,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 1:
@@ -6766,7 +7211,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 11:
@@ -6775,7 +7220,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 14:
@@ -6784,8 +7229,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
resolveDefaultProps(context.type, current),
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
break a;
}
@@ -6798,126 +7243,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return workInProgress;
case 0:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateFunctionComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 1:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateClassComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- updateExpirationTime = workInProgress.updateQueue;
- if (null === current || null === updateExpirationTime)
+ updateLanes = workInProgress.updateQueue;
+ if (null === current || null === updateLanes)
throw Error(
"If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."
);
- updateExpirationTime = workInProgress.pendingProps;
+ updateLanes = workInProgress.pendingProps;
context = workInProgress.memoizedState;
context = null !== context ? context.element : null;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(
- workInProgress,
- updateExpirationTime,
- null,
- renderExpirationTime
- );
- updateExpirationTime = workInProgress.memoizedState.element;
- updateExpirationTime === context
+ processUpdateQueue(workInProgress, updateLanes, null, renderLanes);
+ updateLanes = workInProgress.memoizedState.element;
+ updateLanes === context
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
))
- : (reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ : (reconcileChildren(current, workInProgress, updateLanes, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateExpirationTime = workInProgress.pendingProps.children),
+ (updateLanes = workInProgress.pendingProps.children),
markRef(current, workInProgress),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
- (workInProgress = workInProgress.child),
- workInProgress
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ workInProgress.child
);
case 6:
return null;
case 13:
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
case 4:
return (
pushHostContainer(
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateExpirationTime = workInProgress.pendingProps),
+ (updateLanes = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
))
: reconcileChildren(
current,
workInProgress,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
),
workInProgress.child
);
case 11:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateForwardRef(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 7:
@@ -6926,7 +7351,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
@@ -6936,27 +7361,27 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
case 12:
return (
(workInProgress.effectTag |= 4),
- (updateExpirationTime = workInProgress.stateNode),
- (updateExpirationTime.effectDuration = 0),
- (updateExpirationTime.passiveEffectDuration = 0),
+ (updateLanes = workInProgress.stateNode),
+ (updateLanes.effectDuration = 0),
+ (updateLanes.passiveEffectDuration = 0),
reconcileChildren(
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
case 10:
a: {
- updateExpirationTime = workInProgress.type._context;
+ updateLanes = workInProgress.type._context;
context = workInProgress.pendingProps;
getDerivedStateFromProps = workInProgress.memoizedProps;
hasContext = context.value;
@@ -6968,9 +7393,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
((context$jscomp$0 = getDerivedStateFromProps.value),
(hasContext = objectIs(context$jscomp$0, hasContext)
? 0
- : ("function" ===
- typeof updateExpirationTime._calculateChangedBits
- ? updateExpirationTime._calculateChangedBits(
+ : ("function" === typeof updateLanes._calculateChangedBits
+ ? updateLanes._calculateChangedBits(
context$jscomp$0,
hasContext
)
@@ -6984,7 +7408,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
break a;
}
@@ -7005,25 +7429,25 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
) {
if (
- dependency.context === updateExpirationTime &&
+ dependency.context === updateLanes &&
0 !== (dependency.observedBits & hasContext)
) {
1 === context$jscomp$0.tag &&
- ((dependency = createUpdate(renderExpirationTime, null)),
+ ((dependency = createUpdate(
+ -1,
+ renderLanes & -renderLanes,
+ null
+ )),
(dependency.tag = 2),
enqueueUpdate(context$jscomp$0, dependency));
- context$jscomp$0.expirationTime < renderExpirationTime &&
- (context$jscomp$0.expirationTime = renderExpirationTime);
+ context$jscomp$0.lanes |= renderLanes;
dependency = context$jscomp$0.alternate;
- null !== dependency &&
- dependency.expirationTime < renderExpirationTime &&
- (dependency.expirationTime = renderExpirationTime);
+ null !== dependency && (dependency.lanes |= renderLanes);
scheduleWorkOnParentPath(
context$jscomp$0.return,
- renderExpirationTime
+ renderLanes
);
- list.expirationTime < renderExpirationTime &&
- (list.expirationTime = renderExpirationTime);
+ list.lanes |= renderLanes;
break;
}
dependency = dependency.next;
@@ -7061,7 +7485,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
context.children,
- renderExpirationTime
+ renderLanes
);
workInProgress = workInProgress.child;
}
@@ -7070,17 +7494,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return (
(context = workInProgress.type),
(hasContext = workInProgress.pendingProps),
- (updateExpirationTime = hasContext.children),
- prepareToReadContext(workInProgress, renderExpirationTime),
+ (updateLanes = hasContext.children),
+ prepareToReadContext(workInProgress, renderLanes),
(context = readContext(context, hasContext.unstable_observedBits)),
- (updateExpirationTime = updateExpirationTime(context)),
+ (updateLanes = updateLanes(context)),
(workInProgress.effectTag |= 1),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
workInProgress.child
);
case 14:
@@ -7096,8 +7515,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
hasContext,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
case 15:
@@ -7106,48 +7525,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
case 17:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateExpirationTime)
+ isContextProvider(updateLanes)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
- prepareToReadContext(workInProgress, renderExpirationTime),
- constructClassInstance(workInProgress, updateExpirationTime, context),
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- context,
- renderExpirationTime
- ),
+ prepareToReadContext(workInProgress, renderLanes),
+ constructClassInstance(workInProgress, updateLanes, context),
+ mountClassInstance(workInProgress, updateLanes, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
current,
- renderExpirationTime
+ renderLanes
)
);
case 19:
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
+ case 23:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ case 24:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -7155,16 +7569,16 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
"). This error is likely caused by a bug in React. Please file an issue."
);
};
-function scheduleInteractions(root, expirationTime, interactions) {
+function scheduleInteractions(root, lane, interactions) {
if (0 < interactions.size) {
var pendingInteractionMap = root.pendingInteractionMap,
- pendingInteractions = pendingInteractionMap.get(expirationTime);
+ pendingInteractions = pendingInteractionMap.get(lane);
null != pendingInteractions
? interactions.forEach(function(interaction) {
pendingInteractions.has(interaction) || interaction.__count++;
pendingInteractions.add(interaction);
})
- : (pendingInteractionMap.set(expirationTime, new Set(interactions)),
+ : (pendingInteractionMap.set(lane, new Set(interactions)),
interactions.forEach(function(interaction) {
interaction.__count++;
}));
@@ -7172,20 +7586,20 @@ function scheduleInteractions(root, expirationTime, interactions) {
if (null !== pendingInteractionMap)
pendingInteractionMap.onWorkScheduled(
interactions,
- 1e3 * expirationTime + root.interactionThreadID
+ 1e3 * lane + root.interactionThreadID
);
}
}
-function schedulePendingInteractions(root, expirationTime) {
- scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
+function schedulePendingInteractions(root, lane) {
+ scheduleInteractions(root, lane, tracing.__interactionsRef.current);
}
-function startWorkOnPendingInteractions(root, expirationTime) {
+function startWorkOnPendingInteractions(root, lanes) {
var interactions = new Set();
root.pendingInteractionMap.forEach(function(
scheduledInteractions,
- scheduledExpirationTime
+ scheduledLane
) {
- scheduledExpirationTime >= expirationTime &&
+ 0 !== (lanes & scheduledLane) &&
scheduledInteractions.forEach(function(interaction) {
return interactions.add(interaction);
});
@@ -7194,7 +7608,7 @@ function startWorkOnPendingInteractions(root, expirationTime) {
if (0 < interactions.size) {
var subscriber = tracing.__subscriberRef.current;
if (null !== subscriber) {
- root = 1e3 * expirationTime + root.interactionThreadID;
+ root = 1e3 * lanes + root.interactionThreadID;
try {
subscriber.onWorkStarted(interactions, root);
} catch (error) {
@@ -7205,14 +7619,14 @@ function startWorkOnPendingInteractions(root, expirationTime) {
}
}
}
-function finishPendingInteractions(root, committedExpirationTime) {
- var earliestRemainingTimeAfterCommit = root.firstPendingTime;
+function finishPendingInteractions(root, committedLanes) {
+ var remainingLanesAfterCommit = root.pendingLanes;
try {
var subscriber = tracing.__subscriberRef.current;
if (null !== subscriber && 0 < root.memoizedInteractions.size)
subscriber.onWorkStopped(
root.memoizedInteractions,
- 1e3 * committedExpirationTime + root.interactionThreadID
+ 1e3 * committedLanes + root.interactionThreadID
);
} catch (error) {
scheduleCallback(99, function() {
@@ -7220,54 +7634,23 @@ function finishPendingInteractions(root, committedExpirationTime) {
});
} finally {
var pendingInteractionMap = root.pendingInteractionMap;
- pendingInteractionMap.forEach(function(
- scheduledInteractions,
- scheduledExpirationTime
- ) {
- scheduledExpirationTime > earliestRemainingTimeAfterCommit &&
- (pendingInteractionMap.delete(scheduledExpirationTime),
+ pendingInteractionMap.forEach(function(scheduledInteractions, lane) {
+ 0 === (remainingLanesAfterCommit & lane) &&
+ (pendingInteractionMap.delete(lane),
scheduledInteractions.forEach(function(interaction) {
interaction.__count--;
if (null !== subscriber && 0 === interaction.__count)
try {
subscriber.onInteractionScheduledWorkCompleted(interaction);
- } catch (error) {
+ } catch (error$107) {
scheduleCallback(99, function() {
- throw error;
+ throw error$107;
});
}
}));
});
}
}
-var onCommitFiberRoot = null,
- onCommitFiberUnmount = null,
- isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__;
-function injectInternals(internals) {
- if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1;
- var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
- if (hook.isDisabled || !hook.supportsFiber) return !0;
- try {
- var rendererID = hook.inject(internals);
- onCommitFiberRoot = function(root, expirationTime) {
- try {
- var didError = 64 === (root.current.effectTag & 64),
- currentTime = 1073741821 - ((now() / 10) | 0),
- priorityLevel = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- );
- hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
- } catch (err) {}
- };
- onCommitFiberUnmount = function(fiber) {
- try {
- hook.onCommitFiberUnmount(rendererID, fiber);
- } catch (err) {}
- };
- } catch (err) {}
- return !0;
-}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -7279,12 +7662,15 @@ function FiberNode(tag, pendingProps, key, mode) {
this.mode = mode;
this.effectTag = 0;
this.lastEffect = this.firstEffect = this.nextEffect = null;
- this.childExpirationTime = this.expirationTime = 0;
+ this.childLanes = this.lanes = 0;
this.alternate = null;
this.actualDuration = 0;
this.actualStartTime = -1;
this.treeBaseDuration = this.selfBaseDuration = 0;
}
+function createFiber(tag, pendingProps, key, mode) {
+ return new FiberNode(tag, pendingProps, key, mode);
+}
function shouldConstruct(Component) {
Component = Component.prototype;
return !(!Component || !Component.isReactComponent);
@@ -7302,7 +7688,7 @@ function resolveLazyComponentTag(Component) {
function createWorkInProgress(current, pendingProps) {
var workInProgress = current.alternate;
null === workInProgress
- ? ((workInProgress = new FiberNode(
+ ? ((workInProgress = createFiber(
current.tag,
pendingProps,
current.key,
@@ -7314,18 +7700,15 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.alternate = current),
(current.alternate = workInProgress))
: ((workInProgress.pendingProps = pendingProps),
+ (workInProgress.type = current.type),
(workInProgress.effectTag = 0),
(workInProgress.nextEffect = null),
(workInProgress.firstEffect = null),
(workInProgress.lastEffect = null),
(workInProgress.actualDuration = 0),
(workInProgress.actualStartTime = -1));
- if (null == current)
- throw Error("current is " + current + " but it can't be");
- if (null == workInProgress)
- throw Error("workInProgress is " + workInProgress + " but it can't be");
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
@@ -7335,7 +7718,7 @@ function createWorkInProgress(current, pendingProps) {
null === pendingProps
? null
: {
- expirationTime: pendingProps.expirationTime,
+ lanes: pendingProps.lanes,
firstContext: pendingProps.firstContext,
responders: pendingProps.responders
};
@@ -7352,7 +7735,7 @@ function createFiberFromTypeAndProps(
pendingProps,
owner,
mode,
- expirationTime
+ lanes
) {
var fiberTag = 2;
owner = type;
@@ -7361,15 +7744,10 @@ function createFiberFromTypeAndProps(
else
a: switch (type) {
case REACT_FRAGMENT_TYPE:
- return createFiberFromFragment(
- pendingProps.children,
- mode,
- expirationTime,
- key
- );
- case REACT_CONCURRENT_MODE_TYPE:
+ return createFiberFromFragment(pendingProps.children, mode, lanes, key);
+ case REACT_DEBUG_TRACING_MODE_TYPE:
fiberTag = 8;
- mode |= 7;
+ mode |= 16;
break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
@@ -7377,26 +7755,35 @@ function createFiberFromTypeAndProps(
break;
case REACT_PROFILER_TYPE:
return (
- (type = new FiberNode(12, pendingProps, key, mode | 8)),
+ (type = createFiber(12, pendingProps, key, mode | 8)),
(type.elementType = REACT_PROFILER_TYPE),
(type.type = REACT_PROFILER_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
(type.stateNode = { effectDuration: 0, passiveEffectDuration: 0 }),
type
);
case REACT_SUSPENSE_TYPE:
return (
- (type = new FiberNode(13, pendingProps, key, mode)),
+ (type = createFiber(13, pendingProps, key, mode)),
(type.type = REACT_SUSPENSE_TYPE),
(type.elementType = REACT_SUSPENSE_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
type
);
case REACT_SUSPENSE_LIST_TYPE:
return (
- (type = new FiberNode(19, pendingProps, key, mode)),
+ (type = createFiber(19, pendingProps, key, mode)),
(type.elementType = REACT_SUSPENSE_LIST_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
+ type
+ );
+ case REACT_OFFSCREEN_TYPE:
+ return createFiberFromOffscreen(pendingProps, mode, lanes, key);
+ case REACT_LEGACY_HIDDEN_TYPE:
+ return (
+ (type = createFiber(24, pendingProps, key, mode)),
+ (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
+ (type.lanes = lanes),
type
);
default:
@@ -7428,30 +7815,36 @@ function createFiberFromTypeAndProps(
"."
);
}
- key = new FiberNode(fiberTag, pendingProps, key, mode);
+ key = createFiber(fiberTag, pendingProps, key, mode);
key.elementType = type;
key.type = owner;
- key.expirationTime = expirationTime;
+ key.lanes = lanes;
return key;
}
-function createFiberFromFragment(elements, mode, expirationTime, key) {
- elements = new FiberNode(7, elements, key, mode);
- elements.expirationTime = expirationTime;
+function createFiberFromFragment(elements, mode, lanes, key) {
+ elements = createFiber(7, elements, key, mode);
+ elements.lanes = lanes;
return elements;
}
-function createFiberFromText(content, mode, expirationTime) {
- content = new FiberNode(6, content, null, mode);
- content.expirationTime = expirationTime;
+function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
+ pendingProps = createFiber(23, pendingProps, key, mode);
+ pendingProps.elementType = REACT_OFFSCREEN_TYPE;
+ pendingProps.lanes = lanes;
+ return pendingProps;
+}
+function createFiberFromText(content, mode, lanes) {
+ content = createFiber(6, content, null, mode);
+ content.lanes = lanes;
return content;
}
-function createFiberFromPortal(portal, mode, expirationTime) {
- mode = new FiberNode(
+function createFiberFromPortal(portal, mode, lanes) {
+ mode = createFiber(
4,
null !== portal.children ? portal.children : [],
portal.key,
mode
);
- mode.expirationTime = expirationTime;
+ mode.lanes = lanes;
mode.stateNode = {
containerInfo: portal.containerInfo,
pendingChildren: null,
@@ -7461,54 +7854,34 @@ function createFiberFromPortal(portal, mode, expirationTime) {
}
function FiberRootNode(containerInfo, tag, hydrate) {
this.tag = tag;
- this.current = null;
this.containerInfo = containerInfo;
- this.pingCache = this.pendingChildren = null;
- this.finishedExpirationTime = 0;
- this.finishedWork = null;
+ this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
this.pendingContext = this.context = null;
this.hydrate = hydrate;
this.callbackNode = null;
- this.callbackPriority = 90;
- this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0;
+ this.callbackPriority = 0;
+ this.eventTimes = Array(31).fill(0);
+ this.expirationTimes = Array(31).fill(-1);
+ this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
+ this.entanglements = Array(31).fill(0);
this.interactionThreadID = tracing.unstable_getThreadID();
this.memoizedInteractions = new Set();
this.pendingInteractionMap = new Map();
}
-function isRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- root = root.lastSuspendedTime;
- return (
- 0 !== firstSuspendedTime &&
- firstSuspendedTime >= expirationTime &&
- root <= expirationTime
- );
-}
-function markRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime,
- lastSuspendedTime = root.lastSuspendedTime;
- firstSuspendedTime < expirationTime &&
- (root.firstSuspendedTime = expirationTime);
- if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime)
- root.lastSuspendedTime = expirationTime;
- expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0);
- expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0);
-}
-function markRootUpdatedAtTime(root, expirationTime) {
- expirationTime > root.firstPendingTime &&
- (root.firstPendingTime = expirationTime);
- var firstSuspendedTime = root.firstSuspendedTime;
- 0 !== firstSuspendedTime &&
- (expirationTime >= firstSuspendedTime
- ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0)
- : expirationTime >= root.lastSuspendedTime &&
- (root.lastSuspendedTime = expirationTime + 1),
- expirationTime > root.nextKnownPendingLevel &&
- (root.nextKnownPendingLevel = expirationTime));
+function createPortal(children, containerInfo, implementation) {
+ var key =
+ 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
+ return {
+ $$typeof: REACT_PORTAL_TYPE,
+ key: null == key ? null : "" + key,
+ children: children,
+ containerInfo: containerInfo,
+ implementation: implementation
+ };
}
function findHostInstance(component) {
- var fiber = component._reactInternalFiber;
+ var fiber = component._reactInternals;
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
@@ -7522,11 +7895,11 @@ function findHostInstance(component) {
}
function updateContainer(element, container, parentComponent, callback) {
var current = container.current,
- currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig);
+ eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(current, suspenseConfig);
a: if (parentComponent) {
- parentComponent = parentComponent._reactInternalFiber;
+ parentComponent = parentComponent._reactInternals;
b: {
if (
getNearestMountedFiber(parentComponent) !== parentComponent ||
@@ -7535,22 +7908,23 @@ function updateContainer(element, container, parentComponent, callback) {
throw Error(
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
);
- var parentContext = parentComponent;
+ var JSCompiler_inline_result = parentComponent;
do {
- switch (parentContext.tag) {
+ switch (JSCompiler_inline_result.tag) {
case 3:
- parentContext = parentContext.stateNode.context;
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode.context;
break b;
case 1:
- if (isContextProvider(parentContext.type)) {
- parentContext =
- parentContext.stateNode
+ if (isContextProvider(JSCompiler_inline_result.type)) {
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode
.__reactInternalMemoizedMergedChildContext;
break b;
}
}
- parentContext = parentContext.return;
- } while (null !== parentContext);
+ JSCompiler_inline_result = JSCompiler_inline_result.return;
+ } while (null !== JSCompiler_inline_result);
throw Error(
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
);
@@ -7561,34 +7935,26 @@ function updateContainer(element, container, parentComponent, callback) {
parentComponent = processChildContext(
parentComponent,
Component,
- parentContext
+ JSCompiler_inline_result
);
break a;
}
}
- parentComponent = parentContext;
+ parentComponent = JSCompiler_inline_result;
} else parentComponent = emptyContextObject;
null === container.context
? (container.context = parentComponent)
: (container.pendingContext = parentComponent);
- container = createUpdate(currentTime, suspenseConfig);
+ container = createUpdate(eventTime, lane, suspenseConfig);
container.payload = { element: element };
callback = void 0 === callback ? null : callback;
null !== callback && (container.callback = callback);
enqueueUpdate(current, container);
- scheduleWork(current, currentTime);
- return currentTime;
+ scheduleUpdateOnFiber(current, lane, eventTime);
+ return lane;
}
-function createPortal(children, containerInfo, implementation) {
- var key =
- 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
- return {
- $$typeof: REACT_PORTAL_TYPE,
- key: null == key ? null : "" + key,
- children: children,
- containerInfo: containerInfo,
- implementation: implementation
- };
+function emptyFindFiberByHostInstance() {
+ return null;
}
function findNodeHandle(componentOrHandle) {
if (null == componentOrHandle) return null;
@@ -7610,53 +7976,64 @@ batchedUpdatesImpl = function(fn, a) {
return fn(a);
} finally {
(executionContext = prevExecutionContext),
- executionContext === NoContext && flushSyncCallbackQueue();
+ 0 === executionContext && flushSyncCallbackQueue();
}
};
-var roots = new Map();
-(function(devToolsConfig) {
- var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
- return injectInternals({
- bundleType: devToolsConfig.bundleType,
- version: devToolsConfig.version,
- rendererPackageName: devToolsConfig.rendererPackageName,
- rendererConfig: devToolsConfig.rendererConfig,
- overrideHookState: null,
- overrideProps: null,
- setSuspenseHandler: null,
- scheduleUpdate: null,
- currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
- findHostInstanceByFiber: function(fiber) {
- fiber = findCurrentHostFiber(fiber);
- return null === fiber ? null : fiber.stateNode;
- },
- findFiberByHostInstance: function(instance) {
- return findFiberByHostInstance ? findFiberByHostInstance(instance) : null;
- },
- findHostInstancesForRefresh: null,
- scheduleRefresh: null,
- scheduleRoot: null,
- setRefreshHandler: null,
- getCurrentFiber: null
- });
-})({
- findFiberByHostInstance: getInstanceFromInstance,
- bundleType: 0,
- version: "16.13.0",
- rendererPackageName: "react-native-renderer",
- rendererConfig: {
- getInspectorDataForViewTag: function() {
- throw Error(
- "getInspectorDataForViewTag() is not available in production"
- );
- },
- getInspectorDataForViewAtPoint: function() {
- throw Error(
- "getInspectorDataForViewAtPoint() is not available in production."
- );
- }.bind(null, findNodeHandle)
- }
-});
+var roots = new Map(),
+ devToolsConfig$jscomp$inline_913 = {
+ findFiberByHostInstance: getInstanceFromInstance,
+ bundleType: 0,
+ version: "17.0.0-alpha.0",
+ rendererPackageName: "react-native-renderer",
+ rendererConfig: {
+ getInspectorDataForViewTag: function() {
+ throw Error(
+ "getInspectorDataForViewTag() is not available in production"
+ );
+ },
+ getInspectorDataForViewAtPoint: function() {
+ throw Error(
+ "getInspectorDataForViewAtPoint() is not available in production."
+ );
+ }.bind(null, findNodeHandle)
+ }
+ };
+var internals$jscomp$inline_1111 = {
+ bundleType: devToolsConfig$jscomp$inline_913.bundleType,
+ version: devToolsConfig$jscomp$inline_913.version,
+ rendererPackageName: devToolsConfig$jscomp$inline_913.rendererPackageName,
+ rendererConfig: devToolsConfig$jscomp$inline_913.rendererConfig,
+ overrideHookState: null,
+ overrideProps: null,
+ setSuspenseHandler: null,
+ scheduleUpdate: null,
+ currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
+ findHostInstanceByFiber: function(fiber) {
+ fiber = findCurrentHostFiber(fiber);
+ return null === fiber ? null : fiber.stateNode;
+ },
+ findFiberByHostInstance:
+ devToolsConfig$jscomp$inline_913.findFiberByHostInstance ||
+ emptyFindFiberByHostInstance,
+ findHostInstancesForRefresh: null,
+ scheduleRefresh: null,
+ scheduleRoot: null,
+ setRefreshHandler: null,
+ getCurrentFiber: null
+};
+if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
+ var hook$jscomp$inline_1112 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ if (
+ !hook$jscomp$inline_1112.isDisabled &&
+ hook$jscomp$inline_1112.supportsFiber
+ )
+ try {
+ (rendererID = hook$jscomp$inline_1112.inject(
+ internals$jscomp$inline_1111
+ )),
+ (injectedHook = hook$jscomp$inline_1112);
+ } catch (err) {}
+}
exports.createPortal = function(children, containerTag) {
return createPortal(
children,
@@ -7696,12 +8073,17 @@ exports.render = function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
root = new FiberRootNode(containerTag, 0, !1);
- var uninitializedFiber = 0;
- isDevToolsPresent && (uninitializedFiber |= 8);
- uninitializedFiber = new FiberNode(3, null, null, uninitializedFiber);
- root.current = uninitializedFiber;
- uninitializedFiber.stateNode = root;
- initializeUpdateQueue(uninitializedFiber);
+ var JSCompiler_inline_result = 0;
+ isDevToolsPresent && (JSCompiler_inline_result |= 8);
+ JSCompiler_inline_result = createFiber(
+ 3,
+ null,
+ null,
+ JSCompiler_inline_result
+ );
+ root.current = JSCompiler_inline_result;
+ JSCompiler_inline_result.stateNode = root;
+ initializeUpdateQueue(JSCompiler_inline_result);
roots.set(containerTag, root);
}
updateContainer(element, root, null, callback);
diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js
index 8ef9be346094b2..73e4ee4fcce5da 100644
--- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js
+++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js
@@ -23,21 +23,7 @@ var Scheduler = require("scheduler");
var tracing = require("scheduler/tracing");
var ReactSharedInternals =
- React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
-// Current owner and dispatcher used to share the same ref,
-// but PR #14548 split them out to better support the react-debug-tools package.
-
-if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) {
- ReactSharedInternals.ReactCurrentDispatcher = {
- current: null
- };
-}
-
-if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) {
- ReactSharedInternals.ReactCurrentBatchConfig = {
- suspense: null
- };
-}
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// by calls to these methods by a Babel plugin.
//
@@ -79,19 +65,12 @@ function printWarning(level, format, args) {
// When changing this logic, you might want to also
// update consoleWithStackDev.www.js as well.
{
- var hasExistingStack =
- args.length > 0 &&
- typeof args[args.length - 1] === "string" &&
- args[args.length - 1].indexOf("\n in") === 0;
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
- if (!hasExistingStack) {
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
- var stack = ReactDebugCurrentFrame.getStackAddendum();
-
- if (stack !== "") {
- format += "%s";
- args = args.concat([stack]);
- }
+ if (stack !== "") {
+ format += "%s";
+ args = args.concat([stack]);
}
var argsWithFormat = args.map(function(item) {
@@ -103,161 +82,10 @@ function printWarning(level, format, args) {
// eslint-disable-next-line react-internal/no-production-logging
Function.prototype.apply.call(console[level], console, argsWithFormat);
-
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- var argIndex = 0;
- var message =
- "Warning: " +
- format.replace(/%s/g, function() {
- return args[argIndex++];
- });
- throw new Error(message);
- } catch (x) {}
- }
-}
-
-var FunctionComponent = 0;
-var ClassComponent = 1;
-var IndeterminateComponent = 2; // Before we know whether it is function or class
-
-var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
-
-var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
-
-var HostComponent = 5;
-var HostText = 6;
-var Fragment = 7;
-var Mode = 8;
-var ContextConsumer = 9;
-var ContextProvider = 10;
-var ForwardRef = 11;
-var Profiler = 12;
-var SuspenseComponent = 13;
-var MemoComponent = 14;
-var SimpleMemoComponent = 15;
-var LazyComponent = 16;
-var IncompleteClassComponent = 17;
-var DehydratedFragment = 18;
-var SuspenseListComponent = 19;
-var FundamentalComponent = 20;
-var ScopeComponent = 21;
-var Block = 22;
-
-function getParent(inst) {
- do {
- inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
- // That is depending on if we want nested subtrees (layers) to bubble
- // events to their parent. We could also go through parentNode on the
- // host node but that wouldn't work for React Native and doesn't let us
- // do the portal feature.
- } while (inst && inst.tag !== HostComponent);
-
- if (inst) {
- return inst;
- }
-
- return null;
-}
-/**
- * Return the lowest common ancestor of A and B, or null if they are in
- * different trees.
- */
-
-function getLowestCommonAncestor(instA, instB) {
- var depthA = 0;
-
- for (var tempA = instA; tempA; tempA = getParent(tempA)) {
- depthA++;
- }
-
- var depthB = 0;
-
- for (var tempB = instB; tempB; tempB = getParent(tempB)) {
- depthB++;
- } // If A is deeper, crawl up.
-
- while (depthA - depthB > 0) {
- instA = getParent(instA);
- depthA--;
- } // If B is deeper, crawl up.
-
- while (depthB - depthA > 0) {
- instB = getParent(instB);
- depthB--;
- } // Walk in lockstep until we find a match.
-
- var depth = depthA;
-
- while (depth--) {
- if (instA === instB || instA === instB.alternate) {
- return instA;
- }
-
- instA = getParent(instA);
- instB = getParent(instB);
- }
-
- return null;
-}
-/**
- * Return if A is an ancestor of B.
- */
-
-function isAncestor(instA, instB) {
- while (instB) {
- if (instA === instB || instA === instB.alternate) {
- return true;
- }
-
- instB = getParent(instB);
- }
-
- return false;
-}
-/**
- * Return the parent instance of the passed-in instance.
- */
-
-function getParentInstance(inst) {
- return getParent(inst);
-}
-/**
- * Simulates the traversal of a two-phase, capture/bubble event dispatch.
- */
-
-function traverseTwoPhase(inst, fn, arg) {
- var path = [];
-
- while (inst) {
- path.push(inst);
- inst = getParent(inst);
- }
-
- var i;
-
- for (i = path.length; i-- > 0; ) {
- fn(path[i], "captured", arg);
- }
-
- for (i = 0; i < path.length; i++) {
- fn(path[i], "bubbled", arg);
}
}
-var invokeGuardedCallbackImpl = function(
- name,
- func,
- context,
- a,
- b,
- c,
- d,
- e,
- f
-) {
+function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
var funcArgs = Array.prototype.slice.call(arguments, 3);
try {
@@ -265,7 +93,9 @@ var invokeGuardedCallbackImpl = function(
} catch (error) {
this.onError(error);
}
-};
+}
+
+var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
{
// In DEV mode, we swap out invokeGuardedCallback for a special version
@@ -296,7 +126,7 @@ var invokeGuardedCallbackImpl = function(
) {
var fakeNode = document.createElement("react");
- var invokeGuardedCallbackDev = function(
+ invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(
name,
func,
context,
@@ -317,7 +147,8 @@ var invokeGuardedCallbackImpl = function(
);
}
- var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We
+ var evt = document.createEvent("Event");
+ var didCall = false; // Keeps track of whether the user-provided callback threw an error. We
// set this to true at the beginning, then set it to false right after
// calling the function. If the function errors, `didError` will never be
// set to false. This strategy works even if the browser is flaky and
@@ -334,13 +165,9 @@ var invokeGuardedCallbackImpl = function(
var windowEventDescriptor = Object.getOwnPropertyDescriptor(
window,
"event"
- ); // Create an event handler for our fake event. We will synchronously
- // dispatch our fake event using `dispatchEvent`. Inside the handler, we
- // call the user-provided callback.
-
- var funcArgs = Array.prototype.slice.call(arguments, 3);
+ );
- function callCallback() {
+ function restoreAfterDispatch() {
// We immediately remove the callback from event listeners so that
// nested `invokeGuardedCallback` calls do not clash. Otherwise, a
// nested call would trigger the fake event handlers of any call higher
@@ -356,7 +183,15 @@ var invokeGuardedCallbackImpl = function(
) {
window.event = windowEvent;
}
+ } // Create an event handler for our fake event. We will synchronously
+ // dispatch our fake event using `dispatchEvent`. Inside the handler, we
+ // call the user-provided callback.
+
+ var funcArgs = Array.prototype.slice.call(arguments, 3);
+ function callCallback() {
+ didCall = true;
+ restoreAfterDispatch();
func.apply(context, funcArgs);
didError = false;
} // Create a global error event handler. We use this to capture the value
@@ -411,7 +246,7 @@ var invokeGuardedCallbackImpl = function(
Object.defineProperty(window, "event", windowEventDescriptor);
}
- if (didError) {
+ if (didCall && didError) {
if (!didSetError) {
// The callback errored, but the error event never fired.
error = new Error(
@@ -436,9 +271,16 @@ var invokeGuardedCallbackImpl = function(
} // Remove our event listeners
window.removeEventListener("error", handleWindowError);
- };
- invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
+ if (!didCall) {
+ // Something went really wrong, and our event was not dispatched.
+ // https://github.com/facebook/react/issues/16734
+ // https://github.com/facebook/react/issues/16585
+ // Fall back to the production implementation.
+ restoreAfterDispatch();
+ return invokeGuardedCallbackProd.apply(this, arguments);
+ }
+ };
}
}
@@ -707,293 +549,53 @@ function hasDispatches(event) {
return !!event._dispatchListeners;
}
-function isInteractive(tag) {
- return (
- tag === "button" ||
- tag === "input" ||
- tag === "select" ||
- tag === "textarea"
- );
-}
-
-function shouldPreventMouseEvent(name, type, props) {
- switch (name) {
- case "onClick":
- case "onClickCapture":
- case "onDoubleClick":
- case "onDoubleClickCapture":
- case "onMouseDown":
- case "onMouseDownCapture":
- case "onMouseMove":
- case "onMouseMoveCapture":
- case "onMouseUp":
- case "onMouseUpCapture":
- case "onMouseEnter":
- return !!(props.disabled && isInteractive(type));
-
- default:
- return false;
- }
-}
+var EVENT_POOL_SIZE = 10;
/**
- * @param {object} inst The instance, which is the source of events.
- * @param {string} registrationName Name of listener (e.g. `onClick`).
- * @return {?function} The stored callback.
+ * @interface Event
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
*/
-function getListener(inst, registrationName) {
- var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
- // live here; needs to be moved to a better place soon
-
- var stateNode = inst.stateNode;
-
- if (!stateNode) {
- // Work in progress (ex: onload events in incremental mode).
- return null;
- }
-
- var props = getFiberCurrentPropsFromNode(stateNode);
-
- if (!props) {
- // Work in progress.
- return null;
- }
-
- listener = props[registrationName];
-
- if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
+var EventInterface = {
+ type: null,
+ target: null,
+ // currentTarget is set when dispatching; no use in copying it here
+ currentTarget: function() {
return null;
- }
-
- if (!(!listener || typeof listener === "function")) {
- throw Error(
- "Expected `" +
- registrationName +
- "` listener to be a function, instead got a value of `" +
- typeof listener +
- "` type."
- );
- }
+ },
+ eventPhase: null,
+ bubbles: null,
+ cancelable: null,
+ timeStamp: function(event) {
+ return event.timeStamp || Date.now();
+ },
+ defaultPrevented: null,
+ isTrusted: null
+};
- return listener;
+function functionThatReturnsTrue() {
+ return true;
}
+function functionThatReturnsFalse() {
+ return false;
+}
/**
- * Accumulates items that must not be null or undefined into the first one. This
- * is used to conserve memory by avoiding array allocations, and thus sacrifices
- * API cleanness. Since `current` can be null before being passed in and not
- * null after this function, make sure to assign it back to `current`:
+ * Synthetic events are dispatched by event plugins, typically in response to a
+ * top-level event delegation handler.
*
- * `a = accumulateInto(a, b);`
+ * These systems should generally use pooling to reduce the frequency of garbage
+ * collection. The system should check `isPersistent` to determine whether the
+ * event should be released into the pool after being dispatched. Users that
+ * need a persisted event should invoke `persist`.
*
- * This API should be sparingly used. Try `accumulate` for something cleaner.
+ * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
+ * normalizing browser quirks. Subclasses do not necessarily have to implement a
+ * DOM interface; custom application-specific events can also subclass this.
*
- * @return {*|array<*>} An accumulation of items.
- */
-
-function accumulateInto(current, next) {
- if (!(next != null)) {
- throw Error(
- "accumulateInto(...): Accumulated items must not be null or undefined."
- );
- }
-
- if (current == null) {
- return next;
- } // Both are not empty. Warning: Never call x.concat(y) when you are not
- // certain that x is an Array (x could be a string with concat method).
-
- if (Array.isArray(current)) {
- if (Array.isArray(next)) {
- current.push.apply(current, next);
- return current;
- }
-
- current.push(next);
- return current;
- }
-
- if (Array.isArray(next)) {
- // A bit too dangerous to mutate `next`.
- return [current].concat(next);
- }
-
- return [current, next];
-}
-
-/**
- * @param {array} arr an "accumulation" of items which is either an Array or
- * a single item. Useful when paired with the `accumulate` module. This is a
- * simple utility that allows us to reason about a collection of items, but
- * handling the case when there is exactly one item (and we do not need to
- * allocate an array).
- * @param {function} cb Callback invoked with each element or a collection.
- * @param {?} [scope] Scope used as `this` in a callback.
- */
-function forEachAccumulated(arr, cb, scope) {
- if (Array.isArray(arr)) {
- arr.forEach(cb, scope);
- } else if (arr) {
- cb.call(scope, arr);
- }
-}
-
-/**
- * Some event types have a notion of different registration names for different
- * "phases" of propagation. This finds listeners by a given phase.
- */
-function listenerAtPhase(inst, event, propagationPhase) {
- var registrationName =
- event.dispatchConfig.phasedRegistrationNames[propagationPhase];
- return getListener(inst, registrationName);
-}
-/**
- * A small set of propagation patterns, each of which will accept a small amount
- * of information, and generate a set of "dispatch ready event objects" - which
- * are sets of events that have already been annotated with a set of dispatched
- * listener functions/ids. The API is designed this way to discourage these
- * propagation strategies from actually executing the dispatches, since we
- * always want to collect the entire set of dispatches before executing even a
- * single one.
- */
-
-/**
- * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
- * here, allows us to not have to bind or create functions for each event.
- * Mutating the event's members allows us to not have to create a wrapping
- * "dispatch" object that pairs the event with the listener.
- */
-
-function accumulateDirectionalDispatches(inst, phase, event) {
- {
- if (!inst) {
- error("Dispatching inst must not be null");
- }
- }
-
- var listener = listenerAtPhase(inst, event, phase);
-
- if (listener) {
- event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- );
- event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
- }
-}
-/**
- * Collect dispatches (must be entirely collected before dispatching - see unit
- * tests). Lazily allocate the array to conserve memory. We must loop through
- * each event and perform the traversal for each one. We cannot perform a
- * single traversal for the entire collection of events because each event may
- * have a different target.
- */
-
-function accumulateTwoPhaseDispatchesSingle(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
- }
-}
-/**
- * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
- */
-
-function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- var targetInst = event._targetInst;
- var parentInst = targetInst ? getParentInstance(targetInst) : null;
- traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
- }
-}
-/**
- * Accumulates without regard to direction, does not look for phased
- * registration names. Same as `accumulateDirectDispatchesSingle` but without
- * requiring that the `dispatchMarker` be the same as the dispatched ID.
- */
-
-function accumulateDispatches(inst, ignoredDirection, event) {
- if (inst && event && event.dispatchConfig.registrationName) {
- var registrationName = event.dispatchConfig.registrationName;
- var listener = getListener(inst, registrationName);
-
- if (listener) {
- event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- );
- event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
- }
- }
-}
-/**
- * Accumulates dispatches on an `SyntheticEvent`, but only for the
- * `dispatchMarker`.
- * @param {SyntheticEvent} event
- */
-
-function accumulateDirectDispatchesSingle(event) {
- if (event && event.dispatchConfig.registrationName) {
- accumulateDispatches(event._targetInst, null, event);
- }
-}
-
-function accumulateTwoPhaseDispatches(events) {
- forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
-}
-function accumulateTwoPhaseDispatchesSkipTarget(events) {
- forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
-}
-function accumulateDirectDispatches(events) {
- forEachAccumulated(events, accumulateDirectDispatchesSingle);
-}
-
-var EVENT_POOL_SIZE = 10;
-/**
- * @interface Event
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
- */
-
-var EventInterface = {
- type: null,
- target: null,
- // currentTarget is set when dispatching; no use in copying it here
- currentTarget: function() {
- return null;
- },
- eventPhase: null,
- bubbles: null,
- cancelable: null,
- timeStamp: function(event) {
- return event.timeStamp || Date.now();
- },
- defaultPrevented: null,
- isTrusted: null
-};
-
-function functionThatReturnsTrue() {
- return true;
-}
-
-function functionThatReturnsFalse() {
- return false;
-}
-/**
- * Synthetic events are dispatched by event plugins, typically in response to a
- * top-level event delegation handler.
- *
- * These systems should generally use pooling to reduce the frequency of garbage
- * collection. The system should check `isPersistent` to determine whether the
- * event should be released into the pool after being dispatched. Users that
- * need a persisted event should invoke `persist`.
- *
- * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
- * normalizing browser quirks. Subclasses do not necessarily have to implement a
- * DOM interface; custom application-specific events can also subclass this.
- *
- * @param {object} dispatchConfig Configuration used to dispatch this event.
- * @param {*} targetInst Marker identifying the event target.
- * @param {object} nativeEvent Native browser event.
- * @param {DOMEventTarget} nativeEventTarget Target node.
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
+ * @param {*} targetInst Marker identifying the event target.
+ * @param {object} nativeEvent Native browser event.
+ * @param {DOMEventTarget} nativeEventTarget Target node.
*/
function SyntheticEvent(
@@ -1014,6 +616,8 @@ function SyntheticEvent(
this.dispatchConfig = dispatchConfig;
this._targetInst = targetInst;
this.nativeEvent = nativeEvent;
+ this._dispatchListeners = null;
+ this._dispatchInstances = null;
var Interface = this.constructor.Interface;
for (var propName in Interface) {
@@ -1239,7 +843,12 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
}
}
-function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
+function createOrGetPooledEvent(
+ dispatchConfig,
+ targetInst,
+ nativeEvent,
+ nativeInst
+) {
var EventConstructor = this;
if (EventConstructor.eventPool.length) {
@@ -1279,8 +888,8 @@ function releasePooledEvent(event) {
}
function addEventPoolingTo(EventConstructor) {
+ EventConstructor.getPooled = createOrGetPooledEvent;
EventConstructor.eventPool = [];
- EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}
@@ -1546,63 +1155,152 @@ function accumulate(current, next) {
}
/**
- * Instance of element that should respond to touch/move types of interactions,
- * as indicated explicitly by relevant callbacks.
+ * Accumulates items that must not be null or undefined into the first one. This
+ * is used to conserve memory by avoiding array allocations, and thus sacrifices
+ * API cleanness. Since `current` can be null before being passed in and not
+ * null after this function, make sure to assign it back to `current`:
+ *
+ * `a = accumulateInto(a, b);`
+ *
+ * This API should be sparingly used. Try `accumulate` for something cleaner.
+ *
+ * @return {*|array<*>} An accumulation of items.
*/
-var responderInst = null;
-/**
- * Count of current touches. A textInput should become responder iff the
- * selection changes while there is a touch on the screen.
- */
+function accumulateInto(current, next) {
+ if (!(next != null)) {
+ throw Error(
+ "accumulateInto(...): Accumulated items must not be null or undefined."
+ );
+ }
-var trackedTouchCount = 0;
+ if (current == null) {
+ return next;
+ } // Both are not empty. Warning: Never call x.concat(y) when you are not
+ // certain that x is an Array (x could be a string with concat method).
-var changeResponder = function(nextResponderInst, blockHostResponder) {
- var oldResponderInst = responderInst;
- responderInst = nextResponderInst;
+ if (Array.isArray(current)) {
+ if (Array.isArray(next)) {
+ current.push.apply(current, next);
+ return current;
+ }
- if (ResponderEventPlugin.GlobalResponderHandler !== null) {
- ResponderEventPlugin.GlobalResponderHandler.onChange(
- oldResponderInst,
- nextResponderInst,
- blockHostResponder
- );
+ current.push(next);
+ return current;
}
-};
-var eventTypes = {
- /**
- * On a `touchStart`/`mouseDown`, is it desired that this element become the
- * responder?
- */
- startShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onStartShouldSetResponder",
- captured: "onStartShouldSetResponderCapture"
- },
- dependencies: startDependencies
- },
+ if (Array.isArray(next)) {
+ // A bit too dangerous to mutate `next`.
+ return [current].concat(next);
+ }
- /**
- * On a `scroll`, is it desired that this element become the responder? This
- * is usually not needed, but should be used to retroactively infer that a
- * `touchStart` had occurred during momentum scroll. During a momentum scroll,
- * a touch start will be immediately followed by a scroll event if the view is
- * currently scrolling.
- *
- * TODO: This shouldn't bubble.
- */
- scrollShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onScrollShouldSetResponder",
- captured: "onScrollShouldSetResponderCapture"
- },
- dependencies: [TOP_SCROLL]
- },
+ return [current, next];
+}
- /**
- * On text selection change, should this element become the responder? This
+/**
+ * @param {array} arr an "accumulation" of items which is either an Array or
+ * a single item. Useful when paired with the `accumulate` module. This is a
+ * simple utility that allows us to reason about a collection of items, but
+ * handling the case when there is exactly one item (and we do not need to
+ * allocate an array).
+ * @param {function} cb Callback invoked with each element or a collection.
+ * @param {?} [scope] Scope used as `this` in a callback.
+ */
+function forEachAccumulated(arr, cb, scope) {
+ if (Array.isArray(arr)) {
+ arr.forEach(cb, scope);
+ } else if (arr) {
+ cb.call(scope, arr);
+ }
+}
+
+var FunctionComponent = 0;
+var ClassComponent = 1;
+var IndeterminateComponent = 2; // Before we know whether it is function or class
+
+var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
+
+var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
+
+var HostComponent = 5;
+var HostText = 6;
+var Fragment = 7;
+var Mode = 8;
+var ContextConsumer = 9;
+var ContextProvider = 10;
+var ForwardRef = 11;
+var Profiler = 12;
+var SuspenseComponent = 13;
+var MemoComponent = 14;
+var SimpleMemoComponent = 15;
+var LazyComponent = 16;
+var IncompleteClassComponent = 17;
+var DehydratedFragment = 18;
+var SuspenseListComponent = 19;
+var FundamentalComponent = 20;
+var ScopeComponent = 21;
+var Block = 22;
+var OffscreenComponent = 23;
+var LegacyHiddenComponent = 24;
+
+/**
+ * Instance of element that should respond to touch/move types of interactions,
+ * as indicated explicitly by relevant callbacks.
+ */
+
+var responderInst = null;
+/**
+ * Count of current touches. A textInput should become responder iff the
+ * selection changes while there is a touch on the screen.
+ */
+
+var trackedTouchCount = 0;
+
+var changeResponder = function(nextResponderInst, blockHostResponder) {
+ var oldResponderInst = responderInst;
+ responderInst = nextResponderInst;
+
+ if (ResponderEventPlugin.GlobalResponderHandler !== null) {
+ ResponderEventPlugin.GlobalResponderHandler.onChange(
+ oldResponderInst,
+ nextResponderInst,
+ blockHostResponder
+ );
+ }
+};
+
+var eventTypes = {
+ /**
+ * On a `touchStart`/`mouseDown`, is it desired that this element become the
+ * responder?
+ */
+ startShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onStartShouldSetResponder",
+ captured: "onStartShouldSetResponderCapture"
+ },
+ dependencies: startDependencies
+ },
+
+ /**
+ * On a `scroll`, is it desired that this element become the responder? This
+ * is usually not needed, but should be used to retroactively infer that a
+ * `touchStart` had occurred during momentum scroll. During a momentum scroll,
+ * a touch start will be immediately followed by a scroll event if the view is
+ * currently scrolling.
+ *
+ * TODO: This shouldn't bubble.
+ */
+ scrollShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onScrollShouldSetResponder",
+ captured: "onScrollShouldSetResponderCapture"
+ },
+ dependencies: [TOP_SCROLL]
+ },
+
+ /**
+ * On text selection change, should this element become the responder? This
* is needed for text inputs or other views with native selection, so the
* JS view can claim the responder.
*
@@ -1663,144 +1361,352 @@ var eventTypes = {
registrationName: "onResponderTerminate",
dependencies: []
}
-};
+}; // Start of inline: the below functions were inlined from
+// EventPropagator.js, as they deviated from ReactDOM's newer
+// implementations.
+
+function getParent(inst) {
+ do {
+ inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
+ // That is depending on if we want nested subtrees (layers) to bubble
+ // events to their parent. We could also go through parentNode on the
+ // host node but that wouldn't work for React Native and doesn't let us
+ // do the portal feature.
+ } while (inst && inst.tag !== HostComponent);
+
+ if (inst) {
+ return inst;
+ }
+
+ return null;
+}
/**
- *
- * Responder System:
- * ----------------
- *
- * - A global, solitary "interaction lock" on a view.
- * - If a node becomes the responder, it should convey visual feedback
- * immediately to indicate so, either by highlighting or moving accordingly.
- * - To be the responder means, that touches are exclusively important to that
- * responder view, and no other view.
- * - While touches are still occurring, the responder lock can be transferred to
- * a new view, but only to increasingly "higher" views (meaning ancestors of
- * the current responder).
- *
- * Responder being granted:
- * ------------------------
- *
- * - Touch starts, moves, and scrolls can cause an ID to become the responder.
- * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to
- * the "appropriate place".
- * - If nothing is currently the responder, the "appropriate place" is the
- * initiating event's `targetID`.
- * - If something *is* already the responder, the "appropriate place" is the
- * first common ancestor of the event target and the current `responderInst`.
- * - Some negotiation happens: See the timing diagram below.
- * - Scrolled views automatically become responder. The reasoning is that a
- * platform scroll view that isn't built on top of the responder system has
- * began scrolling, and the active responder must now be notified that the
- * interaction is no longer locked to it - the system has taken over.
- *
- * - Responder being released:
- * As soon as no more touches that *started* inside of descendants of the
- * *current* responderInst, an `onResponderRelease` event is dispatched to the
- * current responder, and the responder lock is released.
- *
- * TODO:
- * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that
- * determines if the responder lock should remain.
- * - If a view shouldn't "remain" the responder, any active touches should by
- * default be considered "dead" and do not influence future negotiations or
- * bubble paths. It should be as if those touches do not exist.
- * -- For multitouch: Usually a translate-z will choose to "remain" responder
- * after one out of many touches ended. For translate-y, usually the view
- * doesn't wish to "remain" responder after one of many touches end.
- * - Consider building this on top of a `stopPropagation` model similar to
- * `W3C` events.
- * - Ensure that `onResponderTerminate` is called on touch cancels, whether or
- * not `onResponderTerminationRequest` returns `true` or `false`.
- *
+ * Return the lowest common ancestor of A and B, or null if they are in
+ * different trees.
*/
-/* Negotiation Performed
- +-----------------------+
- / \
-Process low level events to + Current Responder + wantsResponderID
-determine who to perform negot-| (if any exists at all) |
-iation/transition | Otherwise just pass through|
--------------------------------+----------------------------+------------------+
-Bubble to find first ID | |
-to return true:wantsResponderID| |
- | |
- +-------------+ | |
- | onTouchStart| | |
- +------+------+ none | |
- | return| |
-+-----------v-------------+true| +------------------------+ |
-|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+
-+-----------+-------------+ | +------------------------+ | |
- | | | +--------+-------+
- | returned true for| false:REJECT +-------->|onResponderReject
- | wantsResponderID | | | +----------------+
- | (now attempt | +------------------+-----+ |
- | handoff) | | onResponder | |
- +------------------->| TerminationRequest| |
- | +------------------+-----+ |
- | | | +----------------+
- | true:GRANT +-------->|onResponderGrant|
- | | +--------+-------+
- | +------------------------+ | |
- | | onResponderTerminate |<-----------+
- | +------------------+-----+ |
- | | | +----------------+
- | +-------->|onResponderStart|
- | | +----------------+
-Bubble to find first ID | |
-to return true:wantsResponderID| |
- | |
- +-------------+ | |
- | onTouchMove | | |
- +------+------+ none | |
- | return| |
-+-----------v-------------+true| +------------------------+ |
-|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+
-+-----------+-------------+ | +------------------------+ | |
- | | | +--------+-------+
- | returned true for| false:REJECT +-------->|onResponderRejec|
- | wantsResponderID | | | +----------------+
- | (now attempt | +------------------+-----+ |
- | handoff) | | onResponder | |
- +------------------->| TerminationRequest| |
- | +------------------+-----+ |
- | | | +----------------+
- | true:GRANT +-------->|onResponderGrant|
- | | +--------+-------+
- | +------------------------+ | |
- | | onResponderTerminate |<-----------+
- | +------------------+-----+ |
- | | | +----------------+
- | +-------->|onResponderMove |
- | | +----------------+
- | |
- | |
- Some active touch started| |
- inside current responder | +------------------------+ |
- +------------------------->| onResponderEnd | |
- | | +------------------------+ |
- +---+---------+ | |
- | onTouchEnd | | |
- +---+---------+ | |
- | | +------------------------+ |
- +------------------------->| onResponderEnd | |
- No active touches started| +-----------+------------+ |
- inside current responder | | |
- | v |
- | +------------------------+ |
- | | onResponderRelease | |
- | +------------------------+ |
- | |
- + + */
+function getLowestCommonAncestor(instA, instB) {
+ var depthA = 0;
-/**
- * A note about event ordering in the `EventPluginRegistry`.
- *
- * Suppose plugins are injected in the following order:
- *
- * `[R, S, C]`
- *
+ for (var tempA = instA; tempA; tempA = getParent(tempA)) {
+ depthA++;
+ }
+
+ var depthB = 0;
+
+ for (var tempB = instB; tempB; tempB = getParent(tempB)) {
+ depthB++;
+ } // If A is deeper, crawl up.
+
+ while (depthA - depthB > 0) {
+ instA = getParent(instA);
+ depthA--;
+ } // If B is deeper, crawl up.
+
+ while (depthB - depthA > 0) {
+ instB = getParent(instB);
+ depthB--;
+ } // Walk in lockstep until we find a match.
+
+ var depth = depthA;
+
+ while (depth--) {
+ if (instA === instB || instA === instB.alternate) {
+ return instA;
+ }
+
+ instA = getParent(instA);
+ instB = getParent(instB);
+ }
+
+ return null;
+}
+/**
+ * Return if A is an ancestor of B.
+ */
+
+function isAncestor(instA, instB) {
+ while (instB) {
+ if (instA === instB || instA === instB.alternate) {
+ return true;
+ }
+
+ instB = getParent(instB);
+ }
+
+ return false;
+}
+/**
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
+ */
+
+function traverseTwoPhase(inst, fn, arg) {
+ var path = [];
+
+ while (inst) {
+ path.push(inst);
+ inst = getParent(inst);
+ }
+
+ var i;
+
+ for (i = path.length; i-- > 0; ) {
+ fn(path[i], "captured", arg);
+ }
+
+ for (i = 0; i < path.length; i++) {
+ fn(path[i], "bubbled", arg);
+ }
+}
+
+function getListener(inst, registrationName) {
+ var stateNode = inst.stateNode;
+
+ if (stateNode === null) {
+ // Work in progress (ex: onload events in incremental mode).
+ return null;
+ }
+
+ var props = getFiberCurrentPropsFromNode(stateNode);
+
+ if (props === null) {
+ // Work in progress.
+ return null;
+ }
+
+ var listener = props[registrationName];
+
+ if (!(!listener || typeof listener === "function")) {
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof listener +
+ "` type."
+ );
+ }
+
+ return listener;
+}
+
+function listenerAtPhase(inst, event, propagationPhase) {
+ var registrationName =
+ event.dispatchConfig.phasedRegistrationNames[propagationPhase];
+ return getListener(inst, registrationName);
+}
+
+function accumulateDirectionalDispatches(inst, phase, event) {
+ {
+ if (!inst) {
+ error("Dispatching inst must not be null");
+ }
+ }
+
+ var listener = listenerAtPhase(inst, event, phase);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
+ }
+}
+/**
+ * Accumulates without regard to direction, does not look for phased
+ * registration names. Same as `accumulateDirectDispatchesSingle` but without
+ * requiring that the `dispatchMarker` be the same as the dispatched ID.
+ */
+
+function accumulateDispatches(inst, ignoredDirection, event) {
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var registrationName = event.dispatchConfig.registrationName;
+ var listener = getListener(inst, registrationName);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
+ }
+ }
+}
+/**
+ * Accumulates dispatches on an `SyntheticEvent`, but only for the
+ * `dispatchMarker`.
+ * @param {SyntheticEvent} event
+ */
+
+function accumulateDirectDispatchesSingle(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ accumulateDispatches(event._targetInst, null, event);
+ }
+}
+
+function accumulateDirectDispatches(events) {
+ forEachAccumulated(events, accumulateDirectDispatchesSingle);
+}
+
+function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ var targetInst = event._targetInst;
+ var parentInst = targetInst ? getParent(targetInst) : null;
+ traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
+ }
+}
+
+function accumulateTwoPhaseDispatchesSkipTarget(events) {
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
+}
+
+function accumulateTwoPhaseDispatchesSingle(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
+ }
+}
+
+function accumulateTwoPhaseDispatches(events) {
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
+} // End of inline
+
+/**
+ *
+ * Responder System:
+ * ----------------
+ *
+ * - A global, solitary "interaction lock" on a view.
+ * - If a node becomes the responder, it should convey visual feedback
+ * immediately to indicate so, either by highlighting or moving accordingly.
+ * - To be the responder means, that touches are exclusively important to that
+ * responder view, and no other view.
+ * - While touches are still occurring, the responder lock can be transferred to
+ * a new view, but only to increasingly "higher" views (meaning ancestors of
+ * the current responder).
+ *
+ * Responder being granted:
+ * ------------------------
+ *
+ * - Touch starts, moves, and scrolls can cause an ID to become the responder.
+ * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to
+ * the "appropriate place".
+ * - If nothing is currently the responder, the "appropriate place" is the
+ * initiating event's `targetID`.
+ * - If something *is* already the responder, the "appropriate place" is the
+ * first common ancestor of the event target and the current `responderInst`.
+ * - Some negotiation happens: See the timing diagram below.
+ * - Scrolled views automatically become responder. The reasoning is that a
+ * platform scroll view that isn't built on top of the responder system has
+ * began scrolling, and the active responder must now be notified that the
+ * interaction is no longer locked to it - the system has taken over.
+ *
+ * - Responder being released:
+ * As soon as no more touches that *started* inside of descendants of the
+ * *current* responderInst, an `onResponderRelease` event is dispatched to the
+ * current responder, and the responder lock is released.
+ *
+ * TODO:
+ * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that
+ * determines if the responder lock should remain.
+ * - If a view shouldn't "remain" the responder, any active touches should by
+ * default be considered "dead" and do not influence future negotiations or
+ * bubble paths. It should be as if those touches do not exist.
+ * -- For multitouch: Usually a translate-z will choose to "remain" responder
+ * after one out of many touches ended. For translate-y, usually the view
+ * doesn't wish to "remain" responder after one of many touches end.
+ * - Consider building this on top of a `stopPropagation` model similar to
+ * `W3C` events.
+ * - Ensure that `onResponderTerminate` is called on touch cancels, whether or
+ * not `onResponderTerminationRequest` returns `true` or `false`.
+ *
+ */
+
+/* Negotiation Performed
+ +-----------------------+
+ / \
+Process low level events to + Current Responder + wantsResponderID
+determine who to perform negot-| (if any exists at all) |
+iation/transition | Otherwise just pass through|
+-------------------------------+----------------------------+------------------+
+Bubble to find first ID | |
+to return true:wantsResponderID| |
+ | |
+ +-------------+ | |
+ | onTouchStart| | |
+ +------+------+ none | |
+ | return| |
++-----------v-------------+true| +------------------------+ |
+|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+
++-----------+-------------+ | +------------------------+ | |
+ | | | +--------+-------+
+ | returned true for| false:REJECT +-------->|onResponderReject
+ | wantsResponderID | | | +----------------+
+ | (now attempt | +------------------+-----+ |
+ | handoff) | | onResponder | |
+ +------------------->| TerminationRequest| |
+ | +------------------+-----+ |
+ | | | +----------------+
+ | true:GRANT +-------->|onResponderGrant|
+ | | +--------+-------+
+ | +------------------------+ | |
+ | | onResponderTerminate |<-----------+
+ | +------------------+-----+ |
+ | | | +----------------+
+ | +-------->|onResponderStart|
+ | | +----------------+
+Bubble to find first ID | |
+to return true:wantsResponderID| |
+ | |
+ +-------------+ | |
+ | onTouchMove | | |
+ +------+------+ none | |
+ | return| |
++-----------v-------------+true| +------------------------+ |
+|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+
++-----------+-------------+ | +------------------------+ | |
+ | | | +--------+-------+
+ | returned true for| false:REJECT +-------->|onResponderRejec|
+ | wantsResponderID | | | +----------------+
+ | (now attempt | +------------------+-----+ |
+ | handoff) | | onResponder | |
+ +------------------->| TerminationRequest| |
+ | +------------------+-----+ |
+ | | | +----------------+
+ | true:GRANT +-------->|onResponderGrant|
+ | | +--------+-------+
+ | +------------------------+ | |
+ | | onResponderTerminate |<-----------+
+ | +------------------+-----+ |
+ | | | +----------------+
+ | +-------->|onResponderMove |
+ | | +----------------+
+ | |
+ | |
+ Some active touch started| |
+ inside current responder | +------------------------+ |
+ +------------------------->| onResponderEnd | |
+ | | +------------------------+ |
+ +---+---------+ | |
+ | onTouchEnd | | |
+ +---+---------+ | |
+ | | +------------------------+ |
+ +------------------------->| onResponderEnd | |
+ No active touches started| +-----------+------------+ |
+ inside current responder | | |
+ | v |
+ | +------------------------+ |
+ | | onResponderRelease | |
+ | +------------------------+ |
+ | |
+ + + */
+
+/**
+ * A note about event ordering in the `EventPluginRegistry`.
+ *
+ * Suppose plugins are injected in the following order:
+ *
+ * `[R, S, C]`
+ *
* To help illustrate the example, assume `S` is `SimpleEventPlugin` (for
* `onClick` etc) and `R` is `ResponderEventPlugin`.
*
@@ -2306,65 +2212,208 @@ function injectEventPluginOrder(injectedEventPluginOrder) {
);
} // Clone the ordering so it cannot be dynamically mutated.
- eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
- recomputePluginOrdering();
+ eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
+ recomputePluginOrdering();
+}
+/**
+ * Injects plugins to be used by plugin event system. The plugin names must be
+ * in the ordering injected by `injectEventPluginOrder`.
+ *
+ * Plugins can be injected as part of page initialization or on-the-fly.
+ *
+ * @param {object} injectedNamesToPlugins Map from names to plugin modules.
+ * @internal
+ */
+
+function injectEventPluginsByName(injectedNamesToPlugins) {
+ var isOrderingDirty = false;
+
+ for (var pluginName in injectedNamesToPlugins) {
+ if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
+ continue;
+ }
+
+ var pluginModule = injectedNamesToPlugins[pluginName];
+
+ if (
+ !namesToPlugins.hasOwnProperty(pluginName) ||
+ namesToPlugins[pluginName] !== pluginModule
+ ) {
+ if (!!namesToPlugins[pluginName]) {
+ throw Error(
+ "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
+ pluginName +
+ "`."
+ );
+ }
+
+ namesToPlugins[pluginName] = pluginModule;
+ isOrderingDirty = true;
+ }
+ }
+
+ if (isOrderingDirty) {
+ recomputePluginOrdering();
+ }
+}
+
+function getListener$1(inst, registrationName) {
+ var stateNode = inst.stateNode;
+
+ if (stateNode === null) {
+ // Work in progress (ex: onload events in incremental mode).
+ return null;
+ }
+
+ var props = getFiberCurrentPropsFromNode(stateNode);
+
+ if (props === null) {
+ // Work in progress.
+ return null;
+ }
+
+ var listener = props[registrationName];
+
+ if (!(!listener || typeof listener === "function")) {
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof listener +
+ "` type."
+ );
+ }
+
+ return listener;
+}
+
+var customBubblingEventTypes =
+ ReactNativePrivateInterface.ReactNativeViewConfigRegistry
+ .customBubblingEventTypes,
+ customDirectEventTypes =
+ ReactNativePrivateInterface.ReactNativeViewConfigRegistry
+ .customDirectEventTypes; // Start of inline: the below functions were inlined from
+// EventPropagator.js, as they deviated from ReactDOM's newer
+// implementations.
+
+function listenerAtPhase$1(inst, event, propagationPhase) {
+ var registrationName =
+ event.dispatchConfig.phasedRegistrationNames[propagationPhase];
+ return getListener$1(inst, registrationName);
+}
+
+function accumulateDirectionalDispatches$1(inst, phase, event) {
+ {
+ if (!inst) {
+ error("Dispatching inst must not be null");
+ }
+ }
+
+ var listener = listenerAtPhase$1(inst, event, phase);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
+ }
+}
+
+function getParent$1(inst) {
+ do {
+ inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
+ // That is depending on if we want nested subtrees (layers) to bubble
+ // events to their parent. We could also go through parentNode on the
+ // host node but that wouldn't work for React Native and doesn't let us
+ // do the portal feature.
+ } while (inst && inst.tag !== HostComponent);
+
+ if (inst) {
+ return inst;
+ }
+
+ return null;
}
/**
- * Injects plugins to be used by plugin event system. The plugin names must be
- * in the ordering injected by `injectEventPluginOrder`.
- *
- * Plugins can be injected as part of page initialization or on-the-fly.
- *
- * @param {object} injectedNamesToPlugins Map from names to plugin modules.
- * @internal
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
*/
-function injectEventPluginsByName(injectedNamesToPlugins) {
- var isOrderingDirty = false;
+function traverseTwoPhase$1(inst, fn, arg) {
+ var path = [];
- for (var pluginName in injectedNamesToPlugins) {
- if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
- continue;
- }
+ while (inst) {
+ path.push(inst);
+ inst = getParent$1(inst);
+ }
- var pluginModule = injectedNamesToPlugins[pluginName];
+ var i;
- if (
- !namesToPlugins.hasOwnProperty(pluginName) ||
- namesToPlugins[pluginName] !== pluginModule
- ) {
- if (!!namesToPlugins[pluginName]) {
- throw Error(
- "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName +
- "`."
- );
- }
+ for (i = path.length; i-- > 0; ) {
+ fn(path[i], "captured", arg);
+ }
- namesToPlugins[pluginName] = pluginModule;
- isOrderingDirty = true;
+ for (i = 0; i < path.length; i++) {
+ fn(path[i], "bubbled", arg);
+ }
+}
+
+function accumulateTwoPhaseDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event
+ );
+ }
+}
+
+function accumulateTwoPhaseDispatches$1(events) {
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1);
+}
+/**
+ * Accumulates without regard to direction, does not look for phased
+ * registration names. Same as `accumulateDirectDispatchesSingle` but without
+ * requiring that the `dispatchMarker` be the same as the dispatched ID.
+ */
+
+function accumulateDispatches$1(inst, ignoredDirection, event) {
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var registrationName = event.dispatchConfig.registrationName;
+ var listener = getListener$1(inst, registrationName);
+
+ if (listener) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ );
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
}
}
+}
+/**
+ * Accumulates dispatches on an `SyntheticEvent`, but only for the
+ * `dispatchMarker`.
+ * @param {SyntheticEvent} event
+ */
- if (isOrderingDirty) {
- recomputePluginOrdering();
+function accumulateDirectDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ accumulateDispatches$1(event._targetInst, null, event);
}
}
-var customBubblingEventTypes =
- ReactNativePrivateInterface.ReactNativeViewConfigRegistry
- .customBubblingEventTypes,
- customDirectEventTypes =
- ReactNativePrivateInterface.ReactNativeViewConfigRegistry
- .customDirectEventTypes;
+function accumulateDirectDispatches$1(events) {
+ forEachAccumulated(events, accumulateDirectDispatchesSingle$1);
+} // End of inline
+
var ReactNativeBridgeEventPlugin = {
eventTypes: {},
extractEvents: function(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
) {
if (targetInst == null) {
// Probably a node belonging to another renderer's tree.
@@ -2388,9 +2437,9 @@ var ReactNativeBridgeEventPlugin = {
);
if (bubbleDispatchConfig) {
- accumulateTwoPhaseDispatches(event);
+ accumulateTwoPhaseDispatches$1(event);
} else if (directDispatchConfig) {
- accumulateDirectDispatches(event);
+ accumulateDirectDispatches$1(event);
} else {
return null;
}
@@ -2461,23 +2510,16 @@ function updateFiberProps(tag, props) {
instanceProps.set(tag, props);
}
-var PLUGIN_EVENT_SYSTEM = 1;
-
-var enableProfilerTimer = true;
-var enableFundamentalAPI = false;
-var warnAboutStringRefs = false;
-
+// Used as a way to call batchedUpdates when we don't have a reference to
// the renderer. Such as when we're dispatching events or if third party
// libraries need to call batchedUpdates. Eventually, this API will go away when
// everything is batched by default. We'll then have a similar API to opt-out of
// scheduled work and instead do synchronous work.
// Defaults
-
var batchedUpdatesImpl = function(fn, bookkeeping) {
return fn(bookkeeping);
};
var isInsideEventHandler = false;
-
function batchedUpdates(fn, bookkeeping) {
if (isInsideEventHandler) {
// If we are currently inside another batch, we need to wait until it
@@ -2635,13 +2677,7 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) {
}
batchedUpdates(function() {
- runExtractedPluginEventsInBatch(
- topLevelType,
- inst,
- nativeEvent,
- target,
- PLUGIN_EVENT_SYSTEM
- );
+ runExtractedPluginEventsInBatch(topLevelType, inst, nativeEvent, target);
}); // React Native doesn't use ReactControlledComponent but if it did, here's
// where it would do it.
}
@@ -2657,22 +2693,21 @@ function extractPluginEvents(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
) {
var events = null;
+ var legacyPlugins = plugins;
- for (var i = 0; i < plugins.length; i++) {
+ for (var i = 0; i < legacyPlugins.length; i++) {
// Not every plugin in the ordering may be loaded at runtime.
- var possiblePlugin = plugins[i];
+ var possiblePlugin = legacyPlugins[i];
if (possiblePlugin) {
var extractedEvents = possiblePlugin.extractEvents(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
);
if (extractedEvents) {
@@ -2688,15 +2723,13 @@ function runExtractedPluginEventsInBatch(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
) {
var events = extractPluginEvents(
topLevelType,
targetInst,
nativeEvent,
- nativeEventTarget,
- eventSystemFlags
+ nativeEventTarget
);
runEventsInBatch(events);
}
@@ -2809,37 +2842,64 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler(
* If this becomes an actual Map, that will break.
*/
function get(key) {
- return key._reactInternalFiber;
+ return key._reactInternals;
}
function set(key, value) {
- key._reactInternalFiber = value;
+ key._reactInternals = value;
}
+// ATTENTION
+// When adding new symbols to this file,
+// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
-var hasSymbol = typeof Symbol === "function" && Symbol.for;
-var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7;
-var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca;
-var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb;
-var REACT_STRICT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.strict_mode")
- : 0xeacc;
-var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2;
-var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd;
-var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
-var REACT_CONCURRENT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.concurrent_mode")
- : 0xeacf;
-var REACT_FORWARD_REF_TYPE = hasSymbol
- ? Symbol.for("react.forward_ref")
- : 0xead0;
-var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1;
-var REACT_SUSPENSE_LIST_TYPE = hasSymbol
- ? Symbol.for("react.suspense_list")
- : 0xead8;
-var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3;
-var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4;
-var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 0xead9;
+var REACT_ELEMENT_TYPE = 0xeac7;
+var REACT_PORTAL_TYPE = 0xeaca;
+var REACT_FRAGMENT_TYPE = 0xeacb;
+var REACT_STRICT_MODE_TYPE = 0xeacc;
+var REACT_PROFILER_TYPE = 0xead2;
+var REACT_PROVIDER_TYPE = 0xeacd;
+var REACT_CONTEXT_TYPE = 0xeace;
+var REACT_FORWARD_REF_TYPE = 0xead0;
+var REACT_SUSPENSE_TYPE = 0xead1;
+var REACT_SUSPENSE_LIST_TYPE = 0xead8;
+var REACT_MEMO_TYPE = 0xead3;
+var REACT_LAZY_TYPE = 0xead4;
+var REACT_BLOCK_TYPE = 0xead9;
+var REACT_SERVER_BLOCK_TYPE = 0xeada;
+var REACT_FUNDAMENTAL_TYPE = 0xead5;
+var REACT_RESPONDER_TYPE = 0xead6;
+var REACT_SCOPE_TYPE = 0xead7;
+var REACT_OPAQUE_ID_TYPE = 0xeae0;
+var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
+var REACT_OFFSCREEN_TYPE = 0xeae2;
+var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
+
+if (typeof Symbol === "function" && Symbol.for) {
+ var symbolFor = Symbol.for;
+ REACT_ELEMENT_TYPE = symbolFor("react.element");
+ REACT_PORTAL_TYPE = symbolFor("react.portal");
+ REACT_FRAGMENT_TYPE = symbolFor("react.fragment");
+ REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
+ REACT_PROFILER_TYPE = symbolFor("react.profiler");
+ REACT_PROVIDER_TYPE = symbolFor("react.provider");
+ REACT_CONTEXT_TYPE = symbolFor("react.context");
+ REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
+ REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
+ REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
+ REACT_MEMO_TYPE = symbolFor("react.memo");
+ REACT_LAZY_TYPE = symbolFor("react.lazy");
+ REACT_BLOCK_TYPE = symbolFor("react.block");
+ REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block");
+ REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental");
+ REACT_RESPONDER_TYPE = symbolFor("react.responder");
+ REACT_SCOPE_TYPE = symbolFor("react.scope");
+ REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id");
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
+ REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
+}
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
function getIteratorFn(maybeIterable) {
@@ -2858,63 +2918,6 @@ function getIteratorFn(maybeIterable) {
return null;
}
-// TODO: Move this to "react" once we can import from externals.
-var Uninitialized = -1;
-var Pending = 0;
-var Resolved = 1;
-var Rejected = 2;
-
-function refineResolvedLazyComponent(lazyComponent) {
- return lazyComponent._status === Resolved ? lazyComponent._result : null;
-}
-function initializeLazyComponentType(lazyComponent) {
- if (lazyComponent._status === Uninitialized) {
- var ctor = lazyComponent._result;
-
- if (!ctor) {
- // TODO: Remove this later. THis only exists in case you use an older "react" package.
- ctor = lazyComponent._ctor;
- }
-
- var thenable = ctor(); // Transition to the next state.
-
- var pending = lazyComponent;
- pending._status = Pending;
- pending._result = thenable;
- thenable.then(
- function(moduleObject) {
- if (lazyComponent._status === Pending) {
- var defaultExport = moduleObject.default;
-
- {
- if (defaultExport === undefined) {
- error(
- "lazy: Expected the result of a dynamic import() call. " +
- "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies.
- "const MyComponent = lazy(() => imp" +
- "ort('./MyComponent'))",
- moduleObject
- );
- }
- } // Transition to the next state.
-
- var resolved = lazyComponent;
- resolved._status = Resolved;
- resolved._result = defaultExport;
- }
- },
- function(error) {
- if (lazyComponent._status === Pending) {
- // Transition to the next state.
- var rejected = lazyComponent;
- rejected._status = Rejected;
- rejected._result = error;
- }
- }
- );
- }
-}
-
function getWrappedName(outerType, innerType, wrapperName) {
var functionName = innerType.displayName || innerType.name || "";
return (
@@ -2987,17 +2990,18 @@ function getComponentName(type) {
return getComponentName(type.type);
case REACT_BLOCK_TYPE:
- return getComponentName(type.render);
+ return getComponentName(type._render);
case REACT_LAZY_TYPE: {
- var thenable = type;
- var resolvedThenable = refineResolvedLazyComponent(thenable);
+ var lazyComponent = type;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- if (resolvedThenable) {
- return getComponentName(resolvedThenable);
+ try {
+ return getComponentName(init(payload));
+ } catch (x) {
+ return null;
}
-
- break;
}
}
}
@@ -3007,62 +3011,76 @@ function getComponentName(type) {
// Don't change these two values. They're used by React Dev Tools.
var NoEffect =
- /* */
+ /* */
0;
var PerformedWork =
- /* */
+ /* */
1; // You can change the rest (and add more).
var Placement =
- /* */
+ /* */
2;
var Update =
- /* */
+ /* */
4;
var PlacementAndUpdate =
- /* */
+ /* */
6;
var Deletion =
- /* */
+ /* */
8;
var ContentReset =
- /* */
+ /* */
16;
var Callback =
- /* */
+ /* */
32;
var DidCapture =
- /* */
+ /* */
64;
var Ref =
- /* */
+ /* */
128;
var Snapshot =
- /* */
+ /* */
256;
var Passive =
- /* */
- 512;
+ /* */
+ 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old.
+
+var PassiveUnmountPendingDev =
+ /* */
+ 8192;
var Hydrating =
- /* */
+ /* */
1024;
var HydratingAndUpdate =
- /* */
+ /* */
1028; // Passive & Update & Callback & Ref & Snapshot
var LifecycleEffectMask =
- /* */
+ /* */
932; // Union of all host effects
var HostEffectMask =
- /* */
- 2047;
+ /* */
+ 2047; // These are not really side effects, but we still reuse this field.
+
var Incomplete =
- /* */
+ /* */
2048;
var ShouldCapture =
- /* */
+ /* */
4096;
+var ForceUpdateForLegacySuspense =
+ /* */
+ 16384; // Static tags describe aspects of a fiber that are not specific to a render,
+
+// The rest of the flags are static for better dead code elimination.
+var enableProfilerTimer = true;
+var enableFundamentalAPI = false;
+var warnAboutStringRefs = false;
+var enableNewReconciler = false;
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
function getNearestMountedFiber(fiber) {
@@ -3337,6 +3355,20 @@ function findCurrentHostFiber(parent) {
return null;
}
+function doesFiberContain(parentFiber, childFiber) {
+ var node = childFiber;
+ var parentFiberAlternate = parentFiber.alternate;
+
+ while (node !== null) {
+ if (node === parentFiber || node === parentFiberAlternate) {
+ return true;
+ }
+
+ node = node.return;
+ }
+
+ return false;
+}
// Modules provided by RN:
var emptyObject = {};
@@ -4103,6 +4135,7 @@ function getPublicInstance(instance) {
}
function prepareForCommit(containerInfo) {
// Noop
+ return null;
}
function prepareUpdate(
instance,
@@ -4120,9 +4153,6 @@ function resetAfterCommit(containerInfo) {
var scheduleTimeout = setTimeout;
var cancelTimeout = clearTimeout;
var noTimeout = -1;
-function shouldDeprioritizeSubtree(type, props) {
- return false;
-}
function shouldSetTextContent(type, props) {
// TODO (bvaughn) Revisit this decision.
// Always returning false simplifies the createInstance() implementation,
@@ -4284,546 +4314,360 @@ function hideInstance(instance) {
}
function hideTextInstance(textInstance) {
throw new Error("Not yet implemented.");
-}
-function unhideInstance(instance, props) {
- var viewConfig = instance.viewConfig;
- var updatePayload = diff(
- Object.assign({}, props, {
- style: [
- props.style,
- {
- display: "none"
- }
- ]
- }),
- props,
- viewConfig.validAttributes
- );
- ReactNativePrivateInterface.UIManager.updateView(
- instance._nativeTag,
- viewConfig.uiViewClassName,
- updatePayload
- );
-}
-function unhideTextInstance(textInstance, text) {
- throw new Error("Not yet implemented.");
-}
-
-var loggedTypeFailures = {};
-function checkPropTypes(typeSpecs, values, location, componentName) {
- {
- // $FlowFixMe This is okay but Flow doesn't know it.
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
-
- for (var typeSpecName in typeSpecs) {
- if (has(typeSpecs, typeSpecName)) {
- var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
- // fail the render phase where it didn't fail before. So we log it.
- // After these have been cleaned up, we'll let them throw.
-
- try {
- // This is intentionally an invariant that gets caught. It's the same
- // behavior as without this statement except with a better message.
- if (typeof typeSpecs[typeSpecName] !== "function") {
- var err = Error(
- (componentName || "React class") +
- ": " +
- location +
- " type `" +
- typeSpecName +
- "` is invalid; " +
- "it must be a function, usually from the `prop-types` package, but received `" +
- typeof typeSpecs[typeSpecName] +
- "`." +
- "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
- );
- err.name = "Invariant Violation";
- throw err;
- }
-
- error$1 = typeSpecs[typeSpecName](
- values,
- typeSpecName,
- componentName,
- location,
- null,
- "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"
- );
- } catch (ex) {
- error$1 = ex;
- }
-
- if (error$1 && !(error$1 instanceof Error)) {
- error(
- "%s: type specification of %s" +
- " `%s` is invalid; the type checker " +
- "function must return `null` or an `Error` but returned a %s. " +
- "You may have forgotten to pass an argument to the type checker " +
- "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " +
- "shape all require an argument).",
- componentName || "React class",
- location,
- typeSpecName,
- typeof error$1
- );
- }
-
- if (
- error$1 instanceof Error &&
- !(error$1.message in loggedTypeFailures)
- ) {
- // Only monitor this failure once because there tends to be a lot of the
- // same error.
- loggedTypeFailures[error$1.message] = true;
-
- error("Failed %s type: %s", location, error$1.message);
+}
+function unhideInstance(instance, props) {
+ var viewConfig = instance.viewConfig;
+ var updatePayload = diff(
+ Object.assign({}, props, {
+ style: [
+ props.style,
+ {
+ display: "none"
}
- }
- }
- }
+ ]
+ }),
+ props,
+ viewConfig.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance._nativeTag,
+ viewConfig.uiViewClassName,
+ updatePayload
+ );
+}
+function clearContainer(container) {
+ // TODO Implement this for React Native
+ // UIManager does not expose a "remove all" type method.
+}
+function unhideTextInstance(textInstance, text) {
+ throw new Error("Not yet implemented.");
+}
+function makeClientIdInDEV(warnOnAccessInDEV) {
+ throw new Error("Not yet implemented");
+}
+function preparePortalMount(portalInstance) {
+ // noop
}
-// Prefix measurements so that it's possible to filter them.
-// Longer prefixes are hard to read in DevTools.
-var reactEmoji = "\u269B";
-var warningEmoji = "\u26D4";
-var supportsUserTiming =
- typeof performance !== "undefined" &&
- typeof performance.mark === "function" &&
- typeof performance.clearMarks === "function" &&
- typeof performance.measure === "function" &&
- typeof performance.clearMeasures === "function"; // Keep track of current fiber so that we know the path to unwind on pause.
-// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
-
-var currentFiber = null; // If we're in the middle of user code, which fiber and method is it?
-// Reusing `currentFiber` would be confusing for this because user code fiber
-// can change during commit phase too, but we don't need to unwind it (since
-// lifecycles in the commit phase don't resemble a tree).
-
-var currentPhase = null;
-var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem,
-// so we will keep track of it, and include it in the report.
-// Track commits caused by cascading updates.
-
-var isCommitting = false;
-var hasScheduledUpdateInCurrentCommit = false;
-var hasScheduledUpdateInCurrentPhase = false;
-var commitCountInCurrentWorkLoop = 0;
-var effectCountInCurrentCommit = 0;
-// to avoid stretch the commit phase with measurement overhead.
-
-var labelsInCurrentCommit = new Set();
-
-var formatMarkName = function(markName) {
- return reactEmoji + " " + markName;
-};
-
-var formatLabel = function(label, warning) {
- var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
- var suffix = warning ? " Warning: " + warning : "";
- return "" + prefix + label + suffix;
-};
-
-var beginMark = function(markName) {
- performance.mark(formatMarkName(markName));
-};
-
-var clearMark = function(markName) {
- performance.clearMarks(formatMarkName(markName));
-};
-
-var endMark = function(label, markName, warning) {
- var formattedMarkName = formatMarkName(markName);
- var formattedLabel = formatLabel(label, warning);
-
- try {
- performance.measure(formattedLabel, formattedMarkName);
- } catch (err) {} // If previous mark was missing for some reason, this will throw.
- // This could only happen if React crashed in an unexpected place earlier.
- // Don't pile on with more errors.
- // Clear marks immediately to avoid growing buffer.
-
- performance.clearMarks(formattedMarkName);
- performance.clearMeasures(formattedLabel);
-};
-
-var getFiberMarkName = function(label, debugID) {
- return label + " (#" + debugID + ")";
-};
-
-var getFiberLabel = function(componentName, isMounted, phase) {
- if (phase === null) {
- // These are composite component total time measurements.
- return componentName + " [" + (isMounted ? "update" : "mount") + "]";
- } else {
- // Composite component methods.
- return componentName + "." + phase;
- }
-};
-
-var beginFiberMark = function(fiber, phase) {
- var componentName = getComponentName(fiber.type) || "Unknown";
- var debugID = fiber._debugID;
- var isMounted = fiber.alternate !== null;
- var label = getFiberLabel(componentName, isMounted, phase);
-
- if (isCommitting && labelsInCurrentCommit.has(label)) {
- // During the commit phase, we don't show duplicate labels because
- // there is a fixed overhead for every measurement, and we don't
- // want to stretch the commit phase beyond necessary.
- return false;
- }
-
- labelsInCurrentCommit.add(label);
- var markName = getFiberMarkName(label, debugID);
- beginMark(markName);
- return true;
-};
-
-var clearFiberMark = function(fiber, phase) {
- var componentName = getComponentName(fiber.type) || "Unknown";
- var debugID = fiber._debugID;
- var isMounted = fiber.alternate !== null;
- var label = getFiberLabel(componentName, isMounted, phase);
- var markName = getFiberMarkName(label, debugID);
- clearMark(markName);
-};
-
-var endFiberMark = function(fiber, phase, warning) {
- var componentName = getComponentName(fiber.type) || "Unknown";
- var debugID = fiber._debugID;
- var isMounted = fiber.alternate !== null;
- var label = getFiberLabel(componentName, isMounted, phase);
- var markName = getFiberMarkName(label, debugID);
- endMark(label, markName, warning);
-};
-
-var shouldIgnoreFiber = function(fiber) {
- // Host components should be skipped in the timeline.
- // We could check typeof fiber.type, but does this work with RN?
- switch (fiber.tag) {
- case HostRoot:
- case HostComponent:
- case HostText:
- case HostPortal:
- case Fragment:
- case ContextProvider:
- case ContextConsumer:
- case Mode:
- return true;
-
- default:
- return false;
- }
-};
-
-var clearPendingPhaseMeasurement = function() {
- if (currentPhase !== null && currentPhaseFiber !== null) {
- clearFiberMark(currentPhaseFiber, currentPhase);
- }
-
- currentPhaseFiber = null;
- currentPhase = null;
- hasScheduledUpdateInCurrentPhase = false;
-};
+// Helpers to patch console.logs to avoid logging during side-effect free
+// replaying on render function. This currently only patches the object
+// lazily which won't cover if the log function was extracted eagerly.
+// We could also eagerly patch the method.
+var disabledDepth = 0;
+var prevLog;
+var prevInfo;
+var prevWarn;
+var prevError;
+var prevGroup;
+var prevGroupCollapsed;
+var prevGroupEnd;
-var pauseTimers = function() {
- // Stops all currently active measurements so that they can be resumed
- // if we continue in a later deferred loop from the same unit of work.
- var fiber = currentFiber;
+function disabledLog() {}
- while (fiber) {
- if (fiber._debugIsCurrentlyTiming) {
- endFiberMark(fiber, null, null);
+disabledLog.__reactDisabledLog = true;
+function disableLogs() {
+ {
+ if (disabledDepth === 0) {
+ /* eslint-disable react-internal/no-production-logging */
+ prevLog = console.log;
+ prevInfo = console.info;
+ prevWarn = console.warn;
+ prevError = console.error;
+ prevGroup = console.group;
+ prevGroupCollapsed = console.groupCollapsed;
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
+
+ var props = {
+ configurable: true,
+ enumerable: true,
+ value: disabledLog,
+ writable: true
+ }; // $FlowFixMe Flow thinks console is immutable.
+
+ Object.defineProperties(console, {
+ info: props,
+ log: props,
+ warn: props,
+ error: props,
+ group: props,
+ groupCollapsed: props,
+ groupEnd: props
+ });
+ /* eslint-enable react-internal/no-production-logging */
}
- fiber = fiber.return;
- }
-};
-
-var resumeTimersRecursively = function(fiber) {
- if (fiber.return !== null) {
- resumeTimersRecursively(fiber.return);
- }
-
- if (fiber._debugIsCurrentlyTiming) {
- beginFiberMark(fiber, null);
- }
-};
-
-var resumeTimers = function() {
- // Resumes all measurements that were active during the last deferred loop.
- if (currentFiber !== null) {
- resumeTimersRecursively(currentFiber);
- }
-};
-
-function recordEffect() {
- {
- effectCountInCurrentCommit++;
+ disabledDepth++;
}
}
-function recordScheduleUpdate() {
+function reenableLogs() {
{
- if (isCommitting) {
- hasScheduledUpdateInCurrentCommit = true;
+ disabledDepth--;
+
+ if (disabledDepth === 0) {
+ /* eslint-disable react-internal/no-production-logging */
+ var props = {
+ configurable: true,
+ enumerable: true,
+ writable: true
+ }; // $FlowFixMe Flow thinks console is immutable.
+
+ Object.defineProperties(console, {
+ log: Object.assign({}, props, {
+ value: prevLog
+ }),
+ info: Object.assign({}, props, {
+ value: prevInfo
+ }),
+ warn: Object.assign({}, props, {
+ value: prevWarn
+ }),
+ error: Object.assign({}, props, {
+ value: prevError
+ }),
+ group: Object.assign({}, props, {
+ value: prevGroup
+ }),
+ groupCollapsed: Object.assign({}, props, {
+ value: prevGroupCollapsed
+ }),
+ groupEnd: Object.assign({}, props, {
+ value: prevGroupEnd
+ })
+ });
+ /* eslint-enable react-internal/no-production-logging */
}
- if (
- currentPhase !== null &&
- currentPhase !== "componentWillMount" &&
- currentPhase !== "componentWillReceiveProps"
- ) {
- hasScheduledUpdateInCurrentPhase = true;
+ if (disabledDepth < 0) {
+ error(
+ "disabledDepth fell below zero. " +
+ "This is a bug in React. Please file an issue."
+ );
}
}
}
-function startWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // If we pause, this is the fiber to unwind from.
- currentFiber = fiber;
+var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
+function describeBuiltInComponentFrame(name, source, ownerFn) {
+ {
+ var ownerName = null;
- if (!beginFiberMark(fiber, null)) {
- return;
+ if (ownerFn) {
+ ownerName = ownerFn.displayName || ownerFn.name || null;
}
- fiber._debugIsCurrentlyTiming = true;
+ return describeComponentFrame(name, source, ownerName);
}
}
-function cancelWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // Remember we shouldn't complete measurement for this fiber.
- // Otherwise flamechart will be deep even for small updates.
+var componentFrameCache;
- fiber._debugIsCurrentlyTiming = false;
- clearFiberMark(fiber, null);
- }
+{
+ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
+ componentFrameCache = new PossiblyWeakMap();
}
-function stopWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // If we pause, its parent is the fiber to unwind from.
+var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
- currentFiber = fiber.return;
+function describeComponentFrame(name, source, ownerName) {
+ var sourceInfo = "";
- if (!fiber._debugIsCurrentlyTiming) {
- return;
- }
+ if (source) {
+ var path = source.fileName;
+ var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case:
+ // prefer "folder/index.js" instead of just "index.js".
- fiber._debugIsCurrentlyTiming = false;
- endFiberMark(fiber, null, null);
- }
-}
-function stopFailedWorkTimer(fiber) {
- {
- if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
- return;
- } // If we pause, its parent is the fiber to unwind from.
+ if (/^index\./.test(fileName)) {
+ var match = path.match(BEFORE_SLASH_RE);
- currentFiber = fiber.return;
+ if (match) {
+ var pathBeforeSlash = match[1];
- if (!fiber._debugIsCurrentlyTiming) {
- return;
+ if (pathBeforeSlash) {
+ var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, "");
+ fileName = folderName + "/" + fileName;
+ }
+ }
}
- fiber._debugIsCurrentlyTiming = false;
- var warning =
- fiber.tag === SuspenseComponent
- ? "Rendering was suspended"
- : "An error was thrown inside this error boundary";
- endFiberMark(fiber, null, warning);
+ sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")";
+ } else if (ownerName) {
+ sourceInfo = " (created by " + ownerName + ")";
+ }
+
+ return "\n in " + (name || "Unknown") + sourceInfo;
+}
+
+function describeClassComponentFrame(ctor, source, ownerFn) {
+ {
+ return describeFunctionComponentFrame(ctor, source, ownerFn);
}
}
-function startPhaseTimer(fiber, phase) {
+function describeFunctionComponentFrame(fn, source, ownerFn) {
{
- if (!supportsUserTiming) {
- return;
+ if (!fn) {
+ return "";
}
- clearPendingPhaseMeasurement();
+ var name = fn.displayName || fn.name || null;
+ var ownerName = null;
- if (!beginFiberMark(fiber, phase)) {
- return;
+ if (ownerFn) {
+ ownerName = ownerFn.displayName || ownerFn.name || null;
}
- currentPhaseFiber = fiber;
- currentPhase = phase;
+ return describeComponentFrame(name, source, ownerName);
}
}
-function stopPhaseTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
- if (currentPhase !== null && currentPhaseFiber !== null) {
- var warning = hasScheduledUpdateInCurrentPhase
- ? "Scheduled a cascading update"
- : null;
- endFiberMark(currentPhaseFiber, currentPhase, warning);
- }
-
- currentPhase = null;
- currentPhaseFiber = null;
+function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
+ if (type == null) {
+ return "";
}
-}
-function startWorkLoopTimer(nextUnitOfWork) {
- {
- currentFiber = nextUnitOfWork;
- if (!supportsUserTiming) {
- return;
+ if (typeof type === "function") {
+ {
+ return describeFunctionComponentFrame(type, source, ownerFn);
}
+ }
- commitCountInCurrentWorkLoop = 0; // This is top level call.
- // Any other measurements are performed within.
+ if (typeof type === "string") {
+ return describeBuiltInComponentFrame(type, source, ownerFn);
+ }
- beginMark("(React Tree Reconciliation)"); // Resume any measurements that were in progress during the last loop.
+ switch (type) {
+ case REACT_SUSPENSE_TYPE:
+ return describeBuiltInComponentFrame("Suspense", source, ownerFn);
- resumeTimers();
+ case REACT_SUSPENSE_LIST_TYPE:
+ return describeBuiltInComponentFrame("SuspenseList", source, ownerFn);
}
-}
-function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
- {
- if (!supportsUserTiming) {
- return;
- }
- var warning = null;
+ if (typeof type === "object") {
+ switch (type.$$typeof) {
+ case REACT_FORWARD_REF_TYPE:
+ return describeFunctionComponentFrame(type.render, source, ownerFn);
- if (interruptedBy !== null) {
- if (interruptedBy.tag === HostRoot) {
- warning = "A top-level update interrupted the previous render";
- } else {
- var componentName = getComponentName(interruptedBy.type) || "Unknown";
- warning =
- "An update to " + componentName + " interrupted the previous render";
- }
- } else if (commitCountInCurrentWorkLoop > 1) {
- warning = "There were cascading updates";
- }
+ case REACT_MEMO_TYPE:
+ // Memo may contain any component type so we recursively resolve it.
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
+
+ case REACT_BLOCK_TYPE:
+ return describeFunctionComponentFrame(type._render, source, ownerFn);
- commitCountInCurrentWorkLoop = 0;
- var label = didCompleteRoot
- ? "(React Tree Reconciliation: Completed Root)"
- : "(React Tree Reconciliation: Yielded)"; // Pause any measurements until the next loop.
+ case REACT_LAZY_TYPE: {
+ var lazyComponent = type;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- pauseTimers();
- endMark(label, "(React Tree Reconciliation)", warning);
+ try {
+ // Lazy may contain any component type so we recursively resolve it.
+ return describeUnknownElementTypeFrameInDEV(
+ init(payload),
+ source,
+ ownerFn
+ );
+ } catch (x) {}
+ }
+ }
}
+
+ return "";
}
-function startCommitTimer() {
+
+var loggedTypeFailures = {};
+var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
+
+function setCurrentlyValidatingElement(element) {
{
- if (!supportsUserTiming) {
- return;
+ if (element) {
+ var owner = element._owner;
+ var stack = describeUnknownElementTypeFrameInDEV(
+ element.type,
+ element._source,
+ owner ? owner.type : null
+ );
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
+ } else {
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
}
-
- isCommitting = true;
- hasScheduledUpdateInCurrentCommit = false;
- labelsInCurrentCommit.clear();
- beginMark("(Committing Changes)");
}
}
-function stopCommitTimer() {
+
+function checkPropTypes(typeSpecs, values, location, componentName, element) {
{
- if (!supportsUserTiming) {
- return;
- }
+ // $FlowFixMe This is okay but Flow doesn't know it.
+ var has = Function.call.bind(Object.prototype.hasOwnProperty);
+
+ for (var typeSpecName in typeSpecs) {
+ if (has(typeSpecs, typeSpecName)) {
+ var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
+ // fail the render phase where it didn't fail before. So we log it.
+ // After these have been cleaned up, we'll let them throw.
- var warning = null;
+ try {
+ // This is intentionally an invariant that gets caught. It's the same
+ // behavior as without this statement except with a better message.
+ if (typeof typeSpecs[typeSpecName] !== "function") {
+ var err = Error(
+ (componentName || "React class") +
+ ": " +
+ location +
+ " type `" +
+ typeSpecName +
+ "` is invalid; " +
+ "it must be a function, usually from the `prop-types` package, but received `" +
+ typeof typeSpecs[typeSpecName] +
+ "`." +
+ "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
+ );
+ err.name = "Invariant Violation";
+ throw err;
+ }
- if (hasScheduledUpdateInCurrentCommit) {
- warning = "Lifecycle hook scheduled a cascading update";
- } else if (commitCountInCurrentWorkLoop > 0) {
- warning = "Caused by a cascading update in earlier commit";
- }
+ error$1 = typeSpecs[typeSpecName](
+ values,
+ typeSpecName,
+ componentName,
+ location,
+ null,
+ "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"
+ );
+ } catch (ex) {
+ error$1 = ex;
+ }
- hasScheduledUpdateInCurrentCommit = false;
- commitCountInCurrentWorkLoop++;
- isCommitting = false;
- labelsInCurrentCommit.clear();
- endMark("(Committing Changes)", "(Committing Changes)", warning);
- }
-}
-function startCommitSnapshotEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ if (error$1 && !(error$1 instanceof Error)) {
+ setCurrentlyValidatingElement(element);
- effectCountInCurrentCommit = 0;
- beginMark("(Committing Snapshot Effects)");
- }
-}
-function stopCommitSnapshotEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ error(
+ "%s: type specification of %s" +
+ " `%s` is invalid; the type checker " +
+ "function must return `null` or an `Error` but returned a %s. " +
+ "You may have forgotten to pass an argument to the type checker " +
+ "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " +
+ "shape all require an argument).",
+ componentName || "React class",
+ location,
+ typeSpecName,
+ typeof error$1
+ );
- var count = effectCountInCurrentCommit;
- effectCountInCurrentCommit = 0;
- endMark(
- "(Committing Snapshot Effects: " + count + " Total)",
- "(Committing Snapshot Effects)",
- null
- );
- }
-}
-function startCommitHostEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ setCurrentlyValidatingElement(null);
+ }
- effectCountInCurrentCommit = 0;
- beginMark("(Committing Host Effects)");
- }
-}
-function stopCommitHostEffectsTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ if (
+ error$1 instanceof Error &&
+ !(error$1.message in loggedTypeFailures)
+ ) {
+ // Only monitor this failure once because there tends to be a lot of the
+ // same error.
+ loggedTypeFailures[error$1.message] = true;
+ setCurrentlyValidatingElement(element);
- var count = effectCountInCurrentCommit;
- effectCountInCurrentCommit = 0;
- endMark(
- "(Committing Host Effects: " + count + " Total)",
- "(Committing Host Effects)",
- null
- );
- }
-}
-function startCommitLifeCyclesTimer() {
- {
- if (!supportsUserTiming) {
- return;
- }
+ error("Failed %s type: %s", location, error$1.message);
- effectCountInCurrentCommit = 0;
- beginMark("(Calling Lifecycle Methods)");
- }
-}
-function stopCommitLifeCyclesTimer() {
- {
- if (!supportsUserTiming) {
- return;
+ setCurrentlyValidatingElement(null);
+ }
+ }
}
-
- var count = effectCountInCurrentCommit;
- effectCountInCurrentCommit = 0;
- endMark(
- "(Calling Lifecycle Methods: " + count + " Total)",
- "(Calling Lifecycle Methods)",
- null
- );
}
}
@@ -5030,10 +4874,7 @@ function processChildContext(fiber, type, parentContext) {
return parentContext;
}
- var childContext;
- startPhaseTimer(fiber, "getChildContext");
- childContext = instance.getChildContext();
- stopPhaseTimer();
+ var childContext = instance.getChildContext();
for (var contextKey in childContext) {
if (!(contextKey in childContextTypes)) {
@@ -5154,20 +4995,112 @@ var LegacyRoot = 0;
var BlockingRoot = 1;
var ConcurrentRoot = 2;
+var rendererID = null;
+var injectedHook = null;
+var hasLoggedError = false;
+var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
+function injectInternals(internals) {
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") {
+ // No DevTools
+ return false;
+ }
+
+ var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+
+ if (hook.isDisabled) {
+ // This isn't a real property on the hook, but it can be set to opt out
+ // of DevTools integration and associated warnings and logs.
+ // https://github.com/facebook/react/issues/3877
+ return true;
+ }
+
+ if (!hook.supportsFiber) {
+ {
+ error(
+ "The installed version of React DevTools is too old and will not work " +
+ "with the current version of React. Please update React DevTools. " +
+ "https://fb.me/react-devtools"
+ );
+ } // DevTools exists, even though it doesn't support Fiber.
+
+ return true;
+ }
+
+ try {
+ rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
+
+ injectedHook = hook;
+ } catch (err) {
+ // Catch all errors because it is unsafe to throw during initialization.
+ {
+ error("React instrumentation encountered an error: %s.", err);
+ }
+ } // DevTools exists
+
+ return true;
+}
+function onScheduleRoot(root, children) {
+ {
+ if (
+ injectedHook &&
+ typeof injectedHook.onScheduleFiberRoot === "function"
+ ) {
+ try {
+ injectedHook.onScheduleFiberRoot(rendererID, root, children);
+ } catch (err) {
+ if (!hasLoggedError) {
+ hasLoggedError = true;
+
+ error("React instrumentation encountered an error: %s", err);
+ }
+ }
+ }
+ }
+}
+function onCommitRoot(root, priorityLevel) {
+ if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") {
+ try {
+ var didError = (root.current.effectTag & DidCapture) === DidCapture;
+
+ if (enableProfilerTimer) {
+ injectedHook.onCommitFiberRoot(
+ rendererID,
+ root,
+ priorityLevel,
+ didError
+ );
+ } else {
+ injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError);
+ }
+ } catch (err) {
+ {
+ if (!hasLoggedError) {
+ hasLoggedError = true;
+
+ error("React instrumentation encountered an error: %s", err);
+ }
+ }
+ }
+ }
+}
+function onCommitUnmount(fiber) {
+ if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") {
+ try {
+ injectedHook.onCommitFiberUnmount(rendererID, fiber);
+ } catch (err) {
+ {
+ if (!hasLoggedError) {
+ hasLoggedError = true;
+
+ error("React instrumentation encountered an error: %s", err);
+ }
+ }
+ }
+ }
+}
+
// Intentionally not named imports because Rollup would use dynamic dispatch for
-var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
- Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
- Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
- Scheduler_shouldYield = Scheduler.unstable_shouldYield,
- Scheduler_requestPaint = Scheduler.unstable_requestPaint,
- Scheduler_now = Scheduler.unstable_now,
- Scheduler_getCurrentPriorityLevel =
- Scheduler.unstable_getCurrentPriorityLevel,
- Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
- Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
- Scheduler_NormalPriority = Scheduler.unstable_NormalPriority,
- Scheduler_LowPriority = Scheduler.unstable_LowPriority,
- Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
+var Scheduler_now = Scheduler.unstable_now;
{
// Provide explicit error message when production+profiling bundle of e.g.
@@ -5184,8 +5117,6 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
);
}
}
-
-var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
// ascending numbers so we can compare them like numbers. They start at 90 to
// avoid clashing with Scheduler's priorities.
@@ -5196,1214 +5127,1458 @@ var LowPriority = 96;
var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
var NoPriority = 90;
-var shouldYield = Scheduler_shouldYield;
-var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
- Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {};
-var syncQueue = null;
-var immediateQueueCallbackNode = null;
-var isFlushingSyncQueue = false;
var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
-// This will be the case for modern browsers that support `performance.now`. In
-// older browsers, Scheduler falls back to `Date.now`, which returns a Unix
-// timestamp. In that case, subtract the module initialization time to simulate
-// the behavior of performance.now and keep our times small enough to fit
-// within 32 bits.
-// TODO: Consider lifting this into Scheduler.
-
-var now =
- initialTimeMs < 10000
- ? Scheduler_now
- : function() {
- return Scheduler_now() - initialTimeMs;
- };
-function getCurrentPriorityLevel() {
- switch (Scheduler_getCurrentPriorityLevel()) {
- case Scheduler_ImmediatePriority:
- return ImmediatePriority;
-
- case Scheduler_UserBlockingPriority:
- return UserBlockingPriority;
-
- case Scheduler_NormalPriority:
- return NormalPriority;
-
- case Scheduler_LowPriority:
- return LowPriority;
-
- case Scheduler_IdlePriority:
- return IdlePriority;
-
- default: {
- throw Error("Unknown priority level.");
- }
- }
-}
-
-function reactPriorityToSchedulerPriority(reactPriorityLevel) {
- switch (reactPriorityLevel) {
- case ImmediatePriority:
- return Scheduler_ImmediatePriority;
-
- case UserBlockingPriority:
- return Scheduler_UserBlockingPriority;
-
- case NormalPriority:
- return Scheduler_NormalPriority;
-
- case LowPriority:
- return Scheduler_LowPriority;
-
- case IdlePriority:
- return Scheduler_IdlePriority;
-
- default: {
- throw Error("Unknown priority level.");
- }
- }
-}
-
-function runWithPriority(reactPriorityLevel, fn) {
- var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
- return Scheduler_runWithPriority(priorityLevel, fn);
-}
-function scheduleCallback(reactPriorityLevel, callback, options) {
- var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
- return Scheduler_scheduleCallback(priorityLevel, callback, options);
-}
-function scheduleSyncCallback(callback) {
- // Push this callback into an internal queue. We'll flush these either in
- // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
- if (syncQueue === null) {
- syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
-
- immediateQueueCallbackNode = Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueueImpl
- );
- } else {
- // Push onto existing queue. Don't need to schedule a callback because
- // we already scheduled one when we created the queue.
- syncQueue.push(callback);
- }
-
- return fakeCallbackNode;
-}
-function cancelCallback(callbackNode) {
- if (callbackNode !== fakeCallbackNode) {
- Scheduler_cancelCallback(callbackNode);
- }
-}
-function flushSyncCallbackQueue() {
- if (immediateQueueCallbackNode !== null) {
- var node = immediateQueueCallbackNode;
- immediateQueueCallbackNode = null;
- Scheduler_cancelCallback(node);
- }
-
- flushSyncCallbackQueueImpl();
-}
-
-function flushSyncCallbackQueueImpl() {
- if (!isFlushingSyncQueue && syncQueue !== null) {
- // Prevent re-entrancy.
- isFlushingSyncQueue = true;
- var i = 0;
-
- try {
- var _isSync = true;
- var queue = syncQueue;
- runWithPriority(ImmediatePriority, function() {
- for (; i < queue.length; i++) {
- var callback = queue[i];
- do {
- callback = callback(_isSync);
- } while (callback !== null);
- }
- });
- syncQueue = null;
- } catch (error) {
- // If something throws, leave the remaining callbacks on the queue.
- if (syncQueue !== null) {
- syncQueue = syncQueue.slice(i + 1);
- } // Resume flushing in the next tick
+var SyncLanePriority = 17;
+var SyncBatchedLanePriority = 16;
+var InputDiscreteHydrationLanePriority = 15;
+var InputDiscreteLanePriority = 14;
+var InputContinuousHydrationLanePriority = 13;
+var InputContinuousLanePriority = 12;
+var DefaultHydrationLanePriority = 11;
+var DefaultLanePriority = 10;
+var TransitionShortHydrationLanePriority = 9;
+var TransitionShortLanePriority = 8;
+var TransitionLongHydrationLanePriority = 7;
+var TransitionLongLanePriority = 6;
+var RetryLanePriority = 5;
+var SelectiveHydrationLanePriority = 4;
+var IdleHydrationLanePriority = 3;
+var IdleLanePriority = 2;
+var OffscreenLanePriority = 1;
+var NoLanePriority = 0;
+var TotalLanes = 31;
+var NoLanes =
+ /* */
+ 0;
+var NoLane =
+ /* */
+ 0;
+var SyncLane =
+ /* */
+ 1;
+var SyncBatchedLane =
+ /* */
+ 2;
+var InputDiscreteHydrationLane =
+ /* */
+ 4;
+var InputDiscreteLanes =
+ /* */
+ 24;
+var InputContinuousHydrationLane =
+ /* */
+ 32;
+var InputContinuousLanes =
+ /* */
+ 192;
+var DefaultHydrationLane =
+ /* */
+ 256;
+var DefaultLanes =
+ /* */
+ 3584;
+var TransitionShortHydrationLane =
+ /* */
+ 4096;
+var TransitionShortLanes =
+ /* */
+ 122880;
+var TransitionLongHydrationLane =
+ /* */
+ 131072;
+var TransitionLongLanes =
+ /* */
+ 3932160;
+var RetryLanes =
+ /* */
+ 62914560;
+var SelectiveHydrationLane =
+ /* */
+ 67108864;
+var NonIdleLanes =
+ /* */
+ 134217727;
+var IdleHydrationLane =
+ /* */
+ 134217728;
+var IdleLanes =
+ /* */
+ 805306368;
+var OffscreenLane =
+ /* */
+ 1073741824;
+var NoTimestamp = -1;
+function setCurrentUpdateLanePriority(newLanePriority) {} // "Registers" used to "return" multiple values
+// Used by getHighestPriorityLanes and getNextLanes:
- Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueue
- );
- throw error;
- } finally {
- isFlushingSyncQueue = false;
- }
+var return_highestLanePriority = DefaultLanePriority;
+
+function getHighestPriorityLanes(lanes) {
+ if ((SyncLane & lanes) !== NoLanes) {
+ return_highestLanePriority = SyncLanePriority;
+ return SyncLane;
}
-}
-var NoMode = 0;
-var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
-// tag instead
+ if ((SyncBatchedLane & lanes) !== NoLanes) {
+ return_highestLanePriority = SyncBatchedLanePriority;
+ return SyncBatchedLane;
+ }
-var BlockingMode = 2;
-var ConcurrentMode = 4;
-var ProfileMode = 8;
+ if ((InputDiscreteHydrationLane & lanes) !== NoLanes) {
+ return_highestLanePriority = InputDiscreteHydrationLanePriority;
+ return InputDiscreteHydrationLane;
+ }
-// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
-// Math.pow(2, 30) - 1
-// 0b111111111111111111111111111111
-var MAX_SIGNED_31_BIT_INT = 1073741823;
+ var inputDiscreteLanes = InputDiscreteLanes & lanes;
-var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that
-// Never work can be committed in an inconsistent state without tearing the UI.
-// The main example is offscreen content, like a hidden subtree. So one possible
-// name is Offscreen. However, it also includes dehydrated Suspense boundaries,
-// which are inconsistent in the sense that they haven't finished yet, but
-// aren't visibly inconsistent because the server rendered HTML matches what the
-// hydrated tree would look like.
+ if (inputDiscreteLanes !== NoLanes) {
+ return_highestLanePriority = InputDiscreteLanePriority;
+ return inputDiscreteLanes;
+ }
-var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in
-// order to be consistent.
+ if ((lanes & InputContinuousHydrationLane) !== NoLanes) {
+ return_highestLanePriority = InputContinuousHydrationLanePriority;
+ return InputContinuousHydrationLane;
+ }
-var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase
-var Sync = MAX_SIGNED_31_BIT_INT;
-var Batched = Sync - 1;
-var UNIT_SIZE = 10;
-var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms.
+ var inputContinuousLanes = InputContinuousLanes & lanes;
-function msToExpirationTime(ms) {
- // Always subtract from the offset so that we don't clash with the magic number for NoWork.
- return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0);
-}
-function expirationTimeToMs(expirationTime) {
- return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
-}
+ if (inputContinuousLanes !== NoLanes) {
+ return_highestLanePriority = InputContinuousLanePriority;
+ return inputContinuousLanes;
+ }
-function ceiling(num, precision) {
- return (((num / precision) | 0) + 1) * precision;
-}
+ if ((lanes & DefaultHydrationLane) !== NoLanes) {
+ return_highestLanePriority = DefaultHydrationLanePriority;
+ return DefaultHydrationLane;
+ }
-function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
- return (
- MAGIC_NUMBER_OFFSET -
- ceiling(
- MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE,
- bucketSizeMs / UNIT_SIZE
- )
- );
-} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
-// the names to reflect.
-
-var LOW_PRIORITY_EXPIRATION = 5000;
-var LOW_PRIORITY_BATCH_SIZE = 250;
-function computeAsyncExpiration(currentTime) {
- return computeExpirationBucket(
- currentTime,
- LOW_PRIORITY_EXPIRATION,
- LOW_PRIORITY_BATCH_SIZE
- );
-}
-function computeSuspenseExpiration(currentTime, timeoutMs) {
- // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
- return computeExpirationBucket(
- currentTime,
- timeoutMs,
- LOW_PRIORITY_BATCH_SIZE
- );
-} // We intentionally set a higher expiration time for interactive updates in
-// dev than in production.
-//
-// If the main thread is being blocked so long that you hit the expiration,
-// it's a problem that could be solved with better scheduling.
-//
-// People will be more likely to notice this and fix it with the long
-// expiration time in development.
-//
-// In production we opt for better UX at the risk of masking scheduling
-// problems, by expiring fast.
-
-var HIGH_PRIORITY_EXPIRATION = 500;
-var HIGH_PRIORITY_BATCH_SIZE = 100;
-function computeInteractiveExpiration(currentTime) {
- return computeExpirationBucket(
- currentTime,
- HIGH_PRIORITY_EXPIRATION,
- HIGH_PRIORITY_BATCH_SIZE
- );
-}
-function inferPriorityFromExpirationTime(currentTime, expirationTime) {
- if (expirationTime === Sync) {
- return ImmediatePriority;
+ var defaultLanes = DefaultLanes & lanes;
+
+ if (defaultLanes !== NoLanes) {
+ return_highestLanePriority = DefaultLanePriority;
+ return defaultLanes;
}
- if (expirationTime === Never || expirationTime === Idle) {
- return IdlePriority;
+ if ((lanes & TransitionShortHydrationLane) !== NoLanes) {
+ return_highestLanePriority = TransitionShortHydrationLanePriority;
+ return TransitionShortHydrationLane;
}
- var msUntil =
- expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
+ var transitionShortLanes = TransitionShortLanes & lanes;
- if (msUntil <= 0) {
- return ImmediatePriority;
+ if (transitionShortLanes !== NoLanes) {
+ return_highestLanePriority = TransitionShortLanePriority;
+ return transitionShortLanes;
}
- if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
- return UserBlockingPriority;
+ if ((lanes & TransitionLongHydrationLane) !== NoLanes) {
+ return_highestLanePriority = TransitionLongHydrationLanePriority;
+ return TransitionLongHydrationLane;
}
- if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
- return NormalPriority;
- } // TODO: Handle LowPriority
- // Assume anything lower has idle priority
+ var transitionLongLanes = TransitionLongLanes & lanes;
- return IdlePriority;
-}
-
-/**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
- */
-function is(x, y) {
- return (
- (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
- );
-}
+ if (transitionLongLanes !== NoLanes) {
+ return_highestLanePriority = TransitionLongLanePriority;
+ return transitionLongLanes;
+ }
-var objectIs = typeof Object.is === "function" ? Object.is : is;
+ var retryLanes = RetryLanes & lanes;
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-/**
- * Performs equality by iterating through keys on an object and returning false
- * when any key has values which are not strictly equal between the arguments.
- * Returns true when the values of all keys are strictly equal.
- */
+ if (retryLanes !== NoLanes) {
+ return_highestLanePriority = RetryLanePriority;
+ return retryLanes;
+ }
-function shallowEqual(objA, objB) {
- if (objectIs(objA, objB)) {
- return true;
+ if (lanes & SelectiveHydrationLane) {
+ return_highestLanePriority = SelectiveHydrationLanePriority;
+ return SelectiveHydrationLane;
}
- if (
- typeof objA !== "object" ||
- objA === null ||
- typeof objB !== "object" ||
- objB === null
- ) {
- return false;
+ if ((lanes & IdleHydrationLane) !== NoLanes) {
+ return_highestLanePriority = IdleHydrationLanePriority;
+ return IdleHydrationLane;
}
- var keysA = Object.keys(objA);
- var keysB = Object.keys(objB);
+ var idleLanes = IdleLanes & lanes;
- if (keysA.length !== keysB.length) {
- return false;
- } // Test for A's keys different from B.
+ if (idleLanes !== NoLanes) {
+ return_highestLanePriority = IdleLanePriority;
+ return idleLanes;
+ }
- for (var i = 0; i < keysA.length; i++) {
- if (
- !hasOwnProperty.call(objB, keysA[i]) ||
- !objectIs(objA[keysA[i]], objB[keysA[i]])
- ) {
- return false;
- }
+ if ((OffscreenLane & lanes) !== NoLanes) {
+ return_highestLanePriority = OffscreenLanePriority;
+ return OffscreenLane;
}
- return true;
+ {
+ error("Should have found matching lanes. This is a bug in React.");
+ } // This shouldn't be reachable, but as a fallback, return the entire bitmask.
+
+ return_highestLanePriority = DefaultLanePriority;
+ return lanes;
}
-var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
-function describeComponentFrame(name, source, ownerName) {
- var sourceInfo = "";
+function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
+ switch (schedulerPriorityLevel) {
+ case ImmediatePriority:
+ return SyncLanePriority;
- if (source) {
- var path = source.fileName;
- var fileName = path.replace(BEFORE_SLASH_RE, "");
+ case UserBlockingPriority:
+ return InputContinuousLanePriority;
- {
- // In DEV, include code for a common special case:
- // prefer "folder/index.js" instead of just "index.js".
- if (/^index\./.test(fileName)) {
- var match = path.match(BEFORE_SLASH_RE);
+ case NormalPriority:
+ case LowPriority:
+ // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration.
+ return DefaultLanePriority;
- if (match) {
- var pathBeforeSlash = match[1];
+ case IdlePriority:
+ return IdleLanePriority;
- if (pathBeforeSlash) {
- var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, "");
- fileName = folderName + "/" + fileName;
- }
- }
- }
+ default:
+ return NoLanePriority;
+ }
+}
+function lanePriorityToSchedulerPriority(lanePriority) {
+ switch (lanePriority) {
+ case SyncLanePriority:
+ case SyncBatchedLanePriority:
+ return ImmediatePriority;
+
+ case InputDiscreteHydrationLanePriority:
+ case InputDiscreteLanePriority:
+ case InputContinuousHydrationLanePriority:
+ case InputContinuousLanePriority:
+ return UserBlockingPriority;
+
+ case DefaultHydrationLanePriority:
+ case DefaultLanePriority:
+ case TransitionShortHydrationLanePriority:
+ case TransitionShortLanePriority:
+ case TransitionLongHydrationLanePriority:
+ case TransitionLongLanePriority:
+ case SelectiveHydrationLanePriority:
+ case RetryLanePriority:
+ return NormalPriority;
+
+ case IdleHydrationLanePriority:
+ case IdleLanePriority:
+ case OffscreenLanePriority:
+ return IdlePriority;
+
+ case NoLanePriority:
+ return NoPriority;
+
+ default: {
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
}
+ }
+}
+function getNextLanes(root, wipLanes) {
+ // Early bailout if there's no pending work left.
+ var pendingLanes = root.pendingLanes;
- sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")";
- } else if (ownerName) {
- sourceInfo = " (created by " + ownerName + ")";
+ if (pendingLanes === NoLanes) {
+ return_highestLanePriority = NoLanePriority;
+ return NoLanes;
}
- return "\n in " + (name || "Unknown") + sourceInfo;
-}
+ var nextLanes = NoLanes;
+ var nextLanePriority = NoLanePriority;
+ var expiredLanes = root.expiredLanes;
+ var suspendedLanes = root.suspendedLanes;
+ var pingedLanes = root.pingedLanes; // Check if any work has expired.
-var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
+ if (expiredLanes !== NoLanes) {
+ nextLanes = expiredLanes;
+ nextLanePriority = return_highestLanePriority = SyncLanePriority;
+ } else {
+ // Do not work on any idle work until all the non-idle work has finished,
+ // even if the work is suspended.
+ var nonIdlePendingLanes = pendingLanes & NonIdleLanes;
-function describeFiber(fiber) {
- switch (fiber.tag) {
- case HostRoot:
- case HostPortal:
- case HostText:
- case Fragment:
- case ContextProvider:
- case ContextConsumer:
- return "";
+ if (nonIdlePendingLanes !== NoLanes) {
+ var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
- default:
- var owner = fiber._debugOwner;
- var source = fiber._debugSource;
- var name = getComponentName(fiber.type);
- var ownerName = null;
+ if (nonIdleUnblockedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
+ nextLanePriority = return_highestLanePriority;
+ } else {
+ var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
- if (owner) {
- ownerName = getComponentName(owner.type);
+ if (nonIdlePingedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
+ nextLanePriority = return_highestLanePriority;
+ }
}
+ } else {
+ // The only remaining work is Idle.
+ var unblockedLanes = pendingLanes & ~suspendedLanes;
- return describeComponentFrame(name, source, ownerName);
+ if (unblockedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(unblockedLanes);
+ nextLanePriority = return_highestLanePriority;
+ } else {
+ if (pingedLanes !== NoLanes) {
+ nextLanes = getHighestPriorityLanes(pingedLanes);
+ nextLanePriority = return_highestLanePriority;
+ }
+ }
+ }
}
-}
-function getStackByFiberInDevAndProd(workInProgress) {
- var info = "";
- var node = workInProgress;
+ if (nextLanes === NoLanes) {
+ // This should only be reachable if we're suspended
+ // TODO: Consider warning in this path if a fallback timer is not scheduled.
+ return NoLanes;
+ } // If there are higher priority lanes, we'll include them even if they
+ // are suspended.
- do {
- info += describeFiber(node);
- node = node.return;
- } while (node);
+ nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt
+ // it and we'll lose our progress. We should only do this if the new lanes are
+ // higher priority.
- return info;
-}
-var current = null;
-var isRendering = false;
-function getCurrentFiberOwnerNameInDevOrNull() {
- {
- if (current === null) {
- return null;
+ if (
+ wipLanes !== NoLanes &&
+ wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't
+ // bother waiting until the root is complete.
+ (wipLanes & suspendedLanes) === NoLanes
+ ) {
+ getHighestPriorityLanes(wipLanes);
+ var wipLanePriority = return_highestLanePriority;
+
+ if (nextLanePriority <= wipLanePriority) {
+ return wipLanes;
+ } else {
+ return_highestLanePriority = nextLanePriority;
}
+ } // Check for entangled lanes and add them to the batch.
+ //
+ // A lane is said to be entangled with another when it's not allowed to render
+ // in a batch that does not also include the other lane. Typically we do this
+ // when multiple updates have the same source, and we only want to respond to
+ // the most recent event from that source.
+ //
+ // Note that we apply entanglements *after* checking for partial work above.
+ // This means that if a lane is entangled during an interleaved event while
+ // it's already rendering, we won't interrupt it. This is intentional, since
+ // entanglement is usually "best effort": we'll try our best to render the
+ // lanes in the same batch, but it's not worth throwing out partially
+ // completed work in order to do it.
+ //
+ // For those exceptions where entanglement is semantically important, like
+ // useMutableSource, we should ensure that there is no partial work at the
+ // time we apply the entanglement.
- var owner = current._debugOwner;
+ var entangledLanes = root.entangledLanes;
- if (owner !== null && typeof owner !== "undefined") {
- return getComponentName(owner.type);
+ if (entangledLanes !== NoLanes) {
+ var entanglements = root.entanglements;
+ var lanes = nextLanes & entangledLanes;
+
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ nextLanes |= entanglements[index];
+ lanes &= ~lane;
}
}
- return null;
+ return nextLanes;
}
-function getCurrentFiberStackInDev() {
- {
- if (current === null) {
- return "";
- } // Safe because if current fiber exists, we are reconciling,
- // and it is guaranteed to be the work-in-progress version.
+function getMostRecentEventTime(root, lanes) {
+ var eventTimes = root.eventTimes;
+ var mostRecentEventTime = NoTimestamp;
- return getStackByFiberInDevAndProd(current);
- }
-}
-function resetCurrentFiber() {
- {
- ReactDebugCurrentFrame.getCurrentStack = null;
- current = null;
- isRendering = false;
- }
-}
-function setCurrentFiber(fiber) {
- {
- ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
- current = fiber;
- isRendering = false;
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ var eventTime = eventTimes[index];
+
+ if (eventTime > mostRecentEventTime) {
+ mostRecentEventTime = eventTime;
+ }
+
+ lanes &= ~lane;
}
+
+ return mostRecentEventTime;
}
-function setIsRendering(rendering) {
- {
- isRendering = rendering;
+
+function computeExpirationTime(lane, currentTime) {
+ // TODO: Expiration heuristic is constant per lane, so could use a map.
+ getHighestPriorityLanes(lane);
+ var priority = return_highestLanePriority;
+
+ if (priority >= InputContinuousLanePriority) {
+ // User interactions should expire slightly more quickly.
+ return currentTime + 1000;
+ } else if (priority >= TransitionLongLanePriority) {
+ return currentTime + 5000;
+ } else {
+ // Anything idle priority or lower should never expire.
+ return NoTimestamp;
}
}
-var ReactStrictModeWarnings = {
- recordUnsafeLifecycleWarnings: function(fiber, instance) {},
- flushPendingUnsafeLifecycleWarnings: function() {},
- recordLegacyContextWarning: function(fiber, instance) {},
- flushLegacyContextWarning: function() {},
- discardPendingWarnings: function() {}
-};
+function markStarvedLanesAsExpired(root, currentTime) {
+ // TODO: This gets called every time we yield. We can optimize by storing
+ // the earliest expiration time on the root. Then use that to quickly bail out
+ // of this function.
+ var pendingLanes = root.pendingLanes;
+ var suspendedLanes = root.suspendedLanes;
+ var pingedLanes = root.pingedLanes;
+ var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their
+ // expiration time. If so, we'll assume the update is being starved and mark
+ // it as expired to force it to finish.
-{
- var findStrictRoot = function(fiber) {
- var maybeStrictRoot = null;
- var node = fiber;
+ var lanes = pendingLanes;
- while (node !== null) {
- if (node.mode & StrictMode) {
- maybeStrictRoot = node;
- }
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ var expirationTime = expirationTimes[index];
- node = node.return;
+ if (expirationTime === NoTimestamp) {
+ // Found a pending lane with no expiration time. If it's not suspended, or
+ // if it's pinged, assume it's CPU-bound. Compute a new expiration time
+ // using the current time.
+ if (
+ (lane & suspendedLanes) === NoLanes ||
+ (lane & pingedLanes) !== NoLanes
+ ) {
+ // Assumes timestamps are monotonically increasing.
+ expirationTimes[index] = computeExpirationTime(lane, currentTime);
+ }
+ } else if (expirationTime <= currentTime) {
+ // This lane expired
+ root.expiredLanes |= lane;
}
- return maybeStrictRoot;
- };
+ lanes &= ~lane;
+ }
+} // This returns the highest priority pending lanes regardless of whether they
+function getLanesToRetrySynchronouslyOnError(root) {
+ var everythingButOffscreen = root.pendingLanes & ~OffscreenLane;
- var setToSortedString = function(set) {
- var array = [];
- set.forEach(function(value) {
- array.push(value);
- });
- return array.sort().join(", ");
- };
+ if (everythingButOffscreen !== NoLanes) {
+ return everythingButOffscreen;
+ }
- var pendingComponentWillMountWarnings = [];
- var pendingUNSAFE_ComponentWillMountWarnings = [];
- var pendingComponentWillReceivePropsWarnings = [];
- var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
- var pendingComponentWillUpdateWarnings = [];
- var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
+ if (everythingButOffscreen & OffscreenLane) {
+ return OffscreenLane;
+ }
- var didWarnAboutUnsafeLifecycles = new Set();
+ return NoLanes;
+}
+function returnNextLanesPriority() {
+ return return_highestLanePriority;
+}
+function includesNonIdleWork(lanes) {
+ return (lanes & NonIdleLanes) !== NoLanes;
+}
+function includesOnlyRetries(lanes) {
+ return (lanes & RetryLanes) === lanes;
+} // To ensure consistency across multiple updates in the same event, this should
+// be a pure function, so that it always returns the same lane for given inputs.
- ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function(
- fiber,
- instance
- ) {
- // Dedup strategy: Warn once per component.
- if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
- return;
- }
+function findUpdateLane(lanePriority, wipLanes) {
+ switch (lanePriority) {
+ case NoLanePriority:
+ break;
- if (
- typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components.
- instance.componentWillMount.__suppressDeprecationWarning !== true
- ) {
- pendingComponentWillMountWarnings.push(fiber);
- }
+ case SyncLanePriority:
+ return SyncLane;
+
+ case SyncBatchedLanePriority:
+ return SyncBatchedLane;
+
+ case InputDiscreteLanePriority: {
+ var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes);
- if (
- fiber.mode & StrictMode &&
- typeof instance.UNSAFE_componentWillMount === "function"
- ) {
- pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
- }
+ if (_lane === NoLane) {
+ // Shift to the next priority level
+ return findUpdateLane(InputContinuousLanePriority, wipLanes);
+ }
- if (
- typeof instance.componentWillReceiveProps === "function" &&
- instance.componentWillReceiveProps.__suppressDeprecationWarning !== true
- ) {
- pendingComponentWillReceivePropsWarnings.push(fiber);
+ return _lane;
}
- if (
- fiber.mode & StrictMode &&
- typeof instance.UNSAFE_componentWillReceiveProps === "function"
- ) {
- pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
- }
+ case InputContinuousLanePriority: {
+ var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes);
- if (
- typeof instance.componentWillUpdate === "function" &&
- instance.componentWillUpdate.__suppressDeprecationWarning !== true
- ) {
- pendingComponentWillUpdateWarnings.push(fiber);
- }
+ if (_lane2 === NoLane) {
+ // Shift to the next priority level
+ return findUpdateLane(DefaultLanePriority, wipLanes);
+ }
- if (
- fiber.mode & StrictMode &&
- typeof instance.UNSAFE_componentWillUpdate === "function"
- ) {
- pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
+ return _lane2;
}
- };
- ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() {
- // We do an initial pass to gather component names
- var componentWillMountUniqueNames = new Set();
+ case DefaultLanePriority: {
+ var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes);
- if (pendingComponentWillMountWarnings.length > 0) {
- pendingComponentWillMountWarnings.forEach(function(fiber) {
- componentWillMountUniqueNames.add(
- getComponentName(fiber.type) || "Component"
+ if (_lane3 === NoLane) {
+ // If all the default lanes are already being worked on, look for a
+ // lane in the transition range.
+ _lane3 = pickArbitraryLane(
+ (TransitionShortLanes | TransitionLongLanes) & ~wipLanes
);
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingComponentWillMountWarnings = [];
- }
- var UNSAFE_componentWillMountUniqueNames = new Set();
+ if (_lane3 === NoLane) {
+ // All the transition lanes are taken, too. This should be very
+ // rare, but as a last resort, pick a default lane. This will have
+ // the effect of interrupting the current work-in-progress render.
+ _lane3 = pickArbitraryLane(DefaultLanes);
+ }
+ }
- if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
- pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) {
- UNSAFE_componentWillMountUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingUNSAFE_ComponentWillMountWarnings = [];
+ return _lane3;
}
- var componentWillReceivePropsUniqueNames = new Set();
+ case TransitionShortLanePriority: // Should be handled by findTransitionLane instead
- if (pendingComponentWillReceivePropsWarnings.length > 0) {
- pendingComponentWillReceivePropsWarnings.forEach(function(fiber) {
- componentWillReceivePropsUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingComponentWillReceivePropsWarnings = [];
- }
+ case TransitionLongLanePriority:
+ case RetryLanePriority:
+ // Should be handled by findRetryLane instead
+ break;
- var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
+ case IdleLanePriority:
+ var lane = pickArbitraryLane(IdleLanes & ~wipLanes);
- if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
- pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) {
- UNSAFE_componentWillReceivePropsUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
- }
+ if (lane === NoLane) {
+ lane = pickArbitraryLane(IdleLanes);
+ }
- var componentWillUpdateUniqueNames = new Set();
+ return lane;
+ }
- if (pendingComponentWillUpdateWarnings.length > 0) {
- pendingComponentWillUpdateWarnings.forEach(function(fiber) {
- componentWillUpdateUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingComponentWillUpdateWarnings = [];
+ {
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+ }
+} // To ensure consistency across multiple updates in the same event, this should
+// be pure function, so that it always returns the same lane for given inputs.
+
+function findTransitionLane(lanePriority, wipLanes, pendingLanes) {
+ if (lanePriority === TransitionShortLanePriority) {
+ // First look for lanes that are completely unclaimed, i.e. have no
+ // pending work.
+ var lane = pickArbitraryLane(TransitionShortLanes & ~pendingLanes);
+
+ if (lane === NoLane) {
+ // If all lanes have pending work, look for a lane that isn't currently
+ // being worked on.
+ lane = pickArbitraryLane(TransitionShortLanes & ~wipLanes);
+
+ if (lane === NoLane) {
+ // If everything is being worked on, pick any lane. This has the
+ // effect of interrupting the current work-in-progress.
+ lane = pickArbitraryLane(TransitionShortLanes);
+ }
}
- var UNSAFE_componentWillUpdateUniqueNames = new Set();
+ return lane;
+ }
- if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
- pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) {
- UNSAFE_componentWillUpdateUniqueNames.add(
- getComponentName(fiber.type) || "Component"
- );
- didWarnAboutUnsafeLifecycles.add(fiber.type);
- });
- pendingUNSAFE_ComponentWillUpdateWarnings = [];
- } // Finally, we flush all the warnings
- // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
+ if (lanePriority === TransitionLongLanePriority) {
+ // First look for lanes that are completely unclaimed, i.e. have no
+ // pending work.
+ var _lane4 = pickArbitraryLane(TransitionLongLanes & ~pendingLanes);
- if (UNSAFE_componentWillMountUniqueNames.size > 0) {
- var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
+ if (_lane4 === NoLane) {
+ // If all lanes have pending work, look for a lane that isn't currently
+ // being worked on.
+ _lane4 = pickArbitraryLane(TransitionLongLanes & ~wipLanes);
- error(
- "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
- "\nPlease update the following components: %s",
- sortedNames
- );
+ if (_lane4 === NoLane) {
+ // If everything is being worked on, pick any lane. This has the
+ // effect of interrupting the current work-in-progress.
+ _lane4 = pickArbitraryLane(TransitionLongLanes);
+ }
}
- if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
- var _sortedNames = setToSortedString(
- UNSAFE_componentWillReceivePropsUniqueNames
- );
+ return _lane4;
+ }
- error(
- "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " +
- "and may indicate bugs in your code. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "* If you're updating state whenever props change, " +
- "refactor your code to use memoization techniques or move it to " +
- "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
- "\nPlease update the following components: %s",
- _sortedNames
- );
- }
+ {
+ throw Error(
+ "Invalid transition priority: " +
+ lanePriority +
+ ". This is a bug in React."
+ );
+ }
+} // To ensure consistency across multiple updates in the same event, this should
+// be pure function, so that it always returns the same lane for given inputs.
- if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
- var _sortedNames2 = setToSortedString(
- UNSAFE_componentWillUpdateUniqueNames
- );
+function findRetryLane(wipLanes) {
+ // This is a fork of `findUpdateLane` designed specifically for Suspense
+ // "retries" — a special update that attempts to flip a Suspense boundary
+ // from its placeholder state to its primary/resolved state.
+ var lane = pickArbitraryLane(RetryLanes & ~wipLanes);
- error(
- "Using UNSAFE_componentWillUpdate in strict mode is not recommended " +
- "and may indicate bugs in your code. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "\nPlease update the following components: %s",
- _sortedNames2
- );
- }
+ if (lane === NoLane) {
+ lane = pickArbitraryLane(RetryLanes);
+ }
- if (componentWillMountUniqueNames.size > 0) {
- var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
+ return lane;
+}
- warn(
- "componentWillMount has been renamed, and is not recommended for use. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
- "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " +
- "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " +
- "To rename all deprecated lifecycles to their new names, you can run " +
- "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
- "\nPlease update the following components: %s",
- _sortedNames3
- );
- }
+function getHighestPriorityLane(lanes) {
+ return lanes & -lanes;
+}
- if (componentWillReceivePropsUniqueNames.size > 0) {
- var _sortedNames4 = setToSortedString(
- componentWillReceivePropsUniqueNames
- );
+function getLowestPriorityLane(lanes) {
+ // This finds the most significant non-zero bit.
+ var index = 31 - clz32(lanes);
+ return index < 0 ? NoLanes : 1 << index;
+}
- warn(
- "componentWillReceiveProps has been renamed, and is not recommended for use. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "* If you're updating state whenever props change, refactor your " +
- "code to use memoization techniques or move it to " +
- "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
- "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " +
- "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " +
- "To rename all deprecated lifecycles to their new names, you can run " +
- "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
- "\nPlease update the following components: %s",
- _sortedNames4
- );
- }
+function getEqualOrHigherPriorityLanes(lanes) {
+ return (getLowestPriorityLane(lanes) << 1) - 1;
+}
- if (componentWillUpdateUniqueNames.size > 0) {
- var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
+function pickArbitraryLane(lanes) {
+ // This wrapper function gets inlined. Only exists so to communicate that it
+ // doesn't matter which bit is selected; you can pick any bit without
+ // affecting the algorithms where its used. Here I'm using
+ // getHighestPriorityLane because it requires the fewest operations.
+ return getHighestPriorityLane(lanes);
+}
- warn(
- "componentWillUpdate has been renamed, and is not recommended for use. " +
- "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
- "* Move data fetching code or side effects to componentDidUpdate.\n" +
- "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " +
- "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " +
- "To rename all deprecated lifecycles to their new names, you can run " +
- "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
- "\nPlease update the following components: %s",
- _sortedNames5
- );
- }
- };
+function pickArbitraryLaneIndex(lanes) {
+ return 31 - clz32(lanes);
+}
+
+function laneToIndex(lane) {
+ return pickArbitraryLaneIndex(lane);
+}
+
+function includesSomeLane(a, b) {
+ return (a & b) !== NoLanes;
+}
+function isSubsetOfLanes(set, subset) {
+ return (set & subset) === subset;
+}
+function mergeLanes(a, b) {
+ return a | b;
+}
+function removeLanes(set, subset) {
+ return set & ~subset;
+} // Seems redundant, but it changes the type from a single lane (used for
+// updates) to a group of lanes (used for flushing work).
+
+function laneToLanes(lane) {
+ return lane;
+}
+function createLaneMap(initial) {
+ return new Array(TotalLanes).fill(initial);
+}
+function markRootUpdated(root, updateLane, eventTime) {
+ root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But
+ // it's not practical to try every single possible combination. We need a
+ // heuristic to decide which lanes to attempt to render, and in which batches.
+ // For now, we use the same heuristic as in the old ExpirationTimes model:
+ // retry any lane at equal or lower priority, but don't try updates at higher
+ // priority without also including the lower priority updates. This works well
+ // when considering updates across different priority levels, but isn't
+ // sufficient for updates within the same priority, since we want to treat
+ // those updates as parallel.
+ // Unsuspend any update at equal or lower priority.
+
+ var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111
+
+ root.suspendedLanes &= higherPriorityLanes;
+ root.pingedLanes &= higherPriorityLanes;
+ var eventTimes = root.eventTimes;
+ var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most
+ // recent event, and we assume time is monotonically increasing.
+
+ eventTimes[index] = eventTime;
+}
+function markRootSuspended(root, suspendedLanes) {
+ root.suspendedLanes |= suspendedLanes;
+ root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times.
+
+ var expirationTimes = root.expirationTimes;
+ var lanes = suspendedLanes;
+
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ expirationTimes[index] = NoTimestamp;
+ lanes &= ~lane;
+ }
+}
+function markRootPinged(root, pingedLanes, eventTime) {
+ root.pingedLanes |= root.suspendedLanes & pingedLanes;
+}
+function markRootExpired(root, expiredLanes) {
+ root.expiredLanes |= expiredLanes & root.pendingLanes;
+}
+function hasDiscreteLanes(lanes) {
+ return (lanes & InputDiscreteLanes) !== NoLanes;
+}
+function markRootMutableRead(root, updateLane) {
+ root.mutableReadLanes |= updateLane & root.pendingLanes;
+}
+function markRootFinished(root, remainingLanes) {
+ var noLongerPendingLanes = root.pendingLanes & ~remainingLanes;
+ root.pendingLanes = remainingLanes; // Let's try everything again
+
+ root.suspendedLanes = 0;
+ root.pingedLanes = 0;
+ root.expiredLanes &= remainingLanes;
+ root.mutableReadLanes &= remainingLanes;
+ root.entangledLanes &= remainingLanes;
+ var entanglements = root.entanglements;
+ var eventTimes = root.eventTimes;
+ var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work
+
+ var lanes = noLongerPendingLanes;
+
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ entanglements[index] = NoLanes;
+ eventTimes[index] = NoTimestamp;
+ expirationTimes[index] = NoTimestamp;
+ lanes &= ~lane;
+ }
+}
+function markRootEntangled(root, entangledLanes) {
+ root.entangledLanes |= entangledLanes;
+ var entanglements = root.entanglements;
+ var lanes = entangledLanes;
+
+ while (lanes > 0) {
+ var index = pickArbitraryLaneIndex(lanes);
+ var lane = 1 << index;
+ entanglements[index] |= entangledLanes;
+ lanes &= ~lane;
+ }
+}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer.
+// Based on:
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
+
+var log = Math.log;
+var LN2 = Math.LN2;
+
+function clz32Fallback(lanes) {
+ if (lanes === 0) {
+ return 32;
+ }
+
+ return (31 - ((log(lanes) / LN2) | 0)) | 0;
+}
+
+// Intentionally not named imports because Rollup would use dynamic dispatch for
+var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
+ Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
+ Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
+ Scheduler_shouldYield = Scheduler.unstable_shouldYield,
+ Scheduler_requestPaint = Scheduler.unstable_requestPaint,
+ Scheduler_now$1 = Scheduler.unstable_now,
+ Scheduler_getCurrentPriorityLevel =
+ Scheduler.unstable_getCurrentPriorityLevel,
+ Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
+ Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
+ Scheduler_NormalPriority = Scheduler.unstable_NormalPriority,
+ Scheduler_LowPriority = Scheduler.unstable_LowPriority,
+ Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
+
+{
+ // Provide explicit error message when production+profiling bundle of e.g.
+ // react-dom is used with production (non-profiling) bundle of
+ // scheduler/tracing
+ if (
+ !(
+ tracing.__interactionsRef != null &&
+ tracing.__interactionsRef.current != null
+ )
+ ) {
+ throw Error(
+ "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling"
+ );
+ }
+}
- var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
+var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
+// ascending numbers so we can compare them like numbers. They start at 90 to
+// avoid clashing with Scheduler's priorities.
- var didWarnAboutLegacyContext = new Set();
+var ImmediatePriority$1 = 99;
+var UserBlockingPriority$1 = 98;
+var NormalPriority$1 = 97;
+var LowPriority$1 = 96;
+var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only.
- ReactStrictModeWarnings.recordLegacyContextWarning = function(
- fiber,
- instance
- ) {
- var strictRoot = findStrictRoot(fiber);
+var NoPriority$1 = 90;
+var shouldYield = Scheduler_shouldYield;
+var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
+ Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {};
+var syncQueue = null;
+var immediateQueueCallbackNode = null;
+var isFlushingSyncQueue = false;
+var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
+// This will be the case for modern browsers that support `performance.now`. In
+// older browsers, Scheduler falls back to `Date.now`, which returns a Unix
+// timestamp. In that case, subtract the module initialization time to simulate
+// the behavior of performance.now and keep our times small enough to fit
+// within 32 bits.
+// TODO: Consider lifting this into Scheduler.
- if (strictRoot === null) {
- error(
- "Expected to find a StrictMode component in a strict mode tree. " +
- "This error is likely caused by a bug in React. Please file an issue."
- );
+var now =
+ initialTimeMs$1 < 10000
+ ? Scheduler_now$1
+ : function() {
+ return Scheduler_now$1() - initialTimeMs$1;
+ };
+function getCurrentPriorityLevel() {
+ switch (Scheduler_getCurrentPriorityLevel()) {
+ case Scheduler_ImmediatePriority:
+ return ImmediatePriority$1;
- return;
- } // Dedup strategy: Warn once per component.
+ case Scheduler_UserBlockingPriority:
+ return UserBlockingPriority$1;
- if (didWarnAboutLegacyContext.has(fiber.type)) {
- return;
- }
+ case Scheduler_NormalPriority:
+ return NormalPriority$1;
- var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
+ case Scheduler_LowPriority:
+ return LowPriority$1;
- if (
- fiber.type.contextTypes != null ||
- fiber.type.childContextTypes != null ||
- (instance !== null && typeof instance.getChildContext === "function")
- ) {
- if (warningsForRoot === undefined) {
- warningsForRoot = [];
- pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
- }
+ case Scheduler_IdlePriority:
+ return IdlePriority$1;
- warningsForRoot.push(fiber);
+ default: {
+ throw Error("Unknown priority level.");
}
- };
+ }
+}
- ReactStrictModeWarnings.flushLegacyContextWarning = function() {
- pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) {
- if (fiberArray.length === 0) {
- return;
- }
+function reactPriorityToSchedulerPriority(reactPriorityLevel) {
+ switch (reactPriorityLevel) {
+ case ImmediatePriority$1:
+ return Scheduler_ImmediatePriority;
- var firstFiber = fiberArray[0];
- var uniqueNames = new Set();
- fiberArray.forEach(function(fiber) {
- uniqueNames.add(getComponentName(fiber.type) || "Component");
- didWarnAboutLegacyContext.add(fiber.type);
- });
- var sortedNames = setToSortedString(uniqueNames);
- var firstComponentStack = getStackByFiberInDevAndProd(firstFiber);
+ case UserBlockingPriority$1:
+ return Scheduler_UserBlockingPriority;
- error(
- "Legacy context API has been detected within a strict-mode tree." +
- "\n\nThe old API will be supported in all 16.x releases, but applications " +
- "using it should migrate to the new version." +
- "\n\nPlease update the following components: %s" +
- "\n\nLearn more about this warning here: https://fb.me/react-legacy-context" +
- "%s",
- sortedNames,
- firstComponentStack
- );
- });
- };
+ case NormalPriority$1:
+ return Scheduler_NormalPriority;
- ReactStrictModeWarnings.discardPendingWarnings = function() {
- pendingComponentWillMountWarnings = [];
- pendingUNSAFE_ComponentWillMountWarnings = [];
- pendingComponentWillReceivePropsWarnings = [];
- pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
- pendingComponentWillUpdateWarnings = [];
- pendingUNSAFE_ComponentWillUpdateWarnings = [];
- pendingLegacyContextWarning = new Map();
- };
-}
+ case LowPriority$1:
+ return Scheduler_LowPriority;
-var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
+ case IdlePriority$1:
+ return Scheduler_IdlePriority;
-var failedBoundaries = null;
-var setRefreshHandler = function(handler) {
- {
- resolveFamily = handler;
- }
-};
-function resolveFunctionForHotReloading(type) {
- {
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return type;
+ default: {
+ throw Error("Unknown priority level.");
}
+ }
+}
- var family = resolveFamily(type);
+function runWithPriority(reactPriorityLevel, fn) {
+ var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
+ return Scheduler_runWithPriority(priorityLevel, fn);
+}
+function scheduleCallback(reactPriorityLevel, callback, options) {
+ var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
+ return Scheduler_scheduleCallback(priorityLevel, callback, options);
+}
+function scheduleSyncCallback(callback) {
+ // Push this callback into an internal queue. We'll flush these either in
+ // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
+ if (syncQueue === null) {
+ syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
- if (family === undefined) {
- return type;
- } // Use the latest known implementation.
+ immediateQueueCallbackNode = Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueueImpl
+ );
+ } else {
+ // Push onto existing queue. Don't need to schedule a callback because
+ // we already scheduled one when we created the queue.
+ syncQueue.push(callback);
+ }
- return family.current;
+ return fakeCallbackNode;
+}
+function cancelCallback(callbackNode) {
+ if (callbackNode !== fakeCallbackNode) {
+ Scheduler_cancelCallback(callbackNode);
}
}
-function resolveClassForHotReloading(type) {
- // No implementation differences.
- return resolveFunctionForHotReloading(type);
+function flushSyncCallbackQueue() {
+ if (immediateQueueCallbackNode !== null) {
+ var node = immediateQueueCallbackNode;
+ immediateQueueCallbackNode = null;
+ Scheduler_cancelCallback(node);
+ }
+
+ flushSyncCallbackQueueImpl();
}
-function resolveForwardRefForHotReloading(type) {
- {
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return type;
+
+function flushSyncCallbackQueueImpl() {
+ if (!isFlushingSyncQueue && syncQueue !== null) {
+ // Prevent re-entrancy.
+ isFlushingSyncQueue = true;
+ var i = 0;
+
+ try {
+ var _isSync = true;
+ var queue = syncQueue;
+ setCurrentUpdateLanePriority(SyncLanePriority);
+ runWithPriority(ImmediatePriority$1, function() {
+ for (; i < queue.length; i++) {
+ var callback = queue[i];
+
+ do {
+ callback = callback(_isSync);
+ } while (callback !== null);
+ }
+ });
+ syncQueue = null;
+ } catch (error) {
+ // If something throws, leave the remaining callbacks on the queue.
+ if (syncQueue !== null) {
+ syncQueue = syncQueue.slice(i + 1);
+ } // Resume flushing in the next tick
+
+ Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueue
+ );
+ throw error;
+ } finally {
+ isFlushingSyncQueue = false;
}
+ }
+}
- var family = resolveFamily(type);
+function describeFiber(fiber) {
+ var owner = fiber._debugOwner ? fiber._debugOwner.type : null;
+ var source = fiber._debugSource;
- if (family === undefined) {
- // Check if we're dealing with a real forwardRef. Don't want to crash early.
- if (
- type !== null &&
- type !== undefined &&
- typeof type.render === "function"
- ) {
- // ForwardRef is special because its resolved .type is an object,
- // but it's possible that we only have its inner render function in the map.
- // If that inner render function is different, we'll build a new forwardRef type.
- var currentRender = resolveFunctionForHotReloading(type.render);
+ switch (fiber.tag) {
+ case HostComponent:
+ return describeBuiltInComponentFrame(fiber.type, source, owner);
- if (type.render !== currentRender) {
- var syntheticType = {
- $$typeof: REACT_FORWARD_REF_TYPE,
- render: currentRender
- };
+ case LazyComponent:
+ return describeBuiltInComponentFrame("Lazy", source, owner);
- if (type.displayName !== undefined) {
- syntheticType.displayName = type.displayName;
- }
+ case SuspenseComponent:
+ return describeBuiltInComponentFrame("Suspense", source, owner);
- return syntheticType;
- }
- }
+ case SuspenseListComponent:
+ return describeBuiltInComponentFrame("SuspenseList", source, owner);
- return type;
- } // Use the latest known implementation.
+ case FunctionComponent:
+ case IndeterminateComponent:
+ case SimpleMemoComponent:
+ return describeFunctionComponentFrame(fiber.type, source, owner);
- return family.current;
- }
-}
-function isCompatibleFamilyForHotReloading(fiber, element) {
- {
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return false;
- }
+ case ForwardRef:
+ return describeFunctionComponentFrame(fiber.type.render, source, owner);
- var prevType = fiber.elementType;
- var nextType = element.type; // If we got here, we know types aren't === equal.
+ case Block:
+ return describeFunctionComponentFrame(fiber.type._render, source, owner);
- var needsCompareFamilies = false;
- var $$typeofNextType =
- typeof nextType === "object" && nextType !== null
- ? nextType.$$typeof
- : null;
+ case ClassComponent:
+ return describeClassComponentFrame(fiber.type, source, owner);
- switch (fiber.tag) {
- case ClassComponent: {
- if (typeof nextType === "function") {
- needsCompareFamilies = true;
- }
+ default:
+ return "";
+ }
+}
- break;
- }
+function getStackByFiberInDevAndProd(workInProgress) {
+ try {
+ var info = "";
+ var node = workInProgress;
- case FunctionComponent: {
- if (typeof nextType === "function") {
- needsCompareFamilies = true;
- } else if ($$typeofNextType === REACT_LAZY_TYPE) {
- // We don't know the inner type yet.
- // We're going to assume that the lazy inner type is stable,
- // and so it is sufficient to avoid reconciling it away.
- // We're not going to unwrap or actually use the new lazy type.
- needsCompareFamilies = true;
- }
+ do {
+ info += describeFiber(node);
+ node = node.return;
+ } while (node);
- break;
- }
+ return info;
+ } catch (x) {
+ return "\nError generating stack: " + x.message + "\n" + x.stack;
+ }
+}
- case ForwardRef: {
- if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
- needsCompareFamilies = true;
- } else if ($$typeofNextType === REACT_LAZY_TYPE) {
- needsCompareFamilies = true;
- }
+var NoMode = 0;
+var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
+// tag instead
- break;
- }
+var BlockingMode = 2;
+var ConcurrentMode = 4;
+var ProfileMode = 8;
+var DebugTracingMode = 16;
- case MemoComponent:
- case SimpleMemoComponent: {
- if ($$typeofNextType === REACT_MEMO_TYPE) {
- // TODO: if it was but can no longer be simple,
- // we shouldn't set this.
- needsCompareFamilies = true;
- } else if ($$typeofNextType === REACT_LAZY_TYPE) {
- needsCompareFamilies = true;
- }
+/**
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
+ */
+function is(x, y) {
+ return (
+ (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
+ );
+}
- break;
- }
+var objectIs = typeof Object.is === "function" ? Object.is : is;
- default:
- return false;
- } // Check if both types have a family and it's the same one.
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+/**
+ * Performs equality by iterating through keys on an object and returning false
+ * when any key has values which are not strictly equal between the arguments.
+ * Returns true when the values of all keys are strictly equal.
+ */
- if (needsCompareFamilies) {
- // Note: memo() and forwardRef() we'll compare outer rather than inner type.
- // This means both of them need to be registered to preserve state.
- // If we unwrapped and compared the inner types for wrappers instead,
- // then we would risk falsely saying two separate memo(Foo)
- // calls are equivalent because they wrap the same Foo function.
- var prevFamily = resolveFamily(prevType);
+function shallowEqual(objA, objB) {
+ if (objectIs(objA, objB)) {
+ return true;
+ }
- if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
- return true;
- }
- }
+ if (
+ typeof objA !== "object" ||
+ objA === null ||
+ typeof objB !== "object" ||
+ objB === null
+ ) {
+ return false;
+ }
+
+ var keysA = Object.keys(objA);
+ var keysB = Object.keys(objB);
+ if (keysA.length !== keysB.length) {
return false;
+ } // Test for A's keys different from B.
+
+ for (var i = 0; i < keysA.length; i++) {
+ if (
+ !hasOwnProperty.call(objB, keysA[i]) ||
+ !objectIs(objA[keysA[i]], objB[keysA[i]])
+ ) {
+ return false;
+ }
}
+
+ return true;
}
-function markFailedErrorBoundaryForHotReloading(fiber) {
+
+var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
+var current = null;
+var isRendering = false;
+function getCurrentFiberOwnerNameInDevOrNull() {
{
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return;
+ if (current === null) {
+ return null;
}
- if (typeof WeakSet !== "function") {
- return;
- }
+ var owner = current._debugOwner;
- if (failedBoundaries === null) {
- failedBoundaries = new WeakSet();
+ if (owner !== null && typeof owner !== "undefined") {
+ return getComponentName(owner.type);
}
-
- failedBoundaries.add(fiber);
}
+
+ return null;
}
-var scheduleRefresh = function(root, update) {
+
+function getCurrentFiberStackInDev() {
{
- if (resolveFamily === null) {
- // Hot reloading is disabled.
- return;
- }
+ if (current === null) {
+ return "";
+ } // Safe because if current fiber exists, we are reconciling,
+ // and it is guaranteed to be the work-in-progress version.
- var staleFamilies = update.staleFamilies,
- updatedFamilies = update.updatedFamilies;
- flushPassiveEffects();
- flushSync(function() {
- scheduleFibersWithFamiliesRecursively(
- root.current,
- updatedFamilies,
- staleFamilies
- );
- });
+ return getStackByFiberInDevAndProd(current);
}
-};
-var scheduleRoot = function(root, element) {
+}
+
+function resetCurrentFiber() {
{
- if (root.context !== emptyContextObject) {
- // Super edge case: root has a legacy _renderSubtree context
- // but we don't know the parentComponent so we can't pass it.
- // Just ignore. We'll delete this with _renderSubtree code path later.
- return;
+ ReactDebugCurrentFrame$1.getCurrentStack = null;
+ current = null;
+ isRendering = false;
+ }
+}
+function setCurrentFiber(fiber) {
+ {
+ ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev;
+ current = fiber;
+ isRendering = false;
+ }
+}
+function setIsRendering(rendering) {
+ {
+ isRendering = rendering;
+ }
+}
+function getIsRendering() {
+ {
+ return isRendering;
+ }
+}
+
+var ReactStrictModeWarnings = {
+ recordUnsafeLifecycleWarnings: function(fiber, instance) {},
+ flushPendingUnsafeLifecycleWarnings: function() {},
+ recordLegacyContextWarning: function(fiber, instance) {},
+ flushLegacyContextWarning: function() {},
+ discardPendingWarnings: function() {}
+};
+
+{
+ var findStrictRoot = function(fiber) {
+ var maybeStrictRoot = null;
+ var node = fiber;
+
+ while (node !== null) {
+ if (node.mode & StrictMode) {
+ maybeStrictRoot = node;
+ }
+
+ node = node.return;
}
- flushPassiveEffects();
- syncUpdates(function() {
- updateContainer(element, root, null, null);
+ return maybeStrictRoot;
+ };
+
+ var setToSortedString = function(set) {
+ var array = [];
+ set.forEach(function(value) {
+ array.push(value);
});
- }
-};
+ return array.sort().join(", ");
+ };
-function scheduleFibersWithFamiliesRecursively(
- fiber,
- updatedFamilies,
- staleFamilies
-) {
- {
- var alternate = fiber.alternate,
- child = fiber.child,
- sibling = fiber.sibling,
- tag = fiber.tag,
- type = fiber.type;
- var candidateType = null;
+ var pendingComponentWillMountWarnings = [];
+ var pendingUNSAFE_ComponentWillMountWarnings = [];
+ var pendingComponentWillReceivePropsWarnings = [];
+ var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
+ var pendingComponentWillUpdateWarnings = [];
+ var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
- switch (tag) {
- case FunctionComponent:
- case SimpleMemoComponent:
- case ClassComponent:
- candidateType = type;
- break;
+ var didWarnAboutUnsafeLifecycles = new Set();
+
+ ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function(
+ fiber,
+ instance
+ ) {
+ // Dedup strategy: Warn once per component.
+ if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
+ return;
+ }
+
+ if (
+ typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components.
+ instance.componentWillMount.__suppressDeprecationWarning !== true
+ ) {
+ pendingComponentWillMountWarnings.push(fiber);
+ }
+
+ if (
+ fiber.mode & StrictMode &&
+ typeof instance.UNSAFE_componentWillMount === "function"
+ ) {
+ pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
+ }
- case ForwardRef:
- candidateType = type.render;
- break;
+ if (
+ typeof instance.componentWillReceiveProps === "function" &&
+ instance.componentWillReceiveProps.__suppressDeprecationWarning !== true
+ ) {
+ pendingComponentWillReceivePropsWarnings.push(fiber);
}
- if (resolveFamily === null) {
- throw new Error("Expected resolveFamily to be set during hot reload.");
+ if (
+ fiber.mode & StrictMode &&
+ typeof instance.UNSAFE_componentWillReceiveProps === "function"
+ ) {
+ pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
}
- var needsRender = false;
- var needsRemount = false;
+ if (
+ typeof instance.componentWillUpdate === "function" &&
+ instance.componentWillUpdate.__suppressDeprecationWarning !== true
+ ) {
+ pendingComponentWillUpdateWarnings.push(fiber);
+ }
- if (candidateType !== null) {
- var family = resolveFamily(candidateType);
+ if (
+ fiber.mode & StrictMode &&
+ typeof instance.UNSAFE_componentWillUpdate === "function"
+ ) {
+ pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
+ }
+ };
- if (family !== undefined) {
- if (staleFamilies.has(family)) {
- needsRemount = true;
- } else if (updatedFamilies.has(family)) {
- if (tag === ClassComponent) {
- needsRemount = true;
- } else {
- needsRender = true;
- }
- }
- }
+ ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() {
+ // We do an initial pass to gather component names
+ var componentWillMountUniqueNames = new Set();
+
+ if (pendingComponentWillMountWarnings.length > 0) {
+ pendingComponentWillMountWarnings.forEach(function(fiber) {
+ componentWillMountUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingComponentWillMountWarnings = [];
}
- if (failedBoundaries !== null) {
- if (
- failedBoundaries.has(fiber) ||
- (alternate !== null && failedBoundaries.has(alternate))
- ) {
- needsRemount = true;
- }
+ var UNSAFE_componentWillMountUniqueNames = new Set();
+
+ if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
+ pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) {
+ UNSAFE_componentWillMountUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingUNSAFE_ComponentWillMountWarnings = [];
}
- if (needsRemount) {
- fiber._debugNeedsRemount = true;
+ var componentWillReceivePropsUniqueNames = new Set();
+
+ if (pendingComponentWillReceivePropsWarnings.length > 0) {
+ pendingComponentWillReceivePropsWarnings.forEach(function(fiber) {
+ componentWillReceivePropsUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingComponentWillReceivePropsWarnings = [];
}
- if (needsRemount || needsRender) {
- scheduleWork(fiber, Sync);
+ var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
+
+ if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
+ pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) {
+ UNSAFE_componentWillReceivePropsUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
}
- if (child !== null && !needsRemount) {
- scheduleFibersWithFamiliesRecursively(
- child,
- updatedFamilies,
- staleFamilies
- );
+ var componentWillUpdateUniqueNames = new Set();
+
+ if (pendingComponentWillUpdateWarnings.length > 0) {
+ pendingComponentWillUpdateWarnings.forEach(function(fiber) {
+ componentWillUpdateUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingComponentWillUpdateWarnings = [];
}
- if (sibling !== null) {
- scheduleFibersWithFamiliesRecursively(
- sibling,
- updatedFamilies,
- staleFamilies
+ var UNSAFE_componentWillUpdateUniqueNames = new Set();
+
+ if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
+ pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) {
+ UNSAFE_componentWillUpdateUniqueNames.add(
+ getComponentName(fiber.type) || "Component"
+ );
+ didWarnAboutUnsafeLifecycles.add(fiber.type);
+ });
+ pendingUNSAFE_ComponentWillUpdateWarnings = [];
+ } // Finally, we flush all the warnings
+ // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
+
+ if (UNSAFE_componentWillMountUniqueNames.size > 0) {
+ var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
+
+ error(
+ "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
+ "\nPlease update the following components: %s",
+ sortedNames
);
}
- }
-}
-var findHostInstancesForRefresh = function(root, families) {
- {
- var hostInstances = new Set();
- var types = new Set(
- families.map(function(family) {
- return family.current;
- })
- );
- findHostInstancesForMatchingFibersRecursively(
- root.current,
- types,
- hostInstances
- );
- return hostInstances;
- }
-};
+ if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
+ var _sortedNames = setToSortedString(
+ UNSAFE_componentWillReceivePropsUniqueNames
+ );
-function findHostInstancesForMatchingFibersRecursively(
- fiber,
- types,
- hostInstances
-) {
- {
- var child = fiber.child,
- sibling = fiber.sibling,
- tag = fiber.tag,
- type = fiber.type;
- var candidateType = null;
+ error(
+ "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " +
+ "and may indicate bugs in your code. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "* If you're updating state whenever props change, " +
+ "refactor your code to use memoization techniques or move it to " +
+ "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames
+ );
+ }
- switch (tag) {
- case FunctionComponent:
- case SimpleMemoComponent:
- case ClassComponent:
- candidateType = type;
- break;
+ if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
+ var _sortedNames2 = setToSortedString(
+ UNSAFE_componentWillUpdateUniqueNames
+ );
- case ForwardRef:
- candidateType = type.render;
- break;
+ error(
+ "Using UNSAFE_componentWillUpdate in strict mode is not recommended " +
+ "and may indicate bugs in your code. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames2
+ );
}
- var didMatch = false;
+ if (componentWillMountUniqueNames.size > 0) {
+ var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
- if (candidateType !== null) {
- if (types.has(candidateType)) {
- didMatch = true;
- }
+ warn(
+ "componentWillMount has been renamed, and is not recommended for use. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" +
+ "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " +
+ "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " +
+ "To rename all deprecated lifecycles to their new names, you can run " +
+ "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames3
+ );
}
- if (didMatch) {
- // We have a match. This only drills down to the closest host components.
- // There's no need to search deeper because for the purpose of giving
- // visual feedback, "flashing" outermost parent rectangles is sufficient.
- findHostInstancesForFiberShallowly(fiber, hostInstances);
- } else {
- // If there's no match, maybe there will be one further down in the child tree.
- if (child !== null) {
- findHostInstancesForMatchingFibersRecursively(
- child,
- types,
- hostInstances
- );
- }
- }
+ if (componentWillReceivePropsUniqueNames.size > 0) {
+ var _sortedNames4 = setToSortedString(
+ componentWillReceivePropsUniqueNames
+ );
- if (sibling !== null) {
- findHostInstancesForMatchingFibersRecursively(
- sibling,
- types,
- hostInstances
+ warn(
+ "componentWillReceiveProps has been renamed, and is not recommended for use. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "* If you're updating state whenever props change, refactor your " +
+ "code to use memoization techniques or move it to " +
+ "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" +
+ "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " +
+ "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " +
+ "To rename all deprecated lifecycles to their new names, you can run " +
+ "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames4
);
}
- }
-}
-function findHostInstancesForFiberShallowly(fiber, hostInstances) {
- {
- var foundHostInstances = findChildHostInstancesForFiberShallowly(
- fiber,
- hostInstances
- );
+ if (componentWillUpdateUniqueNames.size > 0) {
+ var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
- if (foundHostInstances) {
- return;
- } // If we didn't find any host children, fallback to closest host parent.
+ warn(
+ "componentWillUpdate has been renamed, and is not recommended for use. " +
+ "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" +
+ "* Move data fetching code or side effects to componentDidUpdate.\n" +
+ "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " +
+ "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " +
+ "To rename all deprecated lifecycles to their new names, you can run " +
+ "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" +
+ "\nPlease update the following components: %s",
+ _sortedNames5
+ );
+ }
+ };
- var node = fiber;
+ var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
- while (true) {
- switch (node.tag) {
- case HostComponent:
- hostInstances.add(node.stateNode);
- return;
+ var didWarnAboutLegacyContext = new Set();
- case HostPortal:
- hostInstances.add(node.stateNode.containerInfo);
- return;
+ ReactStrictModeWarnings.recordLegacyContextWarning = function(
+ fiber,
+ instance
+ ) {
+ var strictRoot = findStrictRoot(fiber);
- case HostRoot:
- hostInstances.add(node.stateNode.containerInfo);
- return;
- }
+ if (strictRoot === null) {
+ error(
+ "Expected to find a StrictMode component in a strict mode tree. " +
+ "This error is likely caused by a bug in React. Please file an issue."
+ );
- if (node.return === null) {
- throw new Error("Expected to reach root first.");
- }
+ return;
+ } // Dedup strategy: Warn once per component.
- node = node.return;
+ if (didWarnAboutLegacyContext.has(fiber.type)) {
+ return;
}
- }
-}
-function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
- {
- var node = fiber;
- var foundHostInstances = false;
+ var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
- while (true) {
- if (node.tag === HostComponent) {
- // We got a match.
- foundHostInstances = true;
- hostInstances.add(node.stateNode); // There may still be more, so keep searching.
- } else if (node.child !== null) {
- node.child.return = node;
- node = node.child;
- continue;
+ if (
+ fiber.type.contextTypes != null ||
+ fiber.type.childContextTypes != null ||
+ (instance !== null && typeof instance.getChildContext === "function")
+ ) {
+ if (warningsForRoot === undefined) {
+ warningsForRoot = [];
+ pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
}
- if (node === fiber) {
- return foundHostInstances;
+ warningsForRoot.push(fiber);
+ }
+ };
+
+ ReactStrictModeWarnings.flushLegacyContextWarning = function() {
+ pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) {
+ if (fiberArray.length === 0) {
+ return;
}
- while (node.sibling === null) {
- if (node.return === null || node.return === fiber) {
- return foundHostInstances;
- }
+ var firstFiber = fiberArray[0];
+ var uniqueNames = new Set();
+ fiberArray.forEach(function(fiber) {
+ uniqueNames.add(getComponentName(fiber.type) || "Component");
+ didWarnAboutLegacyContext.add(fiber.type);
+ });
+ var sortedNames = setToSortedString(uniqueNames);
- node = node.return;
- }
+ try {
+ setCurrentFiber(firstFiber);
- node.sibling.return = node.return;
- node = node.sibling;
- }
- }
+ error(
+ "Legacy context API has been detected within a strict-mode tree." +
+ "\n\nThe old API will be supported in all 16.x releases, but applications " +
+ "using it should migrate to the new version." +
+ "\n\nPlease update the following components: %s" +
+ "\n\nLearn more about this warning here: https://fb.me/react-legacy-context",
+ sortedNames
+ );
+ } finally {
+ resetCurrentFiber();
+ }
+ });
+ };
- return false;
+ ReactStrictModeWarnings.discardPendingWarnings = function() {
+ pendingComponentWillMountWarnings = [];
+ pendingUNSAFE_ComponentWillMountWarnings = [];
+ pendingComponentWillReceivePropsWarnings = [];
+ pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
+ pendingComponentWillUpdateWarnings = [];
+ pendingUNSAFE_ComponentWillUpdateWarnings = [];
+ pendingLegacyContextWarning = new Map();
+ };
}
function resolveDefaultProps(Component, baseProps) {
@@ -6423,15 +6598,11 @@ function resolveDefaultProps(Component, baseProps) {
return baseProps;
}
-function readLazyComponentType(lazyComponent) {
- initializeLazyComponentType(lazyComponent);
-
- if (lazyComponent._status !== Resolved) {
- throw lazyComponent._result;
- }
- return lazyComponent._result;
-}
+// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
+// Math.pow(2, 30) - 1
+// 0b111111111111111111111111111111
+var MAX_SIGNED_31_BIT_INT = 1073741823;
var valueCursor = createCursor(null);
var rendererSigil;
@@ -6521,28 +6692,24 @@ function calculateChangedBits(context, newValue, oldValue) {
return changedBits | 0;
}
}
-function scheduleWorkOnParentPath(parent, renderExpirationTime) {
- // Update the child expiration time of all the ancestors, including
- // the alternates.
+function scheduleWorkOnParentPath(parent, renderLanes) {
+ // Update the child lanes of all the ancestors, including the alternates.
var node = parent;
while (node !== null) {
var alternate = node.alternate;
- if (node.childExpirationTime < renderExpirationTime) {
- node.childExpirationTime = renderExpirationTime;
+ if (!isSubsetOfLanes(node.childLanes, renderLanes)) {
+ node.childLanes = mergeLanes(node.childLanes, renderLanes);
- if (
- alternate !== null &&
- alternate.childExpirationTime < renderExpirationTime
- ) {
- alternate.childExpirationTime = renderExpirationTime;
+ if (alternate !== null) {
+ alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
}
} else if (
alternate !== null &&
- alternate.childExpirationTime < renderExpirationTime
+ !isSubsetOfLanes(alternate.childLanes, renderLanes)
) {
- alternate.childExpirationTime = renderExpirationTime;
+ alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
} else {
// Neither alternate was updated, which means the rest of the
// ancestor path already has sufficient priority.
@@ -6556,7 +6723,7 @@ function propagateContextChange(
workInProgress,
context,
changedBits,
- renderExpirationTime
+ renderLanes
) {
var fiber = workInProgress.child;
@@ -6583,7 +6750,11 @@ function propagateContextChange(
// Match! Schedule an update on this fiber.
if (fiber.tag === ClassComponent) {
// Schedule a force update on the work-in-progress.
- var update = createUpdate(renderExpirationTime, null);
+ var update = createUpdate(
+ NoTimestamp,
+ pickArbitraryLane(renderLanes),
+ null
+ );
update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
// update to the current fiber, too, which means it will persist even if
// this render is thrown away. Since it's a race condition, not sure it's
@@ -6592,24 +6763,16 @@ function propagateContextChange(
enqueueUpdate(fiber, update);
}
- if (fiber.expirationTime < renderExpirationTime) {
- fiber.expirationTime = renderExpirationTime;
- }
-
+ fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
var alternate = fiber.alternate;
- if (
- alternate !== null &&
- alternate.expirationTime < renderExpirationTime
- ) {
- alternate.expirationTime = renderExpirationTime;
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
}
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
+ scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too.
- if (list.expirationTime < renderExpirationTime) {
- list.expirationTime = renderExpirationTime;
- } // Since we already found a match, we can stop traversing the
+ list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the
// dependency list.
break;
@@ -6655,7 +6818,7 @@ function propagateContextChange(
fiber = nextFiber;
}
}
-function prepareToReadContext(workInProgress, renderExpirationTime) {
+function prepareToReadContext(workInProgress, renderLanes) {
currentlyRenderingFiber = workInProgress;
lastContextDependency = null;
lastContextWithAllBitsObserved = null;
@@ -6665,7 +6828,7 @@ function prepareToReadContext(workInProgress, renderExpirationTime) {
var firstContext = dependencies.firstContext;
if (firstContext !== null) {
- if (dependencies.expirationTime >= renderExpirationTime) {
+ if (includesSomeLane(dependencies.lanes, renderLanes)) {
// Context list has a pending update. Mark that this fiber performed work.
markWorkInProgressReceivedUpdate();
} // Reset the work-in-progress list
@@ -6719,7 +6882,7 @@ function readContext(context, observedBits) {
lastContextDependency = contextItem;
currentlyRenderingFiber.dependencies = {
- expirationTime: NoWork,
+ lanes: NoLanes,
firstContext: contextItem,
responders: null
};
@@ -6751,7 +6914,8 @@ var currentlyProcessingQueue;
function initializeUpdateQueue(fiber) {
var queue = {
baseState: fiber.memoizedState,
- baseQueue: null,
+ firstBaseUpdate: null,
+ lastBaseUpdate: null,
shared: {
pending: null
},
@@ -6767,28 +6931,24 @@ function cloneUpdateQueue(current, workInProgress) {
if (queue === currentQueue) {
var clone = {
baseState: currentQueue.baseState,
- baseQueue: currentQueue.baseQueue,
+ firstBaseUpdate: currentQueue.firstBaseUpdate,
+ lastBaseUpdate: currentQueue.lastBaseUpdate,
shared: currentQueue.shared,
effects: currentQueue.effects
};
workInProgress.updateQueue = clone;
}
}
-function createUpdate(expirationTime, suspenseConfig) {
+function createUpdate(eventTime, lane, suspenseConfig) {
var update = {
- expirationTime: expirationTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
tag: UpdateState,
payload: null,
callback: null,
next: null
};
- update.next = update;
-
- {
- update.priority = getCurrentPriorityLevel();
- }
-
return update;
}
function enqueueUpdate(fiber, update) {
@@ -6828,25 +6988,85 @@ function enqueueUpdate(fiber, update) {
}
}
}
-function enqueueCapturedUpdate(workInProgress, update) {
+function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
+ // Captured updates are updates that are thrown by a child during the render
+ // phase. They should be discarded if the render is aborted. Therefore,
+ // we should only put them on the work-in-progress queue, not the current one.
+ var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone.
+
var current = workInProgress.alternate;
if (current !== null) {
- // Ensure the work-in-progress queue is a clone
- cloneUpdateQueue(current, workInProgress);
- } // Captured updates go only on the work-in-progress queue.
+ var currentQueue = current.updateQueue;
+
+ if (queue === currentQueue) {
+ // The work-in-progress queue is the same as current. This happens when
+ // we bail out on a parent fiber that then captures an error thrown by
+ // a child. Since we want to append the update only to the work-in
+ // -progress queue, we need to clone the updates. We usually clone during
+ // processUpdateQueue, but that didn't happen in this case because we
+ // skipped over the parent when we bailed out.
+ var newFirst = null;
+ var newLast = null;
+ var firstBaseUpdate = queue.firstBaseUpdate;
+
+ if (firstBaseUpdate !== null) {
+ // Loop through the updates and clone them.
+ var update = firstBaseUpdate;
+
+ do {
+ var clone = {
+ eventTime: update.eventTime,
+ lane: update.lane,
+ suspenseConfig: update.suspenseConfig,
+ tag: update.tag,
+ payload: update.payload,
+ callback: update.callback,
+ next: null
+ };
- var queue = workInProgress.updateQueue; // Append the update to the end of the list.
+ if (newLast === null) {
+ newFirst = newLast = clone;
+ } else {
+ newLast.next = clone;
+ newLast = clone;
+ }
- var last = queue.baseQueue;
+ update = update.next;
+ } while (update !== null); // Append the captured update the end of the cloned list.
- if (last === null) {
- queue.baseQueue = update.next = update;
- update.next = update;
+ if (newLast === null) {
+ newFirst = newLast = capturedUpdate;
+ } else {
+ newLast.next = capturedUpdate;
+ newLast = capturedUpdate;
+ }
+ } else {
+ // There are no base updates.
+ newFirst = newLast = capturedUpdate;
+ }
+
+ queue = {
+ baseState: currentQueue.baseState,
+ firstBaseUpdate: newFirst,
+ lastBaseUpdate: newLast,
+ shared: currentQueue.shared,
+ effects: currentQueue.effects
+ };
+ workInProgress.updateQueue = queue;
+ return;
+ }
+ } // Append the update to the end of the list.
+
+ var lastBaseUpdate = queue.lastBaseUpdate;
+
+ if (lastBaseUpdate === null) {
+ queue.firstBaseUpdate = capturedUpdate;
} else {
- update.next = last.next;
- last.next = update;
+ lastBaseUpdate.next = capturedUpdate;
}
+
+ queue.lastBaseUpdate = capturedUpdate;
}
function getStateFromUpdate(
@@ -6865,15 +7085,21 @@ function getStateFromUpdate(
// Updater function
{
enterDisallowedContextReadInDEV();
-
- if (workInProgress.mode & StrictMode) {
- payload.call(instance, prevState, nextProps);
- }
}
var nextState = payload.call(instance, prevState, nextProps);
{
+ if (workInProgress.mode & StrictMode) {
+ disableLogs();
+
+ try {
+ payload.call(instance, prevState, nextProps);
+ } finally {
+ reenableLogs();
+ }
+ }
+
exitDisallowedContextReadInDEV();
}
@@ -6897,15 +7123,21 @@ function getStateFromUpdate(
// Updater function
{
enterDisallowedContextReadInDEV();
-
- if (workInProgress.mode & StrictMode) {
- _payload.call(instance, prevState, nextProps);
- }
}
partialState = _payload.call(instance, prevState, nextProps);
{
+ if (workInProgress.mode & StrictMode) {
+ disableLogs();
+
+ try {
+ _payload.call(instance, prevState, nextProps);
+ } finally {
+ reenableLogs();
+ }
+ }
+
exitDisallowedContextReadInDEV();
}
} else {
@@ -6930,161 +7162,172 @@ function getStateFromUpdate(
return prevState;
}
-function processUpdateQueue(
- workInProgress,
- props,
- instance,
- renderExpirationTime
-) {
+function processUpdateQueue(workInProgress, props, instance, renderLanes) {
// This is always non-null on a ClassComponent or HostRoot
var queue = workInProgress.updateQueue;
hasForceUpdate = false;
{
currentlyProcessingQueue = queue.shared;
- } // The last rebase update that is NOT part of the base state.
+ }
- var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet.
+ var firstBaseUpdate = queue.firstBaseUpdate;
+ var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue.
var pendingQueue = queue.shared.pending;
if (pendingQueue !== null) {
- // We have new updates that haven't been processed yet.
- // We'll add them to the base queue.
- if (baseQueue !== null) {
- // Merge the pending queue and the base queue.
- var baseFirst = baseQueue.next;
- var pendingFirst = pendingQueue.next;
- baseQueue.next = pendingFirst;
- pendingQueue.next = baseFirst;
+ queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first
+ // and last so that it's non-circular.
+
+ var lastPendingUpdate = pendingQueue;
+ var firstPendingUpdate = lastPendingUpdate.next;
+ lastPendingUpdate.next = null; // Append pending updates to base queue
+
+ if (lastBaseUpdate === null) {
+ firstBaseUpdate = firstPendingUpdate;
+ } else {
+ lastBaseUpdate.next = firstPendingUpdate;
}
- baseQueue = pendingQueue;
- queue.shared.pending = null; // TODO: Pass `current` as argument
+ lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then
+ // we need to transfer the updates to that queue, too. Because the base
+ // queue is a singly-linked list with no cycles, we can append to both
+ // lists and take advantage of structural sharing.
+ // TODO: Pass `current` as argument
var current = workInProgress.alternate;
if (current !== null) {
+ // This is always non-null on a ClassComponent or HostRoot
var currentQueue = current.updateQueue;
+ var currentLastBaseUpdate = currentQueue.lastBaseUpdate;
+
+ if (currentLastBaseUpdate !== lastBaseUpdate) {
+ if (currentLastBaseUpdate === null) {
+ currentQueue.firstBaseUpdate = firstPendingUpdate;
+ } else {
+ currentLastBaseUpdate.next = firstPendingUpdate;
+ }
- if (currentQueue !== null) {
- currentQueue.baseQueue = pendingQueue;
+ currentQueue.lastBaseUpdate = lastPendingUpdate;
}
}
} // These values may change as we process the queue.
- if (baseQueue !== null) {
- var first = baseQueue.next; // Iterate through the list of updates to compute the result.
+ if (firstBaseUpdate !== null) {
+ // Iterate through the list of updates to compute the result.
+ var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes
+ // from the original lanes.
- var newState = queue.baseState;
- var newExpirationTime = NoWork;
+ var newLanes = NoLanes;
var newBaseState = null;
- var newBaseQueueFirst = null;
- var newBaseQueueLast = null;
+ var newFirstBaseUpdate = null;
+ var newLastBaseUpdate = null;
+ var update = firstBaseUpdate;
+
+ do {
+ var updateLane = update.lane;
+ var updateEventTime = update.eventTime;
- if (first !== null) {
- var update = first;
+ if (!isSubsetOfLanes(renderLanes, updateLane)) {
+ // Priority is insufficient. Skip this update. If this is the first
+ // skipped update, the previous update/state is the new base
+ // update/state.
+ var clone = {
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: update.suspenseConfig,
+ tag: update.tag,
+ payload: update.payload,
+ callback: update.callback,
+ next: null
+ };
- do {
- var updateExpirationTime = update.expirationTime;
+ if (newLastBaseUpdate === null) {
+ newFirstBaseUpdate = newLastBaseUpdate = clone;
+ newBaseState = newState;
+ } else {
+ newLastBaseUpdate = newLastBaseUpdate.next = clone;
+ } // Update the remaining priority in the queue.
- if (updateExpirationTime < renderExpirationTime) {
- // Priority is insufficient. Skip this update. If this is the first
- // skipped update, the previous update/state is the new base
- // update/state.
- var clone = {
- expirationTime: update.expirationTime,
+ newLanes = mergeLanes(newLanes, updateLane);
+ } else {
+ // This update does have sufficient priority.
+ if (newLastBaseUpdate !== null) {
+ var _clone = {
+ eventTime: updateEventTime,
+ // This update is going to be committed so we never want uncommit
+ // it. Using NoLane works because 0 is a subset of all bitmasks, so
+ // this will never be skipped by the check above.
+ lane: NoLane,
suspenseConfig: update.suspenseConfig,
tag: update.tag,
payload: update.payload,
callback: update.callback,
next: null
};
+ newLastBaseUpdate = newLastBaseUpdate.next = _clone;
+ } // Mark the event time of this update as relevant to this render pass.
+ // TODO: This should ideally use the true event time of this update rather than
+ // its priority which is a derived and not reversible value.
+ // TODO: We should skip this update if it was already committed but currently
+ // we have no way of detecting the difference between a committed and suspended
+ // update here.
- if (newBaseQueueLast === null) {
- newBaseQueueFirst = newBaseQueueLast = clone;
- newBaseState = newState;
- } else {
- newBaseQueueLast = newBaseQueueLast.next = clone;
- } // Update the remaining priority in the queue.
+ markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig); // Process this update.
- if (updateExpirationTime > newExpirationTime) {
- newExpirationTime = updateExpirationTime;
- }
- } else {
- // This update does have sufficient priority.
- if (newBaseQueueLast !== null) {
- var _clone = {
- expirationTime: Sync,
- // This update is going to be committed so we never want uncommit it.
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
- next: null
- };
- newBaseQueueLast = newBaseQueueLast.next = _clone;
- } // Mark the event time of this update as relevant to this render pass.
- // TODO: This should ideally use the true event time of this update rather than
- // its priority which is a derived and not reverseable value.
- // TODO: We should skip this update if it was already committed but currently
- // we have no way of detecting the difference between a committed and suspended
- // update here.
-
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ); // Process this update.
-
- newState = getStateFromUpdate(
- workInProgress,
- queue,
- update,
- newState,
- props,
- instance
- );
- var callback = update.callback;
+ newState = getStateFromUpdate(
+ workInProgress,
+ queue,
+ update,
+ newState,
+ props,
+ instance
+ );
+ var callback = update.callback;
- if (callback !== null) {
- workInProgress.effectTag |= Callback;
- var effects = queue.effects;
+ if (callback !== null) {
+ workInProgress.effectTag |= Callback;
+ var effects = queue.effects;
- if (effects === null) {
- queue.effects = [update];
- } else {
- effects.push(update);
- }
+ if (effects === null) {
+ queue.effects = [update];
+ } else {
+ effects.push(update);
}
}
+ }
- update = update.next;
+ update = update.next;
- if (update === null || update === first) {
- pendingQueue = queue.shared.pending;
+ if (update === null) {
+ pendingQueue = queue.shared.pending;
- if (pendingQueue === null) {
- break;
- } else {
- // An update was scheduled from inside a reducer. Add the new
- // pending updates to the end of the list and keep processing.
- update = baseQueue.next = pendingQueue.next;
- pendingQueue.next = first;
- queue.baseQueue = baseQueue = pendingQueue;
- queue.shared.pending = null;
- }
+ if (pendingQueue === null) {
+ break;
+ } else {
+ // An update was scheduled from inside a reducer. Add the new
+ // pending updates to the end of the list and keep processing.
+ var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we
+ // unravel them when transferring them to the base queue.
+
+ var _firstPendingUpdate = _lastPendingUpdate.next;
+ _lastPendingUpdate.next = null;
+ update = _firstPendingUpdate;
+ queue.lastBaseUpdate = _lastPendingUpdate;
+ queue.shared.pending = null;
}
- } while (true);
- }
+ }
+ } while (true);
- if (newBaseQueueLast === null) {
- newBaseState = newState;
- } else {
- newBaseQueueLast.next = newBaseQueueFirst;
+ if (newLastBaseUpdate === null) {
+ newBaseState = newState;
}
queue.baseState = newBaseState;
- queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue.
+ queue.firstBaseUpdate = newFirstBaseUpdate;
+ queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue.
// This should be fine because the only two other things that contribute to
// expiration time are props and context. We're already in the middle of the
// begin phase by the time we start processing the queue, so we've already
@@ -7092,8 +7335,8 @@ function processUpdateQueue(
// shouldComponentUpdate is tricky; but we'll have to account for
// that regardless.
- markUnprocessedUpdateTime(newExpirationTime);
- workInProgress.expirationTime = newExpirationTime;
+ markSkippedUpdateLanes(newLanes);
+ workInProgress.lanes = newLanes;
workInProgress.memoizedState = newState;
}
@@ -7231,8 +7474,14 @@ function applyDerivedStateFromProps(
{
if (workInProgress.mode & StrictMode) {
- // Invoke the function an extra time to help detect side-effects.
- getDerivedStateFromProps(nextProps, prevState);
+ disableLogs();
+
+ try {
+ // Invoke the function an extra time to help detect side-effects.
+ getDerivedStateFromProps(nextProps, prevState);
+ } finally {
+ reenableLogs();
+ }
}
}
@@ -7249,7 +7498,7 @@ function applyDerivedStateFromProps(
workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
// base state.
- if (workInProgress.expirationTime === NoWork) {
+ if (workInProgress.lanes === NoLanes) {
// Queue is always non-null for classes
var updateQueue = workInProgress.updateQueue;
updateQueue.baseState = memoizedState;
@@ -7259,14 +7508,10 @@ var classComponentUpdater = {
isMounted: isMounted,
enqueueSetState: function(inst, payload, callback) {
var fiber = get(inst);
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
- var update = createUpdate(expirationTime, suspenseConfig);
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ var update = createUpdate(eventTime, lane, suspenseConfig);
update.payload = payload;
if (callback !== undefined && callback !== null) {
@@ -7278,18 +7523,14 @@ var classComponentUpdater = {
}
enqueueUpdate(fiber, update);
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
},
enqueueReplaceState: function(inst, payload, callback) {
var fiber = get(inst);
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
- var update = createUpdate(expirationTime, suspenseConfig);
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ var update = createUpdate(eventTime, lane, suspenseConfig);
update.tag = ReplaceState;
update.payload = payload;
@@ -7302,18 +7543,14 @@ var classComponentUpdater = {
}
enqueueUpdate(fiber, update);
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
},
enqueueForceUpdate: function(inst, callback) {
var fiber = get(inst);
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
- var update = createUpdate(expirationTime, suspenseConfig);
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ var update = createUpdate(eventTime, lane, suspenseConfig);
update.tag = ForceUpdate;
if (callback !== undefined && callback !== null) {
@@ -7325,7 +7562,7 @@ var classComponentUpdater = {
}
enqueueUpdate(fiber, update);
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
};
@@ -7343,18 +7580,22 @@ function checkShouldComponentUpdate(
if (typeof instance.shouldComponentUpdate === "function") {
{
if (workInProgress.mode & StrictMode) {
- // Invoke the function an extra time to help detect side-effects.
- instance.shouldComponentUpdate(newProps, newState, nextContext);
+ disableLogs();
+
+ try {
+ // Invoke the function an extra time to help detect side-effects.
+ instance.shouldComponentUpdate(newProps, newState, nextContext);
+ } finally {
+ reenableLogs();
+ }
}
}
- startPhaseTimer(workInProgress, "shouldComponentUpdate");
var shouldUpdate = instance.shouldComponentUpdate(
newProps,
newState,
nextContext
);
- stopPhaseTimer();
{
if (shouldUpdate === undefined) {
@@ -7675,7 +7916,13 @@ function constructClassInstance(workInProgress, ctor, props) {
{
if (workInProgress.mode & StrictMode) {
- new ctor(props, context); // eslint-disable-line no-new
+ disableLogs();
+
+ try {
+ new ctor(props, context); // eslint-disable-line no-new
+ } finally {
+ reenableLogs();
+ }
}
}
@@ -7786,7 +8033,6 @@ function constructClassInstance(workInProgress, ctor, props) {
}
function callComponentWillMount(workInProgress, instance) {
- startPhaseTimer(workInProgress, "componentWillMount");
var oldState = instance.state;
if (typeof instance.componentWillMount === "function") {
@@ -7797,8 +8043,6 @@ function callComponentWillMount(workInProgress, instance) {
instance.UNSAFE_componentWillMount();
}
- stopPhaseTimer();
-
if (oldState !== instance.state) {
{
error(
@@ -7820,7 +8064,6 @@ function callComponentWillReceiveProps(
nextContext
) {
var oldState = instance.state;
- startPhaseTimer(workInProgress, "componentWillReceiveProps");
if (typeof instance.componentWillReceiveProps === "function") {
instance.componentWillReceiveProps(newProps, nextContext);
@@ -7830,8 +8073,6 @@ function callComponentWillReceiveProps(
instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
}
- stopPhaseTimer();
-
if (instance.state !== oldState) {
{
var componentName = getComponentName(workInProgress.type) || "Component";
@@ -7852,12 +8093,7 @@ function callComponentWillReceiveProps(
}
} // Invokes the mount life-cycles on a previously never rendered instance.
-function mountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
{
checkClassInstance(workInProgress, ctor, newProps);
}
@@ -7907,7 +8143,7 @@ function mountClassInstance(
}
}
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
@@ -7931,12 +8167,7 @@ function mountClassInstance(
callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
// process them now.
- processUpdateQueue(
- workInProgress,
- newProps,
- instance,
- renderExpirationTime
- );
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
}
@@ -7945,12 +8176,7 @@ function mountClassInstance(
}
}
-function resumeMountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
var oldProps = workInProgress.memoizedProps;
instance.props = oldProps;
@@ -7996,7 +8222,7 @@ function resumeMountClassInstance(
resetHasForceUpdateBeforeProcessing();
var oldState = workInProgress.memoizedState;
var newState = (instance.state = oldState);
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
newState = workInProgress.memoizedState;
if (
@@ -8044,8 +8270,6 @@ function resumeMountClassInstance(
(typeof instance.UNSAFE_componentWillMount === "function" ||
typeof instance.componentWillMount === "function")
) {
- startPhaseTimer(workInProgress, "componentWillMount");
-
if (typeof instance.componentWillMount === "function") {
instance.componentWillMount();
}
@@ -8053,8 +8277,6 @@ function resumeMountClassInstance(
if (typeof instance.UNSAFE_componentWillMount === "function") {
instance.UNSAFE_componentWillMount();
}
-
- stopPhaseTimer();
}
if (typeof instance.componentDidMount === "function") {
@@ -8084,15 +8306,17 @@ function updateClassInstance(
workInProgress,
ctor,
newProps,
- renderExpirationTime
+ renderLanes
) {
var instance = workInProgress.stateNode;
cloneUpdateQueue(current, workInProgress);
- var oldProps = workInProgress.memoizedProps;
- instance.props =
+ var unresolvedOldProps = workInProgress.memoizedProps;
+ var oldProps =
workInProgress.type === workInProgress.elementType
- ? oldProps
- : resolveDefaultProps(workInProgress.type, oldProps);
+ ? unresolvedOldProps
+ : resolveDefaultProps(workInProgress.type, unresolvedOldProps);
+ instance.props = oldProps;
+ var unresolvedNewProps = workInProgress.pendingProps;
var oldContext = instance.context;
var contextType = ctor.contextType;
var nextContext = emptyContextObject;
@@ -8118,7 +8342,10 @@ function updateClassInstance(
(typeof instance.UNSAFE_componentWillReceiveProps === "function" ||
typeof instance.componentWillReceiveProps === "function")
) {
- if (oldProps !== newProps || oldContext !== nextContext) {
+ if (
+ unresolvedOldProps !== unresolvedNewProps ||
+ oldContext !== nextContext
+ ) {
callComponentWillReceiveProps(
workInProgress,
instance,
@@ -8131,11 +8358,11 @@ function updateClassInstance(
resetHasForceUpdateBeforeProcessing();
var oldState = workInProgress.memoizedState;
var newState = (instance.state = oldState);
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
newState = workInProgress.memoizedState;
if (
- oldProps === newProps &&
+ unresolvedOldProps === unresolvedNewProps &&
oldState === newState &&
!hasContextChanged() &&
!checkHasForceUpdateAfterProcessing()
@@ -8144,7 +8371,7 @@ function updateClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Update;
@@ -8153,7 +8380,7 @@ function updateClassInstance(
if (typeof instance.getSnapshotBeforeUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Snapshot;
@@ -8193,8 +8420,6 @@ function updateClassInstance(
(typeof instance.UNSAFE_componentWillUpdate === "function" ||
typeof instance.componentWillUpdate === "function")
) {
- startPhaseTimer(workInProgress, "componentWillUpdate");
-
if (typeof instance.componentWillUpdate === "function") {
instance.componentWillUpdate(newProps, newState, nextContext);
}
@@ -8202,8 +8427,6 @@ function updateClassInstance(
if (typeof instance.UNSAFE_componentWillUpdate === "function") {
instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
}
-
- stopPhaseTimer();
}
if (typeof instance.componentDidUpdate === "function") {
@@ -8218,7 +8441,7 @@ function updateClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Update;
@@ -8227,7 +8450,7 @@ function updateClassInstance(
if (typeof instance.getSnapshotBeforeUpdate === "function") {
if (
- oldProps !== current.memoizedProps ||
+ unresolvedOldProps !== current.memoizedProps ||
oldState !== current.memoizedState
) {
workInProgress.effectTag |= Snapshot;
@@ -8252,7 +8475,7 @@ var didWarnAboutStringRefs;
var ownerHasKeyUseWarning;
var ownerHasFunctionTypeWarning;
-var warnForMissingKey = function(child) {};
+var warnForMissingKey = function(child, returnFiber) {};
{
didWarnAboutMaps = false;
@@ -8267,7 +8490,7 @@ var warnForMissingKey = function(child) {};
ownerHasKeyUseWarning = {};
ownerHasFunctionTypeWarning = {};
- warnForMissingKey = function(child) {
+ warnForMissingKey = function(child, returnFiber) {
if (child === null || typeof child !== "object") {
return;
}
@@ -8283,17 +8506,13 @@ var warnForMissingKey = function(child) {};
}
child._store.validated = true;
- var currentComponentErrorInfo =
- "Each child in a list should have a unique " +
- '"key" prop. See https://fb.me/react-warning-keys for ' +
- "more information." +
- getCurrentFiberStackInDev();
+ var componentName = getComponentName(returnFiber.type) || "Component";
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
+ if (ownerHasKeyUseWarning[componentName]) {
return;
}
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
+ ownerHasKeyUseWarning[componentName] = true;
error(
"Each child in a list should have a unique " +
@@ -8335,9 +8554,8 @@ function coerceRef(returnFiber, current, element) {
"String refs are a source of potential bugs and should be avoided. " +
"We recommend using useRef() or createRef() instead. " +
"Learn more about using refs safely here: " +
- "https://fb.me/react-strict-mode-string-ref%s",
- mixedRef,
- getStackByFiberInDevAndProd(returnFiber)
+ "https://fb.me/react-strict-mode-string-ref",
+ mixedRef
);
}
@@ -8420,41 +8638,27 @@ function coerceRef(returnFiber, current, element) {
function throwOnInvalidObjectType(returnFiber, newChild) {
if (returnFiber.type !== "textarea") {
- var addendum = "";
-
- {
- addendum =
- " If you meant to render a collection of children, use an array " +
- "instead." +
- getCurrentFiberStackInDev();
- }
-
{
throw Error(
"Objects are not valid as a React child (found: " +
(Object.prototype.toString.call(newChild) === "[object Object]"
? "object with keys {" + Object.keys(newChild).join(", ") + "}"
: newChild) +
- ")." +
- addendum
+ "). If you meant to render a collection of children, use an array instead."
);
}
}
}
-function warnOnFunctionType() {
+function warnOnFunctionType(returnFiber) {
{
- var currentComponentErrorInfo =
- "Functions are not valid as a React child. This may happen if " +
- "you return a Component instead of from render. " +
- "Or maybe you meant to call this function rather than return it." +
- getCurrentFiberStackInDev();
+ var componentName = getComponentName(returnFiber.type) || "Component";
- if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
+ if (ownerHasFunctionTypeWarning[componentName]) {
return;
}
- ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
+ ownerHasFunctionTypeWarning[componentName] = true;
error(
"Functions are not valid as a React child. This may happen if " +
@@ -8462,7 +8666,7 @@ function warnOnFunctionType() {
"Or maybe you meant to call this function rather than return it."
);
}
-} // This wrapper function exists because I expect to clone the code in each path
+} // We avoid inlining this to avoid potential deopts from using try/catch.
// to be able to optimize each path individually by branching early. This needs
// a compiler or we can do it manually. Helpers that don't need this branching
// live outside of this function.
@@ -8575,14 +8779,10 @@ function ChildReconciler(shouldTrackSideEffects) {
return newFiber;
}
- function updateTextNode(returnFiber, current, textContent, expirationTime) {
+ function updateTextNode(returnFiber, current, textContent, lanes) {
if (current === null || current.tag !== HostText) {
// Insert
- var created = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromText(textContent, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
} else {
@@ -8593,7 +8793,7 @@ function ChildReconciler(shouldTrackSideEffects) {
}
}
- function updateElement(returnFiber, current, element, expirationTime) {
+ function updateElement(returnFiber, current, element, lanes) {
if (current !== null) {
if (
current.elementType === element.type || // Keep this check inline so it only runs on the false path:
@@ -8613,17 +8813,13 @@ function ChildReconciler(shouldTrackSideEffects) {
}
} // Insert
- var created = createFiberFromElement(
- element,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromElement(element, returnFiber.mode, lanes);
created.ref = coerceRef(returnFiber, current, element);
created.return = returnFiber;
return created;
}
- function updatePortal(returnFiber, current, portal, expirationTime) {
+ function updatePortal(returnFiber, current, portal, lanes) {
if (
current === null ||
current.tag !== HostPortal ||
@@ -8631,11 +8827,7 @@ function ChildReconciler(shouldTrackSideEffects) {
current.stateNode.implementation !== portal.implementation
) {
// Insert
- var created = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
} else {
@@ -8646,13 +8838,13 @@ function ChildReconciler(shouldTrackSideEffects) {
}
}
- function updateFragment(returnFiber, current, fragment, expirationTime, key) {
+ function updateFragment(returnFiber, current, fragment, lanes, key) {
if (current === null || current.tag !== Fragment) {
// Insert
var created = createFiberFromFragment(
fragment,
returnFiber.mode,
- expirationTime,
+ lanes,
key
);
created.return = returnFiber;
@@ -8665,16 +8857,12 @@ function ChildReconciler(shouldTrackSideEffects) {
}
}
- function createChild(returnFiber, newChild, expirationTime) {
+ function createChild(returnFiber, newChild, lanes) {
if (typeof newChild === "string" || typeof newChild === "number") {
// Text nodes don't have keys. If the previous node is implicitly keyed
// we can continue to replace it without aborting even if it is not a text
// node.
- var created = createFiberFromText(
- "" + newChild,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromText("" + newChild, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
}
@@ -8685,7 +8873,7 @@ function ChildReconciler(shouldTrackSideEffects) {
var _created = createFiberFromElement(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
_created.ref = coerceRef(returnFiber, null, newChild);
@@ -8697,7 +8885,7 @@ function ChildReconciler(shouldTrackSideEffects) {
var _created2 = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
_created2.return = returnFiber;
@@ -8709,7 +8897,7 @@ function ChildReconciler(shouldTrackSideEffects) {
var _created3 = createFiberFromFragment(
newChild,
returnFiber.mode,
- expirationTime,
+ lanes,
null
);
@@ -8722,14 +8910,14 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
return null;
}
- function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
+ function updateSlot(returnFiber, oldFiber, newChild, lanes) {
// Update the fiber if the keys match, otherwise return null.
var key = oldFiber !== null ? oldFiber.key : null;
@@ -8741,12 +8929,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return null;
}
- return updateTextNode(
- returnFiber,
- oldFiber,
- "" + newChild,
- expirationTime
- );
+ return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
}
if (typeof newChild === "object" && newChild !== null) {
@@ -8758,17 +8941,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChild.props.children,
- expirationTime,
+ lanes,
key
);
}
- return updateElement(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime
- );
+ return updateElement(returnFiber, oldFiber, newChild, lanes);
} else {
return null;
}
@@ -8776,12 +8954,7 @@ function ChildReconciler(shouldTrackSideEffects) {
case REACT_PORTAL_TYPE: {
if (newChild.key === key) {
- return updatePortal(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime
- );
+ return updatePortal(returnFiber, oldFiber, newChild, lanes);
} else {
return null;
}
@@ -8793,13 +8966,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return null;
}
- return updateFragment(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime,
- null
- );
+ return updateFragment(returnFiber, oldFiber, newChild, lanes, null);
}
throwOnInvalidObjectType(returnFiber, newChild);
@@ -8807,7 +8974,7 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
@@ -8819,18 +8986,13 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChild,
- expirationTime
+ lanes
) {
if (typeof newChild === "string" || typeof newChild === "number") {
// Text nodes don't have keys, so we neither have to check the old nor
// new node for the key. If both are text nodes, they match.
var matchedFiber = existingChildren.get(newIdx) || null;
- return updateTextNode(
- returnFiber,
- matchedFiber,
- "" + newChild,
- expirationTime
- );
+ return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes);
}
if (typeof newChild === "object" && newChild !== null) {
@@ -8846,17 +9008,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
_matchedFiber,
newChild.props.children,
- expirationTime,
+ lanes,
newChild.key
);
}
- return updateElement(
- returnFiber,
- _matchedFiber,
- newChild,
- expirationTime
- );
+ return updateElement(returnFiber, _matchedFiber, newChild, lanes);
}
case REACT_PORTAL_TYPE: {
@@ -8865,12 +9022,7 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild.key === null ? newIdx : newChild.key
) || null;
- return updatePortal(
- returnFiber,
- _matchedFiber2,
- newChild,
- expirationTime
- );
+ return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);
}
}
@@ -8881,7 +9033,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
_matchedFiber3,
newChild,
- expirationTime,
+ lanes,
null
);
}
@@ -8891,7 +9043,7 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
@@ -8901,7 +9053,7 @@ function ChildReconciler(shouldTrackSideEffects) {
* Warns if there is a duplicate or missing key
*/
- function warnOnInvalidKey(child, knownKeys) {
+ function warnOnInvalidKey(child, knownKeys, returnFiber) {
{
if (typeof child !== "object" || child === null) {
return knownKeys;
@@ -8910,7 +9062,7 @@ function ChildReconciler(shouldTrackSideEffects) {
switch (child.$$typeof) {
case REACT_ELEMENT_TYPE:
case REACT_PORTAL_TYPE:
- warnForMissingKey(child);
+ warnForMissingKey(child, returnFiber);
var key = child.key;
if (typeof key !== "string") {
@@ -8948,7 +9100,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildren,
- expirationTime
+ lanes
) {
// This algorithm can't optimize by searching from both ends since we
// don't have backpointers on fibers. I'm trying to see how far we can get
@@ -8971,7 +9123,7 @@ function ChildReconciler(shouldTrackSideEffects) {
for (var i = 0; i < newChildren.length; i++) {
var child = newChildren[i];
- knownKeys = warnOnInvalidKey(child, knownKeys);
+ knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
}
}
@@ -8994,7 +9146,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (newFiber === null) {
@@ -9044,11 +9196,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// If we don't have any more existing children we can choose a fast path
// since the rest will all be insertions.
for (; newIdx < newChildren.length; newIdx++) {
- var _newFiber = createChild(
- returnFiber,
- newChildren[newIdx],
- expirationTime
- );
+ var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);
if (_newFiber === null) {
continue;
@@ -9077,7 +9225,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (_newFiber2 !== null) {
@@ -9120,7 +9268,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildrenIterable,
- expirationTime
+ lanes
) {
// This is the same implementation as reconcileChildrenArray(),
// but using the iterator instead.
@@ -9155,9 +9303,8 @@ function ChildReconciler(shouldTrackSideEffects) {
if (newChildrenIterable.entries === iteratorFn) {
if (!didWarnAboutMaps) {
error(
- "Using Maps as children is unsupported and will likely yield " +
- "unexpected results. Convert it to a sequence/iterable of keyed " +
- "ReactElements instead."
+ "Using Maps as children is not supported. " +
+ "Use an array of keyed ReactElements instead."
);
}
@@ -9174,7 +9321,7 @@ function ChildReconciler(shouldTrackSideEffects) {
for (; !_step.done; _step = _newChildren.next()) {
var child = _step.value;
- knownKeys = warnOnInvalidKey(child, knownKeys);
+ knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
}
}
}
@@ -9205,12 +9352,7 @@ function ChildReconciler(shouldTrackSideEffects) {
nextOldFiber = oldFiber.sibling;
}
- var newFiber = updateSlot(
- returnFiber,
- oldFiber,
- step.value,
- expirationTime
- );
+ var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
if (newFiber === null) {
// TODO: This breaks on empty slots like null children. That's
@@ -9259,7 +9401,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// If we don't have any more existing children we can choose a fast path
// since the rest will all be insertions.
for (; !step.done; newIdx++, step = newChildren.next()) {
- var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
+ var _newFiber3 = createChild(returnFiber, step.value, lanes);
if (_newFiber3 === null) {
continue;
@@ -9288,7 +9430,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
step.value,
- expirationTime
+ lanes
);
if (_newFiber4 !== null) {
@@ -9331,7 +9473,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
textContent,
- expirationTime
+ lanes
) {
// There's no need to check for keys on text nodes since we don't have a
// way to define them.
@@ -9346,11 +9488,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// and delete the existing ones.
deleteRemainingChildren(returnFiber, currentFirstChild);
- var created = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromText(textContent, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
}
@@ -9359,7 +9497,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
element,
- expirationTime
+ lanes
) {
var key = element.key;
var child = currentFirstChild;
@@ -9428,17 +9566,13 @@ function ChildReconciler(shouldTrackSideEffects) {
var created = createFiberFromFragment(
element.props.children,
returnFiber.mode,
- expirationTime,
+ lanes,
element.key
);
created.return = returnFiber;
return created;
} else {
- var _created4 = createFiberFromElement(
- element,
- returnFiber.mode,
- expirationTime
- );
+ var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);
_created4.ref = coerceRef(returnFiber, currentFirstChild, element);
_created4.return = returnFiber;
@@ -9450,7 +9584,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
portal,
- expirationTime
+ lanes
) {
var key = portal.key;
var child = currentFirstChild;
@@ -9479,11 +9613,7 @@ function ChildReconciler(shouldTrackSideEffects) {
child = child.sibling;
}
- var created = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- );
+ var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
created.return = returnFiber;
return created;
} // This API will tag the children with the side-effect of the reconciliation
@@ -9494,7 +9624,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
) {
// This function is not recursive.
// If the top level item is an array, we treat it as a set of children,
@@ -9523,7 +9653,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
)
);
@@ -9533,7 +9663,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
)
);
}
@@ -9545,7 +9675,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
"" + newChild,
- expirationTime
+ lanes
)
);
}
@@ -9555,7 +9685,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
}
@@ -9564,7 +9694,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
}
@@ -9574,7 +9704,7 @@ function ChildReconciler(shouldTrackSideEffects) {
{
if (typeof newChild === "function") {
- warnOnFunctionType();
+ warnOnFunctionType(returnFiber);
}
}
@@ -9644,11 +9774,11 @@ function cloneChildFibers(current, workInProgress) {
newChild.sibling = null;
} // Reset a workInProgress child set to prepare it for a second pass.
-function resetChildFibers(workInProgress, renderExpirationTime) {
+function resetChildFibers(workInProgress, lanes) {
var child = workInProgress.child;
while (child !== null) {
- resetWorkInProgress(child, renderExpirationTime);
+ resetWorkInProgress(child, lanes);
child = child.sibling;
}
}
@@ -9766,6 +9896,13 @@ function popSuspenseContext(fiber) {
pop(suspenseStackCursor, fiber);
}
+// A non-null SuspenseState means that it is blocked for one reason or another.
+// - A non-null dehydrated field means it's blocked pending hydration.
+// - A non-null dehydrated field can use isSuspenseInstancePending or
+// isSuspenseInstanceFallback to query the reason for being dehydrated.
+// - A null dehydrated field means it's blocked by something suspending and
+// we're currently showing a fallback instead.
+
function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
// If it was the primary children that just suspended, capture and render the
// fallback. Otherwise, don't capture and bubble to the next boundary.
@@ -9863,6 +10000,10 @@ function createDeprecatedResponderListener(responder, props) {
return eventResponderListener;
}
+var NoEffect$1 =
+ /* */
+ 0; // Represents whether effect should fire.
+
var HasEffect =
/* */
1; // Represents the phase in which the effect (not the clean-up) fires.
@@ -9874,16 +10015,113 @@ var Passive$1 =
/* */
4;
-var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
+var isHydrating = false;
+
+function enterHydrationState(fiber) {
+ {
+ return false;
+ }
+}
+
+function prepareToHydrateHostInstance(
+ fiber,
+ rootContainerInstance,
+ hostContext
+) {
+ {
+ {
+ throw Error(
+ "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
+ }
+}
+
+function prepareToHydrateHostTextInstance(fiber) {
+ {
+ {
+ throw Error(
+ "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
+ }
+ var shouldUpdate = hydrateTextInstance();
+}
+
+function popHydrationState(fiber) {
+ {
+ return false;
+ }
+}
+
+function getIsHydrating() {
+ return isHydrating;
+}
+
+// and should be reset before starting a new render.
+// This tracks which mutable sources need to be reset after a render.
+
+var workInProgressSources = [];
+var rendererSigil$1;
+
+{
+ // Used to detect multiple renderers using the same mutable source.
+ rendererSigil$1 = {};
+}
+
+function markSourceAsDirty(mutableSource) {
+ workInProgressSources.push(mutableSource);
+}
+function resetWorkInProgressVersions() {
+ for (var i = 0; i < workInProgressSources.length; i++) {
+ var mutableSource = workInProgressSources[i];
+
+ {
+ mutableSource._workInProgressVersionPrimary = null;
+ }
+ }
+
+ workInProgressSources.length = 0;
+}
+function getWorkInProgressVersion(mutableSource) {
+ {
+ return mutableSource._workInProgressVersionPrimary;
+ }
+}
+function setWorkInProgressVersion(mutableSource, version) {
+ {
+ mutableSource._workInProgressVersionPrimary = version;
+ }
+
+ workInProgressSources.push(mutableSource);
+}
+function warnAboutMultipleRenderersDEV(mutableSource) {
+ {
+ {
+ if (mutableSource._currentPrimaryRenderer == null) {
+ mutableSource._currentPrimaryRenderer = rendererSigil$1;
+ } else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) {
+ error(
+ "Detected multiple renderers concurrently rendering the " +
+ "same mutable source. This is currently unsupported."
+ );
+ }
+ }
+ }
+} // Eager reads the version of a mutable source and stores it on the root.
+
+var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
var didWarnAboutMismatchedHooksForComponent;
+var didWarnAboutUseOpaqueIdentifier;
{
+ didWarnAboutUseOpaqueIdentifier = {};
didWarnAboutMismatchedHooksForComponent = new Set();
}
// These are set right before calling the component.
-var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from
+var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from
// the work-in-progress hook.
var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
@@ -9897,7 +10135,12 @@ var workInProgressHook = null; // Whether an update was scheduled at any point d
// finished evaluating this component. This is an optimization so we know
// whether we need to clear render phase updates after a throw.
-var didScheduleRenderPhaseUpdate = false;
+var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This
+// gets reset after each attempt.
+// TODO: Maybe there's some way to consolidate this with
+// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`.
+
+var didScheduleRenderPhaseUpdateDuringThisPass = false;
var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
@@ -10056,9 +10299,9 @@ function renderWithHooks(
Component,
props,
secondArg,
- nextRenderExpirationTime
+ nextRenderLanes
) {
- renderExpirationTime = nextRenderExpirationTime;
+ renderLanes = nextRenderLanes;
currentlyRenderingFiber$1 = workInProgress;
{
@@ -10071,7 +10314,7 @@ function renderWithHooks(
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- workInProgress.expirationTime = NoWork; // The following should have already been reset
+ workInProgress.lanes = NoLanes; // The following should have already been reset
// currentHook = null;
// workInProgressHook = null;
// didScheduleRenderPhaseUpdate = false;
@@ -10084,28 +10327,28 @@ function renderWithHooks(
{
if (current !== null && current.memoizedState !== null) {
- ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
} else if (hookTypesDev !== null) {
// This dispatcher handles an edge case where a component is updating,
// but no stateful hooks have been used.
// We want to match the production code behavior (which will use HooksDispatcherOnMount),
// but with the extra DEV validation to ensure hooks ordering hasn't changed.
// This dispatcher does that.
- ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
} else {
- ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
}
}
var children = Component(props, secondArg); // Check if there was a render phase update
- if (workInProgress.expirationTime === renderExpirationTime) {
+ if (didScheduleRenderPhaseUpdateDuringThisPass) {
// Keep rendering in a loop for as long as render phase updates continue to
// be scheduled. Use a counter to prevent infinite loops.
var numberOfReRenders = 0;
do {
- workInProgress.expirationTime = NoWork;
+ didScheduleRenderPhaseUpdateDuringThisPass = false;
if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
throw Error(
@@ -10130,13 +10373,13 @@ function renderWithHooks(
hookTypesUpdateIndexDev = -1;
}
- ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV;
children = Component(props, secondArg);
- } while (workInProgress.expirationTime === renderExpirationTime);
+ } while (didScheduleRenderPhaseUpdateDuringThisPass);
} // We can assume the previous dispatcher is always this one, since we set it
// at the beginning of the render phase and there's no re-entrancy.
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
{
workInProgress._debugHookTypes = hookTypesDev;
@@ -10144,7 +10387,7 @@ function renderWithHooks(
// hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
- renderExpirationTime = NoWork;
+ renderLanes = NoLanes;
currentlyRenderingFiber$1 = null;
currentHook = null;
workInProgressHook = null;
@@ -10165,18 +10408,15 @@ function renderWithHooks(
return children;
}
-function bailoutHooks(current, workInProgress, expirationTime) {
+function bailoutHooks(current, workInProgress, lanes) {
workInProgress.updateQueue = current.updateQueue;
workInProgress.effectTag &= ~(Passive | Update);
-
- if (current.expirationTime <= expirationTime) {
- current.expirationTime = NoWork;
- }
+ current.lanes = removeLanes(current.lanes, lanes);
}
function resetHooksAfterThrow() {
// We can assume the previous dispatcher is always this one, since we set it
// at the beginning of the render phase and there's no re-entrancy.
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
if (didScheduleRenderPhaseUpdate) {
// There were render phase updates. These are only valid for this render
@@ -10198,9 +10438,11 @@ function resetHooksAfterThrow() {
hook = hook.next;
}
+
+ didScheduleRenderPhaseUpdate = false;
}
- renderExpirationTime = NoWork;
+ renderLanes = NoLanes;
currentlyRenderingFiber$1 = null;
currentHook = null;
workInProgressHook = null;
@@ -10209,9 +10451,10 @@ function resetHooksAfterThrow() {
hookTypesDev = null;
hookTypesUpdateIndexDev = -1;
currentHookNameInDev = null;
+ isUpdatingOpaqueValueInRenderPhase = false;
}
- didScheduleRenderPhaseUpdate = false;
+ didScheduleRenderPhaseUpdateDuringThisPass = false;
}
function mountWorkInProgressHook() {
@@ -10358,6 +10601,17 @@ function updateReducer(reducer, initialArg, init) {
pendingQueue.next = baseFirst;
}
+ {
+ if (current.baseQueue !== baseQueue) {
+ // Internal invariant that should never happen, but feasibly could in
+ // the future if we implement resuming, or some form of that.
+ error(
+ "Internal error: Expected work-in-progress queue to be a clone. " +
+ "This is a bug in React."
+ );
+ }
+ }
+
current.baseQueue = baseQueue = pendingQueue;
queue.pending = null;
}
@@ -10372,15 +10626,18 @@ function updateReducer(reducer, initialArg, init) {
var update = first;
do {
- var updateExpirationTime = update.expirationTime;
+ var suspenseConfig = update.suspenseConfig;
+ var updateLane = update.lane;
+ var updateEventTime = update.eventTime;
- if (updateExpirationTime < renderExpirationTime) {
+ if (!isSubsetOfLanes(renderLanes, updateLane)) {
// Priority is insufficient. Skip this update. If this is the first
// skipped update, the previous update/state is the new base
// update/state.
var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
@@ -10393,17 +10650,23 @@ function updateReducer(reducer, initialArg, init) {
} else {
newBaseQueueLast = newBaseQueueLast.next = clone;
} // Update the remaining priority in the queue.
+ // TODO: Don't need to accumulate this. Instead, we can remove
+ // renderLanes from the original lanes.
- if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) {
- currentlyRenderingFiber$1.expirationTime = updateExpirationTime;
- markUnprocessedUpdateTime(updateExpirationTime);
- }
+ currentlyRenderingFiber$1.lanes = mergeLanes(
+ currentlyRenderingFiber$1.lanes,
+ updateLane
+ );
+ markSkippedUpdateLanes(updateLane);
} else {
// This update does have sufficient priority.
if (newBaseQueueLast !== null) {
var _clone = {
- expirationTime: Sync,
- // This update is going to be committed so we never want uncommit it.
+ eventTime: updateEventTime,
+ // This update is going to be committed so we never want uncommit
+ // it. Using NoLane works because 0 is a subset of all bitmasks, so
+ // this will never be skipped by the check above.
+ lane: NoLane,
suspenseConfig: update.suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
@@ -10413,15 +10676,12 @@ function updateReducer(reducer, initialArg, init) {
newBaseQueueLast = newBaseQueueLast.next = _clone;
} // Mark the event time of this update as relevant to this render pass.
// TODO: This should ideally use the true event time of this update rather than
- // its priority which is a derived and not reverseable value.
+ // its priority which is a derived and not reversible value.
// TODO: We should skip this update if it was already committed but currently
// we have no way of detecting the difference between a committed and suspended
// update here.
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ); // Process this update.
+ markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); // Process this update.
if (update.eagerReducer === reducer) {
// If this update was processed eagerly, and its reducer matches the
@@ -10490,23 +10750,270 @@ function rerenderReducer(reducer, initialArg, init) {
} while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is
// different from the current state.
- if (!objectIs(newState, hook.memoizedState)) {
- markWorkInProgressReceivedUpdate();
- }
+ if (!objectIs(newState, hook.memoizedState)) {
+ markWorkInProgressReceivedUpdate();
+ }
+
+ hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
+ // the base state unless the queue is empty.
+ // TODO: Not sure if this is the desired semantics, but it's what we
+ // do for gDSFP. I can't remember why.
+
+ if (hook.baseQueue === null) {
+ hook.baseState = newState;
+ }
+
+ queue.lastRenderedState = newState;
+ }
+
+ return [newState, dispatch];
+}
+
+function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+ {
+ warnAboutMultipleRenderersDEV(source);
+ }
+
+ var getVersion = source._getVersion;
+ var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render?
+
+ var isSafeToReadFromSource = false; // Check the version first.
+ // If this render has already been started with a specific version,
+ // we can use it alone to determine if we can safely read from the source.
+
+ var currentRenderVersion = getWorkInProgressVersion(source);
+
+ if (currentRenderVersion !== null) {
+ // It's safe to read if the store hasn't been mutated since the last time
+ // we read something.
+ isSafeToReadFromSource = currentRenderVersion === version;
+ } else {
+ // If there's no version, then this is the first time we've read from the
+ // source during the current render pass, so we need to do a bit more work.
+ // What we need to determine is if there are any hooks that already
+ // subscribed to the source, and if so, whether there are any pending
+ // mutations that haven't been synchronized yet.
+ //
+ // If there are no pending mutations, then `root.mutableReadLanes` will be
+ // empty, and we know we can safely read.
+ //
+ // If there *are* pending mutations, we may still be able to safely read
+ // if the currently rendering lanes are inclusive of the pending mutation
+ // lanes, since that guarantees that the value we're about to read from
+ // the source is consistent with the values that we read during the most
+ // recent mutation.
+ isSafeToReadFromSource = isSubsetOfLanes(
+ renderLanes,
+ root.mutableReadLanes
+ );
+
+ if (isSafeToReadFromSource) {
+ // If it's safe to read from this source during the current render,
+ // store the version in case other components read from it.
+ // A changed version number will let those components know to throw and restart the render.
+ setWorkInProgressVersion(source, version);
+ }
+ }
+
+ if (isSafeToReadFromSource) {
+ var snapshot = getSnapshot(source._source);
+
+ {
+ if (typeof snapshot === "function") {
+ error(
+ "Mutable source should not return a function as the snapshot value. " +
+ "Functions may close over mutable values and cause tearing."
+ );
+ }
+ }
+
+ return snapshot;
+ } else {
+ // This handles the special case of a mutable source being shared between renderers.
+ // In that case, if the source is mutated between the first and second renderer,
+ // The second renderer don't know that it needs to reset the WIP version during unwind,
+ // (because the hook only marks sources as dirty if it's written to their WIP version).
+ // That would cause this tear check to throw again and eventually be visible to the user.
+ // We can avoid this infinite loop by explicitly marking the source as dirty.
+ //
+ // This can lead to tearing in the first renderer when it resumes,
+ // but there's nothing we can do about that (short of throwing here and refusing to continue the render).
+ markSourceAsDirty(source);
+
+ {
+ throw Error(
+ "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
+ );
+ }
+ }
+}
+
+function useMutableSource(hook, source, getSnapshot, subscribe) {
+ var root = getWorkInProgressRoot();
+
+ if (!(root !== null)) {
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ }
+
+ var getVersion = source._getVersion;
+ var version = getVersion(source._source);
+ var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const
+
+ var _dispatcher$useState = dispatcher.useState(function() {
+ return readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ }),
+ currentSnapshot = _dispatcher$useState[0],
+ setSnapshot = _dispatcher$useState[1];
+
+ var snapshot = currentSnapshot; // Grab a handle to the state hook as well.
+ // We use it to clear the pending update queue if we have a new source.
+
+ var stateHook = workInProgressHook;
+ var memoizedState = hook.memoizedState;
+ var refs = memoizedState.refs;
+ var prevGetSnapshot = refs.getSnapshot;
+ var prevSource = memoizedState.source;
+ var prevSubscribe = memoizedState.subscribe;
+ var fiber = currentlyRenderingFiber$1;
+ hook.memoizedState = {
+ refs: refs,
+ source: source,
+ subscribe: subscribe
+ }; // Sync the values needed by our subscription handler after each commit.
+
+ dispatcher.useEffect(
+ function() {
+ refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes,
+ // but this hook recreates the queue in certain cases to avoid updates from stale sources.
+ // handleChange() below needs to reference the dispatch function without re-subscribing,
+ // so we use a ref to ensure that it always has the latest version.
+
+ refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now.
+
+ var maybeNewVersion = getVersion(source._source);
+
+ if (!objectIs(version, maybeNewVersion)) {
+ var maybeNewSnapshot = getSnapshot(source._source);
+
+ {
+ if (typeof maybeNewSnapshot === "function") {
+ error(
+ "Mutable source should not return a function as the snapshot value. " +
+ "Functions may close over mutable values and cause tearing."
+ );
+ }
+ }
+
+ if (!objectIs(snapshot, maybeNewSnapshot)) {
+ setSnapshot(maybeNewSnapshot);
+ var suspenseConfig = requestCurrentSuspenseConfig();
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ markRootMutableRead(root, lane);
+ } // If the source mutated between render and now,
+ // there may be state updates already scheduled from the old source.
+ // Entangle the updates so that they render in the same batch.
+
+ markRootEntangled(root, root.mutableReadLanes);
+ }
+ },
+ [getSnapshot, source, subscribe]
+ ); // If we got a new source or subscribe function, re-subscribe in a passive effect.
+
+ dispatcher.useEffect(
+ function() {
+ var handleChange = function() {
+ var latestGetSnapshot = refs.getSnapshot;
+ var latestSetSnapshot = refs.setSnapshot;
+
+ try {
+ latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time.
+
+ var suspenseConfig = requestCurrentSuspenseConfig();
+ var lane = requestUpdateLane(fiber, suspenseConfig);
+ markRootMutableRead(root, lane);
+ } catch (error) {
+ // A selector might throw after a source mutation.
+ // e.g. it might try to read from a part of the store that no longer exists.
+ // In this case we should still schedule an update with React.
+ // Worst case the selector will throw again and then an error boundary will handle it.
+ latestSetSnapshot(function() {
+ throw error;
+ });
+ }
+ };
+
+ var unsubscribe = subscribe(source._source, handleChange);
- hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
- // the base state unless the queue is empty.
- // TODO: Not sure if this is the desired semantics, but it's what we
- // do for gDSFP. I can't remember why.
+ {
+ if (typeof unsubscribe !== "function") {
+ error(
+ "Mutable source subscribe function must return an unsubscribe function."
+ );
+ }
+ }
- if (hook.baseQueue === null) {
- hook.baseState = newState;
- }
+ return unsubscribe;
+ },
+ [source, subscribe]
+ ); // If any of the inputs to useMutableSource change, reading is potentially unsafe.
+ //
+ // If either the source or the subscription have changed we can't can't trust the update queue.
+ // Maybe the source changed in a way that the old subscription ignored but the new one depends on.
+ //
+ // If the getSnapshot function changed, we also shouldn't rely on the update queue.
+ // It's possible that the underlying source was mutated between the when the last "change" event fired,
+ // and when the current render (with the new getSnapshot function) is processed.
+ //
+ // In both cases, we need to throw away pending updates (since they are no longer relevant)
+ // and treat reading from the source as we do in the mount case.
- queue.lastRenderedState = newState;
+ if (
+ !objectIs(prevGetSnapshot, getSnapshot) ||
+ !objectIs(prevSource, source) ||
+ !objectIs(prevSubscribe, subscribe)
+ ) {
+ // Create a new queue and setState method,
+ // So if there are interleaved updates, they get pushed to the older queue.
+ // When this becomes current, the previous queue and dispatch method will be discarded,
+ // including any interleaving updates that occur.
+ var newQueue = {
+ pending: null,
+ dispatch: null,
+ lastRenderedReducer: basicStateReducer,
+ lastRenderedState: snapshot
+ };
+ newQueue.dispatch = setSnapshot = dispatchAction.bind(
+ null,
+ currentlyRenderingFiber$1,
+ newQueue
+ );
+ stateHook.queue = newQueue;
+ stateHook.baseQueue = null;
+ snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ stateHook.memoizedState = stateHook.baseState = snapshot;
}
- return [newState, dispatch];
+ return snapshot;
+}
+
+function mountMutableSource(source, getSnapshot, subscribe) {
+ var hook = mountWorkInProgressHook();
+ hook.memoizedState = {
+ refs: {
+ getSnapshot: getSnapshot,
+ setSnapshot: null
+ },
+ source: source,
+ subscribe: subscribe
+ };
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+}
+
+function updateMutableSource(source, getSnapshot, subscribe) {
+ var hook = updateWorkInProgressHook();
+ return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountState(initialState) {
@@ -10863,13 +11370,15 @@ function rerenderDeferredValue(value, config) {
function startTransition(setPending, config, callback) {
var priorityLevel = getCurrentPriorityLevel();
runWithPriority(
- priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel,
+ priorityLevel < UserBlockingPriority$1
+ ? UserBlockingPriority$1
+ : priorityLevel,
function() {
setPending(true);
}
- );
+ ); // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition.
runWithPriority(
- priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
+ priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel,
function() {
var previousConfig = ReactCurrentBatchConfig$1.suspense;
ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
@@ -10920,6 +11429,54 @@ function rerenderTransition(config) {
return [start, isPending];
}
+var isUpdatingOpaqueValueInRenderPhase = false;
+function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
+ {
+ return isUpdatingOpaqueValueInRenderPhase;
+ }
+}
+
+function warnOnOpaqueIdentifierAccessInDEV(fiber) {
+ {
+ // TODO: Should warn in effects and callbacks, too
+ var name = getComponentName(fiber.type) || "Unknown";
+
+ if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) {
+ error(
+ "The object passed back from useOpaqueIdentifier is meant to be " +
+ "passed through to attributes only. Do not read the " +
+ "value directly."
+ );
+
+ didWarnAboutUseOpaqueIdentifier[name] = true;
+ }
+ }
+}
+
+function mountOpaqueIdentifier() {
+ var makeId = makeClientIdInDEV.bind(
+ null,
+ warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)
+ );
+
+ {
+ var _id = makeId();
+
+ mountState(_id);
+ return _id;
+ }
+}
+
+function updateOpaqueIdentifier() {
+ var id = updateState()[0];
+ return id;
+}
+
+function rerenderOpaqueIdentifier() {
+ var id = rerenderState()[0];
+ return id;
+}
+
function dispatchAction(fiber, queue, action) {
{
if (typeof arguments[3] === "function") {
@@ -10931,25 +11488,18 @@ function dispatchAction(fiber, queue, action) {
}
}
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- fiber,
- suspenseConfig
- );
+ var lane = requestUpdateLane(fiber, suspenseConfig);
var update = {
- expirationTime: expirationTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
action: action,
eagerReducer: null,
eagerState: null,
next: null
- };
-
- {
- update.priority = getCurrentPriorityLevel();
- } // Append the update to the end of the list.
+ }; // Append the update to the end of the list.
var pending = queue.pending;
@@ -10971,13 +11521,11 @@ function dispatchAction(fiber, queue, action) {
// This is a render phase update. Stash it in a lazily-created map of
// queue -> linked list of updates. After this render pass, we'll restart
// and apply the stashed updates on top of the work-in-progress hook.
- didScheduleRenderPhaseUpdate = true;
- update.expirationTime = renderExpirationTime;
- currentlyRenderingFiber$1.expirationTime = renderExpirationTime;
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
} else {
if (
- fiber.expirationTime === NoWork &&
- (alternate === null || alternate.expirationTime === NoWork)
+ fiber.lanes === NoLanes &&
+ (alternate === null || alternate.lanes === NoLanes)
) {
// The queue is currently empty, which means we can eagerly compute the
// next state before entering the render phase. If the new state is the
@@ -10988,8 +11536,8 @@ function dispatchAction(fiber, queue, action) {
var prevDispatcher;
{
- prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
}
try {
@@ -11013,7 +11561,7 @@ function dispatchAction(fiber, queue, action) {
// Suppress the error. It will throw again in the render phase.
} finally {
{
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
}
}
@@ -11027,18 +11575,10 @@ function dispatchAction(fiber, queue, action) {
}
}
- scheduleWork(fiber, expirationTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
}
-function mountEventListener(event) {
- return undefined;
-}
-
-function updateEventListener(event) {
- return undefined;
-}
-
var ContextOnlyDispatcher = {
readContext: readContext,
useCallback: throwInvalidHookError,
@@ -11054,7 +11594,9 @@ var ContextOnlyDispatcher = {
useResponder: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
- useEvent: throwInvalidHookError
+ useMutableSource: throwInvalidHookError,
+ useOpaqueIdentifier: throwInvalidHookError,
+ unstable_isNewReconciler: enableNewReconciler
};
var HooksDispatcherOnMountInDEV = null;
var HooksDispatcherOnMountWithHookTypesInDEV = null;
@@ -11120,25 +11662,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
mountHookTypesDev();
checkDepsAreArrayDev(deps);
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11149,13 +11691,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11178,11 +11720,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
mountHookTypesDev();
- return mountEventListener();
- }
+ return mountMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ mountHookTypesDev();
+ return mountOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
HooksDispatcherOnMountWithHookTypesInDEV = {
readContext: function(context, observedBits) {
@@ -11216,25 +11764,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMemo: function(create, deps) {
currentHookNameInDev = "useMemo";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11245,13 +11793,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11274,11 +11822,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return mountTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return mountEventListener();
- }
+ return mountMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ updateHookTypesDev();
+ return mountOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
HooksDispatcherOnUpdateInDEV = {
readContext: function(context, observedBits) {
@@ -11312,25 +11866,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMemo: function(create, deps) {
currentHookNameInDev = "useMemo";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11341,13 +11895,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11370,11 +11924,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ updateHookTypesDev();
+ return updateOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
HooksDispatcherOnRerenderInDEV = {
readContext: function(context, observedBits) {
@@ -11408,25 +11968,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMemo: function(create, deps) {
currentHookNameInDev = "useMemo";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
try {
return rerenderReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11437,13 +11997,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useState: function(initialState) {
currentHookNameInDev = "useState";
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
try {
return rerenderState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11466,11 +12026,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return rerenderTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ updateHookTypesDev();
+ return rerenderOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
InvalidNestedHooksDispatcherOnMountInDEV = {
readContext: function(context, observedBits) {
@@ -11511,26 +12077,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
warnInvalidHookAccess();
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
warnInvalidHookAccess();
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11543,13 +12109,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useState";
warnInvalidHookAccess();
mountHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
try {
return mountState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11576,12 +12142,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
mountHookTypesDev();
- return mountEventListener();
- }
+ return mountMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ warnInvalidHookAccess();
+ mountHookTypesDev();
+ return mountOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
InvalidNestedHooksDispatcherOnUpdateInDEV = {
readContext: function(context, observedBits) {
@@ -11622,26 +12195,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11654,13 +12227,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useState";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11687,12 +12260,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
InvalidNestedHooksDispatcherOnRerenderInDEV = {
readContext: function(context, observedBits) {
@@ -11733,26 +12313,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMemo";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return updateMemo(create, deps);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useReducer: function(reducer, initialArg, init) {
currentHookNameInDev = "useReducer";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return rerenderReducer(reducer, initialArg, init);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useRef: function(initialValue) {
@@ -11765,13 +12345,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useState";
warnInvalidHookAccess();
updateHookTypesDev();
- var prevDispatcher = ReactCurrentDispatcher.current;
- ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
try {
return rerenderState(initialState);
} finally {
- ReactCurrentDispatcher.current = prevDispatcher;
+ ReactCurrentDispatcher$1.current = prevDispatcher;
}
},
useDebugValue: function(value, formatterFn) {
@@ -11798,12 +12378,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return rerenderTransition(config);
},
- useEvent: function(event) {
- currentHookNameInDev = "useEvent";
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateEventListener();
- }
+ return updateMutableSource(source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ currentHookNameInDev = "useOpaqueIdentifier";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return rerenderOpaqueIdentifier();
+ },
+ unstable_isNewReconciler: enableNewReconciler
};
}
@@ -11844,40 +12431,15 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
}
}
-function enterHydrationState(fiber) {
- {
- return false;
- }
-}
-
-function prepareToHydrateHostInstance(
- fiber,
- rootContainerInstance,
- hostContext
-) {
- {
- {
- throw Error(
- "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
- );
- }
- }
-}
-
-function prepareToHydrateHostTextInstance(fiber) {
- {
- {
- throw Error(
- "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
- );
- }
- }
- var shouldUpdate = hydrateTextInstance();
-}
+function transferActualDuration(fiber) {
+ // Transfer time spent rendering these children so we don't lose it
+ // after we rerender. This is used as a helper in special cases
+ // where we should count the work of multiple passes.
+ var child = fiber.child;
-function popHydrationState(fiber) {
- {
- return false;
+ while (child) {
+ fiber.actualDuration += child.actualDuration;
+ child = child.sibling;
}
}
@@ -11903,12 +12465,7 @@ var didWarnAboutTailOptions;
didWarnAboutTailOptions = {};
}
-function reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
-) {
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
if (current === null) {
// If this is a fresh new component that hasn't been rendered yet, we
// won't update its child set by applying minimal side-effects. Instead,
@@ -11918,7 +12475,7 @@ function reconcileChildren(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
} else {
// If the current child is the same as the work in progress, it means that
@@ -11930,7 +12487,7 @@ function reconcileChildren(
workInProgress,
current.child,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
}
@@ -11939,7 +12496,7 @@ function forceUnmountCurrentAndReconcile(
current,
workInProgress,
nextChildren,
- renderExpirationTime
+ renderLanes
) {
// This function is fork of reconcileChildren. It's used in cases where we
// want to reconcile without matching against the existing set. This has the
@@ -11953,7 +12510,7 @@ function forceUnmountCurrentAndReconcile(
workInProgress,
current.child,
null,
- renderExpirationTime
+ renderLanes
); // In the second pass, we mount the new children. The trick here is that we
// pass null in place of where we usually pass the current child set. This has
// the effect of remounting all children regardless of whether their
@@ -11963,7 +12520,7 @@ function forceUnmountCurrentAndReconcile(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
@@ -11972,7 +12529,7 @@ function updateForwardRef(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
// TODO: current can be non-null here even if the component
// hasn't yet mounted. This happens after the first render suspends.
@@ -11998,7 +12555,7 @@ function updateForwardRef(
var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
var nextChildren;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
{
ReactCurrentOwner$1.current = workInProgress;
@@ -12009,20 +12566,23 @@ function updateForwardRef(
render,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
if (workInProgress.mode & StrictMode) {
- // Only double-render components with Hooks
- if (workInProgress.memoizedState !== null) {
+ disableLogs();
+
+ try {
nextChildren = renderWithHooks(
current,
workInProgress,
render,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
+ } finally {
+ reenableLogs();
}
}
@@ -12030,21 +12590,12 @@ function updateForwardRef(
}
if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderExpirationTime);
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
} // React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -12053,8 +12604,8 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (current === null) {
var type = Component.type;
@@ -12084,8 +12635,8 @@ function updateMemoComponent(
workInProgress,
resolvedType,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -12110,7 +12661,7 @@ function updateMemoComponent(
nextProps,
null,
workInProgress.mode,
- renderExpirationTime
+ renderLanes
);
child.ref = workInProgress.ref;
child.return = workInProgress;
@@ -12136,7 +12687,7 @@ function updateMemoComponent(
var currentChild = current.child; // This is always exactly one child
- if (updateExpirationTime < renderExpirationTime) {
+ if (!includesSomeLane(updateLanes, renderLanes)) {
// This will be the props with resolved defaultProps,
// unlike current.memoizedProps which will be the unresolved ones.
var prevProps = currentChild.memoizedProps; // Default to shallow comparison
@@ -12145,11 +12696,7 @@ function updateMemoComponent(
compare = compare !== null ? compare : shallowEqual;
if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
} // React DevTools reads this flag.
@@ -12166,8 +12713,8 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
// TODO: current can be non-null here even if the component
// hasn't yet mounted. This happens when the inner render suspends.
@@ -12182,19 +12729,27 @@ function updateSimpleMemoComponent(
// We warn when you define propTypes on lazy()
// so let's just skip over it to find memo() outer wrapper.
// Inner props for memo are validated later.
- outerMemoType = refineResolvedLazyComponent(outerMemoType);
- }
-
- var outerPropTypes = outerMemoType && outerMemoType.propTypes;
+ var lazyComponent = outerMemoType;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
- "prop",
- getComponentName(outerMemoType)
- );
- } // Inner propTypes will be validated in the function component path.
+ try {
+ outerMemoType = init(payload);
+ } catch (x) {
+ outerMemoType = null;
+ } // Inner propTypes will be validated in the function component path.
+
+ var outerPropTypes = outerMemoType && outerMemoType.propTypes;
+
+ if (outerPropTypes) {
+ checkPropTypes(
+ outerPropTypes,
+ nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
+ "prop",
+ getComponentName(outerMemoType)
+ );
+ }
+ }
}
}
@@ -12208,10 +12763,10 @@ function updateSimpleMemoComponent(
) {
didReceiveUpdate = false;
- if (updateExpirationTime < renderExpirationTime) {
- // The pending update priority was cleared at the beginning of
- // beginWork. We're about to bail out, but there might be additional
- // updates at a lower priority. Usually, the priority level of the
+ if (!includesSomeLane(renderLanes, updateLanes)) {
+ // The pending lanes were cleared at the beginning of beginWork. We're
+ // about to bail out, but there might be other lanes that weren't
+ // included in the current render. Usually, the priority level of the
// remaining updates is accumlated during the evaluation of the
// component (i.e. when processing the update queue). But since since
// we're bailing out early *without* evaluating the component, we need
@@ -12222,12 +12777,19 @@ function updateSimpleMemoComponent(
// contains hooks.
// TODO: Move the reset at in beginWork out of the common path so that
// this is no longer necessary.
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.lanes = current.lanes;
return bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
+ } else if (
+ (current.effectTag & ForceUpdateForLegacySuspense) !==
+ NoEffect
+ ) {
+ // This is a special case that only exists for legacy mode.
+ // See https://github.com/facebook/react/pull/19216.
+ didReceiveUpdate = true;
}
}
}
@@ -12237,33 +12799,101 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
);
}
-function updateFragment(current, workInProgress, renderExpirationTime) {
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps;
+ var nextChildren = nextProps.children;
+ var prevState = current !== null ? current.memoizedState : null;
+
+ if (
+ nextProps.mode === "hidden" ||
+ nextProps.mode === "unstable-defer-without-hiding"
+ ) {
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ // In legacy sync mode, don't defer the subtree. Render it now.
+ // TODO: Figure out what we should do in Blocking mode.
+ var nextState = {
+ baseLanes: NoLanes
+ };
+ workInProgress.memoizedState = nextState;
+ pushRenderLanes(workInProgress, renderLanes);
+ } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
+ var nextBaseLanes;
+
+ if (prevState !== null) {
+ var prevBaseLanes = prevState.baseLanes;
+ nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes);
+ } else {
+ nextBaseLanes = renderLanes;
+ } // Schedule this fiber to re-render at offscreen priority. Then bailout.
+
+ {
+ markSpawnedWork(OffscreenLane);
+ }
+
+ workInProgress.lanes = workInProgress.childLanes = laneToLanes(
+ OffscreenLane
+ );
+ var _nextState = {
+ baseLanes: nextBaseLanes
+ };
+ workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway
+ // to avoid a push/pop misalignment.
+
+ pushRenderLanes(workInProgress, nextBaseLanes);
+ return null;
+ } else {
+ // Rendering at offscreen, so we can clear the base lanes.
+ var _nextState2 = {
+ baseLanes: NoLanes
+ };
+ workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out.
+
+ var subtreeRenderLanes =
+ prevState !== null ? prevState.baseLanes : renderLanes;
+ pushRenderLanes(workInProgress, subtreeRenderLanes);
+ }
+ } else {
+ var _subtreeRenderLanes;
+
+ if (prevState !== null) {
+ _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state
+
+ workInProgress.memoizedState = null;
+ } else {
+ // We weren't previously hidden, and we still aren't, so there's nothing
+ // special to do. Need to push to the stack regardless, though, to avoid
+ // a push/pop misalignment.
+ _subtreeRenderLanes = renderLanes;
+ }
+
+ pushRenderLanes(workInProgress, _subtreeRenderLanes);
+ }
+
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+} // Note: These happen to have identical begin phases, for now. We shouldn't hold
+// ourselves to this constraint, though. If the behavior diverges, we should
+// fork the function.
+
+var updateLegacyHiddenComponent = updateOffscreenComponent;
+
+function updateFragment(current, workInProgress, renderLanes) {
var nextChildren = workInProgress.pendingProps;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function updateMode(current, workInProgress, renderExpirationTime) {
+function updateMode(current, workInProgress, renderLanes) {
var nextChildren = workInProgress.pendingProps.children;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function updateProfiler(current, workInProgress, renderExpirationTime) {
+function updateProfiler(current, workInProgress, renderLanes) {
{
workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase.
// These are reset during render to allow the DevTools commit hook a chance to read them,
@@ -12275,12 +12905,7 @@ function updateProfiler(current, workInProgress, renderExpirationTime) {
var nextProps = workInProgress.pendingProps;
var nextChildren = nextProps.children;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -12301,7 +12926,7 @@ function updateFunctionComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
{
if (workInProgress.type !== workInProgress.elementType) {
@@ -12328,7 +12953,7 @@ function updateFunctionComponent(
}
var nextChildren;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
{
ReactCurrentOwner$1.current = workInProgress;
@@ -12339,20 +12964,23 @@ function updateFunctionComponent(
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
if (workInProgress.mode & StrictMode) {
- // Only double-render components with Hooks
- if (workInProgress.memoizedState !== null) {
+ disableLogs();
+
+ try {
nextChildren = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
+ } finally {
+ reenableLogs();
}
}
@@ -12360,21 +12988,12 @@ function updateFunctionComponent(
}
if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderExpirationTime);
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
} // React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -12383,7 +13002,7 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
{
if (workInProgress.type !== workInProgress.elementType) {
@@ -12413,7 +13032,7 @@ function updateClassComponent(
hasContext = false;
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
var instance = workInProgress.stateNode;
var shouldUpdate;
@@ -12430,12 +13049,7 @@ function updateClassComponent(
} // In the initial pass we might need to construct the instance.
constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- );
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
shouldUpdate = true;
} else if (current === null) {
// In a resume, we'll already have an instance we can reuse.
@@ -12443,7 +13057,7 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
);
} else {
shouldUpdate = updateClassInstance(
@@ -12451,7 +13065,7 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
);
}
@@ -12461,13 +13075,13 @@ function updateClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
);
{
var inst = workInProgress.stateNode;
- if (inst.props !== nextProps) {
+ if (shouldUpdate && inst.props !== nextProps) {
if (!didWarnAboutReassigningProps) {
error(
"It looks like %s is reassigning its own `this.props` while rendering. " +
@@ -12489,7 +13103,7 @@ function finishClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
) {
// Refs should update even if shouldComponentUpdate returns false
markRef(current, workInProgress);
@@ -12501,11 +13115,7 @@ function finishClassComponent(
invalidateContextProvider(workInProgress, Component, false);
}
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
var instance = workInProgress.stateNode; // Rerender
@@ -12533,7 +13143,13 @@ function finishClassComponent(
nextChildren = instance.render();
if (workInProgress.mode & StrictMode) {
- instance.render();
+ disableLogs();
+
+ try {
+ instance.render();
+ } finally {
+ reenableLogs();
+ }
}
setIsRendering(false);
@@ -12551,15 +13167,10 @@ function finishClassComponent(
current,
workInProgress,
nextChildren,
- renderExpirationTime
+ renderLanes
);
} else {
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
} // Memoize state using the values we just used to render.
// TODO: Restructure so we never read values from the instance.
@@ -12589,7 +13200,7 @@ function pushHostRootContext(workInProgress) {
pushHostContainer(workInProgress, root.containerInfo);
}
-function updateHostRoot(current, workInProgress, renderExpirationTime) {
+function updateHostRoot(current, workInProgress, renderLanes) {
pushHostRootContext(workInProgress);
var updateQueue = workInProgress.updateQueue;
@@ -12603,32 +13214,24 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) {
var prevState = workInProgress.memoizedState;
var prevChildren = prevState !== null ? prevState.element : null;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime);
+ processUpdateQueue(workInProgress, nextProps, null, renderLanes);
var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
// being called "element".
var nextChildren = nextState.element;
if (nextChildren === prevChildren) {
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
var root = workInProgress.stateNode;
if (root.hydrate && enterHydrationState()) {
- // If we don't have any current children this might be the first pass.
- // We always try to hydrate. If this isn't a hydration pass there won't
- // be any children to hydrate which is effectively the same thing as
- // not hydrating.
var child = mountChildFibers(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
workInProgress.child = child;
var node = child;
@@ -12646,18 +13249,13 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) {
} else {
// Otherwise reset hydration state in case we aborted and resumed another
// root.
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
}
return workInProgress.child;
}
-function updateHostComponent(current, workInProgress, renderExpirationTime) {
+function updateHostComponent(current, workInProgress, renderLanes) {
pushHostContext(workInProgress);
var type = workInProgress.type;
@@ -12671,27 +13269,8 @@ function updateHostComponent(current, workInProgress, renderExpirationTime) {
workInProgress.effectTag |= ContentReset;
}
- markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden.
-
- if (
- workInProgress.mode & ConcurrentMode &&
- renderExpirationTime !== Never &&
- shouldDeprioritizeSubtree()
- ) {
- {
- markSpawnedWork(Never);
- } // Schedule this fiber to re-render at offscreen priority. Then bailout.
-
- workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
- return null;
- }
-
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ markRef(current, workInProgress);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
@@ -12705,8 +13284,8 @@ function mountLazyComponent(
_current,
workInProgress,
elementType,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (_current !== null) {
// A lazy component only mounts if it suspended inside a non-
@@ -12719,15 +13298,14 @@ function mountLazyComponent(
workInProgress.effectTag |= Placement;
}
- var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet.
- // Cancel and resume right after we know the tag.
-
- cancelWorkTimer(workInProgress);
- var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type.
+ var props = workInProgress.pendingProps;
+ var lazyComponent = elementType;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
+ var Component = init(payload); // Store the unwrapped component in the type.
workInProgress.type = Component;
var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component));
- startWorkTimer(workInProgress);
var resolvedProps = resolveDefaultProps(Component, props);
var child;
@@ -12745,7 +13323,7 @@ function mountLazyComponent(
workInProgress,
Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
return child;
}
@@ -12762,7 +13340,7 @@ function mountLazyComponent(
workInProgress,
Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
return child;
}
@@ -12779,7 +13357,7 @@ function mountLazyComponent(
workInProgress,
Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
return child;
}
@@ -12805,8 +13383,8 @@ function mountLazyComponent(
workInProgress,
Component,
resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
return child;
}
@@ -12841,7 +13419,7 @@ function mountIncompleteClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
if (_current !== null) {
// An incomplete component only mounts if it suspended inside a non-
@@ -12868,21 +13446,16 @@ function mountIncompleteClassComponent(
hasContext = false;
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- );
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
return finishClassComponent(
null,
workInProgress,
Component,
true,
hasContext,
- renderExpirationTime
+ renderLanes
);
}
@@ -12890,7 +13463,7 @@ function mountIndeterminateComponent(
_current,
workInProgress,
Component,
- renderExpirationTime
+ renderLanes
) {
if (_current !== null) {
// An indeterminate component only mounts if it suspended inside a non-
@@ -12911,7 +13484,7 @@ function mountIndeterminateComponent(
context = getMaskedContext(workInProgress, unmaskedContext);
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
var value;
{
@@ -12937,6 +13510,7 @@ function mountIndeterminateComponent(
ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
}
+ setIsRendering(true);
ReactCurrentOwner$1.current = workInProgress;
value = renderWithHooks(
null,
@@ -12944,34 +13518,65 @@ function mountIndeterminateComponent(
Component,
props,
context,
- renderExpirationTime
+ renderLanes
);
+ setIsRendering(false);
} // React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
+ {
+ // Support for module components is deprecated and is removed behind a flag.
+ // Whether or not it would crash later, we want to show a good message in DEV first.
+ if (
+ typeof value === "object" &&
+ value !== null &&
+ typeof value.render === "function" &&
+ value.$$typeof === undefined
+ ) {
+ var _componentName = getComponentName(Component) || "Unknown";
+
+ if (!didWarnAboutModulePatternComponent[_componentName]) {
+ error(
+ "The <%s /> component appears to be a function component that returns a class instance. " +
+ "Change %s to a class that extends React.Component instead. " +
+ "If you can't use a class try assigning the prototype on the function as a workaround. " +
+ "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " +
+ "cannot be called with `new` by React.",
+ _componentName,
+ _componentName,
+ _componentName
+ );
+
+ didWarnAboutModulePatternComponent[_componentName] = true;
+ }
+ }
+ }
+
if (
+ // Run these checks in production only if the flag is off.
+ // Eventually we'll delete this branch altogether.
typeof value === "object" &&
value !== null &&
typeof value.render === "function" &&
value.$$typeof === undefined
) {
{
- var _componentName = getComponentName(Component) || "Unknown";
+ var _componentName2 = getComponentName(Component) || "Unknown";
- if (!didWarnAboutModulePatternComponent[_componentName]) {
+ if (!didWarnAboutModulePatternComponent[_componentName2]) {
error(
"The <%s /> component appears to be a function component that returns a class instance. " +
"Change %s to a class that extends React.Component instead. " +
"If you can't use a class try assigning the prototype on the function as a workaround. " +
"`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " +
"cannot be called with `new` by React.",
- _componentName,
- _componentName,
- _componentName
+ _componentName2,
+ _componentName2,
+ _componentName2
);
- didWarnAboutModulePatternComponent[_componentName] = true;
+ didWarnAboutModulePatternComponent[_componentName2] = true;
}
} // Proceed under the assumption that this is a class instance
@@ -13006,14 +13611,14 @@ function mountIndeterminateComponent(
}
adoptClassInstance(workInProgress, value);
- mountClassInstance(workInProgress, Component, props, renderExpirationTime);
+ mountClassInstance(workInProgress, Component, props, renderLanes);
return finishClassComponent(
null,
workInProgress,
Component,
true,
hasContext,
- renderExpirationTime
+ renderLanes
);
} else {
// Proceed under the assumption that this is a function component
@@ -13021,21 +13626,24 @@ function mountIndeterminateComponent(
{
if (workInProgress.mode & StrictMode) {
- // Only double-render components with Hooks
- if (workInProgress.memoizedState !== null) {
+ disableLogs();
+
+ try {
value = renderWithHooks(
null,
workInProgress,
Component,
props,
context,
- renderExpirationTime
+ renderLanes
);
+ } finally {
+ reenableLogs();
}
}
}
- reconcileChildren(null, workInProgress, value, renderExpirationTime);
+ reconcileChildren(null, workInProgress, value, renderLanes);
{
validateFunctionComponentInDev(workInProgress, Component);
@@ -13084,15 +13692,15 @@ function validateFunctionComponentInDev(workInProgress, Component) {
}
if (typeof Component.getDerivedStateFromProps === "function") {
- var _componentName2 = getComponentName(Component) || "Unknown";
+ var _componentName3 = getComponentName(Component) || "Unknown";
- if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
+ if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
error(
"%s: Function components do not support getDerivedStateFromProps.",
- _componentName2
+ _componentName3
);
- didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
+ didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
}
}
@@ -13100,15 +13708,15 @@ function validateFunctionComponentInDev(workInProgress, Component) {
typeof Component.contextType === "object" &&
Component.contextType !== null
) {
- var _componentName3 = getComponentName(Component) || "Unknown";
+ var _componentName4 = getComponentName(Component) || "Unknown";
- if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
+ if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
error(
"%s: Function components do not support contextType.",
- _componentName3
+ _componentName4
);
- didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
+ didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
}
}
}
@@ -13116,24 +13724,51 @@ function validateFunctionComponentInDev(workInProgress, Component) {
var SUSPENDED_MARKER = {
dehydrated: null,
- retryTime: NoWork
+ retryLane: NoLane
};
-function shouldRemainOnFallback(suspenseContext, current, workInProgress) {
- // If the context is telling us that we should show a fallback, and we're not
- // already showing content, then we should show the fallback instead.
- return (
- hasSuspenseContext(suspenseContext, ForceSuspenseFallback) &&
- (current === null || current.memoizedState !== null)
- );
+function mountSuspenseOffscreenState(renderLanes) {
+ return {
+ baseLanes: renderLanes
+ };
+}
+
+function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
+ return {
+ baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes)
+ };
}
-function updateSuspenseComponent(
+function shouldRemainOnFallback(
+ suspenseContext,
current,
workInProgress,
- renderExpirationTime
+ renderLanes
) {
- var mode = workInProgress.mode;
+ // If we're already showing a fallback, there are cases where we need to
+ // remain on that fallback regardless of whether the content has resolved.
+ // For example, SuspenseList coordinates when nested content appears.
+ if (current !== null) {
+ var suspenseState = current.memoizedState;
+
+ if (suspenseState === null) {
+ // Currently showing content. Don't hide it, even if ForceSuspenseFallack
+ // is true. More precise name might be "ForceRemainSuspenseFallback".
+ // Note: This is a factoring smell. Can't remain on a fallback if there's
+ // no fallback to remain on.
+ return false;
+ }
+ } // Not currently showing content. Consult the Suspense context.
+
+ return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
+}
+
+function getRemainingWorkInPrimaryTree(current, renderLanes) {
+ // TODO: Should not remove render lanes that were pinged during this render
+ return removeLanes(current.childLanes, renderLanes);
+}
+
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
{
@@ -13143,13 +13778,13 @@ function updateSuspenseComponent(
}
var suspenseContext = suspenseStackCursor.current;
- var nextDidTimeout = false;
+ var showFallback = false;
var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
// Something in this boundary's subtree already suspended. Switch to
// rendering the fallback children.
- nextDidTimeout = true;
+ showFallback = true;
workInProgress.effectTag &= ~DidCapture;
} else {
// Attempting the main content
@@ -13172,290 +13807,380 @@ function updateSuspenseComponent(
}
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
- pushSuspenseContext(workInProgress, suspenseContext); // This next part is a bit confusing. If the children timeout, we switch to
- // showing the fallback children in place of the "primary" children.
- // However, we don't want to delete the primary children because then their
- // state will be lost (both the React state and the host state, e.g.
- // uncontrolled form inputs). Instead we keep them mounted and hide them.
- // Both the fallback children AND the primary children are rendered at the
- // same time. Once the primary children are un-suspended, we can delete
- // the fallback children — don't need to preserve their state.
+ pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense
+ // boundary's children. This involves some custom reconcilation logic. Two
+ // main reasons this is so complicated.
//
- // The two sets of children are siblings in the host environment, but
- // semantically, for purposes of reconciliation, they are two separate sets.
- // So we store them using two fragment fibers.
+ // First, Legacy Mode has different semantics for backwards compatibility. The
+ // primary tree will commit in an inconsistent state, so when we do the
+ // second pass to render the fallback, we do some exceedingly, uh, clever
+ // hacks to make that not totally break. Like transferring effects and
+ // deletions from hidden tree. In Concurrent Mode, it's much simpler,
+ // because we bailout on the primary tree completely and leave it in its old
+ // state, no effects. Same as what we do for Offscreen (except that
+ // Offscreen doesn't have the first render pass).
//
- // However, we want to avoid allocating extra fibers for every placeholder.
- // They're only necessary when the children time out, because that's the
- // only time when both sets are mounted.
+ // Second is hydration. During hydration, the Suspense fiber has a slightly
+ // different layout, where the child points to a dehydrated fragment, which
+ // contains the DOM rendered by the server.
//
- // So, the extra fragment fibers are only used if the children time out.
- // Otherwise, we render the primary children directly. This requires some
- // custom reconciliation logic to preserve the state of the primary
- // children. It's essentially a very basic form of re-parenting.
+ // Third, even if you set all that aside, Suspense is like error boundaries in
+ // that we first we try to render one tree, and if that fails, we render again
+ // and switch to a different tree. Like a try/catch block. So we have to track
+ // which branch we're currently rendering. Ideally we would model this using
+ // a stack.
if (current === null) {
+ // Initial mount
// If we're currently hydrating, try to hydrate this boundary.
// But only if this has a fallback.
- if (nextProps.fallback !== undefined); // This is the initial mount. This branch is pretty simple because there's
- // no previous state that needs to be preserved.
+ if (nextProps.fallback !== undefined);
- if (nextDidTimeout) {
- // Mount separate fragments for primary and fallback children.
+ if (showFallback) {
+ var nextPrimaryChildren = nextProps.children;
var nextFallbackChildren = nextProps.fallback;
- var primaryChildFragment = createFiberFromFragment(
- null,
- mode,
- NoWork,
- null
- );
- primaryChildFragment.return = workInProgress;
-
- if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, we commit the effects from the
- // partially completed, timed-out tree, too.
- var progressedState = workInProgress.memoizedState;
- var progressedPrimaryChild =
- progressedState !== null
- ? workInProgress.child.child
- : workInProgress.child;
- primaryChildFragment.child = progressedPrimaryChild;
- var progressedChild = progressedPrimaryChild;
-
- while (progressedChild !== null) {
- progressedChild.return = primaryChildFragment;
- progressedChild = progressedChild.sibling;
- }
- }
-
- var fallbackChildFragment = createFiberFromFragment(
+ var fallbackFragment = mountSuspenseFallbackChildren(
+ workInProgress,
+ nextPrimaryChildren,
nextFallbackChildren,
- mode,
- renderExpirationTime,
- null
+ renderLanes
+ );
+ var primaryChildFragment = workInProgress.child;
+ primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
+ renderLanes
);
- fallbackChildFragment.return = workInProgress;
- primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the
- // fallback children.
-
workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = primaryChildFragment;
- return fallbackChildFragment;
+ return fallbackFragment;
} else {
- // Mount the primary children without an intermediate fragment fiber.
- var nextPrimaryChildren = nextProps.children;
- workInProgress.memoizedState = null;
- return (workInProgress.child = mountChildFibers(
+ var _nextPrimaryChildren = nextProps.children;
+ return mountSuspensePrimaryChildren(
workInProgress,
- null,
- nextPrimaryChildren,
- renderExpirationTime
- ));
+ _nextPrimaryChildren,
+ renderLanes
+ );
}
} else {
- // This is an update. This branch is more complicated because we need to
- // ensure the state of the primary children is preserved.
+ // This is an update.
+ // If the current fiber has a SuspenseState, that means it's already showing
+ // a fallback.
var prevState = current.memoizedState;
if (prevState !== null) {
- // wrapped in a fragment fiber.
-
- var currentPrimaryChildFragment = current.child;
- var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
-
- if (nextDidTimeout) {
- // Still timed out. Reuse the current primary children by cloning
- // its fragment. We're going to skip over these entirely.
+ if (showFallback) {
var _nextFallbackChildren2 = nextProps.fallback;
+ var _nextPrimaryChildren3 = nextProps.children;
- var _primaryChildFragment2 = createWorkInProgress(
- currentPrimaryChildFragment,
- currentPrimaryChildFragment.pendingProps
+ var _fallbackChildFragment = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren3,
+ _nextFallbackChildren2,
+ renderLanes
);
- _primaryChildFragment2.return = workInProgress;
-
- if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, we commit the effects from the
- // partially completed, timed-out tree, too.
- var _progressedState = workInProgress.memoizedState;
-
- var _progressedPrimaryChild =
- _progressedState !== null
- ? workInProgress.child.child
- : workInProgress.child;
-
- if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
- _primaryChildFragment2.child = _progressedPrimaryChild;
- var _progressedChild2 = _progressedPrimaryChild;
-
- while (_progressedChild2 !== null) {
- _progressedChild2.return = _primaryChildFragment2;
- _progressedChild2 = _progressedChild2.sibling;
- }
- }
- } // Because primaryChildFragment is a new fiber that we're inserting as the
- // parent of a new tree, we need to set its treeBaseDuration.
-
- if (workInProgress.mode & ProfileMode) {
- // treeBaseDuration is the sum of all the child tree base durations.
- var _treeBaseDuration = 0;
- var _hiddenChild = _primaryChildFragment2.child;
+ var _primaryChildFragment2 = workInProgress.child;
+ var prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment2.memoizedState =
+ prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
+ _primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ );
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return _fallbackChildFragment;
+ } else {
+ var _nextPrimaryChildren4 = nextProps.children;
- while (_hiddenChild !== null) {
- _treeBaseDuration += _hiddenChild.treeBaseDuration;
- _hiddenChild = _hiddenChild.sibling;
- }
+ var _primaryChildFragment3 = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren4,
+ renderLanes
+ );
- _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
- } // Clone the fallback child fragment, too. These we'll continue
- // working on.
+ workInProgress.memoizedState = null;
+ return _primaryChildFragment3;
+ }
+ } else {
+ // The current tree is not already showing a fallback.
+ if (showFallback) {
+ // Timed out.
+ var _nextFallbackChildren3 = nextProps.fallback;
+ var _nextPrimaryChildren5 = nextProps.children;
- var _fallbackChildFragment2 = createWorkInProgress(
- currentFallbackChildFragment,
- _nextFallbackChildren2
+ var _fallbackChildFragment2 = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren5,
+ _nextFallbackChildren3,
+ renderLanes
);
- _fallbackChildFragment2.return = workInProgress;
- _primaryChildFragment2.sibling = _fallbackChildFragment2;
- _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
+ var _primaryChildFragment4 = workInProgress.child;
+ var _prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment4.memoizedState =
+ _prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
+ _primaryChildFragment4.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ ); // Skip the primary children, and continue working on the
// fallback children.
workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = _primaryChildFragment2;
return _fallbackChildFragment2;
} else {
- // No longer suspended. Switch back to showing the primary children,
- // and remove the intermediate fragment fiber.
- var _nextPrimaryChildren = nextProps.children;
- var currentPrimaryChild = currentPrimaryChildFragment.child;
- var primaryChild = reconcileChildFibers(
+ // Still haven't timed out. Continue rendering the children, like we
+ // normally do.
+ var _nextPrimaryChildren6 = nextProps.children;
+
+ var _primaryChildFragment5 = updateSuspensePrimaryChildren(
+ current,
workInProgress,
- currentPrimaryChild,
- _nextPrimaryChildren,
- renderExpirationTime
- ); // If this render doesn't suspend, we need to delete the fallback
- // children. Wait until the complete phase, after we've confirmed the
- // fallback is no longer needed.
- // TODO: Would it be better to store the fallback fragment on
- // the stateNode?
- // Continue rendering the children, like we normally do.
+ _nextPrimaryChildren6,
+ renderLanes
+ );
workInProgress.memoizedState = null;
- return (workInProgress.child = primaryChild);
+ return _primaryChildFragment5;
}
- } else {
- // The current tree has not already timed out. That means the primary
- // children are not wrapped in a fragment fiber.
- var _currentPrimaryChild = current.child;
+ }
+ }
+}
- if (nextDidTimeout) {
- // Timed out. Wrap the children in a fragment fiber to keep them
- // separate from the fallback children.
- var _nextFallbackChildren3 = nextProps.fallback;
+function mountSuspensePrimaryChildren(
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var primaryChildProps = {
+ mode: "visible",
+ children: primaryChildren
+ };
+ var primaryChildFragment = createFiberFromOffscreen(
+ primaryChildProps,
+ mode,
+ renderLanes,
+ null
+ );
+ primaryChildFragment.return = workInProgress;
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
+}
- var _primaryChildFragment3 = createFiberFromFragment(
- // It shouldn't matter what the pending props are because we aren't
- // going to render this fragment.
- null,
- mode,
- NoWork,
- null
- );
+function mountSuspenseFallbackChildren(
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var progressedPrimaryFragment = workInProgress.child;
+ var primaryChildProps = {
+ mode: "hidden",
+ children: primaryChildren
+ };
+ var primaryChildFragment;
+ var fallbackChildFragment;
+
+ if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) {
+ // In legacy mode, we commit the primary tree as if it successfully
+ // completed, even though it's in an inconsistent state.
+ primaryChildFragment = progressedPrimaryFragment;
+ primaryChildFragment.childLanes = NoLanes;
+ primaryChildFragment.pendingProps = primaryChildProps;
+
+ if (workInProgress.mode & ProfileMode) {
+ // Reset the durations from the first pass so they aren't included in the
+ // final amounts. This seems counterintuitive, since we're intentionally
+ // not measuring part of the render phase, but this makes it match what we
+ // do in Concurrent Mode.
+ primaryChildFragment.actualDuration = 0;
+ primaryChildFragment.actualStartTime = -1;
+ primaryChildFragment.selfBaseDuration = 0;
+ primaryChildFragment.treeBaseDuration = 0;
+ }
+
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ } else {
+ primaryChildFragment = createFiberFromOffscreen(
+ primaryChildProps,
+ mode,
+ NoLanes,
+ null
+ );
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ }
- _primaryChildFragment3.return = workInProgress;
- _primaryChildFragment3.child = _currentPrimaryChild;
+ primaryChildFragment.return = workInProgress;
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
+}
- if (_currentPrimaryChild !== null) {
- _currentPrimaryChild.return = _primaryChildFragment3;
- } // Even though we're creating a new fiber, there are no new children,
- // because we're reusing an already mounted tree. So we don't need to
- // schedule a placement.
- // primaryChildFragment.effectTag |= Placement;
+function createWorkInProgressOffscreenFiber(current, offscreenProps) {
+ // The props argument to `createWorkInProgress` is `any` typed, so we use this
+ // wrapper function to constrain it.
+ return createWorkInProgress(current, offscreenProps);
+}
- if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, we commit the effects from the
- // partially completed, timed-out tree, too.
- var _progressedState2 = workInProgress.memoizedState;
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
+ var primaryChildFragment = createWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
+ {
+ mode: "visible",
+ children: primaryChildren
+ }
+ );
- var _progressedPrimaryChild2 =
- _progressedState2 !== null
- ? workInProgress.child.child
- : workInProgress.child;
+ if ((workInProgress.mode & BlockingMode) === NoMode) {
+ primaryChildFragment.lanes = renderLanes;
+ }
- _primaryChildFragment3.child = _progressedPrimaryChild2;
- var _progressedChild3 = _progressedPrimaryChild2;
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = null;
- while (_progressedChild3 !== null) {
- _progressedChild3.return = _primaryChildFragment3;
- _progressedChild3 = _progressedChild3.sibling;
- }
- } // Because primaryChildFragment is a new fiber that we're inserting as the
- // parent of a new tree, we need to set its treeBaseDuration.
+ if (currentFallbackChildFragment !== null) {
+ // Delete the fallback child fragment
+ currentFallbackChildFragment.nextEffect = null;
+ currentFallbackChildFragment.effectTag = Deletion;
+ workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment;
+ }
- if (workInProgress.mode & ProfileMode) {
- // treeBaseDuration is the sum of all the child tree base durations.
- var _treeBaseDuration2 = 0;
- var _hiddenChild2 = _primaryChildFragment3.child;
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
+}
- while (_hiddenChild2 !== null) {
- _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
- _hiddenChild2 = _hiddenChild2.sibling;
- }
+function updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var currentPrimaryChildFragment = current.child;
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
+ var primaryChildProps = {
+ mode: "hidden",
+ children: primaryChildren
+ };
+ var primaryChildFragment;
- _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
- } // Create a fragment from the fallback children, too.
+ if (
+ // In legacy mode, we commit the primary tree as if it successfully
+ // completed, even though it's in an inconsistent state.
+ (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was
+ // already cloned. In legacy mode, the only case where this isn't true is
+ // when DevTools forces us to display a fallback; we skip the first render
+ // pass entirely and go straight to rendering the fallback. (In Concurrent
+ // Mode, SuspenseList can also trigger this scenario, but this is a legacy-
+ // only codepath.)
+ workInProgress.child !== currentPrimaryChildFragment
+ ) {
+ var progressedPrimaryFragment = workInProgress.child;
+ primaryChildFragment = progressedPrimaryFragment;
+ primaryChildFragment.childLanes = NoLanes;
+ primaryChildFragment.pendingProps = primaryChildProps;
+
+ if (workInProgress.mode & ProfileMode) {
+ // Reset the durations from the first pass so they aren't included in the
+ // final amounts. This seems counterintuitive, since we're intentionally
+ // not measuring part of the render phase, but this makes it match what we
+ // do in Concurrent Mode.
+ primaryChildFragment.actualDuration = 0;
+ primaryChildFragment.actualStartTime = -1;
+ primaryChildFragment.selfBaseDuration =
+ currentPrimaryChildFragment.selfBaseDuration;
+ primaryChildFragment.treeBaseDuration =
+ currentPrimaryChildFragment.treeBaseDuration;
+ } // The fallback fiber was added as a deletion effect during the first pass.
+ // However, since we're going to remain on the fallback, we no longer want
+ // to delete it. So we need to remove it from the list. Deletions are stored
+ // on the same list as effects. We want to keep the effects from the primary
+ // tree. So we copy the primary child fragment's effect list, which does not
+ // include the fallback deletion effect.
+
+ var progressedLastEffect = primaryChildFragment.lastEffect;
+
+ if (progressedLastEffect !== null) {
+ workInProgress.firstEffect = primaryChildFragment.firstEffect;
+ workInProgress.lastEffect = progressedLastEffect;
+ progressedLastEffect.nextEffect = null;
+ } else {
+ // TODO: Reset this somewhere else? Lol legacy mode is so weird.
+ workInProgress.firstEffect = workInProgress.lastEffect = null;
+ }
+ } else {
+ primaryChildFragment = createWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ );
+ }
- var _fallbackChildFragment3 = createFiberFromFragment(
- _nextFallbackChildren3,
- mode,
- renderExpirationTime,
- null
- );
+ var fallbackChildFragment;
- _fallbackChildFragment3.return = workInProgress;
- _primaryChildFragment3.sibling = _fallbackChildFragment3;
- _fallbackChildFragment3.effectTag |= Placement;
- _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
- // fallback children.
+ if (currentFallbackChildFragment !== null) {
+ fallbackChildFragment = createWorkInProgress(
+ currentFallbackChildFragment,
+ fallbackChildren
+ );
+ } else {
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ ); // Needs a placement effect because the parent (the Suspense boundary) already
+ // mounted but this is a new fiber.
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = _primaryChildFragment3;
- return _fallbackChildFragment3;
- } else {
- // Still haven't timed out. Continue rendering the children, like we
- // normally do.
- workInProgress.memoizedState = null;
- var _nextPrimaryChildren2 = nextProps.children;
- return (workInProgress.child = reconcileChildFibers(
- workInProgress,
- _currentPrimaryChild,
- _nextPrimaryChildren2,
- renderExpirationTime
- ));
- }
- }
+ fallbackChildFragment.effectTag |= Placement;
}
-}
-function scheduleWorkOnFiber(fiber, renderExpirationTime) {
- if (fiber.expirationTime < renderExpirationTime) {
- fiber.expirationTime = renderExpirationTime;
- }
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
+}
+function scheduleWorkOnFiber(fiber, renderLanes) {
+ fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
var alternate = fiber.alternate;
- if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
- alternate.expirationTime = renderExpirationTime;
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
}
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
+ scheduleWorkOnParentPath(fiber.return, renderLanes);
}
function propagateSuspenseContextChange(
workInProgress,
firstChild,
- renderExpirationTime
+ renderLanes
) {
// Mark any Suspense boundaries with fallbacks as having work to do.
// If they were previously forced into fallbacks, they may now be able
@@ -13467,7 +14192,7 @@ function propagateSuspenseContextChange(
var state = node.memoizedState;
if (state !== null) {
- scheduleWorkOnFiber(node, renderExpirationTime);
+ scheduleWorkOnFiber(node, renderLanes);
}
} else if (node.tag === SuspenseListComponent) {
// If the tail is hidden there might not be an Suspense boundaries
@@ -13475,7 +14200,7 @@ function propagateSuspenseContextChange(
// list itself.
// We don't have to traverse to the children of the list since
// the list will propagate the change when it rerenders.
- scheduleWorkOnFiber(node, renderExpirationTime);
+ scheduleWorkOnFiber(node, renderLanes);
} else if (node.child !== null) {
node.child.return = node;
node = node.child;
@@ -13717,11 +14442,7 @@ function initSuspenseListRenderState(
// in fallback state. Then we render each row in the tail one-by-one.
// That happens in the completeWork phase without going back to beginWork.
-function updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps;
var revealOrder = nextProps.revealOrder;
var tailMode = nextProps.tail;
@@ -13729,7 +14450,7 @@ function updateSuspenseListComponent(
validateRevealOrder(revealOrder);
validateTailOptions(tailMode, revealOrder);
validateSuspenseListChildren(newChildren, revealOrder);
- reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
var suspenseContext = suspenseStackCursor.current;
var shouldForceFallback = hasSuspenseContext(
suspenseContext,
@@ -13753,7 +14474,7 @@ function updateSuspenseListComponent(
propagateSuspenseContextChange(
workInProgress,
workInProgress.child,
- renderExpirationTime
+ renderLanes
);
}
@@ -13763,7 +14484,7 @@ function updateSuspenseListComponent(
pushSuspenseContext(workInProgress, suspenseContext);
if ((workInProgress.mode & BlockingMode) === NoMode) {
- // Outside of blocking mode, SuspenseList doesn't work so we just
+ // In legacy mode, SuspenseList doesn't work so we just
// use make it a noop by treating it as the default revealOrder.
workInProgress.memoizedState = null;
} else {
@@ -13853,7 +14574,7 @@ function updateSuspenseListComponent(
return workInProgress.child;
}
-function updatePortalComponent(current, workInProgress, renderExpirationTime) {
+function updatePortalComponent(current, workInProgress, renderLanes) {
pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
var nextChildren = workInProgress.pendingProps;
@@ -13867,21 +14588,18 @@ function updatePortalComponent(current, workInProgress, renderExpirationTime) {
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
);
} else {
- reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
}
return workInProgress.child;
}
-function updateContextProvider(current, workInProgress, renderExpirationTime) {
+var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
+
+function updateContextProvider(current, workInProgress, renderLanes) {
var providerType = workInProgress.type;
var context = providerType._context;
var newProps = workInProgress.pendingProps;
@@ -13889,6 +14607,16 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) {
var newValue = newProps.value;
{
+ if (!("value" in newProps)) {
+ if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
+ hasWarnedAboutUsingNoValuePropOnContextProvider = true;
+
+ error(
+ "The `value` prop is required for the ``. Did you misspell it or forget to pass it?"
+ );
+ }
+ }
+
var providerPropTypes = workInProgress.type.propTypes;
if (providerPropTypes) {
@@ -13908,29 +14636,24 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) {
return bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
}
} else {
// The context value changed. Search for matching consumers and schedule
// them to update.
- propagateContextChange(
- workInProgress,
- context,
- changedBits,
- renderExpirationTime
- );
+ propagateContextChange(workInProgress, context, changedBits, renderLanes);
}
}
var newChildren = newProps.children;
- reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
return workInProgress.child;
}
var hasWarnedAboutUsingContextAsConsumer = false;
-function updateContextConsumer(current, workInProgress, renderExpirationTime) {
+function updateContextConsumer(current, workInProgress, renderLanes) {
var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
// DEV mode, we create a separate object for Context.Consumer that acts
// like a proxy to Context. This proxy object adds unnecessary code in PROD
@@ -13973,7 +14696,7 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) {
}
}
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
var newValue = readContext(context, newProps.unstable_observedBits);
var newChildren;
@@ -13985,7 +14708,7 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) {
} // React DevTools reads this flag.
workInProgress.effectTag |= PerformedWork;
- reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
return workInProgress.child;
}
@@ -13993,13 +14716,7 @@ function markWorkInProgressReceivedUpdate() {
didReceiveUpdate = true;
}
-function bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
-) {
- cancelWorkTimer(workInProgress);
-
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
if (current !== null) {
// Reuse previous dependencies
workInProgress.dependencies = current.dependencies;
@@ -14010,15 +14727,9 @@ function bailoutOnAlreadyFinishedWork(
stopProfilerTimerIfRunning();
}
- var updateExpirationTime = workInProgress.expirationTime;
+ markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.
- if (updateExpirationTime !== NoWork) {
- markUnprocessedUpdateTime(updateExpirationTime);
- } // Check if the children have any pending work.
-
- var childExpirationTime = workInProgress.childExpirationTime;
-
- if (childExpirationTime < renderExpirationTime) {
+ if (!includesSomeLane(renderLanes, workInProgress.childLanes)) {
// The children don't have any work either. We can skip them.
// TODO: Once we add back resuming, we should check if the children are
// a work-in-progress set. If so, we need to transfer their effects.
@@ -14086,8 +14797,8 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
}
}
-function beginWork(current, workInProgress, renderExpirationTime) {
- var updateExpirationTime = workInProgress.expirationTime;
+function beginWork(current, workInProgress, renderLanes) {
+ var updateLanes = workInProgress.lanes;
{
if (workInProgress._debugNeedsRemount && current !== null) {
@@ -14101,7 +14812,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress.pendingProps,
workInProgress._debugOwner || null,
workInProgress.mode,
- workInProgress.expirationTime
+ workInProgress.lanes
)
);
}
@@ -14119,7 +14830,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// If props or context changed, mark the fiber as having performed work.
// This may be unset if the props are determined to be equal later (memo).
didReceiveUpdate = true;
- } else if (updateExpirationTime < renderExpirationTime) {
+ } else if (!includesSomeLane(renderLanes, updateLanes)) {
didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
// the begin phase. There's still some bookkeeping we that needs to be done
// in this optimized path, mostly pushing stuff onto the stack.
@@ -14131,20 +14842,6 @@ function beginWork(current, workInProgress, renderExpirationTime) {
case HostComponent:
pushHostContext(workInProgress);
-
- if (
- workInProgress.mode & ConcurrentMode &&
- renderExpirationTime !== Never &&
- shouldDeprioritizeSubtree(workInProgress.type)
- ) {
- {
- markSpawnedWork(Never);
- } // Schedule this fiber to re-render at offscreen priority. Then bailout.
-
- workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
- return null;
- }
-
break;
case ClassComponent: {
@@ -14173,8 +14870,10 @@ function beginWork(current, workInProgress, renderExpirationTime) {
case Profiler:
{
// Profiler should only call onRender when one of its descendants actually rendered.
- var hasChildWork =
- workInProgress.childExpirationTime >= renderExpirationTime;
+ var hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
if (hasChildWork) {
workInProgress.effectTag |= Update;
@@ -14197,21 +14896,19 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// child fragment.
var primaryChildFragment = workInProgress.child;
- var primaryChildExpirationTime =
- primaryChildFragment.childExpirationTime;
+ var primaryChildLanes = primaryChildFragment.childLanes;
- if (
- primaryChildExpirationTime !== NoWork &&
- primaryChildExpirationTime >= renderExpirationTime
- ) {
+ if (includesSomeLane(renderLanes, primaryChildLanes)) {
// The primary children have pending work. Use the normal path
// to attempt to render the primary children again.
return updateSuspenseComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
} else {
+ // The primary child fragment does not have pending work marked
+ // on it
pushSuspenseContext(
workInProgress,
setDefaultShallowSuspenseContext(suspenseStackCursor.current)
@@ -14221,7 +14918,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
var child = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
if (child !== null) {
@@ -14245,8 +14942,10 @@ function beginWork(current, workInProgress, renderExpirationTime) {
case SuspenseListComponent: {
var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect;
- var _hasChildWork =
- workInProgress.childExpirationTime >= renderExpirationTime;
+ var _hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
if (didSuspendBefore) {
if (_hasChildWork) {
@@ -14258,7 +14957,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
return updateSuspenseListComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
} // If none of the children had any work, that means that none of
// them got retried so they'll still be blocked in the same way
@@ -14276,6 +14975,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// update in the past but didn't complete it.
renderState.rendering = null;
renderState.tail = null;
+ renderState.lastEffect = null;
}
pushSuspenseContext(workInProgress, suspenseStackCursor.current);
@@ -14289,19 +14989,35 @@ function beginWork(current, workInProgress, renderExpirationTime) {
return null;
}
}
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ // Need to check if the tree still needs to be deferred. This is
+ // almost identical to the logic used in the normal update path,
+ // so we'll just enter that. The only difference is we'll bail out
+ // at the next level instead of this one, because the child props
+ // have not changed. Which is fine.
+ // TODO: Probably should refactor `beginWork` to split the bailout
+ // path from the normal path. I'm tempted to do a labeled break here
+ // but I won't :)
+ workInProgress.lanes = NoLanes;
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ }
}
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
} else {
- // An update was scheduled on this fiber, but there are no new props
- // nor legacy context. Set this to false. If an update queue or context
- // consumer produces a changed value, it will set this to true. Otherwise,
- // the component will assume the children have not changed and bail out.
- didReceiveUpdate = false;
+ if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) {
+ // This is a special case that only exists for legacy mode.
+ // See https://github.com/facebook/react/pull/19216.
+ didReceiveUpdate = true;
+ } else {
+ // An update was scheduled on this fiber, but there are no new props
+ // nor legacy context. Set this to false. If an update queue or context
+ // consumer produces a changed value, it will set this to true. Otherwise,
+ // the component will assume the children have not changed and bail out.
+ didReceiveUpdate = false;
+ }
}
} else {
didReceiveUpdate = false;
@@ -14311,7 +15027,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
// sometimes bails out later in the begin phase. This indicates that we should
// move this assignment out of the common path and into each branch.
- workInProgress.expirationTime = NoWork;
+ workInProgress.lanes = NoLanes;
switch (workInProgress.tag) {
case IndeterminateComponent: {
@@ -14319,7 +15035,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.type,
- renderExpirationTime
+ renderLanes
);
}
@@ -14329,8 +15045,8 @@ function beginWork(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
elementType,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -14346,7 +15062,7 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
_Component,
resolvedProps,
- renderExpirationTime
+ renderLanes
);
}
@@ -14364,32 +15080,24 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
_Component2,
_resolvedProps,
- renderExpirationTime
+ renderLanes
);
}
case HostRoot:
- return updateHostRoot(current, workInProgress, renderExpirationTime);
+ return updateHostRoot(current, workInProgress, renderLanes);
case HostComponent:
- return updateHostComponent(current, workInProgress, renderExpirationTime);
+ return updateHostComponent(current, workInProgress, renderLanes);
case HostText:
return updateHostText();
case SuspenseComponent:
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
case HostPortal:
- return updatePortalComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updatePortalComponent(current, workInProgress, renderLanes);
case ForwardRef: {
var type = workInProgress.type;
@@ -14405,32 +15113,24 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
type,
_resolvedProps2,
- renderExpirationTime
+ renderLanes
);
}
case Fragment:
- return updateFragment(current, workInProgress, renderExpirationTime);
+ return updateFragment(current, workInProgress, renderLanes);
case Mode:
- return updateMode(current, workInProgress, renderExpirationTime);
+ return updateMode(current, workInProgress, renderLanes);
case Profiler:
- return updateProfiler(current, workInProgress, renderExpirationTime);
+ return updateProfiler(current, workInProgress, renderLanes);
case ContextProvider:
- return updateContextProvider(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateContextProvider(current, workInProgress, renderLanes);
case ContextConsumer:
- return updateContextConsumer(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateContextConsumer(current, workInProgress, renderLanes);
case MemoComponent: {
var _type2 = workInProgress.type;
@@ -14459,8 +15159,8 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
_type2,
_resolvedProps3,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -14470,8 +15170,8 @@ function beginWork(current, workInProgress, renderExpirationTime) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
}
@@ -14484,21 +15184,37 @@ function beginWork(current, workInProgress, renderExpirationTime) {
? _unresolvedProps4
: resolveDefaultProps(_Component3, _unresolvedProps4);
- return mountIncompleteClassComponent(
- current,
- workInProgress,
- _Component3,
- _resolvedProps4,
- renderExpirationTime
- );
+ return mountIncompleteClassComponent(
+ current,
+ workInProgress,
+ _Component3,
+ _resolvedProps4,
+ renderLanes
+ );
+ }
+
+ case SuspenseListComponent: {
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
+ }
+
+ case FundamentalComponent: {
+ break;
+ }
+
+ case ScopeComponent: {
+ break;
+ }
+
+ case Block: {
+ break;
}
- case SuspenseListComponent: {
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ case OffscreenComponent: {
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ }
+
+ case LegacyHiddenComponent: {
+ return updateLegacyHiddenComponent(current, workInProgress, renderLanes);
}
}
@@ -14682,7 +15398,7 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
}
}
-function completeWork(current, workInProgress, renderExpirationTime) {
+function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
@@ -14711,6 +15427,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
case HostRoot: {
popHostContainer(workInProgress);
popTopLevelContextObject(workInProgress);
+ resetWorkInProgressVersions();
var fiberRoot = workInProgress.stateNode;
if (fiberRoot.pendingContext) {
@@ -14727,6 +15444,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
// If we hydrated, then we'll need to schedule an update for
// the commit side-effects on the root.
markUpdate(workInProgress);
+ } else if (!fiberRoot.hydrate) {
+ // Schedule an effect to clear this container at the start of the next commit.
+ // This handles the case of React rendering into a container with previous children.
+ // It's also safe to do for updates too, because current.child would only be null
+ // if the previous render was null (so the the container would already be empty).
+ workInProgress.effectTag |= Snapshot;
}
}
@@ -14851,7 +15574,11 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
// Something suspended. Re-render with the fallback children.
- workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list.
+ workInProgress.lanes = renderLanes; // Do not reset the effect list.
+
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ }
return workInProgress;
}
@@ -14864,29 +15591,6 @@ function completeWork(current, workInProgress, renderExpirationTime) {
} else {
var prevState = current.memoizedState;
prevDidTimeout = prevState !== null;
-
- if (!nextDidTimeout && prevState !== null) {
- // We just switched from the fallback to the normal children.
- // Delete the fallback.
- // TODO: Would it be better to store the fallback fragment on
- // the stateNode during the begin phase?
- var currentFallbackChild = current.child.sibling;
-
- if (currentFallbackChild !== null) {
- // Deletions go at the beginning of the return fiber's effect list
- var first = workInProgress.firstEffect;
-
- if (first !== null) {
- workInProgress.firstEffect = currentFallbackChild;
- currentFallbackChild.nextEffect = first;
- } else {
- workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
- currentFallbackChild.nextEffect = null;
- }
-
- currentFallbackChild.effectTag = Deletion;
- }
- }
}
if (nextDidTimeout && !prevDidTimeout) {
@@ -14943,6 +15647,11 @@ function completeWork(current, workInProgress, renderExpirationTime) {
case HostPortal:
popHostContainer(workInProgress);
updateHostContainer(workInProgress);
+
+ if (current === null) {
+ preparePortalMount(workInProgress.stateNode.containerInfo);
+ }
+
return null;
case ContextProvider:
@@ -15029,7 +15738,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state.
- resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately
+ resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
// rerender the children.
pushSuspenseContext(
@@ -15070,7 +15779,8 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if (
renderState.tail === null &&
renderState.tailMode === "hidden" &&
- !renderedTail.alternate
+ !renderedTail.alternate &&
+ !getIsHydrating() // We don't cut it if we're hydrating.
) {
// We need to delete the row we just rendered.
// Reset the effect list to what it was before we rendered this
@@ -15089,7 +15799,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
// the expiration.
now() * 2 - renderState.renderingStartTime >
renderState.tailExpiration &&
- renderExpirationTime > Never
+ renderLanes !== OffscreenLane
) {
// We have now passed our CPU deadline and we'll just give up further
// attempts to render the main content and only render fallbacks.
@@ -15102,11 +15812,10 @@ function completeWork(current, workInProgress, renderExpirationTime) {
// So we'll pick it back up the very next render pass once we've had
// an opportunity to yield for paint.
- var nextPriority = renderExpirationTime - 1;
- workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
+ workInProgress.lanes = renderLanes;
{
- markSpawnedWork(nextPriority);
+ markSpawnedWork(renderLanes);
}
}
}
@@ -15173,6 +15882,38 @@ function completeWork(current, workInProgress, renderExpirationTime) {
return null;
}
+
+ case FundamentalComponent: {
+ break;
+ }
+
+ case ScopeComponent: {
+ break;
+ }
+
+ case Block:
+ break;
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ popRenderLanes(workInProgress);
+
+ if (current !== null) {
+ var _nextState = workInProgress.memoizedState;
+ var _prevState = current.memoizedState;
+ var prevIsHidden = _prevState !== null;
+ var nextIsHidden = _nextState !== null;
+
+ if (
+ prevIsHidden !== nextIsHidden &&
+ newProps.mode !== "unstable-defer-without-hiding"
+ ) {
+ workInProgress.effectTag |= Update;
+ }
+ }
+
+ return null;
+ }
}
{
@@ -15184,7 +15925,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
}
}
-function unwindWork(workInProgress, renderExpirationTime) {
+function unwindWork(workInProgress, renderLanes) {
switch (workInProgress.tag) {
case ClassComponent: {
var Component = workInProgress.type;
@@ -15197,6 +15938,11 @@ function unwindWork(workInProgress, renderExpirationTime) {
if (effectTag & ShouldCapture) {
workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture;
+
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ }
+
return workInProgress;
}
@@ -15206,6 +15952,7 @@ function unwindWork(workInProgress, renderExpirationTime) {
case HostRoot: {
popHostContainer(workInProgress);
popTopLevelContextObject(workInProgress);
+ resetWorkInProgressVersions();
var _effectTag = workInProgress.effectTag;
if (!((_effectTag & DidCapture) === NoEffect)) {
@@ -15232,6 +15979,10 @@ function unwindWork(workInProgress, renderExpirationTime) {
if (_effectTag2 & ShouldCapture) {
workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary.
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ }
+
return workInProgress;
}
@@ -15245,216 +15996,526 @@ function unwindWork(workInProgress, renderExpirationTime) {
return null;
}
- case HostPortal:
- popHostContainer(workInProgress);
- return null;
+ case HostPortal:
+ popHostContainer(workInProgress);
+ return null;
+
+ case ContextProvider:
+ popProvider(workInProgress);
+ return null;
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent:
+ popRenderLanes(workInProgress);
+ return null;
+
+ default:
+ return null;
+ }
+}
+
+function unwindInterruptedWork(interruptedWork) {
+ switch (interruptedWork.tag) {
+ case ClassComponent: {
+ var childContextTypes = interruptedWork.type.childContextTypes;
+
+ if (childContextTypes !== null && childContextTypes !== undefined) {
+ popContext(interruptedWork);
+ }
+
+ break;
+ }
+
+ case HostRoot: {
+ popHostContainer(interruptedWork);
+ popTopLevelContextObject(interruptedWork);
+ resetWorkInProgressVersions();
+ break;
+ }
+
+ case HostComponent: {
+ popHostContext(interruptedWork);
+ break;
+ }
+
+ case HostPortal:
+ popHostContainer(interruptedWork);
+ break;
+
+ case SuspenseComponent:
+ popSuspenseContext(interruptedWork);
+ break;
+
+ case SuspenseListComponent:
+ popSuspenseContext(interruptedWork);
+ break;
+
+ case ContextProvider:
+ popProvider(interruptedWork);
+ break;
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent:
+ popRenderLanes(interruptedWork);
+ break;
+ }
+}
+
+function createCapturedValue(value, source) {
+ // If the value is an error, call this function immediately after it is thrown
+ // so the stack is accurate.
+ return {
+ value: value,
+ source: source,
+ stack: getStackByFiberInDevAndProd(source)
+ };
+}
+
+if (
+ !(
+ typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog ===
+ "function"
+ )
+) {
+ throw Error(
+ "Expected ReactFiberErrorDialog.showErrorDialog to be a function."
+ );
+}
+
+function showErrorDialog(boundary, errorInfo) {
+ var capturedError = {
+ componentStack: errorInfo.stack !== null ? errorInfo.stack : "",
+ error: errorInfo.value,
+ errorBoundary:
+ boundary !== null && boundary.tag === ClassComponent
+ ? boundary.stateNode
+ : null
+ };
+ return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
+ capturedError
+ );
+}
+
+function logCapturedError(boundary, errorInfo) {
+ try {
+ var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging.
+ // This enables renderers like ReactNative to better manage redbox behavior.
+
+ if (logError === false) {
+ return;
+ }
+
+ var error = errorInfo.value;
+
+ if (true) {
+ var source = errorInfo.source;
+ var stack = errorInfo.stack;
+ var componentStack = stack !== null ? stack : ""; // Browsers support silencing uncaught errors by calling
+ // `preventDefault()` in window `error` handler.
+ // We record this information as an expando on the error.
+
+ if (error != null && error._suppressLogging) {
+ if (boundary.tag === ClassComponent) {
+ // The error is recoverable and was silenced.
+ // Ignore it and don't print the stack addendum.
+ // This is handy for testing error boundaries without noise.
+ return;
+ } // The error is fatal. Since the silencing might have
+ // been accidental, we'll surface it anyway.
+ // However, the browser would have silenced the original error
+ // so we'll print it first, and then print the stack addendum.
+
+ console["error"](error); // Don't transform to our wrapper
+ // For a more detailed description of this block, see:
+ // https://github.com/facebook/react/pull/13384
+ }
+
+ var componentName = source ? getComponentName(source.type) : null;
+ var componentNameMessage = componentName
+ ? "The above error occurred in the <" + componentName + "> component:"
+ : "The above error occurred in one of your React components:";
+ var errorBoundaryMessage;
+ var errorBoundaryName = getComponentName(boundary.type);
+
+ if (errorBoundaryName) {
+ errorBoundaryMessage =
+ "React will try to recreate this component tree from scratch " +
+ ("using the error boundary you provided, " + errorBoundaryName + ".");
+ } else {
+ errorBoundaryMessage =
+ "Consider adding an error boundary to your tree to customize error handling behavior.\n" +
+ "Visit https://fb.me/react-error-boundaries to learn more about error boundaries.";
+ }
+
+ var combinedMessage =
+ componentNameMessage +
+ "\n" +
+ componentStack +
+ "\n\n" +
+ ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
+ // We don't include the original error message and JS stack because the browser
+ // has already printed it. Even if the application swallows the error, it is still
+ // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
+
+ console["error"](combinedMessage); // Don't transform to our wrapper
+ } else {
+ // In production, we print the error directly.
+ // This will include the message, the JS stack, and anything the browser wants to show.
+ // We pass the error object instead of custom message so that the browser displays the error natively.
+ console["error"](error); // Don't transform to our wrapper
+ }
+ } catch (e) {
+ // This method must not throw, or React internal state will get messed up.
+ // If console.error is overridden, or logCapturedError() shows a dialog that throws,
+ // we want to report this error outside of the normal stack as a last resort.
+ // https://github.com/facebook/react/issues/13188
+ setTimeout(function() {
+ throw e;
+ });
+ }
+}
+
+var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map;
+
+function createRootErrorUpdate(fiber, errorInfo, lane) {
+ var update = createUpdate(NoTimestamp, lane, null); // Unmount the root by rendering null.
+
+ update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
+ // being called "element".
+
+ update.payload = {
+ element: null
+ };
+ var error = errorInfo.value;
+
+ update.callback = function() {
+ onUncaughtError(error);
+ logCapturedError(fiber, errorInfo);
+ };
+
+ return update;
+}
+
+function createClassErrorUpdate(fiber, errorInfo, lane) {
+ var update = createUpdate(NoTimestamp, lane, null);
+ update.tag = CaptureUpdate;
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+
+ if (typeof getDerivedStateFromError === "function") {
+ var error$1 = errorInfo.value;
+
+ update.payload = function() {
+ logCapturedError(fiber, errorInfo);
+ return getDerivedStateFromError(error$1);
+ };
+ }
+
+ var inst = fiber.stateNode;
+
+ if (inst !== null && typeof inst.componentDidCatch === "function") {
+ update.callback = function callback() {
+ {
+ markFailedErrorBoundaryForHotReloading(fiber);
+ }
+
+ if (typeof getDerivedStateFromError !== "function") {
+ // To preserve the preexisting retry behavior of error boundaries,
+ // we keep track of which ones already failed during this batch.
+ // This gets reset before we yield back to the browser.
+ // TODO: Warn in strict mode if getDerivedStateFromError is
+ // not defined.
+ markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
+
+ logCapturedError(fiber, errorInfo);
+ }
+
+ var error$1 = errorInfo.value;
+ var stack = errorInfo.stack;
+ this.componentDidCatch(error$1, {
+ componentStack: stack !== null ? stack : ""
+ });
+
+ {
+ if (typeof getDerivedStateFromError !== "function") {
+ // If componentDidCatch is the only error boundary method defined,
+ // then it needs to call setState to recover from errors.
+ // If no state update is scheduled then the boundary will swallow the error.
+ if (!includesSomeLane(fiber.lanes, SyncLane)) {
+ error(
+ "%s: Error boundaries should implement getDerivedStateFromError(). " +
+ "In that method, return a state update to display an error message or fallback UI.",
+ getComponentName(fiber.type) || "Unknown"
+ );
+ }
+ }
+ }
+ };
+ } else {
+ update.callback = function() {
+ markFailedErrorBoundaryForHotReloading(fiber);
+ };
+ }
+
+ return update;
+}
+
+function attachPingListener(root, wakeable, lanes) {
+ // Attach a listener to the promise to "ping" the root and retry. But only if
+ // one does not already exist for the lanes we're currently rendering (which
+ // acts like a "thread ID" here).
+ var pingCache = root.pingCache;
+ var threadIDs;
+
+ if (pingCache === null) {
+ pingCache = root.pingCache = new PossiblyWeakMap$1();
+ threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
+ } else {
+ threadIDs = pingCache.get(wakeable);
- case ContextProvider:
- popProvider(workInProgress);
- return null;
+ if (threadIDs === undefined) {
+ threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
+ }
+ }
- default:
- return null;
+ if (!threadIDs.has(lanes)) {
+ // Memoize using the thread ID to prevent redundant listeners.
+ threadIDs.add(lanes);
+ var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes);
+ wakeable.then(ping, ping);
}
}
-function unwindInterruptedWork(interruptedWork) {
- switch (interruptedWork.tag) {
- case ClassComponent: {
- var childContextTypes = interruptedWork.type.childContextTypes;
+function throwException(
+ root,
+ returnFiber,
+ sourceFiber,
+ value,
+ rootRenderLanes
+) {
+ // The source fiber did not complete.
+ sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
- if (childContextTypes !== null && childContextTypes !== undefined) {
- popContext(interruptedWork);
- }
+ sourceFiber.firstEffect = sourceFiber.lastEffect = null;
- break;
- }
+ if (
+ value !== null &&
+ typeof value === "object" &&
+ typeof value.then === "function"
+ ) {
+ // This is a wakeable.
+ var wakeable = value;
- case HostRoot: {
- popHostContainer(interruptedWork);
- popTopLevelContextObject(interruptedWork);
- break;
- }
+ if ((sourceFiber.mode & BlockingMode) === NoMode) {
+ // Reset the memoizedState to what it was before we attempted
+ // to render it.
+ var currentSource = sourceFiber.alternate;
- case HostComponent: {
- popHostContext(interruptedWork);
- break;
+ if (currentSource) {
+ sourceFiber.updateQueue = currentSource.updateQueue;
+ sourceFiber.memoizedState = currentSource.memoizedState;
+ sourceFiber.lanes = currentSource.lanes;
+ } else {
+ sourceFiber.updateQueue = null;
+ sourceFiber.memoizedState = null;
+ }
}
- case HostPortal:
- popHostContainer(interruptedWork);
- break;
-
- case SuspenseComponent:
- popSuspenseContext(interruptedWork);
- break;
+ var hasInvisibleParentBoundary = hasSuspenseContext(
+ suspenseStackCursor.current,
+ InvisibleParentSuspenseContext
+ ); // Schedule the nearest Suspense to re-render the timed out view.
- case SuspenseListComponent:
- popSuspenseContext(interruptedWork);
- break;
+ var _workInProgress = returnFiber;
- case ContextProvider:
- popProvider(interruptedWork);
- break;
- }
-}
+ do {
+ if (
+ _workInProgress.tag === SuspenseComponent &&
+ shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)
+ ) {
+ // Found the nearest boundary.
+ // Stash the promise on the boundary fiber. If the boundary times out, we'll
+ // attach another listener to flip the boundary back to its normal state.
+ var wakeables = _workInProgress.updateQueue;
-function createCapturedValue(value, source) {
- // If the value is an error, call this function immediately after it is thrown
- // so the stack is accurate.
- return {
- value: value,
- source: source,
- stack: getStackByFiberInDevAndProd(source)
- };
-}
+ if (wakeables === null) {
+ var updateQueue = new Set();
+ updateQueue.add(wakeable);
+ _workInProgress.updateQueue = updateQueue;
+ } else {
+ wakeables.add(wakeable);
+ } // If the boundary is outside of blocking mode, we should *not*
+ // suspend the commit. Pretend as if the suspended component rendered
+ // null and keep rendering. In the commit phase, we'll schedule a
+ // subsequent synchronous update to re-render the Suspense.
+ //
+ // Note: It doesn't matter whether the component that suspended was
+ // inside a blocking mode tree. If the Suspense is outside of it, we
+ // should *not* suspend the commit.
-// Module provided by RN:
+ if ((_workInProgress.mode & BlockingMode) === NoMode) {
+ _workInProgress.effectTag |= DidCapture;
+ sourceFiber.effectTag |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete.
+ // But we shouldn't call any lifecycle methods or callbacks. Remove
+ // all lifecycle effect tags.
-if (
- !(
- typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog ===
- "function"
- )
-) {
- throw Error(
- "Expected ReactFiberErrorDialog.showErrorDialog to be a function."
- );
-}
+ sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
-function showErrorDialog(capturedError) {
- return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
- capturedError
- );
-}
+ if (sourceFiber.tag === ClassComponent) {
+ var currentSourceFiber = sourceFiber.alternate;
-function logCapturedError(capturedError) {
- var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging.
- // This enables renderers like ReactNative to better manage redbox behavior.
+ if (currentSourceFiber === null) {
+ // This is a new mount. Change the tag so it's not mistaken for a
+ // completed class component. For example, we should not call
+ // componentWillUnmount if it is deleted.
+ sourceFiber.tag = IncompleteClassComponent;
+ } else {
+ // When we try rendering again, we should not reuse the current fiber,
+ // since it's known to be in an inconsistent state. Use a force update to
+ // prevent a bail out.
+ var update = createUpdate(NoTimestamp, SyncLane, null);
+ update.tag = ForceUpdate;
+ enqueueUpdate(sourceFiber, update);
+ }
+ } // The source fiber did not complete. Mark it with Sync priority to
+ // indicate that it still has pending work.
- if (logError === false) {
- return;
- }
+ sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending.
- var error = capturedError.error;
+ return;
+ } // Confirmed that the boundary is in a concurrent mode tree. Continue
+ // with the normal suspend path.
+ //
+ // After this we'll use a set of heuristics to determine whether this
+ // render pass will run to completion or restart or "suspend" the commit.
+ // The actual logic for this is spread out in different places.
+ //
+ // This first principle is that if we're going to suspend when we complete
+ // a root, then we should also restart if we get an update or ping that
+ // might unsuspend it, and vice versa. The only reason to suspend is
+ // because you think you might want to restart before committing. However,
+ // it doesn't make sense to restart only while in the period we're suspended.
+ //
+ // Restarting too aggressively is also not good because it starves out any
+ // intermediate loading state. So we use heuristics to determine when.
+ // Suspense Heuristics
+ //
+ // If nothing threw a Promise or all the same fallbacks are already showing,
+ // then don't suspend/restart.
+ //
+ // If this is an initial render of a new tree of Suspense boundaries and
+ // those trigger a fallback, then don't suspend/restart. We want to ensure
+ // that we can show the initial loading state as quickly as possible.
+ //
+ // If we hit a "Delayed" case, such as when we'd switch from content back into
+ // a fallback, then we should always suspend/restart. SuspenseConfig applies to
+ // this case. If none is defined, JND is used instead.
+ //
+ // If we're already showing a fallback and it gets "retried", allowing us to show
+ // another level, but there's still an inner boundary that would show a fallback,
+ // then we suspend/restart for 500ms since the last time we showed a fallback
+ // anywhere in the tree. This effectively throttles progressive loading into a
+ // consistent train of commits. This also gives us an opportunity to restart to
+ // get to the completed state slightly earlier.
+ //
+ // If there's ambiguity due to batching it's resolved in preference of:
+ // 1) "delayed", 2) "initial render", 3) "retry".
+ //
+ // We want to ensure that a "busy" state doesn't get force committed. We want to
+ // ensure that new initial loading states can commit as soon as possible.
- {
- var componentName = capturedError.componentName,
- componentStack = capturedError.componentStack,
- errorBoundaryName = capturedError.errorBoundaryName,
- errorBoundaryFound = capturedError.errorBoundaryFound,
- willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
- // `preventDefault()` in window `error` handler.
- // We record this information as an expando on the error.
-
- if (error != null && error._suppressLogging) {
- if (errorBoundaryFound && willRetry) {
- // The error is recoverable and was silenced.
- // Ignore it and don't print the stack addendum.
- // This is handy for testing error boundaries without noise.
+ attachPingListener(root, wakeable, rootRenderLanes);
+ _workInProgress.effectTag |= ShouldCapture;
+ _workInProgress.lanes = rootRenderLanes;
return;
- } // The error is fatal. Since the silencing might have
- // been accidental, we'll surface it anyway.
- // However, the browser would have silenced the original error
- // so we'll print it first, and then print the stack addendum.
+ } // This boundary already captured during this render. Continue to the next
+ // boundary.
- console["error"](error); // Don't transform to our wrapper
- // For a more detailed description of this block, see:
- // https://github.com/facebook/react/pull/13384
- }
+ _workInProgress = _workInProgress.return;
+ } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
+ // TODO: Use invariant so the message is stripped in prod?
- var componentNameMessage = componentName
- ? "The above error occurred in the <" + componentName + "> component:"
- : "The above error occurred in one of your React components:";
- var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
+ value = new Error(
+ (getComponentName(sourceFiber.type) || "A React component") +
+ " suspended while rendering, but no fallback UI was specified.\n" +
+ "\n" +
+ "Add a component higher in the tree to " +
+ "provide a loading indicator or placeholder to display."
+ );
+ } // We didn't find a boundary that could handle this type of exception. Start
+ // over and traverse parent path again, this time treating the exception
+ // as an error.
- if (errorBoundaryFound && errorBoundaryName) {
- if (willRetry) {
- errorBoundaryMessage =
- "React will try to recreate this component tree from scratch " +
- ("using the error boundary you provided, " + errorBoundaryName + ".");
- } else {
- errorBoundaryMessage =
- "This error was initially handled by the error boundary " +
- errorBoundaryName +
- ".\n" +
- "Recreating the tree from scratch failed so React will unmount the tree.";
+ renderDidError();
+ value = createCapturedValue(value, sourceFiber);
+ var workInProgress = returnFiber;
+
+ do {
+ switch (workInProgress.tag) {
+ case HostRoot: {
+ var _errorInfo = value;
+ workInProgress.effectTag |= ShouldCapture;
+ var lane = pickArbitraryLane(rootRenderLanes);
+ workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
+
+ var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
+
+ enqueueCapturedUpdate(workInProgress, _update);
+ return;
}
- } else {
- errorBoundaryMessage =
- "Consider adding an error boundary to your tree to customize error handling behavior.\n" +
- "Visit https://fb.me/react-error-boundaries to learn more about error boundaries.";
- }
- var combinedMessage =
- "" +
- componentNameMessage +
- componentStack +
- "\n\n" +
- ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
- // We don't include the original error message and JS stack because the browser
- // has already printed it. Even if the application swallows the error, it is still
- // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
+ case ClassComponent:
+ // Capture and retry
+ var errorInfo = value;
+ var ctor = workInProgress.type;
+ var instance = workInProgress.stateNode;
+
+ if (
+ (workInProgress.effectTag & DidCapture) === NoEffect &&
+ (typeof ctor.getDerivedStateFromError === "function" ||
+ (instance !== null &&
+ typeof instance.componentDidCatch === "function" &&
+ !isAlreadyFailedLegacyErrorBoundary(instance)))
+ ) {
+ workInProgress.effectTag |= ShouldCapture;
- console["error"](combinedMessage); // Don't transform to our wrapper
- }
-}
+ var _lane = pickArbitraryLane(rootRenderLanes);
-var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
+ workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state
-{
- didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
-}
+ var _update2 = createClassErrorUpdate(
+ workInProgress,
+ errorInfo,
+ _lane
+ );
-var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set;
-function logError(boundary, errorInfo) {
- var source = errorInfo.source;
- var stack = errorInfo.stack;
+ enqueueCapturedUpdate(workInProgress, _update2);
+ return;
+ }
- if (stack === null && source !== null) {
- stack = getStackByFiberInDevAndProd(source);
- }
+ break;
+ }
- var capturedError = {
- componentName: source !== null ? getComponentName(source.type) : null,
- componentStack: stack !== null ? stack : "",
- error: errorInfo.value,
- errorBoundary: null,
- errorBoundaryName: null,
- errorBoundaryFound: false,
- willRetry: false
- };
+ workInProgress = workInProgress.return;
+ } while (workInProgress !== null);
+}
- if (boundary !== null && boundary.tag === ClassComponent) {
- capturedError.errorBoundary = boundary.stateNode;
- capturedError.errorBoundaryName = getComponentName(boundary.type);
- capturedError.errorBoundaryFound = true;
- capturedError.willRetry = true;
- }
+var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
- try {
- logCapturedError(capturedError);
- } catch (e) {
- // This method must not throw, or React internal state will get messed up.
- // If console.error is overridden, or logCapturedError() shows a dialog that throws,
- // we want to report this error outside of the normal stack as a last resort.
- // https://github.com/facebook/react/issues/13188
- setTimeout(function() {
- throw e;
- });
- }
+{
+ didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
}
+var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set;
+
var callComponentWillUnmountWithTimer = function(current, instance) {
- startPhaseTimer(current, "componentWillUnmount");
instance.props = current.memoizedProps;
instance.state = current.memoizedState;
{
instance.componentWillUnmount();
}
-
- stopPhaseTimer();
}; // Capture errors so they don't interrupt unmounting.
function safelyCallComponentWillUnmount(current, instance) {
@@ -15518,7 +16579,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
if (current !== null) {
var prevProps = current.memoizedProps;
var prevState = current.memoizedState;
- startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate");
var instance = finishedWork.stateNode; // We could update instance props and state here,
// but instead we rely on them being set during last render.
// TODO: revisit this when we implement resuming.
@@ -15574,14 +16634,23 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
}
instance.__reactInternalSnapshotBeforeUpdate = snapshot;
- stopPhaseTimer();
}
}
return;
}
- case HostRoot:
+ case HostRoot: {
+ {
+ if (finishedWork.effectTag & Snapshot) {
+ var root = finishedWork.stateNode;
+ clearContainer(root.containerInfo);
+ }
+ }
+
+ return;
+ }
+
case HostComponent:
case HostText:
case HostPortal:
@@ -15665,9 +16734,8 @@ function commitHookEffectListMount(tag, finishedWork) {
error(
"An effect function must not return anything besides a function, " +
- "which is used for clean-up.%s%s",
- addendum,
- getStackByFiberInDevAndProd(finishedWork)
+ "which is used for clean-up.%s",
+ addendum
);
}
}
@@ -15678,33 +16746,33 @@ function commitHookEffectListMount(tag, finishedWork) {
}
}
-function commitPassiveHookEffects(finishedWork) {
- if ((finishedWork.effectTag & Passive) !== NoEffect) {
- switch (finishedWork.tag) {
- case FunctionComponent:
- case ForwardRef:
- case SimpleMemoComponent:
- case Block: {
- // TODO (#17945) We should call all passive destroy functions (for all fibers)
- // before calling any create functions. The current approach only serializes
- // these for a single fiber.
- {
- commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork);
- commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
- }
+function schedulePassiveEffects(finishedWork) {
+ var updateQueue = finishedWork.updateQueue;
+ var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
- break;
+ if (lastEffect !== null) {
+ var firstEffect = lastEffect.next;
+ var effect = firstEffect;
+
+ do {
+ var _effect = effect,
+ next = _effect.next,
+ tag = _effect.tag;
+
+ if (
+ (tag & Passive$1) !== NoEffect$1 &&
+ (tag & HasEffect) !== NoEffect$1
+ ) {
+ enqueuePendingPassiveHookEffectUnmount(finishedWork, effect);
+ enqueuePendingPassiveHookEffectMount(finishedWork, effect);
}
- }
+
+ effect = next;
+ } while (effect !== firstEffect);
}
}
-function commitLifeCycles(
- finishedRoot,
- current,
- finishedWork,
- committedExpirationTime
-) {
+function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) {
switch (finishedWork.tag) {
case FunctionComponent:
case ForwardRef:
@@ -15718,6 +16786,7 @@ function commitLifeCycles(
commitHookEffectListMount(Layout | HasEffect, finishedWork);
}
+ schedulePassiveEffects(finishedWork);
return;
}
@@ -15726,10 +16795,9 @@ function commitLifeCycles(
if (finishedWork.effectTag & Update) {
if (current === null) {
- startPhaseTimer(finishedWork, "componentDidMount"); // We could update instance props and state here,
+ // We could update instance props and state here,
// but instead we rely on them being set during last render.
// TODO: revisit this when we implement resuming.
-
{
if (
finishedWork.type === finishedWork.elementType &&
@@ -15762,15 +16830,12 @@ function commitLifeCycles(
{
instance.componentDidMount();
}
-
- stopPhaseTimer();
} else {
var prevProps =
finishedWork.elementType === finishedWork.type
? current.memoizedProps
: resolveDefaultProps(finishedWork.type, current.memoizedProps);
- var prevState = current.memoizedState;
- startPhaseTimer(finishedWork, "componentDidUpdate"); // We could update instance props and state here,
+ var prevState = current.memoizedState; // We could update instance props and state here,
// but instead we rely on them being set during last render.
// TODO: revisit this when we implement resuming.
@@ -15810,10 +16875,9 @@ function commitLifeCycles(
instance.__reactInternalSnapshotBeforeUpdate
);
}
-
- stopPhaseTimer();
}
- }
+ } // TODO: I think this is now always non-null by the time it reaches the
+ // commit phase. Consider removing the type check.
var updateQueue = finishedWork.updateQueue;
@@ -15856,6 +16920,8 @@ function commitLifeCycles(
}
case HostRoot: {
+ // TODO: I think this is now always non-null by the time it reaches the
+ // commit phase. Consider removing the type check.
var _updateQueue = finishedWork.updateQueue;
if (_updateQueue !== null) {
@@ -15937,6 +17003,8 @@ function commitLifeCycles(
case IncompleteClassComponent:
case FundamentalComponent:
case ScopeComponent:
+ case OffscreenComponent:
+ case LegacyHiddenComponent:
return;
}
@@ -15971,17 +17039,12 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) {
unhideTextInstance(_instance3, node.memoizedProps);
}
} else if (
- node.tag === SuspenseComponent &&
+ (node.tag === OffscreenComponent ||
+ node.tag === LegacyHiddenComponent) &&
node.memoizedState !== null &&
- node.memoizedState.dehydrated === null
- ) {
- // Found a nested Suspense component that timed out. Skip over the
- // primary child fragment, which should remain hidden.
- var fallbackChildFragment = node.child.sibling;
- fallbackChildFragment.return = node;
- node = fallbackChildFragment;
- continue;
- } else if (node.child !== null) {
+ node !== finishedWork
+ );
+ else if (node.child !== null) {
node.child.return = node;
node = node.child;
continue;
@@ -16028,9 +17091,8 @@ function commitAttachRef(finishedWork) {
if (!ref.hasOwnProperty("current")) {
error(
"Unexpected ref object provided for %s. " +
- "Use either a ref-setter function or React.createRef().%s",
- getComponentName(finishedWork.type),
- getStackByFiberInDevAndProd(finishedWork)
+ "Use either a ref-setter function or React.createRef().",
+ getComponentName(finishedWork.type)
);
}
}
@@ -16070,42 +17132,25 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) {
if (lastEffect !== null) {
var firstEffect = lastEffect.next;
+ var effect = firstEffect;
- {
- // When the owner fiber is deleted, the destroy function of a passive
- // effect hook is called during the synchronous commit phase. This is
- // a concession to implementation complexity. Calling it in the
- // passive effect phase (like they usually are, when dependencies
- // change during an update) would require either traversing the
- // children of the deleted fiber again, or including unmount effects
- // as part of the fiber effect list.
- //
- // Because this is during the sync commit phase, we need to change
- // the priority.
- //
- // TODO: Reconsider this implementation trade off.
- var priorityLevel =
- renderPriorityLevel > NormalPriority
- ? NormalPriority
- : renderPriorityLevel;
- runWithPriority(priorityLevel, function() {
- var effect = firstEffect;
-
- do {
- var _effect3 = effect,
- _destroy = _effect3.destroy,
- _tag = _effect3.tag;
-
- if (_destroy !== undefined) {
- {
- safelyCallDestroy(current, _destroy);
- }
+ do {
+ var _effect2 = effect,
+ destroy = _effect2.destroy,
+ tag = _effect2.tag;
+
+ if (destroy !== undefined) {
+ if ((tag & Passive$1) !== NoEffect$1) {
+ enqueuePendingPassiveHookEffectUnmount(current, effect);
+ } else {
+ {
+ safelyCallDestroy(current, destroy);
}
+ }
+ }
- effect = effect.next;
- } while (effect !== firstEffect);
- });
- }
+ effect = effect.next;
+ } while (effect !== firstEffect);
}
}
@@ -16133,7 +17178,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) {
// We are also not using this parent because
// the portal will get pushed immediately.
{
- unmountHostComponents(finishedRoot, current, renderPriorityLevel);
+ unmountHostComponents(finishedRoot, current);
}
return;
@@ -16162,7 +17207,7 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
var node = root;
while (true) {
- commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes.
+ commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes.
// Skip portals because commitUnmount() currently visits them recursively.
if (
@@ -16192,27 +17237,30 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
}
}
-function detachFiber(current) {
- var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we
+function detachFiberMutation(fiber) {
+ // Cut off the return pointers to disconnect it from the tree. Ideally, we
// should clear the child pointer of the parent alternate to let this
// get GC:ed but we don't know which for sure which parent is the current
// one so we'll settle for GC:ing the subtree of this child. This child
// itself will be GC:ed when the parent updates the next time.
+ // Note: we cannot null out sibling here, otherwise it can cause issues
+ // with findDOMNode and how it requires the sibling field to carry out
+ // traversal in a later effect. See PR #16820. We now clear the sibling
+ // field after effects, see: detachFiberAfterEffects.
+ fiber.alternate = null;
+ fiber.child = null;
+ fiber.dependencies = null;
+ fiber.firstEffect = null;
+ fiber.lastEffect = null;
+ fiber.memoizedProps = null;
+ fiber.memoizedState = null;
+ fiber.pendingProps = null;
+ fiber.return = null;
+ fiber.stateNode = null;
+ fiber.updateQueue = null;
- current.return = null;
- current.child = null;
- current.memoizedState = null;
- current.updateQueue = null;
- current.dependencies = null;
- current.alternate = null;
- current.firstEffect = null;
- current.lastEffect = null;
- current.pendingProps = null;
- current.memoizedProps = null;
- current.stateNode = null;
-
- if (alternate !== null) {
- detachFiber(alternate);
+ {
+ fiber._debugOwner = null;
}
}
@@ -16444,7 +17492,7 @@ function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
}
if (node.tag === HostComponent || node.tag === HostText) {
- commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
+ commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the
// node from the tree.
if (currentParentIsContainer) {
@@ -16464,7 +17512,7 @@ function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
continue;
}
} else {
- commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below.
+ commitUnmount(finishedRoot, node); // Visit children because we may find more host components below.
if (node.child !== null) {
node.child.return = node;
@@ -16500,10 +17548,15 @@ function commitDeletion(finishedRoot, current, renderPriorityLevel) {
{
// Recursively delete all host nodes from the parent.
// Detach refs and call componentWillUnmount() on the whole subtree.
- unmountHostComponents(finishedRoot, current, renderPriorityLevel);
+ unmountHostComponents(finishedRoot, current);
}
- detachFiber(current);
+ var alternate = current.alternate;
+ detachFiberMutation(current);
+
+ if (alternate !== null) {
+ detachFiberMutation(alternate);
+ }
}
function commitWork(current, finishedWork) {
@@ -16591,6 +17644,22 @@ function commitWork(current, finishedWork) {
case IncompleteClassComponent: {
return;
}
+
+ case FundamentalComponent: {
+ break;
+ }
+
+ case ScopeComponent: {
+ break;
+ }
+
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ var newState = finishedWork.memoizedState;
+ var isHidden = newState !== null;
+ hideOrUnhideAllChildren(finishedWork, isHidden);
+ return;
+ }
}
{
@@ -16602,29 +17671,33 @@ function commitWork(current, finishedWork) {
function commitSuspenseComponent(finishedWork) {
var newState = finishedWork.memoizedState;
- var newDidTimeout;
- var primaryChildParent = finishedWork;
- if (newState === null) {
- newDidTimeout = false;
- } else {
- newDidTimeout = true;
- primaryChildParent = finishedWork.child;
+ if (newState !== null) {
markCommitTimeOfFallback();
- }
- if (primaryChildParent !== null) {
- hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
+ {
+ // Hide the Offscreen component that contains the primary children. TODO:
+ // Ideally, this effect would have been scheduled on the Offscreen fiber
+ // itself. That's how unhiding works: the Offscreen component schedules an
+ // effect on itself. However, in this case, the component didn't complete,
+ // so the fiber was never added to the effect list in the normal path. We
+ // could have appended it to the effect list in the Suspense component's
+ // second pass, but doing it this way is less complicated. This would be
+ // simpler if we got rid of the effect list and traversed the tree, like
+ // we're planning to do.
+ var primaryChildParent = finishedWork.child;
+ hideOrUnhideAllChildren(primaryChildParent, true);
+ }
}
}
function attachSuspenseRetryListeners(finishedWork) {
- // If this boundary just timed out, then it will have a set of thenables.
- // For each thenable, attach a listener so that when it resolves, React
+ // If this boundary just timed out, then it will have a set of wakeables.
+ // For each wakeable, attach a listener so that when it resolves, React
// attempts to re-render the boundary in the primary (pre-timeout) state.
- var thenables = finishedWork.updateQueue;
+ var wakeables = finishedWork.updateQueue;
- if (thenables !== null) {
+ if (wakeables !== null) {
finishedWork.updateQueue = null;
var retryCache = finishedWork.stateNode;
@@ -16632,3080 +17705,3324 @@ function attachSuspenseRetryListeners(finishedWork) {
retryCache = finishedWork.stateNode = new PossiblyWeakSet();
}
- thenables.forEach(function(thenable) {
+ wakeables.forEach(function(wakeable) {
// Memoize using the boundary fiber to prevent redundant listeners.
- var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
+ var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
- if (!retryCache.has(thenable)) {
+ if (!retryCache.has(wakeable)) {
{
- if (thenable.__reactDoNotTraceInteractions !== true) {
+ if (wakeable.__reactDoNotTraceInteractions !== true) {
retry = tracing.unstable_wrap(retry);
}
}
- retryCache.add(thenable);
- thenable.then(retry, retry);
+ retryCache.add(wakeable);
+ wakeable.then(retry, retry);
}
});
}
+} // This function detects when a Suspense boundary goes from visible to hidden.
+// It returns false if the boundary is already hidden.
+// TODO: Use an effect tag.
+
+function isSuspenseBoundaryBeingHidden(current, finishedWork) {
+ if (current !== null) {
+ var oldState = current.memoizedState;
+
+ if (oldState === null || oldState.dehydrated !== null) {
+ var newState = finishedWork.memoizedState;
+ return newState !== null && newState.dehydrated === null;
+ }
+ }
+
+ return false;
}
function commitResetTextContent(current) {
resetTextContent(current.stateNode);
}
-var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
+var COMPONENT_TYPE = 0;
+var HAS_PSEUDO_CLASS_TYPE = 1;
+var ROLE_TYPE = 2;
+var TEST_NAME_TYPE = 3;
+var TEXT_TYPE = 4;
-function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
- var update = createUpdate(expirationTime, null); // Unmount the root by rendering null.
+if (typeof Symbol === "function" && Symbol.for) {
+ var symbolFor$1 = Symbol.for;
+ COMPONENT_TYPE = symbolFor$1("selector.component");
+ HAS_PSEUDO_CLASS_TYPE = symbolFor$1("selector.has_pseudo_class");
+ ROLE_TYPE = symbolFor$1("selector.role");
+ TEST_NAME_TYPE = symbolFor$1("selector.test_id");
+ TEXT_TYPE = symbolFor$1("selector.text");
+}
- update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
- // being called "element".
+var ceil = Math.ceil;
+var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
+ ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
+ IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
+var NoContext =
+ /* */
+ 0;
+var BatchedContext =
+ /* */
+ 1;
+var DiscreteEventContext =
+ /* */
+ 4;
+var LegacyUnbatchedContext =
+ /* */
+ 8;
+var RenderContext =
+ /* */
+ 16;
+var CommitContext =
+ /* */
+ 32;
+var RetryAfterError =
+ /* */
+ 64;
+var RootIncomplete = 0;
+var RootFatalErrored = 1;
+var RootErrored = 2;
+var RootSuspended = 3;
+var RootSuspendedWithDelay = 4;
+var RootCompleted = 5; // Describes where we are in the React execution stack
- update.payload = {
- element: null
- };
- var error = errorInfo.value;
+var executionContext = NoContext; // The root we're working on
- update.callback = function() {
- onUncaughtError(error);
- logError(fiber, errorInfo);
- };
+var workInProgressRoot = null; // The fiber we're working on
- return update;
+var workInProgress = null; // The lanes we're rendering
+
+var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree
+// This is a superset of the lanes we started working on at the root. The only
+// case where it's different from `workInProgressRootRenderLanes` is when we
+// enter a subtree that is hidden and needs to be unhidden: Suspense and
+// Offscreen component.
+//
+// Most things in the work loop should deal with workInProgressRootRenderLanes.
+// Most things in begin/complete phases should deal with subtreeRenderLanes.
+
+var subtreeRenderLanes = NoLanes;
+var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc.
+
+var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
+
+var workInProgressRootFatalError = null;
+var workInProgressRootLatestSuspenseTimeout = NoTimestamp;
+var workInProgressRootCanSuspendUsingConfig = null; // "Included" lanes refer to lanes that were worked on during this render. It's
+// slightly different than `renderLanes` because `renderLanes` can change as you
+// enter and exit an Offscreen tree. This value is the combination of all render
+// lanes for the entire render phase.
+
+var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only
+// includes unprocessed updates, not work in bailed out children.
+
+var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render.
+
+var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render.
+
+var workInProgressRootPingedLanes = NoLanes;
+var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train
+// model where we don't commit new loading states in too quick succession.
+
+var globalMostRecentFallbackTime = 0;
+var FALLBACK_THROTTLE_MS = 500;
+var DEFAULT_TIMEOUT_MS = 5000;
+var nextEffect = null;
+var hasUncaughtError = false;
+var firstUncaughtError = null;
+var legacyErrorBoundariesThatAlreadyFailed = null;
+var rootDoesHavePassiveEffects = false;
+var rootWithPendingPassiveEffects = null;
+var pendingPassiveEffectsRenderPriority = NoPriority$1;
+var pendingPassiveEffectsLanes = NoLanes;
+var pendingPassiveHookEffectsMount = [];
+var pendingPassiveHookEffectsUnmount = [];
+var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
+
+var NESTED_UPDATE_LIMIT = 50;
+var nestedUpdateCount = 0;
+var rootWithNestedUpdates = null;
+var NESTED_PASSIVE_UPDATE_LIMIT = 50;
+var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes
+// during the commit phase. This enables them to be traced across components
+// that spawn new work during render. E.g. hidden boundaries, suspended SSR
+// hydration or SuspenseList.
+// TODO: Can use a bitmask instead of an array
+
+var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their
+// event times as simultaneous, even if the actual clock time has advanced
+// between the first and second call.
+
+var currentEventTime = NoTimestamp;
+var currentEventWipLanes = NoLanes;
+var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed.
+// We warn about state updates for unmounted components differently in this case.
+
+var isFlushingPassiveEffects = false;
+var focusedInstanceHandle = null;
+var shouldFireAfterActiveInstanceBlur = false;
+function getWorkInProgressRoot() {
+ return workInProgressRoot;
+}
+function requestEventTime() {
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ // We're inside React, so it's fine to read the actual time.
+ return now();
+ } // We're not inside React, so we may be in the middle of a browser event.
+
+ if (currentEventTime !== NoTimestamp) {
+ // Use the same start time for all updates until we enter React again.
+ return currentEventTime;
+ } // This is the first update since React yielded. Compute a new start time.
+
+ currentEventTime = now();
+ return currentEventTime;
}
+function requestUpdateLane(fiber, suspenseConfig) {
+ // Special cases
+ var mode = fiber.mode;
-function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
- var update = createUpdate(expirationTime, null);
- update.tag = CaptureUpdate;
- var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+ if ((mode & BlockingMode) === NoMode) {
+ return SyncLane;
+ } else if ((mode & ConcurrentMode) === NoMode) {
+ return getCurrentPriorityLevel() === ImmediatePriority$1
+ ? SyncLane
+ : SyncBatchedLane;
+ } // The algorithm for assigning an update to a lane should be stable for all
+ // updates at the same priority within the same event. To do this, the inputs
+ // to the algorithm must be the same. For example, we use the `renderLanes`
+ // to avoid choosing a lane that is already in the middle of rendering.
+ //
+ // However, the "included" lanes could be mutated in between updates in the
+ // same event, like if you perform an update inside `flushSync`. Or any other
+ // code path that might call `prepareFreshStack`.
+ //
+ // The trick we use is to cache the first of each of these inputs within an
+ // event. Then reset the cached values once we can be sure the event is over.
+ // Our heuristic for that is whenever we enter a concurrent work loop.
+ //
+ // We'll do the same for `currentEventPendingLanes` below.
+
+ if (currentEventWipLanes === NoLanes) {
+ currentEventWipLanes = workInProgressRootIncludedLanes;
+ }
+
+ if (suspenseConfig !== null) {
+ // Use the size of the timeout as a heuristic to prioritize shorter
+ // transitions over longer ones.
+ // TODO: This will coerce numbers larger than 31 bits to 0.
+ var timeoutMs = suspenseConfig.timeoutMs;
+ var transitionLanePriority =
+ timeoutMs === undefined || (timeoutMs | 0) < 10000
+ ? TransitionShortLanePriority
+ : TransitionLongLanePriority;
+
+ if (currentEventPendingLanes !== NoLanes) {
+ currentEventPendingLanes =
+ mostRecentlyUpdatedRoot !== null
+ ? mostRecentlyUpdatedRoot.pendingLanes
+ : NoLanes;
+ }
+
+ return findTransitionLane(
+ transitionLanePriority,
+ currentEventWipLanes,
+ currentEventPendingLanes
+ );
+ } // TODO: Remove this dependency on the Scheduler priority.
+ // To do that, we're replacing it with an update lane priority.
+
+ var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler.
+ // This couples React to the Scheduler internals, so we're replacing it
+ // with the currentUpdateLanePriority above. As an example of how this
+ // could be problematic, if we're not inside `Scheduler.runWithPriority`,
+ // then we'll get the priority of the current running Scheduler task,
+ // which is probably not what we want.
+
+ var lane;
+
+ if (
+ // TODO: Temporary. We're removing the concept of discrete updates.
+ (executionContext & DiscreteEventContext) !== NoContext &&
+ schedulerPriority === UserBlockingPriority$1
+ ) {
+ lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes);
+ } else {
+ var schedulerLanePriority = schedulerPriorityToLanePriority(
+ schedulerPriority
+ );
+
+ lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes);
+ }
+
+ return lane;
+}
+
+function requestRetryLane(fiber) {
+ // This is a fork of `requestUpdateLane` designed specifically for Suspense
+ // "retries" — a special update that attempts to flip a Suspense boundary
+ // from its placeholder state to its primary/resolved state.
+ // Special cases
+ var mode = fiber.mode;
+
+ if ((mode & BlockingMode) === NoMode) {
+ return SyncLane;
+ } else if ((mode & ConcurrentMode) === NoMode) {
+ return getCurrentPriorityLevel() === ImmediatePriority$1
+ ? SyncLane
+ : SyncBatchedLane;
+ } // See `requestUpdateLane` for explanation of `currentEventWipLanes`
+
+ if (currentEventWipLanes === NoLanes) {
+ currentEventWipLanes = workInProgressRootIncludedLanes;
+ }
+
+ return findRetryLane(currentEventWipLanes);
+}
+
+function scheduleUpdateOnFiber(fiber, lane, eventTime) {
+ checkForNestedUpdates();
+ warnAboutRenderPhaseUpdatesInDEV(fiber);
+ var root = markUpdateLaneFromFiberToRoot(fiber, lane);
+
+ if (root === null) {
+ warnAboutUpdateOnUnmountedFiberInDEV(fiber);
+ return null;
+ } // Mark that the root has a pending update.
+
+ markRootUpdated(root, lane, eventTime);
+
+ if (root === workInProgressRoot) {
+ // Received an update to a tree that's in the middle of rendering. Mark
+ // that there was an interleaved update work on this root. Unless the
+ // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render
+ // phase update. In that case, we don't treat render phase updates as if
+ // they were interleaved, for backwards compat reasons.
+ {
+ workInProgressRootUpdatedLanes = mergeLanes(
+ workInProgressRootUpdatedLanes,
+ lane
+ );
+ }
+
+ if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
+ // The root already suspended with a delay, which means this render
+ // definitely won't finish. Since we have a new update, let's mark it as
+ // suspended now, right before marking the incoming update. This has the
+ // effect of interrupting the current render and switching to the update.
+ // TODO: Make sure this doesn't override pings that happen while we've
+ // already started rendering.
+ markRootSuspended$1(root, workInProgressRootRenderLanes);
+ }
+ } // TODO: requestUpdateLanePriority also reads the priority. Pass the
+ // priority as an argument to that function and this one.
+
+ var priorityLevel = getCurrentPriorityLevel();
+
+ if (lane === SyncLane) {
+ if (
+ // Check if we're inside unbatchedUpdates
+ (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
+ (executionContext & (RenderContext | CommitContext)) === NoContext
+ ) {
+ // Register pending interactions on the root to avoid losing traced interaction data.
+ schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
+ // root inside of batchedUpdates should be synchronous, but layout updates
+ // should be deferred until the end of the batch.
+
+ performSyncWorkOnRoot(root);
+ } else {
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, lane);
+
+ if (executionContext === NoContext) {
+ // Flush the synchronous work now, unless we're already working or inside
+ // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
+ // scheduleCallbackForFiber to preserve the ability to schedule a callback
+ // without immediately flushing it. We only do this for user-initiated
+ // updates, to preserve historical behavior of legacy mode.
+ flushSyncCallbackQueue();
+ }
+ }
+ } else {
+ // Schedule a discrete update but only if it's not Sync.
+ if (
+ (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered
+ // discrete, even inside a discrete event.
+ (priorityLevel === UserBlockingPriority$1 ||
+ priorityLevel === ImmediatePriority$1)
+ ) {
+ // This is the result of a discrete event. Track the lowest priority
+ // discrete update per root so we can flush them early, if needed.
+ if (rootsWithPendingDiscreteUpdates === null) {
+ rootsWithPendingDiscreteUpdates = new Set([root]);
+ } else {
+ rootsWithPendingDiscreteUpdates.add(root);
+ }
+ } // Schedule other updates after in case the callback is sync.
- if (typeof getDerivedStateFromError === "function") {
- var error$1 = errorInfo.value;
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, lane);
+ } // We use this when assigning a lane for a transition inside
+ // `requestUpdateLane`. We assume it's the same as the root being updated,
+ // since in the common case of a single root app it probably is. If it's not
+ // the same root, then it's not a huge deal, we just might batch more stuff
+ // together more than necessary.
- update.payload = function() {
- logError(fiber, errorInfo);
- return getDerivedStateFromError(error$1);
- };
- }
+ mostRecentlyUpdatedRoot = root;
+} // This is split into a separate function so we can mark a fiber with pending
+// work without treating it as a typical update that originates from an event;
+// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
+// on a fiber.
- var inst = fiber.stateNode;
+function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
+ // Update the source fiber's lanes
+ sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane);
+ var alternate = sourceFiber.alternate;
- if (inst !== null && typeof inst.componentDidCatch === "function") {
- update.callback = function callback() {
- {
- markFailedErrorBoundaryForHotReloading(fiber);
- }
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, lane);
+ }
- if (typeof getDerivedStateFromError !== "function") {
- // To preserve the preexisting retry behavior of error boundaries,
- // we keep track of which ones already failed during this batch.
- // This gets reset before we yield back to the browser.
- // TODO: Warn in strict mode if getDerivedStateFromError is
- // not defined.
- markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
+ {
+ if (
+ alternate === null &&
+ (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect
+ ) {
+ warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
+ }
+ } // Walk the parent path to the root and update the child expiration time.
- logError(fiber, errorInfo);
- }
+ var node = sourceFiber;
+ var parent = sourceFiber.return;
- var error$1 = errorInfo.value;
- var stack = errorInfo.stack;
- this.componentDidCatch(error$1, {
- componentStack: stack !== null ? stack : ""
- });
+ while (parent !== null) {
+ parent.childLanes = mergeLanes(parent.childLanes, lane);
+ alternate = parent.alternate;
+ if (alternate !== null) {
+ alternate.childLanes = mergeLanes(alternate.childLanes, lane);
+ } else {
{
- if (typeof getDerivedStateFromError !== "function") {
- // If componentDidCatch is the only error boundary method defined,
- // then it needs to call setState to recover from errors.
- // If no state update is scheduled then the boundary will swallow the error.
- if (fiber.expirationTime !== Sync) {
- error(
- "%s: Error boundaries should implement getDerivedStateFromError(). " +
- "In that method, return a state update to display an error message or fallback UI.",
- getComponentName(fiber.type) || "Unknown"
- );
- }
+ if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) {
+ warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
}
}
- };
+ }
+
+ node = parent;
+ parent = parent.return;
+ }
+
+ if (node.tag === HostRoot) {
+ var root = node.stateNode;
+ return root;
} else {
- update.callback = function() {
- markFailedErrorBoundaryForHotReloading(fiber);
- };
+ return null;
}
+} // Use this function to schedule a task for a root. There's only one task per
+// root; if a task was already scheduled, we'll check to make sure the priority
+// of the existing task is the same as the priority of the next level that the
+// root has work on. This function is called on every update, and right before
+// exiting a task.
- return update;
-}
+function ensureRootIsScheduled(root, currentTime) {
+ var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as
+ // expired so we know to work on those next.
-function attachPingListener(root, renderExpirationTime, thenable) {
- // Attach a listener to the promise to "ping" the root and retry. But
- // only if one does not already exist for the current render expiration
- // time (which acts like a "thread ID" here).
- var pingCache = root.pingCache;
- var threadIDs;
+ markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority.
- if (pingCache === null) {
- pingCache = root.pingCache = new PossiblyWeakMap();
- threadIDs = new Set();
- pingCache.set(thenable, threadIDs);
- } else {
- threadIDs = pingCache.get(thenable);
+ var nextLanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes
+ ); // This returns the priority level computed during the `getNextLanes` call.
- if (threadIDs === undefined) {
- threadIDs = new Set();
- pingCache.set(thenable, threadIDs);
+ var newCallbackPriority = returnNextLanesPriority();
+
+ if (nextLanes === NoLanes) {
+ // Special case: There's nothing to work on.
+ if (existingCallbackNode !== null) {
+ cancelCallback(existingCallbackNode);
+ root.callbackNode = null;
+ root.callbackPriority = NoLanePriority;
}
- }
- if (!threadIDs.has(renderExpirationTime)) {
- // Memoize using the thread ID to prevent redundant listeners.
- threadIDs.add(renderExpirationTime);
- var ping = pingSuspendedRoot.bind(
- null,
- root,
- thenable,
- renderExpirationTime
+ return;
+ } // Check if there's an existing task. We may be able to reuse it.
+
+ if (existingCallbackNode !== null) {
+ var existingCallbackPriority = root.callbackPriority;
+
+ if (existingCallbackPriority === newCallbackPriority) {
+ // The priority hasn't changed. We can reuse the existing task. Exit.
+ return;
+ } // The priority changed. Cancel the existing callback. We'll schedule a new
+ // one below.
+
+ cancelCallback(existingCallbackNode);
+ } // Schedule a new callback.
+
+ var newCallbackNode;
+
+ if (newCallbackPriority === SyncLanePriority) {
+ // Special case: Sync React callbacks are scheduled on a special
+ // internal queue
+ newCallbackNode = scheduleSyncCallback(
+ performSyncWorkOnRoot.bind(null, root)
+ );
+ } else if (newCallbackPriority === SyncBatchedLanePriority) {
+ newCallbackNode = scheduleCallback(
+ ImmediatePriority$1,
+ performSyncWorkOnRoot.bind(null, root)
+ );
+ } else {
+ var schedulerPriorityLevel = lanePriorityToSchedulerPriority(
+ newCallbackPriority
+ );
+ newCallbackNode = scheduleCallback(
+ schedulerPriorityLevel,
+ performConcurrentWorkOnRoot.bind(null, root)
);
- thenable.then(ping, ping);
}
-}
-
-function throwException(
- root,
- returnFiber,
- sourceFiber,
- value,
- renderExpirationTime
-) {
- // The source fiber did not complete.
- sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
- sourceFiber.firstEffect = sourceFiber.lastEffect = null;
+ root.callbackPriority = newCallbackPriority;
+ root.callbackNode = newCallbackNode;
+} // This is the entry point for every concurrent task, i.e. anything that
+// goes through Scheduler.
- if (
- value !== null &&
- typeof value === "object" &&
- typeof value.then === "function"
- ) {
- // This is a thenable.
- var thenable = value;
+function performConcurrentWorkOnRoot(root, didTimeout) {
+ // Since we know we're in a React event, we can clear the current
+ // event time. The next update will compute a new event time.
+ currentEventTime = NoTimestamp;
+ currentEventWipLanes = NoLanes;
+ currentEventPendingLanes = NoLanes;
- if ((sourceFiber.mode & BlockingMode) === NoMode) {
- // Reset the memoizedState to what it was before we attempted
- // to render it.
- var currentSource = sourceFiber.alternate;
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Should not already be working.");
+ } // Flush any pending passive effects before deciding which lanes to work on,
+ // in case they schedule additional work.
- if (currentSource) {
- sourceFiber.updateQueue = currentSource.updateQueue;
- sourceFiber.memoizedState = currentSource.memoizedState;
- sourceFiber.expirationTime = currentSource.expirationTime;
- } else {
- sourceFiber.updateQueue = null;
- sourceFiber.memoizedState = null;
- }
+ var originalCallbackNode = root.callbackNode;
+ var didFlushPassiveEffects = flushPassiveEffects();
+
+ if (didFlushPassiveEffects) {
+ // Something in the passive effect phase may have canceled the current task.
+ // Check if the task node for this root was changed.
+ if (root.callbackNode !== originalCallbackNode) {
+ // The current task was canceled. Exit. We don't need to call
+ // `ensureRootIsScheduled` because the check above implies either that
+ // there's a new task, or that there's no remaining work on this root.
+ return null;
}
+ } // Determine the next expiration time to work on, using the fields stored
+ // on the root.
- var hasInvisibleParentBoundary = hasSuspenseContext(
- suspenseStackCursor.current,
- InvisibleParentSuspenseContext
- ); // Schedule the nearest Suspense to re-render the timed out view.
+ var lanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes
+ );
- var _workInProgress = returnFiber;
+ if (lanes === NoLanes) {
+ // Defensive coding. This is never expected to happen.
+ return null;
+ } // TODO: We only check `didTimeout` defensively, to account for a Scheduler
+ // bug where `shouldYield` sometimes returns `true` even if `didTimeout` is
+ // true, which leads to an infinite loop. Once the bug in Scheduler is
+ // fixed, we can remove this, since we track expiration ourselves.
- do {
- if (
- _workInProgress.tag === SuspenseComponent &&
- shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)
- ) {
- // Found the nearest boundary.
- // Stash the promise on the boundary fiber. If the boundary times out, we'll
- // attach another listener to flip the boundary back to its normal state.
- var thenables = _workInProgress.updateQueue;
+ if (didTimeout) {
+ // Something expired. Flush synchronously until there's no expired
+ // work left.
+ markRootExpired(root, lanes); // This will schedule a synchronous callback.
- if (thenables === null) {
- var updateQueue = new Set();
- updateQueue.add(thenable);
- _workInProgress.updateQueue = updateQueue;
- } else {
- thenables.add(thenable);
- } // If the boundary is outside of blocking mode, we should *not*
- // suspend the commit. Pretend as if the suspended component rendered
- // null and keep rendering. In the commit phase, we'll schedule a
- // subsequent synchronous update to re-render the Suspense.
- //
- // Note: It doesn't matter whether the component that suspended was
- // inside a blocking mode tree. If the Suspense is outside of it, we
- // should *not* suspend the commit.
+ ensureRootIsScheduled(root, now());
+ return null;
+ }
- if ((_workInProgress.mode & BlockingMode) === NoMode) {
- _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete.
- // But we shouldn't call any lifecycle methods or callbacks. Remove
- // all lifecycle effect tags.
+ var exitStatus = renderRootConcurrent(root, lanes);
- sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
+ if (
+ includesSomeLane(
+ workInProgressRootIncludedLanes,
+ workInProgressRootUpdatedLanes
+ )
+ ) {
+ // The render included lanes that were updated during the render phase.
+ // For example, when unhiding a hidden tree, we include all the lanes
+ // that were previously skipped when the tree was hidden. That set of
+ // lanes is a superset of the lanes we started rendering with.
+ //
+ // So we'll throw out the current work and restart.
+ prepareFreshStack(root, NoLanes);
+ } else if (exitStatus !== RootIncomplete) {
+ if (exitStatus === RootErrored) {
+ executionContext |= RetryAfterError; // If an error occurred during hydration,
+ // discard server response and fall back to client side render.
- if (sourceFiber.tag === ClassComponent) {
- var currentSourceFiber = sourceFiber.alternate;
+ if (root.hydrate) {
+ root.hydrate = false;
+ clearContainer(root.containerInfo);
+ } // If something threw an error, try rendering one more time. We'll render
+ // synchronously to block concurrent data mutations, and we'll includes
+ // all pending updates are included. If it still fails after the second
+ // attempt, we'll give up and commit the resulting tree.
- if (currentSourceFiber === null) {
- // This is a new mount. Change the tag so it's not mistaken for a
- // completed class component. For example, we should not call
- // componentWillUnmount if it is deleted.
- sourceFiber.tag = IncompleteClassComponent;
- } else {
- // When we try rendering again, we should not reuse the current fiber,
- // since it's known to be in an inconsistent state. Use a force update to
- // prevent a bail out.
- var update = createUpdate(Sync, null);
- update.tag = ForceUpdate;
- enqueueUpdate(sourceFiber, update);
- }
- } // The source fiber did not complete. Mark it with Sync priority to
- // indicate that it still has pending work.
+ lanes = getLanesToRetrySynchronouslyOnError(root);
- sourceFiber.expirationTime = Sync; // Exit without suspending.
+ if (lanes !== NoLanes) {
+ exitStatus = renderRootSync(root, lanes);
+ }
+ }
- return;
- } // Confirmed that the boundary is in a concurrent mode tree. Continue
- // with the normal suspend path.
- //
- // After this we'll use a set of heuristics to determine whether this
- // render pass will run to completion or restart or "suspend" the commit.
- // The actual logic for this is spread out in different places.
- //
- // This first principle is that if we're going to suspend when we complete
- // a root, then we should also restart if we get an update or ping that
- // might unsuspend it, and vice versa. The only reason to suspend is
- // because you think you might want to restart before committing. However,
- // it doesn't make sense to restart only while in the period we're suspended.
- //
- // Restarting too aggressively is also not good because it starves out any
- // intermediate loading state. So we use heuristics to determine when.
- // Suspense Heuristics
- //
- // If nothing threw a Promise or all the same fallbacks are already showing,
- // then don't suspend/restart.
- //
- // If this is an initial render of a new tree of Suspense boundaries and
- // those trigger a fallback, then don't suspend/restart. We want to ensure
- // that we can show the initial loading state as quickly as possible.
- //
- // If we hit a "Delayed" case, such as when we'd switch from content back into
- // a fallback, then we should always suspend/restart. SuspenseConfig applies to
- // this case. If none is defined, JND is used instead.
- //
- // If we're already showing a fallback and it gets "retried", allowing us to show
- // another level, but there's still an inner boundary that would show a fallback,
- // then we suspend/restart for 500ms since the last time we showed a fallback
- // anywhere in the tree. This effectively throttles progressive loading into a
- // consistent train of commits. This also gives us an opportunity to restart to
- // get to the completed state slightly earlier.
- //
- // If there's ambiguity due to batching it's resolved in preference of:
- // 1) "delayed", 2) "initial render", 3) "retry".
- //
- // We want to ensure that a "busy" state doesn't get force committed. We want to
- // ensure that new initial loading states can commit as soon as possible.
+ if (exitStatus === RootFatalErrored) {
+ var fatalError = workInProgressRootFatalError;
+ prepareFreshStack(root, NoLanes);
+ markRootSuspended$1(root, lanes);
+ ensureRootIsScheduled(root, now());
+ throw fatalError;
+ } // We now have a consistent tree. The next step is either to commit it,
+ // or, if something suspended, wait to commit it after a timeout.
- attachPingListener(root, renderExpirationTime, thenable);
- _workInProgress.effectTag |= ShouldCapture;
- _workInProgress.expirationTime = renderExpirationTime;
- return;
- } // This boundary already captured during this render. Continue to the next
- // boundary.
+ var finishedWork = root.current.alternate;
+ root.finishedWork = finishedWork;
+ root.finishedLanes = lanes;
+ finishConcurrentRender(root, finishedWork, exitStatus, lanes);
+ }
- _workInProgress = _workInProgress.return;
- } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
- // TODO: Use invariant so the message is stripped in prod?
+ ensureRootIsScheduled(root, now());
+
+ if (root.callbackNode === originalCallbackNode) {
+ // The task node scheduled for this root is the same one that's
+ // currently executed. Need to return a continuation.
+ return performConcurrentWorkOnRoot.bind(null, root);
+ }
+
+ return null;
+}
+
+function finishConcurrentRender(root, finishedWork, exitStatus, lanes) {
+ switch (exitStatus) {
+ case RootIncomplete:
+ case RootFatalErrored: {
+ {
+ throw Error("Root did not complete. This is a bug in React.");
+ }
+ }
+ // Flow knows about invariant, so it complains if I add a break
+ // statement, but eslint doesn't know about invariant, so it complains
+ // if I do. eslint-disable-next-line no-fallthrough
- value = new Error(
- (getComponentName(sourceFiber.type) || "A React component") +
- " suspended while rendering, but no fallback UI was specified.\n" +
- "\n" +
- "Add a component higher in the tree to " +
- "provide a loading indicator or placeholder to display." +
- getStackByFiberInDevAndProd(sourceFiber)
- );
- } // We didn't find a boundary that could handle this type of exception. Start
- // over and traverse parent path again, this time treating the exception
- // as an error.
+ case RootErrored: {
+ // We should have already attempted to retry this tree. If we reached
+ // this point, it errored again. Commit it.
+ commitRoot(root);
+ break;
+ }
- renderDidError();
- value = createCapturedValue(value, sourceFiber);
- var workInProgress = returnFiber;
+ case RootSuspended: {
+ markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we
+ // should immediately commit it or wait a bit.
- do {
- switch (workInProgress.tag) {
- case HostRoot: {
- var _errorInfo = value;
- workInProgress.effectTag |= ShouldCapture;
- workInProgress.expirationTime = renderExpirationTime;
+ if (
+ includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope
+ !shouldForceFlushFallbacksInDEV()
+ ) {
+ // This render only included retries, no updates. Throttle committing
+ // retries so that we don't show too many loading states too quickly.
+ var msUntilTimeout =
+ globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
- var _update = createRootErrorUpdate(
- workInProgress,
- _errorInfo,
- renderExpirationTime
- );
+ if (msUntilTimeout > 10) {
+ var nextLanes = getNextLanes(root, NoLanes);
- enqueueCapturedUpdate(workInProgress, _update);
- return;
- }
+ if (nextLanes !== NoLanes) {
+ // There's additional work on this root.
+ break;
+ }
- case ClassComponent:
- // Capture and retry
- var errorInfo = value;
- var ctor = workInProgress.type;
- var instance = workInProgress.stateNode;
+ var suspendedLanes = root.suspendedLanes;
- if (
- (workInProgress.effectTag & DidCapture) === NoEffect &&
- (typeof ctor.getDerivedStateFromError === "function" ||
- (instance !== null &&
- typeof instance.componentDidCatch === "function" &&
- !isAlreadyFailedLegacyErrorBoundary(instance)))
- ) {
- workInProgress.effectTag |= ShouldCapture;
- workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state
+ if (!isSubsetOfLanes(suspendedLanes, lanes)) {
+ // We should prefer to render the fallback of at the last
+ // suspended level. Ping the last suspended level to try
+ // rendering it again.
+ // FIXME: What if the suspended lanes are Idle? Should not restart.
+ var eventTime = requestEventTime();
+ markRootPinged(root, suspendedLanes);
+ break;
+ } // The render is suspended, it hasn't timed out, and there's no
+ // lower priority work to do. Instead of committing the fallback
+ // immediately, wait for more data to arrive.
- var _update2 = createClassErrorUpdate(
- workInProgress,
- errorInfo,
- renderExpirationTime
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ msUntilTimeout
);
-
- enqueueCapturedUpdate(workInProgress, _update2);
- return;
+ break;
}
+ } // The work expired. Commit immediately.
- break;
+ commitRoot(root);
+ break;
}
- workInProgress = workInProgress.return;
- } while (workInProgress !== null);
-}
+ case RootSuspendedWithDelay: {
+ markRootSuspended$1(root, lanes);
-var ceil = Math.ceil;
-var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
- ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
- IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
-var NoContext =
- /* */
- 0;
-var BatchedContext =
- /* */
- 1;
-var DiscreteEventContext =
- /* */
- 4;
-var LegacyUnbatchedContext =
- /* */
- 8;
-var RenderContext =
- /* */
- 16;
-var CommitContext =
- /* */
- 32;
-var RootIncomplete = 0;
-var RootFatalErrored = 1;
-var RootErrored = 2;
-var RootSuspended = 3;
-var RootSuspendedWithDelay = 4;
-var RootCompleted = 5;
-// Describes where we are in the React execution stack
-var executionContext = NoContext; // The root we're working on
+ if (
+ // do not delay if we're inside an act() scope
+ !shouldForceFlushFallbacksInDEV()
+ ) {
+ // We're suspended in a state that should be avoided. We'll try to
+ // avoid committing it for as long as the timeouts let us.
+ var _nextLanes = getNextLanes(root, NoLanes);
-var workInProgressRoot = null; // The fiber we're working on
+ if (_nextLanes !== NoLanes) {
+ // There's additional work on this root.
+ break;
+ }
-var workInProgress = null; // The expiration time we're rendering
+ var _suspendedLanes = root.suspendedLanes;
-var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc.
+ if (!isSubsetOfLanes(_suspendedLanes, lanes)) {
+ // We should prefer to render the fallback of at the last
+ // suspended level. Ping the last suspended level to try
+ // rendering it again.
+ // FIXME: What if the suspended lanes are Idle? Should not restart.
+ var _eventTime = requestEventTime();
-var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
+ markRootPinged(root, _suspendedLanes);
+ break;
+ }
-var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render.
-// This is conceptually a time stamp but expressed in terms of an ExpirationTime
-// because we deal mostly with expiration times in the hot path, so this avoids
-// the conversion happening in the hot path.
+ var mostRecentEventTime = getMostRecentEventTime(root, lanes);
-var workInProgressRootLatestProcessedExpirationTime = Sync;
-var workInProgressRootLatestSuspenseTimeout = Sync;
-var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only
-// includes unprocessed updates, not work in bailed out children.
+ var _msUntilTimeout;
-var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately.
-// This flag determines if it might be worthwhile to restart if an opportunity
-// happens latere.
+ if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) {
+ // We have processed a suspense config whose expiration time we
+ // can use as the timeout.
+ _msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now();
+ } else if (mostRecentEventTime === NoTimestamp) {
+ // This should never normally happen because only new updates
+ // cause delayed states, so we should have processed something.
+ // However, this could also happen in an offscreen tree.
+ _msUntilTimeout = 0;
+ } else {
+ // If we didn't process a suspense config, compute a JND based on
+ // the amount of time elapsed since the most recent event time.
+ var eventTimeMs = mostRecentEventTime;
+ var timeElapsedMs = now() - eventTimeMs;
+ _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs;
+ } // Don't bother with a very short suspense time.
-var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train
-// model where we don't commit new loading states in too quick succession.
+ if (_msUntilTimeout > 10) {
+ // The render is suspended, it hasn't timed out, and there's no
+ // lower priority work to do. Instead of committing the fallback
+ // immediately, wait for more data to arrive.
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ _msUntilTimeout
+ );
+ break;
+ }
+ } // The work expired. Commit immediately.
-var globalMostRecentFallbackTime = 0;
-var FALLBACK_THROTTLE_MS = 500;
-var nextEffect = null;
-var hasUncaughtError = false;
-var firstUncaughtError = null;
-var legacyErrorBoundariesThatAlreadyFailed = null;
-var rootDoesHavePassiveEffects = false;
-var rootWithPendingPassiveEffects = null;
-var pendingPassiveEffectsRenderPriority = NoPriority;
-var pendingPassiveEffectsExpirationTime = NoWork;
-var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
+ commitRoot(root);
+ break;
+ }
-var NESTED_UPDATE_LIMIT = 50;
-var nestedUpdateCount = 0;
-var rootWithNestedUpdates = null;
-var NESTED_PASSIVE_UPDATE_LIMIT = 50;
-var nestedPassiveUpdateCount = 0;
-var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times
-// during the commit phase. This enables them to be traced across components
-// that spawn new work during render. E.g. hidden boundaries, suspended SSR
-// hydration or SuspenseList.
+ case RootCompleted: {
+ // The work completed. Ready to commit.
+ var _mostRecentEventTime = getMostRecentEventTime(root, lanes);
-var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start
-// time). However, if two updates are scheduled within the same event, we
-// should treat their start times as simultaneous, even if the actual clock
-// time has advanced between the first and second call.
-// In other words, because expiration times determine how updates are batched,
-// we want all updates of like priority that occur within the same event to
-// receive the same expiration time. Otherwise we get tearing.
+ if (
+ // do not delay if we're inside an act() scope
+ !shouldForceFlushFallbacksInDEV() &&
+ _mostRecentEventTime !== NoTimestamp &&
+ workInProgressRootCanSuspendUsingConfig !== null
+ ) {
+ // If we have exceeded the minimum loading delay, which probably
+ // means we have shown a spinner already, we might have to suspend
+ // a bit longer to ensure that the spinner is shown for
+ // enough time.
+ var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(
+ _mostRecentEventTime,
+ workInProgressRootCanSuspendUsingConfig
+ );
-var currentEventTime = NoWork;
-function requestCurrentTimeForUpdate() {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
- // We're inside React, so it's fine to read the actual time.
- return msToExpirationTime(now());
- } // We're not inside React, so we may be in the middle of a browser event.
+ if (_msUntilTimeout2 > 10) {
+ markRootSuspended$1(root, lanes);
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ _msUntilTimeout2
+ );
+ break;
+ }
+ }
- if (currentEventTime !== NoWork) {
- // Use the same start time for all updates until we enter React again.
- return currentEventTime;
- } // This is the first update since React yielded. Compute a new start time.
+ commitRoot(root);
+ break;
+ }
- currentEventTime = msToExpirationTime(now());
- return currentEventTime;
-}
-function getCurrentTime() {
- return msToExpirationTime(now());
+ default: {
+ {
+ throw Error("Unknown root exit status.");
+ }
+ }
+ }
}
-function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
- var mode = fiber.mode;
- if ((mode & BlockingMode) === NoMode) {
- return Sync;
+function markRootSuspended$1(root, suspendedLanes) {
+ // When suspending, we should always exclude lanes that were pinged or (more
+ // rarely, since we try to avoid it) updated during the render phase.
+ // TODO: Lol maybe there's a better way to factor this besides this
+ // obnoxiously named function :)
+ suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes);
+ suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes);
+ markRootSuspended(root, suspendedLanes);
+} // This is the entry point for synchronous tasks that don't go
+// through Scheduler
+
+function performSyncWorkOnRoot(root) {
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Should not already be working.");
}
- var priorityLevel = getCurrentPriorityLevel();
+ flushPassiveEffects();
+ var lanes;
+ var exitStatus;
+
+ if (
+ root === workInProgressRoot &&
+ includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes)
+ ) {
+ // There's a partial tree, and at least one of its lanes has expired. Finish
+ // rendering it before rendering the rest of the expired work.
+ lanes = workInProgressRootRenderLanes;
+ exitStatus = renderRootSync(root, lanes);
- if ((mode & ConcurrentMode) === NoMode) {
- return priorityLevel === ImmediatePriority ? Sync : Batched;
+ if (
+ includesSomeLane(
+ workInProgressRootIncludedLanes,
+ workInProgressRootUpdatedLanes
+ )
+ ) {
+ // The render included lanes that were updated during the render phase.
+ // For example, when unhiding a hidden tree, we include all the lanes
+ // that were previously skipped when the tree was hidden. That set of
+ // lanes is a superset of the lanes we started rendering with.
+ //
+ // Note that this only happens when part of the tree is rendered
+ // concurrently. If the whole tree is rendered synchronously, then there
+ // are no interleaved events.
+ lanes = getNextLanes(root, lanes);
+ exitStatus = renderRootSync(root, lanes);
+ }
+ } else {
+ lanes = getNextLanes(root, NoLanes);
+ exitStatus = renderRootSync(root, lanes);
}
- if ((executionContext & RenderContext) !== NoContext) {
- // Use whatever time we're already rendering
- // TODO: Should there be a way to opt out, like with `runWithPriority`?
- return renderExpirationTime$1;
+ if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
+ executionContext |= RetryAfterError; // If an error occurred during hydration,
+ // discard server response and fall back to client side render.
+
+ if (root.hydrate) {
+ root.hydrate = false;
+ clearContainer(root.containerInfo);
+ } // If something threw an error, try rendering one more time. We'll render
+ // synchronously to block concurrent data mutations, and we'll includes
+ // all pending updates are included. If it still fails after the second
+ // attempt, we'll give up and commit the resulting tree.
+
+ lanes = getLanesToRetrySynchronouslyOnError(root);
+
+ if (lanes !== NoLanes) {
+ exitStatus = renderRootSync(root, lanes);
+ }
}
- var expirationTime;
+ if (exitStatus === RootFatalErrored) {
+ var fatalError = workInProgressRootFatalError;
+ prepareFreshStack(root, NoLanes);
+ markRootSuspended$1(root, lanes);
+ ensureRootIsScheduled(root, now());
+ throw fatalError;
+ } // We now have a consistent tree. Because this is a sync render, we
+ // will commit it even if something suspended.
+
+ var finishedWork = root.current.alternate;
+ root.finishedWork = finishedWork;
+ root.finishedLanes = lanes;
+ commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next
+ // pending level.
+
+ ensureRootIsScheduled(root, now());
+ return null;
+}
+
+function batchedUpdates$1(fn, a) {
+ var prevExecutionContext = executionContext;
+ executionContext |= BatchedContext;
+
+ try {
+ return fn(a);
+ } finally {
+ executionContext = prevExecutionContext;
+
+ if (executionContext === NoContext) {
+ // Flush the immediate callbacks that were scheduled during this batch
+ flushSyncCallbackQueue();
+ }
+ }
+}
+function flushSync(fn, a) {
+ var prevExecutionContext = executionContext;
- if (suspenseConfig !== null) {
- // Compute an expiration time based on the Suspense timeout.
- expirationTime = computeSuspenseExpiration(
- currentTime,
- suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION
- );
- } else {
- // Compute an expiration time based on the Scheduler priority.
- switch (priorityLevel) {
- case ImmediatePriority:
- expirationTime = Sync;
- break;
+ if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) {
+ {
+ error(
+ "flushSync was called from inside a lifecycle method. React cannot " +
+ "flush when React is already rendering. Consider moving this call to " +
+ "a scheduler task or micro task."
+ );
+ }
- case UserBlockingPriority:
- // TODO: Rename this to computeUserBlockingExpiration
- expirationTime = computeInteractiveExpiration(currentTime);
- break;
+ return fn(a);
+ }
- case NormalPriority:
- case LowPriority:
- // TODO: Handle LowPriority
- // TODO: Rename this to... something better.
- expirationTime = computeAsyncExpiration(currentTime);
- break;
+ executionContext |= BatchedContext;
- case IdlePriority:
- expirationTime = Idle;
- break;
+ try {
+ setCurrentUpdateLanePriority(SyncLanePriority);
- default: {
- throw Error("Expected a valid priority level");
- }
+ if (fn) {
+ return runWithPriority(ImmediatePriority$1, fn.bind(null, a));
+ } else {
+ return undefined;
}
- } // If we're in the middle of rendering a tree, do not update at the same
- // expiration time that is already rendering.
- // TODO: We shouldn't have to do this if the update is on a different root.
- // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
- // the root when we check for this condition.
+ } finally {
+ executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
+ // Note that this will happen even if batchedUpdates is higher up
+ // the stack.
- if (
- workInProgressRoot !== null &&
- expirationTime === renderExpirationTime$1
- ) {
- // This is a trick to move this update into a separate batch
- expirationTime -= 1;
+ flushSyncCallbackQueue();
}
-
- return expirationTime;
}
-function scheduleUpdateOnFiber(fiber, expirationTime) {
- checkForNestedUpdates();
- warnAboutRenderPhaseUpdatesInDEV(fiber);
- var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
-
- if (root === null) {
- warnAboutUpdateOnUnmountedFiberInDEV(fiber);
- return;
- }
+function pushRenderLanes(fiber, lanes) {
+ push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber);
+ subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes);
+ workInProgressRootIncludedLanes = mergeLanes(
+ workInProgressRootIncludedLanes,
+ lanes
+ );
+}
+function popRenderLanes(fiber) {
+ subtreeRenderLanes = subtreeRenderLanesCursor.current;
+ pop(subtreeRenderLanesCursor, fiber);
+}
- checkForInterruption(fiber, expirationTime);
- recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
- // priority as an argument to that function and this one.
+function prepareFreshStack(root, lanes) {
+ root.finishedWork = null;
+ root.finishedLanes = NoLanes;
+ var timeoutHandle = root.timeoutHandle;
- var priorityLevel = getCurrentPriorityLevel();
+ if (timeoutHandle !== noTimeout) {
+ // The root previous suspended and scheduled a timeout to commit a fallback
+ // state. Now that we have additional work, cancel the timeout.
+ root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
- if (expirationTime === Sync) {
- if (
- // Check if we're inside unbatchedUpdates
- (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
- (executionContext & (RenderContext | CommitContext)) === NoContext
- ) {
- // Register pending interactions on the root to avoid losing traced interaction data.
- schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
- // root inside of batchedUpdates should be synchronous, but layout updates
- // should be deferred until the end of the batch.
+ cancelTimeout(timeoutHandle);
+ }
- performSyncWorkOnRoot(root);
- } else {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, expirationTime);
+ if (workInProgress !== null) {
+ var interruptedWork = workInProgress.return;
- if (executionContext === NoContext) {
- // Flush the synchronous work now, unless we're already working or inside
- // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
- // scheduleCallbackForFiber to preserve the ability to schedule a callback
- // without immediately flushing it. We only do this for user-initiated
- // updates, to preserve historical behavior of legacy mode.
- flushSyncCallbackQueue();
- }
+ while (interruptedWork !== null) {
+ unwindInterruptedWork(interruptedWork);
+ interruptedWork = interruptedWork.return;
}
- } else {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, expirationTime);
}
- if (
- (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered
- // discrete, even inside a discrete event.
- (priorityLevel === UserBlockingPriority ||
- priorityLevel === ImmediatePriority)
- ) {
- // This is the result of a discrete event. Track the lowest priority
- // discrete update per root so we can flush them early, if needed.
- if (rootsWithPendingDiscreteUpdates === null) {
- rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
- } else {
- var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
+ workInProgressRoot = root;
+ workInProgress = createWorkInProgress(root.current, null);
+ workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
+ workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootFatalError = null;
+ workInProgressRootLatestSuspenseTimeout = NoTimestamp;
+ workInProgressRootCanSuspendUsingConfig = null;
+ workInProgressRootSkippedLanes = NoLanes;
+ workInProgressRootUpdatedLanes = NoLanes;
+ workInProgressRootPingedLanes = NoLanes;
- if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
- rootsWithPendingDiscreteUpdates.set(root, expirationTime);
- }
- }
+ {
+ spawnedWorkDuringRender = null;
}
-}
-var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending
-// work without treating it as a typical update that originates from an event;
-// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
-// on a fiber.
-function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
- // Update the source fiber's expiration time
- if (fiber.expirationTime < expirationTime) {
- fiber.expirationTime = expirationTime;
+ {
+ ReactStrictModeWarnings.discardPendingWarnings();
}
+}
- var alternate = fiber.alternate;
+function handleError(root, thrownValue) {
+ do {
+ var erroredWork = workInProgress;
- if (alternate !== null && alternate.expirationTime < expirationTime) {
- alternate.expirationTime = expirationTime;
- } // Walk the parent path to the root and update the child expiration time.
+ try {
+ // Reset module-level state that was set during the render phase.
+ resetContextDependencies();
+ resetHooksAfterThrow();
+ resetCurrentFiber(); // TODO: I found and added this missing line while investigating a
+ // separate issue. Write a regression test using string refs.
- var node = fiber.return;
- var root = null;
+ ReactCurrentOwner$2.current = null;
- if (node === null && fiber.tag === HostRoot) {
- root = fiber.stateNode;
- } else {
- while (node !== null) {
- alternate = node.alternate;
+ if (erroredWork === null || erroredWork.return === null) {
+ // Expected to be working on a non-root fiber. This is a fatal error
+ // because there's no ancestor that can handle it; the root is
+ // supposed to capture all errors that weren't caught by an error
+ // boundary.
+ workInProgressRootExitStatus = RootFatalErrored;
+ workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next
+ // sibling, or the parent if there are no siblings. But since the root
+ // has no siblings nor a parent, we set it to null. Usually this is
+ // handled by `completeUnitOfWork` or `unwindWork`, but since we're
+ // intentionally not calling those, we need set it here.
+ // TODO: Consider calling `unwindWork` to pop the contexts.
- if (node.childExpirationTime < expirationTime) {
- node.childExpirationTime = expirationTime;
+ workInProgress = null;
+ return;
+ }
- if (
- alternate !== null &&
- alternate.childExpirationTime < expirationTime
- ) {
- alternate.childExpirationTime = expirationTime;
- }
- } else if (
- alternate !== null &&
- alternate.childExpirationTime < expirationTime
- ) {
- alternate.childExpirationTime = expirationTime;
+ if (enableProfilerTimer && erroredWork.mode & ProfileMode) {
+ // Record the time spent rendering before an error was thrown. This
+ // avoids inaccurate Profiler durations in the case of a
+ // suspended render.
+ stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
}
- if (node.return === null && node.tag === HostRoot) {
- root = node.stateNode;
- break;
+ throwException(
+ root,
+ erroredWork.return,
+ erroredWork,
+ thrownValue,
+ workInProgressRootRenderLanes
+ );
+ completeUnitOfWork(erroredWork);
+ } catch (yetAnotherThrownValue) {
+ // Something in the return path also threw.
+ thrownValue = yetAnotherThrownValue;
+
+ if (workInProgress === erroredWork && erroredWork !== null) {
+ // If this boundary has already errored, then we had trouble processing
+ // the error. Bubble it to the next boundary.
+ erroredWork = erroredWork.return;
+ workInProgress = erroredWork;
+ } else {
+ erroredWork = workInProgress;
}
- node = node.return;
- }
- }
+ continue;
+ } // Return to the normal work loop.
- if (root !== null) {
- if (workInProgressRoot === root) {
- // Received an update to a tree that's in the middle of rendering. Mark
- // that's unprocessed work on this root.
- markUnprocessedUpdateTime(expirationTime);
-
- if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
- // The root already suspended with a delay, which means this render
- // definitely won't finish. Since we have a new update, let's mark it as
- // suspended now, right before marking the incoming update. This has the
- // effect of interrupting the current render and switching to the update.
- // TODO: This happens to work when receiving an update during the render
- // phase, because of the trick inside computeExpirationForFiber to
- // subtract 1 from `renderExpirationTime` to move it into a
- // separate bucket. But we should probably model it with an exception,
- // using the same mechanism we use to force hydration of a subtree.
- // TODO: This does not account for low pri updates that were already
- // scheduled before the root started rendering. Need to track the next
- // pending expiration time (perhaps by backtracking the return path) and
- // then trigger a restart in the `renderDidSuspendDelayIfPossible` path.
- markRootSuspendedAtTime(root, renderExpirationTime$1);
- }
- } // Mark that the root has a pending update.
-
- markRootUpdatedAtTime(root, expirationTime);
+ return;
+ } while (true);
+}
+
+function pushDispatcher(root) {
+ var prevDispatcher = ReactCurrentDispatcher$2.current;
+ ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
+
+ if (prevDispatcher === null) {
+ // The React isomorphic package does not include a default dispatcher.
+ // Instead the first renderer will lazily attach one, in order to give
+ // nicer error messages.
+ return ContextOnlyDispatcher;
+ } else {
+ return prevDispatcher;
}
+}
- return root;
+function popDispatcher(prevDispatcher) {
+ ReactCurrentDispatcher$2.current = prevDispatcher;
}
-function getNextRootExpirationTimeToWorkOn(root) {
- // Determines the next expiration time that the root should render, taking
- // into account levels that may be suspended, or levels that may have
- // received a ping.
- var lastExpiredTime = root.lastExpiredTime;
+function pushInteractions(root) {
+ {
+ var prevInteractions = tracing.__interactionsRef.current;
+ tracing.__interactionsRef.current = root.memoizedInteractions;
+ return prevInteractions;
+ }
+}
- if (lastExpiredTime !== NoWork) {
- return lastExpiredTime;
- } // "Pending" refers to any update that hasn't committed yet, including if it
- // suspended. The "suspended" range is therefore a subset.
+function popInteractions(prevInteractions) {
+ {
+ tracing.__interactionsRef.current = prevInteractions;
+ }
+}
- var firstPendingTime = root.firstPendingTime;
+function markCommitTimeOfFallback() {
+ globalMostRecentFallbackTime = now();
+}
+function markRenderEventTimeAndConfig(eventTime, suspenseConfig) {
+ // Track the largest/latest timeout deadline in this batch.
+ // TODO: If there are two transitions in the same batch, shouldn't we
+ // choose the smaller one? Maybe this is because when an intermediate
+ // transition is superseded, we should ignore its suspense config, but
+ // we don't currently.
+ if (suspenseConfig !== null) {
+ // If `timeoutMs` is not specified, we default to 5 seconds. We have to
+ // resolve this default here because `suspenseConfig` is owned
+ // by userspace.
+ // TODO: Store this on the root instead (transition -> timeoutMs)
+ // TODO: Should this default to a JND instead?
+ var timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS;
+ var timeoutTime = eventTime + timeoutMs;
+
+ if (timeoutTime > workInProgressRootLatestSuspenseTimeout) {
+ workInProgressRootLatestSuspenseTimeout = timeoutTime;
+ workInProgressRootCanSuspendUsingConfig = suspenseConfig;
+ }
+ }
+}
+function markSkippedUpdateLanes(lane) {
+ workInProgressRootSkippedLanes = mergeLanes(
+ lane,
+ workInProgressRootSkippedLanes
+ );
+}
+function renderDidSuspend() {
+ if (workInProgressRootExitStatus === RootIncomplete) {
+ workInProgressRootExitStatus = RootSuspended;
+ }
+}
+function renderDidSuspendDelayIfPossible() {
+ if (
+ workInProgressRootExitStatus === RootIncomplete ||
+ workInProgressRootExitStatus === RootSuspended
+ ) {
+ workInProgressRootExitStatus = RootSuspendedWithDelay;
+ } // Check if there are updates that we skipped tree that might have unblocked
+ // this render.
- if (!isRootSuspendedAtTime(root, firstPendingTime)) {
- // The highest priority pending time is not suspended. Let's work on that.
- return firstPendingTime;
- } // If the first pending time is suspended, check if there's a lower priority
- // pending level that we know about. Or check if we received a ping. Work
- // on whichever is higher priority.
+ if (
+ workInProgressRoot !== null &&
+ (includesNonIdleWork(workInProgressRootSkippedLanes) ||
+ includesNonIdleWork(workInProgressRootUpdatedLanes))
+ ) {
+ // Mark the current render as suspended so that we switch to working on
+ // the updates that were skipped. Usually we only suspend at the end of
+ // the render phase.
+ // TODO: We should probably always mark the root as suspended immediately
+ // (inside this function), since by suspending at the end of the render
+ // phase introduces a potential mistake where we suspend lanes that were
+ // pinged or updated while we were rendering.
+ markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
+ }
+}
+function renderDidError() {
+ if (workInProgressRootExitStatus !== RootCompleted) {
+ workInProgressRootExitStatus = RootErrored;
+ }
+} // Called during render to determine if anything has suspended.
+// Returns false if we're not sure.
- var lastPingedTime = root.lastPingedTime;
- var nextKnownPendingLevel = root.nextKnownPendingLevel;
- var nextLevel =
- lastPingedTime > nextKnownPendingLevel
- ? lastPingedTime
- : nextKnownPendingLevel;
+function renderHasNotSuspendedYet() {
+ // If something errored or completed, we can't really be sure,
+ // so those are false.
+ return workInProgressRootExitStatus === RootIncomplete;
+}
- if (nextLevel <= Idle && firstPendingTime !== nextLevel) {
- // Don't work on Idle/Never priority unless everything else is committed.
- return NoWork;
- }
+function renderRootSync(root, lanes) {
+ var prevExecutionContext = executionContext;
+ executionContext |= RenderContext;
+ var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack
+ // and prepare a fresh one. Otherwise we'll continue where we left off.
- return nextLevel;
-} // Use this function to schedule a task for a root. There's only one task per
-// root; if a task was already scheduled, we'll check to make sure the
-// expiration time of the existing task is the same as the expiration time of
-// the next level that the root has work on. This function is called on every
-// update, and right before exiting a task.
-
-function ensureRootIsScheduled(root) {
- var lastExpiredTime = root.lastExpiredTime;
-
- if (lastExpiredTime !== NoWork) {
- // Special case: Expired work should flush synchronously.
- root.callbackExpirationTime = Sync;
- root.callbackPriority = ImmediatePriority;
- root.callbackNode = scheduleSyncCallback(
- performSyncWorkOnRoot.bind(null, root)
- );
- return;
+ if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
+ prepareFreshStack(root, lanes);
+ startWorkOnPendingInteractions(root, lanes);
}
- var expirationTime = getNextRootExpirationTimeToWorkOn(root);
- var existingCallbackNode = root.callbackNode;
+ var prevInteractions = pushInteractions(root);
- if (expirationTime === NoWork) {
- // There's nothing to work on.
- if (existingCallbackNode !== null) {
- root.callbackNode = null;
- root.callbackExpirationTime = NoWork;
- root.callbackPriority = NoPriority;
+ do {
+ try {
+ workLoopSync();
+ break;
+ } catch (thrownValue) {
+ handleError(root, thrownValue);
}
+ } while (true);
- return;
- } // TODO: If this is an update, we already read the current time. Pass the
- // time as an argument.
-
- var currentTime = requestCurrentTimeForUpdate();
- var priorityLevel = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- ); // If there's an existing render task, confirm it has the correct priority and
- // expiration time. Otherwise, we'll cancel it and schedule a new one.
+ resetContextDependencies();
- if (existingCallbackNode !== null) {
- var existingCallbackPriority = root.callbackPriority;
- var existingCallbackExpirationTime = root.callbackExpirationTime;
+ {
+ popInteractions(prevInteractions);
+ }
- if (
- // Callback must have the exact same expiration time.
- existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority.
- existingCallbackPriority >= priorityLevel
- ) {
- // Existing callback is sufficient.
- return;
- } // Need to schedule a new task.
- // TODO: Instead of scheduling a new task, we should be able to change the
- // priority of the existing one.
+ executionContext = prevExecutionContext;
+ popDispatcher(prevDispatcher);
- cancelCallback(existingCallbackNode);
+ if (workInProgress !== null) {
+ // This is a sync render, so we should have finished the whole tree.
+ {
+ throw Error(
+ "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
}
- root.callbackExpirationTime = expirationTime;
- root.callbackPriority = priorityLevel;
- var callbackNode;
+ workInProgressRoot = null;
+ workInProgressRootRenderLanes = NoLanes;
+ return workInProgressRootExitStatus;
+} // The work loop is an extremely hot path. Tell Closure not to inline it.
- if (expirationTime === Sync) {
- // Sync React callbacks are scheduled on a special internal queue
- callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
- } else {
- callbackNode = scheduleCallback(
- priorityLevel,
- performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects
- // ordering because tasks are processed in timeout order.
- {
- timeout: expirationTimeToMs(expirationTime) - now()
- }
- );
+/** @noinline */
+
+function workLoopSync() {
+ // Already timed out, so perform work without checking if we need to yield.
+ while (workInProgress !== null) {
+ performUnitOfWork(workInProgress);
}
+}
- root.callbackNode = callbackNode;
-} // This is the entry point for every concurrent task, i.e. anything that
-// goes through Scheduler.
+function renderRootConcurrent(root, lanes) {
+ var prevExecutionContext = executionContext;
+ executionContext |= RenderContext;
+ var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack
+ // and prepare a fresh one. Otherwise we'll continue where we left off.
-function performConcurrentWorkOnRoot(root, didTimeout) {
- // Since we know we're in a React event, we can clear the current
- // event time. The next update will compute a new event time.
- currentEventTime = NoWork; // Check if the render expired.
+ if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
+ prepareFreshStack(root, lanes);
+ startWorkOnPendingInteractions(root, lanes);
+ }
- if (didTimeout) {
- // The render task took too long to complete. Mark the current time as
- // expired to synchronously render all expired work in a single batch.
- var currentTime = requestCurrentTimeForUpdate();
- markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback.
+ var prevInteractions = pushInteractions(root);
- ensureRootIsScheduled(root);
- return null;
- } // Determine the next expiration time to work on, using the fields stored
- // on the root.
+ do {
+ try {
+ workLoopConcurrent();
+ break;
+ } catch (thrownValue) {
+ handleError(root, thrownValue);
+ }
+ } while (true);
- var expirationTime = getNextRootExpirationTimeToWorkOn(root);
+ resetContextDependencies();
- if (expirationTime === NoWork) {
- return null;
+ {
+ popInteractions(prevInteractions);
}
- var originalCallbackNode = root.callbackNode;
+ popDispatcher(prevDispatcher);
+ executionContext = prevExecutionContext;
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
- }
+ if (workInProgress !== null) {
+ return RootIncomplete;
+ } else {
+ workInProgressRoot = null;
+ workInProgressRootRenderLanes = NoLanes; // Return the final exit status.
- flushPassiveEffects();
- var exitStatus = renderRootConcurrent(root, expirationTime);
+ return workInProgressRootExitStatus;
+ }
+}
+/** @noinline */
- if (exitStatus !== RootIncomplete) {
- if (exitStatus === RootErrored) {
- // If something threw an error, try rendering one more time. We'll
- // render synchronously to block concurrent data mutations, and we'll
- // render at Idle (or lower) so that all pending updates are included.
- // If it still fails after the second attempt, we'll give up and commit
- // the resulting tree.
- expirationTime = expirationTime > Idle ? Idle : expirationTime;
- exitStatus = renderRootSync(root, expirationTime);
- }
+function workLoopConcurrent() {
+ // Perform work until Scheduler asks us to yield
+ while (workInProgress !== null && !shouldYield()) {
+ performUnitOfWork(workInProgress);
+ }
+}
- if (exitStatus === RootFatalErrored) {
- var fatalError = workInProgressRootFatalError;
- prepareFreshStack(root, expirationTime);
- markRootSuspendedAtTime(root, expirationTime);
- ensureRootIsScheduled(root);
- throw fatalError;
- } // We now have a consistent tree. The next step is either to commit it,
- // or, if something suspended, wait to commit it after a timeout.
+function performUnitOfWork(unitOfWork) {
+ // The current, flushed, state of this fiber is the alternate. Ideally
+ // nothing should rely on this, but relying on it here means that we don't
+ // need an additional field on the work in progress.
+ var current = unitOfWork.alternate;
+ setCurrentFiber(unitOfWork);
+ var next;
- var finishedWork = (root.finishedWork = root.current.alternate);
- root.finishedExpirationTime = expirationTime;
- finishConcurrentRender(root, finishedWork, exitStatus, expirationTime);
+ if ((unitOfWork.mode & ProfileMode) !== NoMode) {
+ startProfilerTimer(unitOfWork);
+ next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
+ stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
+ } else {
+ next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
}
- ensureRootIsScheduled(root);
+ resetCurrentFiber();
+ unitOfWork.memoizedProps = unitOfWork.pendingProps;
- if (root.callbackNode === originalCallbackNode) {
- // The task node scheduled for this root is the same one that's
- // currently executed. Need to return a continuation.
- return performConcurrentWorkOnRoot.bind(null, root);
+ if (next === null) {
+ // If this doesn't spawn new work, complete the current work.
+ completeUnitOfWork(unitOfWork);
+ } else {
+ workInProgress = next;
}
- return null;
+ ReactCurrentOwner$2.current = null;
}
-function finishConcurrentRender(
- root,
- finishedWork,
- exitStatus,
- expirationTime
-) {
- switch (exitStatus) {
- case RootIncomplete:
- case RootFatalErrored: {
- {
- throw Error("Root did not complete. This is a bug in React.");
- }
- }
- // Flow knows about invariant, so it complains if I add a break
- // statement, but eslint doesn't know about invariant, so it complains
- // if I do. eslint-disable-next-line no-fallthrough
+function completeUnitOfWork(unitOfWork) {
+ // Attempt to complete the current unit of work, then move to the next
+ // sibling. If there are no more siblings, return to the parent fiber.
+ var completedWork = unitOfWork;
- case RootErrored: {
- // We should have already attempted to retry this tree. If we reached
- // this point, it errored again. Commit it.
- commitRoot(root);
- break;
- }
+ do {
+ // The current, flushed, state of this fiber is the alternate. Ideally
+ // nothing should rely on this, but relying on it here means that we don't
+ // need an additional field on the work in progress.
+ var current = completedWork.alternate;
+ var returnFiber = completedWork.return; // Check if the work completed or if something threw.
- case RootSuspended: {
- markRootSuspendedAtTime(root, expirationTime);
- var lastSuspendedTime = root.lastSuspendedTime;
+ if ((completedWork.effectTag & Incomplete) === NoEffect) {
+ setCurrentFiber(completedWork);
+ var next = void 0;
- if (expirationTime === lastSuspendedTime) {
- root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
- } // We have an acceptable loading state. We need to figure out if we
- // should immediately commit it or wait a bit.
- // If we have processed new updates during this render, we may now
- // have a new loading state ready. We want to ensure that we commit
- // that as soon as possible.
+ if ((completedWork.mode & ProfileMode) === NoMode) {
+ next = completeWork(current, completedWork, subtreeRenderLanes);
+ } else {
+ startProfilerTimer(completedWork);
+ next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error.
+
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
+ }
+
+ resetCurrentFiber();
+
+ if (next !== null) {
+ // Completing this fiber spawned new work. Work on that next.
+ workInProgress = next;
+ return;
+ }
- var hasNotProcessedNewUpdates =
- workInProgressRootLatestProcessedExpirationTime === Sync;
+ resetChildLanes(completedWork);
if (
- hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
- !IsThisRendererActing.current
+ returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
+ (returnFiber.effectTag & Incomplete) === NoEffect
) {
- // If we have not processed any new updates during this pass, then
- // this is either a retry of an existing fallback state or a
- // hidden tree. Hidden trees shouldn't be batched with other work
- // and after that's fixed it can only be a retry. We're going to
- // throttle committing retries so that we don't show too many
- // loading states too quickly.
- var msUntilTimeout =
- globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
+ // Append all the effects of the subtree and this fiber onto the effect
+ // list of the parent. The completion order of the children affects the
+ // side-effect order.
+ if (returnFiber.firstEffect === null) {
+ returnFiber.firstEffect = completedWork.firstEffect;
+ }
- if (msUntilTimeout > 10) {
- if (workInProgressRootHasPendingPing) {
- var lastPingedTime = root.lastPingedTime;
-
- if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
- // This render was pinged but we didn't get to restart
- // earlier so try restarting now instead.
- root.lastPingedTime = expirationTime;
- prepareFreshStack(root, expirationTime);
- break;
- }
+ if (completedWork.lastEffect !== null) {
+ if (returnFiber.lastEffect !== null) {
+ returnFiber.lastEffect.nextEffect = completedWork.firstEffect;
}
- var nextTime = getNextRootExpirationTimeToWorkOn(root);
+ returnFiber.lastEffect = completedWork.lastEffect;
+ } // If this fiber had side-effects, we append it AFTER the children's
+ // side-effects. We can perform certain side-effects earlier if needed,
+ // by doing multiple passes over the effect list. We don't want to
+ // schedule our own side-effect on our own list because if end up
+ // reusing children we'll schedule this effect onto itself since we're
+ // at the end.
+
+ var effectTag = completedWork.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
+ // list. PerformedWork effect is read by React DevTools but shouldn't be
+ // committed.
- if (nextTime !== NoWork && nextTime !== expirationTime) {
- // There's additional work on this root.
- break;
+ if (effectTag > PerformedWork) {
+ if (returnFiber.lastEffect !== null) {
+ returnFiber.lastEffect.nextEffect = completedWork;
+ } else {
+ returnFiber.firstEffect = completedWork;
}
- if (
- lastSuspendedTime !== NoWork &&
- lastSuspendedTime !== expirationTime
- ) {
- // We should prefer to render the fallback of at the last
- // suspended level. Ping the last suspended level to try
- // rendering it again.
- root.lastPingedTime = lastSuspendedTime;
- break;
- } // The render is suspended, it hasn't timed out, and there's no
- // lower priority work to do. Instead of committing the fallback
- // immediately, wait for more data to arrive.
-
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- msUntilTimeout
- );
- break;
+ returnFiber.lastEffect = completedWork;
}
- } // The work expired. Commit immediately.
+ }
+ } else {
+ // This fiber did not complete because something threw. Pop values off
+ // the stack without entering the complete phase. If this is a boundary,
+ // capture values if possible.
+ var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time.
- commitRoot(root);
- break;
- }
+ if (_next !== null) {
+ // If completing this work spawned new work, do that next. We'll come
+ // back here again.
+ // Since we're restarting, remove anything that is not a host effect
+ // from the effect tag.
+ _next.effectTag &= HostEffectMask;
+ workInProgress = _next;
+ return;
+ }
- case RootSuspendedWithDelay: {
- markRootSuspendedAtTime(root, expirationTime);
- var _lastSuspendedTime = root.lastSuspendedTime;
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // Record the render duration for the fiber that errored.
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing.
- if (expirationTime === _lastSuspendedTime) {
- root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
- }
+ var actualDuration = completedWork.actualDuration;
+ var child = completedWork.child;
- {
- // We're suspended in a state that should be avoided. We'll try to
- // avoid committing it for as long as the timeouts let us.
- if (workInProgressRootHasPendingPing) {
- var _lastPingedTime = root.lastPingedTime;
-
- if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
- // This render was pinged but we didn't get to restart earlier
- // so try restarting now instead.
- root.lastPingedTime = expirationTime;
- prepareFreshStack(root, expirationTime);
- break;
- }
+ while (child !== null) {
+ actualDuration += child.actualDuration;
+ child = child.sibling;
}
- var _nextTime = getNextRootExpirationTimeToWorkOn(root);
+ completedWork.actualDuration = actualDuration;
+ }
- if (_nextTime !== NoWork && _nextTime !== expirationTime) {
- // There's additional work on this root.
- break;
- }
+ if (returnFiber !== null) {
+ // Mark the parent fiber as incomplete and clear its effect list.
+ returnFiber.firstEffect = returnFiber.lastEffect = null;
+ returnFiber.effectTag |= Incomplete;
+ }
+ }
- if (
- _lastSuspendedTime !== NoWork &&
- _lastSuspendedTime !== expirationTime
- ) {
- // We should prefer to render the fallback of at the last
- // suspended level. Ping the last suspended level to try
- // rendering it again.
- root.lastPingedTime = _lastSuspendedTime;
- break;
- }
+ var siblingFiber = completedWork.sibling;
- var _msUntilTimeout;
+ if (siblingFiber !== null) {
+ // If there is more work to do in this returnFiber, do that next.
+ workInProgress = siblingFiber;
+ return;
+ } // Otherwise, return to the parent
- if (workInProgressRootLatestSuspenseTimeout !== Sync) {
- // We have processed a suspense config whose expiration time we
- // can use as the timeout.
- _msUntilTimeout =
- expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
- } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
- // This should never normally happen because only new updates
- // cause delayed states, so we should have processed something.
- // However, this could also happen in an offscreen tree.
- _msUntilTimeout = 0;
- } else {
- // If we don't have a suspense config, we're going to use a
- // heuristic to determine how long we can suspend.
- var eventTimeMs = inferTimeFromExpirationTime(
- workInProgressRootLatestProcessedExpirationTime
- );
- var currentTimeMs = now();
- var timeUntilExpirationMs =
- expirationTimeToMs(expirationTime) - currentTimeMs;
- var timeElapsed = currentTimeMs - eventTimeMs;
-
- if (timeElapsed < 0) {
- // We get this wrong some time since we estimate the time.
- timeElapsed = 0;
- }
+ completedWork = returnFiber; // Update the next thing we're working on in case something throws.
- _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the
- // event time is exact instead of inferred from expiration time
- // we don't need this.
+ workInProgress = completedWork;
+ } while (completedWork !== null); // We've reached the root.
- if (timeUntilExpirationMs < _msUntilTimeout) {
- _msUntilTimeout = timeUntilExpirationMs;
- }
- } // Don't bother with a very short suspense time.
+ if (workInProgressRootExitStatus === RootIncomplete) {
+ workInProgressRootExitStatus = RootCompleted;
+ }
+}
- if (_msUntilTimeout > 10) {
- // The render is suspended, it hasn't timed out, and there's no
- // lower priority work to do. Instead of committing the fallback
- // immediately, wait for more data to arrive.
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- _msUntilTimeout
- );
- break;
- }
- } // The work expired. Commit immediately.
+function resetChildLanes(completedWork) {
+ if (
+ // TODO: Move this check out of the hot path by moving `resetChildLanes`
+ // to switch statement in `completeWork`.
+ (completedWork.tag === LegacyHiddenComponent ||
+ completedWork.tag === OffscreenComponent) &&
+ completedWork.memoizedState !== null &&
+ !includesSomeLane(subtreeRenderLanes, OffscreenLane) &&
+ (completedWork.mode & ConcurrentMode) !== NoLanes
+ ) {
+ // The children of this component are hidden. Don't bubble their
+ // expiration times.
+ return;
+ }
- commitRoot(root);
- break;
- }
+ var newChildLanes = NoLanes; // Bubble up the earliest expiration time.
- case RootCompleted: {
- // The work completed. Ready to commit.
- if (
- // do not delay if we're inside an act() scope
- workInProgressRootLatestProcessedExpirationTime !== Sync &&
- workInProgressRootCanSuspendUsingConfig !== null
- ) {
- // If we have exceeded the minimum loading delay, which probably
- // means we have shown a spinner already, we might have to suspend
- // a bit longer to ensure that the spinner is shown for
- // enough time.
- var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(
- workInProgressRootLatestProcessedExpirationTime,
- expirationTime,
- workInProgressRootCanSuspendUsingConfig
- );
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // In profiling mode, resetChildExpirationTime is also used to reset
+ // profiler durations.
+ var actualDuration = completedWork.actualDuration;
+ var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
+ // only be updated if work is done on the fiber (i.e. it doesn't bailout).
+ // When work is done, it should bubble to the parent's actualDuration. If
+ // the fiber has not been cloned though, (meaning no work was done), then
+ // this value will reflect the amount of time spent working on a previous
+ // render. In that case it should not bubble. We determine whether it was
+ // cloned by comparing the child pointer.
- if (_msUntilTimeout2 > 10) {
- markRootSuspendedAtTime(root, expirationTime);
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- _msUntilTimeout2
- );
- break;
- }
- }
+ var shouldBubbleActualDurations =
+ completedWork.alternate === null ||
+ completedWork.child !== completedWork.alternate.child;
+ var child = completedWork.child;
- commitRoot(root);
- break;
- }
+ while (child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(child.lanes, child.childLanes)
+ );
- default: {
- {
- throw Error("Unknown root exit status.");
+ if (shouldBubbleActualDurations) {
+ actualDuration += child.actualDuration;
}
+
+ treeBaseDuration += child.treeBaseDuration;
+ child = child.sibling;
}
- }
-} // This is the entry point for synchronous tasks that don't go
-// through Scheduler
-function performSyncWorkOnRoot(root) {
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
- }
+ var isTimedOutSuspense =
+ completedWork.tag === SuspenseComponent &&
+ completedWork.memoizedState !== null;
- flushPassiveEffects();
- var lastExpiredTime = root.lastExpiredTime;
- var expirationTime;
+ if (isTimedOutSuspense) {
+ // Don't count time spent in a timed out Suspense subtree as part of the base duration.
+ var primaryChildFragment = completedWork.child;
- if (lastExpiredTime !== NoWork) {
- // There's expired work on this root. Check if we have a partial tree
- // that we can reuse.
- if (
- root === workInProgressRoot &&
- renderExpirationTime$1 >= lastExpiredTime
- ) {
- // There's a partial tree with equal or greater than priority than the
- // expired level. Finish rendering it before rendering the rest of the
- // expired work.
- expirationTime = renderExpirationTime$1;
- } else {
- // Start a fresh tree.
- expirationTime = lastExpiredTime;
+ if (primaryChildFragment !== null) {
+ treeBaseDuration -= primaryChildFragment.treeBaseDuration;
+ }
}
- } else {
- // There's no expired work. This must be a new, synchronous render.
- expirationTime = Sync;
- }
- var exitStatus = renderRootSync(root, expirationTime);
+ completedWork.actualDuration = actualDuration;
+ completedWork.treeBaseDuration = treeBaseDuration;
+ } else {
+ var _child = completedWork.child;
- if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
- // If something threw an error, try rendering one more time. We'll
- // render synchronously to block concurrent data mutations, and we'll
- // render at Idle (or lower) so that all pending updates are included.
- // If it still fails after the second attempt, we'll give up and commit
- // the resulting tree.
- expirationTime = expirationTime > Idle ? Idle : expirationTime;
- exitStatus = renderRootSync(root, expirationTime);
+ while (_child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child.lanes, _child.childLanes)
+ );
+ _child = _child.sibling;
+ }
}
- if (exitStatus === RootFatalErrored) {
- var fatalError = workInProgressRootFatalError;
- prepareFreshStack(root, expirationTime);
- markRootSuspendedAtTime(root, expirationTime);
- ensureRootIsScheduled(root);
- throw fatalError;
- } // We now have a consistent tree. Because this is a sync render, we
- // will commit it even if something suspended.
-
- root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = expirationTime;
- commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next
- // pending level.
+ completedWork.childLanes = newChildLanes;
+}
- ensureRootIsScheduled(root);
+function commitRoot(root) {
+ var renderPriorityLevel = getCurrentPriorityLevel();
+ runWithPriority(
+ ImmediatePriority$1,
+ commitRootImpl.bind(null, root, renderPriorityLevel)
+ );
return null;
}
-function syncUpdates(fn, a, b, c) {
- return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c));
-}
-function batchedUpdates$1(fn, a) {
- var prevExecutionContext = executionContext;
- executionContext |= BatchedContext;
+function commitRootImpl(root, renderPriorityLevel) {
+ do {
+ // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
+ // means `flushPassiveEffects` will sometimes result in additional
+ // passive effects. So we need to keep flushing in a loop until there are
+ // no more pending effects.
+ // TODO: Might be better if `flushPassiveEffects` did not automatically
+ // flush synchronous work at the end, to avoid factoring hazards like this.
+ flushPassiveEffects();
+ } while (rootWithPendingPassiveEffects !== null);
- try {
- return fn(a);
- } finally {
- executionContext = prevExecutionContext;
+ flushRenderPhaseStrictModeWarningsInDEV();
- if (executionContext === NoContext) {
- // Flush the immediate callbacks that were scheduled during this batch
- flushSyncCallbackQueue();
- }
- }
-}
-function flushSync(fn, a) {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
- {
- throw Error(
- "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering."
- );
- }
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Should not already be working.");
}
- var prevExecutionContext = executionContext;
- executionContext |= BatchedContext;
-
- try {
- return runWithPriority(ImmediatePriority, fn.bind(null, a));
- } finally {
- executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
- // Note that this will happen even if batchedUpdates is higher up
- // the stack.
+ var finishedWork = root.finishedWork;
+ var lanes = root.finishedLanes;
- flushSyncCallbackQueue();
+ if (finishedWork === null) {
+ return null;
}
-}
-function prepareFreshStack(root, expirationTime) {
root.finishedWork = null;
- root.finishedExpirationTime = NoWork;
- var timeoutHandle = root.timeoutHandle;
+ root.finishedLanes = NoLanes;
- if (timeoutHandle !== noTimeout) {
- // The root previous suspended and scheduled a timeout to commit a fallback
- // state. Now that we have additional work, cancel the timeout.
- root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
+ if (!(finishedWork !== root.current)) {
+ throw Error(
+ "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
+ );
+ } // commitRoot never returns a continuation; it always finishes synchronously.
+ // So we can clear these now to allow a new callback to be scheduled.
- cancelTimeout(timeoutHandle);
- }
+ root.callbackNode = null; // Update the first and last pending times on this root. The new first
+ // pending time is whatever is left on the root fiber.
- if (workInProgress !== null) {
- var interruptedWork = workInProgress.return;
+ var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes);
+ markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of
+ // `flushDiscreteUpdates` starts a useless render pass which may cancels
+ // a scheduled timeout.
- while (interruptedWork !== null) {
- unwindInterruptedWork(interruptedWork);
- interruptedWork = interruptedWork.return;
+ if (rootsWithPendingDiscreteUpdates !== null) {
+ if (
+ !hasDiscreteLanes(remainingLanes) &&
+ rootsWithPendingDiscreteUpdates.has(root)
+ ) {
+ rootsWithPendingDiscreteUpdates.delete(root);
}
}
- workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
- renderExpirationTime$1 = expirationTime;
- workInProgressRootExitStatus = RootIncomplete;
- workInProgressRootFatalError = null;
- workInProgressRootLatestProcessedExpirationTime = Sync;
- workInProgressRootLatestSuspenseTimeout = Sync;
- workInProgressRootCanSuspendUsingConfig = null;
- workInProgressRootNextUnprocessedUpdateTime = NoWork;
- workInProgressRootHasPendingPing = false;
+ if (root === workInProgressRoot) {
+ // We can reset these now that they are finished.
+ workInProgressRoot = null;
+ workInProgress = null;
+ workInProgressRootRenderLanes = NoLanes;
+ } // This indicates that the last root we worked on is not the same one that
+ // we're committing now. This most commonly happens when a suspended root
+ // times out.
+ // Get the list of effects.
- {
- spawnedWorkDuringRender = null;
- }
+ var firstEffect;
- {
- ReactStrictModeWarnings.discardPendingWarnings();
+ if (finishedWork.effectTag > PerformedWork) {
+ // A fiber's effect list consists only of its children, not itself. So if
+ // the root has an effect, we need to add it to the end of the list. The
+ // resulting list is the set that would belong to the root's parent, if it
+ // had one; that is, all the effects in the tree including the root.
+ if (finishedWork.lastEffect !== null) {
+ finishedWork.lastEffect.nextEffect = finishedWork;
+ firstEffect = finishedWork.firstEffect;
+ } else {
+ firstEffect = finishedWork;
+ }
+ } else {
+ // There is no effect on the root.
+ firstEffect = finishedWork.firstEffect;
}
-}
-function handleError(root, thrownValue) {
- do {
- try {
- // Reset module-level state that was set during the render phase.
- resetContextDependencies();
- resetHooksAfterThrow();
- resetCurrentFiber();
+ if (firstEffect !== null) {
+ var prevExecutionContext = executionContext;
+ executionContext |= CommitContext;
+ var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
- if (workInProgress === null || workInProgress.return === null) {
- // Expected to be working on a non-root fiber. This is a fatal error
- // because there's no ancestor that can handle it; the root is
- // supposed to capture all errors that weren't caught by an error
- // boundary.
- workInProgressRootExitStatus = RootFatalErrored;
- workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next
- // sibling, or the parent if there are no siblings. But since the root
- // has no siblings nor a parent, we set it to null. Usually this is
- // handled by `completeUnitOfWork` or `unwindWork`, but since we're
- // interntionally not calling those, we need set it here.
- // TODO: Consider calling `unwindWork` to pop the contexts.
+ ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
+ // of the effect list for each phase: all mutation effects come before all
+ // layout effects, and so on.
+ // The first phase a "before mutation" phase. We use this phase to read the
+ // state of the host tree right before we mutate it. This is where
+ // getSnapshotBeforeUpdate is called.
- workInProgress = null;
- return null;
+ focusedInstanceHandle = prepareForCommit(root.containerInfo);
+ shouldFireAfterActiveInstanceBlur = false;
+ nextEffect = firstEffect;
+
+ do {
+ {
+ invokeGuardedCallback(null, commitBeforeMutationEffects, null);
+
+ if (hasCaughtError()) {
+ if (!(nextEffect !== null)) {
+ throw Error("Should be working on an effect.");
+ }
+
+ var error = clearCaughtError();
+ captureCommitPhaseError(nextEffect, error);
+ nextEffect = nextEffect.nextEffect;
+ }
}
+ } while (nextEffect !== null); // We no longer need to track the active instance fiber
- if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
- // Record the time spent rendering before an error was thrown. This
- // avoids inaccurate Profiler durations in the case of a
- // suspended render.
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
+ focusedInstanceHandle = null;
+
+ {
+ // Mark the current commit time to be shared by all Profilers in this
+ // batch. This enables them to be grouped later.
+ recordCommitTime();
+ } // The next phase is the mutation phase, where we mutate the host tree.
+
+ nextEffect = firstEffect;
+
+ do {
+ {
+ invokeGuardedCallback(
+ null,
+ commitMutationEffects,
+ null,
+ root,
+ renderPriorityLevel
+ );
+
+ if (hasCaughtError()) {
+ if (!(nextEffect !== null)) {
+ throw Error("Should be working on an effect.");
+ }
+
+ var _error = clearCaughtError();
+
+ captureCommitPhaseError(nextEffect, _error);
+ nextEffect = nextEffect.nextEffect;
+ }
}
+ } while (nextEffect !== null);
+
+ resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
+ // the mutation phase, so that the previous tree is still current during
+ // componentWillUnmount, but before the layout phase, so that the finished
+ // work is current during componentDidMount/Update.
+
+ root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
+ // the host tree after it's been mutated. The idiomatic use case for this is
+ // layout, but class component lifecycles also fire here for legacy reasons.
- throwException(
- root,
- workInProgress.return,
- workInProgress,
- thrownValue,
- renderExpirationTime$1
- );
- workInProgress = completeUnitOfWork(workInProgress);
- } catch (yetAnotherThrownValue) {
- // Something in the return path also threw.
- thrownValue = yetAnotherThrownValue;
- continue;
- } // Return to the normal work loop.
+ nextEffect = firstEffect;
- return;
- } while (true);
-}
+ do {
+ {
+ invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes);
-function pushDispatcher(root) {
- var prevDispatcher = ReactCurrentDispatcher$1.current;
- ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ if (hasCaughtError()) {
+ if (!(nextEffect !== null)) {
+ throw Error("Should be working on an effect.");
+ }
- if (prevDispatcher === null) {
- // The React isomorphic package does not include a default dispatcher.
- // Instead the first renderer will lazily attach one, in order to give
- // nicer error messages.
- return ContextOnlyDispatcher;
- } else {
- return prevDispatcher;
- }
-}
+ var _error2 = clearCaughtError();
-function popDispatcher(prevDispatcher) {
- ReactCurrentDispatcher$1.current = prevDispatcher;
-}
+ captureCommitPhaseError(nextEffect, _error2);
+ nextEffect = nextEffect.nextEffect;
+ }
+ }
+ } while (nextEffect !== null);
-function pushInteractions(root) {
- {
- var prevInteractions = tracing.__interactionsRef.current;
- tracing.__interactionsRef.current = root.memoizedInteractions;
- return prevInteractions;
- }
-}
+ nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
+ // opportunity to paint.
-function popInteractions(prevInteractions) {
- {
- tracing.__interactionsRef.current = prevInteractions;
- }
-}
+ requestPaint();
-function markCommitTimeOfFallback() {
- globalMostRecentFallbackTime = now();
-}
-function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
- if (
- expirationTime < workInProgressRootLatestProcessedExpirationTime &&
- expirationTime > Idle
- ) {
- workInProgressRootLatestProcessedExpirationTime = expirationTime;
- }
+ {
+ popInteractions(prevInteractions);
+ }
- if (suspenseConfig !== null) {
- if (
- expirationTime < workInProgressRootLatestSuspenseTimeout &&
- expirationTime > Idle
- ) {
- workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad.
+ executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value.
+ } else {
+ // No effects.
+ root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
+ // no effects.
+ // TODO: Maybe there's a better way to report this.
- workInProgressRootCanSuspendUsingConfig = suspenseConfig;
+ {
+ recordCommitTime();
}
}
-}
-function markUnprocessedUpdateTime(expirationTime) {
- if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
- workInProgressRootNextUnprocessedUpdateTime = expirationTime;
- }
-}
-function renderDidSuspend() {
- if (workInProgressRootExitStatus === RootIncomplete) {
- workInProgressRootExitStatus = RootSuspended;
- }
-}
-function renderDidSuspendDelayIfPossible() {
- if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
- ) {
- workInProgressRootExitStatus = RootSuspendedWithDelay;
- } // Check if there's a lower priority update somewhere else in the tree.
- if (
- workInProgressRootNextUnprocessedUpdateTime !== NoWork &&
- workInProgressRoot !== null
- ) {
- // Mark the current render as suspended, and then mark that there's a
- // pending update.
- // TODO: This should immediately interrupt the current render, instead
- // of waiting until the next time we yield.
- markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1);
- markRootUpdatedAtTime(
- workInProgressRoot,
- workInProgressRootNextUnprocessedUpdateTime
- );
- }
-}
-function renderDidError() {
- if (workInProgressRootExitStatus !== RootCompleted) {
- workInProgressRootExitStatus = RootErrored;
- }
-} // Called during render to determine if anything has suspended.
-// Returns false if we're not sure.
+ var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
-function renderHasNotSuspendedYet() {
- // If something errored or completed, we can't really be sure,
- // so those are false.
- return workInProgressRootExitStatus === RootIncomplete;
-}
+ if (rootDoesHavePassiveEffects) {
+ // This commit has passive effects. Stash a reference to them. But don't
+ // schedule a callback until after flushing layout work.
+ rootDoesHavePassiveEffects = false;
+ rootWithPendingPassiveEffects = root;
+ pendingPassiveEffectsLanes = lanes;
+ pendingPassiveEffectsRenderPriority = renderPriorityLevel;
+ } else {
+ // We are done with the effect chain at this point so let's clear the
+ // nextEffect pointers to assist with GC. If we have passive effects, we'll
+ // clear this in flushPassiveEffects.
+ nextEffect = firstEffect;
-function inferTimeFromExpirationTime(expirationTime) {
- // We don't know exactly when the update was scheduled, but we can infer an
- // approximate start time from the expiration time.
- var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
- return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
-}
+ while (nextEffect !== null) {
+ var nextNextEffect = nextEffect.nextEffect;
+ nextEffect.nextEffect = null;
-function inferTimeFromExpirationTimeWithSuspenseConfig(
- expirationTime,
- suspenseConfig
-) {
- // We don't know exactly when the update was scheduled, but we can infer an
- // approximate start time from the expiration time by subtracting the timeout
- // that was added to the event time.
- var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
- return (
- earliestExpirationTimeMs -
- (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION)
- );
-}
+ if (nextEffect.effectTag & Deletion) {
+ detachFiberAfterEffects(nextEffect);
+ }
-function renderRootSync(root, expirationTime) {
- var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
- var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack
- // and prepare a fresh one. Otherwise we'll continue where we left off.
+ nextEffect = nextNextEffect;
+ }
+ } // Read this again, since an effect might have updated it
- if (
- root !== workInProgressRoot ||
- expirationTime !== renderExpirationTime$1
- ) {
- prepareFreshStack(root, expirationTime);
- startWorkOnPendingInteractions(root, expirationTime);
- }
+ remainingLanes = root.pendingLanes; // Check if there's remaining work on this root
- var prevInteractions = pushInteractions(root);
- startWorkLoopTimer(workInProgress);
+ if (remainingLanes !== NoLanes) {
+ {
+ if (spawnedWorkDuringRender !== null) {
+ var expirationTimes = spawnedWorkDuringRender;
+ spawnedWorkDuringRender = null;
- do {
- try {
- workLoopSync();
- break;
- } catch (thrownValue) {
- handleError(root, thrownValue);
- }
- } while (true);
+ for (var i = 0; i < expirationTimes.length; i++) {
+ scheduleInteractions(
+ root,
+ expirationTimes[i],
+ root.memoizedInteractions
+ );
+ }
+ }
- resetContextDependencies();
+ schedulePendingInteractions(root, remainingLanes);
+ }
+ } else {
+ // If there's no remaining work, we can clear the set of already failed
+ // error boundaries.
+ legacyErrorBoundariesThatAlreadyFailed = null;
+ }
{
- popInteractions(prevInteractions);
+ if (!rootDidHavePassiveEffects) {
+ // If there are no passive effects, then we can complete the pending interactions.
+ // Otherwise, we'll wait until after the passive effects are flushed.
+ // Wait to do this until after remaining work has been scheduled,
+ // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
+ finishPendingInteractions(root, lanes);
+ }
}
- executionContext = prevExecutionContext;
- popDispatcher(prevDispatcher);
-
- if (workInProgress !== null) {
- // This is a sync render, so we should have finished the whole tree.
- {
- throw Error(
- "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
- );
+ if (remainingLanes === SyncLane) {
+ // Count the number of times the root synchronously re-renders without
+ // finishing. If there are too many, it indicates an infinite update loop.
+ if (root === rootWithNestedUpdates) {
+ nestedUpdateCount++;
+ } else {
+ nestedUpdateCount = 0;
+ rootWithNestedUpdates = root;
}
+ } else {
+ nestedUpdateCount = 0;
}
- stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render.
-
- workInProgressRoot = null;
- return workInProgressRootExitStatus;
-} // The work loop is an extremely hot path. Tell Closure not to inline it.
+ onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
+ // additional work on this root is scheduled.
-/** @noinline */
+ ensureRootIsScheduled(root, now());
-function workLoopSync() {
- // Already timed out, so perform work without checking if we need to yield.
- while (workInProgress !== null) {
- workInProgress = performUnitOfWork(workInProgress);
+ if (hasUncaughtError) {
+ hasUncaughtError = false;
+ var _error3 = firstUncaughtError;
+ firstUncaughtError = null;
+ throw _error3;
}
-}
-
-function renderRootConcurrent(root, expirationTime) {
- var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
- var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack
- // and prepare a fresh one. Otherwise we'll continue where we left off.
- if (
- root !== workInProgressRoot ||
- expirationTime !== renderExpirationTime$1
- ) {
- prepareFreshStack(root, expirationTime);
- startWorkOnPendingInteractions(root, expirationTime);
- }
+ if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
+ // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
+ // synchronously, but layout updates should be deferred until the end
+ // of the batch.
- var prevInteractions = pushInteractions(root);
- startWorkLoopTimer(workInProgress);
+ return null;
+ } // If layout work was scheduled, flush it now.
- do {
- try {
- workLoopConcurrent();
- break;
- } catch (thrownValue) {
- handleError(root, thrownValue);
- }
- } while (true);
+ flushSyncCallbackQueue();
- resetContextDependencies();
+ return null;
+}
- {
- popInteractions(prevInteractions);
- }
+function commitBeforeMutationEffects() {
+ while (nextEffect !== null) {
+ var current = nextEffect.alternate;
- popDispatcher(prevDispatcher);
- executionContext = prevExecutionContext; // Check if the tree has completed.
+ if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) {
+ if ((nextEffect.effectTag & Deletion) !== NoEffect) {
+ if (doesFiberContain(nextEffect, focusedInstanceHandle)) {
+ shouldFireAfterActiveInstanceBlur = true;
+ }
+ } else {
+ // TODO: Move this out of the hot path using a dedicated effect tag.
+ if (
+ nextEffect.tag === SuspenseComponent &&
+ isSuspenseBoundaryBeingHidden(current, nextEffect) &&
+ doesFiberContain(nextEffect, focusedInstanceHandle)
+ ) {
+ shouldFireAfterActiveInstanceBlur = true;
+ }
+ }
+ }
- if (workInProgress !== null) {
- // Still work remaining.
- stopInterruptedWorkLoopTimer();
- return RootIncomplete;
- } else {
- // Completed the tree.
- stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render.
+ var effectTag = nextEffect.effectTag;
- workInProgressRoot = null; // Return the final exit status.
+ if ((effectTag & Snapshot) !== NoEffect) {
+ setCurrentFiber(nextEffect);
+ commitBeforeMutationLifeCycles(current, nextEffect);
+ resetCurrentFiber();
+ }
- return workInProgressRootExitStatus;
- }
-}
-/** @noinline */
+ if ((effectTag & Passive) !== NoEffect) {
+ // If there are passive effects, schedule a callback to flush at
+ // the earliest opportunity.
+ if (!rootDoesHavePassiveEffects) {
+ rootDoesHavePassiveEffects = true;
+ scheduleCallback(NormalPriority$1, function() {
+ flushPassiveEffects();
+ return null;
+ });
+ }
+ }
-function workLoopConcurrent() {
- // Perform work until Scheduler asks us to yield
- while (workInProgress !== null && !shouldYield()) {
- workInProgress = performUnitOfWork(workInProgress);
+ nextEffect = nextEffect.nextEffect;
}
}
-function performUnitOfWork(unitOfWork) {
- // The current, flushed, state of this fiber is the alternate. Ideally
- // nothing should rely on this, but relying on it here means that we don't
- // need an additional field on the work in progress.
- var current = unitOfWork.alternate;
- startWorkTimer(unitOfWork);
- setCurrentFiber(unitOfWork);
- var next;
+function commitMutationEffects(root, renderPriorityLevel) {
+ // TODO: Should probably move the bulk of this function to commitWork.
+ while (nextEffect !== null) {
+ setCurrentFiber(nextEffect);
+ var effectTag = nextEffect.effectTag;
- if ((unitOfWork.mode & ProfileMode) !== NoMode) {
- startProfilerTimer(unitOfWork);
- next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
- stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
- } else {
- next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
- }
+ if (effectTag & ContentReset) {
+ commitResetTextContent(nextEffect);
+ }
- resetCurrentFiber();
- unitOfWork.memoizedProps = unitOfWork.pendingProps;
+ if (effectTag & Ref) {
+ var current = nextEffect.alternate;
- if (next === null) {
- // If this doesn't spawn new work, complete the current work.
- next = completeUnitOfWork(unitOfWork);
- }
+ if (current !== null) {
+ commitDetachRef(current);
+ }
+ } // The following switch statement is only concerned about placement,
+ // updates, and deletions. To avoid needing to add a case for every possible
+ // bitmap value, we remove the secondary effects from the effect tag and
+ // switch on that value.
- ReactCurrentOwner$2.current = null;
- return next;
-}
+ var primaryEffectTag =
+ effectTag & (Placement | Update | Deletion | Hydrating);
-function completeUnitOfWork(unitOfWork) {
- // Attempt to complete the current unit of work, then move to the next
- // sibling. If there are no more siblings, return to the parent fiber.
- workInProgress = unitOfWork;
+ switch (primaryEffectTag) {
+ case Placement: {
+ commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
+ // inserted, before any life-cycles like componentDidMount gets called.
+ // TODO: findDOMNode doesn't rely on this any more but isMounted does
+ // and isMounted is deprecated anyway so we should be able to kill this.
- do {
- // The current, flushed, state of this fiber is the alternate. Ideally
- // nothing should rely on this, but relying on it here means that we don't
- // need an additional field on the work in progress.
- var current = workInProgress.alternate;
- var returnFiber = workInProgress.return; // Check if the work completed or if something threw.
+ nextEffect.effectTag &= ~Placement;
+ break;
+ }
- if ((workInProgress.effectTag & Incomplete) === NoEffect) {
- setCurrentFiber(workInProgress);
- var next = void 0;
+ case PlacementAndUpdate: {
+ // Placement
+ commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
+ // inserted, before any life-cycles like componentDidMount gets called.
- if ((workInProgress.mode & ProfileMode) === NoMode) {
- next = completeWork(current, workInProgress, renderExpirationTime$1);
- } else {
- startProfilerTimer(workInProgress);
- next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error.
+ nextEffect.effectTag &= ~Placement; // Update
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
+ var _current = nextEffect.alternate;
+ commitWork(_current, nextEffect);
+ break;
}
- stopWorkTimer(workInProgress);
- resetCurrentFiber();
- resetChildExpirationTime(workInProgress);
-
- if (next !== null) {
- // Completing this fiber spawned new work. Work on that next.
- return next;
+ case Hydrating: {
+ nextEffect.effectTag &= ~Hydrating;
+ break;
}
- if (
- returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
- (returnFiber.effectTag & Incomplete) === NoEffect
- ) {
- // Append all the effects of the subtree and this fiber onto the effect
- // list of the parent. The completion order of the children affects the
- // side-effect order.
- if (returnFiber.firstEffect === null) {
- returnFiber.firstEffect = workInProgress.firstEffect;
- }
-
- if (workInProgress.lastEffect !== null) {
- if (returnFiber.lastEffect !== null) {
- returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
- }
-
- returnFiber.lastEffect = workInProgress.lastEffect;
- } // If this fiber had side-effects, we append it AFTER the children's
- // side-effects. We can perform certain side-effects earlier if needed,
- // by doing multiple passes over the effect list. We don't want to
- // schedule our own side-effect on our own list because if end up
- // reusing children we'll schedule this effect onto itself since we're
- // at the end.
+ case HydratingAndUpdate: {
+ nextEffect.effectTag &= ~Hydrating; // Update
- var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
- // list. PerformedWork effect is read by React DevTools but shouldn't be
- // committed.
+ var _current2 = nextEffect.alternate;
+ commitWork(_current2, nextEffect);
+ break;
+ }
- if (effectTag > PerformedWork) {
- if (returnFiber.lastEffect !== null) {
- returnFiber.lastEffect.nextEffect = workInProgress;
- } else {
- returnFiber.firstEffect = workInProgress;
- }
+ case Update: {
+ var _current3 = nextEffect.alternate;
+ commitWork(_current3, nextEffect);
+ break;
+ }
- returnFiber.lastEffect = workInProgress;
- }
+ case Deletion: {
+ commitDeletion(root, nextEffect);
+ break;
}
- } else {
- // This fiber did not complete because something threw. Pop values off
- // the stack without entering the complete phase. If this is a boundary,
- // capture values if possible.
- var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time.
+ }
- if ((workInProgress.mode & ProfileMode) !== NoMode) {
- // Record the render duration for the fiber that errored.
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing.
+ resetCurrentFiber();
+ nextEffect = nextEffect.nextEffect;
+ }
+}
- var actualDuration = workInProgress.actualDuration;
- var child = workInProgress.child;
+function commitLayoutEffects(root, committedLanes) {
+ while (nextEffect !== null) {
+ setCurrentFiber(nextEffect);
+ var effectTag = nextEffect.effectTag;
- while (child !== null) {
- actualDuration += child.actualDuration;
- child = child.sibling;
- }
+ if (effectTag & (Update | Callback)) {
+ var current = nextEffect.alternate;
+ commitLifeCycles(root, current, nextEffect);
+ }
- workInProgress.actualDuration = actualDuration;
+ {
+ if (effectTag & Ref) {
+ commitAttachRef(nextEffect);
}
+ }
- if (_next !== null) {
- // If completing this work spawned new work, do that next. We'll come
- // back here again.
- // Since we're restarting, remove anything that is not a host effect
- // from the effect tag.
- // TODO: The name stopFailedWorkTimer is misleading because Suspense
- // also captures and restarts.
- stopFailedWorkTimer(workInProgress);
- _next.effectTag &= HostEffectMask;
- return _next;
- }
+ resetCurrentFiber();
+ nextEffect = nextEffect.nextEffect;
+ }
+}
- stopWorkTimer(workInProgress);
+function flushPassiveEffects() {
+ // Returns whether passive effects were flushed.
+ if (pendingPassiveEffectsRenderPriority !== NoPriority$1) {
+ var priorityLevel =
+ pendingPassiveEffectsRenderPriority > NormalPriority$1
+ ? NormalPriority$1
+ : pendingPassiveEffectsRenderPriority;
+ pendingPassiveEffectsRenderPriority = NoPriority$1;
- if (returnFiber !== null) {
- // Mark the parent fiber as incomplete and clear its effect list.
- returnFiber.firstEffect = returnFiber.lastEffect = null;
- returnFiber.effectTag |= Incomplete;
- }
+ try {
+ setCurrentUpdateLanePriority(
+ schedulerPriorityToLanePriority(priorityLevel)
+ );
+ return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
+ } finally {
}
+ }
- var siblingFiber = workInProgress.sibling;
+ return false;
+}
+function enqueuePendingPassiveHookEffectMount(fiber, effect) {
+ pendingPassiveHookEffectsMount.push(effect, fiber);
- if (siblingFiber !== null) {
- // If there is more work to do in this returnFiber, do that next.
- return siblingFiber;
- } // Otherwise, return to the parent
+ if (!rootDoesHavePassiveEffects) {
+ rootDoesHavePassiveEffects = true;
+ scheduleCallback(NormalPriority$1, function() {
+ flushPassiveEffects();
+ return null;
+ });
+ }
+}
+function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
+ pendingPassiveHookEffectsUnmount.push(effect, fiber);
- workInProgress = returnFiber;
- } while (workInProgress !== null); // We've reached the root.
+ {
+ fiber.effectTag |= PassiveUnmountPendingDev;
+ var alternate = fiber.alternate;
- if (workInProgressRootExitStatus === RootIncomplete) {
- workInProgressRootExitStatus = RootCompleted;
+ if (alternate !== null) {
+ alternate.effectTag |= PassiveUnmountPendingDev;
+ }
}
- return null;
+ if (!rootDoesHavePassiveEffects) {
+ rootDoesHavePassiveEffects = true;
+ scheduleCallback(NormalPriority$1, function() {
+ flushPassiveEffects();
+ return null;
+ });
+ }
}
-function getRemainingExpirationTime(fiber) {
- var updateExpirationTime = fiber.expirationTime;
- var childExpirationTime = fiber.childExpirationTime;
- return updateExpirationTime > childExpirationTime
- ? updateExpirationTime
- : childExpirationTime;
+function invokePassiveEffectCreate(effect) {
+ var create = effect.create;
+ effect.destroy = create();
}
-function resetChildExpirationTime(completedWork) {
- if (
- renderExpirationTime$1 !== Never &&
- completedWork.childExpirationTime === Never
- ) {
- // The children of this component are hidden. Don't bubble their
- // expiration times.
- return;
+function flushPassiveEffectsImpl() {
+ if (rootWithPendingPassiveEffects === null) {
+ return false;
}
- var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time.
+ var root = rootWithPendingPassiveEffects;
+ var lanes = pendingPassiveEffectsLanes;
+ rootWithPendingPassiveEffects = null;
+ pendingPassiveEffectsLanes = NoLanes;
- if ((completedWork.mode & ProfileMode) !== NoMode) {
- // In profiling mode, resetChildExpirationTime is also used to reset
- // profiler durations.
- var actualDuration = completedWork.actualDuration;
- var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
- // only be updated if work is done on the fiber (i.e. it doesn't bailout).
- // When work is done, it should bubble to the parent's actualDuration. If
- // the fiber has not been cloned though, (meaning no work was done), then
- // this value will reflect the amount of time spent working on a previous
- // render. In that case it should not bubble. We determine whether it was
- // cloned by comparing the child pointer.
+ if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
+ throw Error("Cannot flush passive effects while already rendering.");
+ }
- var shouldBubbleActualDurations =
- completedWork.alternate === null ||
- completedWork.child !== completedWork.alternate.child;
- var child = completedWork.child;
+ {
+ isFlushingPassiveEffects = true;
+ }
- while (child !== null) {
- var childUpdateExpirationTime = child.expirationTime;
- var childChildExpirationTime = child.childExpirationTime;
+ var prevExecutionContext = executionContext;
+ executionContext |= CommitContext;
+ var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called
+ // before ANY passive effect create functions are called.
+ // Otherwise effects in sibling components might interfere with each other.
+ // e.g. a destroy function in one component may unintentionally override a ref
+ // value set by a create function in another component.
+ // Layout effects have the same constraint.
+ // First pass: Destroy stale passive effects.
+
+ var unmountEffects = pendingPassiveHookEffectsUnmount;
+ pendingPassiveHookEffectsUnmount = [];
+
+ for (var i = 0; i < unmountEffects.length; i += 2) {
+ var _effect = unmountEffects[i];
+ var fiber = unmountEffects[i + 1];
+ var destroy = _effect.destroy;
+ _effect.destroy = undefined;
- if (childUpdateExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = childUpdateExpirationTime;
- }
+ {
+ fiber.effectTag &= ~PassiveUnmountPendingDev;
+ var alternate = fiber.alternate;
- if (childChildExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = childChildExpirationTime;
+ if (alternate !== null) {
+ alternate.effectTag &= ~PassiveUnmountPendingDev;
}
+ }
- if (shouldBubbleActualDurations) {
- actualDuration += child.actualDuration;
- }
+ if (typeof destroy === "function") {
+ {
+ setCurrentFiber(fiber);
- treeBaseDuration += child.treeBaseDuration;
- child = child.sibling;
+ {
+ invokeGuardedCallback(null, destroy, null);
+ }
+
+ if (hasCaughtError()) {
+ if (!(fiber !== null)) {
+ throw Error("Should be working on an effect.");
+ }
+
+ var error = clearCaughtError();
+ captureCommitPhaseError(fiber, error);
+ }
+
+ resetCurrentFiber();
+ }
}
+ } // Second pass: Create new passive effects.
- completedWork.actualDuration = actualDuration;
- completedWork.treeBaseDuration = treeBaseDuration;
- } else {
- var _child = completedWork.child;
+ var mountEffects = pendingPassiveHookEffectsMount;
+ pendingPassiveHookEffectsMount = [];
- while (_child !== null) {
- var _childUpdateExpirationTime = _child.expirationTime;
- var _childChildExpirationTime = _child.childExpirationTime;
+ for (var _i = 0; _i < mountEffects.length; _i += 2) {
+ var _effect2 = mountEffects[_i];
+ var _fiber = mountEffects[_i + 1];
+
+ {
+ setCurrentFiber(_fiber);
- if (_childUpdateExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = _childUpdateExpirationTime;
+ {
+ invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2);
}
- if (_childChildExpirationTime > newChildExpirationTime) {
- newChildExpirationTime = _childChildExpirationTime;
+ if (hasCaughtError()) {
+ if (!(_fiber !== null)) {
+ throw Error("Should be working on an effect.");
+ }
+
+ var _error4 = clearCaughtError();
+
+ captureCommitPhaseError(_fiber, _error4);
}
- _child = _child.sibling;
+ resetCurrentFiber();
}
- }
+ } // Note: This currently assumes there are no passive effects on the root fiber
+ // because the root is not part of its own effect list.
+ // This could change in the future.
- completedWork.childExpirationTime = newChildExpirationTime;
-}
+ var effect = root.current.firstEffect;
-function commitRoot(root) {
- var renderPriorityLevel = getCurrentPriorityLevel();
- runWithPriority(
- ImmediatePriority,
- commitRootImpl.bind(null, root, renderPriorityLevel)
- );
- return null;
-}
+ while (effect !== null) {
+ var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
-function commitRootImpl(root, renderPriorityLevel) {
- do {
- // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
- // means `flushPassiveEffects` will sometimes result in additional
- // passive effects. So we need to keep flushing in a loop until there are
- // no more pending effects.
- // TODO: Might be better if `flushPassiveEffects` did not automatically
- // flush synchronous work at the end, to avoid factoring hazards like this.
- flushPassiveEffects();
- } while (rootWithPendingPassiveEffects !== null);
+ effect.nextEffect = null;
- flushRenderPhaseStrictModeWarningsInDEV();
+ if (effect.effectTag & Deletion) {
+ detachFiberAfterEffects(effect);
+ }
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ effect = nextNextEffect;
}
- var finishedWork = root.finishedWork;
- var expirationTime = root.finishedExpirationTime;
-
- if (finishedWork === null) {
- return null;
+ {
+ popInteractions(prevInteractions);
+ finishPendingInteractions(root, lanes);
}
- root.finishedWork = null;
- root.finishedExpirationTime = NoWork;
+ {
+ isFlushingPassiveEffects = false;
+ }
- if (!(finishedWork !== root.current)) {
- throw Error(
- "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
- );
- } // commitRoot never returns a continuation; it always finishes synchronously.
- // So we can clear these now to allow a new callback to be scheduled.
+ executionContext = prevExecutionContext;
+ flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
+ // exceeds the limit, we'll fire a warning.
- root.callbackNode = null;
- root.callbackExpirationTime = NoWork;
- root.callbackPriority = NoPriority;
- root.nextKnownPendingLevel = NoWork;
- startCommitTimer(); // Update the first and last pending times on this root. The new first
- // pending time is whatever is left on the root fiber.
+ nestedPassiveUpdateCount =
+ rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
+ return true;
+}
- var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(
- finishedWork
- );
- markRootFinishedAtTime(
- root,
- expirationTime,
- remainingExpirationTimeBeforeCommit
+function isAlreadyFailedLegacyErrorBoundary(instance) {
+ return (
+ legacyErrorBoundariesThatAlreadyFailed !== null &&
+ legacyErrorBoundariesThatAlreadyFailed.has(instance)
);
+}
+function markLegacyErrorBoundaryAsFailed(instance) {
+ if (legacyErrorBoundariesThatAlreadyFailed === null) {
+ legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
+ } else {
+ legacyErrorBoundariesThatAlreadyFailed.add(instance);
+ }
+}
- if (root === workInProgressRoot) {
- // We can reset these now that they are finished.
- workInProgressRoot = null;
- workInProgress = null;
- renderExpirationTime$1 = NoWork;
- } // This indicates that the last root we worked on is not the same one that
- // we're committing now. This most commonly happens when a suspended root
- // times out.
- // Get the list of effects.
+function prepareToThrowUncaughtError(error) {
+ if (!hasUncaughtError) {
+ hasUncaughtError = true;
+ firstUncaughtError = error;
+ }
+}
- var firstEffect;
+var onUncaughtError = prepareToThrowUncaughtError;
- if (finishedWork.effectTag > PerformedWork) {
- // A fiber's effect list consists only of its children, not itself. So if
- // the root has an effect, we need to add it to the end of the list. The
- // resulting list is the set that would belong to the root's parent, if it
- // had one; that is, all the effects in the tree including the root.
- if (finishedWork.lastEffect !== null) {
- finishedWork.lastEffect.nextEffect = finishedWork;
- firstEffect = finishedWork.firstEffect;
- } else {
- firstEffect = finishedWork;
- }
- } else {
- // There is no effect on the root.
- firstEffect = finishedWork.firstEffect;
- }
+function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
+ var errorInfo = createCapturedValue(error, sourceFiber);
+ var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane);
+ enqueueUpdate(rootFiber, update);
+ var eventTime = requestEventTime();
+ var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane);
- if (firstEffect !== null) {
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
+ if (root !== null) {
+ markRootUpdated(root, SyncLane, eventTime);
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, SyncLane);
+ }
+}
- ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
- // of the effect list for each phase: all mutation effects come before all
- // layout effects, and so on.
- // The first phase a "before mutation" phase. We use this phase to read the
- // state of the host tree right before we mutate it. This is where
- // getSnapshotBeforeUpdate is called.
+function captureCommitPhaseError(sourceFiber, error) {
+ if (sourceFiber.tag === HostRoot) {
+ // Error was thrown at the root. There is no parent, so the root
+ // itself should capture it.
+ captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
+ return;
+ }
- startCommitSnapshotEffectsTimer();
- prepareForCommit(root.containerInfo);
- nextEffect = firstEffect;
+ var fiber = sourceFiber.return;
- do {
- {
- invokeGuardedCallback(null, commitBeforeMutationEffects, null);
+ while (fiber !== null) {
+ if (fiber.tag === HostRoot) {
+ captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
+ return;
+ } else if (fiber.tag === ClassComponent) {
+ var ctor = fiber.type;
+ var instance = fiber.stateNode;
- if (hasCaughtError()) {
- if (!(nextEffect !== null)) {
- throw Error("Should be working on an effect.");
- }
+ if (
+ typeof ctor.getDerivedStateFromError === "function" ||
+ (typeof instance.componentDidCatch === "function" &&
+ !isAlreadyFailedLegacyErrorBoundary(instance))
+ ) {
+ var errorInfo = createCapturedValue(error, sourceFiber);
+ var update = createClassErrorUpdate(fiber, errorInfo, SyncLane);
+ enqueueUpdate(fiber, update);
+ var eventTime = requestEventTime();
+ var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane);
- var error = clearCaughtError();
- captureCommitPhaseError(nextEffect, error);
- nextEffect = nextEffect.nextEffect;
+ if (root !== null) {
+ markRootUpdated(root, SyncLane, eventTime);
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, SyncLane);
}
+
+ return;
}
- } while (nextEffect !== null);
+ }
- stopCommitSnapshotEffectsTimer();
+ fiber = fiber.return;
+ }
+}
+function pingSuspendedRoot(root, wakeable, pingedLanes) {
+ var pingCache = root.pingCache;
- {
- // Mark the current commit time to be shared by all Profilers in this
- // batch. This enables them to be grouped later.
- recordCommitTime();
- } // The next phase is the mutation phase, where we mutate the host tree.
+ if (pingCache !== null) {
+ // The wakeable resolved, so we no longer need to memoize, because it will
+ // never be thrown again.
+ pingCache.delete(wakeable);
+ }
- startCommitHostEffectsTimer();
- nextEffect = firstEffect;
+ var eventTime = requestEventTime();
+ markRootPinged(root, pingedLanes);
- do {
- {
- invokeGuardedCallback(
- null,
- commitMutationEffects,
- null,
- root,
- renderPriorityLevel
- );
+ if (
+ workInProgressRoot === root &&
+ isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)
+ ) {
+ // Received a ping at the same priority level at which we're currently
+ // rendering. We might want to restart this render. This should mirror
+ // the logic of whether or not a root suspends once it completes.
+ // TODO: If we're rendering sync either due to Sync, Batched or expired,
+ // we should probably never restart.
+ // If we're suspended with delay, or if it's a retry, we'll always suspend
+ // so we can always restart.
+ if (
+ workInProgressRootExitStatus === RootSuspendedWithDelay ||
+ (workInProgressRootExitStatus === RootSuspended &&
+ includesOnlyRetries(workInProgressRootRenderLanes) &&
+ now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
+ ) {
+ // Restart from the root.
+ prepareFreshStack(root, NoLanes);
+ } else {
+ // Even though we can't restart right now, we might get an
+ // opportunity later. So we mark this render as having a ping.
+ workInProgressRootPingedLanes = mergeLanes(
+ workInProgressRootPingedLanes,
+ pingedLanes
+ );
+ }
+ }
- if (hasCaughtError()) {
- if (!(nextEffect !== null)) {
- throw Error("Should be working on an effect.");
- }
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, pingedLanes);
+}
- var _error = clearCaughtError();
+function retryTimedOutBoundary(boundaryFiber, retryLane) {
+ // The boundary fiber (a Suspense component or SuspenseList component)
+ // previously was rendered in its fallback state. One of the promises that
+ // suspended it has resolved, which means at least part of the tree was
+ // likely unblocked. Try rendering again, at a new expiration time.
+ if (retryLane === NoLane) {
+ retryLane = requestRetryLane(boundaryFiber);
+ } // TODO: Special case idle priority?
- captureCommitPhaseError(nextEffect, _error);
- nextEffect = nextEffect.nextEffect;
- }
- }
- } while (nextEffect !== null);
+ var eventTime = requestEventTime();
+ var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane);
- stopCommitHostEffectsTimer();
- resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
- // the mutation phase, so that the previous tree is still current during
- // componentWillUnmount, but before the layout phase, so that the finished
- // work is current during componentDidMount/Update.
+ if (root !== null) {
+ markRootUpdated(root, retryLane, eventTime);
+ ensureRootIsScheduled(root, eventTime);
+ schedulePendingInteractions(root, retryLane);
+ }
+}
+function resolveRetryWakeable(boundaryFiber, wakeable) {
+ var retryLane = NoLane; // Default
- root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
- // the host tree after it's been mutated. The idiomatic use case for this is
- // layout, but class component lifecycles also fire here for legacy reasons.
+ var retryCache;
- startCommitLifeCyclesTimer();
- nextEffect = firstEffect;
+ {
+ retryCache = boundaryFiber.stateNode;
+ }
- do {
- {
- invokeGuardedCallback(
- null,
- commitLayoutEffects,
- null,
- root,
- expirationTime
- );
+ if (retryCache !== null) {
+ // The wakeable resolved, so we no longer need to memoize, because it will
+ // never be thrown again.
+ retryCache.delete(wakeable);
+ }
- if (hasCaughtError()) {
- if (!(nextEffect !== null)) {
- throw Error("Should be working on an effect.");
- }
+ retryTimedOutBoundary(boundaryFiber, retryLane);
+} // Computes the next Just Noticeable Difference (JND) boundary.
+// The theory is that a person can't tell the difference between small differences in time.
+// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
+// difference in the experience. However, waiting for longer might mean that we can avoid
+// showing an intermediate loading state. The longer we have already waited, the harder it
+// is to tell small differences in time. Therefore, the longer we've already waited,
+// the longer we can wait additionally. At some point we have to give up though.
+// We pick a train model where the next boundary commits at a consistent schedule.
+// These particular numbers are vague estimates. We expect to adjust them based on research.
+
+function jnd(timeElapsed) {
+ return timeElapsed < 120
+ ? 120
+ : timeElapsed < 480
+ ? 480
+ : timeElapsed < 1080
+ ? 1080
+ : timeElapsed < 1920
+ ? 1920
+ : timeElapsed < 3000
+ ? 3000
+ : timeElapsed < 4320
+ ? 4320
+ : ceil(timeElapsed / 1960) * 1960;
+}
+
+function computeMsUntilSuspenseLoadingDelay(
+ mostRecentEventTime,
+ suspenseConfig
+) {
+ var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
- var _error2 = clearCaughtError();
+ if (busyMinDurationMs <= 0) {
+ return 0;
+ }
- captureCommitPhaseError(nextEffect, _error2);
- nextEffect = nextEffect.nextEffect;
- }
- }
- } while (nextEffect !== null);
+ var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
- stopCommitLifeCyclesTimer();
- nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
- // opportunity to paint.
+ var currentTimeMs = now();
+ var eventTimeMs = mostRecentEventTime;
+ var timeElapsed = currentTimeMs - eventTimeMs;
- requestPaint();
+ if (timeElapsed <= busyDelayMs) {
+ // If we haven't yet waited longer than the initial delay, we don't
+ // have to wait any additional time.
+ return 0;
+ }
- {
- popInteractions(prevInteractions);
- }
+ var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
- executionContext = prevExecutionContext;
- } else {
- // No effects.
- root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
- // no effects.
- // TODO: Maybe there's a better way to report this.
+ return msUntilTimeout;
+}
- startCommitSnapshotEffectsTimer();
- stopCommitSnapshotEffectsTimer();
+function checkForNestedUpdates() {
+ if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
+ nestedUpdateCount = 0;
+ rootWithNestedUpdates = null;
{
- recordCommitTime();
+ throw Error(
+ "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
+ );
}
-
- startCommitHostEffectsTimer();
- stopCommitHostEffectsTimer();
- startCommitLifeCyclesTimer();
- stopCommitLifeCyclesTimer();
}
- stopCommitTimer();
- var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
-
- if (rootDoesHavePassiveEffects) {
- // This commit has passive effects. Stash a reference to them. But don't
- // schedule a callback until after flushing layout work.
- rootDoesHavePassiveEffects = false;
- rootWithPendingPassiveEffects = root;
- pendingPassiveEffectsExpirationTime = expirationTime;
- pendingPassiveEffectsRenderPriority = renderPriorityLevel;
- } else {
- // We are done with the effect chain at this point so let's clear the
- // nextEffect pointers to assist with GC. If we have passive effects, we'll
- // clear this in flushPassiveEffects.
- nextEffect = firstEffect;
+ {
+ if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
+ nestedPassiveUpdateCount = 0;
- while (nextEffect !== null) {
- var nextNextEffect = nextEffect.nextEffect;
- nextEffect.nextEffect = null;
- nextEffect = nextNextEffect;
+ error(
+ "Maximum update depth exceeded. This can happen when a component " +
+ "calls setState inside useEffect, but useEffect either doesn't " +
+ "have a dependency array, or one of the dependencies changes on " +
+ "every render."
+ );
}
- } // Check if there's remaining work on this root
+ }
+}
- var remainingExpirationTime = root.firstPendingTime;
+function flushRenderPhaseStrictModeWarningsInDEV() {
+ {
+ ReactStrictModeWarnings.flushLegacyContextWarning();
- if (remainingExpirationTime !== NoWork) {
{
- if (spawnedWorkDuringRender !== null) {
- var expirationTimes = spawnedWorkDuringRender;
- spawnedWorkDuringRender = null;
-
- for (var i = 0; i < expirationTimes.length; i++) {
- scheduleInteractions(
- root,
- expirationTimes[i],
- root.memoizedInteractions
- );
- }
- }
-
- schedulePendingInteractions(root, remainingExpirationTime);
+ ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
}
- } else {
- // If there's no remaining work, we can clear the set of already failed
- // error boundaries.
- legacyErrorBoundariesThatAlreadyFailed = null;
}
+}
+var didWarnStateUpdateForNotYetMountedComponent = null;
+
+function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
{
- if (!rootDidHavePassiveEffects) {
- // If there are no passive effects, then we can complete the pending interactions.
- // Otherwise, we'll wait until after the passive effects are flushed.
- // Wait to do this until after remaining work has been scheduled,
- // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
- finishPendingInteractions(root, expirationTime);
+ if ((executionContext & RenderContext) !== NoContext) {
+ // We let the other warning about render phase updates deal with this one.
+ return;
}
- }
- if (remainingExpirationTime === Sync) {
- // Count the number of times the root synchronously re-renders without
- // finishing. If there are too many, it indicates an infinite update loop.
- if (root === rootWithNestedUpdates) {
- nestedUpdateCount++;
- } else {
- nestedUpdateCount = 0;
- rootWithNestedUpdates = root;
+ if (!(fiber.mode & (BlockingMode | ConcurrentMode))) {
+ return;
}
- } else {
- nestedUpdateCount = 0;
- }
- onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any
- // additional work on this root is scheduled.
+ var tag = fiber.tag;
- ensureRootIsScheduled(root);
+ if (
+ tag !== IndeterminateComponent &&
+ tag !== HostRoot &&
+ tag !== ClassComponent &&
+ tag !== FunctionComponent &&
+ tag !== ForwardRef &&
+ tag !== MemoComponent &&
+ tag !== SimpleMemoComponent &&
+ tag !== Block
+ ) {
+ // Only warn for user-defined components, not internal ones like Suspense.
+ return;
+ } // We show the whole stack but dedupe on the top component's name because
+ // the problematic code almost always lies inside that component.
- if (hasUncaughtError) {
- hasUncaughtError = false;
- var _error3 = firstUncaughtError;
- firstUncaughtError = null;
- throw _error3;
- }
+ var componentName = getComponentName(fiber.type) || "ReactComponent";
- if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
- // This is a legacy edge case. We just committed the initial mount of
- // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
- // synchronously, but layout updates should be deferred until the end
- // of the batch.
- return null;
- } // If layout work was scheduled, flush it now.
+ if (didWarnStateUpdateForNotYetMountedComponent !== null) {
+ if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
+ return;
+ }
- flushSyncCallbackQueue();
- return null;
-}
+ didWarnStateUpdateForNotYetMountedComponent.add(componentName);
+ } else {
+ didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
+ }
-function commitBeforeMutationEffects() {
- while (nextEffect !== null) {
- var effectTag = nextEffect.effectTag;
+ var previousFiber = current;
- if ((effectTag & Snapshot) !== NoEffect) {
- setCurrentFiber(nextEffect);
- recordEffect();
- var current = nextEffect.alternate;
- commitBeforeMutationLifeCycles(current, nextEffect);
- resetCurrentFiber();
- }
+ try {
+ setCurrentFiber(fiber);
- if ((effectTag & Passive) !== NoEffect) {
- // If there are passive effects, schedule a callback to flush at
- // the earliest opportunity.
- if (!rootDoesHavePassiveEffects) {
- rootDoesHavePassiveEffects = true;
- scheduleCallback(NormalPriority, function() {
- flushPassiveEffects();
- return null;
- });
+ error(
+ "Can't perform a React state update on a component that hasn't mounted yet. " +
+ "This indicates that you have a side-effect in your render function that " +
+ "asynchronously later calls tries to update the component. Move this work to " +
+ "useEffect instead."
+ );
+ } finally {
+ if (previousFiber) {
+ setCurrentFiber(fiber);
+ } else {
+ resetCurrentFiber();
}
}
-
- nextEffect = nextEffect.nextEffect;
}
}
-function commitMutationEffects(root, renderPriorityLevel) {
- // TODO: Should probably move the bulk of this function to commitWork.
- while (nextEffect !== null) {
- setCurrentFiber(nextEffect);
- var effectTag = nextEffect.effectTag;
-
- if (effectTag & ContentReset) {
- commitResetTextContent(nextEffect);
- }
+var didWarnStateUpdateForUnmountedComponent = null;
- if (effectTag & Ref) {
- var current = nextEffect.alternate;
+function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
+ {
+ var tag = fiber.tag;
- if (current !== null) {
- commitDetachRef(current);
- }
- } // The following switch statement is only concerned about placement,
- // updates, and deletions. To avoid needing to add a case for every possible
- // bitmap value, we remove the secondary effects from the effect tag and
- // switch on that value.
+ if (
+ tag !== HostRoot &&
+ tag !== ClassComponent &&
+ tag !== FunctionComponent &&
+ tag !== ForwardRef &&
+ tag !== MemoComponent &&
+ tag !== SimpleMemoComponent &&
+ tag !== Block
+ ) {
+ // Only warn for user-defined components, not internal ones like Suspense.
+ return;
+ } // If there are pending passive effects unmounts for this Fiber,
+ // we can assume that they would have prevented this update.
- var primaryEffectTag =
- effectTag & (Placement | Update | Deletion | Hydrating);
+ if ((fiber.effectTag & PassiveUnmountPendingDev) !== NoEffect) {
+ return;
+ } // We show the whole stack but dedupe on the top component's name because
+ // the problematic code almost always lies inside that component.
- switch (primaryEffectTag) {
- case Placement: {
- commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
- // inserted, before any life-cycles like componentDidMount gets called.
- // TODO: findDOMNode doesn't rely on this any more but isMounted does
- // and isMounted is deprecated anyway so we should be able to kill this.
+ var componentName = getComponentName(fiber.type) || "ReactComponent";
- nextEffect.effectTag &= ~Placement;
- break;
+ if (didWarnStateUpdateForUnmountedComponent !== null) {
+ if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
+ return;
}
- case PlacementAndUpdate: {
- // Placement
- commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
- // inserted, before any life-cycles like componentDidMount gets called.
+ didWarnStateUpdateForUnmountedComponent.add(componentName);
+ } else {
+ didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
+ }
- nextEffect.effectTag &= ~Placement; // Update
+ if (isFlushingPassiveEffects);
+ else {
+ var previousFiber = current;
- var _current = nextEffect.alternate;
- commitWork(_current, nextEffect);
- break;
- }
+ try {
+ setCurrentFiber(fiber);
- case Hydrating: {
- nextEffect.effectTag &= ~Hydrating;
- break;
+ error(
+ "Can't perform a React state update on an unmounted component. This " +
+ "is a no-op, but it indicates a memory leak in your application. To " +
+ "fix, cancel all subscriptions and asynchronous tasks in %s.",
+ tag === ClassComponent
+ ? "the componentWillUnmount method"
+ : "a useEffect cleanup function"
+ );
+ } finally {
+ if (previousFiber) {
+ setCurrentFiber(fiber);
+ } else {
+ resetCurrentFiber();
+ }
}
+ }
+ }
+}
+
+var beginWork$1;
+
+{
+ var dummyFiber = null;
+
+ beginWork$1 = function(current, unitOfWork, lanes) {
+ // If a component throws an error, we replay it again in a synchronously
+ // dispatched event, so that the debugger will treat it as an uncaught
+ // error See ReactErrorUtils for more information.
+ // Before entering the begin phase, copy the work-in-progress onto a dummy
+ // fiber. If beginWork throws, we'll use this to reset the state.
+ var originalWorkInProgressCopy = assignFiberPropertiesInDEV(
+ dummyFiber,
+ unitOfWork
+ );
- case HydratingAndUpdate: {
- nextEffect.effectTag &= ~Hydrating; // Update
+ try {
+ return beginWork(current, unitOfWork, lanes);
+ } catch (originalError) {
+ if (
+ originalError !== null &&
+ typeof originalError === "object" &&
+ typeof originalError.then === "function"
+ ) {
+ // Don't replay promises. Treat everything else like an error.
+ throw originalError;
+ } // Keep this code in sync with handleError; any changes here must have
+ // corresponding changes there.
- var _current2 = nextEffect.alternate;
- commitWork(_current2, nextEffect);
- break;
- }
+ resetContextDependencies();
+ resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the
+ // same fiber again.
+ // Unwind the failed stack frame
- case Update: {
- var _current3 = nextEffect.alternate;
- commitWork(_current3, nextEffect);
- break;
- }
+ unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
- case Deletion: {
- commitDeletion(root, nextEffect, renderPriorityLevel);
- break;
- }
- } // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
+ assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
- recordEffect();
- resetCurrentFiber();
- nextEffect = nextEffect.nextEffect;
- }
-}
+ if (unitOfWork.mode & ProfileMode) {
+ // Reset the profiler timer.
+ startProfilerTimer(unitOfWork);
+ } // Run beginWork again.
-function commitLayoutEffects(root, committedExpirationTime) {
- // TODO: Should probably move the bulk of this function to commitWork.
- while (nextEffect !== null) {
- setCurrentFiber(nextEffect);
- var effectTag = nextEffect.effectTag;
+ invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes);
- if (effectTag & (Update | Callback)) {
- recordEffect();
- var current = nextEffect.alternate;
- commitLifeCycles(root, current, nextEffect);
- }
+ if (hasCaughtError()) {
+ var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
+ // Rethrow this error instead of the original one.
- if (effectTag & Ref) {
- recordEffect();
- commitAttachRef(nextEffect);
+ throw replayError;
+ } else {
+ // This branch is reachable if the render phase is impure.
+ throw originalError;
+ }
}
-
- resetCurrentFiber();
- nextEffect = nextEffect.nextEffect;
- }
+ };
}
-function flushPassiveEffects() {
- if (pendingPassiveEffectsRenderPriority !== NoPriority) {
- var priorityLevel =
- pendingPassiveEffectsRenderPriority > NormalPriority
- ? NormalPriority
- : pendingPassiveEffectsRenderPriority;
- pendingPassiveEffectsRenderPriority = NoPriority;
- return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
- }
+var didWarnAboutUpdateInRender = false;
+var didWarnAboutUpdateInRenderForAnotherComponent;
+
+{
+ didWarnAboutUpdateInRenderForAnotherComponent = new Set();
}
-function flushPassiveEffectsImpl() {
- if (rootWithPendingPassiveEffects === null) {
- return false;
- }
+function warnAboutRenderPhaseUpdatesInDEV(fiber) {
+ {
+ if (
+ isRendering &&
+ (executionContext & RenderContext) !== NoContext &&
+ !getIsUpdatingOpaqueValueInRenderPhaseInDEV()
+ ) {
+ switch (fiber.tag) {
+ case FunctionComponent:
+ case ForwardRef:
+ case SimpleMemoComponent: {
+ var renderingComponentName =
+ (workInProgress && getComponentName(workInProgress.type)) ||
+ "Unknown"; // Dedupe by the rendering component because it's the one that needs to be fixed.
- var root = rootWithPendingPassiveEffects;
- var expirationTime = pendingPassiveEffectsExpirationTime;
- rootWithPendingPassiveEffects = null;
- pendingPassiveEffectsExpirationTime = NoWork;
+ var dedupeKey = renderingComponentName;
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Cannot flush passive effects while already rendering.");
- }
+ if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
+ didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
+ var setStateComponentName =
+ getComponentName(fiber.type) || "Unknown";
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- var prevInteractions = pushInteractions(root);
+ error(
+ "Cannot update a component (`%s`) while rendering a " +
+ "different component (`%s`). To locate the bad setState() call inside `%s`, " +
+ "follow the stack trace as described in https://fb.me/setstate-in-render",
+ setStateComponentName,
+ renderingComponentName,
+ renderingComponentName
+ );
+ }
- {
- // Note: This currently assumes there are no passive effects on the root fiber
- // because the root is not part of its own effect list.
- // This could change in the future.
- var _effect2 = root.current.firstEffect;
+ break;
+ }
- while (_effect2 !== null) {
- {
- setCurrentFiber(_effect2);
- invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2);
+ case ClassComponent: {
+ if (!didWarnAboutUpdateInRender) {
+ error(
+ "Cannot update during an existing state transition (such as " +
+ "within `render`). Render methods should be a pure " +
+ "function of props and state."
+ );
- if (hasCaughtError()) {
- if (!(_effect2 !== null)) {
- throw Error("Should be working on an effect.");
+ didWarnAboutUpdateInRender = true;
}
- var _error5 = clearCaughtError();
-
- captureCommitPhaseError(_effect2, _error5);
+ break;
}
-
- resetCurrentFiber();
}
-
- var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC
-
- _effect2.nextEffect = null;
- _effect2 = nextNextEffect;
}
}
+} // a 'shared' variable that changes when act() opens/closes in tests.
+var IsThisRendererActing = {
+ current: false
+};
+function warnIfNotScopedWithMatchingAct(fiber) {
{
- popInteractions(prevInteractions);
- finishPendingInteractions(root, expirationTime);
- }
-
- executionContext = prevExecutionContext;
- flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
- // exceeds the limit, we'll fire a warning.
+ if (
+ IsSomeRendererActing.current === true &&
+ IsThisRendererActing.current !== true
+ ) {
+ var previousFiber = current;
- nestedPassiveUpdateCount =
- rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
- return true;
-}
+ try {
+ setCurrentFiber(fiber);
-function isAlreadyFailedLegacyErrorBoundary(instance) {
- return (
- legacyErrorBoundariesThatAlreadyFailed !== null &&
- legacyErrorBoundariesThatAlreadyFailed.has(instance)
- );
-}
-function markLegacyErrorBoundaryAsFailed(instance) {
- if (legacyErrorBoundariesThatAlreadyFailed === null) {
- legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
- } else {
- legacyErrorBoundariesThatAlreadyFailed.add(instance);
+ error(
+ "It looks like you're using the wrong act() around your test interactions.\n" +
+ "Be sure to use the matching version of act() corresponding to your renderer:\n\n" +
+ "// for react-dom:\n" + // Break up imports to avoid accidentally parsing them as dependencies.
+ "import {act} fr" +
+ "om 'react-dom/test-utils';\n" +
+ "// ...\n" +
+ "act(() => ...);\n\n" +
+ "// for react-test-renderer:\n" + // Break up imports to avoid accidentally parsing them as dependencies.
+ "import TestRenderer fr" +
+ "om react-test-renderer';\n" +
+ "const {act} = TestRenderer;\n" +
+ "// ...\n" +
+ "act(() => ...);"
+ );
+ } finally {
+ if (previousFiber) {
+ setCurrentFiber(fiber);
+ } else {
+ resetCurrentFiber();
+ }
+ }
+ }
}
}
-
-function prepareToThrowUncaughtError(error) {
- if (!hasUncaughtError) {
- hasUncaughtError = true;
- firstUncaughtError = error;
+function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
+ {
+ if (
+ (fiber.mode & StrictMode) !== NoMode &&
+ IsSomeRendererActing.current === false &&
+ IsThisRendererActing.current === false
+ ) {
+ error(
+ "An update to %s ran an effect, but 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)
+ );
+ }
}
}
-var onUncaughtError = prepareToThrowUncaughtError;
+function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
+ {
+ if (
+ executionContext === NoContext &&
+ IsSomeRendererActing.current === false &&
+ IsThisRendererActing.current === false
+ ) {
+ var previousFiber = current;
-function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
- var errorInfo = createCapturedValue(error, sourceFiber);
- var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
- enqueueUpdate(rootFiber, update);
- var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
+ try {
+ setCurrentFiber(fiber);
- if (root !== null) {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, Sync);
+ error(
+ "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)
+ );
+ } finally {
+ if (previousFiber) {
+ setCurrentFiber(fiber);
+ } else {
+ resetCurrentFiber();
+ }
+ }
+ }
}
}
-function captureCommitPhaseError(sourceFiber, error) {
- if (sourceFiber.tag === HostRoot) {
- // Error was thrown at the root. There is no parent, so the root
- // itself should capture it.
- captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
- return;
- }
+var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
- var fiber = sourceFiber.return;
+var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
+// scheduler is the actual recommendation. The alternative could be a testing build,
+// a new lib, or whatever; we dunno just yet. This message is for early adopters
+// to get their tests right.
- while (fiber !== null) {
- if (fiber.tag === HostRoot) {
- captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
- return;
- } else if (fiber.tag === ClassComponent) {
- var ctor = fiber.type;
- var instance = fiber.stateNode;
+function warnIfUnmockedScheduler(fiber) {
+ {
+ if (
+ didWarnAboutUnmockedScheduler === false &&
+ Scheduler.unstable_flushAllWithoutAsserting === undefined
+ ) {
+ if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
+ didWarnAboutUnmockedScheduler = true;
- if (
- typeof ctor.getDerivedStateFromError === "function" ||
- (typeof instance.componentDidCatch === "function" &&
- !isAlreadyFailedLegacyErrorBoundary(instance))
- ) {
- var errorInfo = createCapturedValue(error, sourceFiber);
- var update = createClassErrorUpdate(
- fiber,
- errorInfo, // TODO: This is always sync
- Sync
+ error(
+ 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
+ "to guarantee consistent behaviour across tests and browsers. " +
+ "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
+ "jest.mock('scheduler', () => require" +
+ "('scheduler/unstable_mock'));\n\n" +
+ "For more info, visit https://fb.me/react-mock-scheduler"
);
- enqueueUpdate(fiber, update);
- var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
-
- if (root !== null) {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, Sync);
- }
+ } else {
+ didWarnAboutUnmockedScheduler = true;
- return;
+ error(
+ 'Starting from React v18, the "scheduler" module will need to be mocked ' +
+ "to guarantee consistent behaviour across tests and browsers. " +
+ "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
+ "jest.mock('scheduler', () => require" +
+ "('scheduler/unstable_mock'));\n\n" +
+ "For more info, visit https://fb.me/react-mock-scheduler"
+ );
}
}
-
- fiber = fiber.return;
}
}
-function pingSuspendedRoot(root, thenable, suspendedTime) {
- var pingCache = root.pingCache;
-
- if (pingCache !== null) {
- // The thenable resolved, so we no longer need to memoize, because it will
- // never be thrown again.
- pingCache.delete(thenable);
- }
-
- if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) {
- // Received a ping at the same priority level at which we're currently
- // rendering. We might want to restart this render. This should mirror
- // the logic of whether or not a root suspends once it completes.
- // TODO: If we're rendering sync either due to Sync, Batched or expired,
- // we should probably never restart.
- // If we're suspended with delay, we'll always suspend so we can always
- // restart. If we're suspended without any updates, it might be a retry.
- // If it's early in the retry we can restart. We can't know for sure
- // whether we'll eventually process an update during this render pass,
- // but it's somewhat unlikely that we get to a ping before that, since
- // getting to the root most update is usually very fast.
- if (
- workInProgressRootExitStatus === RootSuspendedWithDelay ||
- (workInProgressRootExitStatus === RootSuspended &&
- workInProgressRootLatestProcessedExpirationTime === Sync &&
- now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
- ) {
- // Restart from the root. Don't need to schedule a ping because
- // we're already working on this tree.
- prepareFreshStack(root, renderExpirationTime$1);
- } else {
- // Even though we can't restart right now, we might get an
- // opportunity later. So we mark this render as having a ping.
- workInProgressRootHasPendingPing = true;
- }
- return;
- }
+function computeThreadID(root, lane) {
+ // Interaction threads are unique per root and expiration time.
+ // NOTE: Intentionally unsound cast. All that matters is that it's a number
+ // and it represents a batch of work. Could make a helper function instead,
+ // but meh this is fine for now.
+ return lane * 1000 + root.interactionThreadID;
+}
- if (!isRootSuspendedAtTime(root, suspendedTime)) {
- // The root is no longer suspended at this time.
- return;
+function markSpawnedWork(lane) {
+ if (spawnedWorkDuringRender === null) {
+ spawnedWorkDuringRender = [lane];
+ } else {
+ spawnedWorkDuringRender.push(lane);
}
+}
- var lastPingedTime = root.lastPingedTime;
+function scheduleInteractions(root, lane, interactions) {
+ if (interactions.size > 0) {
+ var pendingInteractionMap = root.pendingInteractionMap;
+ var pendingInteractions = pendingInteractionMap.get(lane);
- if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
- // There's already a lower priority ping scheduled.
- return;
- } // Mark the time at which this ping was scheduled.
+ if (pendingInteractions != null) {
+ interactions.forEach(function(interaction) {
+ if (!pendingInteractions.has(interaction)) {
+ // Update the pending async work count for previously unscheduled interaction.
+ interaction.__count++;
+ }
- root.lastPingedTime = suspendedTime;
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, suspendedTime);
-}
+ pendingInteractions.add(interaction);
+ });
+ } else {
+ pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions.
-function retryTimedOutBoundary(boundaryFiber, retryTime) {
- // The boundary fiber (a Suspense component or SuspenseList component)
- // previously was rendered in its fallback state. One of the promises that
- // suspended it has resolved, which means at least part of the tree was
- // likely unblocked. Try rendering again, at a new expiration time.
- if (retryTime === NoWork) {
- var suspenseConfig = null; // Retries don't carry over the already committed update.
-
- var currentTime = requestCurrentTimeForUpdate();
- retryTime = computeExpirationForFiber(
- currentTime,
- boundaryFiber,
- suspenseConfig
- );
- } // TODO: Special case idle priority?
+ interactions.forEach(function(interaction) {
+ interaction.__count++;
+ });
+ }
- var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
+ var subscriber = tracing.__subscriberRef.current;
- if (root !== null) {
- ensureRootIsScheduled(root);
- schedulePendingInteractions(root, retryTime);
+ if (subscriber !== null) {
+ var threadID = computeThreadID(root, lane);
+ subscriber.onWorkScheduled(interactions, threadID);
+ }
}
}
-function resolveRetryThenable(boundaryFiber, thenable) {
- var retryTime = NoWork; // Default
- var retryCache;
+function schedulePendingInteractions(root, lane) {
+ scheduleInteractions(root, lane, tracing.__interactionsRef.current);
+}
- {
- retryCache = boundaryFiber.stateNode;
- }
+function startWorkOnPendingInteractions(root, lanes) {
+ // we can accurately attribute time spent working on it, And so that cascading
+ // work triggered during the render phase will be associated with it.
- if (retryCache !== null) {
- // The thenable resolved, so we no longer need to memoize, because it will
- // never be thrown again.
- retryCache.delete(thenable);
- }
+ var interactions = new Set();
+ root.pendingInteractionMap.forEach(function(
+ scheduledInteractions,
+ scheduledLane
+ ) {
+ if (includesSomeLane(lanes, scheduledLane)) {
+ scheduledInteractions.forEach(function(interaction) {
+ return interactions.add(interaction);
+ });
+ }
+ }); // Store the current set of interactions on the FiberRoot for a few reasons:
+ // We can re-use it in hot functions like performConcurrentWorkOnRoot()
+ // without having to recalculate it. We will also use it in commitWork() to
+ // pass to any Profiler onRender() hooks. This also provides DevTools with a
+ // way to access it when the onCommitRoot() hook is called.
- retryTimedOutBoundary(boundaryFiber, retryTime);
-} // Computes the next Just Noticeable Difference (JND) boundary.
-// The theory is that a person can't tell the difference between small differences in time.
-// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
-// difference in the experience. However, waiting for longer might mean that we can avoid
-// showing an intermediate loading state. The longer we have already waited, the harder it
-// is to tell small differences in time. Therefore, the longer we've already waited,
-// the longer we can wait additionally. At some point we have to give up though.
-// We pick a train model where the next boundary commits at a consistent schedule.
-// These particular numbers are vague estimates. We expect to adjust them based on research.
+ root.memoizedInteractions = interactions;
-function jnd(timeElapsed) {
- return timeElapsed < 120
- ? 120
- : timeElapsed < 480
- ? 480
- : timeElapsed < 1080
- ? 1080
- : timeElapsed < 1920
- ? 1920
- : timeElapsed < 3000
- ? 3000
- : timeElapsed < 4320
- ? 4320
- : ceil(timeElapsed / 1960) * 1960;
-}
+ if (interactions.size > 0) {
+ var subscriber = tracing.__subscriberRef.current;
-function computeMsUntilSuspenseLoadingDelay(
- mostRecentEventTime,
- committedExpirationTime,
- suspenseConfig
-) {
- var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
+ if (subscriber !== null) {
+ var threadID = computeThreadID(root, lanes);
- if (busyMinDurationMs <= 0) {
- return 0;
+ try {
+ subscriber.onWorkStarted(interactions, threadID);
+ } catch (error) {
+ // If the subscriber throws, rethrow it in a separate task
+ scheduleCallback(ImmediatePriority$1, function() {
+ throw error;
+ });
+ }
+ }
}
+}
- var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
+function finishPendingInteractions(root, committedLanes) {
+ var remainingLanesAfterCommit = root.pendingLanes;
+ var subscriber;
- var currentTimeMs = now();
- var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(
- mostRecentEventTime,
- suspenseConfig
- );
- var timeElapsed = currentTimeMs - eventTimeMs;
+ try {
+ subscriber = tracing.__subscriberRef.current;
- if (timeElapsed <= busyDelayMs) {
- // If we haven't yet waited longer than the initial delay, we don't
- // have to wait any additional time.
- return 0;
+ if (subscriber !== null && root.memoizedInteractions.size > 0) {
+ // FIXME: More than one lane can finish in a single commit.
+ var threadID = computeThreadID(root, committedLanes);
+ subscriber.onWorkStopped(root.memoizedInteractions, threadID);
+ }
+ } catch (error) {
+ // If the subscriber throws, rethrow it in a separate task
+ scheduleCallback(ImmediatePriority$1, function() {
+ throw error;
+ });
+ } finally {
+ // Clear completed interactions from the pending Map.
+ // Unless the render was suspended or cascading work was scheduled,
+ // In which case– leave pending interactions until the subsequent render.
+ var pendingInteractionMap = root.pendingInteractionMap;
+ pendingInteractionMap.forEach(function(scheduledInteractions, lane) {
+ // Only decrement the pending interaction count if we're done.
+ // If there's still work at the current priority,
+ // That indicates that we are waiting for suspense data.
+ if (!includesSomeLane(remainingLanesAfterCommit, lane)) {
+ pendingInteractionMap.delete(lane);
+ scheduledInteractions.forEach(function(interaction) {
+ interaction.__count--;
+
+ if (subscriber !== null && interaction.__count === 0) {
+ try {
+ subscriber.onInteractionScheduledWorkCompleted(interaction);
+ } catch (error) {
+ // If the subscriber throws, rethrow it in a separate task
+ scheduleCallback(ImmediatePriority$1, function() {
+ throw error;
+ });
+ }
+ }
+ });
+ }
+ });
}
+} // `act` testing API
+//
+// TODO: This is mostly a copy-paste from the legacy `act`, which does not have
+// access to the same internals that we do here. Some trade offs in the
+// implementation no longer make sense.
- var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
+var isFlushingAct = false;
- return msUntilTimeout;
+function shouldForceFlushFallbacksInDEV() {
+ return isFlushingAct;
}
-function checkForNestedUpdates() {
- if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
- nestedUpdateCount = 0;
- rootWithNestedUpdates = null;
+function detachFiberAfterEffects(fiber) {
+ fiber.sibling = null;
+}
- {
- throw Error(
- "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
- );
- }
- }
+var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
+var failedBoundaries = null;
+var setRefreshHandler = function(handler) {
{
- if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
- nestedPassiveUpdateCount = 0;
-
- error(
- "Maximum update depth exceeded. This can happen when a component " +
- "calls setState inside useEffect, but useEffect either doesn't " +
- "have a dependency array, or one of the dependencies changes on " +
- "every render."
- );
- }
+ resolveFamily = handler;
}
-}
-
-function flushRenderPhaseStrictModeWarningsInDEV() {
+};
+function resolveFunctionForHotReloading(type) {
{
- ReactStrictModeWarnings.flushLegacyContextWarning();
-
- {
- ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return type;
}
- }
-}
-function stopFinishedWorkLoopTimer() {
- var didCompleteRoot = true;
- stopWorkLoopTimer(interruptedBy, didCompleteRoot);
- interruptedBy = null;
-}
+ var family = resolveFamily(type);
-function stopInterruptedWorkLoopTimer() {
- // TODO: Track which fiber caused the interruption.
- var didCompleteRoot = false;
- stopWorkLoopTimer(interruptedBy, didCompleteRoot);
- interruptedBy = null;
-}
+ if (family === undefined) {
+ return type;
+ } // Use the latest known implementation.
-function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
- if (
- workInProgressRoot !== null &&
- updateExpirationTime > renderExpirationTime$1
- ) {
- interruptedBy = fiberThatReceivedUpdate;
+ return family.current;
}
}
-
-var didWarnStateUpdateForUnmountedComponent = null;
-
-function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
+function resolveClassForHotReloading(type) {
+ // No implementation differences.
+ return resolveFunctionForHotReloading(type);
+}
+function resolveForwardRefForHotReloading(type) {
{
- var tag = fiber.tag;
-
- if (
- tag !== HostRoot &&
- tag !== ClassComponent &&
- tag !== FunctionComponent &&
- tag !== ForwardRef &&
- tag !== MemoComponent &&
- tag !== SimpleMemoComponent &&
- tag !== Block
- ) {
- // Only warn for user-defined components, not internal ones like Suspense.
- return;
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return type;
}
- // the problematic code almost always lies inside that component.
- var componentName = getComponentName(fiber.type) || "ReactComponent";
+ var family = resolveFamily(type);
+
+ if (family === undefined) {
+ // Check if we're dealing with a real forwardRef. Don't want to crash early.
+ if (
+ type !== null &&
+ type !== undefined &&
+ typeof type.render === "function"
+ ) {
+ // ForwardRef is special because its resolved .type is an object,
+ // but it's possible that we only have its inner render function in the map.
+ // If that inner render function is different, we'll build a new forwardRef type.
+ var currentRender = resolveFunctionForHotReloading(type.render);
+
+ if (type.render !== currentRender) {
+ var syntheticType = {
+ $$typeof: REACT_FORWARD_REF_TYPE,
+ render: currentRender
+ };
- if (didWarnStateUpdateForUnmountedComponent !== null) {
- if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
- return;
+ if (type.displayName !== undefined) {
+ syntheticType.displayName = type.displayName;
+ }
+
+ return syntheticType;
+ }
}
- didWarnStateUpdateForUnmountedComponent.add(componentName);
- } else {
- didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
- }
+ return type;
+ } // Use the latest known implementation.
- error(
- "Can't perform a React state update on an unmounted component. This " +
- "is a no-op, but it indicates a memory leak in your application. To " +
- "fix, cancel all subscriptions and asynchronous tasks in %s.%s",
- tag === ClassComponent
- ? "the componentWillUnmount method"
- : "a useEffect cleanup function",
- getStackByFiberInDevAndProd(fiber)
- );
+ return family.current;
}
}
+function isCompatibleFamilyForHotReloading(fiber, element) {
+ {
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return false;
+ }
-var beginWork$1;
-
-{
- var dummyFiber = null;
-
- beginWork$1 = function(current, unitOfWork, expirationTime) {
- // If a component throws an error, we replay it again in a synchronously
- // dispatched event, so that the debugger will treat it as an uncaught
- // error See ReactErrorUtils for more information.
- // Before entering the begin phase, copy the work-in-progress onto a dummy
- // fiber. If beginWork throws, we'll use this to reset the state.
- var originalWorkInProgressCopy = assignFiberPropertiesInDEV(
- dummyFiber,
- unitOfWork
- );
-
- try {
- return beginWork(current, unitOfWork, expirationTime);
- } catch (originalError) {
- if (
- originalError !== null &&
- typeof originalError === "object" &&
- typeof originalError.then === "function"
- ) {
- // Don't replay promises. Treat everything else like an error.
- throw originalError;
- } // Keep this code in sync with handleError; any changes here must have
- // corresponding changes there.
+ var prevType = fiber.elementType;
+ var nextType = element.type; // If we got here, we know types aren't === equal.
- resetContextDependencies();
- resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the
- // same fiber again.
- // Unwind the failed stack frame
+ var needsCompareFamilies = false;
+ var $$typeofNextType =
+ typeof nextType === "object" && nextType !== null
+ ? nextType.$$typeof
+ : null;
- unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
+ switch (fiber.tag) {
+ case ClassComponent: {
+ if (typeof nextType === "function") {
+ needsCompareFamilies = true;
+ }
- assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
+ break;
+ }
- if (unitOfWork.mode & ProfileMode) {
- // Reset the profiler timer.
- startProfilerTimer(unitOfWork);
- } // Run beginWork again.
+ case FunctionComponent: {
+ if (typeof nextType === "function") {
+ needsCompareFamilies = true;
+ } else if ($$typeofNextType === REACT_LAZY_TYPE) {
+ // We don't know the inner type yet.
+ // We're going to assume that the lazy inner type is stable,
+ // and so it is sufficient to avoid reconciling it away.
+ // We're not going to unwrap or actually use the new lazy type.
+ needsCompareFamilies = true;
+ }
- invokeGuardedCallback(
- null,
- beginWork,
- null,
- current,
- unitOfWork,
- expirationTime
- );
+ break;
+ }
- if (hasCaughtError()) {
- var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
- // Rethrow this error instead of the original one.
+ case ForwardRef: {
+ if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
+ needsCompareFamilies = true;
+ } else if ($$typeofNextType === REACT_LAZY_TYPE) {
+ needsCompareFamilies = true;
+ }
- throw replayError;
- } else {
- // This branch is reachable if the render phase is impure.
- throw originalError;
+ break;
}
- }
- };
-}
-var didWarnAboutUpdateInRender = false;
+ case MemoComponent:
+ case SimpleMemoComponent: {
+ if ($$typeofNextType === REACT_MEMO_TYPE) {
+ // TODO: if it was but can no longer be simple,
+ // we shouldn't set this.
+ needsCompareFamilies = true;
+ } else if ($$typeofNextType === REACT_LAZY_TYPE) {
+ needsCompareFamilies = true;
+ }
-function warnAboutRenderPhaseUpdatesInDEV(fiber) {
- {
- if ((executionContext & RenderContext) !== NoContext) {
- switch (fiber.tag) {
- case FunctionComponent:
- case ForwardRef:
- case SimpleMemoComponent: {
- error(
- "Cannot update a component from inside the function body of a " +
- "different component."
- );
+ break;
+ }
- break;
- }
+ default:
+ return false;
+ } // Check if both types have a family and it's the same one.
- case ClassComponent: {
- if (isRendering && !didWarnAboutUpdateInRender) {
- error(
- "Cannot update during an existing state transition (such as " +
- "within `render`). Render methods should be a pure " +
- "function of props and state."
- );
+ if (needsCompareFamilies) {
+ // Note: memo() and forwardRef() we'll compare outer rather than inner type.
+ // This means both of them need to be registered to preserve state.
+ // If we unwrapped and compared the inner types for wrappers instead,
+ // then we would risk falsely saying two separate memo(Foo)
+ // calls are equivalent because they wrap the same Foo function.
+ var prevFamily = resolveFamily(prevType);
- didWarnAboutUpdateInRender = true;
- break;
- }
- }
+ if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
+ return true;
}
}
- }
-} // a 'shared' variable that changes when act() opens/closes in tests.
-var IsThisRendererActing = {
- current: false
-};
-function warnIfNotScopedWithMatchingAct(fiber) {
- {
- if (
- IsSomeRendererActing.current === true &&
- IsThisRendererActing.current !== true
- ) {
- error(
- "It looks like you're using the wrong act() around your test interactions.\n" +
- "Be sure to use the matching version of act() corresponding to your renderer:\n\n" +
- "// for react-dom:\n" + // Break up imports to avoid accidentally parsing them as dependencies.
- "import {act} fr" +
- "om 'react-dom/test-utils';\n" +
- "// ...\n" +
- "act(() => ...);\n\n" +
- "// for react-test-renderer:\n" + // Break up imports to avoid accidentally parsing them as dependencies.
- "import TestRenderer fr" +
- "om react-test-renderer';\n" +
- "const {act} = TestRenderer;\n" +
- "// ...\n" +
- "act(() => ...);" +
- "%s",
- getStackByFiberInDevAndProd(fiber)
- );
- }
+ return false;
}
}
-function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
+function markFailedErrorBoundaryForHotReloading(fiber) {
{
- if (
- (fiber.mode & StrictMode) !== NoMode &&
- IsSomeRendererActing.current === false &&
- IsThisRendererActing.current === false
- ) {
- error(
- "An update to %s ran an effect, but 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)
- );
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return;
}
- }
-}
-function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
- {
- if (
- executionContext === NoContext &&
- IsSomeRendererActing.current === false &&
- IsThisRendererActing.current === false
- ) {
- error(
- "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)
- );
+ if (typeof WeakSet !== "function") {
+ return;
+ }
+
+ if (failedBoundaries === null) {
+ failedBoundaries = new WeakSet();
}
+
+ failedBoundaries.add(fiber);
}
}
+var scheduleRefresh = function(root, update) {
+ {
+ if (resolveFamily === null) {
+ // Hot reloading is disabled.
+ return;
+ }
-var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
-
-var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
-// scheduler is the actual recommendation. The alternative could be a testing build,
-// a new lib, or whatever; we dunno just yet. This message is for early adopters
-// to get their tests right.
+ var staleFamilies = update.staleFamilies,
+ updatedFamilies = update.updatedFamilies;
+ flushPassiveEffects();
+ flushSync(function() {
+ scheduleFibersWithFamiliesRecursively(
+ root.current,
+ updatedFamilies,
+ staleFamilies
+ );
+ });
+ }
+};
+var scheduleRoot = function(root, element) {
+ {
+ if (root.context !== emptyContextObject) {
+ // Super edge case: root has a legacy _renderSubtree context
+ // but we don't know the parentComponent so we can't pass it.
+ // Just ignore. We'll delete this with _renderSubtree code path later.
+ return;
+ }
-function warnIfUnmockedScheduler(fiber) {
+ flushPassiveEffects();
+ flushSync(function() {
+ updateContainer(element, root, null, null);
+ });
+ }
+};
+
+function scheduleFibersWithFamiliesRecursively(
+ fiber,
+ updatedFamilies,
+ staleFamilies
+) {
{
- if (
- didWarnAboutUnmockedScheduler === false &&
- Scheduler.unstable_flushAllWithoutAsserting === undefined
- ) {
- if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
- didWarnAboutUnmockedScheduler = true;
+ var alternate = fiber.alternate,
+ child = fiber.child,
+ sibling = fiber.sibling,
+ tag = fiber.tag,
+ type = fiber.type;
+ var candidateType = null;
- error(
- 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
- "to guarantee consistent behaviour across tests and browsers. " +
- "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
- "jest.mock('scheduler', () => require" +
- "('scheduler/unstable_mock'));\n\n" +
- "For more info, visit https://fb.me/react-mock-scheduler"
- );
- } else {
- didWarnAboutUnmockedScheduler = true;
+ switch (tag) {
+ case FunctionComponent:
+ case SimpleMemoComponent:
+ case ClassComponent:
+ candidateType = type;
+ break;
- error(
- 'Starting from React v17, the "scheduler" module will need to be mocked ' +
- "to guarantee consistent behaviour across tests and browsers. " +
- "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies.
- "jest.mock('scheduler', () => require" +
- "('scheduler/unstable_mock'));\n\n" +
- "For more info, visit https://fb.me/react-mock-scheduler"
- );
- }
+ case ForwardRef:
+ candidateType = type.render;
+ break;
}
- }
-}
-function computeThreadID(root, expirationTime) {
- // Interaction threads are unique per root and expiration time.
- return expirationTime * 1000 + root.interactionThreadID;
-}
+ if (resolveFamily === null) {
+ throw new Error("Expected resolveFamily to be set during hot reload.");
+ }
-function markSpawnedWork(expirationTime) {
- if (spawnedWorkDuringRender === null) {
- spawnedWorkDuringRender = [expirationTime];
- } else {
- spawnedWorkDuringRender.push(expirationTime);
- }
-}
+ var needsRender = false;
+ var needsRemount = false;
-function scheduleInteractions(root, expirationTime, interactions) {
- if (interactions.size > 0) {
- var pendingInteractionMap = root.pendingInteractionMap;
- var pendingInteractions = pendingInteractionMap.get(expirationTime);
+ if (candidateType !== null) {
+ var family = resolveFamily(candidateType);
- if (pendingInteractions != null) {
- interactions.forEach(function(interaction) {
- if (!pendingInteractions.has(interaction)) {
- // Update the pending async work count for previously unscheduled interaction.
- interaction.__count++;
+ if (family !== undefined) {
+ if (staleFamilies.has(family)) {
+ needsRemount = true;
+ } else if (updatedFamilies.has(family)) {
+ if (tag === ClassComponent) {
+ needsRemount = true;
+ } else {
+ needsRender = true;
+ }
}
+ }
+ }
- pendingInteractions.add(interaction);
- });
- } else {
- pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions.
+ if (failedBoundaries !== null) {
+ if (
+ failedBoundaries.has(fiber) ||
+ (alternate !== null && failedBoundaries.has(alternate))
+ ) {
+ needsRemount = true;
+ }
+ }
- interactions.forEach(function(interaction) {
- interaction.__count++;
- });
+ if (needsRemount) {
+ fiber._debugNeedsRemount = true;
}
- var subscriber = tracing.__subscriberRef.current;
+ if (needsRemount || needsRender) {
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
+ }
- if (subscriber !== null) {
- var threadID = computeThreadID(root, expirationTime);
- subscriber.onWorkScheduled(interactions, threadID);
+ if (child !== null && !needsRemount) {
+ scheduleFibersWithFamiliesRecursively(
+ child,
+ updatedFamilies,
+ staleFamilies
+ );
}
- }
-}
-function schedulePendingInteractions(root, expirationTime) {
- scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
+ if (sibling !== null) {
+ scheduleFibersWithFamiliesRecursively(
+ sibling,
+ updatedFamilies,
+ staleFamilies
+ );
+ }
+ }
}
-function startWorkOnPendingInteractions(root, expirationTime) {
- // we can accurately attribute time spent working on it, And so that cascading
- // work triggered during the render phase will be associated with it.
+var findHostInstancesForRefresh = function(root, families) {
+ {
+ var hostInstances = new Set();
+ var types = new Set(
+ families.map(function(family) {
+ return family.current;
+ })
+ );
+ findHostInstancesForMatchingFibersRecursively(
+ root.current,
+ types,
+ hostInstances
+ );
+ return hostInstances;
+ }
+};
- var interactions = new Set();
- root.pendingInteractionMap.forEach(function(
- scheduledInteractions,
- scheduledExpirationTime
- ) {
- if (scheduledExpirationTime >= expirationTime) {
- scheduledInteractions.forEach(function(interaction) {
- return interactions.add(interaction);
- });
- }
- }); // Store the current set of interactions on the FiberRoot for a few reasons:
- // We can re-use it in hot functions like performConcurrentWorkOnRoot()
- // without having to recalculate it. We will also use it in commitWork() to
- // pass to any Profiler onRender() hooks. This also provides DevTools with a
- // way to access it when the onCommitRoot() hook is called.
+function findHostInstancesForMatchingFibersRecursively(
+ fiber,
+ types,
+ hostInstances
+) {
+ {
+ var child = fiber.child,
+ sibling = fiber.sibling,
+ tag = fiber.tag,
+ type = fiber.type;
+ var candidateType = null;
- root.memoizedInteractions = interactions;
+ switch (tag) {
+ case FunctionComponent:
+ case SimpleMemoComponent:
+ case ClassComponent:
+ candidateType = type;
+ break;
- if (interactions.size > 0) {
- var subscriber = tracing.__subscriberRef.current;
+ case ForwardRef:
+ candidateType = type.render;
+ break;
+ }
- if (subscriber !== null) {
- var threadID = computeThreadID(root, expirationTime);
+ var didMatch = false;
- try {
- subscriber.onWorkStarted(interactions, threadID);
- } catch (error) {
- // If the subscriber throws, rethrow it in a separate task
- scheduleCallback(ImmediatePriority, function() {
- throw error;
- });
+ if (candidateType !== null) {
+ if (types.has(candidateType)) {
+ didMatch = true;
}
}
- }
-}
-
-function finishPendingInteractions(root, committedExpirationTime) {
- var earliestRemainingTimeAfterCommit = root.firstPendingTime;
- var subscriber;
- try {
- subscriber = tracing.__subscriberRef.current;
-
- if (subscriber !== null && root.memoizedInteractions.size > 0) {
- var threadID = computeThreadID(root, committedExpirationTime);
- subscriber.onWorkStopped(root.memoizedInteractions, threadID);
+ if (didMatch) {
+ // We have a match. This only drills down to the closest host components.
+ // There's no need to search deeper because for the purpose of giving
+ // visual feedback, "flashing" outermost parent rectangles is sufficient.
+ findHostInstancesForFiberShallowly(fiber, hostInstances);
+ } else {
+ // If there's no match, maybe there will be one further down in the child tree.
+ if (child !== null) {
+ findHostInstancesForMatchingFibersRecursively(
+ child,
+ types,
+ hostInstances
+ );
+ }
}
- } catch (error) {
- // If the subscriber throws, rethrow it in a separate task
- scheduleCallback(ImmediatePriority, function() {
- throw error;
- });
- } finally {
- // Clear completed interactions from the pending Map.
- // Unless the render was suspended or cascading work was scheduled,
- // In which case– leave pending interactions until the subsequent render.
- var pendingInteractionMap = root.pendingInteractionMap;
- pendingInteractionMap.forEach(function(
- scheduledInteractions,
- scheduledExpirationTime
- ) {
- // Only decrement the pending interaction count if we're done.
- // If there's still work at the current priority,
- // That indicates that we are waiting for suspense data.
- if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
- pendingInteractionMap.delete(scheduledExpirationTime);
- scheduledInteractions.forEach(function(interaction) {
- interaction.__count--;
- if (subscriber !== null && interaction.__count === 0) {
- try {
- subscriber.onInteractionScheduledWorkCompleted(interaction);
- } catch (error) {
- // If the subscriber throws, rethrow it in a separate task
- scheduleCallback(ImmediatePriority, function() {
- throw error;
- });
- }
- }
- });
- }
- });
+ if (sibling !== null) {
+ findHostInstancesForMatchingFibersRecursively(
+ sibling,
+ types,
+ hostInstances
+ );
+ }
}
}
-var onScheduleFiberRoot = null;
-var onCommitFiberRoot = null;
-var onCommitFiberUnmount = null;
-var hasLoggedError = false;
-var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
-function injectInternals(internals) {
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") {
- // No DevTools
- return false;
- }
+function findHostInstancesForFiberShallowly(fiber, hostInstances) {
+ {
+ var foundHostInstances = findChildHostInstancesForFiberShallowly(
+ fiber,
+ hostInstances
+ );
- var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ if (foundHostInstances) {
+ return;
+ } // If we didn't find any host children, fallback to closest host parent.
- if (hook.isDisabled) {
- // This isn't a real property on the hook, but it can be set to opt out
- // of DevTools integration and associated warnings and logs.
- // https://github.com/facebook/react/issues/3877
- return true;
- }
+ var node = fiber;
- if (!hook.supportsFiber) {
- {
- error(
- "The installed version of React DevTools is too old and will not work " +
- "with the current version of React. Please update React DevTools. " +
- "https://fb.me/react-devtools"
- );
- } // DevTools exists, even though it doesn't support Fiber.
+ while (true) {
+ switch (node.tag) {
+ case HostComponent:
+ hostInstances.add(node.stateNode);
+ return;
- return true;
- }
+ case HostPortal:
+ hostInstances.add(node.stateNode.containerInfo);
+ return;
- try {
- var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
+ case HostRoot:
+ hostInstances.add(node.stateNode.containerInfo);
+ return;
+ }
- if (true) {
- // Only used by Fast Refresh
- if (typeof hook.onScheduleFiberRoot === "function") {
- onScheduleFiberRoot = function(root, children) {
- try {
- hook.onScheduleFiberRoot(rendererID, root, children);
- } catch (err) {
- if (true && !hasLoggedError) {
- hasLoggedError = true;
-
- error("React instrumentation encountered an error: %s", err);
- }
- }
- };
+ if (node.return === null) {
+ throw new Error("Expected to reach root first.");
}
- }
- onCommitFiberRoot = function(root, expirationTime) {
- try {
- var didError = (root.current.effectTag & DidCapture) === DidCapture;
+ node = node.return;
+ }
+ }
+}
- if (enableProfilerTimer) {
- var currentTime = getCurrentTime();
- var priorityLevel = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- );
- hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
- } else {
- hook.onCommitFiberRoot(rendererID, root, undefined, didError);
- }
- } catch (err) {
- if (true) {
- if (!hasLoggedError) {
- hasLoggedError = true;
+function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
+ {
+ var node = fiber;
+ var foundHostInstances = false;
- error("React instrumentation encountered an error: %s", err);
- }
- }
+ while (true) {
+ if (node.tag === HostComponent) {
+ // We got a match.
+ foundHostInstances = true;
+ hostInstances.add(node.stateNode); // There may still be more, so keep searching.
+ } else if (node.child !== null) {
+ node.child.return = node;
+ node = node.child;
+ continue;
}
- };
- onCommitFiberUnmount = function(fiber) {
- try {
- hook.onCommitFiberUnmount(rendererID, fiber);
- } catch (err) {
- if (true) {
- if (!hasLoggedError) {
- hasLoggedError = true;
+ if (node === fiber) {
+ return foundHostInstances;
+ }
- error("React instrumentation encountered an error: %s", err);
- }
+ while (node.sibling === null) {
+ if (node.return === null || node.return === fiber) {
+ return foundHostInstances;
}
+
+ node = node.return;
}
- };
- } catch (err) {
- // Catch all errors because it is unsafe to throw during initialization.
- {
- error("React instrumentation encountered an error: %s.", err);
- }
- } // DevTools exists
- return true;
-}
-function onScheduleRoot(root, children) {
- if (typeof onScheduleFiberRoot === "function") {
- onScheduleFiberRoot(root, children);
- }
-}
-function onCommitRoot(root, expirationTime) {
- if (typeof onCommitFiberRoot === "function") {
- onCommitFiberRoot(root, expirationTime);
- }
-}
-function onCommitUnmount(fiber) {
- if (typeof onCommitFiberUnmount === "function") {
- onCommitFiberUnmount(fiber);
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
}
+
+ return false;
}
var hasBadMapPolyfill;
@@ -19715,13 +21032,11 @@ var hasBadMapPolyfill;
try {
var nonExtensibleObject = Object.preventExtensions({});
- var testMap = new Map([[nonExtensibleObject, null]]);
- var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused.
- // https://github.com/rollup/rollup/issues/1771
- // TODO: we can remove these if Rollup fixes the bug.
+ /* eslint-disable no-new */
- testMap.set(0, 0);
- testSet.add(0);
+ new Map([[nonExtensibleObject, null]]);
+ new Set([nonExtensibleObject]);
+ /* eslint-enable no-new */
} catch (e) {
// TODO: Consider warning about bad polyfills
hasBadMapPolyfill = true;
@@ -19754,8 +21069,8 @@ function FiberNode(tag, pendingProps, key, mode) {
this.nextEffect = null;
this.firstEffect = null;
this.lastEffect = null;
- this.expirationTime = NoWork;
- this.childExpirationTime = NoWork;
+ this.lanes = NoLanes;
+ this.childLanes = NoLanes;
this.alternate = null;
{
@@ -19782,15 +21097,11 @@ function FiberNode(tag, pendingProps, key, mode) {
this.actualStartTime = -1;
this.selfBaseDuration = 0;
this.treeBaseDuration = 0;
- } // This is normally DEV-only except www when it adds listeners.
- // TODO: remove the User Timing integration in favor of Root Events.
-
- {
- this._debugID = debugCounter++;
- this._debugIsCurrentlyTiming = false;
}
{
+ // This isn't directly used but is handy for debugging internals:
+ this._debugID = debugCounter++;
this._debugSource = null;
this._debugOwner = null;
this._debugNeedsRemount = false;
@@ -19870,10 +21181,7 @@ function createWorkInProgress(current, pendingProps) {
{
// DEV-only fields
- {
- workInProgress._debugID = current._debugID;
- }
-
+ workInProgress._debugID = current._debugID;
workInProgress._debugSource = current._debugSource;
workInProgress._debugOwner = current._debugOwner;
workInProgress._debugHookTypes = current._debugHookTypes;
@@ -19882,7 +21190,9 @@ function createWorkInProgress(current, pendingProps) {
workInProgress.alternate = current;
current.alternate = workInProgress;
} else {
- workInProgress.pendingProps = pendingProps; // We already have an alternate.
+ workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type.
+
+ workInProgress.type = current.type; // We already have an alternate.
// Reset the effect tag.
workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
@@ -19901,21 +21211,8 @@ function createWorkInProgress(current, pendingProps) {
}
}
- {
- // Trying to debug a mysterious internal-only production failure.
- // See D20130868 and t62461245.
- // This is only on for RN FB builds.
- if (current == null) {
- throw Error("current is " + current + " but it can't be");
- }
-
- if (workInProgress == null) {
- throw Error("workInProgress is " + workInProgress + " but it can't be");
- }
- }
-
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
@@ -19927,7 +21224,7 @@ function createWorkInProgress(current, pendingProps) {
currentDependencies === null
? null
: {
- expirationTime: currentDependencies.expirationTime,
+ lanes: currentDependencies.lanes,
firstContext: currentDependencies.firstContext,
responders: currentDependencies.responders
}; // These will be overridden during the parent's reconciliation
@@ -19964,7 +21261,7 @@ function createWorkInProgress(current, pendingProps) {
return workInProgress;
} // Used to reuse a Fiber for a second pass.
-function resetWorkInProgress(workInProgress, renderExpirationTime) {
+function resetWorkInProgress(workInProgress, renderLanes) {
// This resets the Fiber to what createFiber or createWorkInProgress would
// have set the values to before during the first pass. Ideally this wouldn't
// be necessary but unfortunately many code paths reads from the workInProgress
@@ -19982,13 +21279,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) {
if (current === null) {
// Reset to createFiber's initial values.
- workInProgress.childExpirationTime = NoWork;
- workInProgress.expirationTime = renderExpirationTime;
+ workInProgress.childLanes = NoLanes;
+ workInProgress.lanes = renderLanes;
workInProgress.child = null;
workInProgress.memoizedProps = null;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
workInProgress.dependencies = null;
+ workInProgress.stateNode = null;
{
// Note: We don't reset the actualTime counts. It's useful to accumulate
@@ -19998,12 +21296,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) {
}
} else {
// Reset to the cloned values that createWorkInProgress would've.
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
- workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
+ workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type.
+
+ workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so
// it cannot be shared with the current fiber.
var currentDependencies = current.dependencies;
@@ -20011,7 +21311,7 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) {
currentDependencies === null
? null
: {
- expirationTime: currentDependencies.expirationTime,
+ lanes: currentDependencies.lanes,
firstContext: currentDependencies.firstContext,
responders: currentDependencies.responders
};
@@ -20052,9 +21352,8 @@ function createFiberFromTypeAndProps(
pendingProps,
owner,
mode,
- expirationTime
+ lanes
) {
- var fiber;
var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
var resolvedType = type;
@@ -20076,16 +21375,11 @@ function createFiberFromTypeAndProps(
} else {
getTag: switch (type) {
case REACT_FRAGMENT_TYPE:
- return createFiberFromFragment(
- pendingProps.children,
- mode,
- expirationTime,
- key
- );
+ return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_CONCURRENT_MODE_TYPE:
+ case REACT_DEBUG_TRACING_MODE_TYPE:
fiberTag = Mode;
- mode |= ConcurrentMode | BlockingMode | StrictMode;
+ mode |= DebugTracingMode;
break;
case REACT_STRICT_MODE_TYPE:
@@ -20094,18 +21388,23 @@ function createFiberFromTypeAndProps(
break;
case REACT_PROFILER_TYPE:
- return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
+ return createFiberFromProfiler(pendingProps, mode, lanes, key);
case REACT_SUSPENSE_TYPE:
- return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
+ return createFiberFromSuspense(pendingProps, mode, lanes, key);
case REACT_SUSPENSE_LIST_TYPE:
- return createFiberFromSuspenseList(
- pendingProps,
- mode,
- expirationTime,
- key
- );
+ return createFiberFromSuspenseList(pendingProps, mode, lanes, key);
+
+ case REACT_OFFSCREEN_TYPE:
+ return createFiberFromOffscreen(pendingProps, mode, lanes, key);
+
+ case REACT_LEGACY_HIDDEN_TYPE:
+ return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
+
+ case REACT_SCOPE_TYPE:
+
+ // eslint-disable-next-line no-fallthrough
default: {
if (typeof type === "object" && type !== null) {
@@ -20177,13 +21476,13 @@ function createFiberFromTypeAndProps(
}
}
- fiber = createFiber(fiberTag, pendingProps, key, mode);
+ var fiber = createFiber(fiberTag, pendingProps, key, mode);
fiber.elementType = type;
fiber.type = resolvedType;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromElement(element, mode, expirationTime) {
+function createFiberFromElement(element, mode, lanes) {
var owner = null;
{
@@ -20199,7 +21498,7 @@ function createFiberFromElement(element, mode, expirationTime) {
pendingProps,
owner,
mode,
- expirationTime
+ lanes
);
{
@@ -20209,13 +21508,13 @@ function createFiberFromElement(element, mode, expirationTime) {
return fiber;
}
-function createFiberFromFragment(elements, mode, expirationTime, key) {
+function createFiberFromFragment(elements, mode, lanes, key) {
var fiber = createFiber(Fragment, elements, key, mode);
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
+function createFiberFromProfiler(pendingProps, mode, lanes, key) {
{
if (typeof pendingProps.id !== "string") {
error('Profiler must specify an "id" as a prop');
@@ -20226,7 +21525,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
fiber.elementType = REACT_PROFILER_TYPE;
fiber.type = REACT_PROFILER_TYPE;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
{
fiber.stateNode = {
@@ -20238,17 +21537,17 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
return fiber;
}
-function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
+function createFiberFromSuspense(pendingProps, mode, lanes, key) {
var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
// This needs to be fixed in getComponentName so that it relies on the tag
// instead.
fiber.type = REACT_SUSPENSE_TYPE;
fiber.elementType = REACT_SUSPENSE_TYPE;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
+function createFiberFromSuspenseList(pendingProps, mode, lanes, key) {
var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
{
@@ -20259,18 +21558,44 @@ function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
}
fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
+ return fiber;
+}
+function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
+ var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag.
+ // This needs to be fixed in getComponentName so that it relies on the tag
+ // instead.
+
+ {
+ fiber.type = REACT_OFFSCREEN_TYPE;
+ }
+
+ fiber.elementType = REACT_OFFSCREEN_TYPE;
+ fiber.lanes = lanes;
+ return fiber;
+}
+function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) {
+ var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag.
+ // This needs to be fixed in getComponentName so that it relies on the tag
+ // instead.
+
+ {
+ fiber.type = REACT_LEGACY_HIDDEN_TYPE;
+ }
+
+ fiber.elementType = REACT_LEGACY_HIDDEN_TYPE;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromText(content, mode, expirationTime) {
+function createFiberFromText(content, mode, lanes) {
var fiber = createFiber(HostText, content, null, mode);
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
return fiber;
}
-function createFiberFromPortal(portal, mode, expirationTime) {
+function createFiberFromPortal(portal, mode, lanes) {
var pendingProps = portal.children !== null ? portal.children : [];
var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
- fiber.expirationTime = expirationTime;
+ fiber.lanes = lanes;
fiber.stateNode = {
containerInfo: portal.containerInfo,
pendingChildren: null,
@@ -20311,8 +21636,8 @@ function assignFiberPropertiesInDEV(target, source) {
target.nextEffect = source.nextEffect;
target.firstEffect = source.firstEffect;
target.lastEffect = source.lastEffect;
- target.expirationTime = source.expirationTime;
- target.childExpirationTime = source.childExpirationTime;
+ target.lanes = source.lanes;
+ target.childLanes = source.childLanes;
target.alternate = source.alternate;
{
@@ -20322,11 +21647,7 @@ function assignFiberPropertiesInDEV(target, source) {
target.treeBaseDuration = source.treeBaseDuration;
}
- {
- target._debugID = source._debugID;
- target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
- }
-
+ target._debugID = source._debugID;
target._debugSource = source._debugSource;
target._debugOwner = source._debugOwner;
target._debugNeedsRemount = source._debugNeedsRemount;
@@ -20336,30 +21657,49 @@ function assignFiberPropertiesInDEV(target, source) {
function FiberRootNode(containerInfo, tag, hydrate) {
this.tag = tag;
- this.current = null;
this.containerInfo = containerInfo;
this.pendingChildren = null;
+ this.current = null;
this.pingCache = null;
- this.finishedExpirationTime = NoWork;
this.finishedWork = null;
this.timeoutHandle = noTimeout;
this.context = null;
this.pendingContext = null;
this.hydrate = hydrate;
this.callbackNode = null;
- this.callbackPriority = NoPriority;
- this.firstPendingTime = NoWork;
- this.firstSuspendedTime = NoWork;
- this.lastSuspendedTime = NoWork;
- this.nextKnownPendingLevel = NoWork;
- this.lastPingedTime = NoWork;
- this.lastExpiredTime = NoWork;
+ this.callbackPriority = NoLanePriority;
+ this.eventTimes = createLaneMap(NoLanes);
+ this.expirationTimes = createLaneMap(NoTimestamp);
+ this.pendingLanes = NoLanes;
+ this.suspendedLanes = NoLanes;
+ this.pingedLanes = NoLanes;
+ this.expiredLanes = NoLanes;
+ this.mutableReadLanes = NoLanes;
+ this.finishedLanes = NoLanes;
+ this.entangledLanes = NoLanes;
+ this.entanglements = createLaneMap(NoLanes);
{
this.interactionThreadID = tracing.unstable_getThreadID();
this.memoizedInteractions = new Set();
this.pendingInteractionMap = new Map();
}
+
+ {
+ switch (tag) {
+ case BlockingRoot:
+ this._debugRootType = "createBlockingRoot()";
+ break;
+
+ case ConcurrentRoot:
+ this._debugRootType = "createRoot()";
+ break;
+
+ case LegacyRoot:
+ this._debugRootType = "createLegacyRoot()";
+ break;
+ }
+ }
}
function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
@@ -20372,95 +21712,22 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
initializeUpdateQueue(uninitializedFiber);
return root;
}
-function isRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- var lastSuspendedTime = root.lastSuspendedTime;
- return (
- firstSuspendedTime !== NoWork &&
- firstSuspendedTime >= expirationTime &&
- lastSuspendedTime <= expirationTime
- );
-}
-function markRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- var lastSuspendedTime = root.lastSuspendedTime;
-
- if (firstSuspendedTime < expirationTime) {
- root.firstSuspendedTime = expirationTime;
- }
-
- if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
- root.lastSuspendedTime = expirationTime;
- }
-
- if (expirationTime <= root.lastPingedTime) {
- root.lastPingedTime = NoWork;
- }
-
- if (expirationTime <= root.lastExpiredTime) {
- root.lastExpiredTime = NoWork;
- }
-}
-function markRootUpdatedAtTime(root, expirationTime) {
- // Update the range of pending times
- var firstPendingTime = root.firstPendingTime;
-
- if (expirationTime > firstPendingTime) {
- root.firstPendingTime = expirationTime;
- } // Update the range of suspended times. Treat everything lower priority or
- // equal to this update as unsuspended.
-
- var firstSuspendedTime = root.firstSuspendedTime;
-
- if (firstSuspendedTime !== NoWork) {
- if (expirationTime >= firstSuspendedTime) {
- // The entire suspended range is now unsuspended.
- root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
- } else if (expirationTime >= root.lastSuspendedTime) {
- root.lastSuspendedTime = expirationTime + 1;
- } // This is a pending level. Check if it's higher priority than the next
- // known pending level.
- if (expirationTime > root.nextKnownPendingLevel) {
- root.nextKnownPendingLevel = expirationTime;
- }
- }
-}
-function markRootFinishedAtTime(
- root,
- finishedExpirationTime,
- remainingExpirationTime
+function createPortal(
+ children,
+ containerInfo, // TODO: figure out the API for cross-renderer implementation.
+ implementation
) {
- // Update the range of pending times
- root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or
- // equal to this update as unsuspended.
-
- if (finishedExpirationTime <= root.lastSuspendedTime) {
- // The entire suspended range is now unsuspended.
- root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
- } else if (finishedExpirationTime <= root.firstSuspendedTime) {
- // Part of the suspended range is now unsuspended. Narrow the range to
- // include everything between the unsuspended time (non-inclusive) and the
- // last suspended time.
- root.firstSuspendedTime = finishedExpirationTime - 1;
- }
-
- if (finishedExpirationTime <= root.lastPingedTime) {
- // Clear the pinged time
- root.lastPingedTime = NoWork;
- }
-
- if (finishedExpirationTime <= root.lastExpiredTime) {
- // Clear the expired time
- root.lastExpiredTime = NoWork;
- }
-}
-function markRootExpiredAtTime(root, expirationTime) {
- var lastExpiredTime = root.lastExpiredTime;
-
- if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
- root.lastExpiredTime = expirationTime;
- }
+ var key =
+ arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
+ return {
+ // This tag allow us to uniquely identify this as a React Portal
+ $$typeof: REACT_PORTAL_TYPE,
+ key: key == null ? null : "" + key,
+ children: children,
+ containerInfo: containerInfo,
+ implementation: implementation
+ };
}
var didWarnAboutNestedUpdates;
@@ -20520,31 +21787,42 @@ function findHostInstanceWithWarning(component, methodName) {
if (!didWarnAboutFindNodeInStrictMode[componentName]) {
didWarnAboutFindNodeInStrictMode[componentName] = true;
+ var previousFiber = current;
- if (fiber.mode & StrictMode) {
- error(
- "%s is deprecated in StrictMode. " +
- "%s was passed an instance of %s which is inside StrictMode. " +
- "Instead, add a ref directly to the element you want to reference. " +
- "Learn more about using refs safely here: " +
- "https://fb.me/react-strict-mode-find-node%s",
- methodName,
- methodName,
- componentName,
- getStackByFiberInDevAndProd(hostFiber)
- );
- } else {
- error(
- "%s is deprecated in StrictMode. " +
- "%s was passed an instance of %s which renders StrictMode children. " +
- "Instead, add a ref directly to the element you want to reference. " +
- "Learn more about using refs safely here: " +
- "https://fb.me/react-strict-mode-find-node%s",
- methodName,
- methodName,
- componentName,
- getStackByFiberInDevAndProd(hostFiber)
- );
+ try {
+ setCurrentFiber(hostFiber);
+
+ if (fiber.mode & StrictMode) {
+ error(
+ "%s is deprecated in StrictMode. " +
+ "%s was passed an instance of %s which is inside StrictMode. " +
+ "Instead, add a ref directly to the element you want to reference. " +
+ "Learn more about using refs safely here: " +
+ "https://fb.me/react-strict-mode-find-node",
+ methodName,
+ methodName,
+ componentName
+ );
+ } else {
+ error(
+ "%s is deprecated in StrictMode. " +
+ "%s was passed an instance of %s which renders StrictMode children. " +
+ "Instead, add a ref directly to the element you want to reference. " +
+ "Learn more about using refs safely here: " +
+ "https://fb.me/react-strict-mode-find-node",
+ methodName,
+ methodName,
+ componentName
+ );
+ }
+ } finally {
+ // Ideally this should reset to previous but this shouldn't be called in
+ // render and there's another warning for that anyway.
+ if (previousFiber) {
+ setCurrentFiber(previousFiber);
+ } else {
+ resetCurrentFiber();
+ }
}
}
}
@@ -20562,7 +21840,7 @@ function updateContainer(element, container, parentComponent, callback) {
}
var current$1 = container.current;
- var currentTime = requestCurrentTimeForUpdate();
+ var eventTime = requestEventTime();
{
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
@@ -20573,11 +21851,8 @@ function updateContainer(element, container, parentComponent, callback) {
}
var suspenseConfig = requestCurrentSuspenseConfig();
- var expirationTime = computeExpirationForFiber(
- currentTime,
- current$1,
- suspenseConfig
- );
+ var lane = requestUpdateLane(current$1, suspenseConfig);
+
var context = getContextForSubtree(parentComponent);
if (container.context === null) {
@@ -20600,7 +21875,7 @@ function updateContainer(element, container, parentComponent, callback) {
}
}
- var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property
+ var update = createUpdate(eventTime, lane, suspenseConfig); // Caution: React DevTools currently depends on this property
// being called "element".
update.payload = {
@@ -20623,8 +21898,8 @@ function updateContainer(element, container, parentComponent, callback) {
}
enqueueUpdate(current$1, update);
- scheduleWork(current$1, expirationTime);
- return expirationTime;
+ scheduleUpdateOnFiber(current$1, lane, eventTime);
+ return lane;
}
function getPublicRootInstance(container) {
var containerFiber = container.current;
@@ -20691,7 +21966,7 @@ var setSuspenseHandler = null;
// Shallow cloning props works as a workaround for now to bypass the bailout check.
fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
- scheduleWork(fiber, Sync);
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
}; // Support DevTools props for function components, forwardRef, memo, host components, etc.
@@ -20702,11 +21977,11 @@ var setSuspenseHandler = null;
fiber.alternate.pendingProps = fiber.pendingProps;
}
- scheduleWork(fiber, Sync);
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
};
scheduleUpdate = function(fiber) {
- scheduleWork(fiber, Sync);
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
};
setSuspenseHandler = function(newShouldSuspendImpl) {
@@ -20714,6 +21989,24 @@ var setSuspenseHandler = null;
};
}
+function findHostInstanceByFiber(fiber) {
+ var hostFiber = findCurrentHostFiber(fiber);
+
+ if (hostFiber === null) {
+ return null;
+ }
+
+ return hostFiber.stateNode;
+}
+
+function emptyFindFiberByHostInstance(instance) {
+ return null;
+}
+
+function getCurrentFiberForDevTools() {
+ return current;
+}
+
function injectIntoDevTools(devToolsConfig) {
var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
@@ -20727,55 +22020,21 @@ function injectIntoDevTools(devToolsConfig) {
setSuspenseHandler: setSuspenseHandler,
scheduleUpdate: scheduleUpdate,
currentDispatcherRef: ReactCurrentDispatcher,
- findHostInstanceByFiber: function(fiber) {
- var hostFiber = findCurrentHostFiber(fiber);
-
- if (hostFiber === null) {
- return null;
- }
-
- return hostFiber.stateNode;
- },
- findFiberByHostInstance: function(instance) {
- if (!findFiberByHostInstance) {
- // Might not be implemented by the renderer.
- return null;
- }
-
- return findFiberByHostInstance(instance);
- },
+ findHostInstanceByFiber: findHostInstanceByFiber,
+ findFiberByHostInstance:
+ findFiberByHostInstance || emptyFindFiberByHostInstance,
// React Refresh
findHostInstancesForRefresh: findHostInstancesForRefresh,
scheduleRefresh: scheduleRefresh,
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
// Enables DevTools to append owner stacks to error messages in DEV mode.
- getCurrentFiber: function() {
- return current;
- }
+ getCurrentFiber: getCurrentFiberForDevTools
});
}
-var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing;
-
-function createPortal(
- children,
- containerInfo, // TODO: figure out the API for cross-renderer implementation.
- implementation
-) {
- var key =
- arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
- return {
- // This tag allow us to uniquely identify this as a React Portal
- $$typeof: REACT_PORTAL_TYPE,
- key: key == null ? null : "" + key,
- children: children,
- containerInfo: containerInfo,
- implementation: implementation
- };
-}
// TODO: this is special because it gets imported during build.
-var ReactVersion = "16.13.0";
+var ReactVersion = "17.0.0-alpha.0";
var emptyObject$1 = {};
@@ -21006,7 +22265,7 @@ var getInspectorDataForViewAtPoint;
);
} else {
error(
- "getInspectorDataForViewAtPoint expects to receieve a host component"
+ "getInspectorDataForViewAtPoint expects to receive a host component"
);
return;
diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js
index f32dc562752364..d47d2375b6c31c 100644
--- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js
+++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js
@@ -15,16 +15,6 @@ require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore");
var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"),
React = require("react"),
Scheduler = require("scheduler");
-function getParent(inst) {
- do inst = inst.return;
- while (inst && 5 !== inst.tag);
- return inst ? inst : null;
-}
-function traverseTwoPhase(inst, fn, arg) {
- for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
- for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
- for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
-}
function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) {
var funcArgs = Array.prototype.slice.call(arguments, 3);
try {
@@ -95,109 +85,6 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
-function getListener(inst, registrationName) {
- var listener = inst.stateNode;
- if (!listener) return null;
- var props = getFiberCurrentPropsFromNode(listener);
- if (!props) return null;
- listener = props[registrationName];
- a: switch (registrationName) {
- case "onClick":
- case "onClickCapture":
- case "onDoubleClick":
- case "onDoubleClickCapture":
- case "onMouseDown":
- case "onMouseDownCapture":
- case "onMouseMove":
- case "onMouseMoveCapture":
- case "onMouseUp":
- case "onMouseUpCapture":
- case "onMouseEnter":
- (props = !props.disabled) ||
- ((inst = inst.type),
- (props = !(
- "button" === inst ||
- "input" === inst ||
- "select" === inst ||
- "textarea" === inst
- )));
- inst = !props;
- break a;
- default:
- inst = !1;
- }
- if (inst) return null;
- if (listener && "function" !== typeof listener)
- throw Error(
- "Expected `" +
- registrationName +
- "` listener to be a function, instead got a value of `" +
- typeof listener +
- "` type."
- );
- return listener;
-}
-function accumulateInto(current, next) {
- if (null == next)
- throw Error(
- "accumulateInto(...): Accumulated items must not be null or undefined."
- );
- if (null == current) return next;
- if (Array.isArray(current)) {
- if (Array.isArray(next)) return current.push.apply(current, next), current;
- current.push(next);
- return current;
- }
- return Array.isArray(next) ? [current].concat(next) : [current, next];
-}
-function forEachAccumulated(arr, cb, scope) {
- Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
-}
-function accumulateDirectionalDispatches(inst, phase, event) {
- if (
- (phase = getListener(
- inst,
- event.dispatchConfig.phasedRegistrationNames[phase]
- ))
- )
- (event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- phase
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- ));
-}
-function accumulateTwoPhaseDispatchesSingle(event) {
- event &&
- event.dispatchConfig.phasedRegistrationNames &&
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
-}
-function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- var targetInst = event._targetInst;
- targetInst = targetInst ? getParent(targetInst) : null;
- traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
- }
-}
-function accumulateDirectDispatchesSingle(event) {
- if (event && event.dispatchConfig.registrationName) {
- var inst = event._targetInst;
- if (inst && event && event.dispatchConfig.registrationName) {
- var listener = getListener(inst, event.dispatchConfig.registrationName);
- listener &&
- ((event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- )));
- }
- }
-}
function functionThatReturnsTrue() {
return !0;
}
@@ -213,6 +100,7 @@ function SyntheticEvent(
this.dispatchConfig = dispatchConfig;
this._targetInst = targetInst;
this.nativeEvent = nativeEvent;
+ this._dispatchInstances = this._dispatchListeners = null;
dispatchConfig = this.constructor.Interface;
for (var propName in dispatchConfig)
dispatchConfig.hasOwnProperty(propName) &&
@@ -292,7 +180,12 @@ SyntheticEvent.extend = function(Interface) {
return Class;
};
addEventPoolingTo(SyntheticEvent);
-function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
+function createOrGetPooledEvent(
+ dispatchConfig,
+ targetInst,
+ nativeEvent,
+ nativeInst
+) {
if (this.eventPool.length) {
var instance = this.eventPool.pop();
this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
@@ -309,8 +202,8 @@ function releasePooledEvent(event) {
10 > this.eventPool.length && this.eventPool.push(event);
}
function addEventPoolingTo(EventConstructor) {
+ EventConstructor.getPooled = createOrGetPooledEvent;
EventConstructor.eventPool = [];
- EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}
var ResponderSyntheticEvent = SyntheticEvent.extend({
@@ -438,6 +331,22 @@ function accumulate(current, next) {
? [current].concat(next)
: [current, next];
}
+function accumulateInto(current, next) {
+ if (null == next)
+ throw Error(
+ "accumulateInto(...): Accumulated items must not be null or undefined."
+ );
+ if (null == current) return next;
+ if (Array.isArray(current)) {
+ if (Array.isArray(next)) return current.push.apply(current, next), current;
+ current.push(next);
+ return current;
+ }
+ return Array.isArray(next) ? [current].concat(next) : [current, next];
+}
+function forEachAccumulated(arr, cb, scope) {
+ Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
+}
var responderInst = null,
trackedTouchCount = 0;
function changeResponder(nextResponderInst, blockHostResponder) {
@@ -451,65 +360,132 @@ function changeResponder(nextResponderInst, blockHostResponder) {
);
}
var eventTypes = {
- startShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onStartShouldSetResponder",
- captured: "onStartShouldSetResponderCapture"
- },
- dependencies: startDependencies
- },
- scrollShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onScrollShouldSetResponder",
- captured: "onScrollShouldSetResponderCapture"
- },
- dependencies: ["topScroll"]
- },
- selectionChangeShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onSelectionChangeShouldSetResponder",
- captured: "onSelectionChangeShouldSetResponderCapture"
- },
- dependencies: ["topSelectionChange"]
- },
- moveShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onMoveShouldSetResponder",
- captured: "onMoveShouldSetResponderCapture"
- },
- dependencies: moveDependencies
- },
- responderStart: {
- registrationName: "onResponderStart",
- dependencies: startDependencies
- },
- responderMove: {
- registrationName: "onResponderMove",
- dependencies: moveDependencies
+ startShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onStartShouldSetResponder",
+ captured: "onStartShouldSetResponderCapture"
},
- responderEnd: {
- registrationName: "onResponderEnd",
- dependencies: endDependencies
- },
- responderRelease: {
- registrationName: "onResponderRelease",
- dependencies: endDependencies
+ dependencies: startDependencies
+ },
+ scrollShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onScrollShouldSetResponder",
+ captured: "onScrollShouldSetResponderCapture"
},
- responderTerminationRequest: {
- registrationName: "onResponderTerminationRequest",
- dependencies: []
+ dependencies: ["topScroll"]
+ },
+ selectionChangeShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onSelectionChangeShouldSetResponder",
+ captured: "onSelectionChangeShouldSetResponderCapture"
},
- responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
- responderReject: {
- registrationName: "onResponderReject",
- dependencies: []
+ dependencies: ["topSelectionChange"]
+ },
+ moveShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onMoveShouldSetResponder",
+ captured: "onMoveShouldSetResponderCapture"
},
- responderTerminate: {
- registrationName: "onResponderTerminate",
- dependencies: []
- }
+ dependencies: moveDependencies
+ },
+ responderStart: {
+ registrationName: "onResponderStart",
+ dependencies: startDependencies
+ },
+ responderMove: {
+ registrationName: "onResponderMove",
+ dependencies: moveDependencies
+ },
+ responderEnd: {
+ registrationName: "onResponderEnd",
+ dependencies: endDependencies
},
- ResponderEventPlugin = {
+ responderRelease: {
+ registrationName: "onResponderRelease",
+ dependencies: endDependencies
+ },
+ responderTerminationRequest: {
+ registrationName: "onResponderTerminationRequest",
+ dependencies: []
+ },
+ responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
+ responderReject: { registrationName: "onResponderReject", dependencies: [] },
+ responderTerminate: {
+ registrationName: "onResponderTerminate",
+ dependencies: []
+ }
+};
+function getParent(inst) {
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ return inst ? inst : null;
+}
+function traverseTwoPhase(inst, fn, arg) {
+ for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
+}
+function getListener(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+function accumulateDirectionalDispatches(inst, phase, event) {
+ if (
+ (phase = getListener(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateDirectDispatchesSingle(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
+function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ var targetInst = event._targetInst;
+ targetInst = targetInst ? getParent(targetInst) : null;
+ traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
+ }
+}
+function accumulateTwoPhaseDispatchesSingle(event) {
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
+}
+var ResponderEventPlugin = {
_getResponder: function() {
return responderInst;
},
@@ -570,68 +546,70 @@ var eventTypes = {
JSCompiler_temp = null;
}
else JSCompiler_temp = targetInst;
- targetInst = JSCompiler_temp === responderInst;
- JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ targetInst = JSCompiler_temp;
+ JSCompiler_temp = targetInst === responderInst;
+ shouldSetEventType = ResponderSyntheticEvent.getPooled(
shouldSetEventType,
- JSCompiler_temp,
+ targetInst,
nativeEvent,
nativeEventTarget
);
- JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory;
- targetInst
+ shouldSetEventType.touchHistory =
+ ResponderTouchHistoryStore.touchHistory;
+ JSCompiler_temp
? forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingleSkipTarget
)
: forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingle
);
b: {
- shouldSetEventType = JSCompiler_temp._dispatchListeners;
- targetInst = JSCompiler_temp._dispatchInstances;
- if (Array.isArray(shouldSetEventType))
+ JSCompiler_temp = shouldSetEventType._dispatchListeners;
+ targetInst = shouldSetEventType._dispatchInstances;
+ if (Array.isArray(JSCompiler_temp))
for (
depthA = 0;
- depthA < shouldSetEventType.length &&
- !JSCompiler_temp.isPropagationStopped();
+ depthA < JSCompiler_temp.length &&
+ !shouldSetEventType.isPropagationStopped();
depthA++
) {
if (
- shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA])
+ JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA])
) {
- shouldSetEventType = targetInst[depthA];
+ JSCompiler_temp = targetInst[depthA];
break b;
}
}
else if (
- shouldSetEventType &&
- shouldSetEventType(JSCompiler_temp, targetInst)
+ JSCompiler_temp &&
+ JSCompiler_temp(shouldSetEventType, targetInst)
) {
- shouldSetEventType = targetInst;
+ JSCompiler_temp = targetInst;
break b;
}
- shouldSetEventType = null;
+ JSCompiler_temp = null;
}
- JSCompiler_temp._dispatchInstances = null;
- JSCompiler_temp._dispatchListeners = null;
- JSCompiler_temp.isPersistent() ||
- JSCompiler_temp.constructor.release(JSCompiler_temp);
- if (shouldSetEventType && shouldSetEventType !== responderInst)
+ shouldSetEventType._dispatchInstances = null;
+ shouldSetEventType._dispatchListeners = null;
+ shouldSetEventType.isPersistent() ||
+ shouldSetEventType.constructor.release(shouldSetEventType);
+ if (JSCompiler_temp && JSCompiler_temp !== responderInst)
if (
- ((JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ ((shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderGrant,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
- (JSCompiler_temp.touchHistory =
+ (shouldSetEventType.touchHistory =
ResponderTouchHistoryStore.touchHistory),
forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateDirectDispatchesSingle
),
- (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)),
+ (targetInst = !0 === executeDirectDispatch(shouldSetEventType)),
responderInst)
)
if (
@@ -658,13 +636,13 @@ var eventTypes = {
forEachAccumulated(depthA, accumulateDirectDispatchesSingle);
var JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- [JSCompiler_temp, depthA]
+ [shouldSetEventType, depthA]
);
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
} else
(shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderReject,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
@@ -681,9 +659,9 @@ var eventTypes = {
else
(JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- JSCompiler_temp
+ shouldSetEventType
)),
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
else JSCompiler_temp$jscomp$0 = null;
} else JSCompiler_temp$jscomp$0 = null;
shouldSetEventType = responderInst && isStartish(topLevelType);
@@ -811,7 +789,6 @@ function recomputePluginOrdering() {
for (var eventName in pluginIndex) {
var JSCompiler_inline_result = void 0;
var dispatchConfig = pluginIndex[eventName],
- pluginModule$jscomp$0 = pluginModule,
eventName$jscomp$0 = eventName;
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
@@ -828,7 +805,7 @@ function recomputePluginOrdering() {
) &&
publishRegistrationName(
phasedRegistrationNames[JSCompiler_inline_result],
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
);
JSCompiler_inline_result = !0;
@@ -836,7 +813,7 @@ function recomputePluginOrdering() {
dispatchConfig.registrationName
? (publishRegistrationName(
dispatchConfig.registrationName,
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
),
(JSCompiler_inline_result = !0))
@@ -864,13 +841,75 @@ function publishRegistrationName(registrationName, pluginModule) {
}
var plugins = [],
eventNameDispatchConfigs = {},
- registrationNameModules = {},
- customBubblingEventTypes =
+ registrationNameModules = {};
+function getListener$1(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customBubblingEventTypes,
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateDirectionalDispatches$1(inst, phase, event) {
+ if (
+ (phase = getListener$1(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateTwoPhaseDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ for (var inst = event._targetInst, path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; )
+ accumulateDirectionalDispatches$1(path[inst], "captured", event);
+ for (inst = 0; inst < path.length; inst++)
+ accumulateDirectionalDispatches$1(path[inst], "bubbled", event);
+ }
+}
+function accumulateDirectDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener$1(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
if (eventPluginOrder)
throw Error(
"EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."
@@ -880,7 +919,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_94 = {
+var injectedNamesToPlugins$jscomp$inline_228 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -904,42 +943,45 @@ var injectedNamesToPlugins$jscomp$inline_94 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle);
+ forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
- forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle);
+ forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
return topLevelType;
}
}
},
- isOrderingDirty$jscomp$inline_95 = !1,
- pluginName$jscomp$inline_96;
-for (pluginName$jscomp$inline_96 in injectedNamesToPlugins$jscomp$inline_94)
+ isOrderingDirty$jscomp$inline_229 = !1,
+ pluginName$jscomp$inline_230;
+for (pluginName$jscomp$inline_230 in injectedNamesToPlugins$jscomp$inline_228)
if (
- injectedNamesToPlugins$jscomp$inline_94.hasOwnProperty(
- pluginName$jscomp$inline_96
+ injectedNamesToPlugins$jscomp$inline_228.hasOwnProperty(
+ pluginName$jscomp$inline_230
)
) {
- var pluginModule$jscomp$inline_97 =
- injectedNamesToPlugins$jscomp$inline_94[pluginName$jscomp$inline_96];
+ var pluginModule$jscomp$inline_231 =
+ injectedNamesToPlugins$jscomp$inline_228[pluginName$jscomp$inline_230];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_96) ||
- namesToPlugins[pluginName$jscomp$inline_96] !==
- pluginModule$jscomp$inline_97
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_230) ||
+ namesToPlugins[pluginName$jscomp$inline_230] !==
+ pluginModule$jscomp$inline_231
) {
- if (namesToPlugins[pluginName$jscomp$inline_96])
+ if (namesToPlugins[pluginName$jscomp$inline_230])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_96 +
+ pluginName$jscomp$inline_230 +
"`."
);
namesToPlugins[
- pluginName$jscomp$inline_96
- ] = pluginModule$jscomp$inline_97;
- isOrderingDirty$jscomp$inline_95 = !0;
+ pluginName$jscomp$inline_230
+ ] = pluginModule$jscomp$inline_231;
+ isOrderingDirty$jscomp$inline_229 = !0;
}
}
-isOrderingDirty$jscomp$inline_95 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_229 && recomputePluginOrdering();
var instanceCache = new Map(),
instanceProps = new Map();
function getInstanceFromTag(tag) {
@@ -985,34 +1027,41 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) {
target = null;
null != inst && (target = inst.stateNode);
batchedUpdates(function() {
- var events = target;
- for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) {
- var possiblePlugin = plugins[i];
+ var JSCompiler_inline_result = target;
+ for (
+ var events = null, legacyPlugins = plugins, i = 0;
+ i < legacyPlugins.length;
+ i++
+ ) {
+ var possiblePlugin = legacyPlugins[i];
possiblePlugin &&
(possiblePlugin = possiblePlugin.extractEvents(
topLevelType,
inst,
nativeEvent,
- events,
- 1
+ JSCompiler_inline_result
)) &&
- (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin));
+ (events = accumulateInto(events, possiblePlugin));
}
- events = events$jscomp$0;
- null !== events && (eventQueue = accumulateInto(eventQueue, events));
- events = eventQueue;
+ JSCompiler_inline_result = events;
+ null !== JSCompiler_inline_result &&
+ (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result));
+ JSCompiler_inline_result = eventQueue;
eventQueue = null;
- if (events) {
- forEachAccumulated(events, executeDispatchesAndReleaseTopLevel);
+ if (JSCompiler_inline_result) {
+ forEachAccumulated(
+ JSCompiler_inline_result,
+ executeDispatchesAndReleaseTopLevel
+ );
if (eventQueue)
throw Error(
"processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
);
if (hasRethrowError)
- throw ((events = rethrowError),
+ throw ((JSCompiler_inline_result = rethrowError),
(hasRethrowError = !1),
(rethrowError = null),
- events);
+ JSCompiler_inline_result);
}
});
}
@@ -1027,13 +1076,13 @@ ReactNativePrivateInterface.RCTEventEmitter.register({
) {
var JSCompiler_temp = [];
for (var i = 0; i < changedIndices.length; i++) {
- var index = changedIndices[i];
- JSCompiler_temp.push(touches[index]);
- touches[index] = null;
+ var index$0 = changedIndices[i];
+ JSCompiler_temp.push(touches[index$0]);
+ touches[index$0] = null;
}
for (i = changedIndices = 0; i < touches.length; i++)
- (index = touches[i]),
- null !== index && (touches[changedIndices++] = index);
+ (index$0 = touches[i]),
+ null !== index$0 && (touches[changedIndices++] = index$0);
touches.length = changedIndices;
} else
for (JSCompiler_temp = [], i = 0; i < changedIndices.length; i++)
@@ -1046,10 +1095,10 @@ ReactNativePrivateInterface.RCTEventEmitter.register({
i = JSCompiler_temp[changedIndices];
i.changedTouches = JSCompiler_temp;
i.touches = touches;
- index = null;
+ index$0 = null;
var target = i.target;
- null === target || void 0 === target || 1 > target || (index = target);
- _receiveRootNodeIDEvent(index, eventTopLevelType, i);
+ null === target || void 0 === target || 1 > target || (index$0 = target);
+ _receiveRootNodeIDEvent(index$0, eventTopLevelType, i);
}
}
});
@@ -1075,31 +1124,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
}
});
var ReactSharedInternals =
- React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") ||
- (ReactSharedInternals.ReactCurrentDispatcher = { current: null });
-ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") ||
- (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null });
-var hasSymbol = "function" === typeof Symbol && Symbol.for,
- REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103,
- REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106,
- REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107,
- REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108,
- REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114,
- REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109,
- REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110,
- REACT_CONCURRENT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.concurrent_mode")
- : 60111,
- REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112,
- REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113,
- REACT_SUSPENSE_LIST_TYPE = hasSymbol
- ? Symbol.for("react.suspense_list")
- : 60120,
- REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115,
- REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116,
- REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121,
- MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ REACT_ELEMENT_TYPE = 60103,
+ REACT_PORTAL_TYPE = 60106,
+ REACT_FRAGMENT_TYPE = 60107,
+ REACT_STRICT_MODE_TYPE = 60108,
+ REACT_PROFILER_TYPE = 60114,
+ REACT_PROVIDER_TYPE = 60109,
+ REACT_CONTEXT_TYPE = 60110,
+ REACT_FORWARD_REF_TYPE = 60112,
+ REACT_SUSPENSE_TYPE = 60113,
+ REACT_SUSPENSE_LIST_TYPE = 60120,
+ REACT_MEMO_TYPE = 60115,
+ REACT_LAZY_TYPE = 60116,
+ REACT_BLOCK_TYPE = 60121,
+ REACT_DEBUG_TRACING_MODE_TYPE = 60129,
+ REACT_OFFSCREEN_TYPE = 60130,
+ REACT_LEGACY_HIDDEN_TYPE = 60131;
+if ("function" === typeof Symbol && Symbol.for) {
+ var symbolFor = Symbol.for;
+ REACT_ELEMENT_TYPE = symbolFor("react.element");
+ REACT_PORTAL_TYPE = symbolFor("react.portal");
+ REACT_FRAGMENT_TYPE = symbolFor("react.fragment");
+ REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
+ REACT_PROFILER_TYPE = symbolFor("react.profiler");
+ REACT_PROVIDER_TYPE = symbolFor("react.provider");
+ REACT_CONTEXT_TYPE = symbolFor("react.context");
+ REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
+ REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
+ REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
+ REACT_MEMO_TYPE = symbolFor("react.memo");
+ REACT_LAZY_TYPE = symbolFor("react.lazy");
+ REACT_BLOCK_TYPE = symbolFor("react.block");
+ symbolFor("react.scope");
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
+ REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
+}
+var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -1107,27 +1169,6 @@ function getIteratorFn(maybeIterable) {
maybeIterable["@@iterator"];
return "function" === typeof maybeIterable ? maybeIterable : null;
}
-function initializeLazyComponentType(lazyComponent) {
- if (-1 === lazyComponent._status) {
- var ctor = lazyComponent._result;
- ctor || (ctor = lazyComponent._ctor);
- ctor = ctor();
- lazyComponent._status = 0;
- lazyComponent._result = ctor;
- ctor.then(
- function(moduleObject) {
- 0 === lazyComponent._status &&
- ((moduleObject = moduleObject.default),
- (lazyComponent._status = 1),
- (lazyComponent._result = moduleObject));
- },
- function(error) {
- 0 === lazyComponent._status &&
- ((lazyComponent._status = 2), (lazyComponent._result = error));
- }
- );
- }
-}
function getComponentName(type) {
if (null == type) return null;
if ("function" === typeof type) return type.displayName || type.name || null;
@@ -1162,10 +1203,13 @@ function getComponentName(type) {
case REACT_MEMO_TYPE:
return getComponentName(type.type);
case REACT_BLOCK_TYPE:
- return getComponentName(type.render);
+ return getComponentName(type._render);
case REACT_LAZY_TYPE:
- if ((type = 1 === type._status ? type._result : null))
- return getComponentName(type);
+ innerType = type._payload;
+ type = type._init;
+ try {
+ return getComponentName(type(innerType));
+ } catch (x) {}
}
return null;
}
@@ -1217,36 +1261,36 @@ function findCurrentFiberUsingSlowPath(fiber) {
}
if (a.return !== b.return) (a = parentA), (b = parentB);
else {
- for (var didFindChild = !1, _child = parentA.child; _child; ) {
- if (_child === a) {
+ for (var didFindChild = !1, child$1 = parentA.child; child$1; ) {
+ if (child$1 === a) {
didFindChild = !0;
a = parentA;
b = parentB;
break;
}
- if (_child === b) {
+ if (child$1 === b) {
didFindChild = !0;
b = parentA;
a = parentB;
break;
}
- _child = _child.sibling;
+ child$1 = child$1.sibling;
}
if (!didFindChild) {
- for (_child = parentB.child; _child; ) {
- if (_child === a) {
+ for (child$1 = parentB.child; child$1; ) {
+ if (child$1 === a) {
didFindChild = !0;
a = parentB;
b = parentA;
break;
}
- if (_child === b) {
+ if (child$1 === b) {
didFindChild = !0;
b = parentB;
a = parentA;
break;
}
- _child = _child.sibling;
+ child$1 = child$1.sibling;
}
if (!didFindChild)
throw Error(
@@ -1281,6 +1325,18 @@ function findCurrentHostFiber(parent) {
}
return null;
}
+function doesFiberContain(parentFiber, childFiber) {
+ for (
+ var parentFiberAlternate = parentFiber.alternate;
+ null !== childFiber;
+
+ ) {
+ if (childFiber === parentFiber || childFiber === parentFiberAlternate)
+ return !0;
+ childFiber = childFiber.return;
+ }
+ return !1;
+}
var emptyObject = {},
removedKeys = null,
removedKeyCount = 0,
@@ -1485,19 +1541,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
),
(removedKeys = null));
}
- for (var _propKey in prevProps)
- void 0 === nextProps[_propKey] &&
- (!(attributeConfig = validAttributes[_propKey]) ||
- (updatePayload && void 0 !== updatePayload[_propKey]) ||
- ((prevProp = prevProps[_propKey]),
+ for (var propKey$3 in prevProps)
+ void 0 === nextProps[propKey$3] &&
+ (!(attributeConfig = validAttributes[propKey$3]) ||
+ (updatePayload && void 0 !== updatePayload[propKey$3]) ||
+ ((prevProp = prevProps[propKey$3]),
void 0 !== prevProp &&
("object" !== typeof attributeConfig ||
"function" === typeof attributeConfig.diff ||
"function" === typeof attributeConfig.process
- ? (((updatePayload || (updatePayload = {}))[_propKey] = null),
+ ? (((updatePayload || (updatePayload = {}))[propKey$3] = null),
removedKeys || (removedKeys = {}),
- removedKeys[_propKey] ||
- ((removedKeys[_propKey] = !0), removedKeyCount++))
+ removedKeys[propKey$3] ||
+ ((removedKeys[propKey$3] = !0), removedKeyCount++))
: (updatePayload = clearNestedProperty(
updatePayload,
prevProp,
@@ -1606,9 +1662,22 @@ function finalizeInitialChildren(parentInstance) {
return !1;
}
var scheduleTimeout = setTimeout,
- cancelTimeout = clearTimeout,
- valueStack = [],
+ cancelTimeout = clearTimeout;
+function describeComponentFrame(name, source, ownerName) {
+ source = "";
+ ownerName && (source = " (created by " + ownerName + ")");
+ return "\n in " + (name || "Unknown") + source;
+}
+function describeFunctionComponentFrame(fn, source) {
+ return fn
+ ? describeComponentFrame(fn.displayName || fn.name || null, source, null)
+ : "";
+}
+var valueStack = [],
index = -1;
+function createCursor(defaultValue) {
+ return { current: defaultValue };
+}
function pop(cursor) {
0 > index ||
((cursor.current = valueStack[index]), (valueStack[index] = null), index--);
@@ -1619,8 +1688,8 @@ function push(cursor, value) {
cursor.current = value;
}
var emptyContextObject = {},
- contextStackCursor = { current: emptyContextObject },
- didPerformWorkStackCursor = { current: !1 },
+ contextStackCursor = createCursor(emptyContextObject),
+ didPerformWorkStackCursor = createCursor(!1),
previousContext = emptyContextObject;
function getMaskedContext(workInProgress, unmaskedContext) {
var contextTypes = workInProgress.type.contextTypes;
@@ -1700,11 +1769,220 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
+var rendererID = null,
+ injectedHook = null,
+ Scheduler_now = Scheduler.unstable_now;
+Scheduler_now();
+var return_highestLanePriority = 10;
+function getHighestPriorityLanes(lanes) {
+ if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1;
+ if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2;
+ if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4;
+ var inputDiscreteLanes = 24 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 14), inputDiscreteLanes;
+ if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32;
+ inputDiscreteLanes = 192 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 12), inputDiscreteLanes;
+ if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256;
+ inputDiscreteLanes = 3584 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 10), inputDiscreteLanes;
+ if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096;
+ inputDiscreteLanes = 122880 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 8), inputDiscreteLanes;
+ if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072;
+ inputDiscreteLanes = 3932160 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 6), inputDiscreteLanes;
+ inputDiscreteLanes = 62914560 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 5), inputDiscreteLanes;
+ if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864;
+ if (0 !== (lanes & 134217728))
+ return (return_highestLanePriority = 3), 134217728;
+ inputDiscreteLanes = 805306368 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 2), inputDiscreteLanes;
+ if (0 !== (1073741824 & lanes))
+ return (return_highestLanePriority = 1), 1073741824;
+ return_highestLanePriority = 10;
+ return lanes;
+}
+function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
+ switch (schedulerPriorityLevel) {
+ case 99:
+ return 17;
+ case 98:
+ return 12;
+ case 97:
+ case 96:
+ return 10;
+ case 95:
+ return 2;
+ default:
+ return 0;
+ }
+}
+function lanePriorityToSchedulerPriority(lanePriority) {
+ switch (lanePriority) {
+ case 17:
+ case 16:
+ return 99;
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ return 98;
+ case 11:
+ case 10:
+ case 9:
+ case 8:
+ case 7:
+ case 6:
+ case 4:
+ case 5:
+ return 97;
+ case 3:
+ case 2:
+ case 1:
+ return 95;
+ case 0:
+ return 90;
+ default:
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+ }
+}
+function getNextLanes(root, wipLanes) {
+ var pendingLanes = root.pendingLanes;
+ if (0 === pendingLanes) return (return_highestLanePriority = 0);
+ var nextLanes = 0,
+ nextLanePriority = 0,
+ expiredLanes = root.expiredLanes,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes;
+ if (0 !== expiredLanes)
+ (nextLanes = expiredLanes),
+ (nextLanePriority = return_highestLanePriority = 17);
+ else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) {
+ var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes;
+ 0 !== nonIdleUnblockedLanes
+ ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : ((pingedLanes &= expiredLanes),
+ 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority)));
+ } else
+ (expiredLanes = pendingLanes & ~suspendedLanes),
+ 0 !== expiredLanes
+ ? ((nextLanes = getHighestPriorityLanes(expiredLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority));
+ if (0 === nextLanes) return 0;
+ nextLanes = 31 - clz32(nextLanes);
+ nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1);
+ if (
+ 0 !== wipLanes &&
+ wipLanes !== nextLanes &&
+ 0 === (wipLanes & suspendedLanes)
+ ) {
+ getHighestPriorityLanes(wipLanes);
+ if (nextLanePriority <= return_highestLanePriority) return wipLanes;
+ return_highestLanePriority = nextLanePriority;
+ }
+ wipLanes = root.entangledLanes;
+ if (0 !== wipLanes)
+ for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; )
+ (pendingLanes = 31 - clz32(wipLanes)),
+ (nextLanePriority = 1 << pendingLanes),
+ (nextLanes |= root[pendingLanes]),
+ (wipLanes &= ~nextLanePriority);
+ return nextLanes;
+}
+function getMostRecentEventTime(root, lanes) {
+ root = root.eventTimes;
+ for (var mostRecentEventTime = -1; 0 < lanes; ) {
+ var index$6 = 31 - clz32(lanes),
+ lane = 1 << index$6;
+ index$6 = root[index$6];
+ index$6 > mostRecentEventTime && (mostRecentEventTime = index$6);
+ lanes &= ~lane;
+ }
+ return mostRecentEventTime;
+}
+function getLanesToRetrySynchronouslyOnError(root) {
+ root = root.pendingLanes & -1073741825;
+ return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0;
+}
+function findUpdateLane(lanePriority, wipLanes) {
+ switch (lanePriority) {
+ case 17:
+ return 1;
+ case 16:
+ return 2;
+ case 14:
+ return (
+ (lanePriority = getHighestPriorityLane(24 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority
+ );
+ case 12:
+ return (
+ (lanePriority = getHighestPriorityLane(192 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority
+ );
+ case 10:
+ return (
+ (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)),
+ 0 === lanePriority &&
+ ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)),
+ 0 === lanePriority && (lanePriority = 512)),
+ lanePriority
+ );
+ case 2:
+ return (
+ (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)),
+ 0 === wipLanes && (wipLanes = 268435456),
+ wipLanes
+ );
+ }
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+}
+function getHighestPriorityLane(lanes) {
+ return lanes & -lanes;
+}
+function pickArbitraryLane(lanes) {
+ return lanes & -lanes;
+}
+function markRootUpdated(root, updateLane, eventTime) {
+ root.pendingLanes |= updateLane;
+ var higherPriorityLanes = updateLane - 1;
+ root.suspendedLanes &= higherPriorityLanes;
+ root.pingedLanes &= higherPriorityLanes;
+ root = root.eventTimes;
+ updateLane = 31 - clz32(updateLane);
+ root[updateLane] = eventTime;
+}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(lanes) {
+ return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0;
+}
var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
+ Scheduler_shouldYield = Scheduler.unstable_shouldYield,
Scheduler_requestPaint = Scheduler.unstable_requestPaint,
- Scheduler_now = Scheduler.unstable_now,
+ Scheduler_now$1 = Scheduler.unstable_now,
Scheduler_getCurrentPriorityLevel =
Scheduler.unstable_getCurrentPriorityLevel,
Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
@@ -1713,18 +1991,17 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
Scheduler_LowPriority = Scheduler.unstable_LowPriority,
Scheduler_IdlePriority = Scheduler.unstable_IdlePriority,
fakeCallbackNode = {},
- shouldYield = Scheduler.unstable_shouldYield,
requestPaint =
void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {},
syncQueue = null,
immediateQueueCallbackNode = null,
isFlushingSyncQueue = !1,
- initialTimeMs = Scheduler_now(),
+ initialTimeMs$1 = Scheduler_now$1(),
now =
- 1e4 > initialTimeMs
- ? Scheduler_now
+ 1e4 > initialTimeMs$1
+ ? Scheduler_now$1
: function() {
- return Scheduler_now() - initialTimeMs;
+ return Scheduler_now$1() - initialTimeMs$1;
};
function getCurrentPriorityLevel() {
switch (Scheduler_getCurrentPriorityLevel()) {
@@ -1766,16 +2043,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) {
reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
return Scheduler_scheduleCallback(reactPriorityLevel, callback, options);
}
-function scheduleSyncCallback(callback) {
- null === syncQueue
- ? ((syncQueue = [callback]),
- (immediateQueueCallbackNode = Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueueImpl
- )))
- : syncQueue.push(callback);
- return fakeCallbackNode;
-}
function flushSyncCallbackQueue() {
if (null !== immediateQueueCallbackNode) {
var node = immediateQueueCallbackNode;
@@ -1810,6 +2077,42 @@ function flushSyncCallbackQueueImpl() {
}
}
}
+function describeFiber(fiber) {
+ switch (fiber.tag) {
+ case 5:
+ return describeComponentFrame(fiber.type, null, null);
+ case 16:
+ return describeComponentFrame("Lazy", null, null);
+ case 13:
+ return describeComponentFrame("Suspense", null, null);
+ case 19:
+ return describeComponentFrame("SuspenseList", null, null);
+ case 0:
+ case 2:
+ case 15:
+ return describeFunctionComponentFrame(fiber.type, null);
+ case 11:
+ return describeFunctionComponentFrame(fiber.type.render, null);
+ case 22:
+ return describeFunctionComponentFrame(fiber.type._render, null);
+ case 1:
+ return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber;
+ default:
+ return "";
+ }
+}
+function getStackByFiberInDevAndProd(workInProgress) {
+ try {
+ var info = "";
+ do
+ (info += describeFiber(workInProgress)),
+ (workInProgress = workInProgress.return);
+ while (workInProgress);
+ return info;
+ } catch (x) {
+ return "\nError generating stack: " + x.message + "\n" + x.stack;
+ }
+}
function is(x, y) {
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
}
@@ -1835,43 +2138,6 @@ function shallowEqual(objA, objB) {
return !1;
return !0;
}
-var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
-function getStackByFiberInDevAndProd(workInProgress) {
- var info = "";
- do {
- a: switch (workInProgress.tag) {
- case 3:
- case 4:
- case 6:
- case 7:
- case 10:
- case 9:
- var JSCompiler_inline_result = "";
- break a;
- default:
- var owner = workInProgress._debugOwner,
- source = workInProgress._debugSource,
- name = getComponentName(workInProgress.type);
- JSCompiler_inline_result = null;
- owner && (JSCompiler_inline_result = getComponentName(owner.type));
- owner = name;
- name = "";
- source
- ? (name =
- " (at " +
- source.fileName.replace(BEFORE_SLASH_RE, "") +
- ":" +
- source.lineNumber +
- ")")
- : JSCompiler_inline_result &&
- (name = " (created by " + JSCompiler_inline_result + ")");
- JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name;
- }
- info += JSCompiler_inline_result;
- workInProgress = workInProgress.return;
- } while (workInProgress);
- return info;
-}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
baseProps = Object.assign({}, baseProps);
@@ -1879,10 +2145,11 @@ function resolveDefaultProps(Component, baseProps) {
for (var propName in Component)
void 0 === baseProps[propName] &&
(baseProps[propName] = Component[propName]);
+ return baseProps;
}
return baseProps;
}
-var valueCursor = { current: null },
+var valueCursor = createCursor(null),
currentlyRenderingFiber = null,
lastContextDependency = null,
lastContextWithAllBitsObserved = null;
@@ -1894,31 +2161,29 @@ function popProvider(providerFiber) {
pop(valueCursor);
providerFiber.type._context._currentValue = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderExpirationTime) {
+function scheduleWorkOnParentPath(parent, renderLanes) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- if (parent.childExpirationTime < renderExpirationTime)
- (parent.childExpirationTime = renderExpirationTime),
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime &&
- (alternate.childExpirationTime = renderExpirationTime);
- else if (
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime
- )
- alternate.childExpirationTime = renderExpirationTime;
- else break;
+ if ((parent.childLanes & renderLanes) === renderLanes)
+ if (
+ null === alternate ||
+ (alternate.childLanes & renderLanes) === renderLanes
+ )
+ break;
+ else alternate.childLanes |= renderLanes;
+ else
+ (parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes);
parent = parent.return;
}
}
-function prepareToReadContext(workInProgress, renderExpirationTime) {
+function prepareToReadContext(workInProgress, renderLanes) {
currentlyRenderingFiber = workInProgress;
lastContextWithAllBitsObserved = lastContextDependency = null;
workInProgress = workInProgress.dependencies;
null !== workInProgress &&
null !== workInProgress.firstContext &&
- (workInProgress.expirationTime >= renderExpirationTime &&
- (didReceiveUpdate = !0),
+ (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0),
(workInProgress.firstContext = null));
}
function readContext(context, observedBits) {
@@ -1937,7 +2202,7 @@ function readContext(context, observedBits) {
);
lastContextDependency = observedBits;
currentlyRenderingFiber.dependencies = {
- expirationTime: 0,
+ lanes: 0,
firstContext: observedBits,
responders: null
};
@@ -1949,7 +2214,8 @@ var hasForceUpdate = !1;
function initializeUpdateQueue(fiber) {
fiber.updateQueue = {
baseState: fiber.memoizedState,
- baseQueue: null,
+ firstBaseUpdate: null,
+ lastBaseUpdate: null,
shared: { pending: null },
effects: null
};
@@ -1959,21 +2225,22 @@ function cloneUpdateQueue(current, workInProgress) {
workInProgress.updateQueue === current &&
(workInProgress.updateQueue = {
baseState: current.baseState,
- baseQueue: current.baseQueue,
+ firstBaseUpdate: current.firstBaseUpdate,
+ lastBaseUpdate: current.lastBaseUpdate,
shared: current.shared,
effects: current.effects
});
}
-function createUpdate(expirationTime, suspenseConfig) {
- expirationTime = {
- expirationTime: expirationTime,
+function createUpdate(eventTime, lane, suspenseConfig) {
+ return {
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
tag: 0,
payload: null,
callback: null,
next: null
};
- return (expirationTime.next = expirationTime);
}
function enqueueUpdate(fiber, update) {
fiber = fiber.updateQueue;
@@ -1986,132 +2253,185 @@ function enqueueUpdate(fiber, update) {
fiber.pending = update;
}
}
-function enqueueCapturedUpdate(workInProgress, update) {
- var current = workInProgress.alternate;
- null !== current && cloneUpdateQueue(current, workInProgress);
- workInProgress = workInProgress.updateQueue;
- current = workInProgress.baseQueue;
- null === current
- ? ((workInProgress.baseQueue = update.next = update),
- (update.next = update))
- : ((update.next = current.next), (current.next = update));
+function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
+ var queue = workInProgress.updateQueue,
+ current = workInProgress.alternate;
+ if (
+ null !== current &&
+ ((current = current.updateQueue), queue === current)
+ ) {
+ var newFirst = null,
+ newLast = null;
+ queue = queue.firstBaseUpdate;
+ if (null !== queue) {
+ do {
+ var clone = {
+ eventTime: queue.eventTime,
+ lane: queue.lane,
+ suspenseConfig: queue.suspenseConfig,
+ tag: queue.tag,
+ payload: queue.payload,
+ callback: queue.callback,
+ next: null
+ };
+ null === newLast
+ ? (newFirst = newLast = clone)
+ : (newLast = newLast.next = clone);
+ queue = queue.next;
+ } while (null !== queue);
+ null === newLast
+ ? (newFirst = newLast = capturedUpdate)
+ : (newLast = newLast.next = capturedUpdate);
+ } else newFirst = newLast = capturedUpdate;
+ queue = {
+ baseState: current.baseState,
+ firstBaseUpdate: newFirst,
+ lastBaseUpdate: newLast,
+ shared: current.shared,
+ effects: current.effects
+ };
+ workInProgress.updateQueue = queue;
+ return;
+ }
+ workInProgress = queue.lastBaseUpdate;
+ null === workInProgress
+ ? (queue.firstBaseUpdate = capturedUpdate)
+ : (workInProgress.next = capturedUpdate);
+ queue.lastBaseUpdate = capturedUpdate;
}
function processUpdateQueue(
workInProgress$jscomp$0,
props,
instance,
- renderExpirationTime
+ renderLanes
) {
var queue = workInProgress$jscomp$0.updateQueue;
hasForceUpdate = !1;
- var baseQueue = queue.baseQueue,
+ var firstBaseUpdate = queue.firstBaseUpdate,
+ lastBaseUpdate = queue.lastBaseUpdate,
pendingQueue = queue.shared.pending;
if (null !== pendingQueue) {
- if (null !== baseQueue) {
- var baseFirst = baseQueue.next;
- baseQueue.next = pendingQueue.next;
- pendingQueue.next = baseFirst;
- }
- baseQueue = pendingQueue;
queue.shared.pending = null;
- baseFirst = workInProgress$jscomp$0.alternate;
- null !== baseFirst &&
- ((baseFirst = baseFirst.updateQueue),
- null !== baseFirst && (baseFirst.baseQueue = pendingQueue));
+ var lastPendingUpdate = pendingQueue,
+ firstPendingUpdate = lastPendingUpdate.next;
+ lastPendingUpdate.next = null;
+ null === lastBaseUpdate
+ ? (firstBaseUpdate = firstPendingUpdate)
+ : (lastBaseUpdate.next = firstPendingUpdate);
+ lastBaseUpdate = lastPendingUpdate;
+ var current = workInProgress$jscomp$0.alternate;
+ if (null !== current) {
+ current = current.updateQueue;
+ var currentLastBaseUpdate = current.lastBaseUpdate;
+ currentLastBaseUpdate !== lastBaseUpdate &&
+ (null === currentLastBaseUpdate
+ ? (current.firstBaseUpdate = firstPendingUpdate)
+ : (currentLastBaseUpdate.next = firstPendingUpdate),
+ (current.lastBaseUpdate = lastPendingUpdate));
+ }
}
- if (null !== baseQueue) {
- baseFirst = baseQueue.next;
- var newState = queue.baseState,
- newExpirationTime = 0,
- newBaseState = null,
- newBaseQueueFirst = null,
- newBaseQueueLast = null;
- if (null !== baseFirst) {
- var update = baseFirst;
- do {
- pendingQueue = update.expirationTime;
- if (pendingQueue < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
+ if (null !== firstBaseUpdate) {
+ currentLastBaseUpdate = queue.baseState;
+ lastBaseUpdate = 0;
+ current = firstPendingUpdate = lastPendingUpdate = null;
+ do {
+ pendingQueue = firstBaseUpdate.lane;
+ var updateEventTime = firstBaseUpdate.eventTime;
+ if ((renderLanes & pendingQueue) === pendingQueue) {
+ null !== current &&
+ (current = current.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
next: null
- };
- null === newBaseQueueLast
- ? ((newBaseQueueFirst = newBaseQueueLast = clone),
- (newBaseState = newState))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- pendingQueue > newExpirationTime &&
- (newExpirationTime = pendingQueue);
- } else {
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
- next: null
- });
- markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig);
- a: {
- var workInProgress = workInProgress$jscomp$0,
- update$jscomp$0 = update;
- pendingQueue = props;
- clone = instance;
- switch (update$jscomp$0.tag) {
- case 1:
- workInProgress = update$jscomp$0.payload;
- if ("function" === typeof workInProgress) {
- newState = workInProgress.call(clone, newState, pendingQueue);
- break a;
- }
- newState = workInProgress;
- break a;
- case 3:
- workInProgress.effectTag =
- (workInProgress.effectTag & -4097) | 64;
- case 0:
- workInProgress = update$jscomp$0.payload;
- pendingQueue =
- "function" === typeof workInProgress
- ? workInProgress.call(clone, newState, pendingQueue)
- : workInProgress;
- if (null === pendingQueue || void 0 === pendingQueue) break a;
- newState = Object.assign({}, newState, pendingQueue);
+ });
+ markRenderEventTimeAndConfig(
+ updateEventTime,
+ firstBaseUpdate.suspenseConfig
+ );
+ a: {
+ var workInProgress = workInProgress$jscomp$0,
+ update = firstBaseUpdate;
+ pendingQueue = props;
+ updateEventTime = instance;
+ switch (update.tag) {
+ case 1:
+ workInProgress = update.payload;
+ if ("function" === typeof workInProgress) {
+ currentLastBaseUpdate = workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ );
break a;
- case 2:
- hasForceUpdate = !0;
- }
+ }
+ currentLastBaseUpdate = workInProgress;
+ break a;
+ case 3:
+ workInProgress.effectTag =
+ (workInProgress.effectTag & -4097) | 64;
+ case 0:
+ workInProgress = update.payload;
+ pendingQueue =
+ "function" === typeof workInProgress
+ ? workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ )
+ : workInProgress;
+ if (null === pendingQueue || void 0 === pendingQueue) break a;
+ currentLastBaseUpdate = Object.assign(
+ {},
+ currentLastBaseUpdate,
+ pendingQueue
+ );
+ break a;
+ case 2:
+ hasForceUpdate = !0;
}
- null !== update.callback &&
- ((workInProgress$jscomp$0.effectTag |= 32),
- (pendingQueue = queue.effects),
- null === pendingQueue
- ? (queue.effects = [update])
- : pendingQueue.push(update));
}
- update = update.next;
- if (null === update || update === baseFirst)
- if (((pendingQueue = queue.shared.pending), null === pendingQueue))
- break;
- else
- (update = baseQueue.next = pendingQueue.next),
- (pendingQueue.next = baseFirst),
- (queue.baseQueue = baseQueue = pendingQueue),
- (queue.shared.pending = null);
- } while (1);
- }
- null === newBaseQueueLast
- ? (newBaseState = newState)
- : (newBaseQueueLast.next = newBaseQueueFirst);
- queue.baseState = newBaseState;
- queue.baseQueue = newBaseQueueLast;
- markUnprocessedUpdateTime(newExpirationTime);
- workInProgress$jscomp$0.expirationTime = newExpirationTime;
- workInProgress$jscomp$0.memoizedState = newState;
+ null !== firstBaseUpdate.callback &&
+ ((workInProgress$jscomp$0.effectTag |= 32),
+ (pendingQueue = queue.effects),
+ null === pendingQueue
+ ? (queue.effects = [firstBaseUpdate])
+ : pendingQueue.push(firstBaseUpdate));
+ } else
+ (updateEventTime = {
+ eventTime: updateEventTime,
+ lane: pendingQueue,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
+ next: null
+ }),
+ null === current
+ ? ((firstPendingUpdate = current = updateEventTime),
+ (lastPendingUpdate = currentLastBaseUpdate))
+ : (current = current.next = updateEventTime),
+ (lastBaseUpdate |= pendingQueue);
+ firstBaseUpdate = firstBaseUpdate.next;
+ if (null === firstBaseUpdate)
+ if (((pendingQueue = queue.shared.pending), null === pendingQueue))
+ break;
+ else
+ (firstBaseUpdate = pendingQueue.next),
+ (pendingQueue.next = null),
+ (queue.lastBaseUpdate = pendingQueue),
+ (queue.shared.pending = null);
+ } while (1);
+ null === current && (lastPendingUpdate = currentLastBaseUpdate);
+ queue.baseState = lastPendingUpdate;
+ queue.firstBaseUpdate = firstPendingUpdate;
+ queue.lastBaseUpdate = current;
+ workInProgressRootSkippedLanes |= lastBaseUpdate;
+ workInProgress$jscomp$0.lanes = lastBaseUpdate;
+ workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate;
}
}
function commitUpdateQueue(finishedWork, finishedQueue, instance) {
@@ -2151,54 +2471,54 @@ function applyDerivedStateFromProps(
? ctor
: Object.assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
- 0 === workInProgress.expirationTime &&
+ 0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
}
var classComponentUpdater = {
isMounted: function(component) {
- return (component = component._reactInternalFiber)
+ return (component = component._reactInternals)
? getNearestMountedFiber(component) === component
: !1;
},
enqueueSetState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueReplaceState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 1;
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueForceUpdate: function(inst, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 2;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
}
};
function checkShouldComponentUpdate(
@@ -2236,7 +2556,7 @@ function constructClassInstance(workInProgress, ctor, props) {
null !== ctor.state && void 0 !== ctor.state ? ctor.state : null;
ctor.updater = classComponentUpdater;
workInProgress.stateNode = ctor;
- ctor._reactInternalFiber = workInProgress;
+ ctor._reactInternals = workInProgress;
isLegacyContextConsumer &&
((workInProgress = workInProgress.stateNode),
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
@@ -2257,12 +2577,7 @@ function callComponentWillReceiveProps(
instance.state !== workInProgress &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
}
-function mountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;
@@ -2275,7 +2590,7 @@ function mountClassInstance(
? previousContext
: contextStackCursor.current),
(instance.context = getMaskedContext(workInProgress, contextType)));
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
contextType = ctor.getDerivedStateFromProps;
"function" === typeof contextType &&
@@ -2292,12 +2607,7 @@ function mountClassInstance(
instance.UNSAFE_componentWillMount(),
ctor !== instance.state &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null),
- processUpdateQueue(
- workInProgress,
- newProps,
- instance,
- renderExpirationTime
- ),
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes),
(instance.state = workInProgress.memoizedState));
"function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4);
@@ -2361,7 +2671,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) {
("[object Object]" === Object.prototype.toString.call(newChild)
? "object with keys {" + Object.keys(newChild).join(", ") + "}"
: newChild) +
- ")."
+ "). If you meant to render a collection of children, use an array instead."
);
}
function ChildReconciler(shouldTrackSideEffects) {
@@ -2417,14 +2727,10 @@ function ChildReconciler(shouldTrackSideEffects) {
(newFiber.effectTag = 2);
return newFiber;
}
- function updateTextNode(returnFiber, current, textContent, expirationTime) {
+ function updateTextNode(returnFiber, current, textContent, lanes) {
if (null === current || 6 !== current.tag)
return (
- (current = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromText(textContent, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2432,27 +2738,27 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateElement(returnFiber, current, element, expirationTime) {
+ function updateElement(returnFiber, current, element, lanes) {
if (null !== current && current.elementType === element.type)
return (
- (expirationTime = useFiber(current, element.props)),
- (expirationTime.ref = coerceRef(returnFiber, current, element)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes = useFiber(current, element.props)),
+ (lanes.ref = coerceRef(returnFiber, current, element)),
+ (lanes.return = returnFiber),
+ lanes
);
- expirationTime = createFiberFromTypeAndProps(
+ lanes = createFiberFromTypeAndProps(
element.type,
element.key,
element.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
);
- expirationTime.ref = coerceRef(returnFiber, current, element);
- expirationTime.return = returnFiber;
- return expirationTime;
+ lanes.ref = coerceRef(returnFiber, current, element);
+ lanes.return = returnFiber;
+ return lanes;
}
- function updatePortal(returnFiber, current, portal, expirationTime) {
+ function updatePortal(returnFiber, current, portal, lanes) {
if (
null === current ||
4 !== current.tag ||
@@ -2460,11 +2766,7 @@ function ChildReconciler(shouldTrackSideEffects) {
current.stateNode.implementation !== portal.implementation
)
return (
- (current = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromPortal(portal, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2472,13 +2774,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateFragment(returnFiber, current, fragment, expirationTime, key) {
+ function updateFragment(returnFiber, current, fragment, lanes, key) {
if (null === current || 7 !== current.tag)
return (
(current = createFiberFromFragment(
fragment,
returnFiber.mode,
- expirationTime,
+ lanes,
key
)),
(current.return = returnFiber),
@@ -2488,13 +2790,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function createChild(returnFiber, newChild, expirationTime) {
+ function createChild(returnFiber, newChild, lanes) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(newChild = createFiberFromText(
"" + newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2503,24 +2805,24 @@ function ChildReconciler(shouldTrackSideEffects) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
return (
- (expirationTime = createFiberFromTypeAndProps(
+ (lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(returnFiber, null, newChild)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes.ref = coerceRef(returnFiber, null, newChild)),
+ (lanes.return = returnFiber),
+ lanes
);
case REACT_PORTAL_TYPE:
return (
(newChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2531,7 +2833,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(newChild = createFiberFromFragment(
newChild,
returnFiber.mode,
- expirationTime,
+ lanes,
null
)),
(newChild.return = returnFiber),
@@ -2541,12 +2843,12 @@ function ChildReconciler(shouldTrackSideEffects) {
}
return null;
}
- function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
+ function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
if ("string" === typeof newChild || "number" === typeof newChild)
return null !== key
? null
- : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime);
+ : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
@@ -2556,26 +2858,20 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChild.props.children,
- expirationTime,
+ lanes,
key
)
- : updateElement(returnFiber, oldFiber, newChild, expirationTime)
+ : updateElement(returnFiber, oldFiber, newChild, lanes)
: null;
case REACT_PORTAL_TYPE:
return newChild.key === key
- ? updatePortal(returnFiber, oldFiber, newChild, expirationTime)
+ ? updatePortal(returnFiber, oldFiber, newChild, lanes)
: null;
}
if (isArray(newChild) || getIteratorFn(newChild))
return null !== key
? null
- : updateFragment(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime,
- null
- );
+ : updateFragment(returnFiber, oldFiber, newChild, lanes, null);
throwOnInvalidObjectType(returnFiber, newChild);
}
return null;
@@ -2585,17 +2881,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChild,
- expirationTime
+ lanes
) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateTextNode(
- returnFiber,
- existingChildren,
- "" + newChild,
- expirationTime
- )
+ updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
@@ -2610,15 +2901,10 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
existingChildren,
newChild.props.children,
- expirationTime,
+ lanes,
newChild.key
)
- : updateElement(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ : updateElement(returnFiber, existingChildren, newChild, lanes)
);
case REACT_PORTAL_TYPE:
return (
@@ -2626,24 +2912,13 @@ function ChildReconciler(shouldTrackSideEffects) {
existingChildren.get(
null === newChild.key ? newIdx : newChild.key
) || null),
- updatePortal(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ updatePortal(returnFiber, existingChildren, newChild, lanes)
);
}
if (isArray(newChild) || getIteratorFn(newChild))
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateFragment(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime,
- null
- )
+ updateFragment(returnFiber, existingChildren, newChild, lanes, null)
);
throwOnInvalidObjectType(returnFiber, newChild);
}
@@ -2653,7 +2928,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildren,
- expirationTime
+ lanes
) {
for (
var resultingFirstChild = null,
@@ -2671,7 +2946,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
@@ -2694,11 +2969,7 @@ function ChildReconciler(shouldTrackSideEffects) {
);
if (null === oldFiber) {
for (; newIdx < newChildren.length; newIdx++)
- (oldFiber = createChild(
- returnFiber,
- newChildren[newIdx],
- expirationTime
- )),
+ (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)),
null !== oldFiber &&
((currentFirstChild = placeChild(
oldFiber,
@@ -2721,7 +2992,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChildren[newIdx],
- expirationTime
+ lanes
)),
null !== nextOldFiber &&
(shouldTrackSideEffects &&
@@ -2748,7 +3019,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildrenIterable,
- expirationTime
+ lanes
) {
var iteratorFn = getIteratorFn(newChildrenIterable);
if ("function" !== typeof iteratorFn)
@@ -2770,12 +3041,7 @@ function ChildReconciler(shouldTrackSideEffects) {
oldFiber.index > newIdx
? ((nextOldFiber = oldFiber), (oldFiber = null))
: (nextOldFiber = oldFiber.sibling);
- var newFiber = updateSlot(
- returnFiber,
- oldFiber,
- step.value,
- expirationTime
- );
+ var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
break;
@@ -2795,7 +3061,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn;
if (null === oldFiber) {
for (; !step.done; newIdx++, step = newChildrenIterable.next())
- (step = createChild(returnFiber, step.value, expirationTime)),
+ (step = createChild(returnFiber, step.value, lanes)),
null !== step &&
((currentFirstChild = placeChild(step, currentFirstChild, newIdx)),
null === previousNewFiber
@@ -2809,13 +3075,7 @@ function ChildReconciler(shouldTrackSideEffects) {
!step.done;
newIdx++, step = newChildrenIterable.next()
)
- (step = updateFromMap(
- oldFiber,
- returnFiber,
- newIdx,
- step.value,
- expirationTime
- )),
+ (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)),
null !== step &&
(shouldTrackSideEffects &&
null !== step.alternate &&
@@ -2831,7 +3091,7 @@ function ChildReconciler(shouldTrackSideEffects) {
});
return iteratorFn;
}
- return function(returnFiber, currentFirstChild, newChild, expirationTime) {
+ return function(returnFiber, currentFirstChild, newChild, lanes) {
var isUnkeyedTopLevelFragment =
"object" === typeof newChild &&
null !== newChild &&
@@ -2897,26 +3157,26 @@ function ChildReconciler(shouldTrackSideEffects) {
? ((currentFirstChild = createFiberFromFragment(
newChild.props.children,
returnFiber.mode,
- expirationTime,
+ lanes,
newChild.key
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild))
- : ((expirationTime = createFiberFromTypeAndProps(
+ : ((lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(
+ (lanes.ref = coerceRef(
returnFiber,
currentFirstChild,
newChild
)),
- (expirationTime.return = returnFiber),
- (returnFiber = expirationTime));
+ (lanes.return = returnFiber),
+ (returnFiber = lanes));
}
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
@@ -2955,7 +3215,7 @@ function ChildReconciler(shouldTrackSideEffects) {
currentFirstChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
@@ -2974,7 +3234,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(currentFirstChild = createFiberFromText(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
@@ -2985,14 +3245,14 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
if (getIteratorFn(newChild))
return reconcileChildrenIterator(
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
isObject && throwOnInvalidObjectType(returnFiber, newChild);
if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
@@ -3011,9 +3271,9 @@ function ChildReconciler(shouldTrackSideEffects) {
var reconcileChildFibers = ChildReconciler(!0),
mountChildFibers = ChildReconciler(!1),
NO_CONTEXT = {},
- contextStackCursor$1 = { current: NO_CONTEXT },
- contextFiberStackCursor = { current: NO_CONTEXT },
- rootInstanceStackCursor = { current: NO_CONTEXT };
+ contextStackCursor$1 = createCursor(NO_CONTEXT),
+ contextFiberStackCursor = createCursor(NO_CONTEXT),
+ rootInstanceStackCursor = createCursor(NO_CONTEXT);
function requiredContext(c) {
if (c === NO_CONTEXT)
throw Error(
@@ -3036,26 +3296,26 @@ function popHostContainer() {
function pushHostContext(fiber) {
requiredContext(rootInstanceStackCursor.current);
var context = requiredContext(contextStackCursor$1.current);
- var nextContext = fiber.type;
- nextContext =
- "AndroidTextInput" === nextContext ||
- "RCTMultilineTextInputView" === nextContext ||
- "RCTSinglelineTextInputView" === nextContext ||
- "RCTText" === nextContext ||
- "RCTVirtualText" === nextContext;
- nextContext =
- context.isInAParentText !== nextContext
- ? { isInAParentText: nextContext }
+ var JSCompiler_inline_result = fiber.type;
+ JSCompiler_inline_result =
+ "AndroidTextInput" === JSCompiler_inline_result ||
+ "RCTMultilineTextInputView" === JSCompiler_inline_result ||
+ "RCTSinglelineTextInputView" === JSCompiler_inline_result ||
+ "RCTText" === JSCompiler_inline_result ||
+ "RCTVirtualText" === JSCompiler_inline_result;
+ JSCompiler_inline_result =
+ context.isInAParentText !== JSCompiler_inline_result
+ ? { isInAParentText: JSCompiler_inline_result }
: context;
- context !== nextContext &&
+ context !== JSCompiler_inline_result &&
(push(contextFiberStackCursor, fiber),
- push(contextStackCursor$1, nextContext));
+ push(contextStackCursor$1, JSCompiler_inline_result));
}
function popHostContext(fiber) {
contextFiberStackCursor.current === fiber &&
(pop(contextStackCursor$1), pop(contextFiberStackCursor));
}
-var suspenseStackCursor = { current: 0 };
+var suspenseStackCursor = createCursor(0);
function findFirstSuspended(row) {
for (var node = row; null !== node; ) {
if (13 === node.tag) {
@@ -3082,13 +3342,20 @@ function findFirstSuspended(row) {
function createDeprecatedResponderListener(responder, props) {
return { responder: responder, props: props };
}
-var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
+var workInProgressSources = [];
+function resetWorkInProgressVersions() {
+ for (var i = 0; i < workInProgressSources.length; i++)
+ workInProgressSources[i]._workInProgressVersionPrimary = null;
+ workInProgressSources.length = 0;
+}
+var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig,
- renderExpirationTime = 0,
+ renderLanes = 0,
currentlyRenderingFiber$1 = null,
currentHook = null,
workInProgressHook = null,
- didScheduleRenderPhaseUpdate = !1;
+ didScheduleRenderPhaseUpdate = !1,
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
function throwInvalidHookError() {
throw Error(
"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."
@@ -3106,36 +3373,36 @@ function renderWithHooks(
Component,
props,
secondArg,
- nextRenderExpirationTime
+ nextRenderLanes
) {
- renderExpirationTime = nextRenderExpirationTime;
+ renderLanes = nextRenderLanes;
currentlyRenderingFiber$1 = workInProgress;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- workInProgress.expirationTime = 0;
- ReactCurrentDispatcher.current =
+ workInProgress.lanes = 0;
+ ReactCurrentDispatcher$1.current =
null === current || null === current.memoizedState
? HooksDispatcherOnMount
: HooksDispatcherOnUpdate;
current = Component(props, secondArg);
- if (workInProgress.expirationTime === renderExpirationTime) {
- nextRenderExpirationTime = 0;
+ if (didScheduleRenderPhaseUpdateDuringThisPass) {
+ nextRenderLanes = 0;
do {
- workInProgress.expirationTime = 0;
- if (!(25 > nextRenderExpirationTime))
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ if (!(25 > nextRenderLanes))
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
- nextRenderExpirationTime += 1;
+ nextRenderLanes += 1;
workInProgressHook = currentHook = null;
workInProgress.updateQueue = null;
- ReactCurrentDispatcher.current = HooksDispatcherOnRerender;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender;
current = Component(props, secondArg);
- } while (workInProgress.expirationTime === renderExpirationTime);
+ } while (didScheduleRenderPhaseUpdateDuringThisPass);
}
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
workInProgress = null !== currentHook && null !== currentHook.next;
- renderExpirationTime = 0;
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
didScheduleRenderPhaseUpdate = !1;
if (workInProgress)
@@ -3216,40 +3483,40 @@ function updateReducer(reducer) {
var newBaseQueueLast = (baseFirst = pendingQueue = null),
update = baseQueue;
do {
- var updateExpirationTime = update.expirationTime;
- if (updateExpirationTime < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- action: update.action,
- eagerReducer: update.eagerReducer,
- eagerState: update.eagerState,
- next: null
- };
- null === newBaseQueueLast
- ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- updateExpirationTime > currentlyRenderingFiber$1.expirationTime &&
- ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime),
- markUnprocessedUpdateTime(updateExpirationTime));
- } else
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
+ var suspenseConfig = update.suspenseConfig,
+ updateLane = update.lane,
+ updateEventTime = update.eventTime;
+ (renderLanes & updateLane) === updateLane
+ ? (null !== newBaseQueueLast &&
+ (newBaseQueueLast = newBaseQueueLast.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: update.suspenseConfig,
+ action: update.action,
+ eagerReducer: update.eagerReducer,
+ eagerState: update.eagerState,
+ next: null
+ }),
+ markRenderEventTimeAndConfig(updateEventTime, suspenseConfig),
+ (current =
+ update.eagerReducer === reducer
+ ? update.eagerState
+ : reducer(current, update.action)))
+ : ((suspenseConfig = {
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
next: null
}),
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ null === newBaseQueueLast
+ ? ((baseFirst = newBaseQueueLast = suspenseConfig),
+ (pendingQueue = current))
+ : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig),
+ (currentlyRenderingFiber$1.lanes |= updateLane),
+ (workInProgressRootSkippedLanes |= updateLane));
update = update.next;
} while (null !== update && update !== baseQueue);
null === newBaseQueueLast
@@ -3286,6 +3553,117 @@ function rerenderReducer(reducer) {
}
return [newState, dispatch];
}
+function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+ var getVersion = source._getVersion;
+ getVersion = getVersion(source._source);
+ var JSCompiler_inline_result = source._workInProgressVersionPrimary;
+ if (null !== JSCompiler_inline_result)
+ root = JSCompiler_inline_result === getVersion;
+ else if (
+ ((root = root.mutableReadLanes), (root = (renderLanes & root) === root))
+ )
+ (source._workInProgressVersionPrimary = getVersion),
+ workInProgressSources.push(source);
+ if (root) return getSnapshot(source._source);
+ workInProgressSources.push(source);
+ throw Error(
+ "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
+ );
+}
+function useMutableSource(hook, source, getSnapshot, subscribe) {
+ var root = workInProgressRoot;
+ if (null === root)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ var getVersion = source._getVersion,
+ version = getVersion(source._source),
+ dispatcher = ReactCurrentDispatcher$1.current,
+ _dispatcher$useState = dispatcher.useState(function() {
+ return readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ }),
+ setSnapshot = _dispatcher$useState[1],
+ snapshot = _dispatcher$useState[0];
+ _dispatcher$useState = workInProgressHook;
+ var memoizedState = hook.memoizedState,
+ refs = memoizedState.refs,
+ prevGetSnapshot = refs.getSnapshot,
+ prevSource = memoizedState.source;
+ memoizedState = memoizedState.subscribe;
+ var fiber = currentlyRenderingFiber$1;
+ hook.memoizedState = { refs: refs, source: source, subscribe: subscribe };
+ dispatcher.useEffect(
+ function() {
+ refs.getSnapshot = getSnapshot;
+ refs.setSnapshot = setSnapshot;
+ var maybeNewVersion = getVersion(source._source);
+ if (!objectIs(version, maybeNewVersion)) {
+ maybeNewVersion = getSnapshot(source._source);
+ objectIs(snapshot, maybeNewVersion) ||
+ (setSnapshot(maybeNewVersion),
+ (maybeNewVersion = requestUpdateLane(
+ fiber,
+ ReactCurrentBatchConfig.suspense
+ )),
+ (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes));
+ maybeNewVersion = root.mutableReadLanes;
+ root.entangledLanes |= maybeNewVersion;
+ for (
+ var entanglements = root.entanglements, lanes = maybeNewVersion;
+ 0 < lanes;
+
+ ) {
+ var index$14 = 31 - clz32(lanes),
+ lane = 1 << index$14;
+ entanglements[index$14] |= maybeNewVersion;
+ lanes &= ~lane;
+ }
+ }
+ },
+ [getSnapshot, source, subscribe]
+ );
+ dispatcher.useEffect(
+ function() {
+ return subscribe(source._source, function() {
+ var latestGetSnapshot = refs.getSnapshot,
+ latestSetSnapshot = refs.setSnapshot;
+ try {
+ latestSetSnapshot(latestGetSnapshot(source._source));
+ var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense);
+ root.mutableReadLanes |= lane & root.pendingLanes;
+ } catch (error) {
+ latestSetSnapshot(function() {
+ throw error;
+ });
+ }
+ });
+ },
+ [source, subscribe]
+ );
+ (objectIs(prevGetSnapshot, getSnapshot) &&
+ objectIs(prevSource, source) &&
+ objectIs(memoizedState, subscribe)) ||
+ ((hook = {
+ pending: null,
+ dispatch: null,
+ lastRenderedReducer: basicStateReducer,
+ lastRenderedState: snapshot
+ }),
+ (hook.dispatch = setSnapshot = dispatchAction.bind(
+ null,
+ currentlyRenderingFiber$1,
+ hook
+ )),
+ (_dispatcher$useState.queue = hook),
+ (_dispatcher$useState.baseQueue = null),
+ (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)),
+ (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot));
+ return snapshot;
+}
+function updateMutableSource(source, getSnapshot, subscribe) {
+ var hook = updateWorkInProgressHook();
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
@@ -3434,11 +3812,12 @@ function startTransition(setPending, config, callback) {
});
}
function dispatchAction(fiber, queue, action) {
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(fiber, suspenseConfig);
suspenseConfig = {
- expirationTime: currentTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
action: action,
eagerReducer: null,
@@ -3455,13 +3834,11 @@ function dispatchAction(fiber, queue, action) {
fiber === currentlyRenderingFiber$1 ||
(null !== pending && pending === currentlyRenderingFiber$1)
)
- (didScheduleRenderPhaseUpdate = !0),
- (suspenseConfig.expirationTime = renderExpirationTime),
- (currentlyRenderingFiber$1.expirationTime = renderExpirationTime);
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
else {
if (
- 0 === fiber.expirationTime &&
- (null === pending || 0 === pending.expirationTime) &&
+ 0 === fiber.lanes &&
+ (null === pending || 0 === pending.lanes) &&
((pending = queue.lastRenderedReducer), null !== pending)
)
try {
@@ -3473,10 +3850,9 @@ function dispatchAction(fiber, queue, action) {
} catch (error) {
} finally {
}
- scheduleWork(fiber, currentTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
}
-function updateEventListener() {}
var ContextOnlyDispatcher = {
readContext: readContext,
useCallback: throwInvalidHookError,
@@ -3492,7 +3868,9 @@ var ContextOnlyDispatcher = {
useResponder: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
- useEvent: throwInvalidHookError
+ useMutableSource: throwInvalidHookError,
+ useOpaqueIdentifier: throwInvalidHookError,
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
readContext: readContext,
@@ -3574,7 +3952,19 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: function() {}
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ var hook = mountWorkInProgressHook();
+ hook.memoizedState = {
+ refs: { getSnapshot: getSnapshot, setSnapshot: null },
+ source: source,
+ subscribe: subscribe
+ };
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ throw Error("Not yet implemented");
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnUpdate = {
readContext: readContext,
@@ -3622,7 +4012,11 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return updateReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
readContext: readContext,
@@ -3670,29 +4064,23 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return rerenderReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
didReceiveUpdate = !1;
-function reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
-) {
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
workInProgress.child =
null === current
- ? mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderExpirationTime
- )
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
: reconcileChildFibers(
workInProgress,
current.child,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
function updateForwardRef(
@@ -3700,33 +4088,28 @@ function updateForwardRef(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
Component = Component.render;
var ref = workInProgress.ref;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
nextProps = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, nextProps, renderExpirationTime);
+ reconcileChildren(current, workInProgress, nextProps, renderLanes);
return workInProgress.child;
}
function updateMemoComponent(
@@ -3734,8 +4117,8 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (null === current) {
var type = Component.type;
@@ -3754,8 +4137,8 @@ function updateMemoComponent(
workInProgress,
type,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
current = createFiberFromTypeAndProps(
@@ -3764,7 +4147,7 @@ function updateMemoComponent(
nextProps,
null,
workInProgress.mode,
- renderExpirationTime
+ renderLanes
);
current.ref = workInProgress.ref;
current.return = workInProgress;
@@ -3772,18 +4155,13 @@ function updateMemoComponent(
}
type = current.child;
if (
- updateExpirationTime < renderExpirationTime &&
- ((updateExpirationTime = type.memoizedProps),
+ 0 === (updateLanes & renderLanes) &&
+ ((updateLanes = type.memoizedProps),
(Component = Component.compare),
(Component = null !== Component ? Component : shallowEqual),
- Component(updateExpirationTime, nextProps) &&
- current.ref === workInProgress.ref)
+ Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
)
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
workInProgress.effectTag |= 1;
current = createWorkInProgress(type, nextProps);
current.ref = workInProgress.ref;
@@ -3795,28 +4173,65 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
- return null !== current &&
+ if (
+ null !== current &&
shallowEqual(current.memoizedProps, nextProps) &&
- current.ref === workInProgress.ref &&
- ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime)
- ? ((workInProgress.expirationTime = current.expirationTime),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- ))
- : updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
+ current.ref === workInProgress.ref
+ )
+ if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes)))
+ 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0);
+ else
+ return (
+ (workInProgress.lanes = current.lanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
-}
-function markRef(current, workInProgress) {
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
+}
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
+ nextChildren = nextProps.children,
+ prevState = null !== current ? current.memoizedState : null;
+ if (
+ "hidden" === nextProps.mode ||
+ "unstable-defer-without-hiding" === nextProps.mode
+ )
+ if (0 === (workInProgress.mode & 4))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(workInProgress, renderLanes);
+ else if (0 !== (renderLanes & 1073741824))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(
+ workInProgress,
+ null !== prevState ? prevState.baseLanes : renderLanes
+ );
+ else
+ return (
+ (current =
+ null !== prevState ? prevState.baseLanes | renderLanes : renderLanes),
+ (workInProgress.lanes = workInProgress.childLanes = 1073741824),
+ (workInProgress.memoizedState = { baseLanes: current }),
+ pushRenderLanes(workInProgress, current),
+ null
+ );
+ else
+ null !== prevState
+ ? ((nextProps = prevState.baseLanes | renderLanes),
+ (workInProgress.memoizedState = null))
+ : (nextProps = renderLanes),
+ pushRenderLanes(workInProgress, nextProps);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
+function markRef(current, workInProgress) {
var ref = workInProgress.ref;
if (
(null === current && null !== ref) ||
@@ -3829,35 +4244,30 @@ function updateFunctionComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
var context = isContextProvider(Component)
? previousContext
: contextStackCursor.current;
context = getMaskedContext(workInProgress, context);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
Component = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, Component, renderExpirationTime);
+ reconcileChildren(current, workInProgress, Component, renderLanes);
return workInProgress.child;
}
function updateClassComponent(
@@ -3865,25 +4275,20 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
if (null === workInProgress.stateNode)
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
constructClassInstance(workInProgress, Component, nextProps),
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- ),
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes),
(nextProps = !0);
else if (null === current) {
var instance = workInProgress.stateNode,
@@ -3914,12 +4319,7 @@ function updateClassComponent(
hasForceUpdate = !1;
var oldState = workInProgress.memoizedState;
instance.state = oldState;
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- );
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
oldContext = workInProgress.memoizedState;
oldProps !== nextProps ||
oldState !== oldContext ||
@@ -3964,117 +4364,111 @@ function updateClassComponent(
: ("function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4),
(nextProps = !1));
- } else
- (instance = workInProgress.stateNode),
- cloneUpdateQueue(current, workInProgress),
- (oldProps = workInProgress.memoizedProps),
- (instance.props =
- workInProgress.type === workInProgress.elementType
- ? oldProps
- : resolveDefaultProps(workInProgress.type, oldProps)),
- (oldContext = instance.context),
- (contextType = Component.contextType),
- "object" === typeof contextType && null !== contextType
- ? (contextType = readContext(contextType))
- : ((contextType = isContextProvider(Component)
- ? previousContext
- : contextStackCursor.current),
- (contextType = getMaskedContext(workInProgress, contextType))),
- (getDerivedStateFromProps = Component.getDerivedStateFromProps),
- (hasNewLifecycles =
- "function" === typeof getDerivedStateFromProps ||
- "function" === typeof instance.getSnapshotBeforeUpdate) ||
- ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
- "function" !== typeof instance.componentWillReceiveProps) ||
- ((oldProps !== nextProps || oldContext !== contextType) &&
- callComponentWillReceiveProps(
+ } else {
+ instance = workInProgress.stateNode;
+ cloneUpdateQueue(current, workInProgress);
+ oldProps = workInProgress.memoizedProps;
+ contextType =
+ workInProgress.type === workInProgress.elementType
+ ? oldProps
+ : resolveDefaultProps(workInProgress.type, oldProps);
+ instance.props = contextType;
+ hasNewLifecycles = workInProgress.pendingProps;
+ oldState = instance.context;
+ oldContext = Component.contextType;
+ "object" === typeof oldContext && null !== oldContext
+ ? (oldContext = readContext(oldContext))
+ : ((oldContext = isContextProvider(Component)
+ ? previousContext
+ : contextStackCursor.current),
+ (oldContext = getMaskedContext(workInProgress, oldContext)));
+ var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps;
+ (getDerivedStateFromProps =
+ "function" === typeof getDerivedStateFromProps$jscomp$0 ||
+ "function" === typeof instance.getSnapshotBeforeUpdate) ||
+ ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
+ "function" !== typeof instance.componentWillReceiveProps) ||
+ ((oldProps !== hasNewLifecycles || oldState !== oldContext) &&
+ callComponentWillReceiveProps(
+ workInProgress,
+ instance,
+ nextProps,
+ oldContext
+ ));
+ hasForceUpdate = !1;
+ oldState = workInProgress.memoizedState;
+ instance.state = oldState;
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
+ var newState = workInProgress.memoizedState;
+ oldProps !== hasNewLifecycles ||
+ oldState !== newState ||
+ didPerformWorkStackCursor.current ||
+ hasForceUpdate
+ ? ("function" === typeof getDerivedStateFromProps$jscomp$0 &&
+ (applyDerivedStateFromProps(
+ workInProgress,
+ Component,
+ getDerivedStateFromProps$jscomp$0,
+ nextProps
+ ),
+ (newState = workInProgress.memoizedState)),
+ (contextType =
+ hasForceUpdate ||
+ checkShouldComponentUpdate(
workInProgress,
- instance,
+ Component,
+ contextType,
nextProps,
- contextType
- )),
- (hasForceUpdate = !1),
- (oldContext = workInProgress.memoizedState),
- (instance.state = oldContext),
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- ),
- (oldState = workInProgress.memoizedState),
- oldProps !== nextProps ||
- oldContext !== oldState ||
- didPerformWorkStackCursor.current ||
- hasForceUpdate
- ? ("function" === typeof getDerivedStateFromProps &&
- (applyDerivedStateFromProps(
- workInProgress,
- Component,
- getDerivedStateFromProps,
- nextProps
- ),
- (oldState = workInProgress.memoizedState)),
- (getDerivedStateFromProps =
- hasForceUpdate ||
- checkShouldComponentUpdate(
- workInProgress,
- Component,
- oldProps,
- nextProps,
- oldContext,
- oldState,
- contextType
- ))
- ? (hasNewLifecycles ||
- ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
- "function" !== typeof instance.componentWillUpdate) ||
- ("function" === typeof instance.componentWillUpdate &&
- instance.componentWillUpdate(
- nextProps,
- oldState,
- contextType
- ),
- "function" === typeof instance.UNSAFE_componentWillUpdate &&
- instance.UNSAFE_componentWillUpdate(
- nextProps,
- oldState,
- contextType
- )),
- "function" === typeof instance.componentDidUpdate &&
- (workInProgress.effectTag |= 4),
- "function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.effectTag |= 256))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (workInProgress.memoizedProps = nextProps),
- (workInProgress.memoizedState = oldState)),
- (instance.props = nextProps),
- (instance.state = oldState),
- (instance.context = contextType),
- (nextProps = getDerivedStateFromProps))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (nextProps = !1));
+ oldState,
+ newState,
+ oldContext
+ ))
+ ? (getDerivedStateFromProps ||
+ ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
+ "function" !== typeof instance.componentWillUpdate) ||
+ ("function" === typeof instance.componentWillUpdate &&
+ instance.componentWillUpdate(nextProps, newState, oldContext),
+ "function" === typeof instance.UNSAFE_componentWillUpdate &&
+ instance.UNSAFE_componentWillUpdate(
+ nextProps,
+ newState,
+ oldContext
+ )),
+ "function" === typeof instance.componentDidUpdate &&
+ (workInProgress.effectTag |= 4),
+ "function" === typeof instance.getSnapshotBeforeUpdate &&
+ (workInProgress.effectTag |= 256))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (workInProgress.memoizedProps = nextProps),
+ (workInProgress.memoizedState = newState)),
+ (instance.props = nextProps),
+ (instance.state = newState),
+ (instance.context = oldContext),
+ (nextProps = contextType))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (nextProps = !1));
+ }
return finishClassComponent(
current,
workInProgress,
Component,
nextProps,
hasContext,
- renderExpirationTime
+ renderLanes
);
}
function finishClassComponent(
@@ -4083,18 +4477,14 @@ function finishClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
) {
markRef(current, workInProgress);
var didCaptureError = 0 !== (workInProgress.effectTag & 64);
if (!shouldUpdate && !didCaptureError)
return (
hasContext && invalidateContextProvider(workInProgress, Component, !1),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
shouldUpdate = workInProgress.stateNode;
ReactCurrentOwner$1.current = workInProgress;
@@ -4108,20 +4498,15 @@ function finishClassComponent(
workInProgress,
current.child,
null,
- renderExpirationTime
+ renderLanes
)),
(workInProgress.child = reconcileChildFibers(
workInProgress,
null,
nextChildren,
- renderExpirationTime
+ renderLanes
)))
- : reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ : reconcileChildren(current, workInProgress, nextChildren, renderLanes);
workInProgress.memoizedState = shouldUpdate.state;
hasContext && invalidateContextProvider(workInProgress, Component, !0);
return workInProgress.child;
@@ -4138,155 +4523,186 @@ function pushHostRootContext(workInProgress) {
pushTopLevelContextObject(workInProgress, root.context, !1);
pushHostContainer(workInProgress, root.containerInfo);
}
-var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 };
-function updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
- var mode = workInProgress.mode,
- nextProps = workInProgress.pendingProps,
+var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
suspenseContext = suspenseStackCursor.current,
- nextDidTimeout = !1,
+ showFallback = !1,
JSCompiler_temp;
(JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) ||
(JSCompiler_temp =
- 0 !== (suspenseContext & 2) &&
- (null === current || null !== current.memoizedState));
+ null !== current && null === current.memoizedState
+ ? !1
+ : 0 !== (suspenseContext & 2));
JSCompiler_temp
- ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65))
+ ? ((showFallback = !0), (workInProgress.effectTag &= -65))
: (null !== current && null === current.memoizedState) ||
void 0 === nextProps.fallback ||
!0 === nextProps.unstable_avoidThisFallback ||
(suspenseContext |= 1);
push(suspenseStackCursor, suspenseContext & 1);
if (null === current) {
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (current = nextProps.fallback),
+ (suspenseContext = workInProgress.mode),
+ (showFallback = workInProgress.child),
+ (nextProps = { mode: "hidden", children: nextProps.children }),
+ 0 === (suspenseContext & 2) && null !== showFallback
+ ? ((showFallback.childLanes = 0),
+ (showFallback.pendingProps = nextProps))
+ : (showFallback = createFiberFromOffscreen(
+ nextProps,
+ suspenseContext,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
+ current,
+ suspenseContext,
+ renderLanes,
+ null
+ )),
+ (showFallback.return = workInProgress),
+ (current.return = workInProgress),
+ (showFallback.sibling = current),
+ (workInProgress.child = showFallback),
+ (workInProgress.child.memoizedState = { baseLanes: renderLanes }),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ current
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- mode = nextProps.children;
- workInProgress.memoizedState = null;
- return (workInProgress.child = mountChildFibers(
- workInProgress,
- null,
- mode,
- renderExpirationTime
- ));
+ renderLanes = createFiberFromOffscreen(
+ { mode: "visible", children: nextProps.children },
+ workInProgress.mode,
+ renderLanes,
+ null
+ );
+ renderLanes.return = workInProgress;
+ return (workInProgress.child = renderLanes);
}
if (null !== current.memoizedState) {
- current = current.child;
- mode = current.sibling;
- if (nextDidTimeout) {
- nextProps = nextProps.fallback;
- renderExpirationTime = createWorkInProgress(
- current,
- current.pendingProps
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- if (
- 0 === (workInProgress.mode & 2) &&
- ((nextDidTimeout =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child),
- nextDidTimeout !== current.child)
- )
- for (
- renderExpirationTime.child = nextDidTimeout;
- null !== nextDidTimeout;
-
- )
- (nextDidTimeout.return = renderExpirationTime),
- (nextDidTimeout = nextDidTimeout.sibling);
- mode = createWorkInProgress(mode, nextProps);
- mode.return = workInProgress;
- renderExpirationTime.sibling = mode;
- renderExpirationTime.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = renderExpirationTime;
- return mode;
- }
- renderExpirationTime = reconcileChildFibers(
+ renderLanes = updateSuspensePrimaryChildren(
+ current,
workInProgress,
- current.child,
nextProps.children,
- renderExpirationTime
+ renderLanes
);
workInProgress.memoizedState = null;
- return (workInProgress.child = renderExpirationTime);
+ return renderLanes;
}
- current = current.child;
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- nextProps.child = current;
- null !== current && (current.return = nextProps);
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- renderExpirationTime.effectTag |= 2;
- nextProps.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- workInProgress.memoizedState = null;
- return (workInProgress.child = reconcileChildFibers(
- workInProgress,
+ renderLanes = updateSuspensePrimaryChildren(
current,
+ workInProgress,
nextProps.children,
- renderExpirationTime
- ));
+ renderLanes
+ );
+ workInProgress.memoizedState = null;
+ return renderLanes;
}
-function scheduleWorkOnFiber(fiber, renderExpirationTime) {
- fiber.expirationTime < renderExpirationTime &&
- (fiber.expirationTime = renderExpirationTime);
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ primaryChildren = createWorkInProgress(currentPrimaryChildFragment, {
+ mode: "visible",
+ children: primaryChildren
+ });
+ 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes);
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = null;
+ null !== current &&
+ ((current.nextEffect = null),
+ (current.effectTag = 8),
+ (workInProgress.firstEffect = workInProgress.lastEffect = current));
+ return (workInProgress.child = primaryChildren);
+}
+function updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode,
+ currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ var primaryChildProps = { mode: "hidden", children: primaryChildren };
+ 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment
+ ? ((primaryChildren = workInProgress.child),
+ (primaryChildren.childLanes = 0),
+ (primaryChildren.pendingProps = primaryChildProps),
+ (currentPrimaryChildFragment = primaryChildren.lastEffect),
+ null !== currentPrimaryChildFragment
+ ? ((workInProgress.firstEffect = primaryChildren.firstEffect),
+ (workInProgress.lastEffect = currentPrimaryChildFragment),
+ (currentPrimaryChildFragment.nextEffect = null))
+ : (workInProgress.firstEffect = workInProgress.lastEffect = null))
+ : (primaryChildren = createWorkInProgress(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ ));
+ null !== current
+ ? (fallbackChildren = createWorkInProgress(current, fallbackChildren))
+ : ((fallbackChildren = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ )),
+ (fallbackChildren.effectTag |= 2));
+ fallbackChildren.return = workInProgress;
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = fallbackChildren;
+ workInProgress.child = primaryChildren;
+ return fallbackChildren;
+}
+function scheduleWorkOnFiber(fiber, renderLanes) {
+ fiber.lanes |= renderLanes;
var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < renderExpirationTime &&
- (alternate.expirationTime = renderExpirationTime);
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
+ null !== alternate && (alternate.lanes |= renderLanes);
+ scheduleWorkOnParentPath(fiber.return, renderLanes);
}
function initSuspenseListRenderState(
workInProgress,
@@ -4317,20 +4733,11 @@ function initSuspenseListRenderState(
(renderState.tailMode = tailMode),
(renderState.lastEffect = lastEffectBeforeRendering));
}
-function updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps,
revealOrder = nextProps.revealOrder,
tailMode = nextProps.tail;
- reconcileChildren(
- current,
- workInProgress,
- nextProps.children,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
nextProps = suspenseStackCursor.current;
if (0 !== (nextProps & 2))
(nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64);
@@ -4339,9 +4746,8 @@ function updateSuspenseListComponent(
a: for (current = workInProgress.child; null !== current; ) {
if (13 === current.tag)
null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderExpirationTime);
- else if (19 === current.tag)
- scheduleWorkOnFiber(current, renderExpirationTime);
+ scheduleWorkOnFiber(current, renderLanes);
+ else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
else if (null !== current.child) {
current.child.return = current;
current = current.child;
@@ -4363,30 +4769,29 @@ function updateSuspenseListComponent(
else
switch (revealOrder) {
case "forwards":
- renderExpirationTime = workInProgress.child;
- for (revealOrder = null; null !== renderExpirationTime; )
- (current = renderExpirationTime.alternate),
+ renderLanes = workInProgress.child;
+ for (revealOrder = null; null !== renderLanes; )
+ (current = renderLanes.alternate),
null !== current &&
null === findFirstSuspended(current) &&
- (revealOrder = renderExpirationTime),
- (renderExpirationTime = renderExpirationTime.sibling);
- renderExpirationTime = revealOrder;
- null === renderExpirationTime
+ (revealOrder = renderLanes),
+ (renderLanes = renderLanes.sibling);
+ renderLanes = revealOrder;
+ null === renderLanes
? ((revealOrder = workInProgress.child),
(workInProgress.child = null))
- : ((revealOrder = renderExpirationTime.sibling),
- (renderExpirationTime.sibling = null));
+ : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
initSuspenseListRenderState(
workInProgress,
!1,
revealOrder,
- renderExpirationTime,
+ renderLanes,
tailMode,
workInProgress.lastEffect
);
break;
case "backwards":
- renderExpirationTime = null;
+ renderLanes = null;
revealOrder = workInProgress.child;
for (workInProgress.child = null; null !== revealOrder; ) {
current = revealOrder.alternate;
@@ -4395,14 +4800,14 @@ function updateSuspenseListComponent(
break;
}
current = revealOrder.sibling;
- revealOrder.sibling = renderExpirationTime;
- renderExpirationTime = revealOrder;
+ revealOrder.sibling = renderLanes;
+ renderLanes = revealOrder;
revealOrder = current;
}
initSuspenseListRenderState(
workInProgress,
!0,
- renderExpirationTime,
+ renderLanes,
null,
tailMode,
workInProgress.lastEffect
@@ -4423,35 +4828,28 @@ function updateSuspenseListComponent(
}
return workInProgress.child;
}
-function bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
null !== current && (workInProgress.dependencies = current.dependencies);
- var updateExpirationTime = workInProgress.expirationTime;
- 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime);
- if (workInProgress.childExpirationTime < renderExpirationTime) return null;
- if (null !== current && workInProgress.child !== current.child)
- throw Error("Resuming work not yet implemented.");
- if (null !== workInProgress.child) {
- current = workInProgress.child;
- renderExpirationTime = createWorkInProgress(current, current.pendingProps);
- workInProgress.child = renderExpirationTime;
- for (
- renderExpirationTime.return = workInProgress;
- null !== current.sibling;
-
- )
- (current = current.sibling),
- (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress(
- current,
- current.pendingProps
- )),
- (renderExpirationTime.return = workInProgress);
- renderExpirationTime.sibling = null;
+ workInProgressRootSkippedLanes |= workInProgress.lanes;
+ if (0 !== (renderLanes & workInProgress.childLanes)) {
+ if (null !== current && workInProgress.child !== current.child)
+ throw Error("Resuming work not yet implemented.");
+ if (null !== workInProgress.child) {
+ current = workInProgress.child;
+ renderLanes = createWorkInProgress(current, current.pendingProps);
+ workInProgress.child = renderLanes;
+ for (renderLanes.return = workInProgress; null !== current.sibling; )
+ (current = current.sibling),
+ (renderLanes = renderLanes.sibling = createWorkInProgress(
+ current,
+ current.pendingProps
+ )),
+ (renderLanes.return = workInProgress);
+ renderLanes.sibling = null;
+ }
+ return workInProgress.child;
}
- return workInProgress.child;
+ return null;
}
var appendAllChildren,
updateHostContainer,
@@ -4498,17 +4896,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
break;
case "collapsed":
lastTailNode = renderState.tail;
- for (var _lastTailNode = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (_lastTailNode = lastTailNode),
+ for (var lastTailNode$64 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode),
(lastTailNode = lastTailNode.sibling);
- null === _lastTailNode
+ null === lastTailNode$64
? hasRenderedATailFallback || null === renderState.tail
? (renderState.tail = null)
: (renderState.tail.sibling = null)
- : (_lastTailNode.sibling = null);
+ : (lastTailNode$64.sibling = null);
}
}
-function completeWork(current, workInProgress, renderExpirationTime) {
+function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
case 2:
@@ -4529,10 +4927,14 @@ function completeWork(current, workInProgress, renderExpirationTime) {
popHostContainer(),
pop(didPerformWorkStackCursor),
pop(contextStackCursor),
- (current = workInProgress.stateNode),
- current.pendingContext &&
- ((current.context = current.pendingContext),
- (current.pendingContext = null)),
+ resetWorkInProgressVersions(),
+ (newProps = workInProgress.stateNode),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ newProps.hydrate ||
+ (workInProgress.effectTag |= 256),
updateHostContainer(workInProgress),
null
);
@@ -4541,12 +4943,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
var rootContainerInstance = requiredContext(
rootInstanceStackCursor.current
);
- renderExpirationTime = workInProgress.type;
+ renderLanes = workInProgress.type;
if (null !== current && null != workInProgress.stateNode)
updateHostComponent$1(
current,
workInProgress,
- renderExpirationTime,
+ renderLanes,
newProps,
rootContainerInstance
),
@@ -4562,22 +4964,22 @@ function completeWork(current, workInProgress, renderExpirationTime) {
}
requiredContext(contextStackCursor$1.current);
current = allocateTag();
- renderExpirationTime = getViewConfigForType(renderExpirationTime);
+ renderLanes = getViewConfigForType(renderLanes);
var updatePayload = diffProperties(
null,
emptyObject,
newProps,
- renderExpirationTime.validAttributes
+ renderLanes.validAttributes
);
ReactNativePrivateInterface.UIManager.createView(
current,
- renderExpirationTime.uiViewClassName,
+ renderLanes.uiViewClassName,
rootContainerInstance,
updatePayload
);
rootContainerInstance = new ReactNativeFiberHostComponent(
current,
- renderExpirationTime,
+ renderLanes,
workInProgress
);
instanceCache.set(current, workInProgress);
@@ -4622,49 +5024,32 @@ function completeWork(current, workInProgress, renderExpirationTime) {
pop(suspenseStackCursor);
newProps = workInProgress.memoizedState;
if (0 !== (workInProgress.effectTag & 64))
- return (
- (workInProgress.expirationTime = renderExpirationTime), workInProgress
- );
+ return (workInProgress.lanes = renderLanes), workInProgress;
newProps = null !== newProps;
rootContainerInstance = !1;
null !== current &&
- ((renderExpirationTime = current.memoizedState),
- (rootContainerInstance = null !== renderExpirationTime),
- newProps ||
- null === renderExpirationTime ||
- ((renderExpirationTime = current.child.sibling),
- null !== renderExpirationTime &&
- ((updatePayload = workInProgress.firstEffect),
- null !== updatePayload
- ? ((workInProgress.firstEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = updatePayload))
- : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = null)),
- (renderExpirationTime.effectTag = 8))));
+ (rootContainerInstance = null !== current.memoizedState);
if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2))
if (
(null === current &&
!0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
0 !== (suspenseStackCursor.current & 1)
)
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootSuspended);
+ 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3);
else {
if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus
)
- workInProgressRootExitStatus = RootSuspendedWithDelay;
- 0 !== workInProgressRootNextUnprocessedUpdateTime &&
- null !== workInProgressRoot &&
- (markRootSuspendedAtTime(
- workInProgressRoot,
- renderExpirationTime$1
- ),
- markRootUpdatedAtTime(
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 134217727) &&
+ 0 === (workInProgressRootUpdatedLanes & 134217727)) ||
+ markRootSuspended$1(
workInProgressRoot,
- workInProgressRootNextUnprocessedUpdateTime
- ));
+ workInProgressRootRenderLanes
+ );
}
if (newProps || rootContainerInstance) workInProgress.effectTag |= 4;
return null;
@@ -4684,7 +5069,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1);
else {
if (
- workInProgressRootExitStatus !== RootIncomplete ||
+ 0 !== workInProgressRootExitStatus ||
(null !== current && 0 !== (current.effectTag & 64))
)
for (current = workInProgress.child; null !== current; ) {
@@ -4699,27 +5084,27 @@ function completeWork(current, workInProgress, renderExpirationTime) {
null === newProps.lastEffect &&
(workInProgress.firstEffect = null);
workInProgress.lastEffect = newProps.lastEffect;
- current = renderExpirationTime;
+ current = renderLanes;
for (newProps = workInProgress.child; null !== newProps; )
(rootContainerInstance = newProps),
- (renderExpirationTime = current),
+ (renderLanes = current),
(rootContainerInstance.effectTag &= 2),
(rootContainerInstance.nextEffect = null),
(rootContainerInstance.firstEffect = null),
(rootContainerInstance.lastEffect = null),
(updatePayload = rootContainerInstance.alternate),
null === updatePayload
- ? ((rootContainerInstance.childExpirationTime = 0),
- (rootContainerInstance.expirationTime = renderExpirationTime),
+ ? ((rootContainerInstance.childLanes = 0),
+ (rootContainerInstance.lanes = renderLanes),
(rootContainerInstance.child = null),
(rootContainerInstance.memoizedProps = null),
(rootContainerInstance.memoizedState = null),
(rootContainerInstance.updateQueue = null),
- (rootContainerInstance.dependencies = null))
- : ((rootContainerInstance.childExpirationTime =
- updatePayload.childExpirationTime),
- (rootContainerInstance.expirationTime =
- updatePayload.expirationTime),
+ (rootContainerInstance.dependencies = null),
+ (rootContainerInstance.stateNode = null))
+ : ((rootContainerInstance.childLanes =
+ updatePayload.childLanes),
+ (rootContainerInstance.lanes = updatePayload.lanes),
(rootContainerInstance.child = updatePayload.child),
(rootContainerInstance.memoizedProps =
updatePayload.memoizedProps),
@@ -4727,15 +5112,15 @@ function completeWork(current, workInProgress, renderExpirationTime) {
updatePayload.memoizedState),
(rootContainerInstance.updateQueue =
updatePayload.updateQueue),
- (renderExpirationTime = updatePayload.dependencies),
+ (rootContainerInstance.type = updatePayload.type),
+ (renderLanes = updatePayload.dependencies),
(rootContainerInstance.dependencies =
- null === renderExpirationTime
+ null === renderLanes
? null
: {
- expirationTime:
- renderExpirationTime.expirationTime,
- firstContext: renderExpirationTime.firstContext,
- responders: renderExpirationTime.responders
+ lanes: renderLanes.lanes,
+ firstContext: renderLanes.firstContext,
+ responders: renderLanes.responders
})),
(newProps = newProps.sibling);
push(
@@ -4772,12 +5157,11 @@ function completeWork(current, workInProgress, renderExpirationTime) {
);
} else
2 * now() - newProps.renderingStartTime > newProps.tailExpiration &&
- 1 < renderExpirationTime &&
+ 1073741824 !== renderLanes &&
((workInProgress.effectTag |= 64),
(rootContainerInstance = !0),
cutOffTailIfNeeded(newProps, !1),
- (workInProgress.expirationTime = workInProgress.childExpirationTime =
- renderExpirationTime - 1));
+ (workInProgress.lanes = renderLanes));
newProps.isBackwards
? ((updatePayload.sibling = workInProgress.child),
(workInProgress.child = updatePayload))
@@ -4805,6 +5189,17 @@ function completeWork(current, workInProgress, renderExpirationTime) {
),
current)
: null;
+ case 23:
+ case 24:
+ return (
+ popRenderLanes(),
+ null !== current &&
+ (null !== current.memoizedState) !==
+ (null !== workInProgress.memoizedState) &&
+ "unstable-defer-without-hiding" !== newProps.mode &&
+ (workInProgress.effectTag |= 4),
+ null
+ );
}
throw Error(
"Unknown unit of work tag (" +
@@ -4825,6 +5220,7 @@ function unwindWork(workInProgress) {
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
effectTag = workInProgress.effectTag;
if (0 !== (effectTag & 64))
throw Error(
@@ -4849,6 +5245,9 @@ function unwindWork(workInProgress) {
return popHostContainer(), null;
case 10:
return popProvider(workInProgress), null;
+ case 23:
+ case 24:
+ return popRenderLanes(), null;
default:
return null;
}
@@ -4867,51 +5266,61 @@ if (
throw Error(
"Expected ReactFiberErrorDialog.showErrorDialog to be a function."
);
-function logCapturedError(capturedError) {
- !1 !==
- ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
- capturedError
- ) && console.error(capturedError.error);
-}
-var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
-function logError(boundary, errorInfo) {
- var source = errorInfo.source,
- stack = errorInfo.stack;
- null === stack &&
- null !== source &&
- (stack = getStackByFiberInDevAndProd(source));
- errorInfo = {
- componentName: null !== source ? getComponentName(source.type) : null,
- componentStack: null !== stack ? stack : "",
- error: errorInfo.value,
- errorBoundary: null,
- errorBoundaryName: null,
- errorBoundaryFound: !1,
- willRetry: !1
- };
- null !== boundary &&
- 1 === boundary.tag &&
- ((errorInfo.errorBoundary = boundary.stateNode),
- (errorInfo.errorBoundaryName = getComponentName(boundary.type)),
- (errorInfo.errorBoundaryFound = !0),
- (errorInfo.willRetry = !0));
+function logCapturedError(boundary, errorInfo) {
try {
- logCapturedError(errorInfo);
+ !1 !==
+ ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({
+ componentStack: null !== errorInfo.stack ? errorInfo.stack : "",
+ error: errorInfo.value,
+ errorBoundary:
+ null !== boundary && 1 === boundary.tag ? boundary.stateNode : null
+ }) && console.error(errorInfo.value);
} catch (e) {
setTimeout(function() {
throw e;
});
}
}
-function safelyCallComponentWillUnmount(current, instance) {
- try {
- (instance.props = current.memoizedProps),
- (instance.state = current.memoizedState),
- instance.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(current, unmountError);
+var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
+function createRootErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ lane.payload = { element: null };
+ var error = errorInfo.value;
+ lane.callback = function() {
+ hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
+ logCapturedError(fiber, errorInfo);
+ };
+ return lane;
+}
+function createClassErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+ if ("function" === typeof getDerivedStateFromError) {
+ var error = errorInfo.value;
+ lane.payload = function() {
+ logCapturedError(fiber, errorInfo);
+ return getDerivedStateFromError(error);
+ };
}
+ var inst = fiber.stateNode;
+ null !== inst &&
+ "function" === typeof inst.componentDidCatch &&
+ (lane.callback = function() {
+ "function" !== typeof getDerivedStateFromError &&
+ (null === legacyErrorBoundariesThatAlreadyFailed
+ ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
+ : legacyErrorBoundariesThatAlreadyFailed.add(this),
+ logCapturedError(fiber, errorInfo));
+ var stack = errorInfo.stack;
+ this.componentDidCatch(errorInfo.value, {
+ componentStack: null !== stack ? stack : ""
+ });
+ });
+ return lane;
}
+var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
function safelyDetachRef(current) {
var ref = current.ref;
if (null !== ref)
@@ -4945,6 +5354,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
}
return;
case 3:
+ return;
case 5:
case 6:
case 4:
@@ -4955,58 +5365,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitHookEffectListUnmount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var destroy = effect.destroy;
- effect.destroy = void 0;
- void 0 !== destroy && destroy();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
-function commitHookEffectListMount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var create = effect.create;
- effect.destroy = create();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
function commitLifeCycles(finishedRoot, current, finishedWork) {
switch (finishedWork.tag) {
case 0:
case 11:
case 15:
case 22:
- commitHookEffectListMount(3, finishedWork);
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ if (3 === (finishedRoot.tag & 3)) {
+ var create$81 = finishedRoot.create;
+ finishedRoot.destroy = create$81();
+ }
+ finishedRoot = finishedRoot.next;
+ } while (finishedRoot !== current);
+ }
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ var _effect = finishedRoot;
+ create$81 = _effect.next;
+ _effect = _effect.tag;
+ 0 !== (_effect & 4) &&
+ 0 !== (_effect & 1) &&
+ (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot),
+ enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot));
+ finishedRoot = create$81;
+ } while (finishedRoot !== current);
+ }
return;
case 1:
finishedRoot = finishedWork.stateNode;
- if (finishedWork.effectTag & 4)
- if (null === current) finishedRoot.componentDidMount();
- else {
- var prevProps =
- finishedWork.elementType === finishedWork.type
- ? current.memoizedProps
- : resolveDefaultProps(finishedWork.type, current.memoizedProps);
- finishedRoot.componentDidUpdate(
- prevProps,
- current.memoizedState,
- finishedRoot.__reactInternalSnapshotBeforeUpdate
- );
- }
+ finishedWork.effectTag & 4 &&
+ (null === current
+ ? finishedRoot.componentDidMount()
+ : ((create$81 =
+ finishedWork.elementType === finishedWork.type
+ ? current.memoizedProps
+ : resolveDefaultProps(
+ finishedWork.type,
+ current.memoizedProps
+ )),
+ finishedRoot.componentDidUpdate(
+ create$81,
+ current.memoizedState,
+ finishedRoot.__reactInternalSnapshotBeforeUpdate
+ )));
current = finishedWork.updateQueue;
null !== current &&
commitUpdateQueue(finishedWork, current, finishedRoot);
@@ -5040,78 +5449,139 @@ function commitLifeCycles(finishedRoot, current, finishedWork) {
case 17:
case 20:
case 21:
+ case 23:
+ case 24:
return;
}
throw Error(
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) {
- "function" === typeof onCommitFiberUnmount &&
- onCommitFiberUnmount(current$jscomp$0);
- switch (current$jscomp$0.tag) {
+function hideOrUnhideAllChildren(finishedWork, isHidden) {
+ for (var node = finishedWork; ; ) {
+ if (5 === node.tag) {
+ var instance = node.stateNode;
+ if (isHidden) {
+ var viewConfig = instance.viewConfig;
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ { style: { display: "none" } },
+ viewConfig.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance._nativeTag,
+ viewConfig.uiViewClassName,
+ updatePayload
+ );
+ } else {
+ instance = node.stateNode;
+ updatePayload = node.memoizedProps;
+ viewConfig = instance.viewConfig;
+ var prevProps = Object.assign({}, updatePayload, {
+ style: [updatePayload.style, { display: "none" }]
+ });
+ updatePayload = diffProperties(
+ null,
+ prevProps,
+ updatePayload,
+ viewConfig.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance._nativeTag,
+ viewConfig.uiViewClassName,
+ updatePayload
+ );
+ }
+ } else {
+ if (6 === node.tag) throw Error("Not yet implemented.");
+ if (
+ ((23 !== node.tag && 24 !== node.tag) ||
+ null === node.memoizedState ||
+ node === finishedWork) &&
+ null !== node.child
+ ) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ }
+ if (node === finishedWork) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === finishedWork) return;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+}
+function commitUnmount(finishedRoot, current) {
+ if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount)
+ try {
+ injectedHook.onCommitFiberUnmount(rendererID, current);
+ } catch (err) {}
+ switch (current.tag) {
case 0:
case 11:
case 14:
case 15:
case 22:
- finishedRoot = current$jscomp$0.updateQueue;
+ finishedRoot = current.updateQueue;
if (
null !== finishedRoot &&
((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot)
) {
- var firstEffect = finishedRoot.next;
- runWithPriority(
- 97 < renderPriorityLevel ? 97 : renderPriorityLevel,
- function() {
- var effect = firstEffect;
- do {
- var _destroy = effect.destroy;
- if (void 0 !== _destroy) {
- var current = current$jscomp$0;
- try {
- _destroy();
- } catch (error) {
- captureCommitPhaseError(current, error);
- }
+ var effect = (finishedRoot = finishedRoot.next);
+ do {
+ var _effect2 = effect,
+ destroy = _effect2.destroy;
+ _effect2 = _effect2.tag;
+ if (void 0 !== destroy)
+ if (0 !== (_effect2 & 4))
+ enqueuePendingPassiveHookEffectUnmount(current, effect);
+ else {
+ _effect2 = current;
+ try {
+ destroy();
+ } catch (error) {
+ captureCommitPhaseError(_effect2, error);
}
- effect = effect.next;
- } while (effect !== firstEffect);
- }
- );
+ }
+ effect = effect.next;
+ } while (effect !== finishedRoot);
}
break;
case 1:
- safelyDetachRef(current$jscomp$0);
- renderPriorityLevel = current$jscomp$0.stateNode;
- "function" === typeof renderPriorityLevel.componentWillUnmount &&
- safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel);
+ safelyDetachRef(current);
+ finishedRoot = current.stateNode;
+ if ("function" === typeof finishedRoot.componentWillUnmount)
+ try {
+ (finishedRoot.props = current.memoizedProps),
+ (finishedRoot.state = current.memoizedState),
+ finishedRoot.componentWillUnmount();
+ } catch (unmountError) {
+ captureCommitPhaseError(current, unmountError);
+ }
break;
case 5:
- safelyDetachRef(current$jscomp$0);
+ safelyDetachRef(current);
break;
case 4:
- unmountHostComponents(
- finishedRoot,
- current$jscomp$0,
- renderPriorityLevel
- );
+ unmountHostComponents(finishedRoot, current);
}
}
-function detachFiber(current) {
- var alternate = current.alternate;
- current.return = null;
- current.child = null;
- current.memoizedState = null;
- current.updateQueue = null;
- current.dependencies = null;
- current.alternate = null;
- current.firstEffect = null;
- current.lastEffect = null;
- current.pendingProps = null;
- current.memoizedProps = null;
- current.stateNode = null;
- null !== alternate && detachFiber(alternate);
+function detachFiberMutation(fiber) {
+ fiber.alternate = null;
+ fiber.child = null;
+ fiber.dependencies = null;
+ fiber.firstEffect = null;
+ fiber.lastEffect = null;
+ fiber.memoizedProps = null;
+ fiber.memoizedState = null;
+ fiber.pendingProps = null;
+ fiber.return = null;
+ fiber.stateNode = null;
+ fiber.updateQueue = null;
}
function isHostParent(fiber) {
return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag;
@@ -5119,16 +5589,14 @@ function isHostParent(fiber) {
function commitPlacement(finishedWork) {
a: {
for (var parent = finishedWork.return; null !== parent; ) {
- if (isHostParent(parent)) {
- var parentFiber = parent;
- break a;
- }
+ if (isHostParent(parent)) break a;
parent = parent.return;
}
throw Error(
"Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."
);
}
+ var parentFiber = parent;
parent = parentFiber.stateNode;
switch (parentFiber.tag) {
case 5:
@@ -5263,11 +5731,7 @@ function insertOrAppendPlacementNode(node, before, parent) {
)
insertOrAppendPlacementNode(node, before, parent), (node = node.sibling);
}
-function unmountHostComponents(
- finishedRoot$jscomp$0,
- current,
- renderPriorityLevel$jscomp$0
-) {
+function unmountHostComponents(finishedRoot$jscomp$0, current) {
for (
var node = current,
currentParentIsValid = !1,
@@ -5305,13 +5769,12 @@ function unmountHostComponents(
a: for (
var finishedRoot = finishedRoot$jscomp$0,
root = node,
- renderPriorityLevel = renderPriorityLevel$jscomp$0,
node$jscomp$0 = root;
;
)
if (
- (commitUnmount(finishedRoot, node$jscomp$0, renderPriorityLevel),
+ (commitUnmount(finishedRoot, node$jscomp$0),
null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag)
)
(node$jscomp$0.child.return = node$jscomp$0),
@@ -5338,18 +5801,18 @@ function unmountHostComponents(
[0]
))
: ((finishedRoot = currentParent),
- (renderPriorityLevel = node.stateNode),
- recursivelyUncacheFiberNode(renderPriorityLevel),
+ (node$jscomp$0 = node.stateNode),
+ recursivelyUncacheFiberNode(node$jscomp$0),
(root = finishedRoot._children),
- (renderPriorityLevel = root.indexOf(renderPriorityLevel)),
- root.splice(renderPriorityLevel, 1),
+ (node$jscomp$0 = root.indexOf(node$jscomp$0)),
+ root.splice(node$jscomp$0, 1),
ReactNativePrivateInterface.UIManager.manageChildren(
finishedRoot._nativeTag,
[],
[],
[],
[],
- [renderPriorityLevel]
+ [node$jscomp$0]
));
} else if (4 === node.tag) {
if (null !== node.child) {
@@ -5360,8 +5823,7 @@ function unmountHostComponents(
continue;
}
} else if (
- (commitUnmount(finishedRoot$jscomp$0, node, renderPriorityLevel$jscomp$0),
- null !== node.child)
+ (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child)
) {
node.child.return = node;
node = node.child;
@@ -5384,31 +5846,42 @@ function commitWork(current, finishedWork) {
case 14:
case 15:
case 22:
- commitHookEffectListUnmount(3, finishedWork);
+ var updateQueue = finishedWork.updateQueue;
+ updateQueue = null !== updateQueue ? updateQueue.lastEffect : null;
+ if (null !== updateQueue) {
+ var effect = (updateQueue = updateQueue.next);
+ do
+ 3 === (effect.tag & 3) &&
+ ((finishedWork = effect.destroy),
+ (effect.destroy = void 0),
+ void 0 !== finishedWork && finishedWork()),
+ (effect = effect.next);
+ while (effect !== updateQueue);
+ }
return;
case 1:
return;
case 5:
- var instance = finishedWork.stateNode;
- if (null != instance) {
- var newProps = finishedWork.memoizedProps;
- current = null !== current ? current.memoizedProps : newProps;
+ updateQueue = finishedWork.stateNode;
+ if (null != updateQueue) {
+ effect = finishedWork.memoizedProps;
+ current = null !== current ? current.memoizedProps : effect;
var updatePayload = finishedWork.updateQueue;
finishedWork.updateQueue = null;
null !== updatePayload &&
- ((finishedWork = instance.viewConfig),
- instanceProps.set(instance._nativeTag, newProps),
- (newProps = diffProperties(
+ ((finishedWork = updateQueue.viewConfig),
+ instanceProps.set(updateQueue._nativeTag, effect),
+ (effect = diffProperties(
null,
current,
- newProps,
+ effect,
finishedWork.validAttributes
)),
- null != newProps &&
+ null != effect &&
ReactNativePrivateInterface.UIManager.updateView(
- instance._nativeTag,
+ updateQueue._nativeTag,
finishedWork.uiViewClassName,
- newProps
+ effect
));
}
return;
@@ -5428,72 +5901,9 @@ function commitWork(current, finishedWork) {
case 12:
return;
case 13:
- instance = finishedWork;
- null === finishedWork.memoizedState
- ? (newProps = !1)
- : ((newProps = !0),
- (instance = finishedWork.child),
- (globalMostRecentFallbackTime = now()));
- if (null !== instance)
- a: for (current = instance; ; ) {
- if (5 === current.tag)
- if (((updatePayload = current.stateNode), newProps)) {
- var viewConfig = updatePayload.viewConfig;
- var updatePayload$jscomp$0 = diffProperties(
- null,
- emptyObject,
- { style: { display: "none" } },
- viewConfig.validAttributes
- );
- ReactNativePrivateInterface.UIManager.updateView(
- updatePayload._nativeTag,
- viewConfig.uiViewClassName,
- updatePayload$jscomp$0
- );
- } else {
- updatePayload = current.stateNode;
- updatePayload$jscomp$0 = current.memoizedProps;
- viewConfig = updatePayload.viewConfig;
- var prevProps = Object.assign({}, updatePayload$jscomp$0, {
- style: [updatePayload$jscomp$0.style, { display: "none" }]
- });
- updatePayload$jscomp$0 = diffProperties(
- null,
- prevProps,
- updatePayload$jscomp$0,
- viewConfig.validAttributes
- );
- ReactNativePrivateInterface.UIManager.updateView(
- updatePayload._nativeTag,
- viewConfig.uiViewClassName,
- updatePayload$jscomp$0
- );
- }
- else {
- if (6 === current.tag) throw Error("Not yet implemented.");
- if (
- 13 === current.tag &&
- null !== current.memoizedState &&
- null === current.memoizedState.dehydrated
- ) {
- updatePayload = current.child.sibling;
- updatePayload.return = current;
- current = updatePayload;
- continue;
- } else if (null !== current.child) {
- current.child.return = current;
- current = current.child;
- continue;
- }
- }
- if (current === instance) break;
- for (; null === current.sibling; ) {
- if (null === current.return || current.return === instance) break a;
- current = current.return;
- }
- current.sibling.return = current.return;
- current = current.sibling;
- }
+ null !== finishedWork.memoizedState &&
+ ((globalMostRecentFallbackTime = now()),
+ hideOrUnhideAllChildren(finishedWork.child, !0));
attachSuspenseRetryListeners(finishedWork);
return;
case 19:
@@ -5501,90 +5911,59 @@ function commitWork(current, finishedWork) {
return;
case 17:
return;
+ case 23:
+ case 24:
+ hideOrUnhideAllChildren(
+ finishedWork,
+ null !== finishedWork.memoizedState
+ );
+ return;
}
throw Error(
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
function attachSuspenseRetryListeners(finishedWork) {
- var thenables = finishedWork.updateQueue;
- if (null !== thenables) {
+ var wakeables = finishedWork.updateQueue;
+ if (null !== wakeables) {
finishedWork.updateQueue = null;
var retryCache = finishedWork.stateNode;
null === retryCache &&
(retryCache = finishedWork.stateNode = new PossiblyWeakSet());
- thenables.forEach(function(thenable) {
- var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
- retryCache.has(thenable) ||
- (retryCache.add(thenable), thenable.then(retry, retry));
+ wakeables.forEach(function(wakeable) {
+ var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
+ retryCache.has(wakeable) ||
+ (retryCache.add(wakeable), wakeable.then(retry, retry));
});
}
}
-var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
-function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- expirationTime.payload = { element: null };
- var error = errorInfo.value;
- expirationTime.callback = function() {
- hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
- logError(fiber, errorInfo);
- };
- return expirationTime;
-}
-function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
- if ("function" === typeof getDerivedStateFromError) {
- var error = errorInfo.value;
- expirationTime.payload = function() {
- logError(fiber, errorInfo);
- return getDerivedStateFromError(error);
- };
- }
- var inst = fiber.stateNode;
- null !== inst &&
- "function" === typeof inst.componentDidCatch &&
- (expirationTime.callback = function() {
- "function" !== typeof getDerivedStateFromError &&
- (null === legacyErrorBoundariesThatAlreadyFailed
- ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logError(fiber, errorInfo));
- var stack = errorInfo.stack;
- this.componentDidCatch(errorInfo.value, {
- componentStack: null !== stack ? stack : ""
- });
- });
- return expirationTime;
+function isSuspenseBoundaryBeingHidden(current, finishedWork) {
+ return null !== current &&
+ ((current = current.memoizedState),
+ null === current || null !== current.dehydrated)
+ ? ((finishedWork = finishedWork.memoizedState),
+ null !== finishedWork && null === finishedWork.dehydrated)
+ : !1;
}
var ceil = Math.ceil,
- ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
+ ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
- NoContext = 0,
- LegacyUnbatchedContext = 8,
- RenderContext = 16,
- CommitContext = 32,
- RootIncomplete = 0,
- RootFatalErrored = 1,
- RootErrored = 2,
- RootSuspended = 3,
- RootSuspendedWithDelay = 4,
- RootCompleted = 5,
- executionContext = NoContext,
+ executionContext = 0,
workInProgressRoot = null,
workInProgress = null,
- renderExpirationTime$1 = 0,
- workInProgressRootExitStatus = RootIncomplete,
+ workInProgressRootRenderLanes = 0,
+ subtreeRenderLanes = 0,
+ subtreeRenderLanesCursor = createCursor(0),
+ workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
- workInProgressRootLatestProcessedExpirationTime = 1073741823,
- workInProgressRootLatestSuspenseTimeout = 1073741823,
+ workInProgressRootLatestSuspenseTimeout = -1,
workInProgressRootCanSuspendUsingConfig = null,
- workInProgressRootNextUnprocessedUpdateTime = 0,
- workInProgressRootHasPendingPing = !1,
+ workInProgressRootIncludedLanes = 0,
+ workInProgressRootSkippedLanes = 0,
+ workInProgressRootUpdatedLanes = 0,
+ workInProgressRootPingedLanes = 0,
+ mostRecentlyUpdatedRoot = null,
globalMostRecentFallbackTime = 0,
- FALLBACK_THROTTLE_MS = 500,
nextEffect = null,
hasUncaughtError = !1,
firstUncaughtError = null,
@@ -5592,205 +5971,200 @@ var ceil = Math.ceil,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsRenderPriority = 90,
+ pendingPassiveHookEffectsMount = [],
+ pendingPassiveHookEffectsUnmount = [],
rootsWithPendingDiscreteUpdates = null,
nestedUpdateCount = 0,
rootWithNestedUpdates = null,
- currentEventTime = 0;
-function requestCurrentTimeForUpdate() {
- return (executionContext & (RenderContext | CommitContext)) !== NoContext
- ? 1073741821 - ((now() / 10) | 0)
- : 0 !== currentEventTime
+ currentEventTime = -1,
+ currentEventWipLanes = 0,
+ currentEventPendingLanes = 0,
+ focusedInstanceHandle = null,
+ shouldFireAfterActiveInstanceBlur = !1;
+function requestEventTime() {
+ return 0 !== (executionContext & 48)
+ ? now()
+ : -1 !== currentEventTime
? currentEventTime
- : (currentEventTime = 1073741821 - ((now() / 10) | 0));
+ : (currentEventTime = now());
}
-function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
+function requestUpdateLane(fiber, suspenseConfig) {
fiber = fiber.mode;
- if (0 === (fiber & 2)) return 1073741823;
- var priorityLevel = getCurrentPriorityLevel();
- if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822;
- if ((executionContext & RenderContext) !== NoContext)
- return renderExpirationTime$1;
- if (null !== suspenseConfig)
- currentTime =
- 1073741821 -
- 25 *
- ((((1073741821 -
- currentTime +
- (suspenseConfig.timeoutMs | 0 || 5e3) / 10) /
- 25) |
- 0) +
- 1);
- else
- switch (priorityLevel) {
- case 99:
- currentTime = 1073741823;
- break;
- case 98:
- currentTime =
- 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1);
- break;
- case 97:
- case 96:
- currentTime =
- 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1);
- break;
- case 95:
- currentTime = 2;
- break;
- default:
- throw Error("Expected a valid priority level");
- }
- null !== workInProgressRoot &&
- currentTime === renderExpirationTime$1 &&
- --currentTime;
- return currentTime;
-}
-function scheduleWork(fiber, expirationTime) {
- if (50 < nestedUpdateCount)
- throw ((nestedUpdateCount = 0),
- (rootWithNestedUpdates = null),
- Error(
- "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
- ));
- fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
- if (null !== fiber) {
- var priorityLevel = getCurrentPriorityLevel();
- 1073741823 === expirationTime
- ? (executionContext & LegacyUnbatchedContext) !== NoContext &&
- (executionContext & (RenderContext | CommitContext)) === NoContext
- ? performSyncWorkOnRoot(fiber)
- : (ensureRootIsScheduled(fiber),
- executionContext === NoContext && flushSyncCallbackQueue())
- : ensureRootIsScheduled(fiber);
- (executionContext & 4) === NoContext ||
- (98 !== priorityLevel && 99 !== priorityLevel) ||
- (null === rootsWithPendingDiscreteUpdates
- ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]))
- : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)),
- (void 0 === priorityLevel || priorityLevel > expirationTime) &&
- rootsWithPendingDiscreteUpdates.set(fiber, expirationTime)));
+ if (0 === (fiber & 2)) return 1;
+ if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2;
+ 0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes);
+ if (null !== suspenseConfig) {
+ suspenseConfig = suspenseConfig.timeoutMs;
+ fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6;
+ 0 !== currentEventPendingLanes &&
+ (currentEventPendingLanes =
+ null !== mostRecentlyUpdatedRoot
+ ? mostRecentlyUpdatedRoot.pendingLanes
+ : 0);
+ suspenseConfig = currentEventWipLanes;
+ var pendingLanes = currentEventPendingLanes;
+ if (8 === fiber)
+ (fiber = pickArbitraryLane(122880 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 8192)),
+ (suspenseConfig = fiber);
+ else if (6 === fiber)
+ (fiber = pickArbitraryLane(3932160 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 262144)),
+ (suspenseConfig = fiber);
+ else
+ throw Error(
+ "Invalid transition priority: " + fiber + ". This is a bug in React."
+ );
+ return suspenseConfig;
}
-}
-function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
- fiber.expirationTime < expirationTime &&
- (fiber.expirationTime = expirationTime);
- var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < expirationTime &&
- (alternate.expirationTime = expirationTime);
- var node = fiber.return,
- root = null;
- if (null === node && 3 === fiber.tag) root = fiber.stateNode;
- else
- for (; null !== node; ) {
- alternate = node.alternate;
- node.childExpirationTime < expirationTime &&
- (node.childExpirationTime = expirationTime);
- null !== alternate &&
- alternate.childExpirationTime < expirationTime &&
- (alternate.childExpirationTime = expirationTime);
- if (null === node.return && 3 === node.tag) {
- root = node.stateNode;
- break;
+ suspenseConfig = getCurrentPriorityLevel();
+ 0 !== (executionContext & 4) && 98 === suspenseConfig
+ ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes))
+ : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)),
+ (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes)));
+ return suspenseConfig;
+}
+function scheduleUpdateOnFiber(fiber, lane, eventTime) {
+ if (50 < nestedUpdateCount)
+ throw ((nestedUpdateCount = 0),
+ (rootWithNestedUpdates = null),
+ Error(
+ "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
+ ));
+ fiber = markUpdateLaneFromFiberToRoot(fiber, lane);
+ if (null === fiber) return null;
+ markRootUpdated(fiber, lane, eventTime);
+ fiber === workInProgressRoot &&
+ ((workInProgressRootUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(fiber, workInProgressRootRenderLanes));
+ var priorityLevel = getCurrentPriorityLevel();
+ 1 === lane
+ ? 0 !== (executionContext & 8) && 0 === (executionContext & 48)
+ ? performSyncWorkOnRoot(fiber)
+ : (ensureRootIsScheduled(fiber, eventTime),
+ 0 === executionContext && flushSyncCallbackQueue())
+ : (0 === (executionContext & 4) ||
+ (98 !== priorityLevel && 99 !== priorityLevel) ||
+ (null === rootsWithPendingDiscreteUpdates
+ ? (rootsWithPendingDiscreteUpdates = new Set([fiber]))
+ : rootsWithPendingDiscreteUpdates.add(fiber)),
+ ensureRootIsScheduled(fiber, eventTime));
+ mostRecentlyUpdatedRoot = fiber;
+}
+function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
+ sourceFiber.lanes |= lane;
+ var alternate = sourceFiber.alternate;
+ null !== alternate && (alternate.lanes |= lane);
+ alternate = sourceFiber;
+ for (sourceFiber = sourceFiber.return; null !== sourceFiber; )
+ (sourceFiber.childLanes |= lane),
+ (alternate = sourceFiber.alternate),
+ null !== alternate && (alternate.childLanes |= lane),
+ (alternate = sourceFiber),
+ (sourceFiber = sourceFiber.return);
+ return 3 === alternate.tag ? alternate.stateNode : null;
+}
+function ensureRootIsScheduled(root, currentTime) {
+ for (
+ var existingCallbackNode = root.callbackNode,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes,
+ expirationTimes = root.expirationTimes,
+ lanes = root.pendingLanes;
+ 0 < lanes;
+
+ ) {
+ var index$7 = 31 - clz32(lanes),
+ lane = 1 << index$7,
+ expirationTime = expirationTimes[index$7];
+ if (-1 === expirationTime) {
+ if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) {
+ expirationTime = currentTime;
+ getHighestPriorityLanes(lane);
+ var priority = return_highestLanePriority;
+ expirationTimes[index$7] =
+ 12 <= priority
+ ? expirationTime + 1e3
+ : 6 <= priority
+ ? expirationTime + 5e3
+ : -1;
}
- node = node.return;
- }
- null !== root &&
- (workInProgressRoot === root &&
- (markUnprocessedUpdateTime(expirationTime),
- workInProgressRootExitStatus === RootSuspendedWithDelay &&
- markRootSuspendedAtTime(root, renderExpirationTime$1)),
- markRootUpdatedAtTime(root, expirationTime));
- return root;
-}
-function getNextRootExpirationTimeToWorkOn(root) {
- var lastExpiredTime = root.lastExpiredTime;
- if (0 !== lastExpiredTime) return lastExpiredTime;
- lastExpiredTime = root.firstPendingTime;
- if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime;
- var lastPingedTime = root.lastPingedTime;
- root = root.nextKnownPendingLevel;
- root = lastPingedTime > root ? lastPingedTime : root;
- return 2 >= root && lastExpiredTime !== root ? 0 : root;
-}
-function ensureRootIsScheduled(root) {
- if (0 !== root.lastExpiredTime)
- (root.callbackExpirationTime = 1073741823),
- (root.callbackPriority = 99),
- (root.callbackNode = scheduleSyncCallback(
- performSyncWorkOnRoot.bind(null, root)
- ));
+ } else expirationTime <= currentTime && (root.expiredLanes |= lane);
+ lanes &= ~lane;
+ }
+ suspendedLanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ currentTime = return_highestLanePriority;
+ if (0 === suspendedLanes)
+ null !== existingCallbackNode &&
+ (existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode),
+ (root.callbackNode = null),
+ (root.callbackPriority = 0));
else {
- var expirationTime = getNextRootExpirationTimeToWorkOn(root),
- existingCallbackNode = root.callbackNode;
- if (0 === expirationTime)
- null !== existingCallbackNode &&
- ((root.callbackNode = null),
- (root.callbackExpirationTime = 0),
- (root.callbackPriority = 90));
- else {
- var priorityLevel = requestCurrentTimeForUpdate();
- 1073741823 === expirationTime
- ? (priorityLevel = 99)
- : 1 === expirationTime || 2 === expirationTime
- ? (priorityLevel = 95)
- : ((priorityLevel =
- 10 * (1073741821 - expirationTime) -
- 10 * (1073741821 - priorityLevel)),
- (priorityLevel =
- 0 >= priorityLevel
- ? 99
- : 250 >= priorityLevel
- ? 98
- : 5250 >= priorityLevel
- ? 97
- : 95));
- if (null !== existingCallbackNode) {
- var existingCallbackPriority = root.callbackPriority;
- if (
- root.callbackExpirationTime === expirationTime &&
- existingCallbackPriority >= priorityLevel
- )
- return;
- existingCallbackNode !== fakeCallbackNode &&
- Scheduler_cancelCallback(existingCallbackNode);
- }
- root.callbackExpirationTime = expirationTime;
- root.callbackPriority = priorityLevel;
- expirationTime =
- 1073741823 === expirationTime
- ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root))
- : scheduleCallback(
- priorityLevel,
- performConcurrentWorkOnRoot.bind(null, root),
- { timeout: 10 * (1073741821 - expirationTime) - now() }
- );
- root.callbackNode = expirationTime;
+ if (null !== existingCallbackNode) {
+ if (root.callbackPriority === currentTime) return;
+ existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode);
}
+ 17 === currentTime
+ ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)),
+ null === syncQueue
+ ? ((syncQueue = [existingCallbackNode]),
+ (immediateQueueCallbackNode = Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueueImpl
+ )))
+ : syncQueue.push(existingCallbackNode),
+ (existingCallbackNode = fakeCallbackNode))
+ : 16 === currentTime
+ ? (existingCallbackNode = scheduleCallback(
+ 99,
+ performSyncWorkOnRoot.bind(null, root)
+ ))
+ : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)),
+ (existingCallbackNode = scheduleCallback(
+ existingCallbackNode,
+ performConcurrentWorkOnRoot.bind(null, root)
+ )));
+ root.callbackPriority = currentTime;
+ root.callbackNode = existingCallbackNode;
}
}
function performConcurrentWorkOnRoot(root, didTimeout) {
- currentEventTime = 0;
- if (didTimeout) {
- didTimeout = requestCurrentTimeForUpdate();
- var lastExpiredTime = root.lastExpiredTime;
- if (0 === lastExpiredTime || lastExpiredTime > didTimeout)
- root.lastExpiredTime = didTimeout;
- ensureRootIsScheduled(root);
- return null;
- }
- lastExpiredTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 === lastExpiredTime) return null;
- didTimeout = root.callbackNode;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ currentEventTime = -1;
+ currentEventPendingLanes = currentEventWipLanes = 0;
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- flushPassiveEffects();
- var expirationTime = lastExpiredTime;
- var exitStatus = executionContext;
- executionContext |= RenderContext;
+ var originalCallbackNode = root.callbackNode;
+ if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
+ return null;
+ var lanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ if (0 === lanes) return null;
+ if (didTimeout)
+ return (
+ (root.expiredLanes |= lanes & root.pendingLanes),
+ ensureRootIsScheduled(root, now()),
+ null
+ );
+ didTimeout = lanes;
+ var prevExecutionContext = executionContext;
+ executionContext |= 16;
var prevDispatcher = pushDispatcher();
- (root === workInProgressRoot && expirationTime === renderExpirationTime$1) ||
- prepareFreshStack(root, expirationTime);
+ (workInProgressRoot === root &&
+ workInProgressRootRenderLanes === didTimeout) ||
+ prepareFreshStack(root, didTimeout);
do
try {
workLoopConcurrent();
@@ -5800,156 +6174,120 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
}
while (1);
resetContextDependencies();
- ReactCurrentDispatcher$1.current = prevDispatcher;
- executionContext = exitStatus;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
+ executionContext = prevExecutionContext;
null !== workInProgress
- ? (exitStatus = RootIncomplete)
+ ? (didTimeout = 0)
: ((workInProgressRoot = null),
- (exitStatus = workInProgressRootExitStatus));
- if (exitStatus !== RootIncomplete) {
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
- throw ((didTimeout = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
- didTimeout);
- expirationTime = root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
- switch (exitStatus) {
- case RootIncomplete:
- case RootFatalErrored:
+ (workInProgressRootRenderLanes = 0),
+ (didTimeout = workInProgressRootExitStatus));
+ if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes))
+ prepareFreshStack(root, 0);
+ else if (0 !== didTimeout) {
+ 2 === didTimeout &&
+ ((executionContext |= 64),
+ root.hydrate && (root.hydrate = !1),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (didTimeout = renderRootSync(root, lanes)));
+ if (1 === didTimeout)
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = root.current.alternate;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
throw Error("Root did not complete. This is a bug in React.");
- case RootErrored:
+ case 2:
commitRoot(root);
break;
- case RootSuspended:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- expirationTime
- ));
+ case 3:
+ markRootSuspended$1(root, lanes);
if (
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- ((expirationTime =
- globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()),
- 10 < expirationTime)
+ (lanes & 62914560) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
) {
- if (
- workInProgressRootHasPendingPing &&
- ((prevDispatcher = root.lastPingedTime),
- 0 === prevDispatcher || prevDispatcher >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- prevDispatcher = getNextRootExpirationTimeToWorkOn(root);
- if (0 !== prevDispatcher && prevDispatcher !== lastExpiredTime) break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ if (0 !== getNextLanes(root, 0)) break;
+ prevExecutionContext = root.suspendedLanes;
+ if ((prevExecutionContext & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & prevExecutionContext;
break;
}
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- expirationTime
+ didTimeout
);
break;
}
commitRoot(root);
break;
- case RootSuspendedWithDelay:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- expirationTime
- ));
- if (
- workInProgressRootHasPendingPing &&
- ((expirationTime = root.lastPingedTime),
- 0 === expirationTime || expirationTime >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- expirationTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 !== expirationTime && expirationTime !== lastExpiredTime) break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if (0 !== getNextLanes(root, 0)) break;
+ didTimeout = root.suspendedLanes;
+ if ((didTimeout & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & didTimeout;
break;
}
- 1073741823 !== workInProgressRootLatestSuspenseTimeout
- ? (expirationTime =
- 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) -
- now())
- : 1073741823 === workInProgressRootLatestProcessedExpirationTime
- ? (expirationTime = 0)
- : ((expirationTime =
- 10 *
- (1073741821 - workInProgressRootLatestProcessedExpirationTime) -
- 5e3),
- (exitStatus = now()),
- (lastExpiredTime =
- 10 * (1073741821 - lastExpiredTime) - exitStatus),
- (expirationTime = exitStatus - expirationTime),
- 0 > expirationTime && (expirationTime = 0),
- (expirationTime =
- (120 > expirationTime
+ lanes = getMostRecentEventTime(root, lanes);
+ -1 !== workInProgressRootLatestSuspenseTimeout
+ ? (lanes = workInProgressRootLatestSuspenseTimeout - now())
+ : -1 === lanes
+ ? (lanes = 0)
+ : ((lanes = now() - lanes),
+ (lanes =
+ (120 > lanes
? 120
- : 480 > expirationTime
+ : 480 > lanes
? 480
- : 1080 > expirationTime
+ : 1080 > lanes
? 1080
- : 1920 > expirationTime
+ : 1920 > lanes
? 1920
- : 3e3 > expirationTime
+ : 3e3 > lanes
? 3e3
- : 4320 > expirationTime
+ : 4320 > lanes
? 4320
- : 1960 * ceil(expirationTime / 1960)) - expirationTime),
- lastExpiredTime < expirationTime &&
- (expirationTime = lastExpiredTime));
- if (10 < expirationTime) {
+ : 1960 * ceil(lanes / 1960)) - lanes));
+ if (10 < lanes) {
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- expirationTime
+ lanes
);
break;
}
commitRoot(root);
break;
- case RootCompleted:
+ case 5:
+ prevDispatcher = getMostRecentEventTime(root, lanes);
if (
- 1073741823 !== workInProgressRootLatestProcessedExpirationTime &&
- null !== workInProgressRootCanSuspendUsingConfig
- ) {
- prevDispatcher = workInProgressRootLatestProcessedExpirationTime;
- var suspenseConfig = workInProgressRootCanSuspendUsingConfig;
- expirationTime = suspenseConfig.busyMinDurationMs | 0;
- 0 >= expirationTime
- ? (expirationTime = 0)
- : ((exitStatus = suspenseConfig.busyDelayMs | 0),
- (prevDispatcher =
- now() -
- (10 * (1073741821 - prevDispatcher) -
- (suspenseConfig.timeoutMs | 0 || 5e3))),
- (expirationTime =
- prevDispatcher <= exitStatus
+ -1 !== prevDispatcher &&
+ null !== workInProgressRootCanSuspendUsingConfig &&
+ ((didTimeout =
+ workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0),
+ 0 >= didTimeout
+ ? (didTimeout = 0)
+ : ((prevExecutionContext =
+ workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0),
+ (prevDispatcher = now() - prevDispatcher),
+ (didTimeout =
+ prevDispatcher <= prevExecutionContext
? 0
- : exitStatus + expirationTime - prevDispatcher));
- if (10 < expirationTime) {
- markRootSuspendedAtTime(root, lastExpiredTime);
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- expirationTime
- );
- break;
- }
+ : prevExecutionContext + didTimeout - prevDispatcher)),
+ 10 < didTimeout)
+ ) {
+ markRootSuspended$1(root, lanes);
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ didTimeout
+ );
+ break;
}
commitRoot(root);
break;
@@ -5957,42 +6295,68 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
throw Error("Unknown root exit status.");
}
}
- ensureRootIsScheduled(root);
- return root.callbackNode === didTimeout
+ ensureRootIsScheduled(root, now());
+ return root.callbackNode === originalCallbackNode
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function markRootSuspended$1(root, suspendedLanes) {
+ suspendedLanes &= ~workInProgressRootPingedLanes;
+ suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ root.suspendedLanes |= suspendedLanes;
+ root.pingedLanes &= ~suspendedLanes;
+ for (root = root.expirationTimes; 0 < suspendedLanes; ) {
+ var index$12 = 31 - clz32(suspendedLanes),
+ lane = 1 << index$12;
+ root[index$12] = -1;
+ suspendedLanes &= ~lane;
+ }
+}
function performSyncWorkOnRoot(root) {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
flushPassiveEffects();
- var lastExpiredTime = root.lastExpiredTime;
- lastExpiredTime =
- 0 !== lastExpiredTime
- ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime
- ? renderExpirationTime$1
- : lastExpiredTime
- : 1073741823;
- var exitStatus = renderRootSync(root, lastExpiredTime);
+ if (
+ root === workInProgressRoot &&
+ 0 !== (root.expiredLanes & workInProgressRootRenderLanes)
+ ) {
+ var lanes = workInProgressRootRenderLanes;
+ var exitStatus = renderRootSync(root, lanes);
+ 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) &&
+ ((lanes = getNextLanes(root, lanes)),
+ (exitStatus = renderRootSync(root, lanes)));
+ } else
+ (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes));
0 !== root.tag &&
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
+ 2 === exitStatus &&
+ ((executionContext |= 64),
+ root.hydrate && (root.hydrate = !1),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (exitStatus = renderRootSync(root, lanes)));
+ if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
exitStatus);
root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
+ root.finishedLanes = lanes;
commitRoot(root);
- ensureRootIsScheduled(root);
+ ensureRootIsScheduled(root, now());
return null;
}
-function prepareFreshStack(root, expirationTime) {
+function pushRenderLanes(fiber, lanes) {
+ push(subtreeRenderLanesCursor, subtreeRenderLanes);
+ subtreeRenderLanes |= lanes;
+ workInProgressRootIncludedLanes |= lanes;
+}
+function popRenderLanes() {
+ subtreeRenderLanes = subtreeRenderLanesCursor.current;
+ pop(subtreeRenderLanesCursor);
+}
+function prepareFreshStack(root, lanes) {
root.finishedWork = null;
- root.finishedExpirationTime = 0;
+ root.finishedLanes = 0;
var timeoutHandle = root.timeoutHandle;
-1 !== timeoutHandle &&
((root.timeoutHandle = -1), cancelTimeout(timeoutHandle));
@@ -6010,6 +6374,7 @@ function prepareFreshStack(root, expirationTime) {
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
break;
case 5:
popHostContext(interruptedWork);
@@ -6025,25 +6390,29 @@ function prepareFreshStack(root, expirationTime) {
break;
case 10:
popProvider(interruptedWork);
+ break;
+ case 23:
+ case 24:
+ popRenderLanes();
}
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
workInProgress = createWorkInProgress(root.current, null);
- renderExpirationTime$1 = expirationTime;
- workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
+ workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823;
+ workInProgressRootLatestSuspenseTimeout = -1;
workInProgressRootCanSuspendUsingConfig = null;
- workInProgressRootNextUnprocessedUpdateTime = 0;
- workInProgressRootHasPendingPing = !1;
+ workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
}
function handleError(root$jscomp$0, thrownValue) {
do {
+ var erroredWork = workInProgress;
try {
resetContextDependencies();
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
- if (didScheduleRenderPhaseUpdate)
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ if (didScheduleRenderPhaseUpdate) {
for (
var hook = currentlyRenderingFiber$1.memoizedState;
null !== hook;
@@ -6053,21 +6422,24 @@ function handleError(root$jscomp$0, thrownValue) {
null !== queue && (queue.pending = null);
hook = hook.next;
}
- renderExpirationTime = 0;
+ didScheduleRenderPhaseUpdate = !1;
+ }
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
- didScheduleRenderPhaseUpdate = !1;
- if (null === workInProgress || null === workInProgress.return)
- return (
- (workInProgressRootExitStatus = RootFatalErrored),
- (workInProgressRootFatalError = thrownValue),
- (workInProgress = null)
- );
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ ReactCurrentOwner$2.current = null;
+ if (null === erroredWork || null === erroredWork.return) {
+ workInProgressRootExitStatus = 1;
+ workInProgressRootFatalError = thrownValue;
+ workInProgress = null;
+ break;
+ }
a: {
var root = root$jscomp$0,
- returnFiber = workInProgress.return,
- sourceFiber = workInProgress,
+ returnFiber = erroredWork.return,
+ sourceFiber = erroredWork,
value = thrownValue;
- thrownValue = renderExpirationTime$1;
+ thrownValue = workInProgressRootRenderLanes;
sourceFiber.effectTag |= 2048;
sourceFiber.firstEffect = sourceFiber.lastEffect = null;
if (
@@ -6075,27 +6447,27 @@ function handleError(root$jscomp$0, thrownValue) {
"object" === typeof value &&
"function" === typeof value.then
) {
- var thenable = value;
+ var wakeable = value;
if (0 === (sourceFiber.mode & 2)) {
var currentSource = sourceFiber.alternate;
currentSource
? ((sourceFiber.updateQueue = currentSource.updateQueue),
(sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.expirationTime = currentSource.expirationTime))
+ (sourceFiber.lanes = currentSource.lanes))
: ((sourceFiber.updateQueue = null),
(sourceFiber.memoizedState = null));
}
var hasInvisibleParentBoundary =
0 !== (suspenseStackCursor.current & 1),
- _workInProgress = returnFiber;
+ workInProgress$76 = returnFiber;
do {
var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === _workInProgress.tag)) {
- var nextState = _workInProgress.memoizedState;
+ if ((JSCompiler_temp = 13 === workInProgress$76.tag)) {
+ var nextState = workInProgress$76.memoizedState;
if (null !== nextState)
JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
else {
- var props = _workInProgress.memoizedProps;
+ var props = workInProgress$76.memoizedProps;
JSCompiler_temp =
void 0 === props.fallback
? !1
@@ -6107,23 +6479,24 @@ function handleError(root$jscomp$0, thrownValue) {
}
}
if (JSCompiler_temp) {
- var thenables = _workInProgress.updateQueue;
- if (null === thenables) {
+ var wakeables = workInProgress$76.updateQueue;
+ if (null === wakeables) {
var updateQueue = new Set();
- updateQueue.add(thenable);
- _workInProgress.updateQueue = updateQueue;
- } else thenables.add(thenable);
- if (0 === (_workInProgress.mode & 2)) {
- _workInProgress.effectTag |= 64;
+ updateQueue.add(wakeable);
+ workInProgress$76.updateQueue = updateQueue;
+ } else wakeables.add(wakeable);
+ if (0 === (workInProgress$76.mode & 2)) {
+ workInProgress$76.effectTag |= 64;
+ sourceFiber.effectTag |= 16384;
sourceFiber.effectTag &= -2981;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
- var update = createUpdate(1073741823, null);
+ var update = createUpdate(-1, 1, null);
update.tag = 2;
enqueueUpdate(sourceFiber, update);
}
- sourceFiber.expirationTime = 1073741823;
+ sourceFiber.lanes |= 1;
break a;
}
value = void 0;
@@ -6132,108 +6505,105 @@ function handleError(root$jscomp$0, thrownValue) {
null === pingCache
? ((pingCache = root.pingCache = new PossiblyWeakMap()),
(value = new Set()),
- pingCache.set(thenable, value))
- : ((value = pingCache.get(thenable)),
+ pingCache.set(wakeable, value))
+ : ((value = pingCache.get(wakeable)),
void 0 === value &&
- ((value = new Set()), pingCache.set(thenable, value)));
+ ((value = new Set()), pingCache.set(wakeable, value)));
if (!value.has(sourceFiber)) {
value.add(sourceFiber);
var ping = pingSuspendedRoot.bind(
null,
root,
- thenable,
+ wakeable,
sourceFiber
);
- thenable.then(ping, ping);
+ wakeable.then(ping, ping);
}
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
+ workInProgress$76.effectTag |= 4096;
+ workInProgress$76.lanes = thrownValue;
break a;
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$76 = workInProgress$76.return;
+ } while (null !== workInProgress$76);
value = Error(
(getComponentName(sourceFiber.type) || "A React component") +
- " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." +
- getStackByFiberInDevAndProd(sourceFiber)
+ " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display."
);
}
- workInProgressRootExitStatus !== RootCompleted &&
- (workInProgressRootExitStatus = RootErrored);
+ 5 !== workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 2);
value = createCapturedValue(value, sourceFiber);
- _workInProgress = returnFiber;
+ workInProgress$76 = returnFiber;
do {
- switch (_workInProgress.tag) {
+ switch (workInProgress$76.tag) {
case 3:
- thenable = value;
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update = createRootErrorUpdate(
- _workInProgress,
- thenable,
+ root = value;
+ workInProgress$76.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$76.lanes |= thrownValue;
+ var update$77 = createRootErrorUpdate(
+ workInProgress$76,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update);
+ enqueueCapturedUpdate(workInProgress$76, update$77);
break a;
case 1:
- thenable = value;
- var ctor = _workInProgress.type,
- instance = _workInProgress.stateNode;
+ root = value;
+ var ctor = workInProgress$76.type,
+ instance = workInProgress$76.stateNode;
if (
- 0 === (_workInProgress.effectTag & 64) &&
+ 0 === (workInProgress$76.effectTag & 64) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update2 = createClassErrorUpdate(
- _workInProgress,
- thenable,
+ workInProgress$76.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$76.lanes |= thrownValue;
+ var update$80 = createClassErrorUpdate(
+ workInProgress$76,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update2);
+ enqueueCapturedUpdate(workInProgress$76, update$80);
break a;
}
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$76 = workInProgress$76.return;
+ } while (null !== workInProgress$76);
}
- workInProgress = completeUnitOfWork(workInProgress);
+ completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
thrownValue = yetAnotherThrownValue;
+ workInProgress === erroredWork &&
+ null !== erroredWork &&
+ (workInProgress = erroredWork = erroredWork.return);
continue;
}
break;
} while (1);
}
function pushDispatcher() {
- var prevDispatcher = ReactCurrentDispatcher$1.current;
- ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ var prevDispatcher = ReactCurrentDispatcher$2.current;
+ ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
-function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
- expirationTime < workInProgressRootLatestProcessedExpirationTime &&
- 2 < expirationTime &&
- (workInProgressRootLatestProcessedExpirationTime = expirationTime);
+function markRenderEventTimeAndConfig(eventTime, suspenseConfig) {
null !== suspenseConfig &&
- expirationTime < workInProgressRootLatestSuspenseTimeout &&
- 2 < expirationTime &&
- ((workInProgressRootLatestSuspenseTimeout = expirationTime),
- (workInProgressRootCanSuspendUsingConfig = suspenseConfig));
+ ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3),
+ eventTime > workInProgressRootLatestSuspenseTimeout &&
+ ((workInProgressRootLatestSuspenseTimeout = eventTime),
+ (workInProgressRootCanSuspendUsingConfig = suspenseConfig)));
}
-function markUnprocessedUpdateTime(expirationTime) {
- expirationTime > workInProgressRootNextUnprocessedUpdateTime &&
- (workInProgressRootNextUnprocessedUpdateTime = expirationTime);
-}
-function renderRootSync(root, expirationTime) {
+function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
+ executionContext |= 16;
var prevDispatcher = pushDispatcher();
- (root === workInProgressRoot && expirationTime === renderExpirationTime$1) ||
- prepareFreshStack(root, expirationTime);
+ (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) ||
+ prepareFreshStack(root, lanes);
do
try {
workLoopSync();
@@ -6244,142 +6614,144 @@ function renderRootSync(root, expirationTime) {
while (1);
resetContextDependencies();
executionContext = prevExecutionContext;
- ReactCurrentDispatcher$1.current = prevDispatcher;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
if (null !== workInProgress)
throw Error(
"Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
);
workInProgressRoot = null;
+ workInProgressRootRenderLanes = 0;
return workInProgressRootExitStatus;
}
function workLoopSync() {
- for (; null !== workInProgress; )
- workInProgress = performUnitOfWork(workInProgress);
+ for (; null !== workInProgress; ) performUnitOfWork(workInProgress);
}
function workLoopConcurrent() {
- for (; null !== workInProgress && !shouldYield(); )
- workInProgress = performUnitOfWork(workInProgress);
+ for (; null !== workInProgress && !Scheduler_shouldYield(); )
+ performUnitOfWork(workInProgress);
}
function performUnitOfWork(unitOfWork) {
- var next = beginWork$1(
- unitOfWork.alternate,
- unitOfWork,
- renderExpirationTime$1
- );
+ var next = beginWork$1(unitOfWork.alternate, unitOfWork, subtreeRenderLanes);
unitOfWork.memoizedProps = unitOfWork.pendingProps;
- null === next && (next = completeUnitOfWork(unitOfWork));
+ null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next);
ReactCurrentOwner$2.current = null;
- return next;
}
function completeUnitOfWork(unitOfWork) {
- workInProgress = unitOfWork;
+ var completedWork = unitOfWork;
do {
- var current = workInProgress.alternate;
- unitOfWork = workInProgress.return;
- if (0 === (workInProgress.effectTag & 2048)) {
- current = completeWork(current, workInProgress, renderExpirationTime$1);
+ var current = completedWork.alternate;
+ unitOfWork = completedWork.return;
+ if (0 === (completedWork.effectTag & 2048)) {
+ current = completeWork(current, completedWork, subtreeRenderLanes);
+ if (null !== current) {
+ workInProgress = current;
+ return;
+ }
+ current = completedWork;
if (
- 1 === renderExpirationTime$1 ||
- 1 !== workInProgress.childExpirationTime
+ (24 !== current.tag && 23 !== current.tag) ||
+ null === current.memoizedState ||
+ 0 !== (subtreeRenderLanes & 1073741824) ||
+ 0 === (current.mode & 4)
) {
- for (
- var newChildExpirationTime = 0, _child = workInProgress.child;
- null !== _child;
-
- ) {
- var _childUpdateExpirationTime = _child.expirationTime,
- _childChildExpirationTime = _child.childExpirationTime;
- _childUpdateExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = _childUpdateExpirationTime);
- _childChildExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = _childChildExpirationTime);
- _child = _child.sibling;
- }
- workInProgress.childExpirationTime = newChildExpirationTime;
+ for (var newChildLanes = 0, child = current.child; null !== child; )
+ (newChildLanes |= child.lanes | child.childLanes),
+ (child = child.sibling);
+ current.childLanes = newChildLanes;
}
- if (null !== current) return current;
null !== unitOfWork &&
0 === (unitOfWork.effectTag & 2048) &&
(null === unitOfWork.firstEffect &&
- (unitOfWork.firstEffect = workInProgress.firstEffect),
- null !== workInProgress.lastEffect &&
+ (unitOfWork.firstEffect = completedWork.firstEffect),
+ null !== completedWork.lastEffect &&
(null !== unitOfWork.lastEffect &&
- (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect),
- (unitOfWork.lastEffect = workInProgress.lastEffect)),
- 1 < workInProgress.effectTag &&
+ (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect),
+ (unitOfWork.lastEffect = completedWork.lastEffect)),
+ 1 < completedWork.effectTag &&
(null !== unitOfWork.lastEffect
- ? (unitOfWork.lastEffect.nextEffect = workInProgress)
- : (unitOfWork.firstEffect = workInProgress),
- (unitOfWork.lastEffect = workInProgress)));
+ ? (unitOfWork.lastEffect.nextEffect = completedWork)
+ : (unitOfWork.firstEffect = completedWork),
+ (unitOfWork.lastEffect = completedWork)));
} else {
- current = unwindWork(workInProgress);
- if (null !== current) return (current.effectTag &= 2047), current;
+ current = unwindWork(completedWork);
+ if (null !== current) {
+ current.effectTag &= 2047;
+ workInProgress = current;
+ return;
+ }
null !== unitOfWork &&
((unitOfWork.firstEffect = unitOfWork.lastEffect = null),
(unitOfWork.effectTag |= 2048));
}
- current = workInProgress.sibling;
- if (null !== current) return current;
- workInProgress = unitOfWork;
- } while (null !== workInProgress);
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootCompleted);
- return null;
-}
-function getRemainingExpirationTime(fiber) {
- var updateExpirationTime = fiber.expirationTime;
- fiber = fiber.childExpirationTime;
- return updateExpirationTime > fiber ? updateExpirationTime : fiber;
+ completedWork = completedWork.sibling;
+ if (null !== completedWork) {
+ workInProgress = completedWork;
+ return;
+ }
+ workInProgress = completedWork = unitOfWork;
+ } while (null !== completedWork);
+ 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
function commitRoot(root) {
var renderPriorityLevel = getCurrentPriorityLevel();
runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel));
return null;
}
-function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
+function commitRootImpl(root, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- var finishedWork = root$jscomp$0.finishedWork,
- expirationTime = root$jscomp$0.finishedExpirationTime;
+ var finishedWork = root.finishedWork;
if (null === finishedWork) return null;
- root$jscomp$0.finishedWork = null;
- root$jscomp$0.finishedExpirationTime = 0;
- if (finishedWork === root$jscomp$0.current)
+ root.finishedWork = null;
+ root.finishedLanes = 0;
+ if (finishedWork === root.current)
throw Error(
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
);
- root$jscomp$0.callbackNode = null;
- root$jscomp$0.callbackExpirationTime = 0;
- root$jscomp$0.callbackPriority = 90;
- root$jscomp$0.nextKnownPendingLevel = 0;
- var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(
- finishedWork
- );
- root$jscomp$0.firstPendingTime = remainingExpirationTimeBeforeCommit;
- expirationTime <= root$jscomp$0.lastSuspendedTime
- ? (root$jscomp$0.firstSuspendedTime = root$jscomp$0.lastSuspendedTime = root$jscomp$0.nextKnownPendingLevel = 0)
- : expirationTime <= root$jscomp$0.firstSuspendedTime &&
- (root$jscomp$0.firstSuspendedTime = expirationTime - 1);
- expirationTime <= root$jscomp$0.lastPingedTime &&
- (root$jscomp$0.lastPingedTime = 0);
- expirationTime <= root$jscomp$0.lastExpiredTime &&
- (root$jscomp$0.lastExpiredTime = 0);
- root$jscomp$0 === workInProgressRoot &&
+ root.callbackNode = null;
+ var remainingLanes = finishedWork.lanes | finishedWork.childLanes,
+ remainingLanes$jscomp$0 = remainingLanes,
+ noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0;
+ root.pendingLanes = remainingLanes$jscomp$0;
+ root.suspendedLanes = 0;
+ root.pingedLanes = 0;
+ root.expiredLanes &= remainingLanes$jscomp$0;
+ root.mutableReadLanes &= remainingLanes$jscomp$0;
+ root.entangledLanes &= remainingLanes$jscomp$0;
+ remainingLanes$jscomp$0 = root.entanglements;
+ for (
+ var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes;
+ 0 < noLongerPendingLanes;
+
+ ) {
+ var index$13 = 31 - clz32(noLongerPendingLanes),
+ lane = 1 << index$13;
+ remainingLanes$jscomp$0[index$13] = 0;
+ eventTimes[index$13] = -1;
+ expirationTimes[index$13] = -1;
+ noLongerPendingLanes &= ~lane;
+ }
+ null !== rootsWithPendingDiscreteUpdates &&
+ 0 === (remainingLanes & 24) &&
+ rootsWithPendingDiscreteUpdates.has(root) &&
+ rootsWithPendingDiscreteUpdates.delete(root);
+ root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
- (renderExpirationTime$1 = 0));
+ (workInProgressRootRenderLanes = 0));
1 < finishedWork.effectTag
? null !== finishedWork.lastEffect
? ((finishedWork.lastEffect.nextEffect = finishedWork),
- (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect))
- : (remainingExpirationTimeBeforeCommit = finishedWork)
- : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect);
- if (null !== remainingExpirationTimeBeforeCommit) {
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- ReactCurrentOwner$2.current = null;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ (remainingLanes = finishedWork.firstEffect))
+ : (remainingLanes = finishedWork)
+ : (remainingLanes = finishedWork.firstEffect);
+ if (null !== remainingLanes) {
+ remainingLanes$jscomp$0 = executionContext;
+ executionContext |= 32;
+ focusedInstanceHandle = ReactCurrentOwner$2.current = null;
+ shouldFireAfterActiveInstanceBlur = !1;
+ nextEffect = remainingLanes;
do
try {
commitBeforeMutationEffects();
@@ -6389,15 +6761,11 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
- nextEffect = remainingExpirationTimeBeforeCommit;
+ focusedInstanceHandle = null;
+ nextEffect = remainingLanes;
do
try {
- for (
- var root = root$jscomp$0,
- renderPriorityLevel = renderPriorityLevel$jscomp$0;
- null !== nextEffect;
-
- ) {
+ for (eventTimes = root; null !== nextEffect; ) {
var effectTag = nextEffect.effectTag;
if (effectTag & 128) {
var current = nextEffect.alternate;
@@ -6430,27 +6798,25 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
commitWork(nextEffect.alternate, nextEffect);
break;
case 8:
- var current$jscomp$0 = nextEffect;
- unmountHostComponents(
- root,
- current$jscomp$0,
- renderPriorityLevel
- );
- detachFiber(current$jscomp$0);
+ expirationTimes = nextEffect;
+ unmountHostComponents(eventTimes, expirationTimes);
+ var alternate = expirationTimes.alternate;
+ detachFiberMutation(expirationTimes);
+ null !== alternate && detachFiberMutation(alternate);
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$93) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$93);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
- root$jscomp$0.current = finishedWork;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ root.current = finishedWork;
+ nextEffect = remainingLanes;
do
try {
- for (effectTag = root$jscomp$0; null !== nextEffect; ) {
+ for (effectTag = root; null !== nextEffect; ) {
var effectTag$jscomp$0 = nextEffect.effectTag;
effectTag$jscomp$0 & 36 &&
commitLifeCycles(effectTag, nextEffect.alternate, nextEffect);
@@ -6473,54 +6839,68 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$94) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$94);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
nextEffect = null;
requestPaint();
- executionContext = prevExecutionContext;
- } else root$jscomp$0.current = finishedWork;
+ executionContext = remainingLanes$jscomp$0;
+ } else root.current = finishedWork;
if (rootDoesHavePassiveEffects)
(rootDoesHavePassiveEffects = !1),
- (rootWithPendingPassiveEffects = root$jscomp$0),
- (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$0);
+ (rootWithPendingPassiveEffects = root),
+ (pendingPassiveEffectsRenderPriority = renderPriorityLevel);
else
- for (
- nextEffect = remainingExpirationTimeBeforeCommit;
- null !== nextEffect;
-
- )
- (renderPriorityLevel$jscomp$0 = nextEffect.nextEffect),
+ for (nextEffect = remainingLanes; null !== nextEffect; )
+ (renderPriorityLevel = nextEffect.nextEffect),
(nextEffect.nextEffect = null),
- (nextEffect = renderPriorityLevel$jscomp$0);
- renderPriorityLevel$jscomp$0 = root$jscomp$0.firstPendingTime;
- 0 === renderPriorityLevel$jscomp$0 &&
- (legacyErrorBoundariesThatAlreadyFailed = null);
- 1073741823 === renderPriorityLevel$jscomp$0
- ? root$jscomp$0 === rootWithNestedUpdates
+ nextEffect.effectTag & 8 && (nextEffect.sibling = null),
+ (nextEffect = renderPriorityLevel);
+ remainingLanes = root.pendingLanes;
+ 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
+ 1 === remainingLanes
+ ? root === rootWithNestedUpdates
? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$0))
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
: (nestedUpdateCount = 0);
- "function" === typeof onCommitFiberRoot &&
- onCommitFiberRoot(finishedWork.stateNode, expirationTime);
- ensureRootIsScheduled(root$jscomp$0);
+ finishedWork = finishedWork.stateNode;
+ if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot)
+ try {
+ injectedHook.onCommitFiberRoot(
+ rendererID,
+ finishedWork,
+ void 0,
+ 64 === (finishedWork.current.effectTag & 64)
+ );
+ } catch (err) {}
+ ensureRootIsScheduled(root, now());
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
- (root$jscomp$0 = firstUncaughtError),
+ (root = firstUncaughtError),
(firstUncaughtError = null),
- root$jscomp$0);
- if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null;
+ root);
+ if (0 !== (executionContext & 8)) return null;
flushSyncCallbackQueue();
return null;
}
function commitBeforeMutationEffects() {
for (; null !== nextEffect; ) {
+ var current = nextEffect.alternate;
+ shouldFireAfterActiveInstanceBlur ||
+ null === focusedInstanceHandle ||
+ (0 !== (nextEffect.effectTag & 8)
+ ? doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0)
+ : 13 === nextEffect.tag &&
+ isSuspenseBoundaryBeingHidden(current, nextEffect) &&
+ doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0));
var effectTag = nextEffect.effectTag;
0 !== (effectTag & 256) &&
- commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect);
+ commitBeforeMutationLifeCycles(current, nextEffect);
0 === (effectTag & 512) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
@@ -6538,47 +6918,83 @@ function flushPassiveEffects() {
? 97
: pendingPassiveEffectsRenderPriority;
pendingPassiveEffectsRenderPriority = 90;
+ schedulerPriorityToLanePriority(priorityLevel);
return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
}
+ return !1;
+}
+function enqueuePendingPassiveHookEffectMount(fiber, effect) {
+ pendingPassiveHookEffectsMount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
+}
+function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
+ pendingPassiveHookEffectsUnmount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
}
function flushPassiveEffectsImpl() {
if (null === rootWithPendingPassiveEffects) return !1;
var root = rootWithPendingPassiveEffects;
rootWithPendingPassiveEffects = null;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- for (root = root.current.firstEffect; null !== root; ) {
+ executionContext |= 32;
+ var unmountEffects = pendingPassiveHookEffectsUnmount;
+ pendingPassiveHookEffectsUnmount = [];
+ for (var i = 0; i < unmountEffects.length; i += 2) {
+ var effect$99 = unmountEffects[i],
+ fiber = unmountEffects[i + 1],
+ destroy = effect$99.destroy;
+ effect$99.destroy = void 0;
+ if ("function" === typeof destroy)
+ try {
+ destroy();
+ } catch (error) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error);
+ }
+ }
+ unmountEffects = pendingPassiveHookEffectsMount;
+ pendingPassiveHookEffectsMount = [];
+ for (i = 0; i < unmountEffects.length; i += 2) {
+ effect$99 = unmountEffects[i];
+ fiber = unmountEffects[i + 1];
try {
- var finishedWork = root;
- if (0 !== (finishedWork.effectTag & 512))
- switch (finishedWork.tag) {
- case 0:
- case 11:
- case 15:
- case 22:
- commitHookEffectListUnmount(5, finishedWork),
- commitHookEffectListMount(5, finishedWork);
- }
- } catch (error) {
- if (null === root) throw Error("Should be working on an effect.");
- captureCommitPhaseError(root, error);
+ var create$103 = effect$99.create;
+ effect$99.destroy = create$103();
+ } catch (error$104) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error$104);
}
- finishedWork = root.nextEffect;
- root.nextEffect = null;
- root = finishedWork;
}
+ for (root = root.current.firstEffect; null !== root; )
+ (create$103 = root.nextEffect),
+ (root.nextEffect = null),
+ root.effectTag & 8 && (root.sibling = null),
+ (root = create$103);
executionContext = prevExecutionContext;
flushSyncCallbackQueue();
return !0;
}
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823);
+ sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1);
enqueueUpdate(rootFiber, sourceFiber);
- rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823);
- null !== rootFiber && ensureRootIsScheduled(rootFiber);
+ sourceFiber = requestEventTime();
+ rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1);
+ null !== rootFiber &&
+ (markRootUpdated(rootFiber, 1, sourceFiber),
+ ensureRootIsScheduled(rootFiber, sourceFiber));
}
function captureCommitPhaseError(sourceFiber, error) {
if (3 === sourceFiber.tag)
@@ -6597,143 +7013,156 @@ function captureCommitPhaseError(sourceFiber, error) {
!legacyErrorBoundariesThatAlreadyFailed.has(instance)))
) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823);
+ sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1);
enqueueUpdate(fiber, sourceFiber);
- fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823);
- null !== fiber && ensureRootIsScheduled(fiber);
+ sourceFiber = requestEventTime();
+ fiber = markUpdateLaneFromFiberToRoot(fiber, 1);
+ null !== fiber &&
+ (markRootUpdated(fiber, 1, sourceFiber),
+ ensureRootIsScheduled(fiber, sourceFiber));
break;
}
}
fiber = fiber.return;
}
}
-function pingSuspendedRoot(root, thenable, suspendedTime) {
+function pingSuspendedRoot(root, wakeable, pingedLanes) {
var pingCache = root.pingCache;
- null !== pingCache && pingCache.delete(thenable);
- workInProgressRoot === root && renderExpirationTime$1 === suspendedTime
- ? workInProgressRootExitStatus === RootSuspendedWithDelay ||
- (workInProgressRootExitStatus === RootSuspended &&
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
- ? prepareFreshStack(root, renderExpirationTime$1)
- : (workInProgressRootHasPendingPing = !0)
- : isRootSuspendedAtTime(root, suspendedTime) &&
- ((thenable = root.lastPingedTime),
- (0 !== thenable && thenable < suspendedTime) ||
- ((root.lastPingedTime = suspendedTime), ensureRootIsScheduled(root)));
-}
-function resolveRetryThenable(boundaryFiber, thenable) {
+ null !== pingCache && pingCache.delete(wakeable);
+ wakeable = requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & pingedLanes;
+ workInProgressRoot === root &&
+ (workInProgressRootRenderLanes & pingedLanes) === pingedLanes &&
+ (4 === workInProgressRootExitStatus ||
+ (3 === workInProgressRootExitStatus &&
+ (workInProgressRootRenderLanes & 62914560) ===
+ workInProgressRootRenderLanes &&
+ 500 > now() - globalMostRecentFallbackTime)
+ ? prepareFreshStack(root, 0)
+ : (workInProgressRootPingedLanes |= pingedLanes));
+ ensureRootIsScheduled(root, wakeable);
+}
+function resolveRetryWakeable(boundaryFiber, wakeable) {
var retryCache = boundaryFiber.stateNode;
- null !== retryCache && retryCache.delete(thenable);
- thenable = 0;
- 0 === thenable &&
- ((thenable = requestCurrentTimeForUpdate()),
- (thenable = computeExpirationForFiber(thenable, boundaryFiber, null)));
- boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable);
- null !== boundaryFiber && ensureRootIsScheduled(boundaryFiber);
+ null !== retryCache && retryCache.delete(wakeable);
+ wakeable = 0;
+ 0 === wakeable &&
+ ((wakeable = boundaryFiber.mode),
+ 0 === (wakeable & 2)
+ ? (wakeable = 1)
+ : 0 === (wakeable & 4)
+ ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2)
+ : (0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes),
+ (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)),
+ 0 === wakeable && (wakeable = 4194304)));
+ retryCache = requestEventTime();
+ boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable);
+ null !== boundaryFiber &&
+ (markRootUpdated(boundaryFiber, wakeable, retryCache),
+ ensureRootIsScheduled(boundaryFiber, retryCache));
}
var beginWork$1;
-beginWork$1 = function(current, workInProgress, renderExpirationTime) {
- var updateExpirationTime = workInProgress.expirationTime;
+beginWork$1 = function(current, workInProgress, renderLanes) {
+ var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
didPerformWorkStackCursor.current
)
didReceiveUpdate = !0;
+ else if (0 !== (renderLanes & updateLanes))
+ didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1;
else {
- if (updateExpirationTime < renderExpirationTime) {
- didReceiveUpdate = !1;
- switch (workInProgress.tag) {
- case 3:
- pushHostRootContext(workInProgress);
- break;
- case 5:
- pushHostContext(workInProgress);
- break;
- case 1:
- isContextProvider(workInProgress.type) &&
- pushContextProvider(workInProgress);
- break;
- case 4:
- pushHostContainer(
+ didReceiveUpdate = !1;
+ switch (workInProgress.tag) {
+ case 3:
+ pushHostRootContext(workInProgress);
+ break;
+ case 5:
+ pushHostContext(workInProgress);
+ break;
+ case 1:
+ isContextProvider(workInProgress.type) &&
+ pushContextProvider(workInProgress);
+ break;
+ case 4:
+ pushHostContainer(
+ workInProgress,
+ workInProgress.stateNode.containerInfo
+ );
+ break;
+ case 10:
+ updateLanes = workInProgress.memoizedProps.value;
+ var context = workInProgress.type._context;
+ push(valueCursor, context._currentValue);
+ context._currentValue = updateLanes;
+ break;
+ case 13:
+ if (null !== workInProgress.memoizedState) {
+ if (0 !== (renderLanes & workInProgress.child.childLanes))
+ return updateSuspenseComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ workInProgress = bailoutOnAlreadyFinishedWork(
+ current,
workInProgress,
- workInProgress.stateNode.containerInfo
+ renderLanes
);
- break;
- case 10:
- updateExpirationTime = workInProgress.memoizedProps.value;
- var context = workInProgress.type._context;
- push(valueCursor, context._currentValue);
- context._currentValue = updateExpirationTime;
- break;
- case 13:
- if (null !== workInProgress.memoizedState) {
- updateExpirationTime = workInProgress.child.childExpirationTime;
- if (
- 0 !== updateExpirationTime &&
- updateExpirationTime >= renderExpirationTime
- )
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- workInProgress = bailoutOnAlreadyFinishedWork(
+ return null !== workInProgress ? workInProgress.sibling : null;
+ }
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
+ case 19:
+ updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.effectTag & 64)) {
+ if (updateLanes)
+ return updateSuspenseListComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateExpirationTime =
- workInProgress.childExpirationTime >= renderExpirationTime;
- if (0 !== (current.effectTag & 64)) {
- if (updateExpirationTime)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- workInProgress.effectTag |= 64;
- }
- context = workInProgress.memoizedState;
- null !== context &&
- ((context.rendering = null), (context.tail = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (!updateExpirationTime) return null;
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ workInProgress.effectTag |= 64;
+ }
+ context = workInProgress.memoizedState;
+ null !== context &&
+ ((context.rendering = null),
+ (context.tail = null),
+ (context.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (updateLanes) break;
+ else return null;
+ case 23:
+ case 24:
+ return (
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
+ );
}
- didReceiveUpdate = !1;
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
else didReceiveUpdate = !1;
- workInProgress.expirationTime = 0;
+ workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateExpirationTime = workInProgress.type;
+ updateLanes = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
context = getMaskedContext(workInProgress, contextStackCursor.current);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
context = renderWithHooks(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
current,
context,
- renderExpirationTime
+ renderLanes
);
workInProgress.effectTag |= 1;
if (
@@ -6745,7 +7174,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateExpirationTime)) {
+ if (isContextProvider(updateLanes)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
@@ -6754,53 +7183,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
? context.state
: null;
initializeUpdateQueue(workInProgress);
- var getDerivedStateFromProps =
- updateExpirationTime.getDerivedStateFromProps;
+ var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps;
"function" === typeof getDerivedStateFromProps &&
applyDerivedStateFromProps(
workInProgress,
- updateExpirationTime,
+ updateLanes,
getDerivedStateFromProps,
current
);
context.updater = classComponentUpdater;
workInProgress.stateNode = context;
- context._reactInternalFiber = workInProgress;
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- current,
- renderExpirationTime
- );
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, updateLanes, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
hasContext,
- renderExpirationTime
+ renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(
- null,
- workInProgress,
- context,
- renderExpirationTime
- ),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
+ context = workInProgress.elementType;
a: {
- context = workInProgress.elementType;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
- initializeLazyComponentType(context);
- if (1 !== context._status) throw context._result;
- context = context._result;
+ hasContext = context._init;
+ context = hasContext(context._payload);
workInProgress.type = context;
hasContext = workInProgress.tag = resolveLazyComponentTag(context);
current = resolveDefaultProps(context, current);
@@ -6811,7 +7228,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 1:
@@ -6820,7 +7237,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 11:
@@ -6829,7 +7246,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 14:
@@ -6838,8 +7255,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
resolveDefaultProps(context.type, current),
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
break a;
}
@@ -6852,126 +7269,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return workInProgress;
case 0:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateFunctionComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 1:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateClassComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- updateExpirationTime = workInProgress.updateQueue;
- if (null === current || null === updateExpirationTime)
+ updateLanes = workInProgress.updateQueue;
+ if (null === current || null === updateLanes)
throw Error(
"If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."
);
- updateExpirationTime = workInProgress.pendingProps;
+ updateLanes = workInProgress.pendingProps;
context = workInProgress.memoizedState;
context = null !== context ? context.element : null;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(
- workInProgress,
- updateExpirationTime,
- null,
- renderExpirationTime
- );
- updateExpirationTime = workInProgress.memoizedState.element;
- updateExpirationTime === context
+ processUpdateQueue(workInProgress, updateLanes, null, renderLanes);
+ updateLanes = workInProgress.memoizedState.element;
+ updateLanes === context
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
))
- : (reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ : (reconcileChildren(current, workInProgress, updateLanes, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateExpirationTime = workInProgress.pendingProps.children),
+ (updateLanes = workInProgress.pendingProps.children),
markRef(current, workInProgress),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
- (workInProgress = workInProgress.child),
- workInProgress
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ workInProgress.child
);
case 6:
return null;
case 13:
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
case 4:
return (
pushHostContainer(
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateExpirationTime = workInProgress.pendingProps),
+ (updateLanes = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
))
: reconcileChildren(
current,
workInProgress,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
),
workInProgress.child
);
case 11:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateForwardRef(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 7:
@@ -6980,7 +7377,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
@@ -6990,7 +7387,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
@@ -7000,13 +7397,13 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
case 10:
a: {
- updateExpirationTime = workInProgress.type._context;
+ updateLanes = workInProgress.type._context;
context = workInProgress.pendingProps;
getDerivedStateFromProps = workInProgress.memoizedProps;
hasContext = context.value;
@@ -7018,9 +7415,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
((context$jscomp$0 = getDerivedStateFromProps.value),
(hasContext = objectIs(context$jscomp$0, hasContext)
? 0
- : ("function" ===
- typeof updateExpirationTime._calculateChangedBits
- ? updateExpirationTime._calculateChangedBits(
+ : ("function" === typeof updateLanes._calculateChangedBits
+ ? updateLanes._calculateChangedBits(
context$jscomp$0,
hasContext
)
@@ -7034,7 +7430,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
break a;
}
@@ -7055,25 +7451,25 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
) {
if (
- dependency.context === updateExpirationTime &&
+ dependency.context === updateLanes &&
0 !== (dependency.observedBits & hasContext)
) {
1 === context$jscomp$0.tag &&
- ((dependency = createUpdate(renderExpirationTime, null)),
+ ((dependency = createUpdate(
+ -1,
+ renderLanes & -renderLanes,
+ null
+ )),
(dependency.tag = 2),
enqueueUpdate(context$jscomp$0, dependency));
- context$jscomp$0.expirationTime < renderExpirationTime &&
- (context$jscomp$0.expirationTime = renderExpirationTime);
+ context$jscomp$0.lanes |= renderLanes;
dependency = context$jscomp$0.alternate;
- null !== dependency &&
- dependency.expirationTime < renderExpirationTime &&
- (dependency.expirationTime = renderExpirationTime);
+ null !== dependency && (dependency.lanes |= renderLanes);
scheduleWorkOnParentPath(
context$jscomp$0.return,
- renderExpirationTime
+ renderLanes
);
- list.expirationTime < renderExpirationTime &&
- (list.expirationTime = renderExpirationTime);
+ list.lanes |= renderLanes;
break;
}
dependency = dependency.next;
@@ -7111,7 +7507,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
context.children,
- renderExpirationTime
+ renderLanes
);
workInProgress = workInProgress.child;
}
@@ -7120,17 +7516,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return (
(context = workInProgress.type),
(hasContext = workInProgress.pendingProps),
- (updateExpirationTime = hasContext.children),
- prepareToReadContext(workInProgress, renderExpirationTime),
+ (updateLanes = hasContext.children),
+ prepareToReadContext(workInProgress, renderLanes),
(context = readContext(context, hasContext.unstable_observedBits)),
- (updateExpirationTime = updateExpirationTime(context)),
+ (updateLanes = updateLanes(context)),
(workInProgress.effectTag |= 1),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
workInProgress.child
);
case 14:
@@ -7146,8 +7537,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
hasContext,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
case 15:
@@ -7156,48 +7547,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
case 17:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateExpirationTime)
+ isContextProvider(updateLanes)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
- prepareToReadContext(workInProgress, renderExpirationTime),
- constructClassInstance(workInProgress, updateExpirationTime, context),
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- context,
- renderExpirationTime
- ),
+ prepareToReadContext(workInProgress, renderLanes),
+ constructClassInstance(workInProgress, updateLanes, context),
+ mountClassInstance(workInProgress, updateLanes, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
current,
- renderExpirationTime
+ renderLanes
)
);
case 19:
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
+ case 23:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ case 24:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -7205,32 +7591,6 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
"). This error is likely caused by a bug in React. Please file an issue."
);
};
-var onCommitFiberRoot = null,
- onCommitFiberUnmount = null;
-function injectInternals(internals) {
- if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1;
- var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
- if (hook.isDisabled || !hook.supportsFiber) return !0;
- try {
- var rendererID = hook.inject(internals);
- onCommitFiberRoot = function(root) {
- try {
- hook.onCommitFiberRoot(
- rendererID,
- root,
- void 0,
- 64 === (root.current.effectTag & 64)
- );
- } catch (err) {}
- };
- onCommitFiberUnmount = function(fiber) {
- try {
- hook.onCommitFiberUnmount(rendererID, fiber);
- } catch (err) {}
- };
- } catch (err) {}
- return !0;
-}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -7242,9 +7602,12 @@ function FiberNode(tag, pendingProps, key, mode) {
this.mode = mode;
this.effectTag = 0;
this.lastEffect = this.firstEffect = this.nextEffect = null;
- this.childExpirationTime = this.expirationTime = 0;
+ this.childLanes = this.lanes = 0;
this.alternate = null;
}
+function createFiber(tag, pendingProps, key, mode) {
+ return new FiberNode(tag, pendingProps, key, mode);
+}
function shouldConstruct(Component) {
Component = Component.prototype;
return !(!Component || !Component.isReactComponent);
@@ -7262,7 +7625,7 @@ function resolveLazyComponentTag(Component) {
function createWorkInProgress(current, pendingProps) {
var workInProgress = current.alternate;
null === workInProgress
- ? ((workInProgress = new FiberNode(
+ ? ((workInProgress = createFiber(
current.tag,
pendingProps,
current.key,
@@ -7274,16 +7637,13 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.alternate = current),
(current.alternate = workInProgress))
: ((workInProgress.pendingProps = pendingProps),
+ (workInProgress.type = current.type),
(workInProgress.effectTag = 0),
(workInProgress.nextEffect = null),
(workInProgress.firstEffect = null),
(workInProgress.lastEffect = null));
- if (null == current)
- throw Error("current is " + current + " but it can't be");
- if (null == workInProgress)
- throw Error("workInProgress is " + workInProgress + " but it can't be");
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
@@ -7293,7 +7653,7 @@ function createWorkInProgress(current, pendingProps) {
null === pendingProps
? null
: {
- expirationTime: pendingProps.expirationTime,
+ lanes: pendingProps.lanes,
firstContext: pendingProps.firstContext,
responders: pendingProps.responders
};
@@ -7308,7 +7668,7 @@ function createFiberFromTypeAndProps(
pendingProps,
owner,
mode,
- expirationTime
+ lanes
) {
var fiberTag = 2;
owner = type;
@@ -7317,15 +7677,10 @@ function createFiberFromTypeAndProps(
else
a: switch (type) {
case REACT_FRAGMENT_TYPE:
- return createFiberFromFragment(
- pendingProps.children,
- mode,
- expirationTime,
- key
- );
- case REACT_CONCURRENT_MODE_TYPE:
+ return createFiberFromFragment(pendingProps.children, mode, lanes, key);
+ case REACT_DEBUG_TRACING_MODE_TYPE:
fiberTag = 8;
- mode |= 7;
+ mode |= 16;
break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
@@ -7333,25 +7688,34 @@ function createFiberFromTypeAndProps(
break;
case REACT_PROFILER_TYPE:
return (
- (type = new FiberNode(12, pendingProps, key, mode | 8)),
+ (type = createFiber(12, pendingProps, key, mode | 8)),
(type.elementType = REACT_PROFILER_TYPE),
(type.type = REACT_PROFILER_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
type
);
case REACT_SUSPENSE_TYPE:
return (
- (type = new FiberNode(13, pendingProps, key, mode)),
+ (type = createFiber(13, pendingProps, key, mode)),
(type.type = REACT_SUSPENSE_TYPE),
(type.elementType = REACT_SUSPENSE_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
type
);
case REACT_SUSPENSE_LIST_TYPE:
return (
- (type = new FiberNode(19, pendingProps, key, mode)),
+ (type = createFiber(19, pendingProps, key, mode)),
(type.elementType = REACT_SUSPENSE_LIST_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
+ type
+ );
+ case REACT_OFFSCREEN_TYPE:
+ return createFiberFromOffscreen(pendingProps, mode, lanes, key);
+ case REACT_LEGACY_HIDDEN_TYPE:
+ return (
+ (type = createFiber(24, pendingProps, key, mode)),
+ (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
+ (type.lanes = lanes),
type
);
default:
@@ -7383,30 +7747,36 @@ function createFiberFromTypeAndProps(
"."
);
}
- key = new FiberNode(fiberTag, pendingProps, key, mode);
+ key = createFiber(fiberTag, pendingProps, key, mode);
key.elementType = type;
key.type = owner;
- key.expirationTime = expirationTime;
+ key.lanes = lanes;
return key;
}
-function createFiberFromFragment(elements, mode, expirationTime, key) {
- elements = new FiberNode(7, elements, key, mode);
- elements.expirationTime = expirationTime;
+function createFiberFromFragment(elements, mode, lanes, key) {
+ elements = createFiber(7, elements, key, mode);
+ elements.lanes = lanes;
return elements;
}
-function createFiberFromText(content, mode, expirationTime) {
- content = new FiberNode(6, content, null, mode);
- content.expirationTime = expirationTime;
+function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
+ pendingProps = createFiber(23, pendingProps, key, mode);
+ pendingProps.elementType = REACT_OFFSCREEN_TYPE;
+ pendingProps.lanes = lanes;
+ return pendingProps;
+}
+function createFiberFromText(content, mode, lanes) {
+ content = createFiber(6, content, null, mode);
+ content.lanes = lanes;
return content;
}
-function createFiberFromPortal(portal, mode, expirationTime) {
- mode = new FiberNode(
+function createFiberFromPortal(portal, mode, lanes) {
+ mode = createFiber(
4,
null !== portal.children ? portal.children : [],
portal.key,
mode
);
- mode.expirationTime = expirationTime;
+ mode.lanes = lanes;
mode.stateNode = {
containerInfo: portal.containerInfo,
pendingChildren: null,
@@ -7416,51 +7786,31 @@ function createFiberFromPortal(portal, mode, expirationTime) {
}
function FiberRootNode(containerInfo, tag, hydrate) {
this.tag = tag;
- this.current = null;
this.containerInfo = containerInfo;
- this.pingCache = this.pendingChildren = null;
- this.finishedExpirationTime = 0;
- this.finishedWork = null;
+ this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
this.pendingContext = this.context = null;
this.hydrate = hydrate;
this.callbackNode = null;
- this.callbackPriority = 90;
- this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0;
-}
-function isRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- root = root.lastSuspendedTime;
- return (
- 0 !== firstSuspendedTime &&
- firstSuspendedTime >= expirationTime &&
- root <= expirationTime
- );
+ this.callbackPriority = 0;
+ this.eventTimes = Array(31).fill(0);
+ this.expirationTimes = Array(31).fill(-1);
+ this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
+ this.entanglements = Array(31).fill(0);
}
-function markRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime,
- lastSuspendedTime = root.lastSuspendedTime;
- firstSuspendedTime < expirationTime &&
- (root.firstSuspendedTime = expirationTime);
- if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime)
- root.lastSuspendedTime = expirationTime;
- expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0);
- expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0);
-}
-function markRootUpdatedAtTime(root, expirationTime) {
- expirationTime > root.firstPendingTime &&
- (root.firstPendingTime = expirationTime);
- var firstSuspendedTime = root.firstSuspendedTime;
- 0 !== firstSuspendedTime &&
- (expirationTime >= firstSuspendedTime
- ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0)
- : expirationTime >= root.lastSuspendedTime &&
- (root.lastSuspendedTime = expirationTime + 1),
- expirationTime > root.nextKnownPendingLevel &&
- (root.nextKnownPendingLevel = expirationTime));
+function createPortal(children, containerInfo, implementation) {
+ var key =
+ 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
+ return {
+ $$typeof: REACT_PORTAL_TYPE,
+ key: null == key ? null : "" + key,
+ children: children,
+ containerInfo: containerInfo,
+ implementation: implementation
+ };
}
function findHostInstance(component) {
- var fiber = component._reactInternalFiber;
+ var fiber = component._reactInternals;
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
@@ -7474,11 +7824,11 @@ function findHostInstance(component) {
}
function updateContainer(element, container, parentComponent, callback) {
var current = container.current,
- currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig);
+ eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(current, suspenseConfig);
a: if (parentComponent) {
- parentComponent = parentComponent._reactInternalFiber;
+ parentComponent = parentComponent._reactInternals;
b: {
if (
getNearestMountedFiber(parentComponent) !== parentComponent ||
@@ -7487,22 +7837,23 @@ function updateContainer(element, container, parentComponent, callback) {
throw Error(
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
);
- var parentContext = parentComponent;
+ var JSCompiler_inline_result = parentComponent;
do {
- switch (parentContext.tag) {
+ switch (JSCompiler_inline_result.tag) {
case 3:
- parentContext = parentContext.stateNode.context;
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode.context;
break b;
case 1:
- if (isContextProvider(parentContext.type)) {
- parentContext =
- parentContext.stateNode
+ if (isContextProvider(JSCompiler_inline_result.type)) {
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode
.__reactInternalMemoizedMergedChildContext;
break b;
}
}
- parentContext = parentContext.return;
- } while (null !== parentContext);
+ JSCompiler_inline_result = JSCompiler_inline_result.return;
+ } while (null !== JSCompiler_inline_result);
throw Error(
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
);
@@ -7513,34 +7864,26 @@ function updateContainer(element, container, parentComponent, callback) {
parentComponent = processChildContext(
parentComponent,
Component,
- parentContext
+ JSCompiler_inline_result
);
break a;
}
}
- parentComponent = parentContext;
+ parentComponent = JSCompiler_inline_result;
} else parentComponent = emptyContextObject;
null === container.context
? (container.context = parentComponent)
: (container.pendingContext = parentComponent);
- container = createUpdate(currentTime, suspenseConfig);
+ container = createUpdate(eventTime, lane, suspenseConfig);
container.payload = { element: element };
callback = void 0 === callback ? null : callback;
null !== callback && (container.callback = callback);
enqueueUpdate(current, container);
- scheduleWork(current, currentTime);
- return currentTime;
+ scheduleUpdateOnFiber(current, lane, eventTime);
+ return lane;
}
-function createPortal(children, containerInfo, implementation) {
- var key =
- 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
- return {
- $$typeof: REACT_PORTAL_TYPE,
- key: null == key ? null : "" + key,
- children: children,
- containerInfo: containerInfo,
- implementation: implementation
- };
+function emptyFindFiberByHostInstance() {
+ return null;
}
function findNodeHandle(componentOrHandle) {
if (null == componentOrHandle) return null;
@@ -7569,53 +7912,64 @@ batchedUpdatesImpl = function(fn, a) {
return fn(a);
} finally {
(executionContext = prevExecutionContext),
- executionContext === NoContext && flushSyncCallbackQueue();
+ 0 === executionContext && flushSyncCallbackQueue();
}
};
-var roots = new Map();
-(function(devToolsConfig) {
- var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
- return injectInternals({
- bundleType: devToolsConfig.bundleType,
- version: devToolsConfig.version,
- rendererPackageName: devToolsConfig.rendererPackageName,
- rendererConfig: devToolsConfig.rendererConfig,
- overrideHookState: null,
- overrideProps: null,
- setSuspenseHandler: null,
- scheduleUpdate: null,
- currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
- findHostInstanceByFiber: function(fiber) {
- fiber = findCurrentHostFiber(fiber);
- return null === fiber ? null : fiber.stateNode;
- },
- findFiberByHostInstance: function(instance) {
- return findFiberByHostInstance ? findFiberByHostInstance(instance) : null;
- },
- findHostInstancesForRefresh: null,
- scheduleRefresh: null,
- scheduleRoot: null,
- setRefreshHandler: null,
- getCurrentFiber: null
- });
-})({
- findFiberByHostInstance: getInstanceFromTag,
- bundleType: 0,
- version: "16.13.0",
- rendererPackageName: "react-native-renderer",
- rendererConfig: {
- getInspectorDataForViewTag: function() {
- throw Error(
- "getInspectorDataForViewTag() is not available in production"
- );
- },
- getInspectorDataForViewAtPoint: function() {
- throw Error(
- "getInspectorDataForViewAtPoint() is not available in production."
- );
- }.bind(null, findNodeHandle)
- }
-});
+var roots = new Map(),
+ devToolsConfig$jscomp$inline_934 = {
+ findFiberByHostInstance: getInstanceFromTag,
+ bundleType: 0,
+ version: "17.0.0-alpha.0",
+ rendererPackageName: "react-native-renderer",
+ rendererConfig: {
+ getInspectorDataForViewTag: function() {
+ throw Error(
+ "getInspectorDataForViewTag() is not available in production"
+ );
+ },
+ getInspectorDataForViewAtPoint: function() {
+ throw Error(
+ "getInspectorDataForViewAtPoint() is not available in production."
+ );
+ }.bind(null, findNodeHandle)
+ }
+ };
+var internals$jscomp$inline_1135 = {
+ bundleType: devToolsConfig$jscomp$inline_934.bundleType,
+ version: devToolsConfig$jscomp$inline_934.version,
+ rendererPackageName: devToolsConfig$jscomp$inline_934.rendererPackageName,
+ rendererConfig: devToolsConfig$jscomp$inline_934.rendererConfig,
+ overrideHookState: null,
+ overrideProps: null,
+ setSuspenseHandler: null,
+ scheduleUpdate: null,
+ currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
+ findHostInstanceByFiber: function(fiber) {
+ fiber = findCurrentHostFiber(fiber);
+ return null === fiber ? null : fiber.stateNode;
+ },
+ findFiberByHostInstance:
+ devToolsConfig$jscomp$inline_934.findFiberByHostInstance ||
+ emptyFindFiberByHostInstance,
+ findHostInstancesForRefresh: null,
+ scheduleRefresh: null,
+ scheduleRoot: null,
+ setRefreshHandler: null,
+ getCurrentFiber: null
+};
+if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
+ var hook$jscomp$inline_1136 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ if (
+ !hook$jscomp$inline_1136.isDisabled &&
+ hook$jscomp$inline_1136.supportsFiber
+ )
+ try {
+ (rendererID = hook$jscomp$inline_1136.inject(
+ internals$jscomp$inline_1135
+ )),
+ (injectedHook = hook$jscomp$inline_1136);
+ } catch (err) {}
+}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
computeComponentStackForErrorReporting: function(reactTag) {
return (reactTag = getInstanceFromTag(reactTag))
@@ -7662,7 +8016,7 @@ exports.render = function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
root = new FiberRootNode(containerTag, 0, !1);
- var uninitializedFiber = new FiberNode(3, null, null, 0);
+ var uninitializedFiber = createFiber(3, null, null, 0);
root.current = uninitializedFiber;
uninitializedFiber.stateNode = root;
initializeUpdateQueue(uninitializedFiber);
diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js
index 2bac9e25f6cf5d..fc338954b12374 100644
--- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js
+++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js
@@ -16,16 +16,6 @@ var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/R
React = require("react"),
Scheduler = require("scheduler"),
tracing = require("scheduler/tracing");
-function getParent(inst) {
- do inst = inst.return;
- while (inst && 5 !== inst.tag);
- return inst ? inst : null;
-}
-function traverseTwoPhase(inst, fn, arg) {
- for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
- for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
- for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
-}
function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) {
var funcArgs = Array.prototype.slice.call(arguments, 3);
try {
@@ -96,109 +86,6 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
-function getListener(inst, registrationName) {
- var listener = inst.stateNode;
- if (!listener) return null;
- var props = getFiberCurrentPropsFromNode(listener);
- if (!props) return null;
- listener = props[registrationName];
- a: switch (registrationName) {
- case "onClick":
- case "onClickCapture":
- case "onDoubleClick":
- case "onDoubleClickCapture":
- case "onMouseDown":
- case "onMouseDownCapture":
- case "onMouseMove":
- case "onMouseMoveCapture":
- case "onMouseUp":
- case "onMouseUpCapture":
- case "onMouseEnter":
- (props = !props.disabled) ||
- ((inst = inst.type),
- (props = !(
- "button" === inst ||
- "input" === inst ||
- "select" === inst ||
- "textarea" === inst
- )));
- inst = !props;
- break a;
- default:
- inst = !1;
- }
- if (inst) return null;
- if (listener && "function" !== typeof listener)
- throw Error(
- "Expected `" +
- registrationName +
- "` listener to be a function, instead got a value of `" +
- typeof listener +
- "` type."
- );
- return listener;
-}
-function accumulateInto(current, next) {
- if (null == next)
- throw Error(
- "accumulateInto(...): Accumulated items must not be null or undefined."
- );
- if (null == current) return next;
- if (Array.isArray(current)) {
- if (Array.isArray(next)) return current.push.apply(current, next), current;
- current.push(next);
- return current;
- }
- return Array.isArray(next) ? [current].concat(next) : [current, next];
-}
-function forEachAccumulated(arr, cb, scope) {
- Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
-}
-function accumulateDirectionalDispatches(inst, phase, event) {
- if (
- (phase = getListener(
- inst,
- event.dispatchConfig.phasedRegistrationNames[phase]
- ))
- )
- (event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- phase
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- ));
-}
-function accumulateTwoPhaseDispatchesSingle(event) {
- event &&
- event.dispatchConfig.phasedRegistrationNames &&
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
-}
-function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
- if (event && event.dispatchConfig.phasedRegistrationNames) {
- var targetInst = event._targetInst;
- targetInst = targetInst ? getParent(targetInst) : null;
- traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
- }
-}
-function accumulateDirectDispatchesSingle(event) {
- if (event && event.dispatchConfig.registrationName) {
- var inst = event._targetInst;
- if (inst && event && event.dispatchConfig.registrationName) {
- var listener = getListener(inst, event.dispatchConfig.registrationName);
- listener &&
- ((event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- )),
- (event._dispatchInstances = accumulateInto(
- event._dispatchInstances,
- inst
- )));
- }
- }
-}
function functionThatReturnsTrue() {
return !0;
}
@@ -214,6 +101,7 @@ function SyntheticEvent(
this.dispatchConfig = dispatchConfig;
this._targetInst = targetInst;
this.nativeEvent = nativeEvent;
+ this._dispatchInstances = this._dispatchListeners = null;
dispatchConfig = this.constructor.Interface;
for (var propName in dispatchConfig)
dispatchConfig.hasOwnProperty(propName) &&
@@ -293,7 +181,12 @@ SyntheticEvent.extend = function(Interface) {
return Class;
};
addEventPoolingTo(SyntheticEvent);
-function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
+function createOrGetPooledEvent(
+ dispatchConfig,
+ targetInst,
+ nativeEvent,
+ nativeInst
+) {
if (this.eventPool.length) {
var instance = this.eventPool.pop();
this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
@@ -310,8 +203,8 @@ function releasePooledEvent(event) {
10 > this.eventPool.length && this.eventPool.push(event);
}
function addEventPoolingTo(EventConstructor) {
+ EventConstructor.getPooled = createOrGetPooledEvent;
EventConstructor.eventPool = [];
- EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}
var ResponderSyntheticEvent = SyntheticEvent.extend({
@@ -439,6 +332,22 @@ function accumulate(current, next) {
? [current].concat(next)
: [current, next];
}
+function accumulateInto(current, next) {
+ if (null == next)
+ throw Error(
+ "accumulateInto(...): Accumulated items must not be null or undefined."
+ );
+ if (null == current) return next;
+ if (Array.isArray(current)) {
+ if (Array.isArray(next)) return current.push.apply(current, next), current;
+ current.push(next);
+ return current;
+ }
+ return Array.isArray(next) ? [current].concat(next) : [current, next];
+}
+function forEachAccumulated(arr, cb, scope) {
+ Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr);
+}
var responderInst = null,
trackedTouchCount = 0;
function changeResponder(nextResponderInst, blockHostResponder) {
@@ -452,65 +361,132 @@ function changeResponder(nextResponderInst, blockHostResponder) {
);
}
var eventTypes = {
- startShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onStartShouldSetResponder",
- captured: "onStartShouldSetResponderCapture"
- },
- dependencies: startDependencies
- },
- scrollShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onScrollShouldSetResponder",
- captured: "onScrollShouldSetResponderCapture"
- },
- dependencies: ["topScroll"]
- },
- selectionChangeShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onSelectionChangeShouldSetResponder",
- captured: "onSelectionChangeShouldSetResponderCapture"
- },
- dependencies: ["topSelectionChange"]
- },
- moveShouldSetResponder: {
- phasedRegistrationNames: {
- bubbled: "onMoveShouldSetResponder",
- captured: "onMoveShouldSetResponderCapture"
- },
- dependencies: moveDependencies
- },
- responderStart: {
- registrationName: "onResponderStart",
- dependencies: startDependencies
- },
- responderMove: {
- registrationName: "onResponderMove",
- dependencies: moveDependencies
+ startShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onStartShouldSetResponder",
+ captured: "onStartShouldSetResponderCapture"
},
- responderEnd: {
- registrationName: "onResponderEnd",
- dependencies: endDependencies
- },
- responderRelease: {
- registrationName: "onResponderRelease",
- dependencies: endDependencies
+ dependencies: startDependencies
+ },
+ scrollShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onScrollShouldSetResponder",
+ captured: "onScrollShouldSetResponderCapture"
},
- responderTerminationRequest: {
- registrationName: "onResponderTerminationRequest",
- dependencies: []
+ dependencies: ["topScroll"]
+ },
+ selectionChangeShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onSelectionChangeShouldSetResponder",
+ captured: "onSelectionChangeShouldSetResponderCapture"
},
- responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
- responderReject: {
- registrationName: "onResponderReject",
- dependencies: []
+ dependencies: ["topSelectionChange"]
+ },
+ moveShouldSetResponder: {
+ phasedRegistrationNames: {
+ bubbled: "onMoveShouldSetResponder",
+ captured: "onMoveShouldSetResponderCapture"
},
- responderTerminate: {
- registrationName: "onResponderTerminate",
- dependencies: []
- }
+ dependencies: moveDependencies
+ },
+ responderStart: {
+ registrationName: "onResponderStart",
+ dependencies: startDependencies
+ },
+ responderMove: {
+ registrationName: "onResponderMove",
+ dependencies: moveDependencies
+ },
+ responderEnd: {
+ registrationName: "onResponderEnd",
+ dependencies: endDependencies
},
- ResponderEventPlugin = {
+ responderRelease: {
+ registrationName: "onResponderRelease",
+ dependencies: endDependencies
+ },
+ responderTerminationRequest: {
+ registrationName: "onResponderTerminationRequest",
+ dependencies: []
+ },
+ responderGrant: { registrationName: "onResponderGrant", dependencies: [] },
+ responderReject: { registrationName: "onResponderReject", dependencies: [] },
+ responderTerminate: {
+ registrationName: "onResponderTerminate",
+ dependencies: []
+ }
+};
+function getParent(inst) {
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ return inst ? inst : null;
+}
+function traverseTwoPhase(inst, fn, arg) {
+ for (var path = []; inst; ) path.push(inst), (inst = getParent(inst));
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
+}
+function getListener(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+function accumulateDirectionalDispatches(inst, phase, event) {
+ if (
+ (phase = getListener(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateDirectDispatchesSingle(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
+function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ var targetInst = event._targetInst;
+ targetInst = targetInst ? getParent(targetInst) : null;
+ traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event);
+ }
+}
+function accumulateTwoPhaseDispatchesSingle(event) {
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
+}
+var ResponderEventPlugin = {
_getResponder: function() {
return responderInst;
},
@@ -571,68 +547,70 @@ var eventTypes = {
JSCompiler_temp = null;
}
else JSCompiler_temp = targetInst;
- targetInst = JSCompiler_temp === responderInst;
- JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ targetInst = JSCompiler_temp;
+ JSCompiler_temp = targetInst === responderInst;
+ shouldSetEventType = ResponderSyntheticEvent.getPooled(
shouldSetEventType,
- JSCompiler_temp,
+ targetInst,
nativeEvent,
nativeEventTarget
);
- JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory;
- targetInst
+ shouldSetEventType.touchHistory =
+ ResponderTouchHistoryStore.touchHistory;
+ JSCompiler_temp
? forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingleSkipTarget
)
: forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateTwoPhaseDispatchesSingle
);
b: {
- shouldSetEventType = JSCompiler_temp._dispatchListeners;
- targetInst = JSCompiler_temp._dispatchInstances;
- if (Array.isArray(shouldSetEventType))
+ JSCompiler_temp = shouldSetEventType._dispatchListeners;
+ targetInst = shouldSetEventType._dispatchInstances;
+ if (Array.isArray(JSCompiler_temp))
for (
depthA = 0;
- depthA < shouldSetEventType.length &&
- !JSCompiler_temp.isPropagationStopped();
+ depthA < JSCompiler_temp.length &&
+ !shouldSetEventType.isPropagationStopped();
depthA++
) {
if (
- shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA])
+ JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA])
) {
- shouldSetEventType = targetInst[depthA];
+ JSCompiler_temp = targetInst[depthA];
break b;
}
}
else if (
- shouldSetEventType &&
- shouldSetEventType(JSCompiler_temp, targetInst)
+ JSCompiler_temp &&
+ JSCompiler_temp(shouldSetEventType, targetInst)
) {
- shouldSetEventType = targetInst;
+ JSCompiler_temp = targetInst;
break b;
}
- shouldSetEventType = null;
+ JSCompiler_temp = null;
}
- JSCompiler_temp._dispatchInstances = null;
- JSCompiler_temp._dispatchListeners = null;
- JSCompiler_temp.isPersistent() ||
- JSCompiler_temp.constructor.release(JSCompiler_temp);
- if (shouldSetEventType && shouldSetEventType !== responderInst)
+ shouldSetEventType._dispatchInstances = null;
+ shouldSetEventType._dispatchListeners = null;
+ shouldSetEventType.isPersistent() ||
+ shouldSetEventType.constructor.release(shouldSetEventType);
+ if (JSCompiler_temp && JSCompiler_temp !== responderInst)
if (
- ((JSCompiler_temp = ResponderSyntheticEvent.getPooled(
+ ((shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderGrant,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
- (JSCompiler_temp.touchHistory =
+ (shouldSetEventType.touchHistory =
ResponderTouchHistoryStore.touchHistory),
forEachAccumulated(
- JSCompiler_temp,
+ shouldSetEventType,
accumulateDirectDispatchesSingle
),
- (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)),
+ (targetInst = !0 === executeDirectDispatch(shouldSetEventType)),
responderInst)
)
if (
@@ -659,13 +637,13 @@ var eventTypes = {
forEachAccumulated(depthA, accumulateDirectDispatchesSingle);
var JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- [JSCompiler_temp, depthA]
+ [shouldSetEventType, depthA]
);
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
} else
(shouldSetEventType = ResponderSyntheticEvent.getPooled(
eventTypes.responderReject,
- shouldSetEventType,
+ JSCompiler_temp,
nativeEvent,
nativeEventTarget
)),
@@ -682,9 +660,9 @@ var eventTypes = {
else
(JSCompiler_temp$jscomp$0 = accumulate(
JSCompiler_temp$jscomp$0,
- JSCompiler_temp
+ shouldSetEventType
)),
- changeResponder(shouldSetEventType, targetInst);
+ changeResponder(JSCompiler_temp, targetInst);
else JSCompiler_temp$jscomp$0 = null;
} else JSCompiler_temp$jscomp$0 = null;
shouldSetEventType = responderInst && isStartish(topLevelType);
@@ -812,7 +790,6 @@ function recomputePluginOrdering() {
for (var eventName in pluginIndex) {
var JSCompiler_inline_result = void 0;
var dispatchConfig = pluginIndex[eventName],
- pluginModule$jscomp$0 = pluginModule,
eventName$jscomp$0 = eventName;
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
@@ -829,7 +806,7 @@ function recomputePluginOrdering() {
) &&
publishRegistrationName(
phasedRegistrationNames[JSCompiler_inline_result],
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
);
JSCompiler_inline_result = !0;
@@ -837,7 +814,7 @@ function recomputePluginOrdering() {
dispatchConfig.registrationName
? (publishRegistrationName(
dispatchConfig.registrationName,
- pluginModule$jscomp$0,
+ pluginModule,
eventName$jscomp$0
),
(JSCompiler_inline_result = !0))
@@ -865,13 +842,75 @@ function publishRegistrationName(registrationName, pluginModule) {
}
var plugins = [],
eventNameDispatchConfigs = {},
- registrationNameModules = {},
- customBubblingEventTypes =
+ registrationNameModules = {};
+function getListener$1(inst, registrationName) {
+ inst = inst.stateNode;
+ if (null === inst) return null;
+ inst = getFiberCurrentPropsFromNode(inst);
+ if (null === inst) return null;
+ if ((inst = inst[registrationName]) && "function" !== typeof inst)
+ throw Error(
+ "Expected `" +
+ registrationName +
+ "` listener to be a function, instead got a value of `" +
+ typeof inst +
+ "` type."
+ );
+ return inst;
+}
+var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customBubblingEventTypes,
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateDirectionalDispatches$1(inst, phase, event) {
+ if (
+ (phase = getListener$1(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase]
+ ))
+ )
+ (event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ phase
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ ));
+}
+function accumulateTwoPhaseDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ for (var inst = event._targetInst, path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; )
+ accumulateDirectionalDispatches$1(path[inst], "captured", event);
+ for (inst = 0; inst < path.length; inst++)
+ accumulateDirectionalDispatches$1(path[inst], "bubbled", event);
+ }
+}
+function accumulateDirectDispatchesSingle$1(event) {
+ if (event && event.dispatchConfig.registrationName) {
+ var inst = event._targetInst;
+ if (inst && event && event.dispatchConfig.registrationName) {
+ var listener = getListener$1(inst, event.dispatchConfig.registrationName);
+ listener &&
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listener
+ )),
+ (event._dispatchInstances = accumulateInto(
+ event._dispatchInstances,
+ inst
+ )));
+ }
+ }
+}
if (eventPluginOrder)
throw Error(
"EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."
@@ -881,7 +920,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_94 = {
+var injectedNamesToPlugins$jscomp$inline_232 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -905,42 +944,45 @@ var injectedNamesToPlugins$jscomp$inline_94 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle);
+ forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
- forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle);
+ forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
return topLevelType;
}
}
},
- isOrderingDirty$jscomp$inline_95 = !1,
- pluginName$jscomp$inline_96;
-for (pluginName$jscomp$inline_96 in injectedNamesToPlugins$jscomp$inline_94)
+ isOrderingDirty$jscomp$inline_233 = !1,
+ pluginName$jscomp$inline_234;
+for (pluginName$jscomp$inline_234 in injectedNamesToPlugins$jscomp$inline_232)
if (
- injectedNamesToPlugins$jscomp$inline_94.hasOwnProperty(
- pluginName$jscomp$inline_96
+ injectedNamesToPlugins$jscomp$inline_232.hasOwnProperty(
+ pluginName$jscomp$inline_234
)
) {
- var pluginModule$jscomp$inline_97 =
- injectedNamesToPlugins$jscomp$inline_94[pluginName$jscomp$inline_96];
+ var pluginModule$jscomp$inline_235 =
+ injectedNamesToPlugins$jscomp$inline_232[pluginName$jscomp$inline_234];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_96) ||
- namesToPlugins[pluginName$jscomp$inline_96] !==
- pluginModule$jscomp$inline_97
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_234) ||
+ namesToPlugins[pluginName$jscomp$inline_234] !==
+ pluginModule$jscomp$inline_235
) {
- if (namesToPlugins[pluginName$jscomp$inline_96])
+ if (namesToPlugins[pluginName$jscomp$inline_234])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_96 +
+ pluginName$jscomp$inline_234 +
"`."
);
namesToPlugins[
- pluginName$jscomp$inline_96
- ] = pluginModule$jscomp$inline_97;
- isOrderingDirty$jscomp$inline_95 = !0;
+ pluginName$jscomp$inline_234
+ ] = pluginModule$jscomp$inline_235;
+ isOrderingDirty$jscomp$inline_233 = !0;
}
}
-isOrderingDirty$jscomp$inline_95 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_233 && recomputePluginOrdering();
var instanceCache = new Map(),
instanceProps = new Map();
function getInstanceFromTag(tag) {
@@ -986,34 +1028,41 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) {
target = null;
null != inst && (target = inst.stateNode);
batchedUpdates(function() {
- var events = target;
- for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) {
- var possiblePlugin = plugins[i];
+ var JSCompiler_inline_result = target;
+ for (
+ var events = null, legacyPlugins = plugins, i = 0;
+ i < legacyPlugins.length;
+ i++
+ ) {
+ var possiblePlugin = legacyPlugins[i];
possiblePlugin &&
(possiblePlugin = possiblePlugin.extractEvents(
topLevelType,
inst,
nativeEvent,
- events,
- 1
+ JSCompiler_inline_result
)) &&
- (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin));
+ (events = accumulateInto(events, possiblePlugin));
}
- events = events$jscomp$0;
- null !== events && (eventQueue = accumulateInto(eventQueue, events));
- events = eventQueue;
+ JSCompiler_inline_result = events;
+ null !== JSCompiler_inline_result &&
+ (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result));
+ JSCompiler_inline_result = eventQueue;
eventQueue = null;
- if (events) {
- forEachAccumulated(events, executeDispatchesAndReleaseTopLevel);
+ if (JSCompiler_inline_result) {
+ forEachAccumulated(
+ JSCompiler_inline_result,
+ executeDispatchesAndReleaseTopLevel
+ );
if (eventQueue)
throw Error(
"processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
);
if (hasRethrowError)
- throw ((events = rethrowError),
+ throw ((JSCompiler_inline_result = rethrowError),
(hasRethrowError = !1),
(rethrowError = null),
- events);
+ JSCompiler_inline_result);
}
});
}
@@ -1028,13 +1077,13 @@ ReactNativePrivateInterface.RCTEventEmitter.register({
) {
var JSCompiler_temp = [];
for (var i = 0; i < changedIndices.length; i++) {
- var index = changedIndices[i];
- JSCompiler_temp.push(touches[index]);
- touches[index] = null;
+ var index$0 = changedIndices[i];
+ JSCompiler_temp.push(touches[index$0]);
+ touches[index$0] = null;
}
for (i = changedIndices = 0; i < touches.length; i++)
- (index = touches[i]),
- null !== index && (touches[changedIndices++] = index);
+ (index$0 = touches[i]),
+ null !== index$0 && (touches[changedIndices++] = index$0);
touches.length = changedIndices;
} else
for (JSCompiler_temp = [], i = 0; i < changedIndices.length; i++)
@@ -1047,10 +1096,10 @@ ReactNativePrivateInterface.RCTEventEmitter.register({
i = JSCompiler_temp[changedIndices];
i.changedTouches = JSCompiler_temp;
i.touches = touches;
- index = null;
+ index$0 = null;
var target = i.target;
- null === target || void 0 === target || 1 > target || (index = target);
- _receiveRootNodeIDEvent(index, eventTopLevelType, i);
+ null === target || void 0 === target || 1 > target || (index$0 = target);
+ _receiveRootNodeIDEvent(index$0, eventTopLevelType, i);
}
}
});
@@ -1076,31 +1125,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
}
});
var ReactSharedInternals =
- React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") ||
- (ReactSharedInternals.ReactCurrentDispatcher = { current: null });
-ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") ||
- (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null });
-var hasSymbol = "function" === typeof Symbol && Symbol.for,
- REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103,
- REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106,
- REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107,
- REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108,
- REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114,
- REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109,
- REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110,
- REACT_CONCURRENT_MODE_TYPE = hasSymbol
- ? Symbol.for("react.concurrent_mode")
- : 60111,
- REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112,
- REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113,
- REACT_SUSPENSE_LIST_TYPE = hasSymbol
- ? Symbol.for("react.suspense_list")
- : 60120,
- REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115,
- REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116,
- REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121,
- MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ REACT_ELEMENT_TYPE = 60103,
+ REACT_PORTAL_TYPE = 60106,
+ REACT_FRAGMENT_TYPE = 60107,
+ REACT_STRICT_MODE_TYPE = 60108,
+ REACT_PROFILER_TYPE = 60114,
+ REACT_PROVIDER_TYPE = 60109,
+ REACT_CONTEXT_TYPE = 60110,
+ REACT_FORWARD_REF_TYPE = 60112,
+ REACT_SUSPENSE_TYPE = 60113,
+ REACT_SUSPENSE_LIST_TYPE = 60120,
+ REACT_MEMO_TYPE = 60115,
+ REACT_LAZY_TYPE = 60116,
+ REACT_BLOCK_TYPE = 60121,
+ REACT_DEBUG_TRACING_MODE_TYPE = 60129,
+ REACT_OFFSCREEN_TYPE = 60130,
+ REACT_LEGACY_HIDDEN_TYPE = 60131;
+if ("function" === typeof Symbol && Symbol.for) {
+ var symbolFor = Symbol.for;
+ REACT_ELEMENT_TYPE = symbolFor("react.element");
+ REACT_PORTAL_TYPE = symbolFor("react.portal");
+ REACT_FRAGMENT_TYPE = symbolFor("react.fragment");
+ REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
+ REACT_PROFILER_TYPE = symbolFor("react.profiler");
+ REACT_PROVIDER_TYPE = symbolFor("react.provider");
+ REACT_CONTEXT_TYPE = symbolFor("react.context");
+ REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
+ REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
+ REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
+ REACT_MEMO_TYPE = symbolFor("react.memo");
+ REACT_LAZY_TYPE = symbolFor("react.lazy");
+ REACT_BLOCK_TYPE = symbolFor("react.block");
+ symbolFor("react.scope");
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
+ REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
+}
+var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -1108,27 +1170,6 @@ function getIteratorFn(maybeIterable) {
maybeIterable["@@iterator"];
return "function" === typeof maybeIterable ? maybeIterable : null;
}
-function initializeLazyComponentType(lazyComponent) {
- if (-1 === lazyComponent._status) {
- var ctor = lazyComponent._result;
- ctor || (ctor = lazyComponent._ctor);
- ctor = ctor();
- lazyComponent._status = 0;
- lazyComponent._result = ctor;
- ctor.then(
- function(moduleObject) {
- 0 === lazyComponent._status &&
- ((moduleObject = moduleObject.default),
- (lazyComponent._status = 1),
- (lazyComponent._result = moduleObject));
- },
- function(error) {
- 0 === lazyComponent._status &&
- ((lazyComponent._status = 2), (lazyComponent._result = error));
- }
- );
- }
-}
function getComponentName(type) {
if (null == type) return null;
if ("function" === typeof type) return type.displayName || type.name || null;
@@ -1163,10 +1204,13 @@ function getComponentName(type) {
case REACT_MEMO_TYPE:
return getComponentName(type.type);
case REACT_BLOCK_TYPE:
- return getComponentName(type.render);
+ return getComponentName(type._render);
case REACT_LAZY_TYPE:
- if ((type = 1 === type._status ? type._result : null))
- return getComponentName(type);
+ innerType = type._payload;
+ type = type._init;
+ try {
+ return getComponentName(type(innerType));
+ } catch (x) {}
}
return null;
}
@@ -1218,36 +1262,36 @@ function findCurrentFiberUsingSlowPath(fiber) {
}
if (a.return !== b.return) (a = parentA), (b = parentB);
else {
- for (var didFindChild = !1, _child = parentA.child; _child; ) {
- if (_child === a) {
+ for (var didFindChild = !1, child$1 = parentA.child; child$1; ) {
+ if (child$1 === a) {
didFindChild = !0;
a = parentA;
b = parentB;
break;
}
- if (_child === b) {
+ if (child$1 === b) {
didFindChild = !0;
b = parentA;
a = parentB;
break;
}
- _child = _child.sibling;
+ child$1 = child$1.sibling;
}
if (!didFindChild) {
- for (_child = parentB.child; _child; ) {
- if (_child === a) {
+ for (child$1 = parentB.child; child$1; ) {
+ if (child$1 === a) {
didFindChild = !0;
a = parentB;
b = parentA;
break;
}
- if (_child === b) {
+ if (child$1 === b) {
didFindChild = !0;
b = parentB;
a = parentA;
break;
}
- _child = _child.sibling;
+ child$1 = child$1.sibling;
}
if (!didFindChild)
throw Error(
@@ -1282,6 +1326,18 @@ function findCurrentHostFiber(parent) {
}
return null;
}
+function doesFiberContain(parentFiber, childFiber) {
+ for (
+ var parentFiberAlternate = parentFiber.alternate;
+ null !== childFiber;
+
+ ) {
+ if (childFiber === parentFiber || childFiber === parentFiberAlternate)
+ return !0;
+ childFiber = childFiber.return;
+ }
+ return !1;
+}
var emptyObject = {},
removedKeys = null,
removedKeyCount = 0,
@@ -1486,19 +1542,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
),
(removedKeys = null));
}
- for (var _propKey in prevProps)
- void 0 === nextProps[_propKey] &&
- (!(attributeConfig = validAttributes[_propKey]) ||
- (updatePayload && void 0 !== updatePayload[_propKey]) ||
- ((prevProp = prevProps[_propKey]),
+ for (var propKey$3 in prevProps)
+ void 0 === nextProps[propKey$3] &&
+ (!(attributeConfig = validAttributes[propKey$3]) ||
+ (updatePayload && void 0 !== updatePayload[propKey$3]) ||
+ ((prevProp = prevProps[propKey$3]),
void 0 !== prevProp &&
("object" !== typeof attributeConfig ||
"function" === typeof attributeConfig.diff ||
"function" === typeof attributeConfig.process
- ? (((updatePayload || (updatePayload = {}))[_propKey] = null),
+ ? (((updatePayload || (updatePayload = {}))[propKey$3] = null),
removedKeys || (removedKeys = {}),
- removedKeys[_propKey] ||
- ((removedKeys[_propKey] = !0), removedKeyCount++))
+ removedKeys[propKey$3] ||
+ ((removedKeys[propKey$3] = !0), removedKeyCount++))
: (updatePayload = clearNestedProperty(
updatePayload,
prevProp,
@@ -1607,9 +1663,22 @@ function finalizeInitialChildren(parentInstance) {
return !1;
}
var scheduleTimeout = setTimeout,
- cancelTimeout = clearTimeout,
- valueStack = [],
+ cancelTimeout = clearTimeout;
+function describeComponentFrame(name, source, ownerName) {
+ source = "";
+ ownerName && (source = " (created by " + ownerName + ")");
+ return "\n in " + (name || "Unknown") + source;
+}
+function describeFunctionComponentFrame(fn, source) {
+ return fn
+ ? describeComponentFrame(fn.displayName || fn.name || null, source, null)
+ : "";
+}
+var valueStack = [],
index = -1;
+function createCursor(defaultValue) {
+ return { current: defaultValue };
+}
function pop(cursor) {
0 > index ||
((cursor.current = valueStack[index]), (valueStack[index] = null), index--);
@@ -1620,8 +1689,8 @@ function push(cursor, value) {
cursor.current = value;
}
var emptyContextObject = {},
- contextStackCursor = { current: emptyContextObject },
- didPerformWorkStackCursor = { current: !1 },
+ contextStackCursor = createCursor(emptyContextObject),
+ didPerformWorkStackCursor = createCursor(!1),
previousContext = emptyContextObject;
function getMaskedContext(workInProgress, unmaskedContext) {
var contextTypes = workInProgress.type.contextTypes;
@@ -1701,12 +1770,228 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
+var rendererID = null,
+ injectedHook = null,
+ isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__,
+ Scheduler_now = Scheduler.unstable_now;
+if (
+ null == tracing.__interactionsRef ||
+ null == tracing.__interactionsRef.current
+)
+ throw Error(
+ "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling"
+ );
+Scheduler_now();
+var return_highestLanePriority = 10;
+function getHighestPriorityLanes(lanes) {
+ if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1;
+ if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2;
+ if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4;
+ var inputDiscreteLanes = 24 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 14), inputDiscreteLanes;
+ if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32;
+ inputDiscreteLanes = 192 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 12), inputDiscreteLanes;
+ if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256;
+ inputDiscreteLanes = 3584 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 10), inputDiscreteLanes;
+ if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096;
+ inputDiscreteLanes = 122880 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 8), inputDiscreteLanes;
+ if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072;
+ inputDiscreteLanes = 3932160 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 6), inputDiscreteLanes;
+ inputDiscreteLanes = 62914560 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 5), inputDiscreteLanes;
+ if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864;
+ if (0 !== (lanes & 134217728))
+ return (return_highestLanePriority = 3), 134217728;
+ inputDiscreteLanes = 805306368 & lanes;
+ if (0 !== inputDiscreteLanes)
+ return (return_highestLanePriority = 2), inputDiscreteLanes;
+ if (0 !== (1073741824 & lanes))
+ return (return_highestLanePriority = 1), 1073741824;
+ return_highestLanePriority = 10;
+ return lanes;
+}
+function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
+ switch (schedulerPriorityLevel) {
+ case 99:
+ return 17;
+ case 98:
+ return 12;
+ case 97:
+ case 96:
+ return 10;
+ case 95:
+ return 2;
+ default:
+ return 0;
+ }
+}
+function lanePriorityToSchedulerPriority(lanePriority) {
+ switch (lanePriority) {
+ case 17:
+ case 16:
+ return 99;
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ return 98;
+ case 11:
+ case 10:
+ case 9:
+ case 8:
+ case 7:
+ case 6:
+ case 4:
+ case 5:
+ return 97;
+ case 3:
+ case 2:
+ case 1:
+ return 95;
+ case 0:
+ return 90;
+ default:
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+ }
+}
+function getNextLanes(root, wipLanes) {
+ var pendingLanes = root.pendingLanes;
+ if (0 === pendingLanes) return (return_highestLanePriority = 0);
+ var nextLanes = 0,
+ nextLanePriority = 0,
+ expiredLanes = root.expiredLanes,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes;
+ if (0 !== expiredLanes)
+ (nextLanes = expiredLanes),
+ (nextLanePriority = return_highestLanePriority = 17);
+ else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) {
+ var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes;
+ 0 !== nonIdleUnblockedLanes
+ ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : ((pingedLanes &= expiredLanes),
+ 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority)));
+ } else
+ (expiredLanes = pendingLanes & ~suspendedLanes),
+ 0 !== expiredLanes
+ ? ((nextLanes = getHighestPriorityLanes(expiredLanes)),
+ (nextLanePriority = return_highestLanePriority))
+ : 0 !== pingedLanes &&
+ ((nextLanes = getHighestPriorityLanes(pingedLanes)),
+ (nextLanePriority = return_highestLanePriority));
+ if (0 === nextLanes) return 0;
+ nextLanes = 31 - clz32(nextLanes);
+ nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1);
+ if (
+ 0 !== wipLanes &&
+ wipLanes !== nextLanes &&
+ 0 === (wipLanes & suspendedLanes)
+ ) {
+ getHighestPriorityLanes(wipLanes);
+ if (nextLanePriority <= return_highestLanePriority) return wipLanes;
+ return_highestLanePriority = nextLanePriority;
+ }
+ wipLanes = root.entangledLanes;
+ if (0 !== wipLanes)
+ for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; )
+ (pendingLanes = 31 - clz32(wipLanes)),
+ (nextLanePriority = 1 << pendingLanes),
+ (nextLanes |= root[pendingLanes]),
+ (wipLanes &= ~nextLanePriority);
+ return nextLanes;
+}
+function getMostRecentEventTime(root, lanes) {
+ root = root.eventTimes;
+ for (var mostRecentEventTime = -1; 0 < lanes; ) {
+ var index$6 = 31 - clz32(lanes),
+ lane = 1 << index$6;
+ index$6 = root[index$6];
+ index$6 > mostRecentEventTime && (mostRecentEventTime = index$6);
+ lanes &= ~lane;
+ }
+ return mostRecentEventTime;
+}
+function getLanesToRetrySynchronouslyOnError(root) {
+ root = root.pendingLanes & -1073741825;
+ return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0;
+}
+function findUpdateLane(lanePriority, wipLanes) {
+ switch (lanePriority) {
+ case 17:
+ return 1;
+ case 16:
+ return 2;
+ case 14:
+ return (
+ (lanePriority = getHighestPriorityLane(24 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority
+ );
+ case 12:
+ return (
+ (lanePriority = getHighestPriorityLane(192 & ~wipLanes)),
+ 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority
+ );
+ case 10:
+ return (
+ (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)),
+ 0 === lanePriority &&
+ ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)),
+ 0 === lanePriority && (lanePriority = 512)),
+ lanePriority
+ );
+ case 2:
+ return (
+ (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)),
+ 0 === wipLanes && (wipLanes = 268435456),
+ wipLanes
+ );
+ }
+ throw Error(
+ "Invalid update priority: " + lanePriority + ". This is a bug in React."
+ );
+}
+function getHighestPriorityLane(lanes) {
+ return lanes & -lanes;
+}
+function pickArbitraryLane(lanes) {
+ return lanes & -lanes;
+}
+function markRootUpdated(root, updateLane, eventTime) {
+ root.pendingLanes |= updateLane;
+ var higherPriorityLanes = updateLane - 1;
+ root.suspendedLanes &= higherPriorityLanes;
+ root.pingedLanes &= higherPriorityLanes;
+ root = root.eventTimes;
+ updateLane = 31 - clz32(updateLane);
+ root[updateLane] = eventTime;
+}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(lanes) {
+ return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0;
+}
var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
Scheduler_shouldYield = Scheduler.unstable_shouldYield,
Scheduler_requestPaint = Scheduler.unstable_requestPaint,
- Scheduler_now = Scheduler.unstable_now,
+ Scheduler_now$1 = Scheduler.unstable_now,
Scheduler_getCurrentPriorityLevel =
Scheduler.unstable_getCurrentPriorityLevel,
Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
@@ -1727,12 +2012,12 @@ var fakeCallbackNode = {},
syncQueue = null,
immediateQueueCallbackNode = null,
isFlushingSyncQueue = !1,
- initialTimeMs = Scheduler_now(),
+ initialTimeMs$1 = Scheduler_now$1(),
now =
- 1e4 > initialTimeMs
- ? Scheduler_now
+ 1e4 > initialTimeMs$1
+ ? Scheduler_now$1
: function() {
- return Scheduler_now() - initialTimeMs;
+ return Scheduler_now$1() - initialTimeMs$1;
};
function getCurrentPriorityLevel() {
switch (Scheduler_getCurrentPriorityLevel()) {
@@ -1774,16 +2059,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) {
reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
return Scheduler_scheduleCallback(reactPriorityLevel, callback, options);
}
-function scheduleSyncCallback(callback) {
- null === syncQueue
- ? ((syncQueue = [callback]),
- (immediateQueueCallbackNode = Scheduler_scheduleCallback(
- Scheduler_ImmediatePriority,
- flushSyncCallbackQueueImpl
- )))
- : syncQueue.push(callback);
- return fakeCallbackNode;
-}
function flushSyncCallbackQueue() {
if (null !== immediateQueueCallbackNode) {
var node = immediateQueueCallbackNode;
@@ -1818,18 +2093,41 @@ function flushSyncCallbackQueueImpl() {
}
}
}
-function inferPriorityFromExpirationTime(currentTime, expirationTime) {
- if (1073741823 === expirationTime) return 99;
- if (1 === expirationTime || 2 === expirationTime) return 95;
- currentTime =
- 10 * (1073741821 - expirationTime) - 10 * (1073741821 - currentTime);
- return 0 >= currentTime
- ? 99
- : 250 >= currentTime
- ? 98
- : 5250 >= currentTime
- ? 97
- : 95;
+function describeFiber(fiber) {
+ switch (fiber.tag) {
+ case 5:
+ return describeComponentFrame(fiber.type, null, null);
+ case 16:
+ return describeComponentFrame("Lazy", null, null);
+ case 13:
+ return describeComponentFrame("Suspense", null, null);
+ case 19:
+ return describeComponentFrame("SuspenseList", null, null);
+ case 0:
+ case 2:
+ case 15:
+ return describeFunctionComponentFrame(fiber.type, null);
+ case 11:
+ return describeFunctionComponentFrame(fiber.type.render, null);
+ case 22:
+ return describeFunctionComponentFrame(fiber.type._render, null);
+ case 1:
+ return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber;
+ default:
+ return "";
+ }
+}
+function getStackByFiberInDevAndProd(workInProgress) {
+ try {
+ var info = "";
+ do
+ (info += describeFiber(workInProgress)),
+ (workInProgress = workInProgress.return);
+ while (workInProgress);
+ return info;
+ } catch (x) {
+ return "\nError generating stack: " + x.message + "\n" + x.stack;
+ }
}
function is(x, y) {
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
@@ -1856,43 +2154,6 @@ function shallowEqual(objA, objB) {
return !1;
return !0;
}
-var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
-function getStackByFiberInDevAndProd(workInProgress) {
- var info = "";
- do {
- a: switch (workInProgress.tag) {
- case 3:
- case 4:
- case 6:
- case 7:
- case 10:
- case 9:
- var JSCompiler_inline_result = "";
- break a;
- default:
- var owner = workInProgress._debugOwner,
- source = workInProgress._debugSource,
- name = getComponentName(workInProgress.type);
- JSCompiler_inline_result = null;
- owner && (JSCompiler_inline_result = getComponentName(owner.type));
- owner = name;
- name = "";
- source
- ? (name =
- " (at " +
- source.fileName.replace(BEFORE_SLASH_RE, "") +
- ":" +
- source.lineNumber +
- ")")
- : JSCompiler_inline_result &&
- (name = " (created by " + JSCompiler_inline_result + ")");
- JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name;
- }
- info += JSCompiler_inline_result;
- workInProgress = workInProgress.return;
- } while (workInProgress);
- return info;
-}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
baseProps = Object.assign({}, baseProps);
@@ -1900,10 +2161,11 @@ function resolveDefaultProps(Component, baseProps) {
for (var propName in Component)
void 0 === baseProps[propName] &&
(baseProps[propName] = Component[propName]);
+ return baseProps;
}
return baseProps;
}
-var valueCursor = { current: null },
+var valueCursor = createCursor(null),
currentlyRenderingFiber = null,
lastContextDependency = null,
lastContextWithAllBitsObserved = null;
@@ -1915,31 +2177,29 @@ function popProvider(providerFiber) {
pop(valueCursor);
providerFiber.type._context._currentValue = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderExpirationTime) {
+function scheduleWorkOnParentPath(parent, renderLanes) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- if (parent.childExpirationTime < renderExpirationTime)
- (parent.childExpirationTime = renderExpirationTime),
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime &&
- (alternate.childExpirationTime = renderExpirationTime);
- else if (
- null !== alternate &&
- alternate.childExpirationTime < renderExpirationTime
- )
- alternate.childExpirationTime = renderExpirationTime;
- else break;
+ if ((parent.childLanes & renderLanes) === renderLanes)
+ if (
+ null === alternate ||
+ (alternate.childLanes & renderLanes) === renderLanes
+ )
+ break;
+ else alternate.childLanes |= renderLanes;
+ else
+ (parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes);
parent = parent.return;
}
}
-function prepareToReadContext(workInProgress, renderExpirationTime) {
+function prepareToReadContext(workInProgress, renderLanes) {
currentlyRenderingFiber = workInProgress;
lastContextWithAllBitsObserved = lastContextDependency = null;
workInProgress = workInProgress.dependencies;
null !== workInProgress &&
null !== workInProgress.firstContext &&
- (workInProgress.expirationTime >= renderExpirationTime &&
- (didReceiveUpdate = !0),
+ (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0),
(workInProgress.firstContext = null));
}
function readContext(context, observedBits) {
@@ -1958,7 +2218,7 @@ function readContext(context, observedBits) {
);
lastContextDependency = observedBits;
currentlyRenderingFiber.dependencies = {
- expirationTime: 0,
+ lanes: 0,
firstContext: observedBits,
responders: null
};
@@ -1970,7 +2230,8 @@ var hasForceUpdate = !1;
function initializeUpdateQueue(fiber) {
fiber.updateQueue = {
baseState: fiber.memoizedState,
- baseQueue: null,
+ firstBaseUpdate: null,
+ lastBaseUpdate: null,
shared: { pending: null },
effects: null
};
@@ -1980,21 +2241,22 @@ function cloneUpdateQueue(current, workInProgress) {
workInProgress.updateQueue === current &&
(workInProgress.updateQueue = {
baseState: current.baseState,
- baseQueue: current.baseQueue,
+ firstBaseUpdate: current.firstBaseUpdate,
+ lastBaseUpdate: current.lastBaseUpdate,
shared: current.shared,
effects: current.effects
});
}
-function createUpdate(expirationTime, suspenseConfig) {
- expirationTime = {
- expirationTime: expirationTime,
+function createUpdate(eventTime, lane, suspenseConfig) {
+ return {
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
tag: 0,
payload: null,
callback: null,
next: null
};
- return (expirationTime.next = expirationTime);
}
function enqueueUpdate(fiber, update) {
fiber = fiber.updateQueue;
@@ -2007,132 +2269,185 @@ function enqueueUpdate(fiber, update) {
fiber.pending = update;
}
}
-function enqueueCapturedUpdate(workInProgress, update) {
- var current = workInProgress.alternate;
- null !== current && cloneUpdateQueue(current, workInProgress);
- workInProgress = workInProgress.updateQueue;
- current = workInProgress.baseQueue;
- null === current
- ? ((workInProgress.baseQueue = update.next = update),
- (update.next = update))
- : ((update.next = current.next), (current.next = update));
+function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
+ var queue = workInProgress.updateQueue,
+ current = workInProgress.alternate;
+ if (
+ null !== current &&
+ ((current = current.updateQueue), queue === current)
+ ) {
+ var newFirst = null,
+ newLast = null;
+ queue = queue.firstBaseUpdate;
+ if (null !== queue) {
+ do {
+ var clone = {
+ eventTime: queue.eventTime,
+ lane: queue.lane,
+ suspenseConfig: queue.suspenseConfig,
+ tag: queue.tag,
+ payload: queue.payload,
+ callback: queue.callback,
+ next: null
+ };
+ null === newLast
+ ? (newFirst = newLast = clone)
+ : (newLast = newLast.next = clone);
+ queue = queue.next;
+ } while (null !== queue);
+ null === newLast
+ ? (newFirst = newLast = capturedUpdate)
+ : (newLast = newLast.next = capturedUpdate);
+ } else newFirst = newLast = capturedUpdate;
+ queue = {
+ baseState: current.baseState,
+ firstBaseUpdate: newFirst,
+ lastBaseUpdate: newLast,
+ shared: current.shared,
+ effects: current.effects
+ };
+ workInProgress.updateQueue = queue;
+ return;
+ }
+ workInProgress = queue.lastBaseUpdate;
+ null === workInProgress
+ ? (queue.firstBaseUpdate = capturedUpdate)
+ : (workInProgress.next = capturedUpdate);
+ queue.lastBaseUpdate = capturedUpdate;
}
function processUpdateQueue(
workInProgress$jscomp$0,
props,
instance,
- renderExpirationTime
+ renderLanes
) {
var queue = workInProgress$jscomp$0.updateQueue;
hasForceUpdate = !1;
- var baseQueue = queue.baseQueue,
+ var firstBaseUpdate = queue.firstBaseUpdate,
+ lastBaseUpdate = queue.lastBaseUpdate,
pendingQueue = queue.shared.pending;
if (null !== pendingQueue) {
- if (null !== baseQueue) {
- var baseFirst = baseQueue.next;
- baseQueue.next = pendingQueue.next;
- pendingQueue.next = baseFirst;
- }
- baseQueue = pendingQueue;
queue.shared.pending = null;
- baseFirst = workInProgress$jscomp$0.alternate;
- null !== baseFirst &&
- ((baseFirst = baseFirst.updateQueue),
- null !== baseFirst && (baseFirst.baseQueue = pendingQueue));
+ var lastPendingUpdate = pendingQueue,
+ firstPendingUpdate = lastPendingUpdate.next;
+ lastPendingUpdate.next = null;
+ null === lastBaseUpdate
+ ? (firstBaseUpdate = firstPendingUpdate)
+ : (lastBaseUpdate.next = firstPendingUpdate);
+ lastBaseUpdate = lastPendingUpdate;
+ var current = workInProgress$jscomp$0.alternate;
+ if (null !== current) {
+ current = current.updateQueue;
+ var currentLastBaseUpdate = current.lastBaseUpdate;
+ currentLastBaseUpdate !== lastBaseUpdate &&
+ (null === currentLastBaseUpdate
+ ? (current.firstBaseUpdate = firstPendingUpdate)
+ : (currentLastBaseUpdate.next = firstPendingUpdate),
+ (current.lastBaseUpdate = lastPendingUpdate));
+ }
}
- if (null !== baseQueue) {
- baseFirst = baseQueue.next;
- var newState = queue.baseState,
- newExpirationTime = 0,
- newBaseState = null,
- newBaseQueueFirst = null,
- newBaseQueueLast = null;
- if (null !== baseFirst) {
- var update = baseFirst;
- do {
- pendingQueue = update.expirationTime;
- if (pendingQueue < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
+ if (null !== firstBaseUpdate) {
+ currentLastBaseUpdate = queue.baseState;
+ lastBaseUpdate = 0;
+ current = firstPendingUpdate = lastPendingUpdate = null;
+ do {
+ pendingQueue = firstBaseUpdate.lane;
+ var updateEventTime = firstBaseUpdate.eventTime;
+ if ((renderLanes & pendingQueue) === pendingQueue) {
+ null !== current &&
+ (current = current.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
next: null
- };
- null === newBaseQueueLast
- ? ((newBaseQueueFirst = newBaseQueueLast = clone),
- (newBaseState = newState))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- pendingQueue > newExpirationTime &&
- (newExpirationTime = pendingQueue);
- } else {
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
- tag: update.tag,
- payload: update.payload,
- callback: update.callback,
- next: null
- });
- markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig);
- a: {
- var workInProgress = workInProgress$jscomp$0,
- update$jscomp$0 = update;
- pendingQueue = props;
- clone = instance;
- switch (update$jscomp$0.tag) {
- case 1:
- workInProgress = update$jscomp$0.payload;
- if ("function" === typeof workInProgress) {
- newState = workInProgress.call(clone, newState, pendingQueue);
- break a;
- }
- newState = workInProgress;
- break a;
- case 3:
- workInProgress.effectTag =
- (workInProgress.effectTag & -4097) | 64;
- case 0:
- workInProgress = update$jscomp$0.payload;
- pendingQueue =
- "function" === typeof workInProgress
- ? workInProgress.call(clone, newState, pendingQueue)
- : workInProgress;
- if (null === pendingQueue || void 0 === pendingQueue) break a;
- newState = Object.assign({}, newState, pendingQueue);
+ });
+ markRenderEventTimeAndConfig(
+ updateEventTime,
+ firstBaseUpdate.suspenseConfig
+ );
+ a: {
+ var workInProgress = workInProgress$jscomp$0,
+ update = firstBaseUpdate;
+ pendingQueue = props;
+ updateEventTime = instance;
+ switch (update.tag) {
+ case 1:
+ workInProgress = update.payload;
+ if ("function" === typeof workInProgress) {
+ currentLastBaseUpdate = workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ );
break a;
- case 2:
- hasForceUpdate = !0;
- }
+ }
+ currentLastBaseUpdate = workInProgress;
+ break a;
+ case 3:
+ workInProgress.effectTag =
+ (workInProgress.effectTag & -4097) | 64;
+ case 0:
+ workInProgress = update.payload;
+ pendingQueue =
+ "function" === typeof workInProgress
+ ? workInProgress.call(
+ updateEventTime,
+ currentLastBaseUpdate,
+ pendingQueue
+ )
+ : workInProgress;
+ if (null === pendingQueue || void 0 === pendingQueue) break a;
+ currentLastBaseUpdate = Object.assign(
+ {},
+ currentLastBaseUpdate,
+ pendingQueue
+ );
+ break a;
+ case 2:
+ hasForceUpdate = !0;
}
- null !== update.callback &&
- ((workInProgress$jscomp$0.effectTag |= 32),
- (pendingQueue = queue.effects),
- null === pendingQueue
- ? (queue.effects = [update])
- : pendingQueue.push(update));
}
- update = update.next;
- if (null === update || update === baseFirst)
- if (((pendingQueue = queue.shared.pending), null === pendingQueue))
- break;
- else
- (update = baseQueue.next = pendingQueue.next),
- (pendingQueue.next = baseFirst),
- (queue.baseQueue = baseQueue = pendingQueue),
- (queue.shared.pending = null);
- } while (1);
- }
- null === newBaseQueueLast
- ? (newBaseState = newState)
- : (newBaseQueueLast.next = newBaseQueueFirst);
- queue.baseState = newBaseState;
- queue.baseQueue = newBaseQueueLast;
- markUnprocessedUpdateTime(newExpirationTime);
- workInProgress$jscomp$0.expirationTime = newExpirationTime;
- workInProgress$jscomp$0.memoizedState = newState;
+ null !== firstBaseUpdate.callback &&
+ ((workInProgress$jscomp$0.effectTag |= 32),
+ (pendingQueue = queue.effects),
+ null === pendingQueue
+ ? (queue.effects = [firstBaseUpdate])
+ : pendingQueue.push(firstBaseUpdate));
+ } else
+ (updateEventTime = {
+ eventTime: updateEventTime,
+ lane: pendingQueue,
+ suspenseConfig: firstBaseUpdate.suspenseConfig,
+ tag: firstBaseUpdate.tag,
+ payload: firstBaseUpdate.payload,
+ callback: firstBaseUpdate.callback,
+ next: null
+ }),
+ null === current
+ ? ((firstPendingUpdate = current = updateEventTime),
+ (lastPendingUpdate = currentLastBaseUpdate))
+ : (current = current.next = updateEventTime),
+ (lastBaseUpdate |= pendingQueue);
+ firstBaseUpdate = firstBaseUpdate.next;
+ if (null === firstBaseUpdate)
+ if (((pendingQueue = queue.shared.pending), null === pendingQueue))
+ break;
+ else
+ (firstBaseUpdate = pendingQueue.next),
+ (pendingQueue.next = null),
+ (queue.lastBaseUpdate = pendingQueue),
+ (queue.shared.pending = null);
+ } while (1);
+ null === current && (lastPendingUpdate = currentLastBaseUpdate);
+ queue.baseState = lastPendingUpdate;
+ queue.firstBaseUpdate = firstPendingUpdate;
+ queue.lastBaseUpdate = current;
+ workInProgressRootSkippedLanes |= lastBaseUpdate;
+ workInProgress$jscomp$0.lanes = lastBaseUpdate;
+ workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate;
}
}
function commitUpdateQueue(finishedWork, finishedQueue, instance) {
@@ -2172,54 +2487,54 @@ function applyDerivedStateFromProps(
? ctor
: Object.assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
- 0 === workInProgress.expirationTime &&
+ 0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
}
var classComponentUpdater = {
isMounted: function(component) {
- return (component = component._reactInternalFiber)
+ return (component = component._reactInternals)
? getNearestMountedFiber(component) === component
: !1;
},
enqueueSetState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueReplaceState: function(inst, payload, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 1;
suspenseConfig.payload = payload;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
},
enqueueForceUpdate: function(inst, callback) {
- inst = inst._reactInternalFiber;
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig);
- suspenseConfig = createUpdate(currentTime, suspenseConfig);
+ inst = inst._reactInternals;
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(inst, suspenseConfig);
+ suspenseConfig = createUpdate(eventTime, lane, suspenseConfig);
suspenseConfig.tag = 2;
void 0 !== callback &&
null !== callback &&
(suspenseConfig.callback = callback);
enqueueUpdate(inst, suspenseConfig);
- scheduleWork(inst, currentTime);
+ scheduleUpdateOnFiber(inst, lane, eventTime);
}
};
function checkShouldComponentUpdate(
@@ -2257,7 +2572,7 @@ function constructClassInstance(workInProgress, ctor, props) {
null !== ctor.state && void 0 !== ctor.state ? ctor.state : null;
ctor.updater = classComponentUpdater;
workInProgress.stateNode = ctor;
- ctor._reactInternalFiber = workInProgress;
+ ctor._reactInternals = workInProgress;
isLegacyContextConsumer &&
((workInProgress = workInProgress.stateNode),
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
@@ -2278,12 +2593,7 @@ function callComponentWillReceiveProps(
instance.state !== workInProgress &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
}
-function mountClassInstance(
- workInProgress,
- ctor,
- newProps,
- renderExpirationTime
-) {
+function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;
@@ -2296,7 +2606,7 @@ function mountClassInstance(
? previousContext
: contextStackCursor.current),
(instance.context = getMaskedContext(workInProgress, contextType)));
- processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes);
instance.state = workInProgress.memoizedState;
contextType = ctor.getDerivedStateFromProps;
"function" === typeof contextType &&
@@ -2313,12 +2623,7 @@ function mountClassInstance(
instance.UNSAFE_componentWillMount(),
ctor !== instance.state &&
classComponentUpdater.enqueueReplaceState(instance, instance.state, null),
- processUpdateQueue(
- workInProgress,
- newProps,
- instance,
- renderExpirationTime
- ),
+ processUpdateQueue(workInProgress, newProps, instance, renderLanes),
(instance.state = workInProgress.memoizedState));
"function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4);
@@ -2382,7 +2687,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) {
("[object Object]" === Object.prototype.toString.call(newChild)
? "object with keys {" + Object.keys(newChild).join(", ") + "}"
: newChild) +
- ")."
+ "). If you meant to render a collection of children, use an array instead."
);
}
function ChildReconciler(shouldTrackSideEffects) {
@@ -2438,14 +2743,10 @@ function ChildReconciler(shouldTrackSideEffects) {
(newFiber.effectTag = 2);
return newFiber;
}
- function updateTextNode(returnFiber, current, textContent, expirationTime) {
+ function updateTextNode(returnFiber, current, textContent, lanes) {
if (null === current || 6 !== current.tag)
return (
- (current = createFiberFromText(
- textContent,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromText(textContent, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2453,27 +2754,27 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateElement(returnFiber, current, element, expirationTime) {
+ function updateElement(returnFiber, current, element, lanes) {
if (null !== current && current.elementType === element.type)
return (
- (expirationTime = useFiber(current, element.props)),
- (expirationTime.ref = coerceRef(returnFiber, current, element)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes = useFiber(current, element.props)),
+ (lanes.ref = coerceRef(returnFiber, current, element)),
+ (lanes.return = returnFiber),
+ lanes
);
- expirationTime = createFiberFromTypeAndProps(
+ lanes = createFiberFromTypeAndProps(
element.type,
element.key,
element.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
);
- expirationTime.ref = coerceRef(returnFiber, current, element);
- expirationTime.return = returnFiber;
- return expirationTime;
+ lanes.ref = coerceRef(returnFiber, current, element);
+ lanes.return = returnFiber;
+ return lanes;
}
- function updatePortal(returnFiber, current, portal, expirationTime) {
+ function updatePortal(returnFiber, current, portal, lanes) {
if (
null === current ||
4 !== current.tag ||
@@ -2481,11 +2782,7 @@ function ChildReconciler(shouldTrackSideEffects) {
current.stateNode.implementation !== portal.implementation
)
return (
- (current = createFiberFromPortal(
- portal,
- returnFiber.mode,
- expirationTime
- )),
+ (current = createFiberFromPortal(portal, returnFiber.mode, lanes)),
(current.return = returnFiber),
current
);
@@ -2493,13 +2790,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function updateFragment(returnFiber, current, fragment, expirationTime, key) {
+ function updateFragment(returnFiber, current, fragment, lanes, key) {
if (null === current || 7 !== current.tag)
return (
(current = createFiberFromFragment(
fragment,
returnFiber.mode,
- expirationTime,
+ lanes,
key
)),
(current.return = returnFiber),
@@ -2509,13 +2806,13 @@ function ChildReconciler(shouldTrackSideEffects) {
current.return = returnFiber;
return current;
}
- function createChild(returnFiber, newChild, expirationTime) {
+ function createChild(returnFiber, newChild, lanes) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(newChild = createFiberFromText(
"" + newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2524,24 +2821,24 @@ function ChildReconciler(shouldTrackSideEffects) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
return (
- (expirationTime = createFiberFromTypeAndProps(
+ (lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(returnFiber, null, newChild)),
- (expirationTime.return = returnFiber),
- expirationTime
+ (lanes.ref = coerceRef(returnFiber, null, newChild)),
+ (lanes.return = returnFiber),
+ lanes
);
case REACT_PORTAL_TYPE:
return (
(newChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(newChild.return = returnFiber),
newChild
@@ -2552,7 +2849,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(newChild = createFiberFromFragment(
newChild,
returnFiber.mode,
- expirationTime,
+ lanes,
null
)),
(newChild.return = returnFiber),
@@ -2562,12 +2859,12 @@ function ChildReconciler(shouldTrackSideEffects) {
}
return null;
}
- function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
+ function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
if ("string" === typeof newChild || "number" === typeof newChild)
return null !== key
? null
- : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime);
+ : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
@@ -2577,26 +2874,20 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChild.props.children,
- expirationTime,
+ lanes,
key
)
- : updateElement(returnFiber, oldFiber, newChild, expirationTime)
+ : updateElement(returnFiber, oldFiber, newChild, lanes)
: null;
case REACT_PORTAL_TYPE:
return newChild.key === key
- ? updatePortal(returnFiber, oldFiber, newChild, expirationTime)
+ ? updatePortal(returnFiber, oldFiber, newChild, lanes)
: null;
}
if (isArray(newChild) || getIteratorFn(newChild))
return null !== key
? null
- : updateFragment(
- returnFiber,
- oldFiber,
- newChild,
- expirationTime,
- null
- );
+ : updateFragment(returnFiber, oldFiber, newChild, lanes, null);
throwOnInvalidObjectType(returnFiber, newChild);
}
return null;
@@ -2606,17 +2897,12 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChild,
- expirationTime
+ lanes
) {
if ("string" === typeof newChild || "number" === typeof newChild)
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateTextNode(
- returnFiber,
- existingChildren,
- "" + newChild,
- expirationTime
- )
+ updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
@@ -2631,15 +2917,10 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
existingChildren,
newChild.props.children,
- expirationTime,
+ lanes,
newChild.key
)
- : updateElement(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ : updateElement(returnFiber, existingChildren, newChild, lanes)
);
case REACT_PORTAL_TYPE:
return (
@@ -2647,24 +2928,13 @@ function ChildReconciler(shouldTrackSideEffects) {
existingChildren.get(
null === newChild.key ? newIdx : newChild.key
) || null),
- updatePortal(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime
- )
+ updatePortal(returnFiber, existingChildren, newChild, lanes)
);
}
if (isArray(newChild) || getIteratorFn(newChild))
return (
(existingChildren = existingChildren.get(newIdx) || null),
- updateFragment(
- returnFiber,
- existingChildren,
- newChild,
- expirationTime,
- null
- )
+ updateFragment(returnFiber, existingChildren, newChild, lanes, null)
);
throwOnInvalidObjectType(returnFiber, newChild);
}
@@ -2674,7 +2944,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildren,
- expirationTime
+ lanes
) {
for (
var resultingFirstChild = null,
@@ -2692,7 +2962,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
oldFiber,
newChildren[newIdx],
- expirationTime
+ lanes
);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
@@ -2715,11 +2985,7 @@ function ChildReconciler(shouldTrackSideEffects) {
);
if (null === oldFiber) {
for (; newIdx < newChildren.length; newIdx++)
- (oldFiber = createChild(
- returnFiber,
- newChildren[newIdx],
- expirationTime
- )),
+ (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)),
null !== oldFiber &&
((currentFirstChild = placeChild(
oldFiber,
@@ -2742,7 +3008,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
newIdx,
newChildren[newIdx],
- expirationTime
+ lanes
)),
null !== nextOldFiber &&
(shouldTrackSideEffects &&
@@ -2769,7 +3035,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChildrenIterable,
- expirationTime
+ lanes
) {
var iteratorFn = getIteratorFn(newChildrenIterable);
if ("function" !== typeof iteratorFn)
@@ -2791,12 +3057,7 @@ function ChildReconciler(shouldTrackSideEffects) {
oldFiber.index > newIdx
? ((nextOldFiber = oldFiber), (oldFiber = null))
: (nextOldFiber = oldFiber.sibling);
- var newFiber = updateSlot(
- returnFiber,
- oldFiber,
- step.value,
- expirationTime
- );
+ var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
if (null === newFiber) {
null === oldFiber && (oldFiber = nextOldFiber);
break;
@@ -2816,7 +3077,7 @@ function ChildReconciler(shouldTrackSideEffects) {
return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn;
if (null === oldFiber) {
for (; !step.done; newIdx++, step = newChildrenIterable.next())
- (step = createChild(returnFiber, step.value, expirationTime)),
+ (step = createChild(returnFiber, step.value, lanes)),
null !== step &&
((currentFirstChild = placeChild(step, currentFirstChild, newIdx)),
null === previousNewFiber
@@ -2830,13 +3091,7 @@ function ChildReconciler(shouldTrackSideEffects) {
!step.done;
newIdx++, step = newChildrenIterable.next()
)
- (step = updateFromMap(
- oldFiber,
- returnFiber,
- newIdx,
- step.value,
- expirationTime
- )),
+ (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)),
null !== step &&
(shouldTrackSideEffects &&
null !== step.alternate &&
@@ -2852,7 +3107,7 @@ function ChildReconciler(shouldTrackSideEffects) {
});
return iteratorFn;
}
- return function(returnFiber, currentFirstChild, newChild, expirationTime) {
+ return function(returnFiber, currentFirstChild, newChild, lanes) {
var isUnkeyedTopLevelFragment =
"object" === typeof newChild &&
null !== newChild &&
@@ -2918,26 +3173,26 @@ function ChildReconciler(shouldTrackSideEffects) {
? ((currentFirstChild = createFiberFromFragment(
newChild.props.children,
returnFiber.mode,
- expirationTime,
+ lanes,
newChild.key
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild))
- : ((expirationTime = createFiberFromTypeAndProps(
+ : ((lanes = createFiberFromTypeAndProps(
newChild.type,
newChild.key,
newChild.props,
null,
returnFiber.mode,
- expirationTime
+ lanes
)),
- (expirationTime.ref = coerceRef(
+ (lanes.ref = coerceRef(
returnFiber,
currentFirstChild,
newChild
)),
- (expirationTime.return = returnFiber),
- (returnFiber = expirationTime));
+ (lanes.return = returnFiber),
+ (returnFiber = lanes));
}
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
@@ -2976,7 +3231,7 @@ function ChildReconciler(shouldTrackSideEffects) {
currentFirstChild = createFiberFromPortal(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
@@ -2995,7 +3250,7 @@ function ChildReconciler(shouldTrackSideEffects) {
(currentFirstChild = createFiberFromText(
newChild,
returnFiber.mode,
- expirationTime
+ lanes
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
@@ -3006,14 +3261,14 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
if (getIteratorFn(newChild))
return reconcileChildrenIterator(
returnFiber,
currentFirstChild,
newChild,
- expirationTime
+ lanes
);
isObject && throwOnInvalidObjectType(returnFiber, newChild);
if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
@@ -3032,9 +3287,9 @@ function ChildReconciler(shouldTrackSideEffects) {
var reconcileChildFibers = ChildReconciler(!0),
mountChildFibers = ChildReconciler(!1),
NO_CONTEXT = {},
- contextStackCursor$1 = { current: NO_CONTEXT },
- contextFiberStackCursor = { current: NO_CONTEXT },
- rootInstanceStackCursor = { current: NO_CONTEXT };
+ contextStackCursor$1 = createCursor(NO_CONTEXT),
+ contextFiberStackCursor = createCursor(NO_CONTEXT),
+ rootInstanceStackCursor = createCursor(NO_CONTEXT);
function requiredContext(c) {
if (c === NO_CONTEXT)
throw Error(
@@ -3057,26 +3312,26 @@ function popHostContainer() {
function pushHostContext(fiber) {
requiredContext(rootInstanceStackCursor.current);
var context = requiredContext(contextStackCursor$1.current);
- var nextContext = fiber.type;
- nextContext =
- "AndroidTextInput" === nextContext ||
- "RCTMultilineTextInputView" === nextContext ||
- "RCTSinglelineTextInputView" === nextContext ||
- "RCTText" === nextContext ||
- "RCTVirtualText" === nextContext;
- nextContext =
- context.isInAParentText !== nextContext
- ? { isInAParentText: nextContext }
+ var JSCompiler_inline_result = fiber.type;
+ JSCompiler_inline_result =
+ "AndroidTextInput" === JSCompiler_inline_result ||
+ "RCTMultilineTextInputView" === JSCompiler_inline_result ||
+ "RCTSinglelineTextInputView" === JSCompiler_inline_result ||
+ "RCTText" === JSCompiler_inline_result ||
+ "RCTVirtualText" === JSCompiler_inline_result;
+ JSCompiler_inline_result =
+ context.isInAParentText !== JSCompiler_inline_result
+ ? { isInAParentText: JSCompiler_inline_result }
: context;
- context !== nextContext &&
+ context !== JSCompiler_inline_result &&
(push(contextFiberStackCursor, fiber),
- push(contextStackCursor$1, nextContext));
+ push(contextStackCursor$1, JSCompiler_inline_result));
}
function popHostContext(fiber) {
contextFiberStackCursor.current === fiber &&
(pop(contextStackCursor$1), pop(contextFiberStackCursor));
}
-var suspenseStackCursor = { current: 0 };
+var suspenseStackCursor = createCursor(0);
function findFirstSuspended(row) {
for (var node = row; null !== node; ) {
if (13 === node.tag) {
@@ -3103,13 +3358,20 @@ function findFirstSuspended(row) {
function createDeprecatedResponderListener(responder, props) {
return { responder: responder, props: props };
}
-var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
+var workInProgressSources = [];
+function resetWorkInProgressVersions() {
+ for (var i = 0; i < workInProgressSources.length; i++)
+ workInProgressSources[i]._workInProgressVersionPrimary = null;
+ workInProgressSources.length = 0;
+}
+var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig,
- renderExpirationTime = 0,
+ renderLanes = 0,
currentlyRenderingFiber$1 = null,
currentHook = null,
workInProgressHook = null,
- didScheduleRenderPhaseUpdate = !1;
+ didScheduleRenderPhaseUpdate = !1,
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
function throwInvalidHookError() {
throw Error(
"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."
@@ -3127,36 +3389,36 @@ function renderWithHooks(
Component,
props,
secondArg,
- nextRenderExpirationTime
+ nextRenderLanes
) {
- renderExpirationTime = nextRenderExpirationTime;
+ renderLanes = nextRenderLanes;
currentlyRenderingFiber$1 = workInProgress;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- workInProgress.expirationTime = 0;
- ReactCurrentDispatcher.current =
+ workInProgress.lanes = 0;
+ ReactCurrentDispatcher$1.current =
null === current || null === current.memoizedState
? HooksDispatcherOnMount
: HooksDispatcherOnUpdate;
current = Component(props, secondArg);
- if (workInProgress.expirationTime === renderExpirationTime) {
- nextRenderExpirationTime = 0;
+ if (didScheduleRenderPhaseUpdateDuringThisPass) {
+ nextRenderLanes = 0;
do {
- workInProgress.expirationTime = 0;
- if (!(25 > nextRenderExpirationTime))
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ if (!(25 > nextRenderLanes))
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
- nextRenderExpirationTime += 1;
+ nextRenderLanes += 1;
workInProgressHook = currentHook = null;
workInProgress.updateQueue = null;
- ReactCurrentDispatcher.current = HooksDispatcherOnRerender;
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender;
current = Component(props, secondArg);
- } while (workInProgress.expirationTime === renderExpirationTime);
+ } while (didScheduleRenderPhaseUpdateDuringThisPass);
}
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
workInProgress = null !== currentHook && null !== currentHook.next;
- renderExpirationTime = 0;
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
didScheduleRenderPhaseUpdate = !1;
if (workInProgress)
@@ -3237,40 +3499,40 @@ function updateReducer(reducer) {
var newBaseQueueLast = (baseFirst = pendingQueue = null),
update = baseQueue;
do {
- var updateExpirationTime = update.expirationTime;
- if (updateExpirationTime < renderExpirationTime) {
- var clone = {
- expirationTime: update.expirationTime,
- suspenseConfig: update.suspenseConfig,
- action: update.action,
- eagerReducer: update.eagerReducer,
- eagerState: update.eagerState,
- next: null
- };
- null === newBaseQueueLast
- ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current))
- : (newBaseQueueLast = newBaseQueueLast.next = clone);
- updateExpirationTime > currentlyRenderingFiber$1.expirationTime &&
- ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime),
- markUnprocessedUpdateTime(updateExpirationTime));
- } else
- null !== newBaseQueueLast &&
- (newBaseQueueLast = newBaseQueueLast.next = {
- expirationTime: 1073741823,
- suspenseConfig: update.suspenseConfig,
+ var suspenseConfig = update.suspenseConfig,
+ updateLane = update.lane,
+ updateEventTime = update.eventTime;
+ (renderLanes & updateLane) === updateLane
+ ? (null !== newBaseQueueLast &&
+ (newBaseQueueLast = newBaseQueueLast.next = {
+ eventTime: updateEventTime,
+ lane: 0,
+ suspenseConfig: update.suspenseConfig,
+ action: update.action,
+ eagerReducer: update.eagerReducer,
+ eagerState: update.eagerState,
+ next: null
+ }),
+ markRenderEventTimeAndConfig(updateEventTime, suspenseConfig),
+ (current =
+ update.eagerReducer === reducer
+ ? update.eagerState
+ : reducer(current, update.action)))
+ : ((suspenseConfig = {
+ eventTime: updateEventTime,
+ lane: updateLane,
+ suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
next: null
}),
- markRenderEventTimeAndConfig(
- updateExpirationTime,
- update.suspenseConfig
- ),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ null === newBaseQueueLast
+ ? ((baseFirst = newBaseQueueLast = suspenseConfig),
+ (pendingQueue = current))
+ : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig),
+ (currentlyRenderingFiber$1.lanes |= updateLane),
+ (workInProgressRootSkippedLanes |= updateLane));
update = update.next;
} while (null !== update && update !== baseQueue);
null === newBaseQueueLast
@@ -3307,6 +3569,117 @@ function rerenderReducer(reducer) {
}
return [newState, dispatch];
}
+function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+ var getVersion = source._getVersion;
+ getVersion = getVersion(source._source);
+ var JSCompiler_inline_result = source._workInProgressVersionPrimary;
+ if (null !== JSCompiler_inline_result)
+ root = JSCompiler_inline_result === getVersion;
+ else if (
+ ((root = root.mutableReadLanes), (root = (renderLanes & root) === root))
+ )
+ (source._workInProgressVersionPrimary = getVersion),
+ workInProgressSources.push(source);
+ if (root) return getSnapshot(source._source);
+ workInProgressSources.push(source);
+ throw Error(
+ "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
+ );
+}
+function useMutableSource(hook, source, getSnapshot, subscribe) {
+ var root = workInProgressRoot;
+ if (null === root)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ var getVersion = source._getVersion,
+ version = getVersion(source._source),
+ dispatcher = ReactCurrentDispatcher$1.current,
+ _dispatcher$useState = dispatcher.useState(function() {
+ return readFromUnsubcribedMutableSource(root, source, getSnapshot);
+ }),
+ setSnapshot = _dispatcher$useState[1],
+ snapshot = _dispatcher$useState[0];
+ _dispatcher$useState = workInProgressHook;
+ var memoizedState = hook.memoizedState,
+ refs = memoizedState.refs,
+ prevGetSnapshot = refs.getSnapshot,
+ prevSource = memoizedState.source;
+ memoizedState = memoizedState.subscribe;
+ var fiber = currentlyRenderingFiber$1;
+ hook.memoizedState = { refs: refs, source: source, subscribe: subscribe };
+ dispatcher.useEffect(
+ function() {
+ refs.getSnapshot = getSnapshot;
+ refs.setSnapshot = setSnapshot;
+ var maybeNewVersion = getVersion(source._source);
+ if (!objectIs(version, maybeNewVersion)) {
+ maybeNewVersion = getSnapshot(source._source);
+ objectIs(snapshot, maybeNewVersion) ||
+ (setSnapshot(maybeNewVersion),
+ (maybeNewVersion = requestUpdateLane(
+ fiber,
+ ReactCurrentBatchConfig.suspense
+ )),
+ (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes));
+ maybeNewVersion = root.mutableReadLanes;
+ root.entangledLanes |= maybeNewVersion;
+ for (
+ var entanglements = root.entanglements, lanes = maybeNewVersion;
+ 0 < lanes;
+
+ ) {
+ var index$14 = 31 - clz32(lanes),
+ lane = 1 << index$14;
+ entanglements[index$14] |= maybeNewVersion;
+ lanes &= ~lane;
+ }
+ }
+ },
+ [getSnapshot, source, subscribe]
+ );
+ dispatcher.useEffect(
+ function() {
+ return subscribe(source._source, function() {
+ var latestGetSnapshot = refs.getSnapshot,
+ latestSetSnapshot = refs.setSnapshot;
+ try {
+ latestSetSnapshot(latestGetSnapshot(source._source));
+ var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense);
+ root.mutableReadLanes |= lane & root.pendingLanes;
+ } catch (error) {
+ latestSetSnapshot(function() {
+ throw error;
+ });
+ }
+ });
+ },
+ [source, subscribe]
+ );
+ (objectIs(prevGetSnapshot, getSnapshot) &&
+ objectIs(prevSource, source) &&
+ objectIs(memoizedState, subscribe)) ||
+ ((hook = {
+ pending: null,
+ dispatch: null,
+ lastRenderedReducer: basicStateReducer,
+ lastRenderedState: snapshot
+ }),
+ (hook.dispatch = setSnapshot = dispatchAction.bind(
+ null,
+ currentlyRenderingFiber$1,
+ hook
+ )),
+ (_dispatcher$useState.queue = hook),
+ (_dispatcher$useState.baseQueue = null),
+ (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)),
+ (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot));
+ return snapshot;
+}
+function updateMutableSource(source, getSnapshot, subscribe) {
+ var hook = updateWorkInProgressHook();
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
@@ -3455,11 +3828,12 @@ function startTransition(setPending, config, callback) {
});
}
function dispatchAction(fiber, queue, action) {
- var currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
+ var eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(fiber, suspenseConfig);
suspenseConfig = {
- expirationTime: currentTime,
+ eventTime: eventTime,
+ lane: lane,
suspenseConfig: suspenseConfig,
action: action,
eagerReducer: null,
@@ -3476,13 +3850,11 @@ function dispatchAction(fiber, queue, action) {
fiber === currentlyRenderingFiber$1 ||
(null !== pending && pending === currentlyRenderingFiber$1)
)
- (didScheduleRenderPhaseUpdate = !0),
- (suspenseConfig.expirationTime = renderExpirationTime),
- (currentlyRenderingFiber$1.expirationTime = renderExpirationTime);
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
else {
if (
- 0 === fiber.expirationTime &&
- (null === pending || 0 === pending.expirationTime) &&
+ 0 === fiber.lanes &&
+ (null === pending || 0 === pending.lanes) &&
((pending = queue.lastRenderedReducer), null !== pending)
)
try {
@@ -3494,10 +3866,9 @@ function dispatchAction(fiber, queue, action) {
} catch (error) {
} finally {
}
- scheduleWork(fiber, currentTime);
+ scheduleUpdateOnFiber(fiber, lane, eventTime);
}
}
-function updateEventListener() {}
var ContextOnlyDispatcher = {
readContext: readContext,
useCallback: throwInvalidHookError,
@@ -3513,7 +3884,9 @@ var ContextOnlyDispatcher = {
useResponder: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
- useEvent: throwInvalidHookError
+ useMutableSource: throwInvalidHookError,
+ useOpaqueIdentifier: throwInvalidHookError,
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
readContext: readContext,
@@ -3595,7 +3968,19 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: function() {}
+ useMutableSource: function(source, getSnapshot, subscribe) {
+ var hook = mountWorkInProgressHook();
+ hook.memoizedState = {
+ refs: { getSnapshot: getSnapshot, setSnapshot: null },
+ source: source,
+ subscribe: subscribe
+ };
+ return useMutableSource(hook, source, getSnapshot, subscribe);
+ },
+ useOpaqueIdentifier: function() {
+ throw Error("Not yet implemented");
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnUpdate = {
readContext: readContext,
@@ -3643,7 +4028,11 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return updateReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
readContext: readContext,
@@ -3691,7 +4080,11 @@ var ContextOnlyDispatcher = {
isPending
];
},
- useEvent: updateEventListener
+ useMutableSource: updateMutableSource,
+ useOpaqueIdentifier: function() {
+ return rerenderReducer(basicStateReducer)[0];
+ },
+ unstable_isNewReconciler: !1
},
now$1 = Scheduler.unstable_now,
commitTime = 0,
@@ -3704,27 +4097,21 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
profilerStartTime = -1;
}
}
+function transferActualDuration(fiber) {
+ for (var child = fiber.child; child; )
+ (fiber.actualDuration += child.actualDuration), (child = child.sibling);
+}
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
didReceiveUpdate = !1;
-function reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
-) {
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
workInProgress.child =
null === current
- ? mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderExpirationTime
- )
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
: reconcileChildFibers(
workInProgress,
current.child,
nextChildren,
- renderExpirationTime
+ renderLanes
);
}
function updateForwardRef(
@@ -3732,33 +4119,28 @@ function updateForwardRef(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
Component = Component.render;
var ref = workInProgress.ref;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
nextProps = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
ref,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, nextProps, renderExpirationTime);
+ reconcileChildren(current, workInProgress, nextProps, renderLanes);
return workInProgress.child;
}
function updateMemoComponent(
@@ -3766,8 +4148,8 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
if (null === current) {
var type = Component.type;
@@ -3786,8 +4168,8 @@ function updateMemoComponent(
workInProgress,
type,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
current = createFiberFromTypeAndProps(
@@ -3796,7 +4178,7 @@ function updateMemoComponent(
nextProps,
null,
workInProgress.mode,
- renderExpirationTime
+ renderLanes
);
current.ref = workInProgress.ref;
current.return = workInProgress;
@@ -3804,18 +4186,13 @@ function updateMemoComponent(
}
type = current.child;
if (
- updateExpirationTime < renderExpirationTime &&
- ((updateExpirationTime = type.memoizedProps),
+ 0 === (updateLanes & renderLanes) &&
+ ((updateLanes = type.memoizedProps),
(Component = Component.compare),
(Component = null !== Component ? Component : shallowEqual),
- Component(updateExpirationTime, nextProps) &&
- current.ref === workInProgress.ref)
+ Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
)
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
workInProgress.effectTag |= 1;
current = createWorkInProgress(type, nextProps);
current.ref = workInProgress.ref;
@@ -3827,26 +4204,66 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
) {
- return null !== current &&
+ if (
+ null !== current &&
shallowEqual(current.memoizedProps, nextProps) &&
- current.ref === workInProgress.ref &&
- ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime)
- ? ((workInProgress.expirationTime = current.expirationTime),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- ))
- : updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
+ current.ref === workInProgress.ref
+ )
+ if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes)))
+ 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0);
+ else
+ return (
+ (workInProgress.lanes = current.lanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
+}
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
+ nextChildren = nextProps.children,
+ prevState = null !== current ? current.memoizedState : null;
+ if (
+ "hidden" === nextProps.mode ||
+ "unstable-defer-without-hiding" === nextProps.mode
+ )
+ if (0 === (workInProgress.mode & 4))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(workInProgress, renderLanes);
+ else if (0 !== (renderLanes & 1073741824))
+ (workInProgress.memoizedState = { baseLanes: 0 }),
+ pushRenderLanes(
+ workInProgress,
+ null !== prevState ? prevState.baseLanes : renderLanes
+ );
+ else
+ return (
+ (current =
+ null !== prevState ? prevState.baseLanes | renderLanes : renderLanes),
+ null === spawnedWorkDuringRender
+ ? (spawnedWorkDuringRender = [1073741824])
+ : spawnedWorkDuringRender.push(1073741824),
+ (workInProgress.lanes = workInProgress.childLanes = 1073741824),
+ (workInProgress.memoizedState = { baseLanes: current }),
+ pushRenderLanes(workInProgress, current),
+ null
+ );
+ else
+ null !== prevState
+ ? ((nextProps = prevState.baseLanes | renderLanes),
+ (workInProgress.memoizedState = null))
+ : (nextProps = renderLanes),
+ pushRenderLanes(workInProgress, nextProps);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
}
function markRef(current, workInProgress) {
var ref = workInProgress.ref;
@@ -3861,35 +4278,30 @@ function updateFunctionComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
var context = isContextProvider(Component)
? previousContext
: contextStackCursor.current;
context = getMaskedContext(workInProgress, context);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
Component = renderWithHooks(
current,
workInProgress,
Component,
nextProps,
context,
- renderExpirationTime
+ renderLanes
);
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
(workInProgress.effectTag &= -517),
- current.expirationTime <= renderExpirationTime &&
- (current.expirationTime = 0),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
workInProgress.effectTag |= 1;
- reconcileChildren(current, workInProgress, Component, renderExpirationTime);
+ reconcileChildren(current, workInProgress, Component, renderLanes);
return workInProgress.child;
}
function updateClassComponent(
@@ -3897,25 +4309,20 @@ function updateClassComponent(
workInProgress,
Component,
nextProps,
- renderExpirationTime
+ renderLanes
) {
if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
if (null === workInProgress.stateNode)
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
constructClassInstance(workInProgress, Component, nextProps),
- mountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderExpirationTime
- ),
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes),
(nextProps = !0);
else if (null === current) {
var instance = workInProgress.stateNode,
@@ -3946,12 +4353,7 @@ function updateClassComponent(
hasForceUpdate = !1;
var oldState = workInProgress.memoizedState;
instance.state = oldState;
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- );
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
oldContext = workInProgress.memoizedState;
oldProps !== nextProps ||
oldState !== oldContext ||
@@ -3996,117 +4398,111 @@ function updateClassComponent(
: ("function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4),
(nextProps = !1));
- } else
- (instance = workInProgress.stateNode),
- cloneUpdateQueue(current, workInProgress),
- (oldProps = workInProgress.memoizedProps),
- (instance.props =
- workInProgress.type === workInProgress.elementType
- ? oldProps
- : resolveDefaultProps(workInProgress.type, oldProps)),
- (oldContext = instance.context),
- (contextType = Component.contextType),
- "object" === typeof contextType && null !== contextType
- ? (contextType = readContext(contextType))
- : ((contextType = isContextProvider(Component)
- ? previousContext
- : contextStackCursor.current),
- (contextType = getMaskedContext(workInProgress, contextType))),
- (getDerivedStateFromProps = Component.getDerivedStateFromProps),
- (hasNewLifecycles =
- "function" === typeof getDerivedStateFromProps ||
- "function" === typeof instance.getSnapshotBeforeUpdate) ||
- ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
- "function" !== typeof instance.componentWillReceiveProps) ||
- ((oldProps !== nextProps || oldContext !== contextType) &&
- callComponentWillReceiveProps(
+ } else {
+ instance = workInProgress.stateNode;
+ cloneUpdateQueue(current, workInProgress);
+ oldProps = workInProgress.memoizedProps;
+ contextType =
+ workInProgress.type === workInProgress.elementType
+ ? oldProps
+ : resolveDefaultProps(workInProgress.type, oldProps);
+ instance.props = contextType;
+ hasNewLifecycles = workInProgress.pendingProps;
+ oldState = instance.context;
+ oldContext = Component.contextType;
+ "object" === typeof oldContext && null !== oldContext
+ ? (oldContext = readContext(oldContext))
+ : ((oldContext = isContextProvider(Component)
+ ? previousContext
+ : contextStackCursor.current),
+ (oldContext = getMaskedContext(workInProgress, oldContext)));
+ var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps;
+ (getDerivedStateFromProps =
+ "function" === typeof getDerivedStateFromProps$jscomp$0 ||
+ "function" === typeof instance.getSnapshotBeforeUpdate) ||
+ ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
+ "function" !== typeof instance.componentWillReceiveProps) ||
+ ((oldProps !== hasNewLifecycles || oldState !== oldContext) &&
+ callComponentWillReceiveProps(
+ workInProgress,
+ instance,
+ nextProps,
+ oldContext
+ ));
+ hasForceUpdate = !1;
+ oldState = workInProgress.memoizedState;
+ instance.state = oldState;
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
+ var newState = workInProgress.memoizedState;
+ oldProps !== hasNewLifecycles ||
+ oldState !== newState ||
+ didPerformWorkStackCursor.current ||
+ hasForceUpdate
+ ? ("function" === typeof getDerivedStateFromProps$jscomp$0 &&
+ (applyDerivedStateFromProps(
workInProgress,
- instance,
+ Component,
+ getDerivedStateFromProps$jscomp$0,
+ nextProps
+ ),
+ (newState = workInProgress.memoizedState)),
+ (contextType =
+ hasForceUpdate ||
+ checkShouldComponentUpdate(
+ workInProgress,
+ Component,
+ contextType,
nextProps,
- contextType
- )),
- (hasForceUpdate = !1),
- (oldContext = workInProgress.memoizedState),
- (instance.state = oldContext),
- processUpdateQueue(
- workInProgress,
- nextProps,
- instance,
- renderExpirationTime
- ),
- (oldState = workInProgress.memoizedState),
- oldProps !== nextProps ||
- oldContext !== oldState ||
- didPerformWorkStackCursor.current ||
- hasForceUpdate
- ? ("function" === typeof getDerivedStateFromProps &&
- (applyDerivedStateFromProps(
- workInProgress,
- Component,
- getDerivedStateFromProps,
- nextProps
- ),
- (oldState = workInProgress.memoizedState)),
- (getDerivedStateFromProps =
- hasForceUpdate ||
- checkShouldComponentUpdate(
- workInProgress,
- Component,
- oldProps,
- nextProps,
- oldContext,
- oldState,
- contextType
- ))
- ? (hasNewLifecycles ||
- ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
- "function" !== typeof instance.componentWillUpdate) ||
- ("function" === typeof instance.componentWillUpdate &&
- instance.componentWillUpdate(
- nextProps,
- oldState,
- contextType
- ),
- "function" === typeof instance.UNSAFE_componentWillUpdate &&
- instance.UNSAFE_componentWillUpdate(
- nextProps,
- oldState,
- contextType
- )),
- "function" === typeof instance.componentDidUpdate &&
- (workInProgress.effectTag |= 4),
- "function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.effectTag |= 256))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (workInProgress.memoizedProps = nextProps),
- (workInProgress.memoizedState = oldState)),
- (instance.props = nextProps),
- (instance.state = oldState),
- (instance.context = contextType),
- (nextProps = getDerivedStateFromProps))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldContext === current.memoizedState) ||
- (workInProgress.effectTag |= 256),
- (nextProps = !1));
+ oldState,
+ newState,
+ oldContext
+ ))
+ ? (getDerivedStateFromProps ||
+ ("function" !== typeof instance.UNSAFE_componentWillUpdate &&
+ "function" !== typeof instance.componentWillUpdate) ||
+ ("function" === typeof instance.componentWillUpdate &&
+ instance.componentWillUpdate(nextProps, newState, oldContext),
+ "function" === typeof instance.UNSAFE_componentWillUpdate &&
+ instance.UNSAFE_componentWillUpdate(
+ nextProps,
+ newState,
+ oldContext
+ )),
+ "function" === typeof instance.componentDidUpdate &&
+ (workInProgress.effectTag |= 4),
+ "function" === typeof instance.getSnapshotBeforeUpdate &&
+ (workInProgress.effectTag |= 256))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (workInProgress.memoizedProps = nextProps),
+ (workInProgress.memoizedState = newState)),
+ (instance.props = nextProps),
+ (instance.state = newState),
+ (instance.context = oldContext),
+ (nextProps = contextType))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.effectTag |= 256),
+ (nextProps = !1));
+ }
return finishClassComponent(
current,
workInProgress,
Component,
nextProps,
hasContext,
- renderExpirationTime
+ renderLanes
);
}
function finishClassComponent(
@@ -4115,18 +4511,14 @@ function finishClassComponent(
Component,
shouldUpdate,
hasContext,
- renderExpirationTime
+ renderLanes
) {
markRef(current, workInProgress);
var didCaptureError = 0 !== (workInProgress.effectTag & 64);
if (!shouldUpdate && !didCaptureError)
return (
hasContext && invalidateContextProvider(workInProgress, Component, !1),
- bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- )
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
shouldUpdate = workInProgress.stateNode;
ReactCurrentOwner$1.current = workInProgress;
@@ -4144,20 +4536,15 @@ function finishClassComponent(
workInProgress,
current.child,
null,
- renderExpirationTime
+ renderLanes
)),
(workInProgress.child = reconcileChildFibers(
workInProgress,
null,
didCaptureError,
- renderExpirationTime
+ renderLanes
)))
- : reconcileChildren(
- current,
- workInProgress,
- nextChildren,
- renderExpirationTime
- );
+ : reconcileChildren(current, workInProgress, nextChildren, renderLanes);
workInProgress.memoizedState = shouldUpdate.state;
hasContext && invalidateContextProvider(workInProgress, Component, !0);
return workInProgress.child;
@@ -4174,169 +4561,198 @@ function pushHostRootContext(workInProgress) {
pushTopLevelContextObject(workInProgress, root.context, !1);
pushHostContainer(workInProgress, root.containerInfo);
}
-var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 };
-function updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
- var mode = workInProgress.mode,
- nextProps = workInProgress.pendingProps,
+var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
suspenseContext = suspenseStackCursor.current,
- nextDidTimeout = !1,
+ showFallback = !1,
JSCompiler_temp;
(JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) ||
(JSCompiler_temp =
- 0 !== (suspenseContext & 2) &&
- (null === current || null !== current.memoizedState));
+ null !== current && null === current.memoizedState
+ ? !1
+ : 0 !== (suspenseContext & 2));
JSCompiler_temp
- ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65))
+ ? ((showFallback = !0), (workInProgress.effectTag &= -65))
: (null !== current && null === current.memoizedState) ||
void 0 === nextProps.fallback ||
!0 === nextProps.unstable_avoidThisFallback ||
(suspenseContext |= 1);
push(suspenseStackCursor, suspenseContext & 1);
if (null === current) {
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (current = nextProps.fallback),
+ (suspenseContext = workInProgress.mode),
+ (showFallback = workInProgress.child),
+ (nextProps = { mode: "hidden", children: nextProps.children }),
+ 0 === (suspenseContext & 2) && null !== showFallback
+ ? ((showFallback.childLanes = 0),
+ (showFallback.pendingProps = nextProps),
+ workInProgress.mode & 8 &&
+ ((showFallback.actualDuration = 0),
+ (showFallback.actualStartTime = -1),
+ (showFallback.selfBaseDuration = 0),
+ (showFallback.treeBaseDuration = 0)))
+ : (showFallback = createFiberFromOffscreen(
+ nextProps,
+ suspenseContext,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
+ current,
+ suspenseContext,
+ renderLanes,
+ null
+ )),
+ (showFallback.return = workInProgress),
+ (current.return = workInProgress),
+ (showFallback.sibling = current),
+ (workInProgress.child = showFallback),
+ (workInProgress.child.memoizedState = { baseLanes: renderLanes }),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ current
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- mode = nextProps.children;
- workInProgress.memoizedState = null;
- return (workInProgress.child = mountChildFibers(
- workInProgress,
- null,
- mode,
- renderExpirationTime
- ));
+ renderLanes = createFiberFromOffscreen(
+ { mode: "visible", children: nextProps.children },
+ workInProgress.mode,
+ renderLanes,
+ null
+ );
+ renderLanes.return = workInProgress;
+ return (workInProgress.child = renderLanes);
}
if (null !== current.memoizedState) {
- current = current.child;
- mode = current.sibling;
- if (nextDidTimeout) {
- nextProps = nextProps.fallback;
- renderExpirationTime = createWorkInProgress(
- current,
- current.pendingProps
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- if (
- 0 === (workInProgress.mode & 2) &&
- ((nextDidTimeout =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child),
- nextDidTimeout !== current.child)
- )
- for (
- renderExpirationTime.child = nextDidTimeout;
- null !== nextDidTimeout;
-
- )
- (nextDidTimeout.return = renderExpirationTime),
- (nextDidTimeout = nextDidTimeout.sibling);
- if (workInProgress.mode & 8) {
- nextDidTimeout = 0;
- for (current = renderExpirationTime.child; null !== current; )
- (nextDidTimeout += current.treeBaseDuration),
- (current = current.sibling);
- renderExpirationTime.treeBaseDuration = nextDidTimeout;
- }
- mode = createWorkInProgress(mode, nextProps);
- mode.return = workInProgress;
- renderExpirationTime.sibling = mode;
- renderExpirationTime.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = renderExpirationTime;
- return mode;
- }
- renderExpirationTime = reconcileChildFibers(
+ renderLanes = updateSuspensePrimaryChildren(
+ current,
workInProgress,
- current.child,
nextProps.children,
- renderExpirationTime
+ renderLanes
);
workInProgress.memoizedState = null;
- return (workInProgress.child = renderExpirationTime);
+ return renderLanes;
}
- current = current.child;
- if (nextDidTimeout) {
- nextDidTimeout = nextProps.fallback;
- nextProps = createFiberFromFragment(null, mode, 0, null);
- nextProps.return = workInProgress;
- nextProps.child = current;
- null !== current && (current.return = nextProps);
- if (0 === (workInProgress.mode & 2))
- for (
- current =
- null !== workInProgress.memoizedState
- ? workInProgress.child.child
- : workInProgress.child,
- nextProps.child = current;
- null !== current;
-
- )
- (current.return = nextProps), (current = current.sibling);
- if (workInProgress.mode & 8) {
- current = 0;
- for (suspenseContext = nextProps.child; null !== suspenseContext; )
- (current += suspenseContext.treeBaseDuration),
- (suspenseContext = suspenseContext.sibling);
- nextProps.treeBaseDuration = current;
- }
- renderExpirationTime = createFiberFromFragment(
- nextDidTimeout,
- mode,
- renderExpirationTime,
- null
+ if (showFallback)
+ return (
+ (nextProps = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (suspenseContext = workInProgress.child),
+ (showFallback = current.child.memoizedState),
+ (suspenseContext.memoizedState =
+ null === showFallback
+ ? { baseLanes: renderLanes }
+ : { baseLanes: showFallback.baseLanes | renderLanes }),
+ (suspenseContext.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ nextProps
);
- renderExpirationTime.return = workInProgress;
- nextProps.sibling = renderExpirationTime;
- renderExpirationTime.effectTag |= 2;
- nextProps.childExpirationTime = 0;
- workInProgress.memoizedState = SUSPENDED_MARKER;
- workInProgress.child = nextProps;
- return renderExpirationTime;
- }
- workInProgress.memoizedState = null;
- return (workInProgress.child = reconcileChildFibers(
- workInProgress,
+ renderLanes = updateSuspensePrimaryChildren(
current,
+ workInProgress,
nextProps.children,
- renderExpirationTime
- ));
+ renderLanes
+ );
+ workInProgress.memoizedState = null;
+ return renderLanes;
}
-function scheduleWorkOnFiber(fiber, renderExpirationTime) {
- fiber.expirationTime < renderExpirationTime &&
- (fiber.expirationTime = renderExpirationTime);
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ primaryChildren = createWorkInProgress(currentPrimaryChildFragment, {
+ mode: "visible",
+ children: primaryChildren
+ });
+ 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes);
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = null;
+ null !== current &&
+ ((current.nextEffect = null),
+ (current.effectTag = 8),
+ (workInProgress.firstEffect = workInProgress.lastEffect = current));
+ return (workInProgress.child = primaryChildren);
+}
+function updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode,
+ currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ var primaryChildProps = { mode: "hidden", children: primaryChildren };
+ 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment
+ ? ((primaryChildren = workInProgress.child),
+ (primaryChildren.childLanes = 0),
+ (primaryChildren.pendingProps = primaryChildProps),
+ workInProgress.mode & 8 &&
+ ((primaryChildren.actualDuration = 0),
+ (primaryChildren.actualStartTime = -1),
+ (primaryChildren.selfBaseDuration =
+ currentPrimaryChildFragment.selfBaseDuration),
+ (primaryChildren.treeBaseDuration =
+ currentPrimaryChildFragment.treeBaseDuration)),
+ (currentPrimaryChildFragment = primaryChildren.lastEffect),
+ null !== currentPrimaryChildFragment
+ ? ((workInProgress.firstEffect = primaryChildren.firstEffect),
+ (workInProgress.lastEffect = currentPrimaryChildFragment),
+ (currentPrimaryChildFragment.nextEffect = null))
+ : (workInProgress.firstEffect = workInProgress.lastEffect = null))
+ : (primaryChildren = createWorkInProgress(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ ));
+ null !== current
+ ? (fallbackChildren = createWorkInProgress(current, fallbackChildren))
+ : ((fallbackChildren = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ )),
+ (fallbackChildren.effectTag |= 2));
+ fallbackChildren.return = workInProgress;
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = fallbackChildren;
+ workInProgress.child = primaryChildren;
+ return fallbackChildren;
+}
+function scheduleWorkOnFiber(fiber, renderLanes) {
+ fiber.lanes |= renderLanes;
var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < renderExpirationTime &&
- (alternate.expirationTime = renderExpirationTime);
- scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
+ null !== alternate && (alternate.lanes |= renderLanes);
+ scheduleWorkOnParentPath(fiber.return, renderLanes);
}
function initSuspenseListRenderState(
workInProgress,
@@ -4367,20 +4783,11 @@ function initSuspenseListRenderState(
(renderState.tailMode = tailMode),
(renderState.lastEffect = lastEffectBeforeRendering));
}
-function updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps,
revealOrder = nextProps.revealOrder,
tailMode = nextProps.tail;
- reconcileChildren(
- current,
- workInProgress,
- nextProps.children,
- renderExpirationTime
- );
+ reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
nextProps = suspenseStackCursor.current;
if (0 !== (nextProps & 2))
(nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64);
@@ -4389,9 +4796,8 @@ function updateSuspenseListComponent(
a: for (current = workInProgress.child; null !== current; ) {
if (13 === current.tag)
null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderExpirationTime);
- else if (19 === current.tag)
- scheduleWorkOnFiber(current, renderExpirationTime);
+ scheduleWorkOnFiber(current, renderLanes);
+ else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
else if (null !== current.child) {
current.child.return = current;
current = current.child;
@@ -4413,30 +4819,29 @@ function updateSuspenseListComponent(
else
switch (revealOrder) {
case "forwards":
- renderExpirationTime = workInProgress.child;
- for (revealOrder = null; null !== renderExpirationTime; )
- (current = renderExpirationTime.alternate),
+ renderLanes = workInProgress.child;
+ for (revealOrder = null; null !== renderLanes; )
+ (current = renderLanes.alternate),
null !== current &&
null === findFirstSuspended(current) &&
- (revealOrder = renderExpirationTime),
- (renderExpirationTime = renderExpirationTime.sibling);
- renderExpirationTime = revealOrder;
- null === renderExpirationTime
+ (revealOrder = renderLanes),
+ (renderLanes = renderLanes.sibling);
+ renderLanes = revealOrder;
+ null === renderLanes
? ((revealOrder = workInProgress.child),
(workInProgress.child = null))
- : ((revealOrder = renderExpirationTime.sibling),
- (renderExpirationTime.sibling = null));
+ : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
initSuspenseListRenderState(
workInProgress,
!1,
revealOrder,
- renderExpirationTime,
+ renderLanes,
tailMode,
workInProgress.lastEffect
);
break;
case "backwards":
- renderExpirationTime = null;
+ renderLanes = null;
revealOrder = workInProgress.child;
for (workInProgress.child = null; null !== revealOrder; ) {
current = revealOrder.alternate;
@@ -4445,14 +4850,14 @@ function updateSuspenseListComponent(
break;
}
current = revealOrder.sibling;
- revealOrder.sibling = renderExpirationTime;
- renderExpirationTime = revealOrder;
+ revealOrder.sibling = renderLanes;
+ renderLanes = revealOrder;
revealOrder = current;
}
initSuspenseListRenderState(
workInProgress,
!0,
- renderExpirationTime,
+ renderLanes,
null,
tailMode,
workInProgress.lastEffect
@@ -4473,36 +4878,29 @@ function updateSuspenseListComponent(
}
return workInProgress.child;
}
-function bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
-) {
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
null !== current && (workInProgress.dependencies = current.dependencies);
profilerStartTime = -1;
- var updateExpirationTime = workInProgress.expirationTime;
- 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime);
- if (workInProgress.childExpirationTime < renderExpirationTime) return null;
- if (null !== current && workInProgress.child !== current.child)
- throw Error("Resuming work not yet implemented.");
- if (null !== workInProgress.child) {
- current = workInProgress.child;
- renderExpirationTime = createWorkInProgress(current, current.pendingProps);
- workInProgress.child = renderExpirationTime;
- for (
- renderExpirationTime.return = workInProgress;
- null !== current.sibling;
-
- )
- (current = current.sibling),
- (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress(
- current,
- current.pendingProps
- )),
- (renderExpirationTime.return = workInProgress);
- renderExpirationTime.sibling = null;
+ workInProgressRootSkippedLanes |= workInProgress.lanes;
+ if (0 !== (renderLanes & workInProgress.childLanes)) {
+ if (null !== current && workInProgress.child !== current.child)
+ throw Error("Resuming work not yet implemented.");
+ if (null !== workInProgress.child) {
+ current = workInProgress.child;
+ renderLanes = createWorkInProgress(current, current.pendingProps);
+ workInProgress.child = renderLanes;
+ for (renderLanes.return = workInProgress; null !== current.sibling; )
+ (current = current.sibling),
+ (renderLanes = renderLanes.sibling = createWorkInProgress(
+ current,
+ current.pendingProps
+ )),
+ (renderLanes.return = workInProgress);
+ renderLanes.sibling = null;
+ }
+ return workInProgress.child;
}
- return workInProgress.child;
+ return null;
}
var appendAllChildren,
updateHostContainer,
@@ -4549,17 +4947,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
break;
case "collapsed":
lastTailNode = renderState.tail;
- for (var _lastTailNode = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (_lastTailNode = lastTailNode),
+ for (var lastTailNode$65 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode),
(lastTailNode = lastTailNode.sibling);
- null === _lastTailNode
+ null === lastTailNode$65
? hasRenderedATailFallback || null === renderState.tail
? (renderState.tail = null)
: (renderState.tail.sibling = null)
- : (_lastTailNode.sibling = null);
+ : (lastTailNode$65.sibling = null);
}
}
-function completeWork(current, workInProgress, renderExpirationTime) {
+function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
case 2:
@@ -4580,10 +4978,14 @@ function completeWork(current, workInProgress, renderExpirationTime) {
popHostContainer(),
pop(didPerformWorkStackCursor),
pop(contextStackCursor),
- (current = workInProgress.stateNode),
- current.pendingContext &&
- ((current.context = current.pendingContext),
- (current.pendingContext = null)),
+ resetWorkInProgressVersions(),
+ (newProps = workInProgress.stateNode),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ newProps.hydrate ||
+ (workInProgress.effectTag |= 256),
updateHostContainer(workInProgress),
null
);
@@ -4592,12 +4994,12 @@ function completeWork(current, workInProgress, renderExpirationTime) {
var rootContainerInstance = requiredContext(
rootInstanceStackCursor.current
);
- renderExpirationTime = workInProgress.type;
+ renderLanes = workInProgress.type;
if (null !== current && null != workInProgress.stateNode)
updateHostComponent$1(
current,
workInProgress,
- renderExpirationTime,
+ renderLanes,
newProps,
rootContainerInstance
),
@@ -4613,22 +5015,22 @@ function completeWork(current, workInProgress, renderExpirationTime) {
}
requiredContext(contextStackCursor$1.current);
current = allocateTag();
- renderExpirationTime = getViewConfigForType(renderExpirationTime);
+ renderLanes = getViewConfigForType(renderLanes);
var updatePayload = diffProperties(
null,
emptyObject,
newProps,
- renderExpirationTime.validAttributes
+ renderLanes.validAttributes
);
ReactNativePrivateInterface.UIManager.createView(
current,
- renderExpirationTime.uiViewClassName,
+ renderLanes.uiViewClassName,
rootContainerInstance,
updatePayload
);
rootContainerInstance = new ReactNativeFiberHostComponent(
current,
- renderExpirationTime,
+ renderLanes,
workInProgress
);
instanceCache.set(current, workInProgress);
@@ -4674,48 +5076,36 @@ function completeWork(current, workInProgress, renderExpirationTime) {
newProps = workInProgress.memoizedState;
if (0 !== (workInProgress.effectTag & 64))
return (
- (workInProgress.expirationTime = renderExpirationTime), workInProgress
+ (workInProgress.lanes = renderLanes),
+ 0 !== (workInProgress.mode & 8) &&
+ transferActualDuration(workInProgress),
+ workInProgress
);
newProps = null !== newProps;
rootContainerInstance = !1;
null !== current &&
- ((renderExpirationTime = current.memoizedState),
- (rootContainerInstance = null !== renderExpirationTime),
- newProps ||
- null === renderExpirationTime ||
- ((renderExpirationTime = current.child.sibling),
- null !== renderExpirationTime &&
- ((updatePayload = workInProgress.firstEffect),
- null !== updatePayload
- ? ((workInProgress.firstEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = updatePayload))
- : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime),
- (renderExpirationTime.nextEffect = null)),
- (renderExpirationTime.effectTag = 8))));
+ (rootContainerInstance = null !== current.memoizedState);
if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2))
if (
(null === current &&
!0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
0 !== (suspenseStackCursor.current & 1)
)
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootSuspended);
+ 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3);
else {
if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus
)
- workInProgressRootExitStatus = RootSuspendedWithDelay;
- 0 !== workInProgressRootNextUnprocessedUpdateTime &&
- null !== workInProgressRoot &&
- (markRootSuspendedAtTime(
- workInProgressRoot,
- renderExpirationTime$1
- ),
- markRootUpdatedAtTime(
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 134217727) &&
+ 0 === (workInProgressRootUpdatedLanes & 134217727)) ||
+ markRootSuspended$1(
workInProgressRoot,
- workInProgressRootNextUnprocessedUpdateTime
- ));
+ workInProgressRootRenderLanes
+ );
}
if (newProps || rootContainerInstance) workInProgress.effectTag |= 4;
return null;
@@ -4735,7 +5125,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1);
else {
if (
- workInProgressRootExitStatus !== RootIncomplete ||
+ 0 !== workInProgressRootExitStatus ||
(null !== current && 0 !== (current.effectTag & 64))
)
for (current = workInProgress.child; null !== current; ) {
@@ -4750,7 +5140,7 @@ function completeWork(current, workInProgress, renderExpirationTime) {
null === newProps.lastEffect &&
(workInProgress.firstEffect = null);
workInProgress.lastEffect = newProps.lastEffect;
- current = renderExpirationTime;
+ current = renderLanes;
for (newProps = workInProgress.child; null !== newProps; )
(rootContainerInstance = newProps),
(updatePayload = current),
@@ -4758,42 +5148,42 @@ function completeWork(current, workInProgress, renderExpirationTime) {
(rootContainerInstance.nextEffect = null),
(rootContainerInstance.firstEffect = null),
(rootContainerInstance.lastEffect = null),
- (renderExpirationTime = rootContainerInstance.alternate),
- null === renderExpirationTime
- ? ((rootContainerInstance.childExpirationTime = 0),
- (rootContainerInstance.expirationTime = updatePayload),
+ (renderLanes = rootContainerInstance.alternate),
+ null === renderLanes
+ ? ((rootContainerInstance.childLanes = 0),
+ (rootContainerInstance.lanes = updatePayload),
(rootContainerInstance.child = null),
(rootContainerInstance.memoizedProps = null),
(rootContainerInstance.memoizedState = null),
(rootContainerInstance.updateQueue = null),
(rootContainerInstance.dependencies = null),
+ (rootContainerInstance.stateNode = null),
(rootContainerInstance.selfBaseDuration = 0),
(rootContainerInstance.treeBaseDuration = 0))
- : ((rootContainerInstance.childExpirationTime =
- renderExpirationTime.childExpirationTime),
- (rootContainerInstance.expirationTime =
- renderExpirationTime.expirationTime),
- (rootContainerInstance.child =
- renderExpirationTime.child),
+ : ((rootContainerInstance.childLanes =
+ renderLanes.childLanes),
+ (rootContainerInstance.lanes = renderLanes.lanes),
+ (rootContainerInstance.child = renderLanes.child),
(rootContainerInstance.memoizedProps =
- renderExpirationTime.memoizedProps),
+ renderLanes.memoizedProps),
(rootContainerInstance.memoizedState =
- renderExpirationTime.memoizedState),
+ renderLanes.memoizedState),
(rootContainerInstance.updateQueue =
- renderExpirationTime.updateQueue),
- (updatePayload = renderExpirationTime.dependencies),
+ renderLanes.updateQueue),
+ (rootContainerInstance.type = renderLanes.type),
+ (updatePayload = renderLanes.dependencies),
(rootContainerInstance.dependencies =
null === updatePayload
? null
: {
- expirationTime: updatePayload.expirationTime,
+ lanes: updatePayload.lanes,
firstContext: updatePayload.firstContext,
responders: updatePayload.responders
}),
(rootContainerInstance.selfBaseDuration =
- renderExpirationTime.selfBaseDuration),
+ renderLanes.selfBaseDuration),
(rootContainerInstance.treeBaseDuration =
- renderExpirationTime.treeBaseDuration)),
+ renderLanes.treeBaseDuration)),
(newProps = newProps.sibling);
push(
suspenseStackCursor,
@@ -4829,15 +5219,14 @@ function completeWork(current, workInProgress, renderExpirationTime) {
);
} else
2 * now() - newProps.renderingStartTime > newProps.tailExpiration &&
- 1 < renderExpirationTime &&
+ 1073741824 !== renderLanes &&
((workInProgress.effectTag |= 64),
(rootContainerInstance = !0),
cutOffTailIfNeeded(newProps, !1),
- (current = renderExpirationTime - 1),
- (workInProgress.expirationTime = workInProgress.childExpirationTime = current),
+ (workInProgress.lanes = renderLanes),
null === spawnedWorkDuringRender
- ? (spawnedWorkDuringRender = [current])
- : spawnedWorkDuringRender.push(current));
+ ? (spawnedWorkDuringRender = [renderLanes])
+ : spawnedWorkDuringRender.push(renderLanes));
newProps.isBackwards
? ((updatePayload.sibling = workInProgress.child),
(workInProgress.child = updatePayload))
@@ -4865,6 +5254,17 @@ function completeWork(current, workInProgress, renderExpirationTime) {
),
current)
: null;
+ case 23:
+ case 24:
+ return (
+ popRenderLanes(),
+ null !== current &&
+ (null !== current.memoizedState) !==
+ (null !== workInProgress.memoizedState) &&
+ "unstable-defer-without-hiding" !== newProps.mode &&
+ (workInProgress.effectTag |= 4),
+ null
+ );
}
throw Error(
"Unknown unit of work tag (" +
@@ -4879,12 +5279,15 @@ function unwindWork(workInProgress) {
var effectTag = workInProgress.effectTag;
return effectTag & 4096
? ((workInProgress.effectTag = (effectTag & -4097) | 64),
+ 0 !== (workInProgress.mode & 8) &&
+ transferActualDuration(workInProgress),
workInProgress)
: null;
case 3:
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
effectTag = workInProgress.effectTag;
if (0 !== (effectTag & 64))
throw Error(
@@ -4900,6 +5303,8 @@ function unwindWork(workInProgress) {
(effectTag = workInProgress.effectTag),
effectTag & 4096
? ((workInProgress.effectTag = (effectTag & -4097) | 64),
+ 0 !== (workInProgress.mode & 8) &&
+ transferActualDuration(workInProgress),
workInProgress)
: null
);
@@ -4909,6 +5314,9 @@ function unwindWork(workInProgress) {
return popHostContainer(), null;
case 10:
return popProvider(workInProgress), null;
+ case 23:
+ case 24:
+ return popRenderLanes(), null;
default:
return null;
}
@@ -4927,51 +5335,61 @@ if (
throw Error(
"Expected ReactFiberErrorDialog.showErrorDialog to be a function."
);
-function logCapturedError(capturedError) {
- !1 !==
- ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog(
- capturedError
- ) && console.error(capturedError.error);
-}
-var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
-function logError(boundary, errorInfo) {
- var source = errorInfo.source,
- stack = errorInfo.stack;
- null === stack &&
- null !== source &&
- (stack = getStackByFiberInDevAndProd(source));
- errorInfo = {
- componentName: null !== source ? getComponentName(source.type) : null,
- componentStack: null !== stack ? stack : "",
- error: errorInfo.value,
- errorBoundary: null,
- errorBoundaryName: null,
- errorBoundaryFound: !1,
- willRetry: !1
- };
- null !== boundary &&
- 1 === boundary.tag &&
- ((errorInfo.errorBoundary = boundary.stateNode),
- (errorInfo.errorBoundaryName = getComponentName(boundary.type)),
- (errorInfo.errorBoundaryFound = !0),
- (errorInfo.willRetry = !0));
+function logCapturedError(boundary, errorInfo) {
try {
- logCapturedError(errorInfo);
+ !1 !==
+ ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({
+ componentStack: null !== errorInfo.stack ? errorInfo.stack : "",
+ error: errorInfo.value,
+ errorBoundary:
+ null !== boundary && 1 === boundary.tag ? boundary.stateNode : null
+ }) && console.error(errorInfo.value);
} catch (e) {
setTimeout(function() {
throw e;
});
}
}
-function safelyCallComponentWillUnmount(current, instance) {
- try {
- (instance.props = current.memoizedProps),
- (instance.state = current.memoizedState),
- instance.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(current, unmountError);
+var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
+function createRootErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ lane.payload = { element: null };
+ var error = errorInfo.value;
+ lane.callback = function() {
+ hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
+ logCapturedError(fiber, errorInfo);
+ };
+ return lane;
+}
+function createClassErrorUpdate(fiber, errorInfo, lane) {
+ lane = createUpdate(-1, lane, null);
+ lane.tag = 3;
+ var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
+ if ("function" === typeof getDerivedStateFromError) {
+ var error = errorInfo.value;
+ lane.payload = function() {
+ logCapturedError(fiber, errorInfo);
+ return getDerivedStateFromError(error);
+ };
}
+ var inst = fiber.stateNode;
+ null !== inst &&
+ "function" === typeof inst.componentDidCatch &&
+ (lane.callback = function() {
+ "function" !== typeof getDerivedStateFromError &&
+ (null === legacyErrorBoundariesThatAlreadyFailed
+ ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
+ : legacyErrorBoundariesThatAlreadyFailed.add(this),
+ logCapturedError(fiber, errorInfo));
+ var stack = errorInfo.stack;
+ this.componentDidCatch(errorInfo.value, {
+ componentStack: null !== stack ? stack : ""
+ });
+ });
+ return lane;
}
+var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set;
function safelyDetachRef(current) {
var ref = current.ref;
if (null !== ref)
@@ -5005,6 +5423,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
}
return;
case 3:
+ return;
case 5:
case 6:
case 4:
@@ -5015,58 +5434,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) {
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitHookEffectListUnmount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var destroy = effect.destroy;
- effect.destroy = void 0;
- void 0 !== destroy && destroy();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
-function commitHookEffectListMount(tag, finishedWork) {
- finishedWork = finishedWork.updateQueue;
- finishedWork = null !== finishedWork ? finishedWork.lastEffect : null;
- if (null !== finishedWork) {
- var effect = (finishedWork = finishedWork.next);
- do {
- if ((effect.tag & tag) === tag) {
- var create = effect.create;
- effect.destroy = create();
- }
- effect = effect.next;
- } while (effect !== finishedWork);
- }
-}
function commitLifeCycles(finishedRoot, current, finishedWork) {
switch (finishedWork.tag) {
case 0:
case 11:
case 15:
case 22:
- commitHookEffectListMount(3, finishedWork);
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ if (3 === (finishedRoot.tag & 3)) {
+ var create$82 = finishedRoot.create;
+ finishedRoot.destroy = create$82();
+ }
+ finishedRoot = finishedRoot.next;
+ } while (finishedRoot !== current);
+ }
+ current = finishedWork.updateQueue;
+ current = null !== current ? current.lastEffect : null;
+ if (null !== current) {
+ finishedRoot = current = current.next;
+ do {
+ var _effect = finishedRoot;
+ create$82 = _effect.next;
+ _effect = _effect.tag;
+ 0 !== (_effect & 4) &&
+ 0 !== (_effect & 1) &&
+ (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot),
+ enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot));
+ finishedRoot = create$82;
+ } while (finishedRoot !== current);
+ }
return;
case 1:
finishedRoot = finishedWork.stateNode;
- if (finishedWork.effectTag & 4)
- if (null === current) finishedRoot.componentDidMount();
- else {
- var prevProps =
- finishedWork.elementType === finishedWork.type
- ? current.memoizedProps
- : resolveDefaultProps(finishedWork.type, current.memoizedProps);
- finishedRoot.componentDidUpdate(
- prevProps,
- current.memoizedState,
- finishedRoot.__reactInternalSnapshotBeforeUpdate
- );
- }
+ finishedWork.effectTag & 4 &&
+ (null === current
+ ? finishedRoot.componentDidMount()
+ : ((create$82 =
+ finishedWork.elementType === finishedWork.type
+ ? current.memoizedProps
+ : resolveDefaultProps(
+ finishedWork.type,
+ current.memoizedProps
+ )),
+ finishedRoot.componentDidUpdate(
+ create$82,
+ current.memoizedState,
+ finishedRoot.__reactInternalSnapshotBeforeUpdate
+ )));
current = finishedWork.updateQueue;
null !== current &&
commitUpdateQueue(finishedWork, current, finishedRoot);
@@ -5093,16 +5511,16 @@ function commitLifeCycles(finishedRoot, current, finishedWork) {
case 4:
return;
case 12:
- prevProps = finishedWork.memoizedProps.onRender;
- var commitTime$jscomp$0 = commitTime;
- "function" === typeof prevProps &&
- prevProps(
+ create$82 = finishedWork.memoizedProps.onRender;
+ _effect = commitTime;
+ "function" === typeof create$82 &&
+ create$82(
finishedWork.memoizedProps.id,
null === current ? "mount" : "update",
finishedWork.actualDuration,
finishedWork.treeBaseDuration,
finishedWork.actualStartTime,
- commitTime$jscomp$0,
+ _effect,
finishedRoot.memoizedInteractions
);
return;
@@ -5112,78 +5530,139 @@ function commitLifeCycles(finishedRoot, current, finishedWork) {
case 17:
case 20:
case 21:
+ case 23:
+ case 24:
return;
}
throw Error(
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
-function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) {
- "function" === typeof onCommitFiberUnmount &&
- onCommitFiberUnmount(current$jscomp$0);
- switch (current$jscomp$0.tag) {
+function hideOrUnhideAllChildren(finishedWork, isHidden) {
+ for (var node = finishedWork; ; ) {
+ if (5 === node.tag) {
+ var instance = node.stateNode;
+ if (isHidden) {
+ var viewConfig = instance.viewConfig;
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ { style: { display: "none" } },
+ viewConfig.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance._nativeTag,
+ viewConfig.uiViewClassName,
+ updatePayload
+ );
+ } else {
+ instance = node.stateNode;
+ updatePayload = node.memoizedProps;
+ viewConfig = instance.viewConfig;
+ var prevProps = Object.assign({}, updatePayload, {
+ style: [updatePayload.style, { display: "none" }]
+ });
+ updatePayload = diffProperties(
+ null,
+ prevProps,
+ updatePayload,
+ viewConfig.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance._nativeTag,
+ viewConfig.uiViewClassName,
+ updatePayload
+ );
+ }
+ } else {
+ if (6 === node.tag) throw Error("Not yet implemented.");
+ if (
+ ((23 !== node.tag && 24 !== node.tag) ||
+ null === node.memoizedState ||
+ node === finishedWork) &&
+ null !== node.child
+ ) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ }
+ if (node === finishedWork) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === finishedWork) return;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+}
+function commitUnmount(finishedRoot, current) {
+ if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount)
+ try {
+ injectedHook.onCommitFiberUnmount(rendererID, current);
+ } catch (err) {}
+ switch (current.tag) {
case 0:
case 11:
case 14:
case 15:
case 22:
- finishedRoot = current$jscomp$0.updateQueue;
+ finishedRoot = current.updateQueue;
if (
null !== finishedRoot &&
((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot)
) {
- var firstEffect = finishedRoot.next;
- runWithPriority(
- 97 < renderPriorityLevel ? 97 : renderPriorityLevel,
- function() {
- var effect = firstEffect;
- do {
- var _destroy = effect.destroy;
- if (void 0 !== _destroy) {
- var current = current$jscomp$0;
- try {
- _destroy();
- } catch (error) {
- captureCommitPhaseError(current, error);
- }
+ var effect = (finishedRoot = finishedRoot.next);
+ do {
+ var _effect2 = effect,
+ destroy = _effect2.destroy;
+ _effect2 = _effect2.tag;
+ if (void 0 !== destroy)
+ if (0 !== (_effect2 & 4))
+ enqueuePendingPassiveHookEffectUnmount(current, effect);
+ else {
+ _effect2 = current;
+ try {
+ destroy();
+ } catch (error) {
+ captureCommitPhaseError(_effect2, error);
}
- effect = effect.next;
- } while (effect !== firstEffect);
- }
- );
+ }
+ effect = effect.next;
+ } while (effect !== finishedRoot);
}
break;
case 1:
- safelyDetachRef(current$jscomp$0);
- renderPriorityLevel = current$jscomp$0.stateNode;
- "function" === typeof renderPriorityLevel.componentWillUnmount &&
- safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel);
+ safelyDetachRef(current);
+ finishedRoot = current.stateNode;
+ if ("function" === typeof finishedRoot.componentWillUnmount)
+ try {
+ (finishedRoot.props = current.memoizedProps),
+ (finishedRoot.state = current.memoizedState),
+ finishedRoot.componentWillUnmount();
+ } catch (unmountError) {
+ captureCommitPhaseError(current, unmountError);
+ }
break;
case 5:
- safelyDetachRef(current$jscomp$0);
+ safelyDetachRef(current);
break;
case 4:
- unmountHostComponents(
- finishedRoot,
- current$jscomp$0,
- renderPriorityLevel
- );
+ unmountHostComponents(finishedRoot, current);
}
}
-function detachFiber(current) {
- var alternate = current.alternate;
- current.return = null;
- current.child = null;
- current.memoizedState = null;
- current.updateQueue = null;
- current.dependencies = null;
- current.alternate = null;
- current.firstEffect = null;
- current.lastEffect = null;
- current.pendingProps = null;
- current.memoizedProps = null;
- current.stateNode = null;
- null !== alternate && detachFiber(alternate);
+function detachFiberMutation(fiber) {
+ fiber.alternate = null;
+ fiber.child = null;
+ fiber.dependencies = null;
+ fiber.firstEffect = null;
+ fiber.lastEffect = null;
+ fiber.memoizedProps = null;
+ fiber.memoizedState = null;
+ fiber.pendingProps = null;
+ fiber.return = null;
+ fiber.stateNode = null;
+ fiber.updateQueue = null;
}
function isHostParent(fiber) {
return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag;
@@ -5191,16 +5670,14 @@ function isHostParent(fiber) {
function commitPlacement(finishedWork) {
a: {
for (var parent = finishedWork.return; null !== parent; ) {
- if (isHostParent(parent)) {
- var parentFiber = parent;
- break a;
- }
+ if (isHostParent(parent)) break a;
parent = parent.return;
}
throw Error(
"Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."
);
}
+ var parentFiber = parent;
parent = parentFiber.stateNode;
switch (parentFiber.tag) {
case 5:
@@ -5335,11 +5812,7 @@ function insertOrAppendPlacementNode(node, before, parent) {
)
insertOrAppendPlacementNode(node, before, parent), (node = node.sibling);
}
-function unmountHostComponents(
- finishedRoot$jscomp$0,
- current,
- renderPriorityLevel$jscomp$0
-) {
+function unmountHostComponents(finishedRoot$jscomp$0, current) {
for (
var node = current,
currentParentIsValid = !1,
@@ -5377,13 +5850,12 @@ function unmountHostComponents(
a: for (
var finishedRoot = finishedRoot$jscomp$0,
root = node,
- renderPriorityLevel = renderPriorityLevel$jscomp$0,
node$jscomp$0 = root;
;
)
if (
- (commitUnmount(finishedRoot, node$jscomp$0, renderPriorityLevel),
+ (commitUnmount(finishedRoot, node$jscomp$0),
null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag)
)
(node$jscomp$0.child.return = node$jscomp$0),
@@ -5410,18 +5882,18 @@ function unmountHostComponents(
[0]
))
: ((finishedRoot = currentParent),
- (renderPriorityLevel = node.stateNode),
- recursivelyUncacheFiberNode(renderPriorityLevel),
+ (node$jscomp$0 = node.stateNode),
+ recursivelyUncacheFiberNode(node$jscomp$0),
(root = finishedRoot._children),
- (renderPriorityLevel = root.indexOf(renderPriorityLevel)),
- root.splice(renderPriorityLevel, 1),
+ (node$jscomp$0 = root.indexOf(node$jscomp$0)),
+ root.splice(node$jscomp$0, 1),
ReactNativePrivateInterface.UIManager.manageChildren(
finishedRoot._nativeTag,
[],
[],
[],
[],
- [renderPriorityLevel]
+ [node$jscomp$0]
));
} else if (4 === node.tag) {
if (null !== node.child) {
@@ -5432,8 +5904,7 @@ function unmountHostComponents(
continue;
}
} else if (
- (commitUnmount(finishedRoot$jscomp$0, node, renderPriorityLevel$jscomp$0),
- null !== node.child)
+ (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child)
) {
node.child.return = node;
node = node.child;
@@ -5456,31 +5927,42 @@ function commitWork(current, finishedWork) {
case 14:
case 15:
case 22:
- commitHookEffectListUnmount(3, finishedWork);
+ var updateQueue = finishedWork.updateQueue;
+ updateQueue = null !== updateQueue ? updateQueue.lastEffect : null;
+ if (null !== updateQueue) {
+ var effect = (updateQueue = updateQueue.next);
+ do
+ 3 === (effect.tag & 3) &&
+ ((finishedWork = effect.destroy),
+ (effect.destroy = void 0),
+ void 0 !== finishedWork && finishedWork()),
+ (effect = effect.next);
+ while (effect !== updateQueue);
+ }
return;
case 1:
return;
case 5:
- var instance = finishedWork.stateNode;
- if (null != instance) {
- var newProps = finishedWork.memoizedProps;
- current = null !== current ? current.memoizedProps : newProps;
+ updateQueue = finishedWork.stateNode;
+ if (null != updateQueue) {
+ effect = finishedWork.memoizedProps;
+ current = null !== current ? current.memoizedProps : effect;
var updatePayload = finishedWork.updateQueue;
finishedWork.updateQueue = null;
null !== updatePayload &&
- ((finishedWork = instance.viewConfig),
- instanceProps.set(instance._nativeTag, newProps),
- (newProps = diffProperties(
+ ((finishedWork = updateQueue.viewConfig),
+ instanceProps.set(updateQueue._nativeTag, effect),
+ (effect = diffProperties(
null,
current,
- newProps,
+ effect,
finishedWork.validAttributes
)),
- null != newProps &&
+ null != effect &&
ReactNativePrivateInterface.UIManager.updateView(
- instance._nativeTag,
+ updateQueue._nativeTag,
finishedWork.uiViewClassName,
- newProps
+ effect
));
}
return;
@@ -5500,72 +5982,9 @@ function commitWork(current, finishedWork) {
case 12:
return;
case 13:
- instance = finishedWork;
- null === finishedWork.memoizedState
- ? (newProps = !1)
- : ((newProps = !0),
- (instance = finishedWork.child),
- (globalMostRecentFallbackTime = now()));
- if (null !== instance)
- a: for (current = instance; ; ) {
- if (5 === current.tag)
- if (((updatePayload = current.stateNode), newProps)) {
- var viewConfig = updatePayload.viewConfig;
- var updatePayload$jscomp$0 = diffProperties(
- null,
- emptyObject,
- { style: { display: "none" } },
- viewConfig.validAttributes
- );
- ReactNativePrivateInterface.UIManager.updateView(
- updatePayload._nativeTag,
- viewConfig.uiViewClassName,
- updatePayload$jscomp$0
- );
- } else {
- updatePayload = current.stateNode;
- updatePayload$jscomp$0 = current.memoizedProps;
- viewConfig = updatePayload.viewConfig;
- var prevProps = Object.assign({}, updatePayload$jscomp$0, {
- style: [updatePayload$jscomp$0.style, { display: "none" }]
- });
- updatePayload$jscomp$0 = diffProperties(
- null,
- prevProps,
- updatePayload$jscomp$0,
- viewConfig.validAttributes
- );
- ReactNativePrivateInterface.UIManager.updateView(
- updatePayload._nativeTag,
- viewConfig.uiViewClassName,
- updatePayload$jscomp$0
- );
- }
- else {
- if (6 === current.tag) throw Error("Not yet implemented.");
- if (
- 13 === current.tag &&
- null !== current.memoizedState &&
- null === current.memoizedState.dehydrated
- ) {
- updatePayload = current.child.sibling;
- updatePayload.return = current;
- current = updatePayload;
- continue;
- } else if (null !== current.child) {
- current.child.return = current;
- current = current.child;
- continue;
- }
- }
- if (current === instance) break;
- for (; null === current.sibling; ) {
- if (null === current.return || current.return === instance) break a;
- current = current.return;
- }
- current.sibling.return = current.return;
- current = current.sibling;
- }
+ null !== finishedWork.memoizedState &&
+ ((globalMostRecentFallbackTime = now()),
+ hideOrUnhideAllChildren(finishedWork.child, !0));
attachSuspenseRetryListeners(finishedWork);
return;
case 19:
@@ -5573,93 +5992,62 @@ function commitWork(current, finishedWork) {
return;
case 17:
return;
+ case 23:
+ case 24:
+ hideOrUnhideAllChildren(
+ finishedWork,
+ null !== finishedWork.memoizedState
+ );
+ return;
}
throw Error(
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
function attachSuspenseRetryListeners(finishedWork) {
- var thenables = finishedWork.updateQueue;
- if (null !== thenables) {
+ var wakeables = finishedWork.updateQueue;
+ if (null !== wakeables) {
finishedWork.updateQueue = null;
var retryCache = finishedWork.stateNode;
null === retryCache &&
(retryCache = finishedWork.stateNode = new PossiblyWeakSet());
- thenables.forEach(function(thenable) {
- var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
- retryCache.has(thenable) ||
- (!0 !== thenable.__reactDoNotTraceInteractions &&
+ wakeables.forEach(function(wakeable) {
+ var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
+ retryCache.has(wakeable) ||
+ (!0 !== wakeable.__reactDoNotTraceInteractions &&
(retry = tracing.unstable_wrap(retry)),
- retryCache.add(thenable),
- thenable.then(retry, retry));
+ retryCache.add(wakeable),
+ wakeable.then(retry, retry));
});
}
}
-var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map;
-function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- expirationTime.payload = { element: null };
- var error = errorInfo.value;
- expirationTime.callback = function() {
- hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error));
- logError(fiber, errorInfo);
- };
- return expirationTime;
-}
-function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
- expirationTime = createUpdate(expirationTime, null);
- expirationTime.tag = 3;
- var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
- if ("function" === typeof getDerivedStateFromError) {
- var error = errorInfo.value;
- expirationTime.payload = function() {
- logError(fiber, errorInfo);
- return getDerivedStateFromError(error);
- };
- }
- var inst = fiber.stateNode;
- null !== inst &&
- "function" === typeof inst.componentDidCatch &&
- (expirationTime.callback = function() {
- "function" !== typeof getDerivedStateFromError &&
- (null === legacyErrorBoundariesThatAlreadyFailed
- ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logError(fiber, errorInfo));
- var stack = errorInfo.stack;
- this.componentDidCatch(errorInfo.value, {
- componentStack: null !== stack ? stack : ""
- });
- });
- return expirationTime;
+function isSuspenseBoundaryBeingHidden(current, finishedWork) {
+ return null !== current &&
+ ((current = current.memoizedState),
+ null === current || null !== current.dehydrated)
+ ? ((finishedWork = finishedWork.memoizedState),
+ null !== finishedWork && null === finishedWork.dehydrated)
+ : !1;
}
var ceil = Math.ceil,
- ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
+ ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
- NoContext = 0,
- LegacyUnbatchedContext = 8,
- RenderContext = 16,
- CommitContext = 32,
- RootIncomplete = 0,
- RootFatalErrored = 1,
- RootErrored = 2,
- RootSuspended = 3,
- RootSuspendedWithDelay = 4,
- RootCompleted = 5,
- executionContext = NoContext,
+ executionContext = 0,
workInProgressRoot = null,
workInProgress = null,
- renderExpirationTime$1 = 0,
- workInProgressRootExitStatus = RootIncomplete,
+ workInProgressRootRenderLanes = 0,
+ subtreeRenderLanes = 0,
+ subtreeRenderLanesCursor = createCursor(0),
+ workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
- workInProgressRootLatestProcessedExpirationTime = 1073741823,
- workInProgressRootLatestSuspenseTimeout = 1073741823,
+ workInProgressRootLatestSuspenseTimeout = -1,
workInProgressRootCanSuspendUsingConfig = null,
- workInProgressRootNextUnprocessedUpdateTime = 0,
- workInProgressRootHasPendingPing = !1,
+ workInProgressRootIncludedLanes = 0,
+ workInProgressRootSkippedLanes = 0,
+ workInProgressRootUpdatedLanes = 0,
+ workInProgressRootPingedLanes = 0,
+ mostRecentlyUpdatedRoot = null,
globalMostRecentFallbackTime = 0,
- FALLBACK_THROTTLE_MS = 500,
nextEffect = null,
hasUncaughtError = !1,
firstUncaughtError = null,
@@ -5667,201 +6055,208 @@ var ceil = Math.ceil,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsRenderPriority = 90,
- pendingPassiveEffectsExpirationTime = 0,
+ pendingPassiveEffectsLanes = 0,
+ pendingPassiveHookEffectsMount = [],
+ pendingPassiveHookEffectsUnmount = [],
rootsWithPendingDiscreteUpdates = null,
nestedUpdateCount = 0,
rootWithNestedUpdates = null,
spawnedWorkDuringRender = null,
- currentEventTime = 0;
-function requestCurrentTimeForUpdate() {
- return (executionContext & (RenderContext | CommitContext)) !== NoContext
- ? 1073741821 - ((now() / 10) | 0)
- : 0 !== currentEventTime
+ currentEventTime = -1,
+ currentEventWipLanes = 0,
+ currentEventPendingLanes = 0,
+ focusedInstanceHandle = null,
+ shouldFireAfterActiveInstanceBlur = !1;
+function requestEventTime() {
+ return 0 !== (executionContext & 48)
+ ? now()
+ : -1 !== currentEventTime
? currentEventTime
- : (currentEventTime = 1073741821 - ((now() / 10) | 0));
+ : (currentEventTime = now());
}
-function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
+function requestUpdateLane(fiber, suspenseConfig) {
fiber = fiber.mode;
- if (0 === (fiber & 2)) return 1073741823;
- var priorityLevel = getCurrentPriorityLevel();
- if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822;
- if ((executionContext & RenderContext) !== NoContext)
- return renderExpirationTime$1;
- if (null !== suspenseConfig)
- currentTime =
- 1073741821 -
- 25 *
- ((((1073741821 -
- currentTime +
- (suspenseConfig.timeoutMs | 0 || 5e3) / 10) /
- 25) |
- 0) +
- 1);
- else
- switch (priorityLevel) {
- case 99:
- currentTime = 1073741823;
- break;
- case 98:
- currentTime =
- 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1);
- break;
- case 97:
- case 96:
- currentTime =
- 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1);
- break;
- case 95:
- currentTime = 2;
- break;
- default:
- throw Error("Expected a valid priority level");
- }
- null !== workInProgressRoot &&
- currentTime === renderExpirationTime$1 &&
- --currentTime;
- return currentTime;
-}
-function scheduleWork(fiber, expirationTime) {
+ if (0 === (fiber & 2)) return 1;
+ if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2;
+ 0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes);
+ if (null !== suspenseConfig) {
+ suspenseConfig = suspenseConfig.timeoutMs;
+ fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6;
+ 0 !== currentEventPendingLanes &&
+ (currentEventPendingLanes =
+ null !== mostRecentlyUpdatedRoot
+ ? mostRecentlyUpdatedRoot.pendingLanes
+ : 0);
+ suspenseConfig = currentEventWipLanes;
+ var pendingLanes = currentEventPendingLanes;
+ if (8 === fiber)
+ (fiber = pickArbitraryLane(122880 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 8192)),
+ (suspenseConfig = fiber);
+ else if (6 === fiber)
+ (fiber = pickArbitraryLane(3932160 & ~pendingLanes)),
+ 0 === fiber &&
+ ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)),
+ 0 === fiber && (fiber = 262144)),
+ (suspenseConfig = fiber);
+ else
+ throw Error(
+ "Invalid transition priority: " + fiber + ". This is a bug in React."
+ );
+ return suspenseConfig;
+ }
+ suspenseConfig = getCurrentPriorityLevel();
+ 0 !== (executionContext & 4) && 98 === suspenseConfig
+ ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes))
+ : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)),
+ (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes)));
+ return suspenseConfig;
+}
+function scheduleUpdateOnFiber(fiber, lane, eventTime) {
if (50 < nestedUpdateCount)
throw ((nestedUpdateCount = 0),
(rootWithNestedUpdates = null),
Error(
"Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
));
- fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
- if (null !== fiber) {
- var priorityLevel = getCurrentPriorityLevel();
- 1073741823 === expirationTime
- ? (executionContext & LegacyUnbatchedContext) !== NoContext &&
- (executionContext & (RenderContext | CommitContext)) === NoContext
- ? (schedulePendingInteractions(fiber, expirationTime),
- performSyncWorkOnRoot(fiber))
- : (ensureRootIsScheduled(fiber),
- schedulePendingInteractions(fiber, expirationTime),
- executionContext === NoContext && flushSyncCallbackQueue())
- : (ensureRootIsScheduled(fiber),
- schedulePendingInteractions(fiber, expirationTime));
- (executionContext & 4) === NoContext ||
- (98 !== priorityLevel && 99 !== priorityLevel) ||
- (null === rootsWithPendingDiscreteUpdates
- ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]))
- : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)),
- (void 0 === priorityLevel || priorityLevel > expirationTime) &&
- rootsWithPendingDiscreteUpdates.set(fiber, expirationTime)));
- }
-}
-function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
- fiber.expirationTime < expirationTime &&
- (fiber.expirationTime = expirationTime);
- var alternate = fiber.alternate;
- null !== alternate &&
- alternate.expirationTime < expirationTime &&
- (alternate.expirationTime = expirationTime);
- var node = fiber.return,
- root = null;
- if (null === node && 3 === fiber.tag) root = fiber.stateNode;
- else
- for (; null !== node; ) {
- alternate = node.alternate;
- node.childExpirationTime < expirationTime &&
- (node.childExpirationTime = expirationTime);
- null !== alternate &&
- alternate.childExpirationTime < expirationTime &&
- (alternate.childExpirationTime = expirationTime);
- if (null === node.return && 3 === node.tag) {
- root = node.stateNode;
- break;
+ fiber = markUpdateLaneFromFiberToRoot(fiber, lane);
+ if (null === fiber) return null;
+ markRootUpdated(fiber, lane, eventTime);
+ fiber === workInProgressRoot &&
+ ((workInProgressRootUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(fiber, workInProgressRootRenderLanes));
+ var priorityLevel = getCurrentPriorityLevel();
+ 1 === lane
+ ? 0 !== (executionContext & 8) && 0 === (executionContext & 48)
+ ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber))
+ : (ensureRootIsScheduled(fiber, eventTime),
+ schedulePendingInteractions(fiber, lane),
+ 0 === executionContext && flushSyncCallbackQueue())
+ : (0 === (executionContext & 4) ||
+ (98 !== priorityLevel && 99 !== priorityLevel) ||
+ (null === rootsWithPendingDiscreteUpdates
+ ? (rootsWithPendingDiscreteUpdates = new Set([fiber]))
+ : rootsWithPendingDiscreteUpdates.add(fiber)),
+ ensureRootIsScheduled(fiber, eventTime),
+ schedulePendingInteractions(fiber, lane));
+ mostRecentlyUpdatedRoot = fiber;
+}
+function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
+ sourceFiber.lanes |= lane;
+ var alternate = sourceFiber.alternate;
+ null !== alternate && (alternate.lanes |= lane);
+ alternate = sourceFiber;
+ for (sourceFiber = sourceFiber.return; null !== sourceFiber; )
+ (sourceFiber.childLanes |= lane),
+ (alternate = sourceFiber.alternate),
+ null !== alternate && (alternate.childLanes |= lane),
+ (alternate = sourceFiber),
+ (sourceFiber = sourceFiber.return);
+ return 3 === alternate.tag ? alternate.stateNode : null;
+}
+function ensureRootIsScheduled(root, currentTime) {
+ for (
+ var existingCallbackNode = root.callbackNode,
+ suspendedLanes = root.suspendedLanes,
+ pingedLanes = root.pingedLanes,
+ expirationTimes = root.expirationTimes,
+ lanes = root.pendingLanes;
+ 0 < lanes;
+
+ ) {
+ var index$7 = 31 - clz32(lanes),
+ lane = 1 << index$7,
+ expirationTime = expirationTimes[index$7];
+ if (-1 === expirationTime) {
+ if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) {
+ expirationTime = currentTime;
+ getHighestPriorityLanes(lane);
+ var priority = return_highestLanePriority;
+ expirationTimes[index$7] =
+ 12 <= priority
+ ? expirationTime + 1e3
+ : 6 <= priority
+ ? expirationTime + 5e3
+ : -1;
}
- node = node.return;
- }
- null !== root &&
- (workInProgressRoot === root &&
- (markUnprocessedUpdateTime(expirationTime),
- workInProgressRootExitStatus === RootSuspendedWithDelay &&
- markRootSuspendedAtTime(root, renderExpirationTime$1)),
- markRootUpdatedAtTime(root, expirationTime));
- return root;
-}
-function getNextRootExpirationTimeToWorkOn(root) {
- var lastExpiredTime = root.lastExpiredTime;
- if (0 !== lastExpiredTime) return lastExpiredTime;
- lastExpiredTime = root.firstPendingTime;
- if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime;
- var lastPingedTime = root.lastPingedTime;
- root = root.nextKnownPendingLevel;
- root = lastPingedTime > root ? lastPingedTime : root;
- return 2 >= root && lastExpiredTime !== root ? 0 : root;
-}
-function ensureRootIsScheduled(root) {
- if (0 !== root.lastExpiredTime)
- (root.callbackExpirationTime = 1073741823),
- (root.callbackPriority = 99),
- (root.callbackNode = scheduleSyncCallback(
- performSyncWorkOnRoot.bind(null, root)
- ));
+ } else expirationTime <= currentTime && (root.expiredLanes |= lane);
+ lanes &= ~lane;
+ }
+ suspendedLanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ currentTime = return_highestLanePriority;
+ if (0 === suspendedLanes)
+ null !== existingCallbackNode &&
+ (existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode),
+ (root.callbackNode = null),
+ (root.callbackPriority = 0));
else {
- var expirationTime = getNextRootExpirationTimeToWorkOn(root),
- existingCallbackNode = root.callbackNode;
- if (0 === expirationTime)
- null !== existingCallbackNode &&
- ((root.callbackNode = null),
- (root.callbackExpirationTime = 0),
- (root.callbackPriority = 90));
- else {
- var currentTime = requestCurrentTimeForUpdate();
- currentTime = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- );
- if (null !== existingCallbackNode) {
- var existingCallbackPriority = root.callbackPriority;
- if (
- root.callbackExpirationTime === expirationTime &&
- existingCallbackPriority >= currentTime
- )
- return;
- existingCallbackNode !== fakeCallbackNode &&
- Scheduler_cancelCallback(existingCallbackNode);
- }
- root.callbackExpirationTime = expirationTime;
- root.callbackPriority = currentTime;
- expirationTime =
- 1073741823 === expirationTime
- ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root))
- : scheduleCallback(
- currentTime,
- performConcurrentWorkOnRoot.bind(null, root),
- { timeout: 10 * (1073741821 - expirationTime) - now() }
- );
- root.callbackNode = expirationTime;
+ if (null !== existingCallbackNode) {
+ if (root.callbackPriority === currentTime) return;
+ existingCallbackNode !== fakeCallbackNode &&
+ Scheduler_cancelCallback(existingCallbackNode);
}
+ 17 === currentTime
+ ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)),
+ null === syncQueue
+ ? ((syncQueue = [existingCallbackNode]),
+ (immediateQueueCallbackNode = Scheduler_scheduleCallback(
+ Scheduler_ImmediatePriority,
+ flushSyncCallbackQueueImpl
+ )))
+ : syncQueue.push(existingCallbackNode),
+ (existingCallbackNode = fakeCallbackNode))
+ : 16 === currentTime
+ ? (existingCallbackNode = scheduleCallback(
+ 99,
+ performSyncWorkOnRoot.bind(null, root)
+ ))
+ : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)),
+ (existingCallbackNode = scheduleCallback(
+ existingCallbackNode,
+ performConcurrentWorkOnRoot.bind(null, root)
+ )));
+ root.callbackPriority = currentTime;
+ root.callbackNode = existingCallbackNode;
}
}
-function performConcurrentWorkOnRoot(root, didTimeout) {
- currentEventTime = 0;
- if (didTimeout) {
- didTimeout = requestCurrentTimeForUpdate();
- var lastExpiredTime = root.lastExpiredTime;
- if (0 === lastExpiredTime || lastExpiredTime > didTimeout)
- root.lastExpiredTime = didTimeout;
- ensureRootIsScheduled(root);
- return null;
- }
- lastExpiredTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 === lastExpiredTime) return null;
- didTimeout = root.callbackNode;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+function performConcurrentWorkOnRoot(root, didTimeout) {
+ currentEventTime = -1;
+ currentEventPendingLanes = currentEventWipLanes = 0;
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- flushPassiveEffects();
- var expirationTime = lastExpiredTime,
- prevExecutionContext = executionContext;
- executionContext |= RenderContext;
- var exitStatus = pushDispatcher();
- if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1)
- prepareFreshStack(root, expirationTime),
- startWorkOnPendingInteractions(root, expirationTime);
- expirationTime = pushInteractions(root);
+ var originalCallbackNode = root.callbackNode;
+ if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
+ return null;
+ var lanes = getNextLanes(
+ root,
+ root === workInProgressRoot ? workInProgressRootRenderLanes : 0
+ );
+ if (0 === lanes) return null;
+ if (didTimeout)
+ return (
+ (root.expiredLanes |= lanes & root.pendingLanes),
+ ensureRootIsScheduled(root, now()),
+ null
+ );
+ var lanes$jscomp$0 = lanes;
+ didTimeout = executionContext;
+ executionContext |= 16;
+ var prevDispatcher = pushDispatcher();
+ if (
+ workInProgressRoot !== root ||
+ workInProgressRootRenderLanes !== lanes$jscomp$0
+ )
+ prepareFreshStack(root, lanes$jscomp$0),
+ startWorkOnPendingInteractions(root, lanes$jscomp$0);
+ lanes$jscomp$0 = pushInteractions(root);
do
try {
workLoopConcurrent();
@@ -5871,162 +6266,121 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
}
while (1);
resetContextDependencies();
- tracing.__interactionsRef.current = expirationTime;
- ReactCurrentDispatcher$1.current = exitStatus;
- executionContext = prevExecutionContext;
+ tracing.__interactionsRef.current = lanes$jscomp$0;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
+ executionContext = didTimeout;
null !== workInProgress
- ? (exitStatus = RootIncomplete)
+ ? (didTimeout = 0)
: ((workInProgressRoot = null),
- (exitStatus = workInProgressRootExitStatus));
- if (exitStatus !== RootIncomplete) {
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
- throw ((didTimeout = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
- didTimeout);
- prevExecutionContext = root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
- switch (exitStatus) {
- case RootIncomplete:
- case RootFatalErrored:
+ (workInProgressRootRenderLanes = 0),
+ (didTimeout = workInProgressRootExitStatus));
+ if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes))
+ prepareFreshStack(root, 0);
+ else if (0 !== didTimeout) {
+ 2 === didTimeout &&
+ ((executionContext |= 64),
+ root.hydrate && (root.hydrate = !1),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (didTimeout = renderRootSync(root, lanes)));
+ if (1 === didTimeout)
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = root.current.alternate;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
throw Error("Root did not complete. This is a bug in React.");
- case RootErrored:
+ case 2:
commitRoot(root);
break;
- case RootSuspended:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- prevExecutionContext
- ));
+ case 3:
+ markRootSuspended$1(root, lanes);
if (
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- ((prevExecutionContext =
- globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()),
- 10 < prevExecutionContext)
+ (lanes & 62914560) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
) {
- if (
- workInProgressRootHasPendingPing &&
- ((expirationTime = root.lastPingedTime),
- 0 === expirationTime || expirationTime >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- expirationTime = getNextRootExpirationTimeToWorkOn(root);
- if (0 !== expirationTime && expirationTime !== lastExpiredTime) break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ if (0 !== getNextLanes(root, 0)) break;
+ prevDispatcher = root.suspendedLanes;
+ if ((prevDispatcher & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & prevDispatcher;
break;
}
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- prevExecutionContext
+ didTimeout
);
break;
}
commitRoot(root);
break;
- case RootSuspendedWithDelay:
- markRootSuspendedAtTime(root, lastExpiredTime);
- exitStatus = root.lastSuspendedTime;
- lastExpiredTime === exitStatus &&
- (root.nextKnownPendingLevel = getRemainingExpirationTime(
- prevExecutionContext
- ));
- if (
- workInProgressRootHasPendingPing &&
- ((prevExecutionContext = root.lastPingedTime),
- 0 === prevExecutionContext || prevExecutionContext >= lastExpiredTime)
- ) {
- root.lastPingedTime = lastExpiredTime;
- prepareFreshStack(root, lastExpiredTime);
- break;
- }
- prevExecutionContext = getNextRootExpirationTimeToWorkOn(root);
- if (
- 0 !== prevExecutionContext &&
- prevExecutionContext !== lastExpiredTime
- )
- break;
- if (0 !== exitStatus && exitStatus !== lastExpiredTime) {
- root.lastPingedTime = exitStatus;
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if (0 !== getNextLanes(root, 0)) break;
+ didTimeout = root.suspendedLanes;
+ if ((didTimeout & lanes) !== lanes) {
+ requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & didTimeout;
break;
}
- 1073741823 !== workInProgressRootLatestSuspenseTimeout
- ? (prevExecutionContext =
- 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) -
- now())
- : 1073741823 === workInProgressRootLatestProcessedExpirationTime
- ? (prevExecutionContext = 0)
- : ((prevExecutionContext =
- 10 *
- (1073741821 - workInProgressRootLatestProcessedExpirationTime) -
- 5e3),
- (exitStatus = now()),
- (lastExpiredTime =
- 10 * (1073741821 - lastExpiredTime) - exitStatus),
- (prevExecutionContext = exitStatus - prevExecutionContext),
- 0 > prevExecutionContext && (prevExecutionContext = 0),
- (prevExecutionContext =
- (120 > prevExecutionContext
+ lanes = getMostRecentEventTime(root, lanes);
+ -1 !== workInProgressRootLatestSuspenseTimeout
+ ? (lanes = workInProgressRootLatestSuspenseTimeout - now())
+ : -1 === lanes
+ ? (lanes = 0)
+ : ((lanes = now() - lanes),
+ (lanes =
+ (120 > lanes
? 120
- : 480 > prevExecutionContext
+ : 480 > lanes
? 480
- : 1080 > prevExecutionContext
+ : 1080 > lanes
? 1080
- : 1920 > prevExecutionContext
+ : 1920 > lanes
? 1920
- : 3e3 > prevExecutionContext
+ : 3e3 > lanes
? 3e3
- : 4320 > prevExecutionContext
+ : 4320 > lanes
? 4320
- : 1960 * ceil(prevExecutionContext / 1960)) -
- prevExecutionContext),
- lastExpiredTime < prevExecutionContext &&
- (prevExecutionContext = lastExpiredTime));
- if (10 < prevExecutionContext) {
+ : 1960 * ceil(lanes / 1960)) - lanes));
+ if (10 < lanes) {
root.timeoutHandle = scheduleTimeout(
commitRoot.bind(null, root),
- prevExecutionContext
+ lanes
);
break;
}
commitRoot(root);
break;
- case RootCompleted:
+ case 5:
+ lanes$jscomp$0 = getMostRecentEventTime(root, lanes);
if (
- 1073741823 !== workInProgressRootLatestProcessedExpirationTime &&
- null !== workInProgressRootCanSuspendUsingConfig
- ) {
- expirationTime = workInProgressRootLatestProcessedExpirationTime;
- var suspenseConfig = workInProgressRootCanSuspendUsingConfig;
- prevExecutionContext = suspenseConfig.busyMinDurationMs | 0;
- 0 >= prevExecutionContext
- ? (prevExecutionContext = 0)
- : ((exitStatus = suspenseConfig.busyDelayMs | 0),
- (expirationTime =
- now() -
- (10 * (1073741821 - expirationTime) -
- (suspenseConfig.timeoutMs | 0 || 5e3))),
- (prevExecutionContext =
- expirationTime <= exitStatus
+ -1 !== lanes$jscomp$0 &&
+ null !== workInProgressRootCanSuspendUsingConfig &&
+ ((didTimeout =
+ workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0),
+ 0 >= didTimeout
+ ? (didTimeout = 0)
+ : ((prevDispatcher =
+ workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0),
+ (lanes$jscomp$0 = now() - lanes$jscomp$0),
+ (didTimeout =
+ lanes$jscomp$0 <= prevDispatcher
? 0
- : exitStatus + prevExecutionContext - expirationTime));
- if (10 < prevExecutionContext) {
- markRootSuspendedAtTime(root, lastExpiredTime);
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- prevExecutionContext
- );
- break;
- }
+ : prevDispatcher + didTimeout - lanes$jscomp$0)),
+ 10 < didTimeout)
+ ) {
+ markRootSuspended$1(root, lanes);
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root),
+ didTimeout
+ );
+ break;
}
commitRoot(root);
break;
@@ -6034,42 +6388,68 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
throw Error("Unknown root exit status.");
}
}
- ensureRootIsScheduled(root);
- return root.callbackNode === didTimeout
+ ensureRootIsScheduled(root, now());
+ return root.callbackNode === originalCallbackNode
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function markRootSuspended$1(root, suspendedLanes) {
+ suspendedLanes &= ~workInProgressRootPingedLanes;
+ suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ root.suspendedLanes |= suspendedLanes;
+ root.pingedLanes &= ~suspendedLanes;
+ for (root = root.expirationTimes; 0 < suspendedLanes; ) {
+ var index$12 = 31 - clz32(suspendedLanes),
+ lane = 1 << index$12;
+ root[index$12] = -1;
+ suspendedLanes &= ~lane;
+ }
+}
function performSyncWorkOnRoot(root) {
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
flushPassiveEffects();
- var lastExpiredTime = root.lastExpiredTime;
- lastExpiredTime =
- 0 !== lastExpiredTime
- ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime
- ? renderExpirationTime$1
- : lastExpiredTime
- : 1073741823;
- var exitStatus = renderRootSync(root, lastExpiredTime);
+ if (
+ root === workInProgressRoot &&
+ 0 !== (root.expiredLanes & workInProgressRootRenderLanes)
+ ) {
+ var lanes = workInProgressRootRenderLanes;
+ var exitStatus = renderRootSync(root, lanes);
+ 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) &&
+ ((lanes = getNextLanes(root, lanes)),
+ (exitStatus = renderRootSync(root, lanes)));
+ } else
+ (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes));
0 !== root.tag &&
- exitStatus === RootErrored &&
- ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime),
- (exitStatus = renderRootSync(root, lastExpiredTime)));
- if (exitStatus === RootFatalErrored)
+ 2 === exitStatus &&
+ ((executionContext |= 64),
+ root.hydrate && (root.hydrate = !1),
+ (lanes = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== lanes && (exitStatus = renderRootSync(root, lanes)));
+ if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
- prepareFreshStack(root, lastExpiredTime),
- markRootSuspendedAtTime(root, lastExpiredTime),
- ensureRootIsScheduled(root),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
exitStatus);
root.finishedWork = root.current.alternate;
- root.finishedExpirationTime = lastExpiredTime;
+ root.finishedLanes = lanes;
commitRoot(root);
- ensureRootIsScheduled(root);
+ ensureRootIsScheduled(root, now());
return null;
}
-function prepareFreshStack(root, expirationTime) {
+function pushRenderLanes(fiber, lanes) {
+ push(subtreeRenderLanesCursor, subtreeRenderLanes);
+ subtreeRenderLanes |= lanes;
+ workInProgressRootIncludedLanes |= lanes;
+}
+function popRenderLanes() {
+ subtreeRenderLanes = subtreeRenderLanesCursor.current;
+ pop(subtreeRenderLanesCursor);
+}
+function prepareFreshStack(root, lanes) {
root.finishedWork = null;
- root.finishedExpirationTime = 0;
+ root.finishedLanes = 0;
var timeoutHandle = root.timeoutHandle;
-1 !== timeoutHandle &&
((root.timeoutHandle = -1), cancelTimeout(timeoutHandle));
@@ -6087,6 +6467,7 @@ function prepareFreshStack(root, expirationTime) {
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor);
+ resetWorkInProgressVersions();
break;
case 5:
popHostContext(interruptedWork);
@@ -6102,26 +6483,30 @@ function prepareFreshStack(root, expirationTime) {
break;
case 10:
popProvider(interruptedWork);
+ break;
+ case 23:
+ case 24:
+ popRenderLanes();
}
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
workInProgress = createWorkInProgress(root.current, null);
- renderExpirationTime$1 = expirationTime;
- workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
+ workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823;
+ workInProgressRootLatestSuspenseTimeout = -1;
workInProgressRootCanSuspendUsingConfig = null;
- workInProgressRootNextUnprocessedUpdateTime = 0;
- workInProgressRootHasPendingPing = !1;
+ workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
spawnedWorkDuringRender = null;
}
function handleError(root$jscomp$0, thrownValue) {
do {
+ var erroredWork = workInProgress;
try {
resetContextDependencies();
- ReactCurrentDispatcher.current = ContextOnlyDispatcher;
- if (didScheduleRenderPhaseUpdate)
+ ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ if (didScheduleRenderPhaseUpdate) {
for (
var hook = currentlyRenderingFiber$1.memoizedState;
null !== hook;
@@ -6131,23 +6516,26 @@ function handleError(root$jscomp$0, thrownValue) {
null !== queue && (queue.pending = null);
hook = hook.next;
}
- renderExpirationTime = 0;
+ didScheduleRenderPhaseUpdate = !1;
+ }
+ renderLanes = 0;
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
- didScheduleRenderPhaseUpdate = !1;
- if (null === workInProgress || null === workInProgress.return)
- return (
- (workInProgressRootExitStatus = RootFatalErrored),
- (workInProgressRootFatalError = thrownValue),
- (workInProgress = null)
- );
- workInProgress.mode & 8 &&
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0);
+ didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ ReactCurrentOwner$2.current = null;
+ if (null === erroredWork || null === erroredWork.return) {
+ workInProgressRootExitStatus = 1;
+ workInProgressRootFatalError = thrownValue;
+ workInProgress = null;
+ break;
+ }
+ erroredWork.mode & 8 &&
+ stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0);
a: {
var root = root$jscomp$0,
- returnFiber = workInProgress.return,
- sourceFiber = workInProgress,
+ returnFiber = erroredWork.return,
+ sourceFiber = erroredWork,
value = thrownValue;
- thrownValue = renderExpirationTime$1;
+ thrownValue = workInProgressRootRenderLanes;
sourceFiber.effectTag |= 2048;
sourceFiber.firstEffect = sourceFiber.lastEffect = null;
if (
@@ -6155,27 +6543,27 @@ function handleError(root$jscomp$0, thrownValue) {
"object" === typeof value &&
"function" === typeof value.then
) {
- var thenable = value;
+ var wakeable = value;
if (0 === (sourceFiber.mode & 2)) {
var currentSource = sourceFiber.alternate;
currentSource
? ((sourceFiber.updateQueue = currentSource.updateQueue),
(sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.expirationTime = currentSource.expirationTime))
+ (sourceFiber.lanes = currentSource.lanes))
: ((sourceFiber.updateQueue = null),
(sourceFiber.memoizedState = null));
}
var hasInvisibleParentBoundary =
0 !== (suspenseStackCursor.current & 1),
- _workInProgress = returnFiber;
+ workInProgress$77 = returnFiber;
do {
var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === _workInProgress.tag)) {
- var nextState = _workInProgress.memoizedState;
+ if ((JSCompiler_temp = 13 === workInProgress$77.tag)) {
+ var nextState = workInProgress$77.memoizedState;
if (null !== nextState)
JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
else {
- var props = _workInProgress.memoizedProps;
+ var props = workInProgress$77.memoizedProps;
JSCompiler_temp =
void 0 === props.fallback
? !1
@@ -6187,23 +6575,24 @@ function handleError(root$jscomp$0, thrownValue) {
}
}
if (JSCompiler_temp) {
- var thenables = _workInProgress.updateQueue;
- if (null === thenables) {
+ var wakeables = workInProgress$77.updateQueue;
+ if (null === wakeables) {
var updateQueue = new Set();
- updateQueue.add(thenable);
- _workInProgress.updateQueue = updateQueue;
- } else thenables.add(thenable);
- if (0 === (_workInProgress.mode & 2)) {
- _workInProgress.effectTag |= 64;
+ updateQueue.add(wakeable);
+ workInProgress$77.updateQueue = updateQueue;
+ } else wakeables.add(wakeable);
+ if (0 === (workInProgress$77.mode & 2)) {
+ workInProgress$77.effectTag |= 64;
+ sourceFiber.effectTag |= 16384;
sourceFiber.effectTag &= -2981;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
- var update = createUpdate(1073741823, null);
+ var update = createUpdate(-1, 1, null);
update.tag = 2;
enqueueUpdate(sourceFiber, update);
}
- sourceFiber.expirationTime = 1073741823;
+ sourceFiber.lanes |= 1;
break a;
}
value = void 0;
@@ -6212,86 +6601,90 @@ function handleError(root$jscomp$0, thrownValue) {
null === pingCache
? ((pingCache = root.pingCache = new PossiblyWeakMap()),
(value = new Set()),
- pingCache.set(thenable, value))
- : ((value = pingCache.get(thenable)),
+ pingCache.set(wakeable, value))
+ : ((value = pingCache.get(wakeable)),
void 0 === value &&
- ((value = new Set()), pingCache.set(thenable, value)));
+ ((value = new Set()), pingCache.set(wakeable, value)));
if (!value.has(sourceFiber)) {
value.add(sourceFiber);
var ping = pingSuspendedRoot.bind(
null,
root,
- thenable,
+ wakeable,
sourceFiber
);
- thenable.then(ping, ping);
+ wakeable.then(ping, ping);
}
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
+ workInProgress$77.effectTag |= 4096;
+ workInProgress$77.lanes = thrownValue;
break a;
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$77 = workInProgress$77.return;
+ } while (null !== workInProgress$77);
value = Error(
(getComponentName(sourceFiber.type) || "A React component") +
- " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." +
- getStackByFiberInDevAndProd(sourceFiber)
+ " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display."
);
}
- workInProgressRootExitStatus !== RootCompleted &&
- (workInProgressRootExitStatus = RootErrored);
+ 5 !== workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 2);
value = createCapturedValue(value, sourceFiber);
- _workInProgress = returnFiber;
+ workInProgress$77 = returnFiber;
do {
- switch (_workInProgress.tag) {
+ switch (workInProgress$77.tag) {
case 3:
- thenable = value;
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update = createRootErrorUpdate(
- _workInProgress,
- thenable,
+ root = value;
+ workInProgress$77.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$77.lanes |= thrownValue;
+ var update$78 = createRootErrorUpdate(
+ workInProgress$77,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update);
+ enqueueCapturedUpdate(workInProgress$77, update$78);
break a;
case 1:
- thenable = value;
- var ctor = _workInProgress.type,
- instance = _workInProgress.stateNode;
+ root = value;
+ var ctor = workInProgress$77.type,
+ instance = workInProgress$77.stateNode;
if (
- 0 === (_workInProgress.effectTag & 64) &&
+ 0 === (workInProgress$77.effectTag & 64) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- _workInProgress.effectTag |= 4096;
- _workInProgress.expirationTime = thrownValue;
- var _update2 = createClassErrorUpdate(
- _workInProgress,
- thenable,
+ workInProgress$77.effectTag |= 4096;
+ thrownValue &= -thrownValue;
+ workInProgress$77.lanes |= thrownValue;
+ var update$81 = createClassErrorUpdate(
+ workInProgress$77,
+ root,
thrownValue
);
- enqueueCapturedUpdate(_workInProgress, _update2);
+ enqueueCapturedUpdate(workInProgress$77, update$81);
break a;
}
}
- _workInProgress = _workInProgress.return;
- } while (null !== _workInProgress);
+ workInProgress$77 = workInProgress$77.return;
+ } while (null !== workInProgress$77);
}
- workInProgress = completeUnitOfWork(workInProgress);
+ completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
thrownValue = yetAnotherThrownValue;
+ workInProgress === erroredWork &&
+ null !== erroredWork &&
+ (workInProgress = erroredWork = erroredWork.return);
continue;
}
break;
} while (1);
}
function pushDispatcher() {
- var prevDispatcher = ReactCurrentDispatcher$1.current;
- ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
+ var prevDispatcher = ReactCurrentDispatcher$2.current;
+ ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
function pushInteractions(root) {
@@ -6299,28 +6692,20 @@ function pushInteractions(root) {
tracing.__interactionsRef.current = root.memoizedInteractions;
return prevInteractions;
}
-function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
- expirationTime < workInProgressRootLatestProcessedExpirationTime &&
- 2 < expirationTime &&
- (workInProgressRootLatestProcessedExpirationTime = expirationTime);
+function markRenderEventTimeAndConfig(eventTime, suspenseConfig) {
null !== suspenseConfig &&
- expirationTime < workInProgressRootLatestSuspenseTimeout &&
- 2 < expirationTime &&
- ((workInProgressRootLatestSuspenseTimeout = expirationTime),
- (workInProgressRootCanSuspendUsingConfig = suspenseConfig));
-}
-function markUnprocessedUpdateTime(expirationTime) {
- expirationTime > workInProgressRootNextUnprocessedUpdateTime &&
- (workInProgressRootNextUnprocessedUpdateTime = expirationTime);
+ ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3),
+ eventTime > workInProgressRootLatestSuspenseTimeout &&
+ ((workInProgressRootLatestSuspenseTimeout = eventTime),
+ (workInProgressRootCanSuspendUsingConfig = suspenseConfig)));
}
-function renderRootSync(root, expirationTime) {
+function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= RenderContext;
+ executionContext |= 16;
var prevDispatcher = pushDispatcher();
- if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1)
- prepareFreshStack(root, expirationTime),
- startWorkOnPendingInteractions(root, expirationTime);
- expirationTime = pushInteractions(root);
+ if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes)
+ prepareFreshStack(root, lanes), startWorkOnPendingInteractions(root, lanes);
+ lanes = pushInteractions(root);
do
try {
workLoopSync();
@@ -6330,187 +6715,197 @@ function renderRootSync(root, expirationTime) {
}
while (1);
resetContextDependencies();
- tracing.__interactionsRef.current = expirationTime;
+ tracing.__interactionsRef.current = lanes;
executionContext = prevExecutionContext;
- ReactCurrentDispatcher$1.current = prevDispatcher;
+ ReactCurrentDispatcher$2.current = prevDispatcher;
if (null !== workInProgress)
throw Error(
"Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
);
workInProgressRoot = null;
+ workInProgressRootRenderLanes = 0;
return workInProgressRootExitStatus;
}
function workLoopSync() {
- for (; null !== workInProgress; )
- workInProgress = performUnitOfWork(workInProgress);
+ for (; null !== workInProgress; ) performUnitOfWork(workInProgress);
}
function workLoopConcurrent() {
for (; null !== workInProgress && !Scheduler_shouldYield(); )
- workInProgress = performUnitOfWork(workInProgress);
+ performUnitOfWork(workInProgress);
}
function performUnitOfWork(unitOfWork) {
var current = unitOfWork.alternate;
0 !== (unitOfWork.mode & 8)
? ((profilerStartTime = now$1()),
0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()),
- (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)),
+ (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)),
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0))
- : (current = beginWork$1(current, unitOfWork, renderExpirationTime$1));
+ : (current = beginWork$1(current, unitOfWork, subtreeRenderLanes));
unitOfWork.memoizedProps = unitOfWork.pendingProps;
- null === current && (current = completeUnitOfWork(unitOfWork));
+ null === current
+ ? completeUnitOfWork(unitOfWork)
+ : (workInProgress = current);
ReactCurrentOwner$2.current = null;
- return current;
}
function completeUnitOfWork(unitOfWork) {
- workInProgress = unitOfWork;
+ var completedWork = unitOfWork;
do {
- var current = workInProgress.alternate;
- unitOfWork = workInProgress.return;
- if (0 === (workInProgress.effectTag & 2048)) {
- if (0 === (workInProgress.mode & 8))
- current = completeWork(current, workInProgress, renderExpirationTime$1);
+ var current = completedWork.alternate;
+ unitOfWork = completedWork.return;
+ if (0 === (completedWork.effectTag & 2048)) {
+ if (0 === (completedWork.mode & 8))
+ current = completeWork(current, completedWork, subtreeRenderLanes);
else {
- var fiber = workInProgress;
+ var fiber = completedWork;
profilerStartTime = now$1();
0 > fiber.actualStartTime && (fiber.actualStartTime = now$1());
- current = completeWork(current, workInProgress, renderExpirationTime$1);
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1);
+ current = completeWork(current, completedWork, subtreeRenderLanes);
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1);
}
- fiber = workInProgress;
- if (1 === renderExpirationTime$1 || 1 !== fiber.childExpirationTime) {
- var newChildExpirationTime = 0;
- if (0 !== (fiber.mode & 8)) {
+ if (null !== current) {
+ workInProgress = current;
+ return;
+ }
+ current = completedWork;
+ if (
+ (24 !== current.tag && 23 !== current.tag) ||
+ null === current.memoizedState ||
+ 0 !== (subtreeRenderLanes & 1073741824) ||
+ 0 === (current.mode & 4)
+ ) {
+ fiber = 0;
+ if (0 !== (current.mode & 8)) {
for (
- var actualDuration = fiber.actualDuration,
- treeBaseDuration = fiber.selfBaseDuration,
+ var actualDuration = current.actualDuration,
+ treeBaseDuration = current.selfBaseDuration,
shouldBubbleActualDurations =
- null === fiber.alternate ||
- fiber.child !== fiber.alternate.child,
- child = fiber.child;
+ null === current.alternate ||
+ current.child !== current.alternate.child,
+ child = current.child;
null !== child;
- ) {
- var childUpdateExpirationTime = child.expirationTime,
- childChildExpirationTime = child.childExpirationTime;
- childUpdateExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = childUpdateExpirationTime);
- childChildExpirationTime > newChildExpirationTime &&
- (newChildExpirationTime = childChildExpirationTime);
- shouldBubbleActualDurations &&
- (actualDuration += child.actualDuration);
- treeBaseDuration += child.treeBaseDuration;
- child = child.sibling;
- }
- fiber.actualDuration = actualDuration;
- fiber.treeBaseDuration = treeBaseDuration;
+ )
+ (fiber |= child.lanes | child.childLanes),
+ shouldBubbleActualDurations &&
+ (actualDuration += child.actualDuration),
+ (treeBaseDuration += child.treeBaseDuration),
+ (child = child.sibling);
+ 13 === current.tag &&
+ null !== current.memoizedState &&
+ ((shouldBubbleActualDurations = current.child),
+ null !== shouldBubbleActualDurations &&
+ (treeBaseDuration -=
+ shouldBubbleActualDurations.treeBaseDuration));
+ current.actualDuration = actualDuration;
+ current.treeBaseDuration = treeBaseDuration;
} else
- for (actualDuration = fiber.child; null !== actualDuration; )
- (treeBaseDuration = actualDuration.expirationTime),
- (shouldBubbleActualDurations =
- actualDuration.childExpirationTime),
- treeBaseDuration > newChildExpirationTime &&
- (newChildExpirationTime = treeBaseDuration),
- shouldBubbleActualDurations > newChildExpirationTime &&
- (newChildExpirationTime = shouldBubbleActualDurations),
+ for (actualDuration = current.child; null !== actualDuration; )
+ (fiber |= actualDuration.lanes | actualDuration.childLanes),
(actualDuration = actualDuration.sibling);
- fiber.childExpirationTime = newChildExpirationTime;
+ current.childLanes = fiber;
}
- if (null !== current) return current;
null !== unitOfWork &&
0 === (unitOfWork.effectTag & 2048) &&
(null === unitOfWork.firstEffect &&
- (unitOfWork.firstEffect = workInProgress.firstEffect),
- null !== workInProgress.lastEffect &&
+ (unitOfWork.firstEffect = completedWork.firstEffect),
+ null !== completedWork.lastEffect &&
(null !== unitOfWork.lastEffect &&
- (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect),
- (unitOfWork.lastEffect = workInProgress.lastEffect)),
- 1 < workInProgress.effectTag &&
+ (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect),
+ (unitOfWork.lastEffect = completedWork.lastEffect)),
+ 1 < completedWork.effectTag &&
(null !== unitOfWork.lastEffect
- ? (unitOfWork.lastEffect.nextEffect = workInProgress)
- : (unitOfWork.firstEffect = workInProgress),
- (unitOfWork.lastEffect = workInProgress)));
+ ? (unitOfWork.lastEffect.nextEffect = completedWork)
+ : (unitOfWork.firstEffect = completedWork),
+ (unitOfWork.lastEffect = completedWork)));
} else {
- current = unwindWork(workInProgress);
- if (0 !== (workInProgress.mode & 8)) {
- stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1);
- fiber = workInProgress.actualDuration;
- for (
- newChildExpirationTime = workInProgress.child;
- null !== newChildExpirationTime;
-
- )
- (fiber += newChildExpirationTime.actualDuration),
- (newChildExpirationTime = newChildExpirationTime.sibling);
- workInProgress.actualDuration = fiber;
+ current = unwindWork(completedWork);
+ if (null !== current) {
+ current.effectTag &= 2047;
+ workInProgress = current;
+ return;
+ }
+ if (0 !== (completedWork.mode & 8)) {
+ stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1);
+ current = completedWork.actualDuration;
+ for (fiber = completedWork.child; null !== fiber; )
+ (current += fiber.actualDuration), (fiber = fiber.sibling);
+ completedWork.actualDuration = current;
}
- if (null !== current) return (current.effectTag &= 2047), current;
null !== unitOfWork &&
((unitOfWork.firstEffect = unitOfWork.lastEffect = null),
(unitOfWork.effectTag |= 2048));
}
- current = workInProgress.sibling;
- if (null !== current) return current;
- workInProgress = unitOfWork;
- } while (null !== workInProgress);
- workInProgressRootExitStatus === RootIncomplete &&
- (workInProgressRootExitStatus = RootCompleted);
- return null;
-}
-function getRemainingExpirationTime(fiber) {
- var updateExpirationTime = fiber.expirationTime;
- fiber = fiber.childExpirationTime;
- return updateExpirationTime > fiber ? updateExpirationTime : fiber;
+ completedWork = completedWork.sibling;
+ if (null !== completedWork) {
+ workInProgress = completedWork;
+ return;
+ }
+ workInProgress = completedWork = unitOfWork;
+ } while (null !== completedWork);
+ 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
function commitRoot(root) {
var renderPriorityLevel = getCurrentPriorityLevel();
runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel));
return null;
}
-function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
+function commitRootImpl(root, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ if (0 !== (executionContext & 48))
throw Error("Should not already be working.");
- var finishedWork = root$jscomp$0.finishedWork,
- expirationTime = root$jscomp$0.finishedExpirationTime;
+ var finishedWork = root.finishedWork,
+ lanes = root.finishedLanes;
if (null === finishedWork) return null;
- root$jscomp$0.finishedWork = null;
- root$jscomp$0.finishedExpirationTime = 0;
- if (finishedWork === root$jscomp$0.current)
+ root.finishedWork = null;
+ root.finishedLanes = 0;
+ if (finishedWork === root.current)
throw Error(
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
);
- root$jscomp$0.callbackNode = null;
- root$jscomp$0.callbackExpirationTime = 0;
- root$jscomp$0.callbackPriority = 90;
- root$jscomp$0.nextKnownPendingLevel = 0;
- var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(
- finishedWork
- );
- root$jscomp$0.firstPendingTime = remainingExpirationTimeBeforeCommit;
- expirationTime <= root$jscomp$0.lastSuspendedTime
- ? (root$jscomp$0.firstSuspendedTime = root$jscomp$0.lastSuspendedTime = root$jscomp$0.nextKnownPendingLevel = 0)
- : expirationTime <= root$jscomp$0.firstSuspendedTime &&
- (root$jscomp$0.firstSuspendedTime = expirationTime - 1);
- expirationTime <= root$jscomp$0.lastPingedTime &&
- (root$jscomp$0.lastPingedTime = 0);
- expirationTime <= root$jscomp$0.lastExpiredTime &&
- (root$jscomp$0.lastExpiredTime = 0);
- root$jscomp$0 === workInProgressRoot &&
+ root.callbackNode = null;
+ var remainingLanes = finishedWork.lanes | finishedWork.childLanes,
+ remainingLanes$jscomp$0 = remainingLanes,
+ noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0;
+ root.pendingLanes = remainingLanes$jscomp$0;
+ root.suspendedLanes = 0;
+ root.pingedLanes = 0;
+ root.expiredLanes &= remainingLanes$jscomp$0;
+ root.mutableReadLanes &= remainingLanes$jscomp$0;
+ root.entangledLanes &= remainingLanes$jscomp$0;
+ remainingLanes$jscomp$0 = root.entanglements;
+ for (
+ var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes;
+ 0 < noLongerPendingLanes;
+
+ ) {
+ var index$13 = 31 - clz32(noLongerPendingLanes),
+ lane = 1 << index$13;
+ remainingLanes$jscomp$0[index$13] = 0;
+ eventTimes[index$13] = -1;
+ expirationTimes[index$13] = -1;
+ noLongerPendingLanes &= ~lane;
+ }
+ null !== rootsWithPendingDiscreteUpdates &&
+ 0 === (remainingLanes & 24) &&
+ rootsWithPendingDiscreteUpdates.has(root) &&
+ rootsWithPendingDiscreteUpdates.delete(root);
+ root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
- (renderExpirationTime$1 = 0));
+ (workInProgressRootRenderLanes = 0));
1 < finishedWork.effectTag
? null !== finishedWork.lastEffect
? ((finishedWork.lastEffect.nextEffect = finishedWork),
- (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect))
- : (remainingExpirationTimeBeforeCommit = finishedWork)
- : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect);
- if (null !== remainingExpirationTimeBeforeCommit) {
- var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- var prevInteractions = pushInteractions(root$jscomp$0);
- ReactCurrentOwner$2.current = null;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ (remainingLanes = finishedWork.firstEffect))
+ : (remainingLanes = finishedWork)
+ : (remainingLanes = finishedWork.firstEffect);
+ if (null !== remainingLanes) {
+ remainingLanes$jscomp$0 = executionContext;
+ executionContext |= 32;
+ eventTimes = pushInteractions(root);
+ focusedInstanceHandle = ReactCurrentOwner$2.current = null;
+ shouldFireAfterActiveInstanceBlur = !1;
+ nextEffect = remainingLanes;
do
try {
commitBeforeMutationEffects();
@@ -6520,16 +6915,12 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
+ focusedInstanceHandle = null;
commitTime = now$1();
- nextEffect = remainingExpirationTimeBeforeCommit;
+ nextEffect = remainingLanes;
do
try {
- for (
- var root = root$jscomp$0,
- renderPriorityLevel = renderPriorityLevel$jscomp$0;
- null !== nextEffect;
-
- ) {
+ for (expirationTimes = root; null !== nextEffect; ) {
var effectTag = nextEffect.effectTag;
if (effectTag & 128) {
var current = nextEffect.alternate;
@@ -6562,27 +6953,25 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
commitWork(nextEffect.alternate, nextEffect);
break;
case 8:
- var current$jscomp$0 = nextEffect;
- unmountHostComponents(
- root,
- current$jscomp$0,
- renderPriorityLevel
- );
- detachFiber(current$jscomp$0);
+ noLongerPendingLanes = nextEffect;
+ unmountHostComponents(expirationTimes, noLongerPendingLanes);
+ var alternate = noLongerPendingLanes.alternate;
+ detachFiberMutation(noLongerPendingLanes);
+ null !== alternate && detachFiberMutation(alternate);
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$96) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$96);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
- root$jscomp$0.current = finishedWork;
- nextEffect = remainingExpirationTimeBeforeCommit;
+ root.current = finishedWork;
+ nextEffect = remainingLanes;
do
try {
- for (effectTag = root$jscomp$0; null !== nextEffect; ) {
+ for (effectTag = root; null !== nextEffect; ) {
var effectTag$jscomp$0 = nextEffect.effectTag;
effectTag$jscomp$0 & 36 &&
commitLifeCycles(effectTag, nextEffect.alternate, nextEffect);
@@ -6605,72 +6994,82 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) {
}
nextEffect = nextEffect.nextEffect;
}
- } catch (error) {
+ } catch (error$97) {
if (null === nextEffect) throw Error("Should be working on an effect.");
- captureCommitPhaseError(nextEffect, error);
+ captureCommitPhaseError(nextEffect, error$97);
nextEffect = nextEffect.nextEffect;
}
while (null !== nextEffect);
nextEffect = null;
requestPaint();
- tracing.__interactionsRef.current = prevInteractions;
- executionContext = prevExecutionContext;
- } else (root$jscomp$0.current = finishedWork), (commitTime = now$1());
+ tracing.__interactionsRef.current = eventTimes;
+ executionContext = remainingLanes$jscomp$0;
+ } else (root.current = finishedWork), (commitTime = now$1());
if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects))
(rootDoesHavePassiveEffects = !1),
- (rootWithPendingPassiveEffects = root$jscomp$0),
- (pendingPassiveEffectsExpirationTime = expirationTime),
- (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$0);
+ (rootWithPendingPassiveEffects = root),
+ (pendingPassiveEffectsLanes = lanes),
+ (pendingPassiveEffectsRenderPriority = renderPriorityLevel);
else
- for (
- nextEffect = remainingExpirationTimeBeforeCommit;
- null !== nextEffect;
-
- )
- (renderPriorityLevel$jscomp$0 = nextEffect.nextEffect),
+ for (nextEffect = remainingLanes; null !== nextEffect; )
+ (ref = nextEffect.nextEffect),
(nextEffect.nextEffect = null),
- (nextEffect = renderPriorityLevel$jscomp$0);
- renderPriorityLevel$jscomp$0 = root$jscomp$0.firstPendingTime;
- if (0 !== renderPriorityLevel$jscomp$0) {
+ nextEffect.effectTag & 8 && (nextEffect.sibling = null),
+ (nextEffect = ref);
+ remainingLanes = root.pendingLanes;
+ if (0 !== remainingLanes) {
if (null !== spawnedWorkDuringRender)
for (
- remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender,
+ ref = spawnedWorkDuringRender,
spawnedWorkDuringRender = null,
- ref = 0;
- ref < remainingExpirationTimeBeforeCommit.length;
- ref++
+ instance = 0;
+ instance < ref.length;
+ instance++
)
- scheduleInteractions(
- root$jscomp$0,
- remainingExpirationTimeBeforeCommit[ref],
- root$jscomp$0.memoizedInteractions
- );
- schedulePendingInteractions(root$jscomp$0, renderPriorityLevel$jscomp$0);
+ scheduleInteractions(root, ref[instance], root.memoizedInteractions);
+ schedulePendingInteractions(root, remainingLanes);
} else legacyErrorBoundariesThatAlreadyFailed = null;
- effectTag$jscomp$0 ||
- finishPendingInteractions(root$jscomp$0, expirationTime);
- 1073741823 === renderPriorityLevel$jscomp$0
- ? root$jscomp$0 === rootWithNestedUpdates
+ effectTag$jscomp$0 || finishPendingInteractions(root, lanes);
+ 1 === remainingLanes
+ ? root === rootWithNestedUpdates
? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$0))
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
: (nestedUpdateCount = 0);
- "function" === typeof onCommitFiberRoot &&
- onCommitFiberRoot(finishedWork.stateNode, expirationTime);
- ensureRootIsScheduled(root$jscomp$0);
+ finishedWork = finishedWork.stateNode;
+ if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot)
+ try {
+ injectedHook.onCommitFiberRoot(
+ rendererID,
+ finishedWork,
+ renderPriorityLevel,
+ 64 === (finishedWork.current.effectTag & 64)
+ );
+ } catch (err) {}
+ ensureRootIsScheduled(root, now());
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
- (root$jscomp$0 = firstUncaughtError),
+ (root = firstUncaughtError),
(firstUncaughtError = null),
- root$jscomp$0);
- if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null;
+ root);
+ if (0 !== (executionContext & 8)) return null;
flushSyncCallbackQueue();
return null;
}
function commitBeforeMutationEffects() {
for (; null !== nextEffect; ) {
+ var current = nextEffect.alternate;
+ shouldFireAfterActiveInstanceBlur ||
+ null === focusedInstanceHandle ||
+ (0 !== (nextEffect.effectTag & 8)
+ ? doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0)
+ : 13 === nextEffect.tag &&
+ isSuspenseBoundaryBeingHidden(current, nextEffect) &&
+ doesFiberContain(nextEffect, focusedInstanceHandle) &&
+ (shouldFireAfterActiveInstanceBlur = !0));
var effectTag = nextEffect.effectTag;
0 !== (effectTag & 256) &&
- commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect);
+ commitBeforeMutationLifeCycles(current, nextEffect);
0 === (effectTag & 512) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
@@ -6688,58 +7087,89 @@ function flushPassiveEffects() {
? 97
: pendingPassiveEffectsRenderPriority;
pendingPassiveEffectsRenderPriority = 90;
+ schedulerPriorityToLanePriority(priorityLevel);
return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
}
+ return !1;
+}
+function enqueuePendingPassiveHookEffectMount(fiber, effect) {
+ pendingPassiveHookEffectsMount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
+}
+function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
+ pendingPassiveHookEffectsUnmount.push(effect, fiber);
+ rootDoesHavePassiveEffects ||
+ ((rootDoesHavePassiveEffects = !0),
+ scheduleCallback(97, function() {
+ flushPassiveEffects();
+ return null;
+ }));
}
function flushPassiveEffectsImpl() {
if (null === rootWithPendingPassiveEffects) return !1;
var root = rootWithPendingPassiveEffects,
- expirationTime = pendingPassiveEffectsExpirationTime;
+ lanes = pendingPassiveEffectsLanes;
rootWithPendingPassiveEffects = null;
- pendingPassiveEffectsExpirationTime = 0;
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext)
+ pendingPassiveEffectsLanes = 0;
+ if (0 !== (executionContext & 48))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= CommitContext;
- for (
- var prevInteractions = pushInteractions(root),
- _effect2 = root.current.firstEffect;
- null !== _effect2;
-
- ) {
+ executionContext |= 32;
+ var prevInteractions = pushInteractions(root),
+ unmountEffects = pendingPassiveHookEffectsUnmount;
+ pendingPassiveHookEffectsUnmount = [];
+ for (var i = 0; i < unmountEffects.length; i += 2) {
+ var effect$102 = unmountEffects[i],
+ fiber = unmountEffects[i + 1],
+ destroy = effect$102.destroy;
+ effect$102.destroy = void 0;
+ if ("function" === typeof destroy)
+ try {
+ destroy();
+ } catch (error) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error);
+ }
+ }
+ unmountEffects = pendingPassiveHookEffectsMount;
+ pendingPassiveHookEffectsMount = [];
+ for (i = 0; i < unmountEffects.length; i += 2) {
+ effect$102 = unmountEffects[i];
+ fiber = unmountEffects[i + 1];
try {
- var finishedWork = _effect2;
- if (0 !== (finishedWork.effectTag & 512))
- switch (finishedWork.tag) {
- case 0:
- case 11:
- case 15:
- case 22:
- commitHookEffectListUnmount(5, finishedWork),
- commitHookEffectListMount(5, finishedWork);
- }
- } catch (error) {
- if (null === _effect2) throw Error("Should be working on an effect.");
- captureCommitPhaseError(_effect2, error);
+ var create$106 = effect$102.create;
+ effect$102.destroy = create$106();
+ } catch (error$107) {
+ if (null === fiber) throw Error("Should be working on an effect.");
+ captureCommitPhaseError(fiber, error$107);
}
- finishedWork = _effect2.nextEffect;
- _effect2.nextEffect = null;
- _effect2 = finishedWork;
}
+ for (create$106 = root.current.firstEffect; null !== create$106; )
+ (unmountEffects = create$106.nextEffect),
+ (create$106.nextEffect = null),
+ create$106.effectTag & 8 && (create$106.sibling = null),
+ (create$106 = unmountEffects);
tracing.__interactionsRef.current = prevInteractions;
- finishPendingInteractions(root, expirationTime);
+ finishPendingInteractions(root, lanes);
executionContext = prevExecutionContext;
flushSyncCallbackQueue();
return !0;
}
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823);
+ sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1);
enqueueUpdate(rootFiber, sourceFiber);
- rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823);
+ sourceFiber = requestEventTime();
+ rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1);
null !== rootFiber &&
- (ensureRootIsScheduled(rootFiber),
- schedulePendingInteractions(rootFiber, 1073741823));
+ (markRootUpdated(rootFiber, 1, sourceFiber),
+ ensureRootIsScheduled(rootFiber, sourceFiber),
+ schedulePendingInteractions(rootFiber, 1));
}
function captureCommitPhaseError(sourceFiber, error) {
if (3 === sourceFiber.tag)
@@ -6758,156 +7188,166 @@ function captureCommitPhaseError(sourceFiber, error) {
!legacyErrorBoundariesThatAlreadyFailed.has(instance)))
) {
sourceFiber = createCapturedValue(error, sourceFiber);
- sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823);
+ sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1);
enqueueUpdate(fiber, sourceFiber);
- fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823);
+ sourceFiber = requestEventTime();
+ fiber = markUpdateLaneFromFiberToRoot(fiber, 1);
null !== fiber &&
- (ensureRootIsScheduled(fiber),
- schedulePendingInteractions(fiber, 1073741823));
+ (markRootUpdated(fiber, 1, sourceFiber),
+ ensureRootIsScheduled(fiber, sourceFiber),
+ schedulePendingInteractions(fiber, 1));
break;
}
}
fiber = fiber.return;
}
}
-function pingSuspendedRoot(root, thenable, suspendedTime) {
+function pingSuspendedRoot(root, wakeable, pingedLanes) {
var pingCache = root.pingCache;
- null !== pingCache && pingCache.delete(thenable);
- workInProgressRoot === root && renderExpirationTime$1 === suspendedTime
- ? workInProgressRootExitStatus === RootSuspendedWithDelay ||
- (workInProgressRootExitStatus === RootSuspended &&
- 1073741823 === workInProgressRootLatestProcessedExpirationTime &&
- now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS)
- ? prepareFreshStack(root, renderExpirationTime$1)
- : (workInProgressRootHasPendingPing = !0)
- : isRootSuspendedAtTime(root, suspendedTime) &&
- ((thenable = root.lastPingedTime),
- (0 !== thenable && thenable < suspendedTime) ||
- ((root.lastPingedTime = suspendedTime),
- ensureRootIsScheduled(root),
- schedulePendingInteractions(root, suspendedTime)));
-}
-function resolveRetryThenable(boundaryFiber, thenable) {
+ null !== pingCache && pingCache.delete(wakeable);
+ wakeable = requestEventTime();
+ root.pingedLanes |= root.suspendedLanes & pingedLanes;
+ workInProgressRoot === root &&
+ (workInProgressRootRenderLanes & pingedLanes) === pingedLanes &&
+ (4 === workInProgressRootExitStatus ||
+ (3 === workInProgressRootExitStatus &&
+ (workInProgressRootRenderLanes & 62914560) ===
+ workInProgressRootRenderLanes &&
+ 500 > now() - globalMostRecentFallbackTime)
+ ? prepareFreshStack(root, 0)
+ : (workInProgressRootPingedLanes |= pingedLanes));
+ ensureRootIsScheduled(root, wakeable);
+ schedulePendingInteractions(root, pingedLanes);
+}
+function resolveRetryWakeable(boundaryFiber, wakeable) {
var retryCache = boundaryFiber.stateNode;
- null !== retryCache && retryCache.delete(thenable);
- thenable = 0;
- 0 === thenable &&
- ((thenable = requestCurrentTimeForUpdate()),
- (thenable = computeExpirationForFiber(thenable, boundaryFiber, null)));
- boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable);
+ null !== retryCache && retryCache.delete(wakeable);
+ wakeable = 0;
+ 0 === wakeable &&
+ ((wakeable = boundaryFiber.mode),
+ 0 === (wakeable & 2)
+ ? (wakeable = 1)
+ : 0 === (wakeable & 4)
+ ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2)
+ : (0 === currentEventWipLanes &&
+ (currentEventWipLanes = workInProgressRootIncludedLanes),
+ (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)),
+ 0 === wakeable && (wakeable = 4194304)));
+ retryCache = requestEventTime();
+ boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable);
null !== boundaryFiber &&
- (ensureRootIsScheduled(boundaryFiber),
- schedulePendingInteractions(boundaryFiber, thenable));
+ (markRootUpdated(boundaryFiber, wakeable, retryCache),
+ ensureRootIsScheduled(boundaryFiber, retryCache),
+ schedulePendingInteractions(boundaryFiber, wakeable));
}
var beginWork$1;
-beginWork$1 = function(current, workInProgress, renderExpirationTime) {
- var updateExpirationTime = workInProgress.expirationTime;
+beginWork$1 = function(current, workInProgress, renderLanes) {
+ var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
didPerformWorkStackCursor.current
)
didReceiveUpdate = !0;
+ else if (0 !== (renderLanes & updateLanes))
+ didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1;
else {
- if (updateExpirationTime < renderExpirationTime) {
- didReceiveUpdate = !1;
- switch (workInProgress.tag) {
- case 3:
- pushHostRootContext(workInProgress);
- break;
- case 5:
- pushHostContext(workInProgress);
- break;
- case 1:
- isContextProvider(workInProgress.type) &&
- pushContextProvider(workInProgress);
- break;
- case 4:
- pushHostContainer(
+ didReceiveUpdate = !1;
+ switch (workInProgress.tag) {
+ case 3:
+ pushHostRootContext(workInProgress);
+ break;
+ case 5:
+ pushHostContext(workInProgress);
+ break;
+ case 1:
+ isContextProvider(workInProgress.type) &&
+ pushContextProvider(workInProgress);
+ break;
+ case 4:
+ pushHostContainer(
+ workInProgress,
+ workInProgress.stateNode.containerInfo
+ );
+ break;
+ case 10:
+ updateLanes = workInProgress.memoizedProps.value;
+ var context = workInProgress.type._context;
+ push(valueCursor, context._currentValue);
+ context._currentValue = updateLanes;
+ break;
+ case 12:
+ 0 !== (renderLanes & workInProgress.childLanes) &&
+ (workInProgress.effectTag |= 4);
+ updateLanes = workInProgress.stateNode;
+ updateLanes.effectDuration = 0;
+ updateLanes.passiveEffectDuration = 0;
+ break;
+ case 13:
+ if (null !== workInProgress.memoizedState) {
+ if (0 !== (renderLanes & workInProgress.child.childLanes))
+ return updateSuspenseComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ workInProgress = bailoutOnAlreadyFinishedWork(
+ current,
workInProgress,
- workInProgress.stateNode.containerInfo
+ renderLanes
);
- break;
- case 10:
- updateExpirationTime = workInProgress.memoizedProps.value;
- var context = workInProgress.type._context;
- push(valueCursor, context._currentValue);
- context._currentValue = updateExpirationTime;
- break;
- case 12:
- workInProgress.childExpirationTime >= renderExpirationTime &&
- (workInProgress.effectTag |= 4);
- updateExpirationTime = workInProgress.stateNode;
- updateExpirationTime.effectDuration = 0;
- updateExpirationTime.passiveEffectDuration = 0;
- break;
- case 13:
- if (null !== workInProgress.memoizedState) {
- updateExpirationTime = workInProgress.child.childExpirationTime;
- if (
- 0 !== updateExpirationTime &&
- updateExpirationTime >= renderExpirationTime
- )
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- workInProgress = bailoutOnAlreadyFinishedWork(
+ return null !== workInProgress ? workInProgress.sibling : null;
+ }
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
+ case 19:
+ updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.effectTag & 64)) {
+ if (updateLanes)
+ return updateSuspenseListComponent(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateExpirationTime =
- workInProgress.childExpirationTime >= renderExpirationTime;
- if (0 !== (current.effectTag & 64)) {
- if (updateExpirationTime)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
- workInProgress.effectTag |= 64;
- }
- context = workInProgress.memoizedState;
- null !== context &&
- ((context.rendering = null), (context.tail = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (!updateExpirationTime) return null;
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderExpirationTime
- );
+ workInProgress.effectTag |= 64;
+ }
+ context = workInProgress.memoizedState;
+ null !== context &&
+ ((context.rendering = null),
+ (context.tail = null),
+ (context.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (updateLanes) break;
+ else return null;
+ case 23:
+ case 24:
+ return (
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
+ );
}
- didReceiveUpdate = !1;
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
else didReceiveUpdate = !1;
- workInProgress.expirationTime = 0;
+ workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateExpirationTime = workInProgress.type;
+ updateLanes = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
context = getMaskedContext(workInProgress, contextStackCursor.current);
- prepareToReadContext(workInProgress, renderExpirationTime);
+ prepareToReadContext(workInProgress, renderLanes);
context = renderWithHooks(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
current,
context,
- renderExpirationTime
+ renderLanes
);
workInProgress.effectTag |= 1;
if (
@@ -6919,7 +7359,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateExpirationTime)) {
+ if (isContextProvider(updateLanes)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
@@ -6928,53 +7368,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
? context.state
: null;
initializeUpdateQueue(workInProgress);
- var getDerivedStateFromProps =
- updateExpirationTime.getDerivedStateFromProps;
+ var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps;
"function" === typeof getDerivedStateFromProps &&
applyDerivedStateFromProps(
workInProgress,
- updateExpirationTime,
+ updateLanes,
getDerivedStateFromProps,
current
);
context.updater = classComponentUpdater;
workInProgress.stateNode = context;
- context._reactInternalFiber = workInProgress;
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- current,
- renderExpirationTime
- );
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, updateLanes, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
hasContext,
- renderExpirationTime
+ renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(
- null,
- workInProgress,
- context,
- renderExpirationTime
- ),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
+ context = workInProgress.elementType;
a: {
- context = workInProgress.elementType;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2));
current = workInProgress.pendingProps;
- initializeLazyComponentType(context);
- if (1 !== context._status) throw context._result;
- context = context._result;
+ hasContext = context._init;
+ context = hasContext(context._payload);
workInProgress.type = context;
hasContext = workInProgress.tag = resolveLazyComponentTag(context);
current = resolveDefaultProps(context, current);
@@ -6985,7 +7413,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 1:
@@ -6994,7 +7422,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 11:
@@ -7003,7 +7431,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
current,
- renderExpirationTime
+ renderLanes
);
break a;
case 14:
@@ -7012,8 +7440,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
resolveDefaultProps(context.type, current),
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
break a;
}
@@ -7026,126 +7454,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return workInProgress;
case 0:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateFunctionComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 1:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateClassComponent(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- updateExpirationTime = workInProgress.updateQueue;
- if (null === current || null === updateExpirationTime)
+ updateLanes = workInProgress.updateQueue;
+ if (null === current || null === updateLanes)
throw Error(
"If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."
);
- updateExpirationTime = workInProgress.pendingProps;
+ updateLanes = workInProgress.pendingProps;
context = workInProgress.memoizedState;
context = null !== context ? context.element : null;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(
- workInProgress,
- updateExpirationTime,
- null,
- renderExpirationTime
- );
- updateExpirationTime = workInProgress.memoizedState.element;
- updateExpirationTime === context
+ processUpdateQueue(workInProgress, updateLanes, null, renderLanes);
+ updateLanes = workInProgress.memoizedState.element;
+ updateLanes === context
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
))
- : (reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ : (reconcileChildren(current, workInProgress, updateLanes, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateExpirationTime = workInProgress.pendingProps.children),
+ (updateLanes = workInProgress.pendingProps.children),
markRef(current, workInProgress),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
- (workInProgress = workInProgress.child),
- workInProgress
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ workInProgress.child
);
case 6:
return null;
case 13:
- return updateSuspenseComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
case 4:
return (
pushHostContainer(
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateExpirationTime = workInProgress.pendingProps),
+ (updateLanes = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
))
: reconcileChildren(
current,
workInProgress,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
),
workInProgress.child
);
case 11:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
updateForwardRef(
current,
workInProgress,
- updateExpirationTime,
+ updateLanes,
context,
- renderExpirationTime
+ renderLanes
)
);
case 7:
@@ -7154,7 +7562,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
@@ -7164,27 +7572,27 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
case 12:
return (
(workInProgress.effectTag |= 4),
- (updateExpirationTime = workInProgress.stateNode),
- (updateExpirationTime.effectDuration = 0),
- (updateExpirationTime.passiveEffectDuration = 0),
+ (updateLanes = workInProgress.stateNode),
+ (updateLanes.effectDuration = 0),
+ (updateLanes.passiveEffectDuration = 0),
reconcileChildren(
current,
workInProgress,
workInProgress.pendingProps.children,
- renderExpirationTime
+ renderLanes
),
workInProgress.child
);
case 10:
a: {
- updateExpirationTime = workInProgress.type._context;
+ updateLanes = workInProgress.type._context;
context = workInProgress.pendingProps;
getDerivedStateFromProps = workInProgress.memoizedProps;
hasContext = context.value;
@@ -7196,9 +7604,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
((context$jscomp$0 = getDerivedStateFromProps.value),
(hasContext = objectIs(context$jscomp$0, hasContext)
? 0
- : ("function" ===
- typeof updateExpirationTime._calculateChangedBits
- ? updateExpirationTime._calculateChangedBits(
+ : ("function" === typeof updateLanes._calculateChangedBits
+ ? updateLanes._calculateChangedBits(
context$jscomp$0,
hasContext
)
@@ -7212,7 +7619,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- renderExpirationTime
+ renderLanes
);
break a;
}
@@ -7233,25 +7640,25 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
) {
if (
- dependency.context === updateExpirationTime &&
+ dependency.context === updateLanes &&
0 !== (dependency.observedBits & hasContext)
) {
1 === context$jscomp$0.tag &&
- ((dependency = createUpdate(renderExpirationTime, null)),
+ ((dependency = createUpdate(
+ -1,
+ renderLanes & -renderLanes,
+ null
+ )),
(dependency.tag = 2),
enqueueUpdate(context$jscomp$0, dependency));
- context$jscomp$0.expirationTime < renderExpirationTime &&
- (context$jscomp$0.expirationTime = renderExpirationTime);
+ context$jscomp$0.lanes |= renderLanes;
dependency = context$jscomp$0.alternate;
- null !== dependency &&
- dependency.expirationTime < renderExpirationTime &&
- (dependency.expirationTime = renderExpirationTime);
+ null !== dependency && (dependency.lanes |= renderLanes);
scheduleWorkOnParentPath(
context$jscomp$0.return,
- renderExpirationTime
+ renderLanes
);
- list.expirationTime < renderExpirationTime &&
- (list.expirationTime = renderExpirationTime);
+ list.lanes |= renderLanes;
break;
}
dependency = dependency.next;
@@ -7289,7 +7696,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
current,
workInProgress,
context.children,
- renderExpirationTime
+ renderLanes
);
workInProgress = workInProgress.child;
}
@@ -7298,17 +7705,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
return (
(context = workInProgress.type),
(hasContext = workInProgress.pendingProps),
- (updateExpirationTime = hasContext.children),
- prepareToReadContext(workInProgress, renderExpirationTime),
+ (updateLanes = hasContext.children),
+ prepareToReadContext(workInProgress, renderLanes),
(context = readContext(context, hasContext.unstable_observedBits)),
- (updateExpirationTime = updateExpirationTime(context)),
+ (updateLanes = updateLanes(context)),
(workInProgress.effectTag |= 1),
- reconcileChildren(
- current,
- workInProgress,
- updateExpirationTime,
- renderExpirationTime
- ),
+ reconcileChildren(current, workInProgress, updateLanes, renderLanes),
workInProgress.child
);
case 14:
@@ -7324,8 +7726,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
context,
hasContext,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
)
);
case 15:
@@ -7334,48 +7736,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateExpirationTime,
- renderExpirationTime
+ updateLanes,
+ renderLanes
);
case 17:
return (
- (updateExpirationTime = workInProgress.type),
+ (updateLanes = workInProgress.type),
(context = workInProgress.pendingProps),
(context =
- workInProgress.elementType === updateExpirationTime
+ workInProgress.elementType === updateLanes
? context
- : resolveDefaultProps(updateExpirationTime, context)),
+ : resolveDefaultProps(updateLanes, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.effectTag |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateExpirationTime)
+ isContextProvider(updateLanes)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
- prepareToReadContext(workInProgress, renderExpirationTime),
- constructClassInstance(workInProgress, updateExpirationTime, context),
- mountClassInstance(
- workInProgress,
- updateExpirationTime,
- context,
- renderExpirationTime
- ),
+ prepareToReadContext(workInProgress, renderLanes),
+ constructClassInstance(workInProgress, updateLanes, context),
+ mountClassInstance(workInProgress, updateLanes, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateExpirationTime,
+ updateLanes,
!0,
current,
- renderExpirationTime
+ renderLanes
)
);
case 19:
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderExpirationTime
- );
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
+ case 23:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ case 24:
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -7383,16 +7780,16 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) {
"). This error is likely caused by a bug in React. Please file an issue."
);
};
-function scheduleInteractions(root, expirationTime, interactions) {
+function scheduleInteractions(root, lane, interactions) {
if (0 < interactions.size) {
var pendingInteractionMap = root.pendingInteractionMap,
- pendingInteractions = pendingInteractionMap.get(expirationTime);
+ pendingInteractions = pendingInteractionMap.get(lane);
null != pendingInteractions
? interactions.forEach(function(interaction) {
pendingInteractions.has(interaction) || interaction.__count++;
pendingInteractions.add(interaction);
})
- : (pendingInteractionMap.set(expirationTime, new Set(interactions)),
+ : (pendingInteractionMap.set(lane, new Set(interactions)),
interactions.forEach(function(interaction) {
interaction.__count++;
}));
@@ -7400,20 +7797,20 @@ function scheduleInteractions(root, expirationTime, interactions) {
if (null !== pendingInteractionMap)
pendingInteractionMap.onWorkScheduled(
interactions,
- 1e3 * expirationTime + root.interactionThreadID
+ 1e3 * lane + root.interactionThreadID
);
}
}
-function schedulePendingInteractions(root, expirationTime) {
- scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
+function schedulePendingInteractions(root, lane) {
+ scheduleInteractions(root, lane, tracing.__interactionsRef.current);
}
-function startWorkOnPendingInteractions(root, expirationTime) {
+function startWorkOnPendingInteractions(root, lanes) {
var interactions = new Set();
root.pendingInteractionMap.forEach(function(
scheduledInteractions,
- scheduledExpirationTime
+ scheduledLane
) {
- scheduledExpirationTime >= expirationTime &&
+ 0 !== (lanes & scheduledLane) &&
scheduledInteractions.forEach(function(interaction) {
return interactions.add(interaction);
});
@@ -7422,7 +7819,7 @@ function startWorkOnPendingInteractions(root, expirationTime) {
if (0 < interactions.size) {
var subscriber = tracing.__subscriberRef.current;
if (null !== subscriber) {
- root = 1e3 * expirationTime + root.interactionThreadID;
+ root = 1e3 * lanes + root.interactionThreadID;
try {
subscriber.onWorkStarted(interactions, root);
} catch (error) {
@@ -7433,14 +7830,14 @@ function startWorkOnPendingInteractions(root, expirationTime) {
}
}
}
-function finishPendingInteractions(root, committedExpirationTime) {
- var earliestRemainingTimeAfterCommit = root.firstPendingTime;
+function finishPendingInteractions(root, committedLanes) {
+ var remainingLanesAfterCommit = root.pendingLanes;
try {
var subscriber = tracing.__subscriberRef.current;
if (null !== subscriber && 0 < root.memoizedInteractions.size)
subscriber.onWorkStopped(
root.memoizedInteractions,
- 1e3 * committedExpirationTime + root.interactionThreadID
+ 1e3 * committedLanes + root.interactionThreadID
);
} catch (error) {
scheduleCallback(99, function() {
@@ -7448,54 +7845,23 @@ function finishPendingInteractions(root, committedExpirationTime) {
});
} finally {
var pendingInteractionMap = root.pendingInteractionMap;
- pendingInteractionMap.forEach(function(
- scheduledInteractions,
- scheduledExpirationTime
- ) {
- scheduledExpirationTime > earliestRemainingTimeAfterCommit &&
- (pendingInteractionMap.delete(scheduledExpirationTime),
+ pendingInteractionMap.forEach(function(scheduledInteractions, lane) {
+ 0 === (remainingLanesAfterCommit & lane) &&
+ (pendingInteractionMap.delete(lane),
scheduledInteractions.forEach(function(interaction) {
interaction.__count--;
if (null !== subscriber && 0 === interaction.__count)
try {
subscriber.onInteractionScheduledWorkCompleted(interaction);
- } catch (error) {
+ } catch (error$108) {
scheduleCallback(99, function() {
- throw error;
+ throw error$108;
});
}
}));
});
}
}
-var onCommitFiberRoot = null,
- onCommitFiberUnmount = null,
- isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__;
-function injectInternals(internals) {
- if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1;
- var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
- if (hook.isDisabled || !hook.supportsFiber) return !0;
- try {
- var rendererID = hook.inject(internals);
- onCommitFiberRoot = function(root, expirationTime) {
- try {
- var didError = 64 === (root.current.effectTag & 64),
- currentTime = 1073741821 - ((now() / 10) | 0),
- priorityLevel = inferPriorityFromExpirationTime(
- currentTime,
- expirationTime
- );
- hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
- } catch (err) {}
- };
- onCommitFiberUnmount = function(fiber) {
- try {
- hook.onCommitFiberUnmount(rendererID, fiber);
- } catch (err) {}
- };
- } catch (err) {}
- return !0;
-}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -7507,12 +7873,15 @@ function FiberNode(tag, pendingProps, key, mode) {
this.mode = mode;
this.effectTag = 0;
this.lastEffect = this.firstEffect = this.nextEffect = null;
- this.childExpirationTime = this.expirationTime = 0;
+ this.childLanes = this.lanes = 0;
this.alternate = null;
this.actualDuration = 0;
this.actualStartTime = -1;
this.treeBaseDuration = this.selfBaseDuration = 0;
}
+function createFiber(tag, pendingProps, key, mode) {
+ return new FiberNode(tag, pendingProps, key, mode);
+}
function shouldConstruct(Component) {
Component = Component.prototype;
return !(!Component || !Component.isReactComponent);
@@ -7530,7 +7899,7 @@ function resolveLazyComponentTag(Component) {
function createWorkInProgress(current, pendingProps) {
var workInProgress = current.alternate;
null === workInProgress
- ? ((workInProgress = new FiberNode(
+ ? ((workInProgress = createFiber(
current.tag,
pendingProps,
current.key,
@@ -7542,18 +7911,15 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.alternate = current),
(current.alternate = workInProgress))
: ((workInProgress.pendingProps = pendingProps),
+ (workInProgress.type = current.type),
(workInProgress.effectTag = 0),
(workInProgress.nextEffect = null),
(workInProgress.firstEffect = null),
(workInProgress.lastEffect = null),
(workInProgress.actualDuration = 0),
(workInProgress.actualStartTime = -1));
- if (null == current)
- throw Error("current is " + current + " but it can't be");
- if (null == workInProgress)
- throw Error("workInProgress is " + workInProgress + " but it can't be");
- workInProgress.childExpirationTime = current.childExpirationTime;
- workInProgress.expirationTime = current.expirationTime;
+ workInProgress.childLanes = current.childLanes;
+ workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
@@ -7563,7 +7929,7 @@ function createWorkInProgress(current, pendingProps) {
null === pendingProps
? null
: {
- expirationTime: pendingProps.expirationTime,
+ lanes: pendingProps.lanes,
firstContext: pendingProps.firstContext,
responders: pendingProps.responders
};
@@ -7580,7 +7946,7 @@ function createFiberFromTypeAndProps(
pendingProps,
owner,
mode,
- expirationTime
+ lanes
) {
var fiberTag = 2;
owner = type;
@@ -7589,15 +7955,10 @@ function createFiberFromTypeAndProps(
else
a: switch (type) {
case REACT_FRAGMENT_TYPE:
- return createFiberFromFragment(
- pendingProps.children,
- mode,
- expirationTime,
- key
- );
- case REACT_CONCURRENT_MODE_TYPE:
+ return createFiberFromFragment(pendingProps.children, mode, lanes, key);
+ case REACT_DEBUG_TRACING_MODE_TYPE:
fiberTag = 8;
- mode |= 7;
+ mode |= 16;
break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
@@ -7605,26 +7966,35 @@ function createFiberFromTypeAndProps(
break;
case REACT_PROFILER_TYPE:
return (
- (type = new FiberNode(12, pendingProps, key, mode | 8)),
+ (type = createFiber(12, pendingProps, key, mode | 8)),
(type.elementType = REACT_PROFILER_TYPE),
(type.type = REACT_PROFILER_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
(type.stateNode = { effectDuration: 0, passiveEffectDuration: 0 }),
type
);
case REACT_SUSPENSE_TYPE:
return (
- (type = new FiberNode(13, pendingProps, key, mode)),
+ (type = createFiber(13, pendingProps, key, mode)),
(type.type = REACT_SUSPENSE_TYPE),
(type.elementType = REACT_SUSPENSE_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
type
);
case REACT_SUSPENSE_LIST_TYPE:
return (
- (type = new FiberNode(19, pendingProps, key, mode)),
+ (type = createFiber(19, pendingProps, key, mode)),
(type.elementType = REACT_SUSPENSE_LIST_TYPE),
- (type.expirationTime = expirationTime),
+ (type.lanes = lanes),
+ type
+ );
+ case REACT_OFFSCREEN_TYPE:
+ return createFiberFromOffscreen(pendingProps, mode, lanes, key);
+ case REACT_LEGACY_HIDDEN_TYPE:
+ return (
+ (type = createFiber(24, pendingProps, key, mode)),
+ (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
+ (type.lanes = lanes),
type
);
default:
@@ -7656,30 +8026,36 @@ function createFiberFromTypeAndProps(
"."
);
}
- key = new FiberNode(fiberTag, pendingProps, key, mode);
+ key = createFiber(fiberTag, pendingProps, key, mode);
key.elementType = type;
key.type = owner;
- key.expirationTime = expirationTime;
+ key.lanes = lanes;
return key;
}
-function createFiberFromFragment(elements, mode, expirationTime, key) {
- elements = new FiberNode(7, elements, key, mode);
- elements.expirationTime = expirationTime;
+function createFiberFromFragment(elements, mode, lanes, key) {
+ elements = createFiber(7, elements, key, mode);
+ elements.lanes = lanes;
return elements;
}
-function createFiberFromText(content, mode, expirationTime) {
- content = new FiberNode(6, content, null, mode);
- content.expirationTime = expirationTime;
+function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
+ pendingProps = createFiber(23, pendingProps, key, mode);
+ pendingProps.elementType = REACT_OFFSCREEN_TYPE;
+ pendingProps.lanes = lanes;
+ return pendingProps;
+}
+function createFiberFromText(content, mode, lanes) {
+ content = createFiber(6, content, null, mode);
+ content.lanes = lanes;
return content;
}
-function createFiberFromPortal(portal, mode, expirationTime) {
- mode = new FiberNode(
+function createFiberFromPortal(portal, mode, lanes) {
+ mode = createFiber(
4,
null !== portal.children ? portal.children : [],
portal.key,
mode
);
- mode.expirationTime = expirationTime;
+ mode.lanes = lanes;
mode.stateNode = {
containerInfo: portal.containerInfo,
pendingChildren: null,
@@ -7689,54 +8065,34 @@ function createFiberFromPortal(portal, mode, expirationTime) {
}
function FiberRootNode(containerInfo, tag, hydrate) {
this.tag = tag;
- this.current = null;
this.containerInfo = containerInfo;
- this.pingCache = this.pendingChildren = null;
- this.finishedExpirationTime = 0;
- this.finishedWork = null;
+ this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
this.pendingContext = this.context = null;
this.hydrate = hydrate;
this.callbackNode = null;
- this.callbackPriority = 90;
- this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0;
+ this.callbackPriority = 0;
+ this.eventTimes = Array(31).fill(0);
+ this.expirationTimes = Array(31).fill(-1);
+ this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
+ this.entanglements = Array(31).fill(0);
this.interactionThreadID = tracing.unstable_getThreadID();
this.memoizedInteractions = new Set();
this.pendingInteractionMap = new Map();
}
-function isRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime;
- root = root.lastSuspendedTime;
- return (
- 0 !== firstSuspendedTime &&
- firstSuspendedTime >= expirationTime &&
- root <= expirationTime
- );
-}
-function markRootSuspendedAtTime(root, expirationTime) {
- var firstSuspendedTime = root.firstSuspendedTime,
- lastSuspendedTime = root.lastSuspendedTime;
- firstSuspendedTime < expirationTime &&
- (root.firstSuspendedTime = expirationTime);
- if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime)
- root.lastSuspendedTime = expirationTime;
- expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0);
- expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0);
-}
-function markRootUpdatedAtTime(root, expirationTime) {
- expirationTime > root.firstPendingTime &&
- (root.firstPendingTime = expirationTime);
- var firstSuspendedTime = root.firstSuspendedTime;
- 0 !== firstSuspendedTime &&
- (expirationTime >= firstSuspendedTime
- ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0)
- : expirationTime >= root.lastSuspendedTime &&
- (root.lastSuspendedTime = expirationTime + 1),
- expirationTime > root.nextKnownPendingLevel &&
- (root.nextKnownPendingLevel = expirationTime));
+function createPortal(children, containerInfo, implementation) {
+ var key =
+ 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
+ return {
+ $$typeof: REACT_PORTAL_TYPE,
+ key: null == key ? null : "" + key,
+ children: children,
+ containerInfo: containerInfo,
+ implementation: implementation
+ };
}
function findHostInstance(component) {
- var fiber = component._reactInternalFiber;
+ var fiber = component._reactInternals;
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
@@ -7750,11 +8106,11 @@ function findHostInstance(component) {
}
function updateContainer(element, container, parentComponent, callback) {
var current = container.current,
- currentTime = requestCurrentTimeForUpdate(),
- suspenseConfig = ReactCurrentBatchConfig.suspense;
- currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig);
+ eventTime = requestEventTime(),
+ suspenseConfig = ReactCurrentBatchConfig.suspense,
+ lane = requestUpdateLane(current, suspenseConfig);
a: if (parentComponent) {
- parentComponent = parentComponent._reactInternalFiber;
+ parentComponent = parentComponent._reactInternals;
b: {
if (
getNearestMountedFiber(parentComponent) !== parentComponent ||
@@ -7763,22 +8119,23 @@ function updateContainer(element, container, parentComponent, callback) {
throw Error(
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
);
- var parentContext = parentComponent;
+ var JSCompiler_inline_result = parentComponent;
do {
- switch (parentContext.tag) {
+ switch (JSCompiler_inline_result.tag) {
case 3:
- parentContext = parentContext.stateNode.context;
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode.context;
break b;
case 1:
- if (isContextProvider(parentContext.type)) {
- parentContext =
- parentContext.stateNode
+ if (isContextProvider(JSCompiler_inline_result.type)) {
+ JSCompiler_inline_result =
+ JSCompiler_inline_result.stateNode
.__reactInternalMemoizedMergedChildContext;
break b;
}
}
- parentContext = parentContext.return;
- } while (null !== parentContext);
+ JSCompiler_inline_result = JSCompiler_inline_result.return;
+ } while (null !== JSCompiler_inline_result);
throw Error(
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
);
@@ -7789,34 +8146,26 @@ function updateContainer(element, container, parentComponent, callback) {
parentComponent = processChildContext(
parentComponent,
Component,
- parentContext
+ JSCompiler_inline_result
);
break a;
}
}
- parentComponent = parentContext;
+ parentComponent = JSCompiler_inline_result;
} else parentComponent = emptyContextObject;
null === container.context
? (container.context = parentComponent)
: (container.pendingContext = parentComponent);
- container = createUpdate(currentTime, suspenseConfig);
+ container = createUpdate(eventTime, lane, suspenseConfig);
container.payload = { element: element };
callback = void 0 === callback ? null : callback;
null !== callback && (container.callback = callback);
enqueueUpdate(current, container);
- scheduleWork(current, currentTime);
- return currentTime;
+ scheduleUpdateOnFiber(current, lane, eventTime);
+ return lane;
}
-function createPortal(children, containerInfo, implementation) {
- var key =
- 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
- return {
- $$typeof: REACT_PORTAL_TYPE,
- key: null == key ? null : "" + key,
- children: children,
- containerInfo: containerInfo,
- implementation: implementation
- };
+function emptyFindFiberByHostInstance() {
+ return null;
}
function findNodeHandle(componentOrHandle) {
if (null == componentOrHandle) return null;
@@ -7845,53 +8194,64 @@ batchedUpdatesImpl = function(fn, a) {
return fn(a);
} finally {
(executionContext = prevExecutionContext),
- executionContext === NoContext && flushSyncCallbackQueue();
+ 0 === executionContext && flushSyncCallbackQueue();
}
};
-var roots = new Map();
-(function(devToolsConfig) {
- var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
- return injectInternals({
- bundleType: devToolsConfig.bundleType,
- version: devToolsConfig.version,
- rendererPackageName: devToolsConfig.rendererPackageName,
- rendererConfig: devToolsConfig.rendererConfig,
- overrideHookState: null,
- overrideProps: null,
- setSuspenseHandler: null,
- scheduleUpdate: null,
- currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
- findHostInstanceByFiber: function(fiber) {
- fiber = findCurrentHostFiber(fiber);
- return null === fiber ? null : fiber.stateNode;
- },
- findFiberByHostInstance: function(instance) {
- return findFiberByHostInstance ? findFiberByHostInstance(instance) : null;
- },
- findHostInstancesForRefresh: null,
- scheduleRefresh: null,
- scheduleRoot: null,
- setRefreshHandler: null,
- getCurrentFiber: null
- });
-})({
- findFiberByHostInstance: getInstanceFromTag,
- bundleType: 0,
- version: "16.13.0",
- rendererPackageName: "react-native-renderer",
- rendererConfig: {
- getInspectorDataForViewTag: function() {
- throw Error(
- "getInspectorDataForViewTag() is not available in production"
- );
- },
- getInspectorDataForViewAtPoint: function() {
- throw Error(
- "getInspectorDataForViewAtPoint() is not available in production."
- );
- }.bind(null, findNodeHandle)
- }
-});
+var roots = new Map(),
+ devToolsConfig$jscomp$inline_956 = {
+ findFiberByHostInstance: getInstanceFromTag,
+ bundleType: 0,
+ version: "17.0.0-alpha.0",
+ rendererPackageName: "react-native-renderer",
+ rendererConfig: {
+ getInspectorDataForViewTag: function() {
+ throw Error(
+ "getInspectorDataForViewTag() is not available in production"
+ );
+ },
+ getInspectorDataForViewAtPoint: function() {
+ throw Error(
+ "getInspectorDataForViewAtPoint() is not available in production."
+ );
+ }.bind(null, findNodeHandle)
+ }
+ };
+var internals$jscomp$inline_1172 = {
+ bundleType: devToolsConfig$jscomp$inline_956.bundleType,
+ version: devToolsConfig$jscomp$inline_956.version,
+ rendererPackageName: devToolsConfig$jscomp$inline_956.rendererPackageName,
+ rendererConfig: devToolsConfig$jscomp$inline_956.rendererConfig,
+ overrideHookState: null,
+ overrideProps: null,
+ setSuspenseHandler: null,
+ scheduleUpdate: null,
+ currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
+ findHostInstanceByFiber: function(fiber) {
+ fiber = findCurrentHostFiber(fiber);
+ return null === fiber ? null : fiber.stateNode;
+ },
+ findFiberByHostInstance:
+ devToolsConfig$jscomp$inline_956.findFiberByHostInstance ||
+ emptyFindFiberByHostInstance,
+ findHostInstancesForRefresh: null,
+ scheduleRefresh: null,
+ scheduleRoot: null,
+ setRefreshHandler: null,
+ getCurrentFiber: null
+};
+if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
+ var hook$jscomp$inline_1173 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ if (
+ !hook$jscomp$inline_1173.isDisabled &&
+ hook$jscomp$inline_1173.supportsFiber
+ )
+ try {
+ (rendererID = hook$jscomp$inline_1173.inject(
+ internals$jscomp$inline_1172
+ )),
+ (injectedHook = hook$jscomp$inline_1173);
+ } catch (err) {}
+}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
computeComponentStackForErrorReporting: function(reactTag) {
return (reactTag = getInstanceFromTag(reactTag))
@@ -7938,12 +8298,17 @@ exports.render = function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
root = new FiberRootNode(containerTag, 0, !1);
- var uninitializedFiber = 0;
- isDevToolsPresent && (uninitializedFiber |= 8);
- uninitializedFiber = new FiberNode(3, null, null, uninitializedFiber);
- root.current = uninitializedFiber;
- uninitializedFiber.stateNode = root;
- initializeUpdateQueue(uninitializedFiber);
+ var JSCompiler_inline_result = 0;
+ isDevToolsPresent && (JSCompiler_inline_result |= 8);
+ JSCompiler_inline_result = createFiber(
+ 3,
+ null,
+ null,
+ JSCompiler_inline_result
+ );
+ root.current = JSCompiler_inline_result;
+ JSCompiler_inline_result.stateNode = root;
+ initializeUpdateQueue(JSCompiler_inline_result);
roots.set(containerTag, root);
}
updateContainer(element, root, null, callback);
diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js
index 41d220ab71a936..2f9876384b8357 100644
--- a/Libraries/Renderer/shims/ReactNativeTypes.js
+++ b/Libraries/Renderer/shims/ReactNativeTypes.js
@@ -212,7 +212,6 @@ export type ReactFaricEvent = {
...
};
-//
// Imperative LayoutAnimation API types
//
export type LayoutAnimationType =
diff --git a/package.json b/package.json
index cd92bab7e33c16..e1067504c09f24 100644
--- a/package.json
+++ b/package.json
@@ -82,7 +82,7 @@
"test-ios": "./scripts/objc-test.sh test"
},
"peerDependencies": {
- "react": "0.0.0-experimental-aae83a4b9"
+ "react": "16.13.1"
},
"dependencies": {
"@react-native-community/cli": "^4.10.0",
@@ -111,7 +111,7 @@
"react-devtools-core": "^4.6.0",
"react-refresh": "^0.4.0",
"regenerator-runtime": "^0.13.2",
- "scheduler": "0.0.0-experimental-aae83a4b9",
+ "scheduler": "0.19.1",
"stacktrace-parser": "^0.1.3",
"use-subscription": "^1.0.0",
"whatwg-fetch": "^3.0.0"
@@ -147,9 +147,9 @@
"jscodeshift": "^0.9.0",
"mkdirp": "^0.5.1",
"prettier": "1.19.1",
- "react": "0.0.0-experimental-aae83a4b9",
+ "react": "16.13.1",
+ "react-test-renderer": "16.13.1",
"react-shallow-renderer": "16.13.1",
- "react-test-renderer": "0.0.0-experimental-aae83a4b9",
"shelljs": "^0.7.8",
"signedsource": "^1.0.0",
"ws": "^6.1.4",
diff --git a/template/package.json b/template/package.json
index b9f6e1b2943ee9..c0e21af4a7263a 100644
--- a/template/package.json
+++ b/template/package.json
@@ -10,7 +10,7 @@
"lint": "eslint ."
},
"dependencies": {
- "react": "0.0.0-experimental-aae83a4b9",
+ "react": "16.13.1",
"react-native": "1000.0.0"
},
"devDependencies": {
@@ -21,7 +21,7 @@
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.61.0",
- "react-test-renderer": "0.0.0-experimental-aae83a4b9 "
+ "react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
diff --git a/yarn.lock b/yarn.lock
index b168a1baf8d7d4..debeb305440c3e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6217,11 +6217,6 @@ react-devtools-core@^4.6.0:
shell-quote "^1.6.1"
ws "^7"
-react-is@0.0.0-experimental-aae83a4b9:
- version "0.0.0-experimental-aae83a4b9"
- resolved "https://registry.yarnpkg.com/react-is/-/react-is-0.0.0-experimental-aae83a4b9.tgz#9dde6f4ac1da013398bf990706af2d4f59774d2b"
- integrity sha512-0AZ4lHKqoXzYZ5RhNtj7ODYhQ6fXLDRn9lRapoVxYd2rgfe6LLrrf7ob5lweuo/krb7heBGINZ479FdQIvNLfg==
-
react-is@^16.12.0:
version "16.12.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c"
@@ -6232,12 +6227,17 @@ react-is@^16.8.1, react-is@^16.8.4:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2"
integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA==
+react-is@^16.8.6:
+ version "16.13.1"
+ resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
+ integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
+
react-refresh@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.4.0.tgz#d421f9bd65e0e4b9822a399f14ac56bda9c92292"
integrity sha512-bacjSio8GOtzNZKZZM6EWqbhlbb6pr28JWJWFTLwEBKvPIBRo6/Ob68D2EWZA2VyTdQxAh+TRnCYOPNKsQiXTA==
-react-shallow-renderer@16.13.1, react-shallow-renderer@^16.13.1:
+react-shallow-renderer@16.13.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.13.1.tgz#4cfd6dc0f05a8d4d261ff7a80e9b88f15491a00a"
integrity sha512-hLmExm5/ZnjodLgm/4oxYw4i7fL6LLPhbO9mF/4tmaZUurtLrp2aSeDHZmRk0SVCHXPz0VaEbb3Dqi5J7odz7Q==
@@ -6245,23 +6245,24 @@ react-shallow-renderer@16.13.1, react-shallow-renderer@^16.13.1:
object-assign "^4.1.1"
react-is "^16.12.0"
-react-test-renderer@0.0.0-experimental-aae83a4b9:
- version "0.0.0-experimental-aae83a4b9"
- resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-0.0.0-experimental-aae83a4b9.tgz#494dc7b72fe7ab6d469cd43032e686aa15f767f8"
- integrity sha512-Wbj7W/YQhJZpC5FbJmOgtEUNIFKfXmWvAHlJn9wc636pUHTMDYs/180qJlUwtrfW2WLb1xEpPKZQ9RnfT7gVxg==
+react-test-renderer@16.13.1:
+ version "16.13.1"
+ resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.13.1.tgz#de25ea358d9012606de51e012d9742e7f0deabc1"
+ integrity sha512-Sn2VRyOK2YJJldOqoh8Tn/lWQ+ZiKhyZTPtaO0Q6yNj+QDbmRkVFap6pZPy3YQk8DScRDfyqm/KxKYP9gCMRiQ==
dependencies:
object-assign "^4.1.1"
- react-is "0.0.0-experimental-aae83a4b9"
- react-shallow-renderer "^16.13.1"
- scheduler "0.0.0-experimental-aae83a4b9"
+ prop-types "^15.6.2"
+ react-is "^16.8.6"
+ scheduler "^0.19.1"
-react@0.0.0-experimental-aae83a4b9:
- version "0.0.0-experimental-aae83a4b9"
- resolved "https://registry.yarnpkg.com/react/-/react-0.0.0-experimental-aae83a4b9.tgz#9b2063ddb2dc9a3d347e7a0a4233462c78800ba0"
- integrity sha512-PuabEUXkXk9E4FrB3FoHY6GwvkqBpN7Od2V91TQgwJcgfErMIXQQm1n9GxzQBJ/RfgkTBCoaV4zEC/B8cNJWjw==
+react@16.13.1:
+ version "16.13.1"
+ resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e"
+ integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
+ prop-types "^15.6.2"
read-pkg-up@^7.0.1:
version "7.0.1"
@@ -6678,10 +6679,10 @@ saxes@^5.0.0:
dependencies:
xmlchars "^2.2.0"
-scheduler@0.0.0-experimental-aae83a4b9:
- version "0.0.0-experimental-aae83a4b9"
- resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.0.0-experimental-aae83a4b9.tgz#da2d706425a55ff1538d26f634171bc333a38b3b"
- integrity sha512-z0Z0TqehF/6dZbOtRcdvJBX5qUWhNs4sLddxe8VtCThTnBhK+vv5Hv6R/LP5UcE+ROk8988uTYlQExzofI7yZA==
+scheduler@0.19.1, scheduler@^0.19.1:
+ version "0.19.1"
+ resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196"
+ integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"