diff --git a/Libraries/Components/TextInput/__tests__/TextInput-test.js b/Libraries/Components/TextInput/__tests__/TextInput-test.js
index f63c82bebe6d2f..18992428a64612 100644
--- a/Libraries/Components/TextInput/__tests__/TextInput-test.js
+++ b/Libraries/Components/TextInput/__tests__/TextInput-test.js
@@ -14,8 +14,6 @@ const ReactTestRenderer = require('react-test-renderer');
const TextInput = require('../TextInput');
const ReactNative = require('../../../Renderer/shims/ReactNative');
-import Component from '@reactions/component';
-
const {
enter,
expectRendersMatchingSnapshot,
@@ -33,23 +31,24 @@ describe('TextInput tests', () => {
inputRef = React.createRef(null);
onChangeListener = jest.fn();
onChangeTextListener = jest.fn();
- const renderTree = ReactTestRenderer.create(
-
- {({setState, state}) => (
- {
- onChangeTextListener(text);
- setState({text});
- }}
- onChange={event => {
- onChangeListener(event);
- }}
- />
- )}
- ,
- );
+ function TextInputWrapper() {
+ const [state, setState] = React.useState({text: initialValue});
+
+ return (
+ {
+ onChangeTextListener(text);
+ setState({text});
+ }}
+ onChange={event => {
+ onChangeListener(event);
+ }}
+ />
+ );
+ }
+ const renderTree = ReactTestRenderer.create();
input = renderTree.root.findByType(TextInput);
});
it('has expected instance functions', () => {
@@ -71,7 +70,9 @@ describe('TextInput tests', () => {
it('calls onChange callbacks', () => {
expect(input.props.value).toBe(initialValue);
const message = 'This is a test message';
- enter(input, message);
+ ReactTestRenderer.act(() => {
+ enter(input, message);
+ });
expect(input.props.value).toBe(message);
expect(onChangeTextListener).toHaveBeenCalledWith(message);
expect(onChangeListener).toHaveBeenCalledWith({
diff --git a/Libraries/Lists/__tests__/VirtualizedList-test.js b/Libraries/Lists/__tests__/VirtualizedList-test.js
index a2da1b2abc736a..a7589992564214 100644
--- a/Libraries/Lists/__tests__/VirtualizedList-test.js
+++ b/Libraries/Lists/__tests__/VirtualizedList-test.js
@@ -1116,6 +1116,8 @@ it('retains batch render region when an item is appended', () => {
performAllBatches();
});
+ jest.runAllTimers();
+
ReactTestRenderer.act(() => {
component.update(
{
performAllBatches();
});
+ jest.runAllTimers();
// A windowSize of 3 means that we should render a viewport's worth of content
// above and below the current. A 20 dip viewport at the top of the list means
// we should render the top 4 10-dip items (for the current viewport, and
@@ -1402,6 +1405,7 @@ it('renders windowSize derived region in middle', () => {
performAllBatches();
});
+ jest.runAllTimers();
// A windowSize of 3 means that we should render a viewport's worth of content
// above and below the current. A 20 dip viewport in the top of the list means
// we should render the 6 10-dip items (for the current viewport, 20 dip above
@@ -1434,12 +1438,12 @@ it('renders windowSize derived region at bottom', () => {
});
performAllBatches();
});
-
ReactTestRenderer.act(() => {
simulateScroll(component, {x: 0, y: 80});
performAllBatches();
});
+ jest.runAllTimers();
// A windowSize of 3 means that we should render a viewport's worth of content
// above and below the current. A 20 dip viewport at the bottom of the list
// means we should render the bottom 4 10-dip items (for the current viewport,
diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION
index c7e70edea9dfb1..ab1f258cab12b4 100644
--- a/Libraries/Renderer/REVISION
+++ b/Libraries/Renderer/REVISION
@@ -1 +1 @@
-1159ff6193d500046d7bb86c234e167ea4b0becb
\ No newline at end of file
+34aa5cfe0d9b6ec4667e02bf46ab34d83dfb2d6d
\ No newline at end of file
diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.js b/Libraries/Renderer/implementations/ReactFabric-dev.js
index e00496d83cf1a1..af858df2513b9e 100644
--- a/Libraries/Renderer/implementations/ReactFabric-dev.js
+++ b/Libraries/Renderer/implementations/ReactFabric-dev.js
@@ -1,5 +1,5 @@
/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@@ -8,14 +8,25 @@
* @nolint
* @providesModule ReactFabric-dev
* @preventMunge
- * @generated SignedSource<>
+ * @generated SignedSource<<1905bf58c5e02827f73cc582ec7db91b>>
*/
'use strict';
if (__DEV__) {
(function() {
-"use strict";
+
+ 'use strict';
+
+/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
+}
+ "use strict";
var React = require("react");
require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore");
@@ -32,32 +43,36 @@ var ReactSharedInternals =
function warn(format) {
{
- for (
- var _len = arguments.length,
- args = new Array(_len > 1 ? _len - 1 : 0),
- _key = 1;
- _key < _len;
- _key++
- ) {
- args[_key - 1] = arguments[_key];
- }
+ {
+ for (
+ var _len = arguments.length,
+ args = new Array(_len > 1 ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ ) {
+ args[_key - 1] = arguments[_key];
+ }
- printWarning("warn", format, args);
+ printWarning("warn", format, args);
+ }
}
}
function error(format) {
{
- for (
- var _len2 = arguments.length,
- args = new Array(_len2 > 1 ? _len2 - 1 : 0),
- _key2 = 1;
- _key2 < _len2;
- _key2++
- ) {
- args[_key2 - 1] = arguments[_key2];
- }
+ {
+ for (
+ var _len2 = arguments.length,
+ args = new Array(_len2 > 1 ? _len2 - 1 : 0),
+ _key2 = 1;
+ _key2 < _len2;
+ _key2++
+ ) {
+ args[_key2 - 1] = arguments[_key2];
+ }
- printWarning("error", format, args);
+ printWarning("error", format, args);
+ }
}
}
@@ -71,10 +86,10 @@ function printWarning(level, format, args) {
if (stack !== "") {
format += "%s";
args = args.concat([stack]);
- }
+ } // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function(item) {
- return "" + item;
+ return String(item);
}); // Careful: RN currently depends on this prefix
argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it
@@ -141,9 +156,15 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
// when we call document.createEvent(). However this can cause confusing
// errors: https://github.com/facebook/create-react-app/issues/3482
// So we preemptively throw with a better message instead.
- if (!(typeof document !== "undefined")) {
- throw Error(
- "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."
+ if (typeof document === "undefined" || document === null) {
+ throw new Error(
+ "The `document` global was defined when React was initialized, but is not " +
+ "defined anymore. This can happen in a test environment if a component " +
+ "schedules an update from an asynchronous callback, but the test has already " +
+ "finished running. To solve this, you can either unmount the component at " +
+ "the end of your test (and ensure that any asynchronous operations get " +
+ "canceled in `componentWillUnmount`), or you can change the test itself " +
+ "to be asynchronous."
);
}
@@ -249,6 +270,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
if (didCall && didError) {
if (!didSetError) {
// The callback errored, but the error event never fired.
+ // eslint-disable-next-line react-internal/prod-error-codes
error = new Error(
"An error was thrown inside one of your components, but React " +
"doesn't know what it was. This is likely due to browser " +
@@ -260,6 +282,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
"actually an issue with React, please file an issue."
);
} else if (isCrossOriginError) {
+ // eslint-disable-next-line react-internal/prod-error-codes
error = new Error(
"A cross-origin error was thrown. React doesn't have access to " +
"the actual error object in development. " +
@@ -372,11 +395,10 @@ function clearCaughtError() {
caughtError = null;
return error;
} else {
- {
- throw Error(
- "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."
- );
- }
+ throw new Error(
+ "clearCaughtError was called but no error was captured. This error " +
+ "is likely caused by a bug in React. Please file an issue."
+ );
}
}
@@ -533,8 +555,8 @@ function executeDirectDispatch(event) {
var dispatchListener = event._dispatchListeners;
var dispatchInstance = event._dispatchInstances;
- if (!!isArray(dispatchListener)) {
- throw Error("executeDirectDispatch(...): Invalid `event`.");
+ if (isArray(dispatchListener)) {
+ throw new Error("executeDirectDispatch(...): Invalid `event`.");
}
event.currentTarget = dispatchListener
@@ -555,6 +577,8 @@ function hasDispatches(event) {
return !!event._dispatchListeners;
}
+var assign = Object.assign;
+
var EVENT_POOL_SIZE = 10;
/**
* @interface Event
@@ -663,7 +687,7 @@ function SyntheticEvent(
return this;
}
-Object.assign(SyntheticEvent.prototype, {
+assign(SyntheticEvent.prototype, {
preventDefault: function() {
this.defaultPrevented = true;
var event = this.nativeEvent;
@@ -793,10 +817,10 @@ SyntheticEvent.extend = function(Interface) {
return Super.apply(this, arguments);
}
- Object.assign(prototype, Class.prototype);
+ assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = Object.assign({}, Super.Interface, Interface);
+ Class.Interface = assign({}, Super.Interface, Interface);
Class.extend = Super.extend;
addEventPoolingTo(Class);
return Class;
@@ -881,7 +905,7 @@ function releasePooledEvent(event) {
var EventConstructor = this;
if (!(event instanceof EventConstructor)) {
- throw Error(
+ throw new Error(
"Trying to release an event instance into a pool of a different type."
);
}
@@ -990,8 +1014,8 @@ function resetTouchRecord(touchRecord, touch) {
function getTouchIdentifier(_ref) {
var identifier = _ref.identifier;
- if (!(identifier != null)) {
- throw Error("Touch object is missing identifier.");
+ if (identifier == null) {
+ throw new Error("Touch object is missing identifier.");
}
{
@@ -1149,8 +1173,8 @@ var ResponderTouchHistoryStore = {
*/
function accumulate(current, next) {
- if (!(next != null)) {
- throw Error(
+ if (next == null) {
+ throw new Error(
"accumulate(...): Accumulated items must not be null or undefined."
);
}
@@ -1185,8 +1209,8 @@ function accumulate(current, next) {
*/
function accumulateInto(current, next) {
- if (!(next != null)) {
- throw Error(
+ if (next == null) {
+ throw new Error(
"accumulateInto(...): Accumulated items must not be null or undefined."
);
}
@@ -1258,6 +1282,7 @@ var ScopeComponent = 21;
var OffscreenComponent = 22;
var LegacyHiddenComponent = 23;
var CacheComponent = 24;
+var TracingMarkerComponent = 25;
/**
* Instance of element that should respond to touch/move types of interactions,
@@ -1492,8 +1517,8 @@ function getListener(inst, registrationName) {
var listener = props[registrationName];
- if (!(!listener || typeof listener === "function")) {
- throw Error(
+ if (listener && typeof listener !== "function") {
+ throw new Error(
"Expected `" +
registrationName +
"` listener to be a function, instead got a value of `" +
@@ -2075,11 +2100,10 @@ function recomputePluginOrdering() {
var pluginModule = namesToPlugins[pluginName];
var pluginIndex = eventPluginOrder.indexOf(pluginName);
- if (!(pluginIndex > -1)) {
- throw Error(
- "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" +
- pluginName +
- "`."
+ if (pluginIndex <= -1) {
+ throw new Error(
+ "EventPluginRegistry: Cannot inject event plugins that do not exist in " +
+ ("the plugin ordering, `" + pluginName + "`.")
);
}
@@ -2088,10 +2112,9 @@ function recomputePluginOrdering() {
}
if (!pluginModule.extractEvents) {
- throw Error(
- "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" +
- pluginName +
- "` does not."
+ throw new Error(
+ "EventPluginRegistry: Event plugins must implement an `extractEvents` " +
+ ("method, but `" + pluginName + "` does not.")
);
}
@@ -2106,7 +2129,7 @@ function recomputePluginOrdering() {
eventName
)
) {
- throw Error(
+ throw new Error(
"EventPluginRegistry: Failed to publish event `" +
eventName +
"` for plugin `" +
@@ -2127,11 +2150,10 @@ function recomputePluginOrdering() {
*/
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
- if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
- throw Error(
- "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" +
- eventName +
- "`."
+ if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
+ throw new Error(
+ "EventPluginRegistry: More than one plugin attempted to publish the same " +
+ ("event name, `" + eventName + "`.")
);
}
@@ -2171,11 +2193,10 @@ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
*/
function publishRegistrationName(registrationName, pluginModule, eventName) {
- if (!!registrationNameModules[registrationName]) {
- throw Error(
- "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" +
- registrationName +
- "`."
+ if (registrationNameModules[registrationName]) {
+ throw new Error(
+ "EventPluginRegistry: More than one plugin attempted to publish the same " +
+ ("registration name, `" + registrationName + "`.")
);
}
@@ -2222,9 +2243,10 @@ var registrationNameDependencies = {};
*/
function injectEventPluginOrder(injectedEventPluginOrder) {
- 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."
+ if (eventPluginOrder) {
+ throw new Error(
+ "EventPluginRegistry: Cannot inject event plugin ordering more than " +
+ "once. You are likely trying to load more than one copy of React."
);
} // Clone the ordering so it cannot be dynamically mutated.
@@ -2255,11 +2277,10 @@ function injectEventPluginsByName(injectedNamesToPlugins) {
!namesToPlugins.hasOwnProperty(pluginName) ||
namesToPlugins[pluginName] !== pluginModule
) {
- if (!!namesToPlugins[pluginName]) {
- throw Error(
- "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName +
- "`."
+ if (namesToPlugins[pluginName]) {
+ throw new Error(
+ "EventPluginRegistry: Cannot inject two different event plugins " +
+ ("using the same name, `" + pluginName + "`.")
);
}
@@ -2273,13 +2294,35 @@ function injectEventPluginsByName(injectedNamesToPlugins) {
}
}
-function getListener$1(inst, registrationName) {
+/**
+ * Get a list of listeners for a specific event, in-order.
+ * For React Native we treat the props-based function handlers
+ * as the first-class citizens, and they are always executed first
+ * for both capture and bubbling phase.
+ *
+ * We need "phase" propagated to this point to support the HostComponent
+ * EventEmitter API, which does not mutate the name of the handler based
+ * on phase (whereas prop handlers are registered as `onMyEvent` and `onMyEvent_Capture`).
+ *
+ * Native system events emitted into React Native
+ * will be emitted both to the prop handler function and to imperative event
+ * listeners.
+ *
+ * This will either return null, a single Function without an array, or
+ * an array of 2+ items.
+ */
+
+function getListeners(
+ inst,
+ registrationName,
+ phase,
+ dispatchToImperativeListeners
+) {
var stateNode = inst.stateNode;
if (stateNode === null) {
- // Work in progress (ex: onload events in incremental mode).
return null;
- }
+ } // If null: Work in progress (ex: onload events in incremental mode).
var props = getFiberCurrentPropsFromNode(stateNode);
@@ -2290,17 +2333,133 @@ function getListener$1(inst, registrationName) {
var listener = props[registrationName];
- if (!(!listener || typeof listener === "function")) {
- throw Error(
+ if (listener && typeof listener !== "function") {
+ throw new Error(
"Expected `" +
registrationName +
"` listener to be a function, instead got a value of `" +
typeof listener +
"` type."
);
+ } // If there are no imperative listeners, early exit.
+
+ if (
+ !(
+ dispatchToImperativeListeners &&
+ stateNode.canonical &&
+ stateNode.canonical._eventListeners
+ )
+ ) {
+ return listener;
+ } // Below this is the de-optimized path.
+ // If you are using _eventListeners, we do not (yet)
+ // expect this to be as performant as the props-only path.
+ // If/when this becomes a bottleneck, it can be refactored
+ // to avoid unnecessary closures and array allocations.
+ //
+ // Previously, there was only one possible listener for an event:
+ // the onEventName property in props.
+ // Now, it is also possible to have N listeners
+ // for a specific event on a node. Thus, we accumulate all of the listeners,
+ // including the props listener, and return a function that calls them all in
+ // order, starting with the handler prop and then the listeners in order.
+ // We return either a non-empty array or null.
+
+ var listeners = [];
+
+ if (listener) {
+ listeners.push(listener);
+ } // TODO: for now, all of these events get an `rn:` prefix to enforce
+ // that the user knows they're only getting non-W3C-compliant events
+ // through this imperative event API.
+ // Events might not necessarily be noncompliant, but we currently have
+ // no verification that /any/ events are compliant.
+ // Thus, we prefix to ensure no collision with W3C event names.
+
+ var requestedPhaseIsCapture = phase === "captured";
+ var mangledImperativeRegistrationName = requestedPhaseIsCapture
+ ? "rn:" + registrationName.replace(/Capture$/, "")
+ : "rn:" + registrationName; // Get imperative event listeners for this event
+
+ if (
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName] &&
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName]
+ .length > 0
+ ) {
+ var eventListeners =
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName];
+ eventListeners.forEach(function(listenerObj) {
+ // Make sure phase of listener matches requested phase
+ var isCaptureEvent =
+ listenerObj.options.capture != null && listenerObj.options.capture;
+
+ if (isCaptureEvent !== requestedPhaseIsCapture) {
+ return;
+ } // For now (this is an area of future optimization) we must wrap
+ // all imperative event listeners in a function to unwrap the SyntheticEvent
+ // and pass them an Event.
+ // When this API is more stable and used more frequently, we can revisit.
+
+ var listenerFnWrapper = function(syntheticEvent) {
+ var eventInst = new ReactNativePrivateInterface.CustomEvent(
+ mangledImperativeRegistrationName,
+ {
+ detail: syntheticEvent.nativeEvent
+ }
+ );
+ eventInst.isTrusted = true; // setSyntheticEvent is present on the React Native Event shim.
+ // It is used to forward method calls on Event to the underlying SyntheticEvent.
+ // $FlowFixMe
+
+ eventInst.setSyntheticEvent(syntheticEvent);
+
+ for (
+ var _len = arguments.length,
+ args = new Array(_len > 1 ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ ) {
+ args[_key - 1] = arguments[_key];
+ }
+
+ listenerObj.listener.apply(listenerObj, [eventInst].concat(args));
+ }; // Only call once?
+ // If so, we ensure that it's only called once by setting a flag
+ // and by removing it from eventListeners once it is called (but only
+ // when it's actually been executed).
+
+ if (listenerObj.options.once) {
+ listeners.push(function() {
+ // Remove from the event listener once it's been called
+ stateNode.canonical.removeEventListener_unstable(
+ mangledImperativeRegistrationName,
+ listenerObj.listener,
+ listenerObj.capture
+ ); // Guard against function being called more than once in
+ // case there are somehow multiple in-flight references to
+ // it being processed
+
+ if (!listenerObj.invalidated) {
+ listenerObj.invalidated = true;
+ listenerObj.listener.apply(listenerObj, arguments);
+ }
+ });
+ } else {
+ listeners.push(listenerFnWrapper);
+ }
+ });
}
- return listener;
+ if (listeners.length === 0) {
+ return null;
+ }
+
+ if (listeners.length === 1) {
+ return listeners[0];
+ }
+
+ return listeners;
}
var customBubblingEventTypes =
@@ -2312,10 +2471,39 @@ var customBubblingEventTypes =
// EventPropagator.js, as they deviated from ReactDOM's newer
// implementations.
-function listenerAtPhase$1(inst, event, propagationPhase) {
+function listenersAtPhase(inst, event, propagationPhase) {
var registrationName =
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
- return getListener$1(inst, registrationName);
+ return getListeners(inst, registrationName, propagationPhase, true);
+}
+
+function accumulateListenersAndInstances(inst, event, listeners) {
+ var listenersLength = listeners
+ ? isArray(listeners)
+ ? listeners.length
+ : 1
+ : 0;
+
+ if (listenersLength > 0) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listeners
+ ); // Avoid allocating additional arrays here
+
+ if (event._dispatchInstances == null && listenersLength === 1) {
+ event._dispatchInstances = inst;
+ } else {
+ event._dispatchInstances = event._dispatchInstances || [];
+
+ if (!isArray(event._dispatchInstances)) {
+ event._dispatchInstances = [event._dispatchInstances];
+ }
+
+ for (var i = 0; i < listenersLength; i++) {
+ event._dispatchInstances.push(inst);
+ }
+ }
+ }
}
function accumulateDirectionalDispatches$1(inst, phase, event) {
@@ -2325,15 +2513,8 @@ function accumulateDirectionalDispatches$1(inst, phase, event) {
}
}
- var listener = listenerAtPhase$1(inst, event, phase);
-
- if (listener) {
- event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- );
- event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
- }
+ var listeners = listenersAtPhase(inst, event, phase);
+ accumulateListenersAndInstances(inst, event, listeners);
}
function getParent$1(inst) {
@@ -2355,7 +2536,7 @@ function getParent$1(inst) {
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
*/
-function traverseTwoPhase$1(inst, fn, arg) {
+function traverseTwoPhase$1(inst, fn, arg, skipBubbling) {
var path = [];
while (inst) {
@@ -2369,8 +2550,13 @@ function traverseTwoPhase$1(inst, fn, arg) {
fn(path[i], "captured", arg);
}
- for (i = 0; i < path.length; i++) {
- fn(path[i], "bubbled", arg);
+ if (skipBubbling) {
+ // Dispatch on target only
+ fn(path[0], "bubbled", arg);
+ } else {
+ for (i = 0; i < path.length; i++) {
+ fn(path[i], "bubbled", arg);
+ }
}
}
@@ -2379,7 +2565,8 @@ function accumulateTwoPhaseDispatchesSingle$1(event) {
traverseTwoPhase$1(
event._targetInst,
accumulateDirectionalDispatches$1,
- event
+ event,
+ false
);
}
}
@@ -2387,6 +2574,17 @@ function accumulateTwoPhaseDispatchesSingle$1(event) {
function accumulateTwoPhaseDispatches$1(events) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1);
}
+
+function accumulateCapturePhaseDispatches(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event,
+ true
+ );
+ }
+}
/**
* Accumulates without regard to direction, does not look for phased
* registration names. Same as `accumulateDirectDispatchesSingle` but without
@@ -2396,15 +2594,8 @@ function accumulateTwoPhaseDispatches$1(events) {
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);
- }
+ var listeners = getListeners(inst, registrationName, "bubbled", false);
+ accumulateListenersAndInstances(inst, event, listeners);
}
}
/**
@@ -2439,8 +2630,8 @@ var ReactNativeBridgeEventPlugin = {
var bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
var directDispatchConfig = customDirectEventTypes[topLevelType];
- if (!(bubbleDispatchConfig || directDispatchConfig)) {
- throw Error(
+ if (!bubbleDispatchConfig && !directDispatchConfig) {
+ throw new Error( // $FlowFixMe - Flow doesn't like this string coercion because DOMTopLevelEventType is opaque
'Unsupported top level event type "' + topLevelType + '" dispatched'
);
}
@@ -2453,7 +2644,16 @@ var ReactNativeBridgeEventPlugin = {
);
if (bubbleDispatchConfig) {
- accumulateTwoPhaseDispatches$1(event);
+ var skipBubbling =
+ event != null &&
+ event.dispatchConfig.phasedRegistrationNames != null &&
+ event.dispatchConfig.phasedRegistrationNames.skipBubbling;
+
+ if (skipBubbling) {
+ accumulateCapturePhaseDispatches(event);
+ } else {
+ accumulateTwoPhaseDispatches$1(event);
+ }
} else if (directDispatchConfig) {
accumulateDirectDispatches$1(event);
} else {
@@ -2498,7 +2698,7 @@ function getTagFromInstance(inst) {
var nativeInstance = inst.stateNode.canonical;
if (!nativeInstance._nativeTag) {
- throw Error("All native instances should have a tag.");
+ throw new Error("All native instances should have a tag.");
}
return nativeInstance;
@@ -2573,53 +2773,39 @@ function set(key, value) {
key._reactInternals = value;
}
+var enableSchedulingProfiler = false;
+var enableProfilerTimer = true;
+var enableProfilerCommitHooks = true;
+var enableLazyElements = false;
+var warnAboutStringRefs = false;
+var enableSuspenseAvoidThisFallback = false;
+var enableNewReconciler = false;
+var enableLazyContextPropagation = false;
+var enableLegacyHidden = false;
+
// 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 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_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;
-var REACT_CACHE_TYPE = 0xeae4;
-
-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_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");
- REACT_CACHE_TYPE = symbolFor("react.cache");
-}
-
-var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
+// The Symbol used to tag the ReactElement-like types.
+var REACT_ELEMENT_TYPE = Symbol.for("react.element");
+var REACT_PORTAL_TYPE = Symbol.for("react.portal");
+var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
+var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
+var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
+var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
+var REACT_CONTEXT_TYPE = Symbol.for("react.context");
+var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
+var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
+var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
+var REACT_MEMO_TYPE = Symbol.for("react.memo");
+var REACT_LAZY_TYPE = Symbol.for("react.lazy");
+var REACT_SCOPE_TYPE = Symbol.for("react.scope");
+var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for("react.debug_trace_mode");
+var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
+var REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden");
+var REACT_CACHE_TYPE = Symbol.for("react.cache");
+var REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker");
+var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
function getIteratorFn(maybeIterable) {
if (maybeIterable === null || typeof maybeIterable !== "object") {
@@ -2695,9 +2881,6 @@ function getComponentNameFromType(type) {
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
-
- case REACT_CACHE_TYPE:
- return "Cache";
}
if (typeof type === "object") {
@@ -2733,6 +2916,8 @@ function getComponentNameFromType(type) {
return null;
}
}
+
+ // eslint-disable-next-line no-fallthrough
}
}
@@ -2793,9 +2978,6 @@ function getComponentNameFromFiber(fiber) {
// Name comes from the type in this case; we don't have a tag.
return getComponentNameFromType(type);
- case LegacyHiddenComponent:
- return "LegacyHidden";
-
case Mode:
if (type === REACT_STRICT_MODE_TYPE) {
// Don't be less specific than shared/getComponentNameFromType
@@ -2818,6 +3000,9 @@ function getComponentNameFromFiber(fiber) {
case SuspenseListComponent:
return "SuspenseList";
+
+ case TracingMarkerComponent:
+ return "TracingMarker";
// The display name for this tags come from the user-provided type:
case ClassComponent:
@@ -2840,13 +3025,6 @@ function getComponentNameFromFiber(fiber) {
return null;
}
-var enableProfilerTimer = true;
-var enableProfilerCommitHooks = true;
-var enableLazyElements = false;
-var warnAboutStringRefs = false;
-var enableNewReconciler = false;
-var enableLazyContextPropagation = false;
-
// Don't change these two values. They're used by React Dev Tools.
var NoFlags =
/* */
@@ -2876,39 +3054,49 @@ var Callback =
var DidCapture =
/* */
128;
+var ForceClientRender =
+ /* */
+ 256;
var Ref =
/* */
- 256;
+ 512;
var Snapshot =
/* */
- 512;
+ 1024;
var Passive =
/* */
- 1024;
+ 2048;
var Hydrating =
/* */
- 2048;
+ 4096;
var HydratingAndUpdate =
/* */
Hydrating | Update;
var Visibility =
/* */
- 4096;
-var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit)
+ 8192;
+var StoreConsistency =
+ /* */
+ 16384;
+var LifecycleEffectMask =
+ Passive | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit)
var HostEffectMask =
/* */
- 8191; // These are not really side effects, but we still reuse this field.
+ 32767; // These are not really side effects, but we still reuse this field.
var Incomplete =
/* */
- 8192;
+ 32768;
var ShouldCapture =
/* */
- 16384;
+ 65536;
var ForceUpdateForLegacySuspense =
/* */
- 32768;
+ 131072;
+var Forked =
+ /* */
+ 1048576; // Static tags describe aspects of a fiber that are not specific to a render,
// e.g. a fiber uses a passive effect (even if there are no updates on this particular render).
// This enables us to defer more work in the unmount case,
// since we can defer traversing the tree during layout to look for Passive effects,
@@ -2916,16 +3104,16 @@ var ForceUpdateForLegacySuspense =
var RefStatic =
/* */
- 262144;
+ 2097152;
var LayoutStatic =
/* */
- 524288;
+ 4194304;
var PassiveStatic =
/* */
- 1048576; // These flags allow us to traverse to fibers that have effects on mount
+ 8388608; // These flags allow us to traverse to fibers that have effects on mount
// don't contain effects, by checking subtreeFlags.
-var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visiblity
+var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility
// flag logic (see #20043)
Update | Snapshot | 0;
var MutationMask =
@@ -2936,10 +3124,10 @@ var MutationMask =
Ref |
Hydrating |
Visibility;
-var LayoutMask = Update | Callback | Ref; // TODO: Split into PassiveMountMask and PassiveUnmountMask
+var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask
var PassiveMask = Passive | ChildDeletion; // Union of tags that don't get reset on clones.
-// This allows certain concepts to persist without recalculting them,
+// This allows certain concepts to persist without recalculating them,
// e.g. whether a subtree contains passive effects or portals.
var StaticMask = LayoutStatic | PassiveStatic | RefStatic;
@@ -3017,8 +3205,8 @@ function isMounted(component) {
}
function assertIsMounted(fiber) {
- if (!(getNearestMountedFiber(fiber) === fiber)) {
- throw Error("Unable to find node on an unmounted component.");
+ if (getNearestMountedFiber(fiber) !== fiber) {
+ throw new Error("Unable to find node on an unmounted component.");
}
}
@@ -3029,8 +3217,8 @@ function findCurrentFiberUsingSlowPath(fiber) {
// If there is no alternate, then we only need to check if it is mounted.
var nearestMounted = getNearestMountedFiber(fiber);
- if (!(nearestMounted !== null)) {
- throw Error("Unable to find node on an unmounted component.");
+ if (nearestMounted === null) {
+ throw new Error("Unable to find node on an unmounted component.");
}
if (nearestMounted !== fiber) {
@@ -3092,9 +3280,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
} // We should never have an alternate for any mounting node. So the only
// way this could possibly happen is if this was unmounted, if at all.
- {
- throw Error("Unable to find node on an unmounted component.");
- }
+ throw new Error("Unable to find node on an unmounted component.");
}
if (a.return !== b.return) {
@@ -3154,23 +3340,25 @@ function findCurrentFiberUsingSlowPath(fiber) {
}
if (!didFindChild) {
- throw Error(
- "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."
+ throw new Error(
+ "Child was not found in either parent set. This indicates a bug " +
+ "in React related to the return pointer. Please file an issue."
);
}
}
}
- if (!(a.alternate === b)) {
- throw Error(
- "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."
+ if (a.alternate !== b) {
+ throw new Error(
+ "Return fibers should always be each others' alternates. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
} // If the root is not a host container, we're in a disconnected tree. I.e.
// unmounted.
- if (!(a.tag === HostRoot)) {
- throw Error("Unable to find node on an unmounted component.");
+ if (a.tag !== HostRoot) {
+ throw new Error("Unable to find node on an unmounted component.");
}
if (a.stateNode.current === a) {
@@ -3705,6 +3893,7 @@ function diff(prevProps, nextProps, validAttributes) {
var batchedUpdatesImpl = function(fn, bookkeeping) {
return fn(bookkeeping);
};
+
var isInsideEventHandler = false;
function batchedUpdates(fn, bookkeeping) {
if (isInsideEventHandler) {
@@ -3721,11 +3910,7 @@ function batchedUpdates(fn, bookkeeping) {
isInsideEventHandler = false;
}
}
-function setBatchingImplementation(
- _batchedUpdatesImpl,
- _discreteUpdatesImpl,
- _batchedEventUpdatesImpl
-) {
+function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl) {
batchedUpdatesImpl = _batchedUpdatesImpl;
}
@@ -3771,9 +3956,10 @@ function runEventsInBatch(events) {
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
- if (!!eventQueue) {
- throw Error(
- "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
+ if (eventQueue) {
+ throw new Error(
+ "processEventQueue(): Additional events were enqueued while processing " +
+ "an event queue. Support for this has not yet been implemented."
);
} // This would be a good time to rethrow if any of the event handlers threw.
@@ -3846,7 +4032,34 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
}
batchedUpdates(function() {
- // Heritage plugin event system
+ // Emit event to the RawEventEmitter. This is an unused-by-default EventEmitter
+ // that can be used to instrument event performance monitoring (primarily - could be useful
+ // for other things too).
+ //
+ // NOTE: this merely emits events into the EventEmitter below.
+ // If *you* do not add listeners to the `RawEventEmitter`,
+ // then all of these emitted events will just blackhole and are no-ops.
+ // It is available (although not officially supported... yet) if you want to collect
+ // perf data on event latency in your application, and could also be useful for debugging
+ // low-level events issues.
+ //
+ // If you do not have any event perf monitoring and are extremely concerned about event perf,
+ // it is safe to disable these "emit" statements; it will prevent checking the size of
+ // an empty array twice and prevent two no-ops. Practically the overhead is so low that
+ // we don't think it's worth thinking about in prod; your perf issues probably lie elsewhere.
+ //
+ // We emit two events here: one for listeners to this specific event,
+ // and one for the catchall listener '*', for any listeners that want
+ // to be notified for all events.
+ // Note that extracted events are *not* emitted,
+ // only events that have a 1:1 mapping with a native event, at least for now.
+ var event = {
+ eventName: topLevelType,
+ nativeEvent: nativeEvent
+ };
+ ReactNativePrivateInterface.RawEventEmitter.emit(topLevelType, event);
+ ReactNativePrivateInterface.RawEventEmitter.emit("*", event); // Heritage plugin event system
+
runExtractedPluginEventsInBatch(
topLevelType,
targetFiber,
@@ -3900,6 +4113,16 @@ function injectInternals(internals) {
}
try {
+ if (enableSchedulingProfiler) {
+ // Conditionally inject these hooks only if Timeline profiler is supported by this build.
+ // This gives DevTools a way to feature detect that isn't tied to version number
+ // (since profiling and timeline are controlled by different feature flags).
+ internals = assign({}, internals, {
+ getLaneLabelMap: getLaneLabelMap,
+ injectProfilingHooks: injectProfilingHooks
+ });
+ }
+
rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
injectedHook = hook;
@@ -3908,9 +4131,15 @@ function injectInternals(internals) {
{
error("React instrumentation encountered an error: %s.", err);
}
- } // DevTools exists
+ }
- return true;
+ if (hook.checkDCE) {
+ // This is the real DevTools.
+ return true;
+ } else {
+ // This is likely a hook installed by Fast Refresh runtime.
+ return false;
+ }
}
function onScheduleRoot(root, children) {
{
@@ -4014,6 +4243,17 @@ function onCommitUnmount(fiber) {
}
}
+function injectProfilingHooks(profilingHooks) {}
+
+function getLaneLabelMap() {
+ {
+ return null;
+ }
+}
+function markComponentRenderStopped() {}
+function markComponentErrored(fiber, thrownValue, lanes) {}
+function markComponentSuspended(fiber, wakeable, lanes) {}
+
var NoMode =
/* */
0; // TODO: Remove ConcurrentMode by reading from the root tag instead
@@ -4024,13 +4264,28 @@ var ConcurrentMode =
var ProfileMode =
/* */
2;
-var DebugTracingMode =
- /* */
- 4;
var StrictLegacyMode =
/* */
8;
+// TODO: This is pretty well supported by browsers. Maybe we can drop it.
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros.
+// 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(x) {
+ var asUint = x >>> 0;
+
+ if (asUint === 0) {
+ return 32;
+ }
+
+ return (31 - ((log(asUint) / LN2) | 0)) | 0;
+}
+
// If those values are changed that package should be rebuilt and redeployed.
var TotalLanes = 31;
@@ -4142,7 +4397,7 @@ var IdleLane =
536870912;
var OffscreenLane =
/* */
- 1073741824; // This function is used for the experimental scheduling profiler (react-devtools-scheduling-profiler)
+ 1073741824; // This function is used for the experimental timeline (react-devtools-timeline)
var NoTimestamp = -1;
var nextTransitionLane = TransitionLane1;
var nextRetryLane = RetryLane1;
@@ -4462,6 +4717,9 @@ function getLanesToRetrySynchronouslyOnError(root) {
return NoLanes;
}
+function includesSyncLane(lanes) {
+ return (lanes & SyncLane) !== NoLanes;
+}
function includesNonIdleWork(lanes) {
return (lanes & NonIdleLanes) !== NoLanes;
}
@@ -4471,19 +4729,18 @@ function includesOnlyRetries(lanes) {
function includesOnlyTransitions(lanes) {
return (lanes & TransitionLanes) === lanes;
}
-function shouldTimeSlice(root, lanes) {
- if ((lanes & root.expiredLanes) !== NoLanes) {
- // At least one of these lanes expired. To prevent additional starvation,
- // finish rendering without yielding execution.
- return false;
- }
-
+function includesBlockingLane(root, lanes) {
var SyncDefaultLanes =
InputContinuousHydrationLane |
InputContinuousLane |
DefaultHydrationLane |
DefaultLane;
- return (lanes & SyncDefaultLanes) === NoLanes;
+ return (lanes & SyncDefaultLanes) !== NoLanes;
+}
+function includesExpiredLane(root, lanes) {
+ // This is a separate check from includesBlockingLane because a lane can
+ // expire after a render has already started.
+ return (lanes & root.expiredLanes) !== NoLanes;
}
function isTransitionLane(lane) {
return (lane & TransitionLanes) !== 0;
@@ -4603,9 +4860,6 @@ function markRootSuspended(root, suspendedLanes) {
function markRootPinged(root, pingedLanes, eventTime) {
root.pingedLanes |= root.suspendedLanes & pingedLanes;
}
-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
@@ -4615,7 +4869,6 @@ function markRootFinished(root, remainingLanes) {
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
@@ -4704,20 +4957,6 @@ function movePendingFibersToMemoized(root, lanes) {
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;
-}
var DiscreteEventPriority = SyncLane;
var ContinuousEventPriority = InputContinuousLane;
@@ -4757,28 +4996,27 @@ function lanesToEventPriority(lanes) {
return IdleEventPriority;
}
+// Renderers that don't support mutation
// can re-export everything from this module.
-
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."
- );
- }
+ throw new Error(
+ "The current renderer does not support mutation. " +
+ "This error is likely caused by a bug in React. " +
+ "Please file an issue."
+ );
} // Mutation (when unsupported)
var supportsMutation = false;
var commitMount = shim;
-var clearContainer = shim;
+// Renderers that don't support hydration
// can re-export everything from this module.
-
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."
- );
- }
+ throw new Error(
+ "The current renderer does not support hydration. " +
+ "This error is likely caused by a bug in React. " +
+ "Please file an issue."
+ );
} // Hydration (when unsupported)
var isSuspenseInstancePending = shim$1;
var isSuspenseInstanceFallback = shim$1;
@@ -4847,17 +5085,25 @@ var ReactFabricHostComponent = /*#__PURE__*/ (function() {
};
_proto.measure = function measure(callback) {
- fabricMeasure(
- this._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, callback)
- );
+ var stateNode = this._internalInstanceHandle.stateNode;
+
+ if (stateNode != null) {
+ fabricMeasure(
+ stateNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, callback)
+ );
+ }
};
_proto.measureInWindow = function measureInWindow(callback) {
- fabricMeasureInWindow(
- this._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, callback)
- );
+ var stateNode = this._internalInstanceHandle.stateNode;
+
+ if (stateNode != null) {
+ fabricMeasureInWindow(
+ stateNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, callback)
+ );
+ }
};
_proto.measureLayout = function measureLayout(
@@ -4879,12 +5125,17 @@ var ReactFabricHostComponent = /*#__PURE__*/ (function() {
return;
}
- fabricMeasureLayout(
- this._internalInstanceHandle.stateNode.node,
- relativeToNativeNode._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, onFail),
- mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)
- );
+ var toStateNode = this._internalInstanceHandle.stateNode;
+ var fromStateNode = relativeToNativeNode._internalInstanceHandle.stateNode;
+
+ if (toStateNode != null && fromStateNode != null) {
+ fabricMeasureLayout(
+ toStateNode.node,
+ fromStateNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, onFail),
+ mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)
+ );
+ }
};
_proto.setNativeProps = function setNativeProps(nativeProps) {
@@ -4893,16 +5144,115 @@ var ReactFabricHostComponent = /*#__PURE__*/ (function() {
}
return;
- };
+ }; // This API (addEventListener, removeEventListener) attempts to adhere to the
+ // w3 Level2 Events spec as much as possible, treating HostComponent as a DOM node.
+ //
+ // Unless otherwise noted, these methods should "just work" and adhere to the W3 specs.
+ // If they deviate in a way that is not explicitly noted here, you've found a bug!
+ //
+ // See:
+ // * https://www.w3.org/TR/DOM-Level-2-Events/events.html
+ // * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
+ // * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
+ //
+ // And notably, not implemented (yet?):
+ // * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
+ //
+ //
+ // Deviations from spec/TODOs:
+ // (1) listener must currently be a function, we do not support EventListener objects yet.
+ // (2) we do not support the `signal` option / AbortSignal yet
+
+ _proto.addEventListener_unstable = function addEventListener_unstable(
+ eventType,
+ listener,
+ options
+ ) {
+ if (typeof eventType !== "string") {
+ throw new Error("addEventListener_unstable eventType must be a string");
+ }
- return ReactFabricHostComponent;
-})(); // eslint-disable-next-line no-unused-expressions
-function appendInitialChild(parentInstance, child) {
- appendChildNode(parentInstance.node, child.node);
-}
-function createInstance(
- type,
- props,
+ if (typeof listener !== "function") {
+ throw new Error("addEventListener_unstable listener must be a function");
+ } // The third argument is either boolean indicating "captures" or an object.
+
+ var optionsObj =
+ typeof options === "object" && options !== null ? options : {};
+ var capture =
+ (typeof options === "boolean" ? options : optionsObj.capture) || false;
+ var once = optionsObj.once || false;
+ var passive = optionsObj.passive || false;
+ var signal = null; // TODO: implement signal/AbortSignal
+
+ var eventListeners = this._eventListeners || {};
+
+ if (this._eventListeners == null) {
+ this._eventListeners = eventListeners;
+ }
+
+ var namedEventListeners = eventListeners[eventType] || [];
+
+ if (eventListeners[eventType] == null) {
+ eventListeners[eventType] = namedEventListeners;
+ }
+
+ namedEventListeners.push({
+ listener: listener,
+ invalidated: false,
+ options: {
+ capture: capture,
+ once: once,
+ passive: passive,
+ signal: signal
+ }
+ });
+ }; // See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
+
+ _proto.removeEventListener_unstable = function removeEventListener_unstable(
+ eventType,
+ listener,
+ options
+ ) {
+ // eventType and listener must be referentially equal to be removed from the listeners
+ // data structure, but in "options" we only check the `capture` flag, according to spec.
+ // That means if you add the same function as a listener with capture set to true and false,
+ // you must also call removeEventListener twice with capture set to true/false.
+ var optionsObj =
+ typeof options === "object" && options !== null ? options : {};
+ var capture =
+ (typeof options === "boolean" ? options : optionsObj.capture) || false; // If there are no event listeners or named event listeners, we can bail early - our
+ // job is already done.
+
+ var eventListeners = this._eventListeners;
+
+ if (!eventListeners) {
+ return;
+ }
+
+ var namedEventListeners = eventListeners[eventType];
+
+ if (!namedEventListeners) {
+ return;
+ } // TODO: optimize this path to make remove cheaper
+
+ eventListeners[eventType] = namedEventListeners.filter(function(
+ listenerObj
+ ) {
+ return !(
+ listenerObj.listener === listener &&
+ listenerObj.options.capture === capture
+ );
+ });
+ };
+
+ return ReactFabricHostComponent;
+})(); // eslint-disable-next-line no-unused-expressions
+function appendInitialChild(parentInstance, child) {
+ appendChildNode(parentInstance.node, child.node);
+}
+function createInstance(
+ type,
+ props,
rootContainerInstance,
hostContext,
internalInstanceHandle
@@ -4946,8 +5296,10 @@ function createTextInstance(
hostContext,
internalInstanceHandle
) {
- if (!hostContext.isInAParentText) {
- throw Error("Text strings must be rendered within a component.");
+ {
+ if (!hostContext.isInAParentText) {
+ error("Text strings must be rendered within a component.");
+ }
}
var tag = nextReactTag;
@@ -4977,7 +5329,8 @@ function getChildHostContext(parentHostContext, type, rootContainerInstance) {
type === "RCTMultilineTextInputView" || // iOS
type === "RCTSinglelineTextInputView" || // iOS
type === "RCTText" ||
- type === "RCTVirtualText";
+ type === "RCTVirtualText"; // TODO: If this is an offscreen host container, we should reuse the
+ // parent context.
if (prevIsInAParentText !== isInAParentText) {
return {
@@ -5040,6 +5393,8 @@ function getCurrentEventPriority() {
return DefaultEventPriority;
} // The Fabric renderer is secondary to the existing React Native renderer.
+
+var warnsIfNotActing = false;
var scheduleTimeout = setTimeout;
var cancelTimeout = clearTimeout;
var noTimeout = -1; // -------------------
@@ -5074,7 +5429,7 @@ function cloneInstance(
node: clone,
canonical: instance.canonical
};
-}
+} // TODO: These two methods should be replaced with `createOffscreenInstance` and
function cloneHiddenInstance(instance, type, props, internalInstanceHandle) {
var viewConfig = instance.canonical.viewConfig;
var node = instance.node;
@@ -5103,9 +5458,6 @@ function appendChildToContainerChildSet(childSet, child) {
function finalizeContainerChildren(container, newChildren) {
completeRoot(container, newChildren);
}
-function makeClientIdInDEV(warnOnAccessInDEV) {
- throw new Error("Not yet implemented");
-}
function preparePortalMount(portalInstance) {
// noop
}
@@ -5269,6 +5621,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) {
// 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") {
+ // eslint-disable-next-line react-internal/prod-error-codes
var err = Error(
(componentName || "React class") +
": " +
@@ -5500,9 +5853,10 @@ function popTopLevelContextObject(fiber) {
function pushTopLevelContextObject(fiber, context, didChange) {
{
- if (!(contextStackCursor.current === emptyContextObject)) {
- throw Error(
- "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."
+ if (contextStackCursor.current !== emptyContextObject) {
+ throw new Error(
+ "Unexpected context found on stack. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -5541,7 +5895,7 @@ function processChildContext(fiber, type, parentContext) {
for (var contextKey in childContext) {
if (!(contextKey in childContextTypes)) {
- throw Error(
+ throw new Error(
(getComponentNameFromFiber(fiber) || "Unknown") +
'.getChildContext(): key "' +
contextKey +
@@ -5555,7 +5909,7 @@ function processChildContext(fiber, type, parentContext) {
checkPropTypes(childContextTypes, childContext, "child context", name);
}
- return Object.assign({}, parentContext, childContext);
+ return assign({}, parentContext, childContext);
}
}
@@ -5586,8 +5940,9 @@ function invalidateContextProvider(workInProgress, type, didChange) {
var instance = workInProgress.stateNode;
if (!instance) {
- throw Error(
- "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."
+ throw new Error(
+ "Expected to have an instance by this point. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -5619,9 +5974,10 @@ function findCurrentUnmaskedContext(fiber) {
{
// Currently this is only used with renderSubtreeIntoContainer; not sure if it
// makes sense elsewhere
- if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
- 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."
+ if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) {
+ throw new Error(
+ "Expected subtree parent to be a mounted class component. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -5646,17 +6002,28 @@ function findCurrentUnmaskedContext(fiber) {
node = node.return;
} while (node !== null);
- {
- throw Error(
- "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
- );
- }
+ throw new Error(
+ "Found unexpected detached subtree parent. " +
+ "This error is likely caused by a bug in React. Please file an issue."
+ );
}
}
var LegacyRoot = 0;
var ConcurrentRoot = 1;
+/**
+ * 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
+ );
+}
+
+var objectIs = typeof Object.is === "function" ? Object.is : is;
+
var syncQueue = null;
var includesLegacySyncCallbacks = false;
var isFlushingSyncQueue = false;
@@ -5687,7 +6054,7 @@ function flushSyncCallbacksOnlyInLegacyMode() {
}
function flushSyncCallbacks() {
if (!isFlushingSyncQueue && syncQueue !== null) {
- // Prevent re-entrancy.
+ // Prevent re-entrance.
isFlushingSyncQueue = true;
var i = 0;
var previousUpdatePriority = getCurrentUpdatePriority();
@@ -5726,41 +6093,20 @@ function flushSyncCallbacks() {
return null;
}
-var NoFlags$1 =
- /* */
- 0; // Represents whether effect should fire.
-
-var HasEffect =
- /* */
- 1; // Represents the phase in which the effect (not the clean-up) fires.
-
-var Layout =
- /* */
- 2;
-var Passive$1 =
- /* */
- 4;
-
-var ReactVersion = "18.0.0-568dc3532";
+// This is imported by the event replaying implementation in React DOM. It's
+// in a separate file to break a circular dependency between the renderer and
+// the reconciler.
+function isRootDehydrated(root) {
+ var currentState = root.current.memoizedState;
+ return currentState.isDehydrated;
+}
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
-var NoTransition = 0;
+var NoTransition = null;
function requestCurrentTransition() {
return ReactCurrentBatchConfig.transition;
}
-/**
- * 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
- );
-}
-
-var objectIs = typeof Object.is === "function" ? Object.is : is;
-
/**
* 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.
@@ -5789,9 +6135,11 @@ function shallowEqual(objA, objB) {
} // Test for A's keys different from B.
for (var i = 0; i < keysA.length; i++) {
+ var currentKey = keysA[i];
+
if (
- !hasOwnProperty.call(objB, keysA[i]) ||
- !objectIs(objA[keysA[i]], objB[keysA[i]])
+ !hasOwnProperty.call(objB, currentKey) ||
+ !objectIs(objA[currentKey], objB[currentKey])
) {
return false;
}
@@ -5898,11 +6246,6 @@ function setIsRendering(rendering) {
isRendering = rendering;
}
}
-function getIsRendering() {
- {
- return isRendering;
- }
-}
var ReactStrictModeWarnings = {
recordUnsafeLifecycleWarnings: function(fiber, instance) {},
@@ -6252,10 +6595,97 @@ var ReactStrictModeWarnings = {
};
}
+/*
+ * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
+ * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
+ *
+ * The functions in this module will throw an easier-to-understand,
+ * easier-to-debug exception with a clear errors message message explaining the
+ * problem. (Instead of a confusing exception thrown inside the implementation
+ * of the `value` object).
+ */
+// $FlowFixMe only called in DEV, so void return is not possible.
+function typeName(value) {
+ {
+ // toStringTag is needed for namespaced types like Temporal.Instant
+ var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
+ var type =
+ (hasToStringTag && value[Symbol.toStringTag]) ||
+ value.constructor.name ||
+ "Object";
+ return type;
+ }
+} // $FlowFixMe only called in DEV, so void return is not possible.
+
+function willCoercionThrow(value) {
+ {
+ try {
+ testStringCoercion(value);
+ return false;
+ } catch (e) {
+ return true;
+ }
+ }
+}
+
+function testStringCoercion(value) {
+ // If you ended up here by following an exception call stack, here's what's
+ // happened: you supplied an object or symbol value to React (as a prop, key,
+ // DOM attribute, CSS property, string ref, etc.) and when React tried to
+ // coerce it to a string using `'' + value`, an exception was thrown.
+ //
+ // The most common types that will cause this exception are `Symbol` instances
+ // and Temporal objects like `Temporal.Instant`. But any object that has a
+ // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
+ // exception. (Library authors do this to prevent users from using built-in
+ // numeric operators like `+` or comparison operators like `>=` because custom
+ // methods are needed to perform accurate arithmetic or comparison.)
+ //
+ // To fix the problem, coerce this object or symbol value to a string before
+ // passing it to React. The most reliable way is usually `String(value)`.
+ //
+ // To find which value is throwing, check the browser or debugger console.
+ // Before this exception was thrown, there should be `console.error` output
+ // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
+ // problem and how that type was used: key, atrribute, input value prop, etc.
+ // In most cases, this console output also shows the component and its
+ // ancestor components where the exception happened.
+ //
+ // eslint-disable-next-line react-internal/safe-string-coercion
+ return "" + value;
+}
+function checkKeyStringCoercion(value) {
+ {
+ if (willCoercionThrow(value)) {
+ error(
+ "The provided key is an unsupported type %s." +
+ " This value must be coerced to a string before before using it here.",
+ typeName(value)
+ );
+
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
+ }
+ }
+}
+function checkPropStringCoercion(value, propName) {
+ {
+ if (willCoercionThrow(value)) {
+ error(
+ "The provided `%s` prop is an unsupported type %s." +
+ " This value must be coerced to a string before before using it here.",
+ propName,
+ typeName(value)
+ );
+
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
+ }
+ }
+}
+
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
// Resolve default props. Taken from ReactElement
- var props = Object.assign({}, baseProps);
+ var props = assign({}, baseProps);
var defaultProps = Component.defaultProps;
for (var propName in defaultProps) {
@@ -6329,10 +6759,12 @@ function popProvider(context, providerFiber) {
pop(valueCursor, providerFiber);
{
- context._currentValue2 = currentValue;
+ {
+ context._currentValue2 = currentValue;
+ }
}
}
-function scheduleWorkOnParentPath(parent, renderLanes) {
+function scheduleContextWorkOnParentPath(parent, renderLanes, propagationRoot) {
// Update the child lanes of all the ancestors, including the alternates.
var node = parent;
@@ -6350,14 +6782,23 @@ function scheduleWorkOnParentPath(parent, renderLanes) {
!isSubsetOfLanes(alternate.childLanes, renderLanes)
) {
alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
- } else {
- // Neither alternate was updated, which means the rest of the
- // ancestor path already has sufficient priority.
+ }
+
+ if (node === propagationRoot) {
break;
}
node = node.return;
}
+
+ {
+ if (node !== propagationRoot) {
+ error(
+ "Expected to find the propagation root when scheduling context work. " +
+ "This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
+ }
}
function propagateContextChange(workInProgress, context, renderLanes) {
{
@@ -6422,7 +6863,11 @@ function propagateContextChange_eager(workInProgress, context, renderLanes) {
alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
}
- scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too.
+ scheduleContextWorkOnParentPath(
+ fiber.return,
+ renderLanes,
+ workInProgress
+ ); // Mark the updated lanes on the list, too.
list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the
// dependency list.
@@ -6516,9 +6961,12 @@ function readContext(context) {
};
if (lastContextDependency === null) {
- if (!(currentlyRenderingFiber !== null)) {
- throw Error(
- "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
+ if (currentlyRenderingFiber === null) {
+ throw new Error(
+ "Context can only be read while React is rendering. " +
+ "In classes, you can read it in the render method or getDerivedStateFromProps. " +
+ "In function components, you can read it directly in the function body, but not " +
+ "inside Hooks like useReducer() or useMemo()."
);
} // This is the first dependency for this component. Create a new list.
@@ -6858,7 +7306,7 @@ function getStateFromUpdate(
return prevState;
} // Merge the partial state and the previous state.
- return Object.assign({}, prevState, partialState);
+ return assign({}, prevState, partialState);
}
case ForceUpdate: {
@@ -7066,10 +7514,10 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) {
}
function callCallback(callback, context) {
- if (!(typeof callback === "function")) {
- throw Error(
- "Invalid argument passed as callback. Expected a function. Instead received: " +
- callback
+ if (typeof callback !== "function") {
+ throw new Error(
+ "Invalid argument passed as callback. Expected a function. Instead " +
+ ("received: " + callback)
);
}
@@ -7168,11 +7616,14 @@ var didWarnAboutInvalidateContextType;
Object.defineProperty(fakeInternalInstance, "_processChildContext", {
enumerable: false,
value: function() {
- {
- throw Error(
- "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)."
- );
- }
+ throw new Error(
+ "_processChildContext is not available in React 16+. This likely " +
+ "means you have multiple copies of React and are attempting to nest " +
+ "a React 15 tree inside a React 16 tree using " +
+ "unstable_renderSubtreeIntoContainer, which isn't supported. Try " +
+ "to make sure you have only one copy of React (and ideally, switch " +
+ "to ReactDOM.createPortal)."
+ );
}
});
Object.freeze(fakeInternalInstance);
@@ -7185,7 +7636,6 @@ function applyDerivedStateFromProps(
nextProps
) {
var prevState = workInProgress.memoizedState;
-
var partialState = getDerivedStateFromProps(nextProps, prevState);
{
@@ -7195,7 +7645,7 @@ function applyDerivedStateFromProps(
var memoizedState =
partialState === null || partialState === undefined
? prevState
- : Object.assign({}, prevState, partialState);
+ : assign({}, prevState, partialState);
workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
// base state.
@@ -7610,9 +8060,10 @@ function constructClassInstance(workInProgress, ctor, props) {
context = isLegacyContextConsumer
? getMaskedContext(workInProgress, unmaskedContext)
: emptyContextObject;
- } // Instantiate twice to help detect side-effects.
+ }
+
+ var instance = new ctor(props, context); // Instantiate twice to help detect side-effects.
- var instance = new ctor(props, context);
var state = (workInProgress.memoizedState =
instance.state !== null && instance.state !== undefined
? instance.state
@@ -8168,6 +8619,78 @@ function updateClassInstance(
return shouldUpdate;
}
+// TODO: Use the unified fiber stack module instead of this local one?
+// Intentionally not using it yet to derisk the initial implementation, because
+// the way we push/pop these values is a bit unusual. If there's a mistake, I'd
+// rather the ids be wrong than crash the whole reconciler.
+var forkStack = [];
+var forkStackIndex = 0;
+var treeForkProvider = null;
+var treeForkCount = 0;
+var idStack = [];
+var idStackIndex = 0;
+var treeContextProvider = null;
+var treeContextId = 1;
+var treeContextOverflow = "";
+
+function popTreeContext(workInProgress) {
+ // Restore the previous values.
+ // This is a bit more complicated than other context-like modules in Fiber
+ // because the same Fiber may appear on the stack multiple times and for
+ // different reasons. We have to keep popping until the work-in-progress is
+ // no longer at the top of the stack.
+ while (workInProgress === treeForkProvider) {
+ treeForkProvider = forkStack[--forkStackIndex];
+ forkStack[forkStackIndex] = null;
+ treeForkCount = forkStack[--forkStackIndex];
+ forkStack[forkStackIndex] = null;
+ }
+
+ while (workInProgress === treeContextProvider) {
+ treeContextProvider = idStack[--idStackIndex];
+ idStack[idStackIndex] = null;
+ treeContextOverflow = idStack[--idStackIndex];
+ idStack[idStackIndex] = null;
+ treeContextId = idStack[--idStackIndex];
+ idStack[idStackIndex] = null;
+ }
+}
+
+var isHydrating = false;
+
+function prepareToHydrateHostInstance(
+ fiber,
+ rootContainerInstance,
+ hostContext
+) {
+ {
+ throw new 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 new 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;
+}
+
var didWarnAboutMaps;
var didWarnAboutGenerators;
var didWarnAboutStringRefs;
@@ -8198,9 +8721,10 @@ var warnForMissingKey = function(child, returnFiber) {};
return;
}
- if (!(typeof child._store === "object")) {
- throw Error(
- "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue."
+ if (typeof child._store !== "object") {
+ throw new Error(
+ "React Component in warnForMissingKey should have a _store. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -8269,9 +8793,12 @@ function coerceRef(returnFiber, current, element) {
if (owner) {
var ownerFiber = owner;
- if (!(ownerFiber.tag === ClassComponent)) {
- throw Error(
- "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
+ if (ownerFiber.tag !== ClassComponent) {
+ throw new Error(
+ "Function components cannot have string refs. " +
+ "We recommend using useRef() instead. " +
+ "Learn more about using refs safely here: " +
+ "https://reactjs.org/link/strict-mode-string-ref"
);
}
@@ -8279,11 +8806,18 @@ function coerceRef(returnFiber, current, element) {
}
if (!inst) {
- throw Error(
+ throw new Error(
"Missing owner for string ref " +
mixedRef +
- ". This error is likely caused by a bug in React. Please file an issue."
+ ". This error is likely caused by a " +
+ "bug in React. Please file an issue."
);
+ } // Assigning this to a const so Flow knows it won't change in the closure
+
+ var resolvedInst = inst;
+
+ {
+ checkPropStringCoercion(mixedRef, "ref");
}
var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref
@@ -8298,11 +8832,11 @@ function coerceRef(returnFiber, current, element) {
}
var ref = function(value) {
- var refs = inst.refs;
+ var refs = resolvedInst.refs;
if (refs === emptyRefsObject) {
// This is a lazy pooled frozen object, so we need to initialize.
- refs = inst.refs = {};
+ refs = resolvedInst.refs = {};
}
if (value === null) {
@@ -8315,17 +8849,22 @@ function coerceRef(returnFiber, current, element) {
ref._stringRef = stringRef;
return ref;
} else {
- if (!(typeof mixedRef === "string")) {
- throw Error(
+ if (typeof mixedRef !== "string") {
+ throw new Error(
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
);
}
if (!element._owner) {
- throw Error(
+ throw new Error(
"Element ref was specified as a string (" +
mixedRef +
- ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
+ ") but no owner was set. This could happen for one of" +
+ " the following reasons:\n" +
+ "1. You may be adding a ref to a function component\n" +
+ "2. You may be adding a ref to a component that was not created inside a component's render method\n" +
+ "3. You have multiple copies of React loaded\n" +
+ "See https://reactjs.org/link/refs-must-have-owner for more information."
);
}
}
@@ -8336,16 +8875,15 @@ function coerceRef(returnFiber, current, element) {
function throwOnInvalidObjectType(returnFiber, newChild) {
var childString = Object.prototype.toString.call(newChild);
-
- {
- throw Error(
- "Objects are not valid as a React child (found: " +
- (childString === "[object Object]"
- ? "object with keys {" + Object.keys(newChild).join(", ") + "}"
- : childString) +
- "). If you meant to render a collection of children, use an array instead."
- );
- }
+ throw new Error(
+ "Objects are not valid as a React child (found: " +
+ (childString === "[object Object]"
+ ? "object with keys {" + Object.keys(newChild).join(", ") + "}"
+ : childString) +
+ "). " +
+ "If you meant to render a collection of children, use an array " +
+ "instead."
+ );
}
function warnOnFunctionType(returnFiber) {
@@ -8436,7 +8974,9 @@ function ChildReconciler(shouldTrackSideEffects) {
newFiber.index = newIndex;
if (!shouldTrackSideEffects) {
- // Noop.
+ // During hydration, the useId algorithm needs to know which fibers are
+ // part of a list of children (arrays, iterators).
+ newFiber.flags |= Forked;
return lastPlacedIndex;
}
@@ -8565,7 +9105,10 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function createChild(returnFiber, newChild, lanes) {
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ 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.
@@ -8628,7 +9171,10 @@ function ChildReconciler(shouldTrackSideEffects) {
// Update the fiber if the keys match, otherwise return null.
var key = oldFiber !== null ? oldFiber.key : null;
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ 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.
@@ -8685,7 +9231,10 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild,
lanes
) {
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ 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;
@@ -8876,6 +9425,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (newIdx === newChildren.length) {
// We've reached the end of the new children. We can delete the rest.
deleteRemainingChildren(returnFiber, oldFiber);
+
return resultingFirstChild;
}
@@ -8961,9 +9511,10 @@ function ChildReconciler(shouldTrackSideEffects) {
// but using the iterator instead.
var iteratorFn = getIteratorFn(newChildrenIterable);
- if (!(typeof iteratorFn === "function")) {
- throw Error(
- "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue."
+ if (typeof iteratorFn !== "function") {
+ throw new Error(
+ "An object is not an iterable. This error is likely caused by a bug in " +
+ "React. Please file an issue."
);
}
@@ -9015,8 +9566,8 @@ function ChildReconciler(shouldTrackSideEffects) {
var newChildren = iteratorFn.call(newChildrenIterable);
- if (!(newChildren != null)) {
- throw Error("An iterable object provided no iterator.");
+ if (newChildren == null) {
+ throw new Error("An iterable object provided no iterator.");
}
var resultingFirstChild = null;
@@ -9081,6 +9632,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (step.done) {
// We've reached the end of the new children. We can delete the rest.
deleteRemainingChildren(returnFiber, oldFiber);
+
return resultingFirstChild;
}
@@ -9367,7 +9919,10 @@ function ChildReconciler(shouldTrackSideEffects) {
throwOnInvalidObjectType(returnFiber, newChild);
}
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ typeof newChild === "number"
+ ) {
return placeSingleChild(
reconcileSingleTextNode(
returnFiber,
@@ -9382,38 +9937,6 @@ function ChildReconciler(shouldTrackSideEffects) {
if (typeof newChild === "function") {
warnOnFunctionType(returnFiber);
}
- }
-
- if (typeof newChild === "undefined" && !isUnkeyedTopLevelFragment) {
- // If the new child is undefined, and the return fiber is a composite
- // component, throw an error. If Fiber return types are disabled,
- // we already threw above.
- switch (returnFiber.tag) {
- case ClassComponent: {
- {
- var instance = returnFiber.stateNode;
-
- if (instance.render._isMockFunction) {
- // We allow auto-mocks to proceed as if they're returning null.
- break;
- }
- }
- }
- // Intentionally fall through to the next case, which handles both
- // functions and classes
- // eslint-disable-next-lined no-fallthrough
-
- case FunctionComponent:
- case ForwardRef:
- case SimpleMemoComponent: {
- {
- throw Error(
- (getComponentNameFromFiber(returnFiber) || "Component") +
- "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."
- );
- }
- }
- }
} // Remaining cases are all treated as empty.
return deleteRemainingChildren(returnFiber, currentFirstChild);
@@ -9425,8 +9948,8 @@ function ChildReconciler(shouldTrackSideEffects) {
var reconcileChildFibers = ChildReconciler(true);
var mountChildFibers = ChildReconciler(false);
function cloneChildFibers(current, workInProgress) {
- if (!(current === null || workInProgress.child === current.child)) {
- throw Error("Resuming work not yet implemented.");
+ if (current !== null && workInProgress.child !== current.child) {
+ throw new Error("Resuming work not yet implemented.");
}
if (workInProgress.child === null) {
@@ -9465,9 +9988,10 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT);
var rootInstanceStackCursor = createCursor(NO_CONTEXT);
function requiredContext(c) {
- if (!(c !== NO_CONTEXT)) {
- throw Error(
- "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."
+ if (c === NO_CONTEXT) {
+ throw new Error(
+ "Expected host context to exist. This error is likely caused by a bug " +
+ "in React. Please file an issue."
);
}
@@ -9586,22 +10110,11 @@ function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
return false;
}
- var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
-
- if (props.fallback === undefined) {
- return false;
- } // Regular boundaries always capture.
+ var props = workInProgress.memoizedProps; // Regular boundaries always capture.
- if (props.unstable_avoidThisFallback !== true) {
+ {
return true;
} // If it's a boundary we should avoid, then we prefer to bubble up to the
- // parent boundary if it is currently invisible.
-
- if (hasInvisibleParent) {
- return false;
- } // If the parent is not able to handle it, we must handle it.
-
- return true;
}
function findFirstSuspended(row) {
var node = row;
@@ -9656,114 +10169,46 @@ function findFirstSuspended(row) {
return null;
}
-var isHydrating = false;
+var NoFlags$1 =
+ /* */
+ 0; // Represents whether effect should fire.
-function enterHydrationState(fiber) {
- {
- return false;
- }
-}
+var HasEffect =
+ /* */
+ 1; // Represents the phase in which the effect (not the clean-up) fires.
+
+var Insertion =
+ /* */
+ 2;
+var Layout =
+ /* */
+ 4;
+var Passive$1 =
+ /* */
+ 8;
+
+// and should be reset before starting a new render.
+// This tracks which mutable sources need to be reset after a render.
+
+var workInProgressSources = [];
+function resetWorkInProgressVersions() {
+ for (var i = 0; i < workInProgressSources.length; i++) {
+ var mutableSource = workInProgressSources[i];
-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;
+ 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.
-
-function getSuspendedCachePool() {
- {
- return null;
- } // We check the cache on the stack first, since that's the one any new Caches
-}
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
var didWarnAboutMismatchedHooksForComponent;
-var didWarnAboutUseOpaqueIdentifier;
+var didWarnUncachedGetSnapshot;
{
- didWarnAboutUseOpaqueIdentifier = {};
didWarnAboutMismatchedHooksForComponent = new Set();
}
@@ -9787,7 +10232,11 @@ var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only
// TODO: Maybe there's some way to consolidate this with
// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`.
-var didScheduleRenderPhaseUpdateDuringThisPass = false;
+var didScheduleRenderPhaseUpdateDuringThisPass = false; // Counts the number of useId hooks in this component.
+// hydration). This counter is global, so client ids are not stable across
+// render attempts.
+
+var globalClientIdCounter = 0;
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.
@@ -9885,11 +10334,14 @@ function warnOnHookMismatchInDev(currentHookName) {
}
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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
- );
- }
+ throw new 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:\n" +
+ "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" +
+ "2. You might be breaking the Rules of Hooks\n" +
+ "3. You might have more than one copy of React in the same app\n" +
+ "See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
+ );
}
function areHookInputsEqual(nextDeps, prevDeps) {
@@ -9965,6 +10417,7 @@ function renderWithHooks(
// currentHook = null;
// workInProgressHook = null;
// didScheduleRenderPhaseUpdate = false;
+ // localIdCounter = 0;
// TODO Warn if no hooks are used at all during mount, then some are used during update.
// Currently we will identify the update render as a mount because memoizedState === null.
// This is tricky because it's valid for certain types of components (e.g. React.lazy)
@@ -9997,9 +10450,10 @@ function renderWithHooks(
do {
didScheduleRenderPhaseUpdateDuringThisPass = false;
- if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
- throw Error(
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
+ if (numberOfReRenders >= RE_RENDER_LIMIT) {
+ throw new Error(
+ "Too many re-renders. React limits the number of renders to prevent " +
+ "an infinite loop."
);
}
@@ -10024,7 +10478,7 @@ function renderWithHooks(
children = Component(props, secondArg);
} 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.
+ // at the beginning of the render phase and there's no re-entrance.
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -10063,11 +10517,13 @@ function renderWithHooks(
}
}
- didScheduleRenderPhaseUpdate = false;
+ didScheduleRenderPhaseUpdate = false; // This is reset by checkDidRenderIdHook
+ // localIdCounter = 0;
- if (!!didRenderTooFewHooks) {
- throw Error(
- "Rendered fewer hooks than expected. This may be caused by an accidental early return statement."
+ if (didRenderTooFewHooks) {
+ throw new Error(
+ "Rendered fewer hooks than expected. This may be caused by an accidental " +
+ "early return statement."
);
}
@@ -10085,7 +10541,7 @@ function bailoutHooks(current, workInProgress, 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.
+ // at the beginning of the render phase and there's no re-entrance.
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
if (didScheduleRenderPhaseUpdate) {
@@ -10182,8 +10638,8 @@ function updateWorkInProgressHook() {
currentHook = nextCurrentHook;
} else {
// Clone from the current hook.
- if (!(nextCurrentHook !== null)) {
- throw Error("Rendered more hooks than during the previous render.");
+ if (nextCurrentHook === null) {
+ throw new Error("Rendered more hooks than during the previous render.");
}
currentHook = nextCurrentHook;
@@ -10209,7 +10665,8 @@ function updateWorkInProgressHook() {
function createFunctionComponentUpdateQueue() {
return {
- lastEffect: null
+ lastEffect: null,
+ stores: null
};
}
@@ -10229,15 +10686,16 @@ function mountReducer(reducer, initialArg, init) {
}
hook.memoizedState = hook.baseState = initialState;
- var queue = (hook.queue = {
+ var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: reducer,
lastRenderedState: initialState
- });
- var dispatch = (queue.dispatch = dispatchAction.bind(
+ };
+ hook.queue = queue;
+ var dispatch = (queue.dispatch = dispatchReducerAction.bind(
null,
currentlyRenderingFiber$1,
queue
@@ -10249,8 +10707,8 @@ function updateReducer(reducer, initialArg, init) {
var hook = updateWorkInProgressHook();
var queue = hook.queue;
- if (!(queue !== null)) {
- throw Error(
+ if (queue === null) {
+ throw new Error(
"Should have a queue. This is likely a bug in React. Please file an issue."
);
}
@@ -10307,7 +10765,7 @@ function updateReducer(reducer, initialArg, init) {
var clone = {
lane: updateLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
@@ -10335,16 +10793,16 @@ function updateReducer(reducer, initialArg, init) {
// this will never be skipped by the check above.
lane: NoLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
newBaseQueueLast = newBaseQueueLast.next = _clone;
} // Process this update.
- if (update.eagerReducer === reducer) {
- // If this update was processed eagerly, and its reducer matches the
- // current reducer, we can use the eagerly computed state.
+ if (update.hasEagerState) {
+ // If this update is a state update (not a reducer) and was processed eagerly,
+ // we can use the eagerly computed state
newState = update.eagerState;
} else {
var action = update.action;
@@ -10402,8 +10860,8 @@ function rerenderReducer(reducer, initialArg, init) {
var hook = updateWorkInProgressHook();
var queue = hook.queue;
- if (!(queue !== null)) {
- throw Error(
+ if (queue === null) {
+ throw new Error(
"Should have a queue. This is likely a bug in React. Please file an issue."
);
}
@@ -10450,290 +10908,221 @@ function rerenderReducer(reducer, initialArg, init) {
return [newState, dispatch];
}
-function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+function mountMutableSource(source, getSnapshot, subscribe) {
{
- warnAboutMultipleRenderersDEV(source);
+ return undefined;
}
+}
- 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);
- }
+function updateMutableSource(source, getSnapshot, subscribe) {
+ {
+ return undefined;
}
+}
- 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."
- );
- }
- }
+function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
+ var fiber = currentlyRenderingFiber$1;
+ var hook = mountWorkInProgressHook();
+ var nextSnapshot;
- 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); // Intentioally throw an error to force React to retry synchronously. During
- // the synchronous retry, it will block interleaved mutations, so we should
- // get a consistent read. Therefore, the following error should never be
- // visible to the user.
- //
- // If it were to become visible to the user, it suggests one of two things:
- // a bug in React, or (more likely), a mutation during the render phase that
- // caused the second re-render attempt to be different from the first.
- //
- // We know it's the second case if the logs are currently disabled. So in
- // dev, we can present a more accurate error message.
+ {
+ nextSnapshot = getSnapshot();
{
- // eslint-disable-next-line react-internal/no-production-logging
- if (console.log.__reactDisabledLog) {
- // If the logs are disabled, this is the dev-only double render. This is
- // only reachable if there was a mutation during render. Show a helpful
- // error message.
- //
- // Something interesting to note: because we only double render in
- // development, this error will never happen during production. This is
- // actually true of all errors that occur during a double render,
- // because if the first render had thrown, we would have exited the
- // begin phase without double rendering. We should consider suppressing
- // any error from a double render (with a warning) to more closely match
- // the production behavior.
- var componentName = getComponentNameFromFiber(
- currentlyRenderingFiber$1
- );
+ if (!didWarnUncachedGetSnapshot) {
+ var cachedSnapshot = getSnapshot();
- {
- throw Error(
- "A mutable source was mutated while the " +
- componentName +
- " component was rendering. This is not supported. Move any mutations into event handlers or effects."
+ if (!objectIs(nextSnapshot, cachedSnapshot)) {
+ error(
+ "The result of getSnapshot should be cached to avoid an infinite loop"
);
+
+ didWarnUncachedGetSnapshot = true;
}
}
- } // We expect this error not to be thrown during the synchronous retry,
- // because we blocked interleaved mutations.
+ } // Unless we're rendering a blocking lane, schedule a consistency check.
+ // Right before committing, we will walk the tree and check if any of the
+ // stores were mutated.
+ //
+ // We won't do this if we're hydrating server-rendered content, because if
+ // the content is stale, it's already visible anyway. Instead we'll patch
+ // it up in a passive effect.
- {
- throw Error(
- "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue."
+ var root = getWorkInProgressRoot();
+
+ if (root === null) {
+ throw new Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
);
}
- }
-}
-function useMutableSource(hook, source, getSnapshot, subscribe) {
- var root = getWorkInProgressRoot();
+ if (!includesBlockingLane(root, renderLanes)) {
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ } // Read the current snapshot from the store on every render. This breaks the
+ // normal rules of React, and only works because store updates are
+ // always synchronous.
- if (!(root !== null)) {
- throw Error(
- "Expected a work-in-progress root. This is a bug in React. Please file an issue."
- );
- }
+ hook.memoizedState = nextSnapshot;
+ var inst = {
+ value: nextSnapshot,
+ getSnapshot: getSnapshot
+ };
+ hook.queue = inst; // Schedule an effect to subscribe to the store.
+
+ mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); // Schedule an effect to update the mutable instance fields. We will update
+ // this whenever subscribe, getSnapshot, or value changes. Because there's no
+ // clean-up function, and we track the deps correctly, we can call pushEffect
+ // directly, without storing any additional state. For the same reason, we
+ // don't need to set a static flag, either.
+ // TODO: We can move this to the passive phase once we add a pre-commit
+ // consistency check. See the next comment.
+
+ fiber.flags |= Passive;
+ pushEffect(
+ HasEffect | Passive$1,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ undefined,
+ null
+ );
+ return nextSnapshot;
+}
- var getVersion = source._getVersion;
- var version = getVersion(source._source);
- var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const
+function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
+ var fiber = currentlyRenderingFiber$1;
+ var hook = updateWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the
+ // normal rules of React, and only works because store updates are
+ // always synchronous.
- var _dispatcher$useState = dispatcher.useState(function() {
- return readFromUnsubcribedMutableSource(root, source, getSnapshot);
- }),
- currentSnapshot = _dispatcher$useState[0],
- setSnapshot = _dispatcher$useState[1];
+ var nextSnapshot = getSnapshot();
- 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.
+ {
+ if (!didWarnUncachedGetSnapshot) {
+ var cachedSnapshot = getSnapshot();
- 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.
+ if (!objectIs(nextSnapshot, cachedSnapshot)) {
+ error(
+ "The result of getSnapshot should be cached to avoid an infinite loop"
+ );
- 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.
+ didWarnUncachedGetSnapshot = true;
+ }
+ }
+ }
- refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now.
+ var prevSnapshot = hook.memoizedState;
+ var snapshotChanged = !objectIs(prevSnapshot, nextSnapshot);
- var maybeNewVersion = getVersion(source._source);
+ if (snapshotChanged) {
+ hook.memoizedState = nextSnapshot;
+ markWorkInProgressReceivedUpdate();
+ }
- if (!objectIs(version, maybeNewVersion)) {
- var maybeNewSnapshot = getSnapshot(source._source);
+ var inst = hook.queue;
+ updateEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [
+ subscribe
+ ]); // Whenever getSnapshot or subscribe changes, we need to check in the
+ // commit phase if there was an interleaved mutation. In concurrent mode
+ // this can happen all the time, but even in synchronous mode, an earlier
+ // effect may have mutated the store.
- {
- 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 (
+ inst.getSnapshot !== getSnapshot ||
+ snapshotChanged || // Check if the susbcribe function changed. We can save some memory by
+ // checking whether we scheduled a subscription effect above.
+ (workInProgressHook !== null &&
+ workInProgressHook.memoizedState.tag & HasEffect)
+ ) {
+ fiber.flags |= Passive;
+ pushEffect(
+ HasEffect | Passive$1,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ undefined,
+ null
+ ); // Unless we're rendering a blocking lane, schedule a consistency check.
+ // Right before committing, we will walk the tree and check if any of the
+ // stores were mutated.
- if (!objectIs(snapshot, maybeNewSnapshot)) {
- setSnapshot(maybeNewSnapshot);
- var lane = requestUpdateLane(fiber);
- 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.
+ var root = getWorkInProgressRoot();
- markRootEntangled(root, root.mutableReadLanes);
- }
- },
- [getSnapshot, source, subscribe]
- ); // If we got a new source or subscribe function, re-subscribe in a passive effect.
+ if (root === null) {
+ throw new Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ }
- dispatcher.useEffect(
- function() {
- var handleChange = function() {
- var latestGetSnapshot = refs.getSnapshot;
- var latestSetSnapshot = refs.setSnapshot;
+ if (!includesBlockingLane(root, renderLanes)) {
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ }
- try {
- latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time.
+ return nextSnapshot;
+}
- var lane = requestUpdateLane(fiber);
- 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;
- });
- }
- };
+function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
+ fiber.flags |= StoreConsistency;
+ var check = {
+ getSnapshot: getSnapshot,
+ value: renderedSnapshot
+ };
+ var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
- var unsubscribe = subscribe(source._source, handleChange);
+ if (componentUpdateQueue === null) {
+ componentUpdateQueue = createFunctionComponentUpdateQueue();
+ currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
+ componentUpdateQueue.stores = [check];
+ } else {
+ var stores = componentUpdateQueue.stores;
- {
- if (typeof unsubscribe !== "function") {
- error(
- "Mutable source subscribe function must return an unsubscribe function."
- );
- }
- }
+ if (stores === null) {
+ componentUpdateQueue.stores = [check];
+ } else {
+ stores.push(check);
+ }
+ }
+}
- 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.
+function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
+ // These are updated in the passive phase
+ inst.value = nextSnapshot;
+ inst.getSnapshot = getSnapshot; // Something may have been mutated in between render and commit. This could
+ // have been in an event that fired before the passive effects, or it could
+ // have been in a layout effect. In that case, we would have used the old
+ // snapsho and getSnapshot values to bail out. We need to check one more time.
- 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,
- interleaved: null,
- lanes: NoLanes,
- 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;
+ if (checkIfSnapshotChanged(inst)) {
+ // Force a re-render.
+ forceStoreRerender(fiber);
}
+}
+
+function subscribeToStore(fiber, inst, subscribe) {
+ var handleStoreChange = function() {
+ // The store changed. Check if the snapshot changed since the last time we
+ // read from the store.
+ if (checkIfSnapshotChanged(inst)) {
+ // Force a re-render.
+ forceStoreRerender(fiber);
+ }
+ }; // Subscribe to the store and return a clean-up function.
- return snapshot;
+ return subscribe(handleStoreChange);
}
-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 checkIfSnapshotChanged(inst) {
+ var latestGetSnapshot = inst.getSnapshot;
+ var prevValue = inst.value;
+
+ try {
+ var nextValue = latestGetSnapshot();
+ return !objectIs(prevValue, nextValue);
+ } catch (error) {
+ return true;
+ }
}
-function updateMutableSource(source, getSnapshot, subscribe) {
- var hook = updateWorkInProgressHook();
- return useMutableSource(hook, source, getSnapshot, subscribe);
+function forceStoreRerender(fiber) {
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
function mountState(initialState) {
@@ -10745,15 +11134,16 @@ function mountState(initialState) {
}
hook.memoizedState = hook.baseState = initialState;
- var queue = (hook.queue = {
+ var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
- });
- var dispatch = (queue.dispatch = dispatchAction.bind(
+ };
+ hook.queue = queue;
+ var dispatch = (queue.dispatch = dispatchSetState.bind(
null,
currentlyRenderingFiber$1,
queue
@@ -10867,6 +11257,14 @@ function updateEffect(create, deps) {
return updateEffectImpl(Passive, Passive$1, create, deps);
}
+function mountInsertionEffect(create, deps) {
+ return mountEffectImpl(Update, Insertion, create, deps);
+}
+
+function updateInsertionEffect(create, deps) {
+ return updateEffectImpl(Update, Insertion, create, deps);
+}
+
function mountLayoutEffect(create, deps) {
var fiberFlags = Update;
@@ -11024,7 +11422,7 @@ function mountDeferredValue(value) {
mountEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
@@ -11045,7 +11443,7 @@ function updateDeferredValue(value) {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
@@ -11066,7 +11464,7 @@ function rerenderDeferredValue(value) {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
@@ -11079,14 +11477,19 @@ function rerenderDeferredValue(value) {
return prevValue;
}
-function startTransition(setPending, callback) {
+function startTransition(setPending, callback, options) {
var previousPriority = getCurrentUpdatePriority();
setCurrentUpdatePriority(
higherEventPriority(previousPriority, ContinuousEventPriority)
);
setPending(true);
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
+ var currentTransition = ReactCurrentBatchConfig$1.transition;
+
+ {
+ ReactCurrentBatchConfig$1.transition._updatedFibers = new Set();
+ }
try {
setPending(false);
@@ -11094,6 +11497,22 @@ function startTransition(setPending, callback) {
} finally {
setCurrentUpdatePriority(previousPriority);
ReactCurrentBatchConfig$1.transition = prevTransition;
+
+ {
+ if (prevTransition === null && currentTransition._updatedFibers) {
+ var updatedFibersCount = currentTransition._updatedFibers.size;
+
+ if (updatedFibersCount > 10) {
+ warn(
+ "Detected a large number of updates inside startTransition. " +
+ "If this is due to a subscription please re-write it to use React provided hooks. " +
+ "Otherwise concurrent mode guarantees are off the table."
+ );
+ }
+
+ currentTransition._updatedFibers.clear();
+ }
+ }
}
}
@@ -11133,48 +11552,34 @@ function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
}
}
-function warnOnOpaqueIdentifierAccessInDEV(fiber) {
- {
- // TODO: Should warn in effects and callbacks, too
- var name = getComponentNameFromFiber(fiber) || "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 mountId() {
+ var hook = mountWorkInProgressHook();
+ var root = getWorkInProgressRoot(); // TODO: In Fizz, id generation is specific to each server config. Maybe we
+ // should do this in Fiber, too? Deferring this decision for now because
+ // there's no other place to store the prefix except for an internal field on
+ // the public createRoot object, which the fiber tree does not currently have
+ // a reference to.
-function mountOpaqueIdentifier() {
- var makeId = makeClientIdInDEV.bind(
- null,
- warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)
- );
+ var identifierPrefix = root.identifierPrefix;
+ var id;
{
- var _id = makeId();
-
- mountState(_id);
- return _id;
+ // Use a lowercase r prefix for client-generated ids.
+ var globalClientId = globalClientIdCounter++;
+ id = ":" + identifierPrefix + "r" + globalClientId.toString(32) + ":";
}
-}
-function updateOpaqueIdentifier() {
- var id = updateState()[0];
+ hook.memoizedState = id;
return id;
}
-function rerenderOpaqueIdentifier() {
- var id = rerenderState()[0];
+function updateId() {
+ var hook = updateWorkInProgressHook();
+ var id = hook.memoizedState;
return id;
}
-function dispatchAction(fiber, queue, action) {
+function dispatchReducerAction(fiber, queue, action) {
{
if (typeof arguments[3] === "function") {
error(
@@ -11185,65 +11590,53 @@ function dispatchAction(fiber, queue, action) {
}
}
- var eventTime = requestEventTime();
var lane = requestUpdateLane(fiber);
var update = {
lane: lane,
action: action,
- eagerReducer: null,
+ hasEagerState: false,
eagerState: null,
next: null
};
- var alternate = fiber.alternate;
- if (
- fiber === currentlyRenderingFiber$1 ||
- (alternate !== null && alternate === currentlyRenderingFiber$1)
- ) {
- // 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.
- didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
- var pending = queue.pending;
+ if (isRenderPhaseUpdate(fiber)) {
+ enqueueRenderPhaseUpdate(queue, update);
+ } else {
+ enqueueUpdate$1(fiber, queue, update);
+ var eventTime = requestEventTime();
+ var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
- if (pending === null) {
- // This is the first update. Create a circular list.
- update.next = update;
- } else {
- update.next = pending.next;
- pending.next = update;
+ if (root !== null) {
+ entangleTransitionUpdate(root, queue, lane);
}
+ }
+}
- queue.pending = update;
- } else {
- if (isInterleavedUpdate(fiber)) {
- var interleaved = queue.interleaved;
+function dispatchSetState(fiber, queue, action) {
+ {
+ if (typeof arguments[3] === "function") {
+ error(
+ "State updates from the useState() and useReducer() Hooks don't support the " +
+ "second callback argument. To execute a side effect after " +
+ "rendering, declare it in the component body with useEffect()."
+ );
+ }
+ }
- if (interleaved === null) {
- // This is the first update. Create a circular list.
- update.next = update; // At the end of the current render, this queue's interleaved updates will
- // be transferred to the pending queue.
+ var lane = requestUpdateLane(fiber);
+ var update = {
+ lane: lane,
+ action: action,
+ hasEagerState: false,
+ eagerState: null,
+ next: null
+ };
- pushInterleavedQueue(queue);
- } else {
- update.next = interleaved.next;
- interleaved.next = update;
- }
-
- queue.interleaved = update;
- } else {
- var _pending = queue.pending;
-
- if (_pending === null) {
- // This is the first update. Create a circular list.
- update.next = update;
- } else {
- update.next = _pending.next;
- _pending.next = update;
- }
-
- queue.pending = update;
- }
+ if (isRenderPhaseUpdate(fiber)) {
+ enqueueRenderPhaseUpdate(queue, update);
+ } else {
+ enqueueUpdate$1(fiber, queue, update);
+ var alternate = fiber.alternate;
if (
fiber.lanes === NoLanes &&
@@ -11269,7 +11662,7 @@ function dispatchAction(fiber, queue, action) {
// time we enter the render phase, then the eager state can be used
// without calling the reducer again.
- update.eagerReducer = lastRenderedReducer;
+ update.hasEagerState = true;
update.eagerState = eagerState;
if (objectIs(eagerState, currentState)) {
@@ -11289,24 +11682,88 @@ function dispatchAction(fiber, queue, action) {
}
}
+ var eventTime = requestEventTime();
var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
- if (isTransitionLane(lane) && root !== null) {
- var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they
- // must have finished. We can remove them from the shared queue, which
- // represents a superset of the actually pending lanes. In some cases we
- // may entangle more than we need to, but that's OK. In fact it's worse if
- // we *don't* entangle when we should.
+ if (root !== null) {
+ entangleTransitionUpdate(root, queue, lane);
+ }
+ }
+}
+
+function isRenderPhaseUpdate(fiber) {
+ var alternate = fiber.alternate;
+ return (
+ fiber === currentlyRenderingFiber$1 ||
+ (alternate !== null && alternate === currentlyRenderingFiber$1)
+ );
+}
+
+function enqueueRenderPhaseUpdate(queue, update) {
+ // 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.
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
+ var pending = queue.pending;
+
+ if (pending === null) {
+ // This is the first update. Create a circular list.
+ update.next = update;
+ } else {
+ update.next = pending.next;
+ pending.next = update;
+ }
+
+ queue.pending = update;
+}
+
+function enqueueUpdate$1(fiber, queue, update, lane) {
+ if (isInterleavedUpdate(fiber)) {
+ var interleaved = queue.interleaved;
+
+ if (interleaved === null) {
+ // This is the first update. Create a circular list.
+ update.next = update; // At the end of the current render, this queue's interleaved updates will
+ // be transferred to the pending queue.
- queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes.
+ pushInterleavedQueue(queue);
+ } else {
+ update.next = interleaved.next;
+ interleaved.next = update;
+ }
- var newQueueLanes = mergeLanes(queueLanes, lane);
- queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if
- // the lane finished since the last time we entangled it. So we need to
- // entangle it again, just to be sure.
+ queue.interleaved = update;
+ } else {
+ var pending = queue.pending;
- markRootEntangled(root, newQueueLanes);
+ if (pending === null) {
+ // This is the first update. Create a circular list.
+ update.next = update;
+ } else {
+ update.next = pending.next;
+ pending.next = update;
}
+
+ queue.pending = update;
+ }
+}
+
+function entangleTransitionUpdate(root, queue, lane) {
+ if (isTransitionLane(lane)) {
+ var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they
+ // must have finished. We can remove them from the shared queue, which
+ // represents a superset of the actually pending lanes. In some cases we
+ // may entangle more than we need to, but that's OK. In fact it's worse if
+ // we *don't* entangle when we should.
+
+ queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes.
+
+ var newQueueLanes = mergeLanes(queueLanes, lane);
+ queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if
+ // the lane finished since the last time we entangled it. So we need to
+ // entangle it again, just to be sure.
+
+ markRootEntangled(root, newQueueLanes);
}
}
@@ -11316,6 +11773,7 @@ var ContextOnlyDispatcher = {
useContext: throwInvalidHookError,
useEffect: throwInvalidHookError,
useImperativeHandle: throwInvalidHookError,
+ useInsertionEffect: throwInvalidHookError,
useLayoutEffect: throwInvalidHookError,
useMemo: throwInvalidHookError,
useReducer: throwInvalidHookError,
@@ -11325,7 +11783,8 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
- useOpaqueIdentifier: throwInvalidHookError,
+ useSyncExternalStore: throwInvalidHookError,
+ useId: throwInvalidHookError,
unstable_isNewReconciler: enableNewReconciler
};
@@ -11383,6 +11842,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
checkDepsAreArrayDev(deps);
return mountImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ mountHookTypesDev();
+ checkDepsAreArrayDev(deps);
+ return mountInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
mountHookTypesDev();
@@ -11449,12 +11914,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
mountHookTypesDev();
- return mountMutableSource(source, getSnapshot, subscribe);
+ return mountMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ mountHookTypesDev();
+ return mountSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
mountHookTypesDev();
- return mountOpaqueIdentifier();
+ return mountId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11483,6 +11953,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return mountImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ updateHookTypesDev();
+ return mountInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
updateHookTypesDev();
@@ -11547,12 +12022,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return mountMutableSource(source, getSnapshot, subscribe);
+ return mountMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ updateHookTypesDev();
+ return mountSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
updateHookTypesDev();
- return mountOpaqueIdentifier();
+ return mountId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11581,6 +12061,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
updateHookTypesDev();
@@ -11645,12 +12130,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ updateHookTypesDev();
+ return updateSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
updateHookTypesDev();
- return updateOpaqueIdentifier();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11679,6 +12169,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
updateHookTypesDev();
@@ -11743,12 +12238,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ updateHookTypesDev();
+ return updateSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
updateHookTypesDev();
- return rerenderOpaqueIdentifier();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11782,6 +12282,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ warnInvalidHookAccess();
+ mountHookTypesDev();
+ return mountInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
warnInvalidHookAccess();
@@ -11855,13 +12361,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
mountHookTypesDev();
- return mountMutableSource(source, getSnapshot, subscribe);
+ return mountMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ warnInvalidHookAccess();
+ mountHookTypesDev();
+ return mountSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
warnInvalidHookAccess();
mountHookTypesDev();
- return mountOpaqueIdentifier();
+ return mountId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11895,6 +12407,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
warnInvalidHookAccess();
@@ -11968,13 +12486,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateOpaqueIdentifier();
+ return updateSyncExternalStore(subscribe, getSnapshot);
+ },
+ useId: function() {
+ currentHookNameInDev = "useId";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -12008,6 +12532,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
warnInvalidHookAccess();
@@ -12081,13 +12611,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
warnInvalidHookAccess();
updateHookTypesDev();
- return rerenderOpaqueIdentifier();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -12269,12 +12805,10 @@ function createCapturedValue(value, source) {
}
if (
- !(
- typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog ===
- "function"
- )
+ typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog !==
+ "function"
) {
- throw Error(
+ throw new Error(
"Expected ReactFiberErrorDialog.showErrorDialog to be a function."
);
}
@@ -12403,9 +12937,16 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
var error$1 = errorInfo.value;
update.payload = function() {
- logCapturedError(fiber, errorInfo);
return getDerivedStateFromError(error$1);
};
+
+ update.callback = function() {
+ {
+ markFailedErrorBoundaryForHotReloading(fiber);
+ }
+
+ logCapturedError(fiber, errorInfo);
+ };
}
var inst = fiber.stateNode;
@@ -12416,15 +12957,15 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
markFailedErrorBoundaryForHotReloading(fiber);
}
+ logCapturedError(fiber, errorInfo);
+
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);
+ markLegacyErrorBoundaryAsFailed(this);
}
var error$1 = errorInfo.value;
@@ -12448,19 +12989,24 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
}
}
};
- } 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).
+ // Attach a ping listener
+ //
+ // The data might resolve before we have a chance to commit the fallback. Or,
+ // in the case of a refresh, we'll never commit a fallback. So we need to
+ // attach a listener now. When it resolves ("pings"), we can decide whether to
+ // try rendering the tree again.
+ //
+ // Only attach a listener if one does not already exist for the lanes
+ // we're currently rendering (which acts like a "thread ID" here).
+ //
+ // We only need to do this in concurrent mode. Legacy Suspense always
+ // commits fallbacks synchronously, so there are no pings.
var pingCache = root.pingCache;
var threadIDs;
@@ -12493,6 +13039,180 @@ function attachPingListener(root, wakeable, lanes) {
}
}
+function attachRetryListener(suspenseBoundary, root, wakeable, lanes) {
+ // Retry listener
+ //
+ // If the fallback does commit, we need to attach a different type of
+ // listener. This one schedules an update on the Suspense boundary to turn
+ // the fallback state off.
+ //
+ // Stash the wakeable on the boundary fiber so we can access it in the
+ // commit phase.
+ //
+ // When the wakeable resolves, we'll attempt to render the boundary
+ // again ("retry").
+ var wakeables = suspenseBoundary.updateQueue;
+
+ if (wakeables === null) {
+ var updateQueue = new Set();
+ updateQueue.add(wakeable);
+ suspenseBoundary.updateQueue = updateQueue;
+ } else {
+ wakeables.add(wakeable);
+ }
+}
+
+function resetSuspendedComponent(sourceFiber, rootRenderLanes) {
+ // A legacy mode Suspense quirk, only relevant to hook components.
+
+ var tag = sourceFiber.tag;
+
+ if (
+ (sourceFiber.mode & ConcurrentMode) === NoMode &&
+ (tag === FunctionComponent ||
+ tag === ForwardRef ||
+ tag === SimpleMemoComponent)
+ ) {
+ var currentSource = sourceFiber.alternate;
+
+ if (currentSource) {
+ sourceFiber.updateQueue = currentSource.updateQueue;
+ sourceFiber.memoizedState = currentSource.memoizedState;
+ sourceFiber.lanes = currentSource.lanes;
+ } else {
+ sourceFiber.updateQueue = null;
+ sourceFiber.memoizedState = null;
+ }
+ }
+}
+
+function getNearestSuspenseBoundaryToCapture(returnFiber) {
+ var node = returnFiber;
+
+ do {
+ if (node.tag === SuspenseComponent && shouldCaptureSuspense(node)) {
+ return node;
+ } // This boundary already captured during this render. Continue to the next
+ // boundary.
+
+ node = node.return;
+ } while (node !== null);
+
+ return null;
+}
+
+function markSuspenseBoundaryShouldCapture(
+ suspenseBoundary,
+ returnFiber,
+ sourceFiber,
+ root,
+ rootRenderLanes
+) {
+ // This marks a Suspense boundary so that when we're unwinding the stack,
+ // it captures the suspended "exception" and does a second (fallback) pass.
+ if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) {
+ // Legacy Mode Suspense
+ //
+ // If the boundary is in legacy mode, we should *not*
+ // suspend the commit. Pretend as if the suspended component rendered
+ // null and keep rendering. When the Suspense boundary completes,
+ // we'll do a second pass to render the fallback.
+ if (suspenseBoundary === returnFiber) {
+ // Special case where we suspended while reconciling the children of
+ // a Suspense boundary's inner Offscreen wrapper fiber. This happens
+ // when a React.lazy component is a direct child of a
+ // Suspense boundary.
+ //
+ // Suspense boundaries are implemented as multiple fibers, but they
+ // are a single conceptual unit. The legacy mode behavior where we
+ // pretend the suspended fiber committed as `null` won't work,
+ // because in this case the "suspended" fiber is the inner
+ // Offscreen wrapper.
+ //
+ // Because the contents of the boundary haven't started rendering
+ // yet (i.e. nothing in the tree has partially rendered) we can
+ // switch to the regular, concurrent mode behavior: mark the
+ // boundary with ShouldCapture and enter the unwind phase.
+ suspenseBoundary.flags |= ShouldCapture;
+ } else {
+ suspenseBoundary.flags |= DidCapture;
+ sourceFiber.flags |= 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.
+
+ sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
+
+ if (sourceFiber.tag === ClassComponent) {
+ var currentSourceFiber = sourceFiber.alternate;
+
+ 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);
+ 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.
+
+ sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane);
+ }
+
+ return suspenseBoundary;
+ } // 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. Transitions apply
+ // 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.
+
+ suspenseBoundary.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in
+ // the begin phase to prevent an early bailout.
+
+ suspenseBoundary.lanes = rootRenderLanes;
+ return suspenseBoundary;
+}
+
function throwException(
root,
returnFiber,
@@ -12515,163 +13235,62 @@ function throwException(
typeof value === "object" &&
typeof value.then === "function"
) {
+ // This is a wakeable. The component suspended.
var wakeable = value;
- // A legacy mode Suspense quirk, only relevant to hook components.
+ resetSuspendedComponent(sourceFiber);
- var tag = sourceFiber.tag;
+ var suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
- if (
- (sourceFiber.mode & ConcurrentMode) === NoMode &&
- (tag === FunctionComponent ||
- tag === ForwardRef ||
- tag === SimpleMemoComponent)
- ) {
- var currentSource = sourceFiber.alternate;
+ if (suspenseBoundary !== null) {
+ suspenseBoundary.flags &= ~ForceClientRender;
+ markSuspenseBoundaryShouldCapture(
+ suspenseBoundary,
+ returnFiber,
+ sourceFiber,
+ root,
+ rootRenderLanes
+ ); // We only attach ping listeners in concurrent mode. Legacy Suspense always
+ // commits fallbacks synchronously, so there are no pings.
- if (currentSource) {
- sourceFiber.updateQueue = currentSource.updateQueue;
- sourceFiber.memoizedState = currentSource.memoizedState;
- sourceFiber.lanes = currentSource.lanes;
- } else {
- sourceFiber.updateQueue = null;
- sourceFiber.memoizedState = null;
+ if (suspenseBoundary.mode & ConcurrentMode) {
+ attachPingListener(root, wakeable, rootRenderLanes);
}
- }
-
- var hasInvisibleParentBoundary = hasSuspenseContext(
- suspenseStackCursor.current,
- InvisibleParentSuspenseContext
- ); // Schedule the nearest Suspense to re-render the timed out view.
-
- var _workInProgress = returnFiber;
-
- 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;
-
- if (wakeables === null) {
- var updateQueue = new Set();
- updateQueue.add(wakeable);
- _workInProgress.updateQueue = updateQueue;
- } else {
- wakeables.add(wakeable);
- } // If the boundary is in legacy 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 concurrent mode tree. If the Suspense is outside of it, we
- // should *not* suspend the commit.
- //
- // If the suspense boundary suspended itself suspended, we don't have to
- // do this trick because nothing was partially started. We can just
- // directly do a second pass over the fallback in this render and
- // pretend we meant to render that directly.
-
- if (
- (_workInProgress.mode & ConcurrentMode) === NoMode &&
- _workInProgress !== returnFiber
- ) {
- _workInProgress.flags |= DidCapture;
- sourceFiber.flags |= 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.
-
- sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
-
- if (sourceFiber.tag === ClassComponent) {
- var _currentSourceFiber = sourceFiber.alternate;
-
- 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);
- 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.
- sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending.
-
- 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. Transitions apply
- // 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".
+ attachRetryListener(suspenseBoundary, root, wakeable);
+ return;
+ } else {
+ // No boundary was found. Unless this is a sync update, this is OK.
+ // We can suspend and wait for more data to arrive.
+ if (!includesSyncLane(rootRenderLanes)) {
+ // This is not a sync update. Suspend. Since we're not activating a
+ // Suspense boundary, this will unwind all the way to the root without
+ // performing a second pass to render a fallback. (This is arguably how
+ // refresh transitions should work, too, since we're not going to commit
+ // the fallbacks anyway.)
//
- // 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.
-
+ // This case also applies to initial hydration.
attachPingListener(root, wakeable, rootRenderLanes);
- _workInProgress.flags |= ShouldCapture;
- _workInProgress.lanes = rootRenderLanes;
+ renderDidSuspendDelayIfPossible();
return;
- } // This boundary already captured during this render. Continue to the next
- // boundary.
+ } // This is a sync/discrete update. We treat this case like an error
+ // because discrete renders are expected to produce a complete tree
+ // synchronously to maintain consistency with external state.
- _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 uncaughtSuspenseError = new Error(
+ "A component suspended while responding to synchronous input. This " +
+ "will cause the UI to be replaced with a loading indicator. To " +
+ "fix, updates that suspend should be wrapped " +
+ "with startTransition."
+ ); // If we're outside a transition, fall through to the regular error path.
+ // The error will be caught by the nearest suspense boundary.
- value = new Error(
- (getComponentNameFromFiber(sourceFiber) || "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."
- );
+ value = uncaughtSuspenseError;
+ }
} // 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.
- renderDidError();
+ renderDidError(value);
value = createCapturedValue(value, sourceFiber);
var workInProgress = returnFiber;
@@ -12682,10 +13301,8 @@ function throwException(
workInProgress.flags |= ShouldCapture;
var lane = pickArbitraryLane(rootRenderLanes);
workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
-
- var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
-
- enqueueCapturedUpdate(workInProgress, _update);
+ var update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
+ enqueueCapturedUpdate(workInProgress, update);
return;
}
@@ -12708,13 +13325,13 @@ function throwException(
workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state
- var _update2 = createClassErrorUpdate(
+ var _update = createClassErrorUpdate(
workInProgress,
errorInfo,
_lane
);
- enqueueCapturedUpdate(workInProgress, _update2);
+ enqueueCapturedUpdate(workInProgress, _update);
return;
}
@@ -12725,3838 +13342,3801 @@ function throwException(
} while (workInProgress !== null);
}
-var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
-var didReceiveUpdate = false;
-var didWarnAboutBadClass;
-var didWarnAboutModulePatternComponent;
-var didWarnAboutContextTypeOnFunctionComponent;
-var didWarnAboutGetDerivedStateOnFunctionComponent;
-var didWarnAboutFunctionRefs;
-var didWarnAboutReassigningProps;
-var didWarnAboutRevealOrder;
-var didWarnAboutTailOptions;
+function getSuspendedCache() {
+ {
+ return null;
+ } // This function is called when a Suspense boundary suspends. It returns the
+}
-{
- didWarnAboutBadClass = {};
- didWarnAboutModulePatternComponent = {};
- didWarnAboutContextTypeOnFunctionComponent = {};
- didWarnAboutGetDerivedStateOnFunctionComponent = {};
- didWarnAboutFunctionRefs = {};
- didWarnAboutReassigningProps = false;
- didWarnAboutRevealOrder = {};
- didWarnAboutTailOptions = {};
+function markUpdate(workInProgress) {
+ // Tag the fiber with an update effect. This turns a Placement into
+ // a PlacementAndUpdate.
+ workInProgress.flags |= Update;
}
-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,
- // we will add them all to the child before it gets rendered. That means
- // we can optimize this reconciliation pass by not tracking side-effects.
- workInProgress.child = mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderLanes
- );
- } else {
- // If the current child is the same as the work in progress, it means that
- // we haven't yet started any work on these children. Therefore, we use
- // the clone algorithm to create a copy of all the current children.
- // If we had any progressed work already, that is invalid at this point so
- // let's throw it out.
- workInProgress.child = reconcileChildFibers(
- workInProgress,
- current.child,
- nextChildren,
- renderLanes
- );
- }
-}
-
-function forceUnmountCurrentAndReconcile(
- current,
- workInProgress,
- nextChildren,
- 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
- // effect of all current children being unmounted; even if the type and key
- // are the same, the old child is unmounted and a new child is created.
- //
- // To do this, we're going to go through the reconcile algorithm twice. In
- // the first pass, we schedule a deletion for all the current children by
- // passing null.
- workInProgress.child = reconcileChildFibers(
- workInProgress,
- current.child,
- null,
- 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
- // identities match.
-
- workInProgress.child = reconcileChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderLanes
- );
+function markRef(workInProgress) {
+ workInProgress.flags |= Ref;
}
-function updateForwardRef(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- // TODO: current can be non-null here even if the component
- // hasn't yet mounted. This happens after the first render suspends.
- // We'll need to figure out if this is fine or can cause issues.
- {
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var innerPropTypes = Component.propTypes;
+function hadNoMutationsEffects(current, completedWork) {
+ var didBailout = current !== null && current.child === completedWork.child;
- if (innerPropTypes) {
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(Component)
- );
- }
- }
+ if (didBailout) {
+ return true;
}
- var render = Component.render;
- var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
+ if ((completedWork.flags & ChildDeletion) !== NoFlags) {
+ return false;
+ } // TODO: If we move the `hadNoMutationsEffects` call after `bubbleProperties`
+ // then we only have to check the `completedWork.subtreeFlags`.
- var nextChildren;
- prepareToReadContext(workInProgress, renderLanes);
+ var child = completedWork.child;
- {
- ReactCurrentOwner$1.current = workInProgress;
- setIsRendering(true);
- nextChildren = renderWithHooks(
- current,
- workInProgress,
- render,
- nextProps,
- ref,
- renderLanes
- );
+ while (child !== null) {
+ if (
+ (child.flags & MutationMask) !== NoFlags ||
+ (child.subtreeFlags & MutationMask) !== NoFlags
+ ) {
+ return false;
+ }
- setIsRendering(false);
+ child = child.sibling;
}
- if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderLanes);
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- } // React DevTools reads this flag.
-
- workInProgress.flags |= PerformedWork;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
+ return true;
}
-function updateMemoComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
-) {
- if (current === null) {
- var type = Component.type;
-
- if (
- isSimpleFunctionComponent(type) &&
- Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
- Component.defaultProps === undefined
- ) {
- var resolvedType = type;
+var appendAllChildren;
+var updateHostContainer;
+var updateHostComponent;
+var updateHostText;
- {
- resolvedType = resolveFunctionForHotReloading(type);
- } // If this is a plain function component without default props,
- // and with only the default shallow comparison, we upgrade it
- // to a SimpleMemoComponent to allow fast path updates.
+{
+ // Persistent host tree mode
+ appendAllChildren = function(
+ parent,
+ workInProgress,
+ needsVisibilityToggle,
+ isHidden
+ ) {
+ // We only have the top Fiber that was created but we need recurse down its
+ // children to find all the terminal nodes.
+ var node = workInProgress.child;
- workInProgress.tag = SimpleMemoComponent;
- workInProgress.type = resolvedType;
+ while (node !== null) {
+ // eslint-disable-next-line no-labels
+ if (node.tag === HostComponent) {
+ var instance = node.stateNode;
- {
- validateFunctionComponentInDev(workInProgress, type);
- }
+ if (needsVisibilityToggle && isHidden) {
+ // This child is inside a timed out tree. Hide it.
+ var props = node.memoizedProps;
+ var type = node.type;
+ instance = cloneHiddenInstance(instance);
+ }
- return updateSimpleMemoComponent(
- current,
- workInProgress,
- resolvedType,
- nextProps,
- updateLanes,
- renderLanes
- );
- }
+ appendInitialChild(parent, instance);
+ } else if (node.tag === HostText) {
+ var _instance = node.stateNode;
- {
- var innerPropTypes = type.propTypes;
+ if (needsVisibilityToggle && isHidden) {
+ // This child is inside a timed out tree. Hide it.
+ var text = node.memoizedProps;
+ _instance = cloneHiddenTextInstance();
+ }
- if (innerPropTypes) {
- // Inner memo component props aren't currently validated in createElement.
- // We could move it there, but we'd still need this for lazy code path.
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(type)
- );
- }
- }
+ appendInitialChild(parent, _instance);
+ } else if (node.tag === HostPortal);
+ else if (node.tag === OffscreenComponent && node.memoizedState !== null) {
+ // The children in this boundary are hidden. Toggle their visibility
+ // before appending.
+ var child = node.child;
- var child = createFiberFromTypeAndProps(
- Component.type,
- null,
- nextProps,
- workInProgress,
- workInProgress.mode,
- renderLanes
- );
- child.ref = workInProgress.ref;
- child.return = workInProgress;
- workInProgress.child = child;
- return child;
- }
+ if (child !== null) {
+ child.return = node;
+ }
- {
- var _type = Component.type;
- var _innerPropTypes = _type.propTypes;
+ {
+ appendAllChildren(parent, node, true, true);
+ }
+ } else if (node.child !== null) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ } // $FlowFixMe This is correct but Flow is confused by the labeled break.
- if (_innerPropTypes) {
- // Inner memo component props aren't currently validated in createElement.
- // We could move it there, but we'd still need this for lazy code path.
- checkPropTypes(
- _innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(_type)
- );
- }
- }
+ node = node;
- var currentChild = current.child; // This is always exactly one child
+ if (node === workInProgress) {
+ return;
+ }
- 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
+ while (node.sibling === null) {
+ if (node.return === null || node.return === workInProgress) {
+ return;
+ }
- var compare = Component.compare;
- compare = compare !== null ? compare : shallowEqual;
+ node = node.return;
+ }
- if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ node.sibling.return = node.return;
+ node = node.sibling;
}
- } // React DevTools reads this flag.
+ }; // An unfortunate fork of appendAllChildren because we have two different parent types.
- workInProgress.flags |= PerformedWork;
- var newChild = createWorkInProgress(currentChild, nextProps);
- newChild.ref = workInProgress.ref;
- newChild.return = workInProgress;
- workInProgress.child = newChild;
- return newChild;
-}
+ var appendAllChildrenToContainer = function(
+ containerChildSet,
+ workInProgress,
+ needsVisibilityToggle,
+ isHidden
+ ) {
+ // We only have the top Fiber that was created but we need recurse down its
+ // children to find all the terminal nodes.
+ var node = workInProgress.child;
-function updateSimpleMemoComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
-) {
- // TODO: current can be non-null here even if the component
- // hasn't yet mounted. This happens when the inner render suspends.
- // We'll need to figure out if this is fine or can cause issues.
- {
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var outerMemoType = workInProgress.elementType;
+ while (node !== null) {
+ // eslint-disable-next-line no-labels
+ if (node.tag === HostComponent) {
+ var instance = node.stateNode;
- if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
- // 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.
- var lazyComponent = outerMemoType;
- var payload = lazyComponent._payload;
- var init = lazyComponent._init;
+ if (needsVisibilityToggle && isHidden) {
+ // This child is inside a timed out tree. Hide it.
+ var props = node.memoizedProps;
+ var type = node.type;
+ instance = cloneHiddenInstance(instance);
+ }
- try {
- outerMemoType = init(payload);
- } catch (x) {
- outerMemoType = null;
- } // Inner propTypes will be validated in the function component path.
+ appendChildToContainerChildSet(containerChildSet, instance);
+ } else if (node.tag === HostText) {
+ var _instance2 = node.stateNode;
- var outerPropTypes = outerMemoType && outerMemoType.propTypes;
+ if (needsVisibilityToggle && isHidden) {
+ // This child is inside a timed out tree. Hide it.
+ var text = node.memoizedProps;
+ _instance2 = cloneHiddenTextInstance();
+ }
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
- "prop",
- getComponentNameFromType(outerMemoType)
- );
+ appendChildToContainerChildSet(containerChildSet, _instance2);
+ } else if (node.tag === HostPortal);
+ else if (node.tag === OffscreenComponent && node.memoizedState !== null) {
+ // The children in this boundary are hidden. Toggle their visibility
+ // before appending.
+ var child = node.child;
+
+ if (child !== null) {
+ child.return = node;
+ }
+
+ {
+ appendAllChildrenToContainer(containerChildSet, node, true, true);
+ }
+ } else if (node.child !== null) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ } // $FlowFixMe This is correct but Flow is confused by the labeled break.
+
+ node = node;
+
+ if (node === workInProgress) {
+ return;
+ }
+
+ while (node.sibling === null) {
+ if (node.return === null || node.return === workInProgress) {
+ return;
}
+
+ node = node.return;
}
+
+ node.sibling.return = node.return;
+ node = node.sibling;
}
- }
+ };
- if (current !== null) {
- var prevProps = current.memoizedProps;
+ updateHostContainer = function(current, workInProgress) {
+ var portalOrRoot = workInProgress.stateNode;
+ var childrenUnchanged = hadNoMutationsEffects(current, workInProgress);
- if (
- shallowEqual(prevProps, nextProps) &&
- current.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload.
- workInProgress.type === current.type
- ) {
- didReceiveUpdate = false;
+ if (childrenUnchanged);
+ else {
+ var container = portalOrRoot.containerInfo;
+ var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set.
- 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 accumulated 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
- // to account for it here, too. Reset to the value of the current fiber.
- // NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
- // because a MemoComponent fiber does not have hooks or an update queue;
- // rather, it wraps around an inner component, which may or may not
- // contains hooks.
- // TODO: Move the reset at in beginWork out of the common path so that
- // this is no longer necessary.
- workInProgress.lanes = current.lanes;
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
- );
- } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
- // This is a special case that only exists for legacy mode.
- // See https://github.com/facebook/react/pull/19216.
- didReceiveUpdate = true;
- }
+ appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
+ portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container.
+
+ markUpdate(workInProgress);
+ finalizeContainerChildren(container, newChildSet);
}
- }
+ };
- return updateFunctionComponent(
+ updateHostComponent = function(
current,
workInProgress,
- Component,
- nextProps,
- renderLanes
- );
-}
-
-function updateOffscreenComponent(current, workInProgress, renderLanes) {
- var nextProps = workInProgress.pendingProps;
- var nextChildren = nextProps.children;
- var prevState = current !== null ? current.memoizedState : null; // If this is not null, this is a cache pool that was carried over from the
- // previous render. We will push this to the cache pool context so that we can
- // resume in-flight requests.
+ type,
+ newProps,
+ rootContainerInstance
+ ) {
+ var currentInstance = current.stateNode;
+ var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates.
+ // This guarantees that we can reuse all of them.
- var spawnedCachePool = null;
+ var childrenUnchanged = hadNoMutationsEffects(current, workInProgress);
- if (
- nextProps.mode === "hidden" ||
- nextProps.mode === "unstable-defer-without-hiding"
- ) {
- // Rendering a hidden tree.
- if ((workInProgress.mode & ConcurrentMode) === NoMode) {
- // In legacy sync mode, don't defer the subtree. Render it now.
- var nextState = {
- baseLanes: NoLanes,
- cachePool: null
- };
- workInProgress.memoizedState = nextState;
- pushRenderLanes(workInProgress, renderLanes);
- } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
- // We're hidden, and we're not rendering at Offscreen. We will bail out
- // and resume this tree later.
- var nextBaseLanes;
+ if (childrenUnchanged && oldProps === newProps) {
+ // No changes, just reuse the existing instance.
+ // Note that this might release a previous clone.
+ workInProgress.stateNode = currentInstance;
+ return;
+ }
- 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.
+ var recyclableInstance = workInProgress.stateNode;
+ var currentHostContext = getHostContext();
+ var updatePayload = null;
- workInProgress.lanes = workInProgress.childLanes = laneToLanes(
- OffscreenLane
+ if (oldProps !== newProps) {
+ updatePayload = prepareUpdate(
+ recyclableInstance,
+ type,
+ oldProps,
+ newProps
);
- var _nextState = {
- baseLanes: nextBaseLanes,
- cachePool: spawnedCachePool
- };
- workInProgress.memoizedState = _nextState;
- workInProgress.updateQueue = null; // 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);
+ if (childrenUnchanged && updatePayload === null) {
+ // No changes, just reuse the existing instance.
+ // Note that this might release a previous clone.
+ workInProgress.stateNode = currentInstance;
+ return;
+ }
- return null;
- } else {
- var _nextState2 = {
- baseLanes: NoLanes,
- cachePool: null
- };
- workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out.
+ var newInstance = cloneInstance(
+ currentInstance,
+ updatePayload,
+ type,
+ oldProps,
+ newProps,
+ workInProgress,
+ childrenUnchanged
+ );
- var subtreeRenderLanes =
- prevState !== null ? prevState.baseLanes : renderLanes;
- pushRenderLanes(workInProgress, subtreeRenderLanes);
+ workInProgress.stateNode = newInstance;
+
+ if (childrenUnchanged) {
+ // If there are no other effects in this tree, we need to flag this node as having one.
+ // Even though we're not going to use it for anything.
+ // Otherwise parents won't know that there are new children to propagate upwards.
+ markUpdate(workInProgress);
+ } else {
+ // If children might have changed, we have to add them all to the set.
+ appendAllChildren(newInstance, workInProgress, false, false);
}
- } else {
- // Rendering a visible tree.
- var _subtreeRenderLanes;
+ };
- if (prevState !== null) {
- // We're going from hidden -> visible.
- _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes);
+ updateHostText = function(current, workInProgress, oldText, newText) {
+ if (oldText !== newText) {
+ // If the text content differs, we'll create a new text instance for it.
+ var rootContainerInstance = getRootHostContainer();
+ var currentHostContext = getHostContext();
+ workInProgress.stateNode = createTextInstance(
+ newText,
+ rootContainerInstance,
+ currentHostContext,
+ workInProgress
+ ); // We'll have to mark it as having an effect, even though we won't use the effect for anything.
+ // This lets the parents know that at least one of their children has changed.
- workInProgress.memoizedState = null;
+ markUpdate(workInProgress);
} 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;
+ workInProgress.stateNode = current.stateNode;
}
+ };
+}
- 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 cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
+ switch (renderState.tailMode) {
+ case "hidden": {
+ // Any insertions at the end of the tail list after this point
+ // should be invisible. If there are already mounted boundaries
+ // anything before them are not considered for collapsing.
+ // Therefore we need to go through the whole tail to find if
+ // there are any.
+ var tailNode = renderState.tail;
+ var lastTailNode = null;
-function updateFragment(current, workInProgress, renderLanes) {
- var nextChildren = workInProgress.pendingProps;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ while (tailNode !== null) {
+ if (tailNode.alternate !== null) {
+ lastTailNode = tailNode;
+ }
-function updateMode(current, workInProgress, renderLanes) {
- var nextChildren = workInProgress.pendingProps.children;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ tailNode = tailNode.sibling;
+ } // Next we're simply going to delete all insertions after the
+ // last rendered item.
-function updateProfiler(current, workInProgress, renderLanes) {
- {
- workInProgress.flags |= Update;
+ if (lastTailNode === null) {
+ // All remaining items in the tail are insertions.
+ renderState.tail = null;
+ } else {
+ // Detach the insertion after the last node that was already
+ // inserted.
+ lastTailNode.sibling = null;
+ }
- {
- // 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,
- var stateNode = workInProgress.stateNode;
- stateNode.effectDuration = 0;
- stateNode.passiveEffectDuration = 0;
+ break;
}
- }
-
- var nextProps = workInProgress.pendingProps;
- var nextChildren = nextProps.children;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
-function markRef(current, workInProgress) {
- var ref = workInProgress.ref;
+ case "collapsed": {
+ // Any insertions at the end of the tail list after this point
+ // should be invisible. If there are already mounted boundaries
+ // anything before them are not considered for collapsing.
+ // Therefore we need to go through the whole tail to find if
+ // there are any.
+ var _tailNode = renderState.tail;
+ var _lastTailNode = null;
- if (
- (current === null && ref !== null) ||
- (current !== null && current.ref !== ref)
- ) {
- // Schedule a Ref effect
- workInProgress.flags |= Ref;
- }
-}
+ while (_tailNode !== null) {
+ if (_tailNode.alternate !== null) {
+ _lastTailNode = _tailNode;
+ }
-function updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- {
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var innerPropTypes = Component.propTypes;
+ _tailNode = _tailNode.sibling;
+ } // Next we're simply going to delete all insertions after the
+ // last rendered item.
- if (innerPropTypes) {
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(Component)
- );
+ if (_lastTailNode === null) {
+ // All remaining items in the tail are insertions.
+ if (!hasRenderedATailFallback && renderState.tail !== null) {
+ // We suspended during the head. We want to show at least one
+ // row at the tail. So we'll keep on and cut off the rest.
+ renderState.tail.sibling = null;
+ } else {
+ renderState.tail = null;
+ }
+ } else {
+ // Detach the insertion after the last node that was already
+ // inserted.
+ _lastTailNode.sibling = null;
}
- }
- }
-
- var context;
-
- {
- var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
- context = getMaskedContext(workInProgress, unmaskedContext);
- }
-
- var nextChildren;
- prepareToReadContext(workInProgress, renderLanes);
-
- {
- ReactCurrentOwner$1.current = workInProgress;
- setIsRendering(true);
- nextChildren = renderWithHooks(
- current,
- workInProgress,
- Component,
- nextProps,
- context,
- renderLanes
- );
- setIsRendering(false);
+ break;
+ }
}
-
- if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderLanes);
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- } // React DevTools reads this flag.
-
- workInProgress.flags |= PerformedWork;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
}
-function updateClassComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- {
- // This is used by DevTools to force a boundary to error.
- switch (shouldError(workInProgress)) {
- case false: {
- var _instance = workInProgress.stateNode;
- var ctor = workInProgress.type; // TODO This way of resetting the error boundary state is a hack.
- // Is there a better way to do this?
+function bubbleProperties(completedWork) {
+ var didBailout =
+ completedWork.alternate !== null &&
+ completedWork.alternate.child === completedWork.child;
+ var newChildLanes = NoLanes;
+ var subtreeFlags = NoFlags;
- var tempInstance = new ctor(
- workInProgress.memoizedProps,
- _instance.context
- );
- var state = tempInstance.state;
+ if (!didBailout) {
+ // Bubble up the earliest expiration time.
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // In profiling mode, resetChildExpirationTime is also used to reset
+ // profiler durations.
+ var actualDuration = completedWork.actualDuration;
+ var treeBaseDuration = completedWork.selfBaseDuration;
+ var child = completedWork.child;
- _instance.updater.enqueueSetState(_instance, state, null);
+ while (child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(child.lanes, child.childLanes)
+ );
+ subtreeFlags |= child.subtreeFlags;
+ subtreeFlags |= child.flags; // 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.
- break;
+ actualDuration += child.actualDuration;
+ treeBaseDuration += child.treeBaseDuration;
+ child = child.sibling;
}
- case true: {
- workInProgress.flags |= DidCapture;
- workInProgress.flags |= ShouldCapture;
- var error$1 = new Error("Simulated error coming from DevTools");
- var lane = pickArbitraryLane(renderLanes);
- workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state
+ completedWork.actualDuration = actualDuration;
+ completedWork.treeBaseDuration = treeBaseDuration;
+ } else {
+ var _child = completedWork.child;
- var update = createClassErrorUpdate(
- workInProgress,
- createCapturedValue(error$1, workInProgress),
- lane
+ while (_child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child.lanes, _child.childLanes)
);
- enqueueCapturedUpdate(workInProgress, update);
- break;
- }
- }
-
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var innerPropTypes = Component.propTypes;
+ subtreeFlags |= _child.subtreeFlags;
+ subtreeFlags |= _child.flags; // Update the return pointer so the tree is consistent. This is a code
+ // smell because it assumes the commit phase is never concurrent with
+ // the render phase. Will address during refactor to alternate model.
- if (innerPropTypes) {
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(Component)
- );
+ _child.return = completedWork;
+ _child = _child.sibling;
}
}
- } // Push context providers early to prevent context stack mismatches.
- // During mounting we don't know the child context yet as the instance doesn't exist.
- // We will invalidate the child context in finishClassComponent() right after rendering.
-
- var hasContext;
- if (isContextProvider(Component)) {
- hasContext = true;
- pushContextProvider(workInProgress);
+ completedWork.subtreeFlags |= subtreeFlags;
} else {
- hasContext = false;
- }
+ // Bubble up the earliest expiration time.
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // In profiling mode, resetChildExpirationTime is also used to reset
+ // profiler durations.
+ var _treeBaseDuration = completedWork.selfBaseDuration;
+ var _child2 = completedWork.child;
- prepareToReadContext(workInProgress, renderLanes);
- var instance = workInProgress.stateNode;
- var shouldUpdate;
-
- if (instance === null) {
- if (current !== null) {
- // A class component without an instance only mounts if it suspended
- // inside a non-concurrent tree, in an inconsistent state. We want to
- // treat it like a new mount, even though an empty version of it already
- // committed. Disconnect the alternate pointers.
- current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
+ while (_child2 !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child2.lanes, _child2.childLanes)
+ ); // "Static" flags share the lifetime of the fiber/hook they belong to,
+ // so we should bubble those up even during a bailout. All the other
+ // flags have a lifetime only of a single render + commit, so we should
+ // ignore them.
- workInProgress.flags |= Placement;
- } // In the initial pass we might need to construct the instance.
+ subtreeFlags |= _child2.subtreeFlags & StaticMask;
+ subtreeFlags |= _child2.flags & StaticMask;
+ _treeBaseDuration += _child2.treeBaseDuration;
+ _child2 = _child2.sibling;
+ }
- constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(workInProgress, Component, nextProps, renderLanes);
- shouldUpdate = true;
- } else if (current === null) {
- // In a resume, we'll already have an instance we can reuse.
- shouldUpdate = resumeMountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderLanes
- );
- } else {
- shouldUpdate = updateClassInstance(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
- );
- }
+ completedWork.treeBaseDuration = _treeBaseDuration;
+ } else {
+ var _child3 = completedWork.child;
- var nextUnitOfWork = finishClassComponent(
- current,
- workInProgress,
- Component,
- shouldUpdate,
- hasContext,
- renderLanes
- );
+ while (_child3 !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child3.lanes, _child3.childLanes)
+ ); // "Static" flags share the lifetime of the fiber/hook they belong to,
+ // so we should bubble those up even during a bailout. All the other
+ // flags have a lifetime only of a single render + commit, so we should
+ // ignore them.
- {
- var inst = workInProgress.stateNode;
+ subtreeFlags |= _child3.subtreeFlags & StaticMask;
+ subtreeFlags |= _child3.flags & StaticMask; // Update the return pointer so the tree is consistent. This is a code
+ // smell because it assumes the commit phase is never concurrent with
+ // the render phase. Will address during refactor to alternate model.
- if (shouldUpdate && inst.props !== nextProps) {
- if (!didWarnAboutReassigningProps) {
- error(
- "It looks like %s is reassigning its own `this.props` while rendering. " +
- "This is not supported and can lead to confusing bugs.",
- getComponentNameFromFiber(workInProgress) || "a component"
- );
+ _child3.return = completedWork;
+ _child3 = _child3.sibling;
}
-
- didWarnAboutReassigningProps = true;
}
+
+ completedWork.subtreeFlags |= subtreeFlags;
}
- return nextUnitOfWork;
+ completedWork.childLanes = newChildLanes;
+ return didBailout;
}
-function finishClassComponent(
- current,
- workInProgress,
- Component,
- shouldUpdate,
- hasContext,
- renderLanes
-) {
- // Refs should update even if shouldComponentUpdate returns false
- markRef(current, workInProgress);
- var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags;
-
- if (!shouldUpdate && !didCaptureError) {
- // Context providers should defer to sCU for rendering
- if (hasContext) {
- invalidateContextProvider(workInProgress, Component, false);
- }
-
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- }
+function completeWork(current, workInProgress, renderLanes) {
+ var newProps = workInProgress.pendingProps; // Note: This intentionally doesn't check if we're hydrating because comparing
+ // to the current tree provider fiber is just as fast and less error-prone.
+ // Ideally we would have a special version of the work loop only
+ // for hydration.
- var instance = workInProgress.stateNode; // Rerender
+ popTreeContext(workInProgress);
- ReactCurrentOwner$1.current = workInProgress;
- var nextChildren;
+ switch (workInProgress.tag) {
+ case IndeterminateComponent:
+ case LazyComponent:
+ case SimpleMemoComponent:
+ case FunctionComponent:
+ case ForwardRef:
+ case Fragment:
+ case Mode:
+ case Profiler:
+ case ContextConsumer:
+ case MemoComponent:
+ bubbleProperties(workInProgress);
+ return null;
- if (
- didCaptureError &&
- typeof Component.getDerivedStateFromError !== "function"
- ) {
- // If we captured an error, but getDerivedStateFromError is not defined,
- // unmount all the children. componentDidCatch will schedule an update to
- // re-render a fallback. This is temporary until we migrate everyone to
- // the new API.
- // TODO: Warn in a future release.
- nextChildren = null;
+ case ClassComponent: {
+ var Component = workInProgress.type;
- {
- stopProfilerTimerIfRunning();
- }
- } else {
- {
- setIsRendering(true);
- nextChildren = instance.render();
+ if (isContextProvider(Component)) {
+ popContext(workInProgress);
+ }
- setIsRendering(false);
+ bubbleProperties(workInProgress);
+ return null;
}
- } // React DevTools reads this flag.
- workInProgress.flags |= PerformedWork;
+ case HostRoot: {
+ var fiberRoot = workInProgress.stateNode;
- if (current !== null && didCaptureError) {
- // If we're recovering from an error, reconcile without reusing any of
- // the existing children. Conceptually, the normal children and the children
- // that are shown on error are two different sets, so we shouldn't reuse
- // normal children even if their identities match.
- forceUnmountCurrentAndReconcile(
- current,
- workInProgress,
- nextChildren,
- renderLanes
- );
- } else {
- 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.
+ popHostContainer(workInProgress);
+ popTopLevelContextObject(workInProgress);
+ resetWorkInProgressVersions();
- workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
+ if (fiberRoot.pendingContext) {
+ fiberRoot.context = fiberRoot.pendingContext;
+ fiberRoot.pendingContext = null;
+ }
- if (hasContext) {
- invalidateContextProvider(workInProgress, Component, true);
- }
+ if (current === null || current.child === null) {
+ // If we hydrated, pop so that we can delete any remaining children
+ // that weren't hydrated.
+ var wasHydrated = popHydrationState();
- return workInProgress.child;
-}
+ if (wasHydrated) {
+ // If we hydrated, then we'll need to schedule an update for
+ // the commit side-effects on the root.
+ markUpdate(workInProgress);
+ } else {
+ if (current !== null) {
+ var prevState = current.memoizedState;
-function pushHostRootContext(workInProgress) {
- var root = workInProgress.stateNode;
+ if (
+ // Check if this is a client root
+ !prevState.isDehydrated || // Check if we reverted to client rendering (e.g. due to an error)
+ (workInProgress.flags & ForceClientRender) !== NoFlags
+ ) {
+ // 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 container would already
+ // be empty).
+ workInProgress.flags |= Snapshot; // If this was a forced client render, there may have been
+ }
+ }
+ }
+ }
- if (root.pendingContext) {
- pushTopLevelContextObject(
- workInProgress,
- root.pendingContext,
- root.pendingContext !== root.context
- );
- } else if (root.context) {
- // Should always be set
- pushTopLevelContextObject(workInProgress, root.context, false);
- }
+ updateHostContainer(current, workInProgress);
+ bubbleProperties(workInProgress);
+ return null;
+ }
- pushHostContainer(workInProgress, root.containerInfo);
-}
+ case HostComponent: {
+ popHostContext(workInProgress);
+ var rootContainerInstance = getRootHostContainer();
+ var type = workInProgress.type;
-function updateHostRoot(current, workInProgress, renderLanes) {
- pushHostRootContext(workInProgress);
- var updateQueue = workInProgress.updateQueue;
+ if (current !== null && workInProgress.stateNode != null) {
+ updateHostComponent(
+ current,
+ workInProgress,
+ type,
+ newProps,
+ rootContainerInstance
+ );
- if (!(current !== null && updateQueue !== null)) {
- 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."
- );
- }
+ if (current.ref !== workInProgress.ref) {
+ markRef(workInProgress);
+ }
+ } else {
+ if (!newProps) {
+ if (workInProgress.stateNode === null) {
+ throw new Error(
+ "We must have new props for new mounts. This error is likely " +
+ "caused by a bug in React. Please file an issue."
+ );
+ } // This can happen when we abort work.
- var nextProps = workInProgress.pendingProps;
- var prevState = workInProgress.memoizedState;
- var prevChildren = prevState.element;
- cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextProps, null, renderLanes);
- var nextState = workInProgress.memoizedState;
- var root = workInProgress.stateNode;
- // being called "element".
+ bubbleProperties(workInProgress);
+ return null;
+ }
- var nextChildren = nextState.element;
+ var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
+ // "stack" as the parent. Then append children as we go in beginWork
+ // or completeWork depending on whether we want to add them top->down or
+ // bottom->up. Top->down is faster in IE11.
- if (nextChildren === prevChildren) {
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- }
+ var _wasHydrated = popHydrationState();
- if (root.hydrate && enterHydrationState()) {
- var child = mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderLanes
- );
- workInProgress.child = child;
- var node = child;
-
- while (node) {
- // Mark each child as hydrating. This is a fast path to know whether this
- // tree is part of a hydrating tree. This is used to determine if a child
- // node has fully mounted yet, and for scheduling event replaying.
- // Conceptually this is similar to Placement in that a new subtree is
- // inserted into the React tree here. It just happens to not need DOM
- // mutations because it already exists.
- node.flags = (node.flags & ~Placement) | Hydrating;
- node = node.sibling;
+ if (_wasHydrated) {
+ // TODO: Move this and createInstance step into the beginPhase
+ // to consolidate.
+ if (prepareToHydrateHostInstance()) {
+ // If changes to the hydrated node need to be applied at the
+ // commit-phase we mark this as such.
+ markUpdate(workInProgress);
+ }
+ } else {
+ var instance = createInstance(
+ type,
+ newProps,
+ rootContainerInstance,
+ currentHostContext,
+ workInProgress
+ );
+ appendAllChildren(instance, workInProgress, false, false);
+ workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount.
+ }
+
+ if (workInProgress.ref !== null) {
+ // If there is a ref on a host node we need to schedule a callback
+ markRef(workInProgress);
+ }
+ }
+
+ bubbleProperties(workInProgress);
+ return null;
}
- } else {
- // Otherwise reset hydration state in case we aborted and resumed another
- // root.
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- }
- return workInProgress.child;
-}
+ case HostText: {
+ var newText = newProps;
-function updateHostComponent(current, workInProgress, renderLanes) {
- pushHostContext(workInProgress);
+ if (current && workInProgress.stateNode != null) {
+ var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
+ // to schedule a side-effect to do the updates.
- var type = workInProgress.type;
- var nextProps = workInProgress.pendingProps;
- var prevProps = current !== null ? current.memoizedProps : null;
- var nextChildren = nextProps.children;
+ updateHostText(current, workInProgress, oldText, newText);
+ } else {
+ if (typeof newText !== "string") {
+ if (workInProgress.stateNode === null) {
+ throw new Error(
+ "We must have new props for new mounts. This error is likely " +
+ "caused by a bug in React. Please file an issue."
+ );
+ } // This can happen when we abort work.
+ }
- if (prevProps !== null && shouldSetTextContent()) {
- // If we're switching from a direct text child to a normal child, or to
- // empty, we need to schedule the text content to be reset.
- workInProgress.flags |= ContentReset;
- }
+ var _rootContainerInstance = getRootHostContainer();
- markRef(current, workInProgress);
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ var _currentHostContext = getHostContext();
-function updateHostText(current, workInProgress) {
- // immediately after.
+ var _wasHydrated2 = popHydrationState();
- return null;
-}
+ if (_wasHydrated2) {
+ if (prepareToHydrateHostTextInstance()) {
+ markUpdate(workInProgress);
+ }
+ } else {
+ workInProgress.stateNode = createTextInstance(
+ newText,
+ _rootContainerInstance,
+ _currentHostContext,
+ workInProgress
+ );
+ }
+ }
-function mountLazyComponent(
- _current,
- workInProgress,
- elementType,
- updateLanes,
- renderLanes
-) {
- if (_current !== null) {
- // A lazy component only mounts if it suspended inside a non-
- // concurrent tree, in an inconsistent state. We want to treat it like
- // a new mount, even though an empty version of it already committed.
- // Disconnect the alternate pointers.
- _current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
+ bubbleProperties(workInProgress);
+ return null;
+ }
- workInProgress.flags |= Placement;
- }
+ case SuspenseComponent: {
+ popSuspenseContext(workInProgress);
+ var nextState = workInProgress.memoizedState;
- 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.
+ if ((workInProgress.flags & DidCapture) !== NoFlags) {
+ // Something suspended. Re-render with the fallback children.
+ workInProgress.lanes = renderLanes; // Do not reset the effect list.
- workInProgress.type = Component;
- var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component));
- var resolvedProps = resolveDefaultProps(Component, props);
- var child;
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ } // Don't bubble properties in this case.
- switch (resolvedTag) {
- case FunctionComponent: {
- {
- validateFunctionComponentInDev(workInProgress, Component);
- workInProgress.type = Component = resolveFunctionForHotReloading(
- Component
- );
+ return workInProgress;
}
- child = updateFunctionComponent(
- null,
- workInProgress,
- Component,
- resolvedProps,
- renderLanes
- );
- return child;
- }
+ var nextDidTimeout = nextState !== null;
+ var prevDidTimeout = false;
- case ClassComponent: {
- {
- workInProgress.type = Component = resolveClassForHotReloading(
- Component
- );
+ if (current === null);
+ else {
+ var _prevState = current.memoizedState;
+ prevDidTimeout = _prevState !== null;
}
+ // an effect to toggle the subtree's visibility. When we switch from
+ // fallback -> primary, the inner Offscreen fiber schedules this effect
+ // as part of its normal complete phase. But when we switch from
+ // primary -> fallback, the inner Offscreen fiber does not have a complete
+ // phase. So we need to schedule its effect here.
+ //
+ // We also use this flag to connect/disconnect the effects, but the same
+ // logic applies: when re-connecting, the Offscreen fiber's complete
+ // phase will handle scheduling the effect. It's only when the fallback
+ // is active that we have to do anything special.
- child = updateClassComponent(
- null,
- workInProgress,
- Component,
- resolvedProps,
- renderLanes
- );
- return child;
- }
+ if (nextDidTimeout && !prevDidTimeout) {
+ var _offscreenFiber = workInProgress.child;
+ _offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything
+ // in the concurrent tree already suspended during this render.
+ // This is a known bug.
- case ForwardRef: {
- {
- workInProgress.type = Component = resolveForwardRefForHotReloading(
- Component
- );
+ if ((workInProgress.mode & ConcurrentMode) !== NoMode) {
+ // TODO: Move this back to throwException because this is too late
+ // if this is a large tree which is common for initial loads. We
+ // don't know if we should restart a render or not until we get
+ // this marker, and this is too late.
+ // If this render already had a ping or lower pri updates,
+ // and this is the first time we know we're going to suspend we
+ // should be able to immediately restart from within throwException.
+ var hasInvisibleChildContext =
+ current === null &&
+ (workInProgress.memoizedProps.unstable_avoidThisFallback !== true ||
+ !enableSuspenseAvoidThisFallback);
+
+ if (
+ hasInvisibleChildContext ||
+ hasSuspenseContext(
+ suspenseStackCursor.current,
+ InvisibleParentSuspenseContext
+ )
+ ) {
+ // If this was in an invisible tree or a new render, then showing
+ // this boundary is ok.
+ renderDidSuspend();
+ } else {
+ // Otherwise, we're going to have to hide content so we should
+ // suspend for longer if possible.
+ renderDidSuspendDelayIfPossible();
+ }
+ }
}
- child = updateForwardRef(
- null,
- workInProgress,
- Component,
- resolvedProps,
- renderLanes
- );
- return child;
- }
+ var wakeables = workInProgress.updateQueue;
+
+ if (wakeables !== null) {
+ // Schedule an effect to attach a retry listener to the promise.
+ // TODO: Move to passive phase
+ workInProgress.flags |= Update;
+ }
+
+ bubbleProperties(workInProgress);
- case MemoComponent: {
{
- if (workInProgress.type !== workInProgress.elementType) {
- var outerPropTypes = Component.propTypes;
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ if (nextDidTimeout) {
+ // Don't count time spent in a timed out Suspense subtree as part of the base duration.
+ var _primaryChildFragment2 = workInProgress.child;
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- resolvedProps, // Resolved for outer only
- "prop",
- getComponentNameFromType(Component)
- );
+ if (_primaryChildFragment2 !== null) {
+ // $FlowFixMe Flow doesn't support type casting in combination with the -= operator
+ workInProgress.treeBaseDuration -=
+ _primaryChildFragment2.treeBaseDuration;
+ }
}
}
}
- child = updateMemoComponent(
- null,
- workInProgress,
- Component,
- resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
- updateLanes,
- renderLanes
- );
- return child;
+ return null;
}
- }
- var hint = "";
+ case HostPortal:
+ popHostContainer(workInProgress);
+ updateHostContainer(current, workInProgress);
- {
- if (
- Component !== null &&
- typeof Component === "object" &&
- Component.$$typeof === REACT_LAZY_TYPE
- ) {
- hint = " Did you wrap a component in React.lazy() more than once?";
- }
- } // This message intentionally doesn't mention ForwardRef or MemoComponent
- // because the fact that it's a separate type of work is an
- // implementation detail.
+ if (current === null) {
+ preparePortalMount(workInProgress.stateNode.containerInfo);
+ }
- {
- throw Error(
- "Element type is invalid. Received a promise that resolves to: " +
- Component +
- ". Lazy element type must resolve to a class or function." +
- hint
- );
- }
-}
+ bubbleProperties(workInProgress);
+ return null;
-function mountIncompleteClassComponent(
- _current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- if (_current !== null) {
- // An incomplete component only mounts if it suspended inside a non-
- // concurrent tree, in an inconsistent state. We want to treat it like
- // a new mount, even though an empty version of it already committed.
- // Disconnect the alternate pointers.
- _current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
-
- workInProgress.flags |= Placement;
- } // Promote the fiber to a class and try rendering again.
-
- workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
- // Push context providers early to prevent context stack mismatches.
- // During mounting we don't know the child context yet as the instance doesn't exist.
- // We will invalidate the child context in finishClassComponent() right after rendering.
+ case ContextProvider:
+ // Pop provider fiber
+ var context = workInProgress.type._context;
+ popProvider(context, workInProgress);
+ bubbleProperties(workInProgress);
+ return null;
- var hasContext;
+ case IncompleteClassComponent: {
+ // Same as class component case. I put it down here so that the tags are
+ // sequential to ensure this switch is compiled to a jump table.
+ var _Component = workInProgress.type;
- if (isContextProvider(Component)) {
- hasContext = true;
- pushContextProvider(workInProgress);
- } else {
- hasContext = false;
- }
+ if (isContextProvider(_Component)) {
+ popContext(workInProgress);
+ }
- prepareToReadContext(workInProgress, renderLanes);
- constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(workInProgress, Component, nextProps, renderLanes);
- return finishClassComponent(
- null,
- workInProgress,
- Component,
- true,
- hasContext,
- renderLanes
- );
-}
+ bubbleProperties(workInProgress);
+ return null;
+ }
-function mountIndeterminateComponent(
- _current,
- workInProgress,
- Component,
- renderLanes
-) {
- if (_current !== null) {
- // An indeterminate component only mounts if it suspended inside a non-
- // concurrent tree, in an inconsistent state. We want to treat it like
- // a new mount, even though an empty version of it already committed.
- // Disconnect the alternate pointers.
- _current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
+ case SuspenseListComponent: {
+ popSuspenseContext(workInProgress);
+ var renderState = workInProgress.memoizedState;
- workInProgress.flags |= Placement;
- }
+ if (renderState === null) {
+ // We're running in the default, "independent" mode.
+ // We don't do anything in this mode.
+ bubbleProperties(workInProgress);
+ return null;
+ }
- var props = workInProgress.pendingProps;
- var context;
+ var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags;
+ var renderedTail = renderState.rendering;
- {
- var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
- context = getMaskedContext(workInProgress, unmaskedContext);
- }
+ if (renderedTail === null) {
+ // We just rendered the head.
+ if (!didSuspendAlready) {
+ // This is the first pass. We need to figure out if anything is still
+ // suspended in the rendered set.
+ // If new content unsuspended, but there's still some content that
+ // didn't. Then we need to do a second pass that forces everything
+ // to keep showing their fallbacks.
+ // We might be suspended if something in this render pass suspended, or
+ // something in the previous committed pass suspended. Otherwise,
+ // there's no chance so we can skip the expensive call to
+ // findFirstSuspended.
+ var cannotBeSuspended =
+ renderHasNotSuspendedYet() &&
+ (current === null || (current.flags & DidCapture) === NoFlags);
- prepareToReadContext(workInProgress, renderLanes);
- var value;
+ if (!cannotBeSuspended) {
+ var row = workInProgress.child;
- {
- if (
- Component.prototype &&
- typeof Component.prototype.render === "function"
- ) {
- var componentName = getComponentNameFromType(Component) || "Unknown";
+ while (row !== null) {
+ var suspended = findFirstSuspended(row);
- if (!didWarnAboutBadClass[componentName]) {
- error(
- "The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
- "This is likely to cause errors. Change %s to extend React.Component instead.",
- componentName,
- componentName
- );
+ if (suspended !== null) {
+ didSuspendAlready = true;
+ workInProgress.flags |= DidCapture;
+ cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
+ // part of the second pass. In that case nothing will subscribe to
+ // its thenables. Instead, we'll transfer its thenables to the
+ // SuspenseList so that it can retry if they resolve.
+ // There might be multiple of these in the list but since we're
+ // going to wait for all of them anyway, it doesn't really matter
+ // which ones gets to ping. In theory we could get clever and keep
+ // track of how many dependencies remain but it gets tricky because
+ // in the meantime, we can add/remove/change items and dependencies.
+ // We might bail out of the loop before finding any but that
+ // doesn't matter since that means that the other boundaries that
+ // we did find already has their listeners attached.
- didWarnAboutBadClass[componentName] = true;
- }
- }
+ var newThenables = suspended.updateQueue;
- if (workInProgress.mode & StrictLegacyMode) {
- ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
- }
+ if (newThenables !== null) {
+ workInProgress.updateQueue = newThenables;
+ workInProgress.flags |= Update;
+ } // Rerender the whole list, but this time, we'll force fallbacks
+ // to stay in place.
+ // Reset the effect flags before doing the second pass since that's now invalid.
+ // Reset the child fibers to their original state.
- setIsRendering(true);
- ReactCurrentOwner$1.current = workInProgress;
- value = renderWithHooks(
- null,
- workInProgress,
- Component,
- props,
- context,
- renderLanes
- );
- setIsRendering(false);
- } // React DevTools reads this flag.
+ workInProgress.subtreeFlags = NoFlags;
+ resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
+ // rerender the children.
- workInProgress.flags |= PerformedWork;
+ pushSuspenseContext(
+ workInProgress,
+ setShallowSuspenseContext(
+ suspenseStackCursor.current,
+ ForceSuspenseFallback
+ )
+ ); // Don't bubble properties in this case.
- {
- // 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 = getComponentNameFromType(Component) || "Unknown";
+ return workInProgress.child;
+ }
- 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
- );
+ row = row.sibling;
+ }
+ }
- didWarnAboutModulePatternComponent[_componentName] = true;
- }
- }
- }
+ if (renderState.tail !== null && now() > getRenderTargetTime()) {
+ // We have already passed our CPU deadline but we still have rows
+ // left in the tail. We'll just give up further attempts to render
+ // the main content and only render fallbacks.
+ workInProgress.flags |= DidCapture;
+ didSuspendAlready = true;
+ cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
+ // to get it started back up to attempt the next item. While in terms
+ // of priority this work has the same priority as this current render,
+ // it's not part of the same transition once the transition has
+ // committed. If it's sync, we still want to yield so that it can be
+ // painted. Conceptually, this is really the same as pinging.
+ // We can use any RetryLane even if it's the one currently rendering
+ // since we're leaving it behind on this node.
- 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 _componentName2 = getComponentNameFromType(Component) || "Unknown";
+ workInProgress.lanes = SomeRetryLane;
+ }
+ } else {
+ cutOffTailIfNeeded(renderState, false);
+ } // Next we're going to render the tail.
+ } else {
+ // Append the rendered row to the child list.
+ if (!didSuspendAlready) {
+ var _suspended = findFirstSuspended(renderedTail);
- 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.",
- _componentName2,
- _componentName2,
- _componentName2
- );
+ if (_suspended !== null) {
+ workInProgress.flags |= DidCapture;
+ didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't
+ // get lost if this row ends up dropped during a second pass.
- didWarnAboutModulePatternComponent[_componentName2] = true;
- }
- } // Proceed under the assumption that this is a class instance
+ var _newThenables = _suspended.updateQueue;
- workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
+ if (_newThenables !== null) {
+ workInProgress.updateQueue = _newThenables;
+ workInProgress.flags |= Update;
+ }
- workInProgress.memoizedState = null;
- workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches.
- // During mounting we don't know the child context yet as the instance doesn't exist.
- // We will invalidate the child context in finishClassComponent() right after rendering.
+ cutOffTailIfNeeded(renderState, true); // This might have been modified.
- var hasContext = false;
-
- if (isContextProvider(Component)) {
- hasContext = true;
- pushContextProvider(workInProgress);
- } else {
- hasContext = false;
- }
-
- workInProgress.memoizedState =
- value.state !== null && value.state !== undefined ? value.state : null;
- initializeUpdateQueue(workInProgress);
- adoptClassInstance(workInProgress, value);
- mountClassInstance(workInProgress, Component, props, renderLanes);
- return finishClassComponent(
- null,
- workInProgress,
- Component,
- true,
- hasContext,
- renderLanes
- );
- } else {
- // Proceed under the assumption that this is a function component
- workInProgress.tag = FunctionComponent;
-
- reconcileChildren(null, workInProgress, value, renderLanes);
-
- {
- validateFunctionComponentInDev(workInProgress, Component);
- }
-
- return workInProgress.child;
- }
-}
-
-function validateFunctionComponentInDev(workInProgress, Component) {
- {
- if (Component) {
- if (Component.childContextTypes) {
- error(
- "%s(...): childContextTypes cannot be defined on a function component.",
- Component.displayName || Component.name || "Component"
- );
- }
- }
+ if (
+ renderState.tail === null &&
+ renderState.tailMode === "hidden" &&
+ !renderedTail.alternate &&
+ !getIsHydrating() // We don't cut it if we're hydrating.
+ ) {
+ // We're done.
+ bubbleProperties(workInProgress);
+ return null;
+ }
+ } else if (
+ // The time it took to render last row is greater than the remaining
+ // time we have to render. So rendering one more row would likely
+ // exceed it.
+ now() * 2 - renderState.renderingStartTime >
+ getRenderTargetTime() &&
+ 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.
+ // The assumption is that this is usually faster.
+ workInProgress.flags |= DidCapture;
+ didSuspendAlready = true;
+ cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
+ // to get it started back up to attempt the next item. While in terms
+ // of priority this work has the same priority as this current render,
+ // it's not part of the same transition once the transition has
+ // committed. If it's sync, we still want to yield so that it can be
+ // painted. Conceptually, this is really the same as pinging.
+ // We can use any RetryLane even if it's the one currently rendering
+ // since we're leaving it behind on this node.
- if (workInProgress.ref !== null) {
- var info = "";
- var ownerName = getCurrentFiberOwnerNameInDevOrNull();
+ workInProgress.lanes = SomeRetryLane;
+ }
+ }
- if (ownerName) {
- info += "\n\nCheck the render method of `" + ownerName + "`.";
- }
+ if (renderState.isBackwards) {
+ // The effect list of the backwards tail will have been added
+ // to the end. This breaks the guarantee that life-cycles fire in
+ // sibling order but that isn't a strong guarantee promised by React.
+ // Especially since these might also just pop in during future commits.
+ // Append to the beginning of the list.
+ renderedTail.sibling = workInProgress.child;
+ workInProgress.child = renderedTail;
+ } else {
+ var previousSibling = renderState.last;
- var warningKey = ownerName || "";
- var debugSource = workInProgress._debugSource;
+ if (previousSibling !== null) {
+ previousSibling.sibling = renderedTail;
+ } else {
+ workInProgress.child = renderedTail;
+ }
- if (debugSource) {
- warningKey = debugSource.fileName + ":" + debugSource.lineNumber;
+ renderState.last = renderedTail;
+ }
}
- if (!didWarnAboutFunctionRefs[warningKey]) {
- didWarnAboutFunctionRefs[warningKey] = true;
+ if (renderState.tail !== null) {
+ // We still have tail rows to render.
+ // Pop a row.
+ var next = renderState.tail;
+ renderState.rendering = next;
+ renderState.tail = next.sibling;
+ renderState.renderingStartTime = now();
+ next.sibling = null; // Restore the context.
+ // TODO: We can probably just avoid popping it instead and only
+ // setting it the first time we go from not suspended to suspended.
- error(
- "Function components cannot be given refs. " +
- "Attempts to access this ref will fail. " +
- "Did you mean to use React.forwardRef()?%s",
- info
- );
- }
- }
+ var suspenseContext = suspenseStackCursor.current;
- if (typeof Component.getDerivedStateFromProps === "function") {
- var _componentName3 = getComponentNameFromType(Component) || "Unknown";
+ if (didSuspendAlready) {
+ suspenseContext = setShallowSuspenseContext(
+ suspenseContext,
+ ForceSuspenseFallback
+ );
+ } else {
+ suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
+ }
- if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
- error(
- "%s: Function components do not support getDerivedStateFromProps.",
- _componentName3
- );
+ pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
+ // Don't bubble properties in this case.
- didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
+ return next;
}
- }
-
- if (
- typeof Component.contextType === "object" &&
- Component.contextType !== null
- ) {
- var _componentName4 = getComponentNameFromType(Component) || "Unknown";
-
- if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
- error(
- "%s: Function components do not support contextType.",
- _componentName4
- );
- didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
- }
+ bubbleProperties(workInProgress);
+ return null;
}
- }
-}
-
-var SUSPENDED_MARKER = {
- dehydrated: null,
- retryLane: NoLane
-};
-function mountSuspenseOffscreenState(renderLanes) {
- return {
- baseLanes: renderLanes,
- cachePool: getSuspendedCachePool()
- };
-}
-
-function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
- var cachePool = null;
-
- return {
- baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes),
- cachePool: cachePool
- };
-} // TODO: Probably should inline this back
-
-function shouldRemainOnFallback(
- suspenseContext,
- current,
- workInProgress,
- renderLanes
-) {
- // 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;
+ case ScopeComponent: {
+ break;
}
- } // 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.
- {
- if (shouldSuspend(workInProgress)) {
- workInProgress.flags |= DidCapture;
- }
- }
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ popRenderLanes(workInProgress);
+ var _nextState = workInProgress.memoizedState;
+ var nextIsHidden = _nextState !== null;
- var suspenseContext = suspenseStackCursor.current;
- var showFallback = false;
- var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags;
+ if (current !== null) {
+ var _prevState2 = current.memoizedState;
+ var prevIsHidden = _prevState2 !== null;
- if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
- // Something in this boundary's subtree already suspended. Switch to
- // rendering the fallback children.
- showFallback = true;
- workInProgress.flags &= ~DidCapture;
- } else {
- // Attempting the main content
- if (current === null || current.memoizedState !== null) {
- // This is a new mount or this boundary is already showing a fallback state.
- // Mark this subtree context as having at least one invisible parent that could
- // handle the fallback state.
- // Boundaries without fallbacks or should be avoided are not considered since
- // they cannot handle preferred fallback states.
- if (
- nextProps.fallback !== undefined &&
- nextProps.unstable_avoidThisFallback !== true
- ) {
- suspenseContext = addSubtreeSuspenseContext(
- suspenseContext,
- InvisibleParentSuspenseContext
- );
+ if (
+ prevIsHidden !== nextIsHidden && // LegacyHidden doesn't do any hiding — it only pre-renders.
+ !enableLegacyHidden
+ ) {
+ workInProgress.flags |= Visibility;
+ }
}
- }
- }
-
- suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
- 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.
- //
- // 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).
- //
- // 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.
- //
- // 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);
- var nextPrimaryChildren = nextProps.children;
- var nextFallbackChildren = nextProps.fallback;
-
- if (showFallback) {
- var fallbackFragment = mountSuspenseFallbackChildren(
- workInProgress,
- nextPrimaryChildren,
- nextFallbackChildren,
- renderLanes
- );
- var primaryChildFragment = workInProgress.child;
- primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- );
- workInProgress.memoizedState = SUSPENDED_MARKER;
- return fallbackFragment;
- } else if (typeof nextProps.unstable_expectedLoadTime === "number") {
- // This is a CPU-bound tree. Skip this tree and show a placeholder to
- // unblock the surrounding content. Then immediately retry after the
- // initial commit.
- var _fallbackFragment = mountSuspenseFallbackChildren(
- workInProgress,
- nextPrimaryChildren,
- nextFallbackChildren,
- renderLanes
- );
-
- var _primaryChildFragment = workInProgress.child;
- _primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- );
- workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to
- // get it started back up to attempt the next item. While in terms of
- // priority this work has the same priority as this current render, it's
- // not part of the same transition once the transition has committed. If
- // it's sync, we still want to yield so that it can be painted.
- // Conceptually, this is really the same as pinging. We can use any
- // RetryLane even if it's the one currently rendering since we're leaving
- // it behind on this node.
-
- workInProgress.lanes = SomeRetryLane;
- return _fallbackFragment;
- } else {
- return mountSuspensePrimaryChildren(
- workInProgress,
- nextPrimaryChildren,
- renderLanes
- );
- }
- } else {
- // 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) {
- if (showFallback) {
- var _nextFallbackChildren2 = nextProps.fallback;
- var _nextPrimaryChildren2 = nextProps.children;
-
- var _fallbackChildFragment = updateSuspenseFallbackChildren(
- current,
- workInProgress,
- _nextPrimaryChildren2,
- _nextFallbackChildren2,
- renderLanes
- );
-
- var _primaryChildFragment3 = workInProgress.child;
- var prevOffscreenState = current.child.memoizedState;
- _primaryChildFragment3.memoizedState =
- prevOffscreenState === null
- ? mountSuspenseOffscreenState(renderLanes)
- : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
- _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(
- current,
- renderLanes
- );
- workInProgress.memoizedState = SUSPENDED_MARKER;
- return _fallbackChildFragment;
+ if (!nextIsHidden || (workInProgress.mode & ConcurrentMode) === NoMode) {
+ bubbleProperties(workInProgress);
} else {
- var _nextPrimaryChildren3 = nextProps.children;
-
- var _primaryChildFragment4 = updateSuspensePrimaryChildren(
- current,
- workInProgress,
- _nextPrimaryChildren3,
- renderLanes
- );
-
- workInProgress.memoizedState = null;
- return _primaryChildFragment4;
+ // Don't bubble properties for hidden children unless we're rendering
+ // at offscreen priority.
+ if (includesSomeLane(subtreeRenderLanes, OffscreenLane)) {
+ bubbleProperties(workInProgress);
+ }
}
- } else {
- // The current tree is not already showing a fallback.
- if (showFallback) {
- // Timed out.
- var _nextFallbackChildren3 = nextProps.fallback;
- var _nextPrimaryChildren4 = nextProps.children;
- var _fallbackChildFragment2 = updateSuspenseFallbackChildren(
- current,
- workInProgress,
- _nextPrimaryChildren4,
- _nextFallbackChildren3,
- renderLanes
- );
-
- var _primaryChildFragment5 = workInProgress.child;
- var _prevOffscreenState = current.child.memoizedState;
- _primaryChildFragment5.memoizedState =
- _prevOffscreenState === null
- ? mountSuspenseOffscreenState(renderLanes)
- : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
- _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(
- current,
- renderLanes
- ); // Skip the primary children, and continue working on the
- // fallback children.
-
- workInProgress.memoizedState = SUSPENDED_MARKER;
- return _fallbackChildFragment2;
- } else {
- // Still haven't timed out. Continue rendering the children, like we
- // normally do.
- var _nextPrimaryChildren5 = nextProps.children;
+ return null;
+ }
- var _primaryChildFragment6 = updateSuspensePrimaryChildren(
- current,
- workInProgress,
- _nextPrimaryChildren5,
- renderLanes
- );
+ case CacheComponent: {
+ return null;
+ }
- workInProgress.memoizedState = null;
- return _primaryChildFragment6;
- }
+ case TracingMarkerComponent: {
+ return null;
}
}
-}
-function mountSuspensePrimaryChildren(
- workInProgress,
- primaryChildren,
- renderLanes
-) {
- var mode = workInProgress.mode;
- var primaryChildProps = {
- mode: "visible",
- children: primaryChildren
- };
- var primaryChildFragment = createFiberFromOffscreen(
- primaryChildProps,
- mode,
- renderLanes,
- null
+ throw new Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in " +
+ "React. Please file an issue."
);
- primaryChildFragment.return = workInProgress;
- workInProgress.child = primaryChildFragment;
- return primaryChildFragment;
}
-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 & ConcurrentMode) === 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;
- }
+var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
+var didReceiveUpdate = false;
+var didWarnAboutBadClass;
+var didWarnAboutModulePatternComponent;
+var didWarnAboutContextTypeOnFunctionComponent;
+var didWarnAboutGetDerivedStateOnFunctionComponent;
+var didWarnAboutFunctionRefs;
+var didWarnAboutReassigningProps;
+var didWarnAboutRevealOrder;
+var didWarnAboutTailOptions;
- fallbackChildFragment = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
+{
+ didWarnAboutBadClass = {};
+ didWarnAboutModulePatternComponent = {};
+ didWarnAboutContextTypeOnFunctionComponent = {};
+ didWarnAboutGetDerivedStateOnFunctionComponent = {};
+ didWarnAboutFunctionRefs = {};
+ didWarnAboutReassigningProps = false;
+ didWarnAboutRevealOrder = {};
+ didWarnAboutTailOptions = {};
+}
+
+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,
+ // we will add them all to the child before it gets rendered. That means
+ // we can optimize this reconciliation pass by not tracking side-effects.
+ workInProgress.child = mountChildFibers(
+ workInProgress,
+ null,
+ nextChildren,
+ renderLanes
);
} else {
- primaryChildFragment = createFiberFromOffscreen(
- primaryChildProps,
- mode,
- NoLanes,
- null
- );
- fallbackChildFragment = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
+ // If the current child is the same as the work in progress, it means that
+ // we haven't yet started any work on these children. Therefore, we use
+ // the clone algorithm to create a copy of all the current children.
+ // If we had any progressed work already, that is invalid at this point so
+ // let's throw it out.
+ workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ current.child,
+ nextChildren,
+ renderLanes
);
}
-
- primaryChildFragment.return = workInProgress;
- fallbackChildFragment.return = workInProgress;
- primaryChildFragment.sibling = fallbackChildFragment;
- workInProgress.child = primaryChildFragment;
- return fallbackChildFragment;
}
-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);
+function forceUnmountCurrentAndReconcile(
+ current,
+ workInProgress,
+ nextChildren,
+ 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
+ // effect of all current children being unmounted; even if the type and key
+ // are the same, the old child is unmounted and a new child is created.
+ //
+ // To do this, we're going to go through the reconcile algorithm twice. In
+ // the first pass, we schedule a deletion for all the current children by
+ // passing null.
+ workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ current.child,
+ null,
+ 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
+ // identities match.
+
+ workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ null,
+ nextChildren,
+ renderLanes
+ );
}
-function updateSuspensePrimaryChildren(
+function updateForwardRef(
current,
workInProgress,
- primaryChildren,
+ Component,
+ nextProps,
renderLanes
) {
- var currentPrimaryChildFragment = current.child;
- var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
- var primaryChildFragment = createWorkInProgressOffscreenFiber(
- currentPrimaryChildFragment,
- {
- mode: "visible",
- children: primaryChildren
- }
- );
+ // TODO: current can be non-null here even if the component
+ // hasn't yet mounted. This happens after the first render suspends.
+ // We'll need to figure out if this is fine or can cause issues.
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var innerPropTypes = Component.propTypes;
- if ((workInProgress.mode & ConcurrentMode) === NoMode) {
- primaryChildFragment.lanes = renderLanes;
+ if (innerPropTypes) {
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(Component)
+ );
+ }
+ }
}
- primaryChildFragment.return = workInProgress;
- primaryChildFragment.sibling = null;
+ var render = Component.render;
+ var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
- if (currentFallbackChildFragment !== null) {
- // Delete the fallback child fragment
- var deletions = workInProgress.deletions;
+ var nextChildren;
+ prepareToReadContext(workInProgress, renderLanes);
- if (deletions === null) {
- workInProgress.deletions = [currentFallbackChildFragment];
- workInProgress.flags |= ChildDeletion;
- } else {
- deletions.push(currentFallbackChildFragment);
- }
+ {
+ ReactCurrentOwner$1.current = workInProgress;
+ setIsRendering(true);
+ nextChildren = renderWithHooks(
+ current,
+ workInProgress,
+ render,
+ nextProps,
+ ref,
+ renderLanes
+ );
+
+ setIsRendering(false);
}
- workInProgress.child = primaryChildFragment;
- return primaryChildFragment;
+ if (current !== null && !didReceiveUpdate) {
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
+
+ workInProgress.flags |= PerformedWork;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
}
-function updateSuspenseFallbackChildren(
+function updateMemoComponent(
current,
workInProgress,
- primaryChildren,
- fallbackChildren,
+ Component,
+ nextProps,
renderLanes
) {
- var mode = workInProgress.mode;
- var currentPrimaryChildFragment = current.child;
- var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
- var primaryChildProps = {
- mode: "hidden",
- children: primaryChildren
- };
- var primaryChildFragment;
+ if (current === null) {
+ var type = Component.type;
- if (
- // In legacy mode, we commit the primary tree as if it successfully
- // completed, even though it's in an inconsistent state.
- (mode & ConcurrentMode) === 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 (
+ isSimpleFunctionComponent(type) &&
+ Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
+ Component.defaultProps === undefined
+ ) {
+ var resolvedType = type;
- 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 during the first pass.
- // However, since we're going to remain on the fallback, we no longer want
- // to delete it.
+ {
+ resolvedType = resolveFunctionForHotReloading(type);
+ } // If this is a plain function component without default props,
+ // and with only the default shallow comparison, we upgrade it
+ // to a SimpleMemoComponent to allow fast path updates.
+
+ workInProgress.tag = SimpleMemoComponent;
+ workInProgress.type = resolvedType;
+
+ {
+ validateFunctionComponentInDev(workInProgress, type);
+ }
+
+ return updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ resolvedType,
+ nextProps,
+ renderLanes
+ );
+ }
+
+ {
+ var innerPropTypes = type.propTypes;
+
+ if (innerPropTypes) {
+ // Inner memo component props aren't currently validated in createElement.
+ // We could move it there, but we'd still need this for lazy code path.
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(type)
+ );
+ }
+ }
+
+ var child = createFiberFromTypeAndProps(
+ Component.type,
+ null,
+ nextProps,
+ workInProgress,
+ workInProgress.mode,
+ renderLanes
+ );
+ child.ref = workInProgress.ref;
+ child.return = workInProgress;
+ workInProgress.child = child;
+ return child;
+ }
- workInProgress.deletions = null;
- } else {
- primaryChildFragment = createWorkInProgressOffscreenFiber(
- currentPrimaryChildFragment,
- primaryChildProps
- ); // Since we're reusing a current tree, we need to reuse the flags, too.
- // (We don't do this in legacy mode, because in legacy mode we don't re-use
- // the current tree; see previous branch.)
+ {
+ var _type = Component.type;
+ var _innerPropTypes = _type.propTypes;
- primaryChildFragment.subtreeFlags =
- currentPrimaryChildFragment.subtreeFlags & StaticMask;
+ if (_innerPropTypes) {
+ // Inner memo component props aren't currently validated in createElement.
+ // We could move it there, but we'd still need this for lazy code path.
+ checkPropTypes(
+ _innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(_type)
+ );
+ }
}
- var fallbackChildFragment;
-
- 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.
+ var currentChild = current.child; // This is always exactly one child
- fallbackChildFragment.flags |= Placement;
- }
+ var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(
+ current,
+ renderLanes
+ );
- fallbackChildFragment.return = workInProgress;
- primaryChildFragment.return = workInProgress;
- primaryChildFragment.sibling = fallbackChildFragment;
- workInProgress.child = primaryChildFragment;
- return fallbackChildFragment;
-}
+ if (!hasScheduledUpdateOrContext) {
+ // 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
-function scheduleWorkOnFiber(fiber, renderLanes) {
- fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
- var alternate = fiber.alternate;
+ var compare = Component.compare;
+ compare = compare !== null ? compare : shallowEqual;
- if (alternate !== null) {
- alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
- }
+ if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
+ } // React DevTools reads this flag.
- scheduleWorkOnParentPath(fiber.return, renderLanes);
+ workInProgress.flags |= PerformedWork;
+ var newChild = createWorkInProgress(currentChild, nextProps);
+ newChild.ref = workInProgress.ref;
+ newChild.return = workInProgress;
+ workInProgress.child = newChild;
+ return newChild;
}
-function propagateSuspenseContextChange(
+function updateSimpleMemoComponent(
+ current,
workInProgress,
- firstChild,
+ Component,
+ nextProps,
renderLanes
) {
- // Mark any Suspense boundaries with fallbacks as having work to do.
- // If they were previously forced into fallbacks, they may now be able
- // to unblock.
- var node = firstChild;
+ // TODO: current can be non-null here even if the component
+ // hasn't yet mounted. This happens when the inner render suspends.
+ // We'll need to figure out if this is fine or can cause issues.
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var outerMemoType = workInProgress.elementType;
- while (node !== null) {
- if (node.tag === SuspenseComponent) {
- var state = node.memoizedState;
+ if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
+ // 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.
+ var lazyComponent = outerMemoType;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- if (state !== null) {
- scheduleWorkOnFiber(node, renderLanes);
+ 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",
+ getComponentNameFromType(outerMemoType)
+ );
+ }
}
- } else if (node.tag === SuspenseListComponent) {
- // If the tail is hidden there might not be an Suspense boundaries
- // to schedule work on. In this case we have to schedule it on the
- // 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, renderLanes);
- } else if (node.child !== null) {
- node.child.return = node;
- node = node.child;
- continue;
}
+ }
- if (node === workInProgress) {
- return;
- }
+ if (current !== null) {
+ var prevProps = current.memoizedProps;
- while (node.sibling === null) {
- if (node.return === null || node.return === workInProgress) {
- return;
- }
+ if (
+ shallowEqual(prevProps, nextProps) &&
+ current.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload.
+ workInProgress.type === current.type
+ ) {
+ didReceiveUpdate = false;
- node = node.return;
+ if (!checkScheduledUpdateOrContext(current, renderLanes)) {
+ // 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 accumulated 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
+ // to account for it here, too. Reset to the value of the current fiber.
+ // NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
+ // because a MemoComponent fiber does not have hooks or an update queue;
+ // rather, it wraps around an inner component, which may or may not
+ // contains hooks.
+ // TODO: Move the reset at in beginWork out of the common path so that
+ // this is no longer necessary.
+ workInProgress.lanes = current.lanes;
+ return bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
+ // This is a special case that only exists for legacy mode.
+ // See https://github.com/facebook/react/pull/19216.
+ didReceiveUpdate = true;
+ }
}
-
- node.sibling.return = node.return;
- node = node.sibling;
}
+
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
}
-function findLastContentRow(firstChild) {
- // This is going to find the last row among these children that is already
- // showing content on the screen, as opposed to being in fallback state or
- // new. If a row has multiple Suspense boundaries, any of them being in the
- // fallback state, counts as the whole row being in a fallback state.
- // Note that the "rows" will be workInProgress, but any nested children
- // will still be current since we haven't rendered them yet. The mounted
- // order may not be the same as the new order. We use the new order.
- var row = firstChild;
- var lastContentRow = null;
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps;
+ var nextChildren = nextProps.children;
+ var prevState = current !== null ? current.memoizedState : null;
- while (row !== null) {
- var currentRow = row.alternate; // New rows can't be content rows.
+ if (nextProps.mode === "hidden" || enableLegacyHidden) {
+ // Rendering a hidden tree.
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ // In legacy sync mode, don't defer the subtree. Render it now.
+ var nextState = {
+ baseLanes: NoLanes,
+ cachePool: null
+ };
+ workInProgress.memoizedState = nextState;
- if (currentRow !== null && findFirstSuspended(currentRow) === null) {
- lastContentRow = row;
- }
+ pushRenderLanes(workInProgress, renderLanes);
+ } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
+ var spawnedCachePool = null; // We're hidden, and we're not rendering at Offscreen. We will bail out
+ // and resume this tree later.
- row = row.sibling;
- }
+ var nextBaseLanes;
- return lastContentRow;
-}
+ 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.
-function validateRevealOrder(revealOrder) {
- {
- if (
- revealOrder !== undefined &&
- revealOrder !== "forwards" &&
- revealOrder !== "backwards" &&
- revealOrder !== "together" &&
- !didWarnAboutRevealOrder[revealOrder]
- ) {
- didWarnAboutRevealOrder[revealOrder] = true;
+ workInProgress.lanes = workInProgress.childLanes = laneToLanes(
+ OffscreenLane
+ );
+ var _nextState = {
+ baseLanes: nextBaseLanes,
+ cachePool: spawnedCachePool
+ };
+ workInProgress.memoizedState = _nextState;
+ workInProgress.updateQueue = null;
+ // to avoid a push/pop misalignment.
- if (typeof revealOrder === "string") {
- switch (revealOrder.toLowerCase()) {
- case "together":
- case "forwards":
- case "backwards": {
- error(
- '"%s" is not a valid value for revealOrder on . ' +
- 'Use lowercase "%s" instead.',
- revealOrder,
- revealOrder.toLowerCase()
- );
+ pushRenderLanes(workInProgress, nextBaseLanes);
- break;
- }
+ return null;
+ } else {
+ // This is the second render. The surrounding visible content has already
+ // committed. Now we resume rendering the hidden tree.
+ // Rendering at offscreen, so we can clear the base lanes.
+ var _nextState2 = {
+ baseLanes: NoLanes,
+ cachePool: null
+ };
+ workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out.
- case "forward":
- case "backward": {
- error(
- '"%s" is not a valid value for revealOrder on . ' +
- 'React uses the -s suffix in the spelling. Use "%ss" instead.',
- revealOrder,
- revealOrder.toLowerCase()
- );
+ var subtreeRenderLanes =
+ prevState !== null ? prevState.baseLanes : renderLanes;
- break;
- }
+ pushRenderLanes(workInProgress, subtreeRenderLanes);
+ }
+ } else {
+ // Rendering a visible tree.
+ var _subtreeRenderLanes;
- default:
- error(
- '"%s" is not a supported revealOrder on . ' +
- 'Did you mean "together", "forwards" or "backwards"?',
- revealOrder
- );
+ if (prevState !== null) {
+ // We're going from hidden -> visible.
+ _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes);
- break;
- }
- } else {
- error(
- "%s is not a supported value for revealOrder on . " +
- 'Did you mean "together", "forwards" or "backwards"?',
- revealOrder
- );
- }
+ 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);
}
-}
-function validateTailOptions(tailMode, revealOrder) {
{
- if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
- if (tailMode !== "collapsed" && tailMode !== "hidden") {
- didWarnAboutTailOptions[tailMode] = true;
-
- error(
- '"%s" is not a supported value for tail on . ' +
- 'Did you mean "collapsed" or "hidden"?',
- tailMode
- );
- } else if (revealOrder !== "forwards" && revealOrder !== "backwards") {
- didWarnAboutTailOptions[tailMode] = true;
-
- error(
- ' is only valid if revealOrder is ' +
- '"forwards" or "backwards". ' +
- 'Did you mean to specify revealOrder="forwards"?',
- tailMode
- );
- }
- }
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
}
}
-function validateSuspenseListNestedChild(childSlot, index) {
- {
- var isAnArray = isArray(childSlot);
- var isIterable =
- !isAnArray && typeof getIteratorFn(childSlot) === "function";
+function updateFragment(current, workInProgress, renderLanes) {
+ var nextChildren = workInProgress.pendingProps;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
- if (isAnArray || isIterable) {
- var type = isAnArray ? "array" : "iterable";
+function updateMode(current, workInProgress, renderLanes) {
+ var nextChildren = workInProgress.pendingProps.children;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
- error(
- "A nested %s was passed to row #%s in . Wrap it in " +
- "an additional SuspenseList to configure its revealOrder: " +
- " ... " +
- "{%s} ... " +
- "",
- type,
- index,
- type
- );
+function updateProfiler(current, workInProgress, renderLanes) {
+ {
+ workInProgress.flags |= Update;
- return false;
+ {
+ // 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,
+ var stateNode = workInProgress.stateNode;
+ stateNode.effectDuration = 0;
+ stateNode.passiveEffectDuration = 0;
}
}
- return true;
+ var nextProps = workInProgress.pendingProps;
+ var nextChildren = nextProps.children;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
}
-function validateSuspenseListChildren(children, revealOrder) {
- {
- if (
- (revealOrder === "forwards" || revealOrder === "backwards") &&
- children !== undefined &&
- children !== null &&
- children !== false
- ) {
- if (isArray(children)) {
- for (var i = 0; i < children.length; i++) {
- if (!validateSuspenseListNestedChild(children[i], i)) {
- return;
- }
- }
- } else {
- var iteratorFn = getIteratorFn(children);
-
- if (typeof iteratorFn === "function") {
- var childrenIterator = iteratorFn.call(children);
+function markRef$1(current, workInProgress) {
+ var ref = workInProgress.ref;
- if (childrenIterator) {
- var step = childrenIterator.next();
- var _i = 0;
+ if (
+ (current === null && ref !== null) ||
+ (current !== null && current.ref !== ref)
+ ) {
+ // Schedule a Ref effect
+ workInProgress.flags |= Ref;
+ }
+}
- for (; !step.done; step = childrenIterator.next()) {
- if (!validateSuspenseListNestedChild(step.value, _i)) {
- return;
- }
+function updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var innerPropTypes = Component.propTypes;
- _i++;
- }
- }
- } else {
- error(
- 'A single row was passed to a . ' +
- "This is not useful since it needs multiple rows. " +
- "Did you mean to pass multiple children or an array?",
- revealOrder
- );
- }
+ if (innerPropTypes) {
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(Component)
+ );
}
}
}
-}
-function initSuspenseListRenderState(
- workInProgress,
- isBackwards,
- tail,
- lastContentRow,
- tailMode
-) {
- var renderState = workInProgress.memoizedState;
+ var context;
- if (renderState === null) {
- workInProgress.memoizedState = {
- isBackwards: isBackwards,
- rendering: null,
- renderingStartTime: 0,
- last: lastContentRow,
- tail: tail,
- tailMode: tailMode
- };
- } else {
- // We can reuse the existing object from previous renders.
- renderState.isBackwards = isBackwards;
- renderState.rendering = null;
- renderState.renderingStartTime = 0;
- renderState.last = lastContentRow;
- renderState.tail = tail;
- renderState.tailMode = tailMode;
+ {
+ var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
+ context = getMaskedContext(workInProgress, unmaskedContext);
}
-} // This can end up rendering this component multiple passes.
-// The first pass splits the children fibers into two sets. A head and tail.
-// We first render the head. If anything is in fallback state, we do another
-// pass through beginWork to rerender all children (including the tail) with
-// the force suspend context. If the first render didn't have anything in
-// 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, renderLanes) {
- var nextProps = workInProgress.pendingProps;
- var revealOrder = nextProps.revealOrder;
- var tailMode = nextProps.tail;
- var newChildren = nextProps.children;
- validateRevealOrder(revealOrder);
- validateTailOptions(tailMode, revealOrder);
- validateSuspenseListChildren(newChildren, revealOrder);
- reconcileChildren(current, workInProgress, newChildren, renderLanes);
- var suspenseContext = suspenseStackCursor.current;
- var shouldForceFallback = hasSuspenseContext(
- suspenseContext,
- ForceSuspenseFallback
- );
+ var nextChildren;
+ prepareToReadContext(workInProgress, renderLanes);
- if (shouldForceFallback) {
- suspenseContext = setShallowSuspenseContext(
- suspenseContext,
- ForceSuspenseFallback
+ {
+ ReactCurrentOwner$1.current = workInProgress;
+ setIsRendering(true);
+ nextChildren = renderWithHooks(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ context,
+ renderLanes
);
- workInProgress.flags |= DidCapture;
- } else {
- var didSuspendBefore =
- current !== null && (current.flags & DidCapture) !== NoFlags;
-
- if (didSuspendBefore) {
- // If we previously forced a fallback, we need to schedule work
- // on any nested boundaries to let them know to try to render
- // again. This is the same as context updating.
- propagateSuspenseContextChange(
- workInProgress,
- workInProgress.child,
- renderLanes
- );
- }
- suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
+ setIsRendering(false);
}
- pushSuspenseContext(workInProgress, suspenseContext);
+ if (current !== null && !didReceiveUpdate) {
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
- if ((workInProgress.mode & ConcurrentMode) === NoMode) {
- // 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 {
- switch (revealOrder) {
- case "forwards": {
- var lastContentRow = findLastContentRow(workInProgress.child);
- var tail;
+ workInProgress.flags |= PerformedWork;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
- if (lastContentRow === null) {
- // The whole list is part of the tail.
- // TODO: We could fast path by just rendering the tail now.
- tail = workInProgress.child;
- workInProgress.child = null;
- } else {
- // Disconnect the tail rows after the content row.
- // We're going to render them separately later.
- tail = lastContentRow.sibling;
- lastContentRow.sibling = null;
- }
+function updateClassComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ {
+ // This is used by DevTools to force a boundary to error.
+ switch (shouldError(workInProgress)) {
+ case false: {
+ var _instance = workInProgress.stateNode;
+ var ctor = workInProgress.type; // TODO This way of resetting the error boundary state is a hack.
+ // Is there a better way to do this?
- initSuspenseListRenderState(
- workInProgress,
- false, // isBackwards
- tail,
- lastContentRow,
- tailMode
+ var tempInstance = new ctor(
+ workInProgress.memoizedProps,
+ _instance.context
);
- break;
- }
+ var state = tempInstance.state;
- case "backwards": {
- // We're going to find the first row that has existing content.
- // At the same time we're going to reverse the list of everything
- // we pass in the meantime. That's going to be our tail in reverse
- // order.
- var _tail = null;
- var row = workInProgress.child;
- workInProgress.child = null;
+ _instance.updater.enqueueSetState(_instance, state, null);
- while (row !== null) {
- var currentRow = row.alternate; // New rows can't be content rows.
+ break;
+ }
- if (currentRow !== null && findFirstSuspended(currentRow) === null) {
- // This is the beginning of the main content.
- workInProgress.child = row;
- break;
- }
+ case true: {
+ workInProgress.flags |= DidCapture;
+ workInProgress.flags |= ShouldCapture; // eslint-disable-next-line react-internal/prod-error-codes
- var nextRow = row.sibling;
- row.sibling = _tail;
- _tail = row;
- row = nextRow;
- } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
+ var error$1 = new Error("Simulated error coming from DevTools");
+ var lane = pickArbitraryLane(renderLanes);
+ workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state
- initSuspenseListRenderState(
+ var update = createClassErrorUpdate(
workInProgress,
- true, // isBackwards
- _tail,
- null, // last
- tailMode
+ createCapturedValue(error$1, workInProgress),
+ lane
);
+ enqueueCapturedUpdate(workInProgress, update);
break;
}
+ }
- case "together": {
- initSuspenseListRenderState(
- workInProgress,
- false, // isBackwards
- null, // tail
- null, // last
- undefined
- );
- break;
- }
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var innerPropTypes = Component.propTypes;
- default: {
- // The default reveal order is the same as not having
- // a boundary.
- workInProgress.memoizedState = null;
+ if (innerPropTypes) {
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(Component)
+ );
}
}
+ } // Push context providers early to prevent context stack mismatches.
+ // During mounting we don't know the child context yet as the instance doesn't exist.
+ // We will invalidate the child context in finishClassComponent() right after rendering.
+
+ var hasContext;
+
+ if (isContextProvider(Component)) {
+ hasContext = true;
+ pushContextProvider(workInProgress);
+ } else {
+ hasContext = false;
}
- return workInProgress.child;
-}
+ prepareToReadContext(workInProgress, renderLanes);
+ var instance = workInProgress.stateNode;
+ var shouldUpdate;
-function updatePortalComponent(current, workInProgress, renderLanes) {
- pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
- var nextChildren = workInProgress.pendingProps;
+ if (instance === null) {
+ if (current !== null) {
+ // A class component without an instance only mounts if it suspended
+ // inside a non-concurrent tree, in an inconsistent state. We want to
+ // treat it like a new mount, even though an empty version of it already
+ // committed. Disconnect the alternate pointers.
+ current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
- if (current === null) {
- // Portals are special because we don't append the children during mount
- // but at commit. Therefore we need to track insertions which the normal
- // flow doesn't do during mount. This doesn't happen at the root because
- // the root always starts with a "current" with a null child.
- // TODO: Consider unifying this with how the root works.
- workInProgress.child = reconcileChildFibers(
+ workInProgress.flags |= Placement;
+ } // In the initial pass we might need to construct the instance.
+
+ constructClassInstance(workInProgress, Component, nextProps);
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
+ shouldUpdate = true;
+ } else if (current === null) {
+ // In a resume, we'll already have an instance we can reuse.
+ shouldUpdate = resumeMountClassInstance(
workInProgress,
- null,
- nextChildren,
+ Component,
+ nextProps,
renderLanes
);
} else {
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ shouldUpdate = updateClassInstance(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
}
- return workInProgress.child;
-}
-
-var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
-
-function updateContextProvider(current, workInProgress, renderLanes) {
- var providerType = workInProgress.type;
- var context = providerType._context;
- var newProps = workInProgress.pendingProps;
- var oldProps = workInProgress.memoizedProps;
- var newValue = newProps.value;
+ var nextUnitOfWork = finishClassComponent(
+ current,
+ workInProgress,
+ Component,
+ shouldUpdate,
+ hasContext,
+ renderLanes
+ );
{
- if (!("value" in newProps)) {
- if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
- hasWarnedAboutUsingNoValuePropOnContextProvider = true;
+ var inst = workInProgress.stateNode;
+ if (shouldUpdate && inst.props !== nextProps) {
+ if (!didWarnAboutReassigningProps) {
error(
- "The `value` prop is required for the ``. Did you misspell it or forget to pass it?"
+ "It looks like %s is reassigning its own `this.props` while rendering. " +
+ "This is not supported and can lead to confusing bugs.",
+ getComponentNameFromFiber(workInProgress) || "a component"
);
}
+
+ didWarnAboutReassigningProps = true;
}
+ }
- var providerPropTypes = workInProgress.type.propTypes;
+ return nextUnitOfWork;
+}
- if (providerPropTypes) {
- checkPropTypes(providerPropTypes, newProps, "prop", "Context.Provider");
+function finishClassComponent(
+ current,
+ workInProgress,
+ Component,
+ shouldUpdate,
+ hasContext,
+ renderLanes
+) {
+ // Refs should update even if shouldComponentUpdate returns false
+ markRef$1(current, workInProgress);
+ var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags;
+
+ if (!shouldUpdate && !didCaptureError) {
+ // Context providers should defer to sCU for rendering
+ if (hasContext) {
+ invalidateContextProvider(workInProgress, Component, false);
+ }
+
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
+
+ var instance = workInProgress.stateNode; // Rerender
+
+ ReactCurrentOwner$1.current = workInProgress;
+ var nextChildren;
+
+ if (
+ didCaptureError &&
+ typeof Component.getDerivedStateFromError !== "function"
+ ) {
+ // If we captured an error, but getDerivedStateFromError is not defined,
+ // unmount all the children. componentDidCatch will schedule an update to
+ // re-render a fallback. This is temporary until we migrate everyone to
+ // the new API.
+ // TODO: Warn in a future release.
+ nextChildren = null;
+
+ {
+ stopProfilerTimerIfRunning();
+ }
+ } else {
+ {
+ setIsRendering(true);
+ nextChildren = instance.render();
+
+ setIsRendering(false);
}
- }
+ } // React DevTools reads this flag.
- pushProvider(workInProgress, context, newValue);
+ workInProgress.flags |= PerformedWork;
- {
- if (oldProps !== null) {
- var oldValue = oldProps.value;
+ if (current !== null && didCaptureError) {
+ // If we're recovering from an error, reconcile without reusing any of
+ // the existing children. Conceptually, the normal children and the children
+ // that are shown on error are two different sets, so we shouldn't reuse
+ // normal children even if their identities match.
+ forceUnmountCurrentAndReconcile(
+ current,
+ workInProgress,
+ nextChildren,
+ renderLanes
+ );
+ } else {
+ 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.
- if (objectIs(oldValue, newValue)) {
- // No change. Bailout early if children are the same.
- if (oldProps.children === newProps.children && !hasContextChanged()) {
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
- );
- }
- } else {
- // The context value changed. Search for matching consumers and schedule
- // them to update.
- propagateContextChange(workInProgress, context, renderLanes);
- }
- }
+ workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
+
+ if (hasContext) {
+ invalidateContextProvider(workInProgress, Component, true);
}
- var newChildren = newProps.children;
- reconcileChildren(current, workInProgress, newChildren, renderLanes);
return workInProgress.child;
}
-var hasWarnedAboutUsingContextAsConsumer = false;
+function pushHostRootContext(workInProgress) {
+ var root = workInProgress.stateNode;
-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
- // so we use the old behaviour (Context.Consumer references Context) to
- // reduce size and overhead. The separate object references context via
- // a property called "_context", which also gives us the ability to check
- // in DEV mode if this property exists or not and warn if it does not.
+ if (root.pendingContext) {
+ pushTopLevelContextObject(
+ workInProgress,
+ root.pendingContext,
+ root.pendingContext !== root.context
+ );
+ } else if (root.context) {
+ // Should always be set
+ pushTopLevelContextObject(workInProgress, root.context, false);
+ }
- {
- if (context._context === undefined) {
- // This may be because it's a Context (rather than a Consumer).
- // Or it may be because it's older React where they're the same thing.
- // We only want to warn if we're sure it's a new React.
- if (context !== context.Consumer) {
- if (!hasWarnedAboutUsingContextAsConsumer) {
- hasWarnedAboutUsingContextAsConsumer = true;
+ pushHostContainer(workInProgress, root.containerInfo);
+}
- error(
- "Rendering directly is not supported and will be removed in " +
- "a future major release. Did you mean to render instead?"
- );
- }
- }
- } else {
- context = context._context;
- }
+function updateHostRoot(current, workInProgress, renderLanes) {
+ pushHostRootContext(workInProgress);
+
+ if (current === null) {
+ throw new Error("Should have a current fiber. This is a bug in React.");
}
- var newProps = workInProgress.pendingProps;
- var render = newProps.children;
+ var nextProps = workInProgress.pendingProps;
+ var prevState = workInProgress.memoizedState;
+ var prevChildren = prevState.element;
+ cloneUpdateQueue(current, workInProgress);
+ processUpdateQueue(workInProgress, nextProps, null, renderLanes);
+ var nextState = workInProgress.memoizedState;
+ var root = workInProgress.stateNode;
+ // being called "element".
+
+ var nextChildren = nextState.element;
{
- if (typeof render !== "function") {
- error(
- "A context consumer was rendered with multiple children, or a child " +
- "that isn't a function. A context consumer expects a single child " +
- "that is a function. If you did pass a function, make sure there " +
- "is no trailing or leading whitespace around it."
- );
+ if (nextChildren === prevChildren) {
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
- }
-
- prepareToReadContext(workInProgress, renderLanes);
- var newValue = readContext(context);
- var newChildren;
- {
- ReactCurrentOwner$1.current = workInProgress;
- setIsRendering(true);
- newChildren = render(newValue);
- setIsRendering(false);
- } // React DevTools reads this flag.
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ }
- workInProgress.flags |= PerformedWork;
- reconcileChildren(current, workInProgress, newChildren, renderLanes);
return workInProgress.child;
}
-function markWorkInProgressReceivedUpdate() {
- didReceiveUpdate = true;
-}
+function updateHostComponent$1(current, workInProgress, renderLanes) {
+ pushHostContext(workInProgress);
-function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
- if (current !== null) {
- // Reuse previous dependencies
- workInProgress.dependencies = current.dependencies;
- }
+ var type = workInProgress.type;
+ var nextProps = workInProgress.pendingProps;
+ var prevProps = current !== null ? current.memoizedProps : null;
+ var nextChildren = nextProps.children;
- {
- // Don't update "base" render times for bailouts.
- stopProfilerTimerIfRunning();
+ if (prevProps !== null && shouldSetTextContent()) {
+ // If we're switching from a direct text child to a normal child, or to
+ // empty, we need to schedule the text content to be reset.
+ workInProgress.flags |= ContentReset;
}
- markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.
-
- 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.
- {
- return null;
- }
- } // This fiber doesn't have work, but its subtree does. Clone the child
- // fibers and continue.
-
- cloneChildFibers(current, workInProgress);
+ markRef$1(current, workInProgress);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
- {
- var returnFiber = oldWorkInProgress.return;
+function updateHostText$1(current, workInProgress) {
+ // immediately after.
- if (returnFiber === null) {
- throw new Error("Cannot swap the root fiber.");
- } // Disconnect from the old current.
- // It will get deleted.
+ return null;
+}
- current.alternate = null;
- oldWorkInProgress.alternate = null; // Connect to the new tree.
+function mountLazyComponent(
+ _current,
+ workInProgress,
+ elementType,
+ renderLanes
+) {
+ if (_current !== null) {
+ // A lazy component only mounts if it suspended inside a non-
+ // concurrent tree, in an inconsistent state. We want to treat it like
+ // a new mount, even though an empty version of it already committed.
+ // Disconnect the alternate pointers.
+ _current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
- newWorkInProgress.index = oldWorkInProgress.index;
- newWorkInProgress.sibling = oldWorkInProgress.sibling;
- newWorkInProgress.return = oldWorkInProgress.return;
- newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
+ workInProgress.flags |= Placement;
+ }
- if (oldWorkInProgress === returnFiber.child) {
- returnFiber.child = newWorkInProgress;
- } else {
- var prevSibling = returnFiber.child;
+ 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.
- if (prevSibling === null) {
- throw new Error("Expected parent to have a child.");
+ workInProgress.type = Component;
+ var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component));
+ var resolvedProps = resolveDefaultProps(Component, props);
+ var child;
+
+ switch (resolvedTag) {
+ case FunctionComponent: {
+ {
+ validateFunctionComponentInDev(workInProgress, Component);
+ workInProgress.type = Component = resolveFunctionForHotReloading(
+ Component
+ );
}
- while (prevSibling.sibling !== oldWorkInProgress) {
- prevSibling = prevSibling.sibling;
+ child = updateFunctionComponent(
+ null,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ return child;
+ }
- if (prevSibling === null) {
- throw new Error("Expected to find the previous sibling.");
- }
+ case ClassComponent: {
+ {
+ workInProgress.type = Component = resolveClassForHotReloading(
+ Component
+ );
}
- prevSibling.sibling = newWorkInProgress;
- } // Delete the old fiber and place the new one.
- // Since the old fiber is disconnected, we have to schedule it manually.
+ child = updateClassComponent(
+ null,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ return child;
+ }
- var deletions = returnFiber.deletions;
+ case ForwardRef: {
+ {
+ workInProgress.type = Component = resolveForwardRefForHotReloading(
+ Component
+ );
+ }
- if (deletions === null) {
- returnFiber.deletions = [current];
- returnFiber.flags |= ChildDeletion;
- } else {
- deletions.push(current);
+ child = updateForwardRef(
+ null,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ return child;
}
- newWorkInProgress.flags |= Placement; // Restart work from the new fiber.
-
- return newWorkInProgress;
- }
-}
+ case MemoComponent: {
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ var outerPropTypes = Component.propTypes;
-function beginWork(current, workInProgress, renderLanes) {
- var updateLanes = workInProgress.lanes;
+ if (outerPropTypes) {
+ checkPropTypes(
+ outerPropTypes,
+ resolvedProps, // Resolved for outer only
+ "prop",
+ getComponentNameFromType(Component)
+ );
+ }
+ }
+ }
- {
- if (workInProgress._debugNeedsRemount && current !== null) {
- // This will restart the begin phase with a new fiber.
- return remountFiber(
- current,
+ child = updateMemoComponent(
+ null,
workInProgress,
- createFiberFromTypeAndProps(
- workInProgress.type,
- workInProgress.key,
- workInProgress.pendingProps,
- workInProgress._debugOwner || null,
- workInProgress.mode,
- workInProgress.lanes
- )
+ Component,
+ resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
+ renderLanes
);
+ return child;
}
}
- if (current !== null) {
- var oldProps = current.memoizedProps;
- var newProps = workInProgress.pendingProps;
+ var hint = "";
+ {
if (
- oldProps !== newProps ||
- hasContextChanged() || // Force a re-render if the implementation changed due to hot reload:
- workInProgress.type !== current.type
+ Component !== null &&
+ typeof Component === "object" &&
+ Component.$$typeof === REACT_LAZY_TYPE
) {
- // 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 (!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.
+ hint = " Did you wrap a component in React.lazy() more than once?";
+ }
+ } // This message intentionally doesn't mention ForwardRef or MemoComponent
+ // because the fact that it's a separate type of work is an
+ // implementation detail.
- switch (workInProgress.tag) {
- case HostRoot:
- pushHostRootContext(workInProgress);
- break;
+ throw new Error(
+ "Element type is invalid. Received a promise that resolves to: " +
+ Component +
+ ". " +
+ ("Lazy element type must resolve to a class or function." + hint)
+ );
+}
- case HostComponent:
- pushHostContext(workInProgress);
- break;
+function mountIncompleteClassComponent(
+ _current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ if (_current !== null) {
+ // An incomplete component only mounts if it suspended inside a non-
+ // concurrent tree, in an inconsistent state. We want to treat it like
+ // a new mount, even though an empty version of it already committed.
+ // Disconnect the alternate pointers.
+ _current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
- case ClassComponent: {
- var Component = workInProgress.type;
+ workInProgress.flags |= Placement;
+ } // Promote the fiber to a class and try rendering again.
- if (isContextProvider(Component)) {
- pushContextProvider(workInProgress);
- }
+ workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
+ // Push context providers early to prevent context stack mismatches.
+ // During mounting we don't know the child context yet as the instance doesn't exist.
+ // We will invalidate the child context in finishClassComponent() right after rendering.
- break;
- }
+ var hasContext;
- case HostPortal:
- pushHostContainer(
- workInProgress,
- workInProgress.stateNode.containerInfo
- );
- break;
+ if (isContextProvider(Component)) {
+ hasContext = true;
+ pushContextProvider(workInProgress);
+ } else {
+ hasContext = false;
+ }
- case ContextProvider: {
- var newValue = workInProgress.memoizedProps.value;
- var context = workInProgress.type._context;
- pushProvider(workInProgress, context, newValue);
- break;
- }
+ prepareToReadContext(workInProgress, renderLanes);
+ constructClassInstance(workInProgress, Component, nextProps);
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
+ return finishClassComponent(
+ null,
+ workInProgress,
+ Component,
+ true,
+ hasContext,
+ renderLanes
+ );
+}
- case Profiler:
- {
- // Profiler should only call onRender when one of its descendants actually rendered.
- var hasChildWork = includesSomeLane(
- renderLanes,
- workInProgress.childLanes
- );
+function mountIndeterminateComponent(
+ _current,
+ workInProgress,
+ Component,
+ renderLanes
+) {
+ if (_current !== null) {
+ // An indeterminate component only mounts if it suspended inside a non-
+ // concurrent tree, in an inconsistent state. We want to treat it like
+ // a new mount, even though an empty version of it already committed.
+ // Disconnect the alternate pointers.
+ _current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
- if (hasChildWork) {
- workInProgress.flags |= Update;
- }
+ workInProgress.flags |= Placement;
+ }
- {
- // 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,
- var stateNode = workInProgress.stateNode;
- stateNode.effectDuration = 0;
- stateNode.passiveEffectDuration = 0;
- }
- }
+ var props = workInProgress.pendingProps;
+ var context;
- break;
+ {
+ var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
+ context = getMaskedContext(workInProgress, unmaskedContext);
+ }
- case SuspenseComponent: {
- var state = workInProgress.memoizedState;
+ prepareToReadContext(workInProgress, renderLanes);
+ var value;
- if (state !== null) {
- // whether to retry the primary children, or to skip over it and
- // go straight to the fallback. Check the priority of the primary
- // child fragment.
+ {
+ if (
+ Component.prototype &&
+ typeof Component.prototype.render === "function"
+ ) {
+ var componentName = getComponentNameFromType(Component) || "Unknown";
- var primaryChildFragment = workInProgress.child;
- var primaryChildLanes = primaryChildFragment.childLanes;
+ if (!didWarnAboutBadClass[componentName]) {
+ error(
+ "The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
+ "This is likely to cause errors. Change %s to extend React.Component instead.",
+ componentName,
+ componentName
+ );
- 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,
- renderLanes
- );
- } else {
- // The primary child fragment does not have pending work marked
- // on it
- pushSuspenseContext(
- workInProgress,
- setDefaultShallowSuspenseContext(suspenseStackCursor.current)
- ); // The primary children do not have pending work with sufficient
- // priority. Bailout.
-
- var child = bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
- );
+ didWarnAboutBadClass[componentName] = true;
+ }
+ }
- if (child !== null) {
- // The fallback children have pending work. Skip over the
- // primary children and work on the fallback.
- return child.sibling;
- } else {
- // Note: We can return `null` here because we already checked
- // whether there were nested context consumers, via the call to
- // `bailoutOnAlreadyFinishedWork` above.
- return null;
- }
- }
- } else {
- pushSuspenseContext(
- workInProgress,
- setDefaultShallowSuspenseContext(suspenseStackCursor.current)
- );
- }
+ if (workInProgress.mode & StrictLegacyMode) {
+ ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
+ }
- break;
- }
+ setIsRendering(true);
+ ReactCurrentOwner$1.current = workInProgress;
+ value = renderWithHooks(
+ null,
+ workInProgress,
+ Component,
+ props,
+ context,
+ renderLanes
+ );
+ setIsRendering(false);
+ }
- case SuspenseListComponent: {
- var didSuspendBefore = (current.flags & DidCapture) !== NoFlags;
+ workInProgress.flags |= PerformedWork;
- var _hasChildWork = includesSomeLane(
- renderLanes,
- workInProgress.childLanes
- );
+ {
+ // 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 = getComponentNameFromType(Component) || "Unknown";
- if (didSuspendBefore) {
- if (_hasChildWork) {
- // If something was in fallback state last time, and we have all the
- // same children then we're still in progressive loading state.
- // Something might get unblocked by state updates or retries in the
- // tree which will affect the tail. So we need to use the normal
- // path to compute the correct tail.
- return updateSuspenseListComponent(
- current,
- workInProgress,
- 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
- // as before. We can fast bail out.
+ 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
+ );
- workInProgress.flags |= DidCapture;
- } // If nothing suspended before and we're rendering the same children,
- // then the tail doesn't matter. Anything new that suspends will work
- // in the "together" mode, so we can continue from the state we had.
-
- var renderState = workInProgress.memoizedState;
-
- if (renderState !== null) {
- // Reset to the "together" mode in case we've started a different
- // update in the past but didn't complete it.
- renderState.rendering = null;
- renderState.tail = null;
- renderState.lastEffect = null;
- }
+ didWarnAboutModulePatternComponent[_componentName] = true;
+ }
+ }
+ }
- pushSuspenseContext(workInProgress, suspenseStackCursor.current);
+ 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 _componentName2 = getComponentNameFromType(Component) || "Unknown";
- if (_hasChildWork) {
- break;
- } else {
- // 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
- // as before. We can fast bail out.
- return null;
- }
- }
+ 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.",
+ _componentName2,
+ _componentName2,
+ _componentName2
+ );
+
+ didWarnAboutModulePatternComponent[_componentName2] = true;
+ }
+ } // Proceed under the assumption that this is a class instance
+
+ workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
- 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);
- }
- }
+ workInProgress.memoizedState = null;
+ workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches.
+ // During mounting we don't know the child context yet as the instance doesn't exist.
+ // We will invalidate the child context in finishClassComponent() right after rendering.
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ var hasContext = false;
+
+ if (isContextProvider(Component)) {
+ hasContext = true;
+ pushContextProvider(workInProgress);
} else {
- if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
- // 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;
- }
+ hasContext = false;
}
+
+ workInProgress.memoizedState =
+ value.state !== null && value.state !== undefined ? value.state : null;
+ initializeUpdateQueue(workInProgress);
+ adoptClassInstance(workInProgress, value);
+ mountClassInstance(workInProgress, Component, props, renderLanes);
+ return finishClassComponent(
+ null,
+ workInProgress,
+ Component,
+ true,
+ hasContext,
+ renderLanes
+ );
} else {
- didReceiveUpdate = false;
- } // Before entering the begin phase, clear pending update priority.
- // TODO: This assumes that we're about to evaluate the component and process
- // the update queue. However, there's an exception: SimpleMemoComponent
- // 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.
+ // Proceed under the assumption that this is a function component
+ workInProgress.tag = FunctionComponent;
- workInProgress.lanes = NoLanes;
+ reconcileChildren(null, workInProgress, value, renderLanes);
- switch (workInProgress.tag) {
- case IndeterminateComponent: {
- return mountIndeterminateComponent(
- current,
- workInProgress,
- workInProgress.type,
- renderLanes
- );
+ {
+ validateFunctionComponentInDev(workInProgress, Component);
}
- case LazyComponent: {
- var elementType = workInProgress.elementType;
- return mountLazyComponent(
- current,
- workInProgress,
- elementType,
- updateLanes,
- renderLanes
- );
- }
+ return workInProgress.child;
+ }
+}
- case FunctionComponent: {
- var _Component = workInProgress.type;
- var unresolvedProps = workInProgress.pendingProps;
- var resolvedProps =
- workInProgress.elementType === _Component
- ? unresolvedProps
- : resolveDefaultProps(_Component, unresolvedProps);
- return updateFunctionComponent(
- current,
- workInProgress,
- _Component,
- resolvedProps,
- renderLanes
- );
+function validateFunctionComponentInDev(workInProgress, Component) {
+ {
+ if (Component) {
+ if (Component.childContextTypes) {
+ error(
+ "%s(...): childContextTypes cannot be defined on a function component.",
+ Component.displayName || Component.name || "Component"
+ );
+ }
}
- case ClassComponent: {
- var _Component2 = workInProgress.type;
- var _unresolvedProps = workInProgress.pendingProps;
+ if (workInProgress.ref !== null) {
+ var info = "";
+ var ownerName = getCurrentFiberOwnerNameInDevOrNull();
- var _resolvedProps =
- workInProgress.elementType === _Component2
- ? _unresolvedProps
- : resolveDefaultProps(_Component2, _unresolvedProps);
+ if (ownerName) {
+ info += "\n\nCheck the render method of `" + ownerName + "`.";
+ }
- return updateClassComponent(
- current,
- workInProgress,
- _Component2,
- _resolvedProps,
- renderLanes
- );
- }
+ var warningKey = ownerName || "";
+ var debugSource = workInProgress._debugSource;
- case HostRoot:
- return updateHostRoot(current, workInProgress, renderLanes);
+ if (debugSource) {
+ warningKey = debugSource.fileName + ":" + debugSource.lineNumber;
+ }
- case HostComponent:
- return updateHostComponent(current, workInProgress, renderLanes);
+ if (!didWarnAboutFunctionRefs[warningKey]) {
+ didWarnAboutFunctionRefs[warningKey] = true;
- case HostText:
- return updateHostText();
+ error(
+ "Function components cannot be given refs. " +
+ "Attempts to access this ref will fail. " +
+ "Did you mean to use React.forwardRef()?%s",
+ info
+ );
+ }
+ }
- case SuspenseComponent:
- return updateSuspenseComponent(current, workInProgress, renderLanes);
+ if (typeof Component.getDerivedStateFromProps === "function") {
+ var _componentName3 = getComponentNameFromType(Component) || "Unknown";
- case HostPortal:
- return updatePortalComponent(current, workInProgress, renderLanes);
+ if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
+ error(
+ "%s: Function components do not support getDerivedStateFromProps.",
+ _componentName3
+ );
- case ForwardRef: {
- var type = workInProgress.type;
- var _unresolvedProps2 = workInProgress.pendingProps;
+ didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
+ }
+ }
- var _resolvedProps2 =
- workInProgress.elementType === type
- ? _unresolvedProps2
- : resolveDefaultProps(type, _unresolvedProps2);
+ if (
+ typeof Component.contextType === "object" &&
+ Component.contextType !== null
+ ) {
+ var _componentName4 = getComponentNameFromType(Component) || "Unknown";
- return updateForwardRef(
- current,
- workInProgress,
- type,
- _resolvedProps2,
- renderLanes
- );
+ if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
+ error(
+ "%s: Function components do not support contextType.",
+ _componentName4
+ );
+
+ didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
+ }
}
+ }
+}
- case Fragment:
- return updateFragment(current, workInProgress, renderLanes);
+var SUSPENDED_MARKER = {
+ dehydrated: null,
+ treeContext: null,
+ retryLane: NoLane
+};
- case Mode:
- return updateMode(current, workInProgress, renderLanes);
+function mountSuspenseOffscreenState(renderLanes) {
+ return {
+ baseLanes: renderLanes,
+ cachePool: getSuspendedCache()
+ };
+}
- case Profiler:
- return updateProfiler(current, workInProgress, renderLanes);
+function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
+ var cachePool = null;
- case ContextProvider:
- return updateContextProvider(current, workInProgress, renderLanes);
+ return {
+ baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes),
+ cachePool: cachePool
+ };
+} // TODO: Probably should inline this back
- case ContextConsumer:
- return updateContextConsumer(current, workInProgress, renderLanes);
+function shouldRemainOnFallback(
+ suspenseContext,
+ current,
+ workInProgress,
+ renderLanes
+) {
+ // 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;
- case MemoComponent: {
- var _type2 = workInProgress.type;
- var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
+ if (suspenseState === null) {
+ // Currently showing content. Don't hide it, even if ForceSuspenseFallback
+ // 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.
- var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
+ return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
+}
- {
- if (workInProgress.type !== workInProgress.elementType) {
- var outerPropTypes = _type2.propTypes;
+function getRemainingWorkInPrimaryTree(current, renderLanes) {
+ // TODO: Should not remove render lanes that were pinged during this render
+ return removeLanes(current.childLanes, renderLanes);
+}
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- _resolvedProps3, // Resolved for outer only
- "prop",
- getComponentNameFromType(_type2)
- );
- }
- }
- }
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
- _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
- return updateMemoComponent(
- current,
- workInProgress,
- _type2,
- _resolvedProps3,
- updateLanes,
- renderLanes
- );
+ {
+ if (shouldSuspend(workInProgress)) {
+ workInProgress.flags |= DidCapture;
}
+ }
- case SimpleMemoComponent: {
- return updateSimpleMemoComponent(
- current,
- workInProgress,
- workInProgress.type,
- workInProgress.pendingProps,
- updateLanes,
- renderLanes
- );
+ var suspenseContext = suspenseStackCursor.current;
+ var showFallback = false;
+ var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags;
+
+ if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
+ // Something in this boundary's subtree already suspended. Switch to
+ // rendering the fallback children.
+ showFallback = true;
+ workInProgress.flags &= ~DidCapture;
+ } else {
+ // Attempting the main content
+ if (current === null || current.memoizedState !== null) {
+ // This is a new mount or this boundary is already showing a fallback state.
+ // Mark this subtree context as having at least one invisible parent that could
+ // handle the fallback state.
+ // Avoided boundaries are not considered since they cannot handle preferred fallback states.
+ {
+ suspenseContext = addSubtreeSuspenseContext(
+ suspenseContext,
+ InvisibleParentSuspenseContext
+ );
+ }
}
+ }
- case IncompleteClassComponent: {
- var _Component3 = workInProgress.type;
- var _unresolvedProps4 = workInProgress.pendingProps;
+ suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
+ pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense
+ // boundary's children. This involves some custom reconciliation logic. Two
+ // main reasons this is so complicated.
+ //
+ // 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).
+ //
+ // 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.
+ //
+ // 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.
- var _resolvedProps4 =
- workInProgress.elementType === _Component3
- ? _unresolvedProps4
- : resolveDefaultProps(_Component3, _unresolvedProps4);
+ if (current === null) {
+ var nextPrimaryChildren = nextProps.children;
+ var nextFallbackChildren = nextProps.fallback;
- return mountIncompleteClassComponent(
- current,
+ if (showFallback) {
+ var fallbackFragment = mountSuspenseFallbackChildren(
workInProgress,
- _Component3,
- _resolvedProps4,
+ nextPrimaryChildren,
+ nextFallbackChildren,
renderLanes
);
+ var primaryChildFragment = workInProgress.child;
+ primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
+ renderLanes
+ );
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return fallbackFragment;
+ } else {
+ return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren);
}
+ } else {
+ // This is an update.
+ // If the current fiber has a SuspenseState, that means it's already showing
+ // a fallback.
+ var prevState = current.memoizedState;
- case SuspenseListComponent: {
- return updateSuspenseListComponent(current, workInProgress, renderLanes);
- }
-
- case ScopeComponent: {
- break;
- }
-
- case OffscreenComponent: {
- return updateOffscreenComponent(current, workInProgress, renderLanes);
- }
+ if (prevState !== null) {
+ if (showFallback) {
+ var _nextFallbackChildren2 = nextProps.fallback;
+ var _nextPrimaryChildren2 = nextProps.children;
- case LegacyHiddenComponent: {
- return updateLegacyHiddenComponent(current, workInProgress, renderLanes);
- }
- }
+ var _fallbackChildFragment = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren2,
+ _nextFallbackChildren2,
+ renderLanes
+ );
- {
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
- }
-}
+ var _primaryChildFragment3 = workInProgress.child;
+ var prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment3.memoizedState =
+ prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
+ _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ );
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return _fallbackChildFragment;
+ } else {
+ var _nextPrimaryChildren3 = nextProps.children;
-function markUpdate(workInProgress) {
- // Tag the fiber with an update effect. This turns a Placement into
- // a PlacementAndUpdate.
- workInProgress.flags |= Update;
-}
+ var _primaryChildFragment4 = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren3,
+ renderLanes
+ );
-function markRef$1(workInProgress) {
- workInProgress.flags |= Ref;
-}
+ workInProgress.memoizedState = null;
+ return _primaryChildFragment4;
+ }
+ } else {
+ // The current tree is not already showing a fallback.
+ if (showFallback) {
+ // Timed out.
+ var _nextFallbackChildren3 = nextProps.fallback;
+ var _nextPrimaryChildren4 = nextProps.children;
-function hadNoMutationsEffects(current, completedWork) {
- var didBailout = current !== null && current.child === completedWork.child;
+ var _fallbackChildFragment2 = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren4,
+ _nextFallbackChildren3,
+ renderLanes
+ );
- if (didBailout) {
- return true;
- }
+ var _primaryChildFragment5 = workInProgress.child;
+ var _prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment5.memoizedState =
+ _prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
+ _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ ); // Skip the primary children, and continue working on the
+ // fallback children.
- if ((completedWork.flags & ChildDeletion) !== NoFlags) {
- return false;
- } // TODO: If we move the `hadNoMutationsEffects` call after `bubbleProperties`
- // then we only have to check the `completedWork.subtreeFlags`.
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return _fallbackChildFragment2;
+ } else {
+ // Still haven't timed out. Continue rendering the children, like we
+ // normally do.
+ var _nextPrimaryChildren5 = nextProps.children;
- var child = completedWork.child;
+ var _primaryChildFragment6 = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren5,
+ renderLanes
+ );
- while (child !== null) {
- if (
- (child.flags & MutationMask) !== NoFlags ||
- (child.subtreeFlags & MutationMask) !== NoFlags
- ) {
- return false;
+ workInProgress.memoizedState = null;
+ return _primaryChildFragment6;
+ }
}
-
- child = child.sibling;
}
+}
- return true;
+function mountSuspensePrimaryChildren(
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var primaryChildProps = {
+ mode: "visible",
+ children: primaryChildren
+ };
+ var primaryChildFragment = mountWorkInProgressOffscreenFiber(
+ primaryChildProps,
+ mode
+ );
+ primaryChildFragment.return = workInProgress;
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
}
-var appendAllChildren;
-var updateHostContainer;
-var updateHostComponent$1;
-var updateHostText$1;
+function mountSuspenseFallbackChildren(
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var progressedPrimaryFragment = workInProgress.child;
+ var primaryChildProps = {
+ mode: "hidden",
+ children: primaryChildren
+ };
+ var primaryChildFragment;
+ var fallbackChildFragment;
-{
- // Persistent host tree mode
- appendAllChildren = function(
- parent,
- workInProgress,
- needsVisibilityToggle,
- isHidden
+ if (
+ (mode & ConcurrentMode) === NoMode &&
+ progressedPrimaryFragment !== null
) {
- // We only have the top Fiber that was created but we need recurse down its
- // children to find all the terminal nodes.
- var node = workInProgress.child;
+ // 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;
+ }
- while (node !== null) {
- // eslint-disable-next-line no-labels
- if (node.tag === HostComponent) {
- var instance = node.stateNode;
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ } else {
+ primaryChildFragment = mountWorkInProgressOffscreenFiber(
+ primaryChildProps,
+ mode
+ );
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ }
- if (needsVisibilityToggle && isHidden) {
- // This child is inside a timed out tree. Hide it.
- var props = node.memoizedProps;
- var type = node.type;
- instance = cloneHiddenInstance(instance);
- }
+ primaryChildFragment.return = workInProgress;
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
+}
- appendInitialChild(parent, instance);
- } else if (node.tag === HostText) {
- var _instance = node.stateNode;
+function mountWorkInProgressOffscreenFiber(offscreenProps, mode, renderLanes) {
+ // The props argument to `createFiberFromOffscreen` is `any` typed, so we use
+ // this wrapper function to constrain it.
+ return createFiberFromOffscreen(offscreenProps, mode, NoLanes, null);
+}
- if (needsVisibilityToggle && isHidden) {
- // This child is inside a timed out tree. Hide it.
- var text = node.memoizedProps;
- _instance = cloneHiddenTextInstance();
- }
+function updateWorkInProgressOffscreenFiber(current, offscreenProps) {
+ // The props argument to `createWorkInProgress` is `any` typed, so we use this
+ // wrapper function to constrain it.
+ return createWorkInProgress(current, offscreenProps);
+}
- appendInitialChild(parent, _instance);
- } else if (node.tag === HostPortal);
- else if (node.tag === SuspenseComponent) {
- if ((node.flags & Update) !== NoFlags) {
- // Need to toggle the visibility of the primary children.
- var newIsHidden = node.memoizedState !== null;
-
- if (newIsHidden) {
- var primaryChildParent = node.child;
-
- if (primaryChildParent !== null) {
- if (primaryChildParent.child !== null) {
- primaryChildParent.child.return = primaryChildParent;
- appendAllChildren(
- parent,
- primaryChildParent,
- true,
- newIsHidden
- );
- }
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
+ var primaryChildFragment = updateWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
+ {
+ mode: "visible",
+ children: primaryChildren
+ }
+ );
- var fallbackChildParent = primaryChildParent.sibling;
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ primaryChildFragment.lanes = renderLanes;
+ }
- if (fallbackChildParent !== null) {
- fallbackChildParent.return = node;
- node = fallbackChildParent;
- continue;
- }
- }
- }
- }
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = null;
- if (node.child !== null) {
- // Continue traversing like normal
- node.child.return = node;
- node = node.child;
- continue;
- }
- } else if (node.child !== null) {
- node.child.return = node;
- node = node.child;
- continue;
- } // $FlowFixMe This is correct but Flow is confused by the labeled break.
+ if (currentFallbackChildFragment !== null) {
+ // Delete the fallback child fragment
+ var deletions = workInProgress.deletions;
- node = node;
+ if (deletions === null) {
+ workInProgress.deletions = [currentFallbackChildFragment];
+ workInProgress.flags |= ChildDeletion;
+ } else {
+ deletions.push(currentFallbackChildFragment);
+ }
+ }
- if (node === workInProgress) {
- return;
- }
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
+}
- while (node.sibling === null) {
- if (node.return === null || node.return === workInProgress) {
- return;
- }
+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;
- node = node.return;
- }
+ if (
+ // In legacy mode, we commit the primary tree as if it successfully
+ // completed, even though it's in an inconsistent state.
+ (mode & ConcurrentMode) === 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;
- node.sibling.return = node.return;
- node = node.sibling;
+ 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;
}
- }; // An unfortunate fork of appendAllChildren because we have two different parent types.
+ // However, since we're going to remain on the fallback, we no longer want
+ // to delete it.
- var appendAllChildrenToContainer = function(
- containerChildSet,
- workInProgress,
- needsVisibilityToggle,
- isHidden
- ) {
- // We only have the top Fiber that was created but we need recurse down its
- // children to find all the terminal nodes.
- var node = workInProgress.child;
+ workInProgress.deletions = null;
+ } else {
+ primaryChildFragment = updateWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ );
+ // (We don't do this in legacy mode, because in legacy mode we don't re-use
+ // the current tree; see previous branch.)
- while (node !== null) {
- // eslint-disable-next-line no-labels
- if (node.tag === HostComponent) {
- var instance = node.stateNode;
+ primaryChildFragment.subtreeFlags =
+ currentPrimaryChildFragment.subtreeFlags & StaticMask;
+ }
- if (needsVisibilityToggle && isHidden) {
- // This child is inside a timed out tree. Hide it.
- var props = node.memoizedProps;
- var type = node.type;
- instance = cloneHiddenInstance(instance);
- }
+ var fallbackChildFragment;
- appendChildToContainerChildSet(containerChildSet, instance);
- } else if (node.tag === HostText) {
- var _instance2 = node.stateNode;
+ 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.
- if (needsVisibilityToggle && isHidden) {
- // This child is inside a timed out tree. Hide it.
- var text = node.memoizedProps;
- _instance2 = cloneHiddenTextInstance();
- }
+ fallbackChildFragment.flags |= Placement;
+ }
- appendChildToContainerChildSet(containerChildSet, _instance2);
- } else if (node.tag === HostPortal);
- else if (node.tag === SuspenseComponent) {
- if ((node.flags & Update) !== NoFlags) {
- // Need to toggle the visibility of the primary children.
- var newIsHidden = node.memoizedState !== null;
-
- if (newIsHidden) {
- var primaryChildParent = node.child;
-
- if (primaryChildParent !== null) {
- if (primaryChildParent.child !== null) {
- primaryChildParent.child.return = primaryChildParent;
- appendAllChildrenToContainer(
- containerChildSet,
- primaryChildParent,
- true,
- newIsHidden
- );
- }
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
+}
- var fallbackChildParent = primaryChildParent.sibling;
+function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) {
+ fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
+ var alternate = fiber.alternate;
- if (fallbackChildParent !== null) {
- fallbackChildParent.return = node;
- node = fallbackChildParent;
- continue;
- }
- }
- }
- }
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
+ }
- if (node.child !== null) {
- // Continue traversing like normal
- node.child.return = node;
- node = node.child;
- continue;
- }
- } else if (node.child !== null) {
- node.child.return = node;
- node = node.child;
- continue;
- } // $FlowFixMe This is correct but Flow is confused by the labeled break.
+ scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot);
+}
- node = node;
+function propagateSuspenseContextChange(
+ workInProgress,
+ firstChild,
+ renderLanes
+) {
+ // Mark any Suspense boundaries with fallbacks as having work to do.
+ // If they were previously forced into fallbacks, they may now be able
+ // to unblock.
+ var node = firstChild;
- if (node === workInProgress) {
- return;
+ while (node !== null) {
+ if (node.tag === SuspenseComponent) {
+ var state = node.memoizedState;
+
+ if (state !== null) {
+ scheduleSuspenseWorkOnFiber(node, renderLanes, workInProgress);
}
+ } else if (node.tag === SuspenseListComponent) {
+ // If the tail is hidden there might not be an Suspense boundaries
+ // to schedule work on. In this case we have to schedule it on the
+ // list itself.
+ // We don't have to traverse to the children of the list since
+ // the list will propagate the change when it rerenders.
+ scheduleSuspenseWorkOnFiber(node, renderLanes, workInProgress);
+ } else if (node.child !== null) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
- while (node.sibling === null) {
- if (node.return === null || node.return === workInProgress) {
- return;
- }
+ if (node === workInProgress) {
+ return;
+ }
- node = node.return;
+ while (node.sibling === null) {
+ if (node.return === null || node.return === workInProgress) {
+ return;
}
- node.sibling.return = node.return;
- node = node.sibling;
+ node = node.return;
}
- };
- updateHostContainer = function(current, workInProgress) {
- var portalOrRoot = workInProgress.stateNode;
- var childrenUnchanged = hadNoMutationsEffects(current, workInProgress);
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+}
- if (childrenUnchanged);
- else {
- var container = portalOrRoot.containerInfo;
- var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set.
+function findLastContentRow(firstChild) {
+ // This is going to find the last row among these children that is already
+ // showing content on the screen, as opposed to being in fallback state or
+ // new. If a row has multiple Suspense boundaries, any of them being in the
+ // fallback state, counts as the whole row being in a fallback state.
+ // Note that the "rows" will be workInProgress, but any nested children
+ // will still be current since we haven't rendered them yet. The mounted
+ // order may not be the same as the new order. We use the new order.
+ var row = firstChild;
+ var lastContentRow = null;
- appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
- portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container.
+ while (row !== null) {
+ var currentRow = row.alternate; // New rows can't be content rows.
- markUpdate(workInProgress);
- finalizeContainerChildren(container, newChildSet);
+ if (currentRow !== null && findFirstSuspended(currentRow) === null) {
+ lastContentRow = row;
}
- };
- updateHostComponent$1 = function(
- current,
- workInProgress,
- type,
- newProps,
- rootContainerInstance
- ) {
- var currentInstance = current.stateNode;
- var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates.
- // This guarantees that we can reuse all of them.
+ row = row.sibling;
+ }
- var childrenUnchanged = hadNoMutationsEffects(current, workInProgress);
+ return lastContentRow;
+}
- if (childrenUnchanged && oldProps === newProps) {
- // No changes, just reuse the existing instance.
- // Note that this might release a previous clone.
- workInProgress.stateNode = currentInstance;
- return;
- }
+function validateRevealOrder(revealOrder) {
+ {
+ if (
+ revealOrder !== undefined &&
+ revealOrder !== "forwards" &&
+ revealOrder !== "backwards" &&
+ revealOrder !== "together" &&
+ !didWarnAboutRevealOrder[revealOrder]
+ ) {
+ didWarnAboutRevealOrder[revealOrder] = true;
- var recyclableInstance = workInProgress.stateNode;
- var currentHostContext = getHostContext();
- var updatePayload = null;
+ if (typeof revealOrder === "string") {
+ switch (revealOrder.toLowerCase()) {
+ case "together":
+ case "forwards":
+ case "backwards": {
+ error(
+ '"%s" is not a valid value for revealOrder on . ' +
+ 'Use lowercase "%s" instead.',
+ revealOrder,
+ revealOrder.toLowerCase()
+ );
- if (oldProps !== newProps) {
- updatePayload = prepareUpdate(
- recyclableInstance,
- type,
- oldProps,
- newProps
- );
- }
+ break;
+ }
- if (childrenUnchanged && updatePayload === null) {
- // No changes, just reuse the existing instance.
- // Note that this might release a previous clone.
- workInProgress.stateNode = currentInstance;
- return;
- }
+ case "forward":
+ case "backward": {
+ error(
+ '"%s" is not a valid value for revealOrder on . ' +
+ 'React uses the -s suffix in the spelling. Use "%ss" instead.',
+ revealOrder,
+ revealOrder.toLowerCase()
+ );
- var newInstance = cloneInstance(
- currentInstance,
- updatePayload,
- type,
- oldProps,
- newProps,
- workInProgress,
- childrenUnchanged
- );
+ break;
+ }
- workInProgress.stateNode = newInstance;
+ default:
+ error(
+ '"%s" is not a supported revealOrder on . ' +
+ 'Did you mean "together", "forwards" or "backwards"?',
+ revealOrder
+ );
- if (childrenUnchanged) {
- // If there are no other effects in this tree, we need to flag this node as having one.
- // Even though we're not going to use it for anything.
- // Otherwise parents won't know that there are new children to propagate upwards.
- markUpdate(workInProgress);
- } else {
- // If children might have changed, we have to add them all to the set.
- appendAllChildren(newInstance, workInProgress, false, false);
+ break;
+ }
+ } else {
+ error(
+ "%s is not a supported value for revealOrder on . " +
+ 'Did you mean "together", "forwards" or "backwards"?',
+ revealOrder
+ );
+ }
}
- };
+ }
+}
- updateHostText$1 = function(current, workInProgress, oldText, newText) {
- if (oldText !== newText) {
- // If the text content differs, we'll create a new text instance for it.
- var rootContainerInstance = getRootHostContainer();
- var currentHostContext = getHostContext();
- workInProgress.stateNode = createTextInstance(
- newText,
- rootContainerInstance,
- currentHostContext,
- workInProgress
- ); // We'll have to mark it as having an effect, even though we won't use the effect for anything.
- // This lets the parents know that at least one of their children has changed.
+function validateTailOptions(tailMode, revealOrder) {
+ {
+ if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
+ if (tailMode !== "collapsed" && tailMode !== "hidden") {
+ didWarnAboutTailOptions[tailMode] = true;
- markUpdate(workInProgress);
- } else {
- workInProgress.stateNode = current.stateNode;
+ error(
+ '"%s" is not a supported value for tail on . ' +
+ 'Did you mean "collapsed" or "hidden"?',
+ tailMode
+ );
+ } else if (revealOrder !== "forwards" && revealOrder !== "backwards") {
+ didWarnAboutTailOptions[tailMode] = true;
+
+ error(
+ ' is only valid if revealOrder is ' +
+ '"forwards" or "backwards". ' +
+ 'Did you mean to specify revealOrder="forwards"?',
+ tailMode
+ );
+ }
}
- };
+ }
}
-function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
- switch (renderState.tailMode) {
- case "hidden": {
- // Any insertions at the end of the tail list after this point
- // should be invisible. If there are already mounted boundaries
- // anything before them are not considered for collapsing.
- // Therefore we need to go through the whole tail to find if
- // there are any.
- var tailNode = renderState.tail;
- var lastTailNode = null;
-
- while (tailNode !== null) {
- if (tailNode.alternate !== null) {
- lastTailNode = tailNode;
- }
+function validateSuspenseListNestedChild(childSlot, index) {
+ {
+ var isAnArray = isArray(childSlot);
+ var isIterable =
+ !isAnArray && typeof getIteratorFn(childSlot) === "function";
- tailNode = tailNode.sibling;
- } // Next we're simply going to delete all insertions after the
- // last rendered item.
+ if (isAnArray || isIterable) {
+ var type = isAnArray ? "array" : "iterable";
- if (lastTailNode === null) {
- // All remaining items in the tail are insertions.
- renderState.tail = null;
- } else {
- // Detach the insertion after the last node that was already
- // inserted.
- lastTailNode.sibling = null;
- }
+ error(
+ "A nested %s was passed to row #%s in . Wrap it in " +
+ "an additional SuspenseList to configure its revealOrder: " +
+ " ... " +
+ "{%s} ... " +
+ "",
+ type,
+ index,
+ type
+ );
- break;
+ return false;
}
+ }
- case "collapsed": {
- // Any insertions at the end of the tail list after this point
- // should be invisible. If there are already mounted boundaries
- // anything before them are not considered for collapsing.
- // Therefore we need to go through the whole tail to find if
- // there are any.
- var _tailNode = renderState.tail;
- var _lastTailNode = null;
+ return true;
+}
- while (_tailNode !== null) {
- if (_tailNode.alternate !== null) {
- _lastTailNode = _tailNode;
+function validateSuspenseListChildren(children, revealOrder) {
+ {
+ if (
+ (revealOrder === "forwards" || revealOrder === "backwards") &&
+ children !== undefined &&
+ children !== null &&
+ children !== false
+ ) {
+ if (isArray(children)) {
+ for (var i = 0; i < children.length; i++) {
+ if (!validateSuspenseListNestedChild(children[i], i)) {
+ return;
+ }
}
+ } else {
+ var iteratorFn = getIteratorFn(children);
- _tailNode = _tailNode.sibling;
- } // Next we're simply going to delete all insertions after the
- // last rendered item.
+ if (typeof iteratorFn === "function") {
+ var childrenIterator = iteratorFn.call(children);
- if (_lastTailNode === null) {
- // All remaining items in the tail are insertions.
- if (!hasRenderedATailFallback && renderState.tail !== null) {
- // We suspended during the head. We want to show at least one
- // row at the tail. So we'll keep on and cut off the rest.
- renderState.tail.sibling = null;
+ if (childrenIterator) {
+ var step = childrenIterator.next();
+ var _i = 0;
+
+ for (; !step.done; step = childrenIterator.next()) {
+ if (!validateSuspenseListNestedChild(step.value, _i)) {
+ return;
+ }
+
+ _i++;
+ }
+ }
} else {
- renderState.tail = null;
+ error(
+ 'A single row was passed to a . ' +
+ "This is not useful since it needs multiple rows. " +
+ "Did you mean to pass multiple children or an array?",
+ revealOrder
+ );
}
- } else {
- // Detach the insertion after the last node that was already
- // inserted.
- _lastTailNode.sibling = null;
}
-
- break;
}
}
}
-function bubbleProperties(completedWork) {
- var didBailout =
- completedWork.alternate !== null &&
- completedWork.alternate.child === completedWork.child;
- var newChildLanes = NoLanes;
- var subtreeFlags = NoFlags;
+function initSuspenseListRenderState(
+ workInProgress,
+ isBackwards,
+ tail,
+ lastContentRow,
+ tailMode
+) {
+ var renderState = workInProgress.memoizedState;
- if (!didBailout) {
- // Bubble up the earliest expiration time.
- if ((completedWork.mode & ProfileMode) !== NoMode) {
- // In profiling mode, resetChildExpirationTime is also used to reset
- // profiler durations.
- var actualDuration = completedWork.actualDuration;
- var treeBaseDuration = completedWork.selfBaseDuration;
- var child = completedWork.child;
+ if (renderState === null) {
+ workInProgress.memoizedState = {
+ isBackwards: isBackwards,
+ rendering: null,
+ renderingStartTime: 0,
+ last: lastContentRow,
+ tail: tail,
+ tailMode: tailMode
+ };
+ } else {
+ // We can reuse the existing object from previous renders.
+ renderState.isBackwards = isBackwards;
+ renderState.rendering = null;
+ renderState.renderingStartTime = 0;
+ renderState.last = lastContentRow;
+ renderState.tail = tail;
+ renderState.tailMode = tailMode;
+ }
+} // This can end up rendering this component multiple passes.
+// The first pass splits the children fibers into two sets. A head and tail.
+// We first render the head. If anything is in fallback state, we do another
+// pass through beginWork to rerender all children (including the tail) with
+// the force suspend context. If the first render didn't have anything in
+// 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.
- while (child !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(child.lanes, child.childLanes)
- );
- subtreeFlags |= child.subtreeFlags;
- subtreeFlags |= child.flags; // 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.
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps;
+ var revealOrder = nextProps.revealOrder;
+ var tailMode = nextProps.tail;
+ var newChildren = nextProps.children;
+ validateRevealOrder(revealOrder);
+ validateTailOptions(tailMode, revealOrder);
+ validateSuspenseListChildren(newChildren, revealOrder);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
+ var suspenseContext = suspenseStackCursor.current;
+ var shouldForceFallback = hasSuspenseContext(
+ suspenseContext,
+ ForceSuspenseFallback
+ );
- actualDuration += child.actualDuration;
- treeBaseDuration += child.treeBaseDuration;
- child = child.sibling;
- }
+ if (shouldForceFallback) {
+ suspenseContext = setShallowSuspenseContext(
+ suspenseContext,
+ ForceSuspenseFallback
+ );
+ workInProgress.flags |= DidCapture;
+ } else {
+ var didSuspendBefore =
+ current !== null && (current.flags & DidCapture) !== NoFlags;
- completedWork.actualDuration = actualDuration;
- completedWork.treeBaseDuration = treeBaseDuration;
- } else {
- var _child = completedWork.child;
+ if (didSuspendBefore) {
+ // If we previously forced a fallback, we need to schedule work
+ // on any nested boundaries to let them know to try to render
+ // again. This is the same as context updating.
+ propagateSuspenseContextChange(
+ workInProgress,
+ workInProgress.child,
+ renderLanes
+ );
+ }
- while (_child !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(_child.lanes, _child.childLanes)
- );
- subtreeFlags |= _child.subtreeFlags;
- subtreeFlags |= _child.flags; // Update the return pointer so the tree is consistent. This is a code
- // smell because it assumes the commit phase is never concurrent with
- // the render phase. Will address during refactor to alternate model.
+ suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
+ }
- _child.return = completedWork;
- _child = _child.sibling;
- }
- }
+ pushSuspenseContext(workInProgress, suspenseContext);
- completedWork.subtreeFlags |= subtreeFlags;
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ // 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 {
- // Bubble up the earliest expiration time.
- if ((completedWork.mode & ProfileMode) !== NoMode) {
- // In profiling mode, resetChildExpirationTime is also used to reset
- // profiler durations.
- var _treeBaseDuration = completedWork.selfBaseDuration;
- var _child2 = completedWork.child;
+ switch (revealOrder) {
+ case "forwards": {
+ var lastContentRow = findLastContentRow(workInProgress.child);
+ var tail;
- while (_child2 !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(_child2.lanes, _child2.childLanes)
- ); // "Static" flags share the lifetime of the fiber/hook they belong to,
- // so we should bubble those up even during a bailout. All the other
- // flags have a lifetime only of a single render + commit, so we should
- // ignore them.
+ if (lastContentRow === null) {
+ // The whole list is part of the tail.
+ // TODO: We could fast path by just rendering the tail now.
+ tail = workInProgress.child;
+ workInProgress.child = null;
+ } else {
+ // Disconnect the tail rows after the content row.
+ // We're going to render them separately later.
+ tail = lastContentRow.sibling;
+ lastContentRow.sibling = null;
+ }
- subtreeFlags |= _child2.subtreeFlags & StaticMask;
- subtreeFlags |= _child2.flags & StaticMask;
- _treeBaseDuration += _child2.treeBaseDuration;
- _child2 = _child2.sibling;
+ initSuspenseListRenderState(
+ workInProgress,
+ false, // isBackwards
+ tail,
+ lastContentRow,
+ tailMode
+ );
+ break;
}
- completedWork.treeBaseDuration = _treeBaseDuration;
- } else {
- var _child3 = completedWork.child;
+ case "backwards": {
+ // We're going to find the first row that has existing content.
+ // At the same time we're going to reverse the list of everything
+ // we pass in the meantime. That's going to be our tail in reverse
+ // order.
+ var _tail = null;
+ var row = workInProgress.child;
+ workInProgress.child = null;
- while (_child3 !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(_child3.lanes, _child3.childLanes)
- ); // "Static" flags share the lifetime of the fiber/hook they belong to,
- // so we should bubble those up even during a bailout. All the other
- // flags have a lifetime only of a single render + commit, so we should
- // ignore them.
+ while (row !== null) {
+ var currentRow = row.alternate; // New rows can't be content rows.
- subtreeFlags |= _child3.subtreeFlags & StaticMask;
- subtreeFlags |= _child3.flags & StaticMask; // Update the return pointer so the tree is consistent. This is a code
- // smell because it assumes the commit phase is never concurrent with
- // the render phase. Will address during refactor to alternate model.
+ if (currentRow !== null && findFirstSuspended(currentRow) === null) {
+ // This is the beginning of the main content.
+ workInProgress.child = row;
+ break;
+ }
+
+ var nextRow = row.sibling;
+ row.sibling = _tail;
+ _tail = row;
+ row = nextRow;
+ } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
+
+ initSuspenseListRenderState(
+ workInProgress,
+ true, // isBackwards
+ _tail,
+ null, // last
+ tailMode
+ );
+ break;
+ }
+
+ case "together": {
+ initSuspenseListRenderState(
+ workInProgress,
+ false, // isBackwards
+ null, // tail
+ null, // last
+ undefined
+ );
+ break;
+ }
- _child3.return = completedWork;
- _child3 = _child3.sibling;
+ default: {
+ // The default reveal order is the same as not having
+ // a boundary.
+ workInProgress.memoizedState = null;
}
}
+ }
- completedWork.subtreeFlags |= subtreeFlags;
+ return workInProgress.child;
+}
+
+function updatePortalComponent(current, workInProgress, renderLanes) {
+ pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
+ var nextChildren = workInProgress.pendingProps;
+
+ if (current === null) {
+ // Portals are special because we don't append the children during mount
+ // but at commit. Therefore we need to track insertions which the normal
+ // flow doesn't do during mount. This doesn't happen at the root because
+ // the root always starts with a "current" with a null child.
+ // TODO: Consider unifying this with how the root works.
+ workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ null,
+ nextChildren,
+ renderLanes
+ );
+ } else {
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
}
- completedWork.childLanes = newChildLanes;
- return didBailout;
+ return workInProgress.child;
}
-function completeWork(current, workInProgress, renderLanes) {
- var newProps = workInProgress.pendingProps;
+var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
- switch (workInProgress.tag) {
- case IndeterminateComponent:
- case LazyComponent:
- case SimpleMemoComponent:
- case FunctionComponent:
- case ForwardRef:
- case Fragment:
- case Mode:
- case Profiler:
- case ContextConsumer:
- case MemoComponent:
- bubbleProperties(workInProgress);
- return null;
+function updateContextProvider(current, workInProgress, renderLanes) {
+ var providerType = workInProgress.type;
+ var context = providerType._context;
+ var newProps = workInProgress.pendingProps;
+ var oldProps = workInProgress.memoizedProps;
+ var newValue = newProps.value;
- case ClassComponent: {
- var Component = workInProgress.type;
+ {
+ if (!("value" in newProps)) {
+ if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
+ hasWarnedAboutUsingNoValuePropOnContextProvider = true;
- if (isContextProvider(Component)) {
- popContext(workInProgress);
+ error(
+ "The `value` prop is required for the ``. Did you misspell it or forget to pass it?"
+ );
}
+ }
- bubbleProperties(workInProgress);
- return null;
+ var providerPropTypes = workInProgress.type.propTypes;
+
+ if (providerPropTypes) {
+ checkPropTypes(providerPropTypes, newProps, "prop", "Context.Provider");
}
+ }
- case HostRoot: {
- var fiberRoot = workInProgress.stateNode;
+ pushProvider(workInProgress, context, newValue);
- popHostContainer(workInProgress);
- popTopLevelContextObject(workInProgress);
- resetWorkInProgressVersions();
+ {
+ if (oldProps !== null) {
+ var oldValue = oldProps.value;
- if (fiberRoot.pendingContext) {
- fiberRoot.context = fiberRoot.pendingContext;
- fiberRoot.pendingContext = null;
+ if (objectIs(oldValue, newValue)) {
+ // No change. Bailout early if children are the same.
+ if (oldProps.children === newProps.children && !hasContextChanged()) {
+ return bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ }
+ } else {
+ // The context value changed. Search for matching consumers and schedule
+ // them to update.
+ propagateContextChange(workInProgress, context, renderLanes);
}
+ }
+ }
- if (current === null || current.child === null) {
- // If we hydrated, pop so that we can delete any remaining children
- // that weren't hydrated.
- var wasHydrated = popHydrationState();
+ var newChildren = newProps.children;
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
+ return workInProgress.child;
+}
- if (wasHydrated) {
- // 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.flags |= Snapshot;
+var hasWarnedAboutUsingContextAsConsumer = false;
+
+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
+ // so we use the old behaviour (Context.Consumer references Context) to
+ // reduce size and overhead. The separate object references context via
+ // a property called "_context", which also gives us the ability to check
+ // in DEV mode if this property exists or not and warn if it does not.
+
+ {
+ if (context._context === undefined) {
+ // This may be because it's a Context (rather than a Consumer).
+ // Or it may be because it's older React where they're the same thing.
+ // We only want to warn if we're sure it's a new React.
+ if (context !== context.Consumer) {
+ if (!hasWarnedAboutUsingContextAsConsumer) {
+ hasWarnedAboutUsingContextAsConsumer = true;
+
+ error(
+ "Rendering directly is not supported and will be removed in " +
+ "a future major release. Did you mean to render instead?"
+ );
}
}
+ } else {
+ context = context._context;
+ }
+ }
- updateHostContainer(current, workInProgress);
- bubbleProperties(workInProgress);
- return null;
+ var newProps = workInProgress.pendingProps;
+ var render = newProps.children;
+
+ {
+ if (typeof render !== "function") {
+ error(
+ "A context consumer was rendered with multiple children, or a child " +
+ "that isn't a function. A context consumer expects a single child " +
+ "that is a function. If you did pass a function, make sure there " +
+ "is no trailing or leading whitespace around it."
+ );
}
+ }
- case HostComponent: {
- popHostContext(workInProgress);
- var rootContainerInstance = getRootHostContainer();
- var type = workInProgress.type;
+ prepareToReadContext(workInProgress, renderLanes);
+ var newValue = readContext(context);
- if (current !== null && workInProgress.stateNode != null) {
- updateHostComponent$1(
- current,
- workInProgress,
- type,
- newProps,
- rootContainerInstance
- );
+ var newChildren;
- if (current.ref !== workInProgress.ref) {
- markRef$1(workInProgress);
- }
- } else {
- if (!newProps) {
- if (!(workInProgress.stateNode !== null)) {
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- } // This can happen when we abort work.
+ {
+ ReactCurrentOwner$1.current = workInProgress;
+ setIsRendering(true);
+ newChildren = render(newValue);
+ setIsRendering(false);
+ }
- bubbleProperties(workInProgress);
- return null;
- }
+ workInProgress.flags |= PerformedWork;
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
+ return workInProgress.child;
+}
- var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
- // "stack" as the parent. Then append children as we go in beginWork
- // or completeWork depending on whether we want to add them top->down or
- // bottom->up. Top->down is faster in IE11.
+function markWorkInProgressReceivedUpdate() {
+ didReceiveUpdate = true;
+}
- var _wasHydrated = popHydrationState();
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
+ if (current !== null) {
+ // Reuse previous dependencies
+ workInProgress.dependencies = current.dependencies;
+ }
- if (_wasHydrated) {
- // TODO: Move this and createInstance step into the beginPhase
- // to consolidate.
- if (prepareToHydrateHostInstance()) {
- // If changes to the hydrated node need to be applied at the
- // commit-phase we mark this as such.
- markUpdate(workInProgress);
- }
- } else {
- var instance = createInstance(
- type,
- newProps,
- rootContainerInstance,
- currentHostContext,
- workInProgress
- );
- appendAllChildren(instance, workInProgress, false, false);
- workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount.
- }
+ {
+ // Don't update "base" render times for bailouts.
+ stopProfilerTimerIfRunning();
+ }
- if (workInProgress.ref !== null) {
- // If there is a ref on a host node we need to schedule a callback
- markRef$1(workInProgress);
- }
- }
+ markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.
- bubbleProperties(workInProgress);
+ 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.
+ {
return null;
}
+ } // This fiber doesn't have work, but its subtree does. Clone the child
+ // fibers and continue.
- case HostText: {
- var newText = newProps;
+ cloneChildFibers(current, workInProgress);
+ return workInProgress.child;
+}
+
+function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
+ {
+ var returnFiber = oldWorkInProgress.return;
+
+ if (returnFiber === null) {
+ // eslint-disable-next-line react-internal/prod-error-codes
+ throw new Error("Cannot swap the root fiber.");
+ } // Disconnect from the old current.
+ // It will get deleted.
- if (current && workInProgress.stateNode != null) {
- var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
- // to schedule a side-effect to do the updates.
+ current.alternate = null;
+ oldWorkInProgress.alternate = null; // Connect to the new tree.
- updateHostText$1(current, workInProgress, oldText, newText);
- } else {
- if (typeof newText !== "string") {
- if (!(workInProgress.stateNode !== null)) {
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- } // This can happen when we abort work.
- }
+ newWorkInProgress.index = oldWorkInProgress.index;
+ newWorkInProgress.sibling = oldWorkInProgress.sibling;
+ newWorkInProgress.return = oldWorkInProgress.return;
+ newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
- var _rootContainerInstance = getRootHostContainer();
+ if (oldWorkInProgress === returnFiber.child) {
+ returnFiber.child = newWorkInProgress;
+ } else {
+ var prevSibling = returnFiber.child;
- var _currentHostContext = getHostContext();
+ if (prevSibling === null) {
+ // eslint-disable-next-line react-internal/prod-error-codes
+ throw new Error("Expected parent to have a child.");
+ }
- var _wasHydrated2 = popHydrationState();
+ while (prevSibling.sibling !== oldWorkInProgress) {
+ prevSibling = prevSibling.sibling;
- if (_wasHydrated2) {
- if (prepareToHydrateHostTextInstance()) {
- markUpdate(workInProgress);
- }
- } else {
- workInProgress.stateNode = createTextInstance(
- newText,
- _rootContainerInstance,
- _currentHostContext,
- workInProgress
- );
+ if (prevSibling === null) {
+ // eslint-disable-next-line react-internal/prod-error-codes
+ throw new Error("Expected to find the previous sibling.");
}
}
- bubbleProperties(workInProgress);
- return null;
+ prevSibling.sibling = newWorkInProgress;
+ } // Delete the old fiber and place the new one.
+ // Since the old fiber is disconnected, we have to schedule it manually.
+
+ var deletions = returnFiber.deletions;
+
+ if (deletions === null) {
+ returnFiber.deletions = [current];
+ returnFiber.flags |= ChildDeletion;
+ } else {
+ deletions.push(current);
}
- case SuspenseComponent: {
- popSuspenseContext(workInProgress);
- var nextState = workInProgress.memoizedState;
+ newWorkInProgress.flags |= Placement; // Restart work from the new fiber.
- if ((workInProgress.flags & DidCapture) !== NoFlags) {
- // Something suspended. Re-render with the fallback children.
- workInProgress.lanes = renderLanes; // Do not reset the effect list.
+ return newWorkInProgress;
+ }
+}
- if ((workInProgress.mode & ProfileMode) !== NoMode) {
- transferActualDuration(workInProgress);
- } // Don't bubble properties in this case.
+function checkScheduledUpdateOrContext(current, renderLanes) {
+ // Before performing an early bailout, we must check if there are pending
+ // updates or context.
+ var updateLanes = current.lanes;
- return workInProgress;
- }
+ if (includesSomeLane(updateLanes, renderLanes)) {
+ return true;
+ } // No pending update, but because context is propagated lazily, we need
- var nextDidTimeout = nextState !== null;
- var prevDidTimeout = false;
+ return false;
+}
- if (current === null) {
- if (workInProgress.memoizedProps.fallback !== undefined);
- } else {
- var prevState = current.memoizedState;
- prevDidTimeout = prevState !== null;
- }
+function attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+) {
+ // 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.
+ switch (workInProgress.tag) {
+ case HostRoot:
+ pushHostRootContext(workInProgress);
+ var root = workInProgress.stateNode;
+ break;
- if (nextDidTimeout && !prevDidTimeout) {
- // TODO: This will still suspend a synchronous tree if anything
- // in the concurrent tree already suspended during this render.
- // This is a known bug.
- if ((workInProgress.mode & ConcurrentMode) !== NoMode) {
- // TODO: Move this back to throwException because this is too late
- // if this is a large tree which is common for initial loads. We
- // don't know if we should restart a render or not until we get
- // this marker, and this is too late.
- // If this render already had a ping or lower pri updates,
- // and this is the first time we know we're going to suspend we
- // should be able to immediately restart from within throwException.
- var hasInvisibleChildContext =
- current === null &&
- workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
+ case HostComponent:
+ pushHostContext(workInProgress);
+ break;
- if (
- hasInvisibleChildContext ||
- hasSuspenseContext(
- suspenseStackCursor.current,
- InvisibleParentSuspenseContext
- )
- ) {
- // If this was in an invisible tree or a new render, then showing
- // this boundary is ok.
- renderDidSuspend();
- } else {
- // Otherwise, we're going to have to hide content so we should
- // suspend for longer if possible.
- renderDidSuspendDelayIfPossible();
- }
- }
+ case ClassComponent: {
+ var Component = workInProgress.type;
+
+ if (isContextProvider(Component)) {
+ pushContextProvider(workInProgress);
}
+ break;
+ }
+
+ case HostPortal:
+ pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
+ break;
+
+ case ContextProvider: {
+ var newValue = workInProgress.memoizedProps.value;
+ var context = workInProgress.type._context;
+ pushProvider(workInProgress, context, newValue);
+ break;
+ }
+
+ case Profiler:
{
- // TODO: Only schedule updates if not prevDidTimeout.
- if (nextDidTimeout) {
- // If this boundary just timed out, schedule an effect to attach a
- // retry listener to the promise. This flag is also used to hide the
- // primary children.
+ // Profiler should only call onRender when one of its descendants actually rendered.
+ var hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
+
+ if (hasChildWork) {
workInProgress.flags |= 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,
+ var stateNode = workInProgress.stateNode;
+ stateNode.effectDuration = 0;
+ stateNode.passiveEffectDuration = 0;
+ }
}
- bubbleProperties(workInProgress);
+ break;
- {
- if ((workInProgress.mode & ProfileMode) !== NoMode) {
- if (nextDidTimeout) {
- // Don't count time spent in a timed out Suspense subtree as part of the base duration.
- var _primaryChildFragment2 = workInProgress.child;
+ case SuspenseComponent: {
+ var state = workInProgress.memoizedState;
- if (_primaryChildFragment2 !== null) {
- // $FlowFixMe Flow doesn't support type casting in combination with the -= operator
- workInProgress.treeBaseDuration -=
- _primaryChildFragment2.treeBaseDuration;
- }
+ if (state !== null) {
+ // whether to retry the primary children, or to skip over it and
+ // go straight to the fallback. Check the priority of the primary
+ // child fragment.
+
+ var primaryChildFragment = workInProgress.child;
+ var primaryChildLanes = primaryChildFragment.childLanes;
+
+ 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, renderLanes);
+ } else {
+ // The primary child fragment does not have pending work marked
+ // on it
+ pushSuspenseContext(
+ workInProgress,
+ setDefaultShallowSuspenseContext(suspenseStackCursor.current)
+ ); // The primary children do not have pending work with sufficient
+ // priority. Bailout.
+
+ var child = bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
+ );
+
+ if (child !== null) {
+ // The fallback children have pending work. Skip over the
+ // primary children and work on the fallback.
+ return child.sibling;
+ } else {
+ // Note: We can return `null` here because we already checked
+ // whether there were nested context consumers, via the call to
+ // `bailoutOnAlreadyFinishedWork` above.
+ return null;
}
}
+ } else {
+ pushSuspenseContext(
+ workInProgress,
+ setDefaultShallowSuspenseContext(suspenseStackCursor.current)
+ );
}
- return null;
+ break;
}
- case HostPortal:
- popHostContainer(workInProgress);
- updateHostContainer(current, workInProgress);
+ case SuspenseListComponent: {
+ var didSuspendBefore = (current.flags & DidCapture) !== NoFlags;
- if (current === null) {
- preparePortalMount(workInProgress.stateNode.containerInfo);
- }
+ var _hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
- bubbleProperties(workInProgress);
- return null;
+ if (didSuspendBefore) {
+ if (_hasChildWork) {
+ // If something was in fallback state last time, and we have all the
+ // same children then we're still in progressive loading state.
+ // Something might get unblocked by state updates or retries in the
+ // tree which will affect the tail. So we need to use the normal
+ // path to compute the correct tail.
+ return updateSuspenseListComponent(
+ current,
+ workInProgress,
+ 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
+ // as before. We can fast bail out.
- case ContextProvider:
- // Pop provider fiber
- var context = workInProgress.type._context;
- popProvider(context, workInProgress);
- bubbleProperties(workInProgress);
- return null;
+ workInProgress.flags |= DidCapture;
+ } // If nothing suspended before and we're rendering the same children,
+ // then the tail doesn't matter. Anything new that suspends will work
+ // in the "together" mode, so we can continue from the state we had.
- case IncompleteClassComponent: {
- // Same as class component case. I put it down here so that the tags are
- // sequential to ensure this switch is compiled to a jump table.
- var _Component = workInProgress.type;
+ var renderState = workInProgress.memoizedState;
- if (isContextProvider(_Component)) {
- popContext(workInProgress);
+ if (renderState !== null) {
+ // Reset to the "together" mode in case we've started a different
+ // update in the past but didn't complete it.
+ renderState.rendering = null;
+ renderState.tail = null;
+ renderState.lastEffect = null;
}
- bubbleProperties(workInProgress);
- return null;
- }
-
- case SuspenseListComponent: {
- popSuspenseContext(workInProgress);
- var renderState = workInProgress.memoizedState;
+ pushSuspenseContext(workInProgress, suspenseStackCursor.current);
- if (renderState === null) {
- // We're running in the default, "independent" mode.
- // We don't do anything in this mode.
- bubbleProperties(workInProgress);
+ if (_hasChildWork) {
+ break;
+ } else {
+ // 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
+ // as before. We can fast bail out.
return null;
}
+ }
- var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags;
- var renderedTail = renderState.rendering;
+ 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);
+ }
+ }
- if (renderedTail === null) {
- // We just rendered the head.
- if (!didSuspendAlready) {
- // This is the first pass. We need to figure out if anything is still
- // suspended in the rendered set.
- // If new content unsuspended, but there's still some content that
- // didn't. Then we need to do a second pass that forces everything
- // to keep showing their fallbacks.
- // We might be suspended if something in this render pass suspended, or
- // something in the previous committed pass suspended. Otherwise,
- // there's no chance so we can skip the expensive call to
- // findFirstSuspended.
- var cannotBeSuspended =
- renderHasNotSuspendedYet() &&
- (current === null || (current.flags & DidCapture) === NoFlags);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+}
+
+function beginWork(current, workInProgress, renderLanes) {
+ {
+ if (workInProgress._debugNeedsRemount && current !== null) {
+ // This will restart the begin phase with a new fiber.
+ return remountFiber(
+ current,
+ workInProgress,
+ createFiberFromTypeAndProps(
+ workInProgress.type,
+ workInProgress.key,
+ workInProgress.pendingProps,
+ workInProgress._debugOwner || null,
+ workInProgress.mode,
+ workInProgress.lanes
+ )
+ );
+ }
+ }
+
+ if (current !== null) {
+ var oldProps = current.memoizedProps;
+ var newProps = workInProgress.pendingProps;
+
+ if (
+ oldProps !== newProps ||
+ hasContextChanged() || // Force a re-render if the implementation changed due to hot reload:
+ workInProgress.type !== current.type
+ ) {
+ // 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 {
+ // Neither props nor legacy context changes. Check if there's a pending
+ // update or context change.
+ var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(
+ current,
+ renderLanes
+ );
- if (!cannotBeSuspended) {
- var row = workInProgress.child;
+ if (
+ !hasScheduledUpdateOrContext && // If this is the second pass of an error or suspense boundary, there
+ // may not be work scheduled on `current`, so we check for this flag.
+ (workInProgress.flags & DidCapture) === NoFlags
+ ) {
+ // No pending updates or context. Bail out now.
+ didReceiveUpdate = false;
+ return attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ }
- while (row !== null) {
- var suspended = findFirstSuspended(row);
+ if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
+ // 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;
+ } // Before entering the begin phase, clear pending update priority.
+ // TODO: This assumes that we're about to evaluate the component and process
+ // the update queue. However, there's an exception: SimpleMemoComponent
+ // 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.
- if (suspended !== null) {
- didSuspendAlready = true;
- workInProgress.flags |= DidCapture;
- cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
- // part of the second pass. In that case nothing will subscribe to
- // its thennables. Instead, we'll transfer its thennables to the
- // SuspenseList so that it can retry if they resolve.
- // There might be multiple of these in the list but since we're
- // going to wait for all of them anyway, it doesn't really matter
- // which ones gets to ping. In theory we could get clever and keep
- // track of how many dependencies remain but it gets tricky because
- // in the meantime, we can add/remove/change items and dependencies.
- // We might bail out of the loop before finding any but that
- // doesn't matter since that means that the other boundaries that
- // we did find already has their listeners attached.
+ workInProgress.lanes = NoLanes;
- var newThennables = suspended.updateQueue;
+ switch (workInProgress.tag) {
+ case IndeterminateComponent: {
+ return mountIndeterminateComponent(
+ current,
+ workInProgress,
+ workInProgress.type,
+ renderLanes
+ );
+ }
- if (newThennables !== null) {
- workInProgress.updateQueue = newThennables;
- workInProgress.flags |= Update;
- } // Rerender the whole list, but this time, we'll force fallbacks
- // to stay in place.
- // Reset the effect flags before doing the second pass since that's now invalid.
- // Reset the child fibers to their original state.
+ case LazyComponent: {
+ var elementType = workInProgress.elementType;
+ return mountLazyComponent(
+ current,
+ workInProgress,
+ elementType,
+ renderLanes
+ );
+ }
- workInProgress.subtreeFlags = NoFlags;
- resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
- // rerender the children.
+ case FunctionComponent: {
+ var Component = workInProgress.type;
+ var unresolvedProps = workInProgress.pendingProps;
+ var resolvedProps =
+ workInProgress.elementType === Component
+ ? unresolvedProps
+ : resolveDefaultProps(Component, unresolvedProps);
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ }
- pushSuspenseContext(
- workInProgress,
- setShallowSuspenseContext(
- suspenseStackCursor.current,
- ForceSuspenseFallback
- )
- ); // Don't bubble properties in this case.
+ case ClassComponent: {
+ var _Component = workInProgress.type;
+ var _unresolvedProps = workInProgress.pendingProps;
- return workInProgress.child;
- }
+ var _resolvedProps =
+ workInProgress.elementType === _Component
+ ? _unresolvedProps
+ : resolveDefaultProps(_Component, _unresolvedProps);
- row = row.sibling;
- }
- }
+ return updateClassComponent(
+ current,
+ workInProgress,
+ _Component,
+ _resolvedProps,
+ renderLanes
+ );
+ }
- if (renderState.tail !== null && now() > getRenderTargetTime()) {
- // We have already passed our CPU deadline but we still have rows
- // left in the tail. We'll just give up further attempts to render
- // the main content and only render fallbacks.
- workInProgress.flags |= DidCapture;
- didSuspendAlready = true;
- cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
- // to get it started back up to attempt the next item. While in terms
- // of priority this work has the same priority as this current render,
- // it's not part of the same transition once the transition has
- // committed. If it's sync, we still want to yield so that it can be
- // painted. Conceptually, this is really the same as pinging.
- // We can use any RetryLane even if it's the one currently rendering
- // since we're leaving it behind on this node.
+ case HostRoot:
+ return updateHostRoot(current, workInProgress, renderLanes);
- workInProgress.lanes = SomeRetryLane;
- }
- } else {
- cutOffTailIfNeeded(renderState, false);
- } // Next we're going to render the tail.
- } else {
- // Append the rendered row to the child list.
- if (!didSuspendAlready) {
- var _suspended = findFirstSuspended(renderedTail);
+ case HostComponent:
+ return updateHostComponent$1(current, workInProgress, renderLanes);
- if (_suspended !== null) {
- workInProgress.flags |= DidCapture;
- didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't
- // get lost if this row ends up dropped during a second pass.
+ case HostText:
+ return updateHostText$1();
- var _newThennables = _suspended.updateQueue;
+ case SuspenseComponent:
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
- if (_newThennables !== null) {
- workInProgress.updateQueue = _newThennables;
- workInProgress.flags |= Update;
- }
+ case HostPortal:
+ return updatePortalComponent(current, workInProgress, renderLanes);
- cutOffTailIfNeeded(renderState, true); // This might have been modified.
+ case ForwardRef: {
+ var type = workInProgress.type;
+ var _unresolvedProps2 = workInProgress.pendingProps;
- if (
- renderState.tail === null &&
- renderState.tailMode === "hidden" &&
- !renderedTail.alternate &&
- !getIsHydrating() // We don't cut it if we're hydrating.
- ) {
- // We're done.
- bubbleProperties(workInProgress);
- return null;
- }
- } else if (
- // The time it took to render last row is greater than the remaining
- // time we have to render. So rendering one more row would likely
- // exceed it.
- now() * 2 - renderState.renderingStartTime >
- getRenderTargetTime() &&
- 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.
- // The assumption is that this is usually faster.
- workInProgress.flags |= DidCapture;
- didSuspendAlready = true;
- cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
- // to get it started back up to attempt the next item. While in terms
- // of priority this work has the same priority as this current render,
- // it's not part of the same transition once the transition has
- // committed. If it's sync, we still want to yield so that it can be
- // painted. Conceptually, this is really the same as pinging.
- // We can use any RetryLane even if it's the one currently rendering
- // since we're leaving it behind on this node.
+ var _resolvedProps2 =
+ workInProgress.elementType === type
+ ? _unresolvedProps2
+ : resolveDefaultProps(type, _unresolvedProps2);
- workInProgress.lanes = SomeRetryLane;
- }
- }
+ return updateForwardRef(
+ current,
+ workInProgress,
+ type,
+ _resolvedProps2,
+ renderLanes
+ );
+ }
- if (renderState.isBackwards) {
- // The effect list of the backwards tail will have been added
- // to the end. This breaks the guarantee that life-cycles fire in
- // sibling order but that isn't a strong guarantee promised by React.
- // Especially since these might also just pop in during future commits.
- // Append to the beginning of the list.
- renderedTail.sibling = workInProgress.child;
- workInProgress.child = renderedTail;
- } else {
- var previousSibling = renderState.last;
+ case Fragment:
+ return updateFragment(current, workInProgress, renderLanes);
- if (previousSibling !== null) {
- previousSibling.sibling = renderedTail;
- } else {
- workInProgress.child = renderedTail;
- }
+ case Mode:
+ return updateMode(current, workInProgress, renderLanes);
- renderState.last = renderedTail;
- }
- }
+ case Profiler:
+ return updateProfiler(current, workInProgress, renderLanes);
- if (renderState.tail !== null) {
- // We still have tail rows to render.
- // Pop a row.
- var next = renderState.tail;
- renderState.rendering = next;
- renderState.tail = next.sibling;
- renderState.renderingStartTime = now();
- next.sibling = null; // Restore the context.
- // TODO: We can probably just avoid popping it instead and only
- // setting it the first time we go from not suspended to suspended.
+ case ContextProvider:
+ return updateContextProvider(current, workInProgress, renderLanes);
- var suspenseContext = suspenseStackCursor.current;
+ case ContextConsumer:
+ return updateContextConsumer(current, workInProgress, renderLanes);
- if (didSuspendAlready) {
- suspenseContext = setShallowSuspenseContext(
- suspenseContext,
- ForceSuspenseFallback
- );
- } else {
- suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
- }
+ case MemoComponent: {
+ var _type2 = workInProgress.type;
+ var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
- pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
- // Don't bubble properties in this case.
+ var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
- return next;
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ var outerPropTypes = _type2.propTypes;
+
+ if (outerPropTypes) {
+ checkPropTypes(
+ outerPropTypes,
+ _resolvedProps3, // Resolved for outer only
+ "prop",
+ getComponentNameFromType(_type2)
+ );
+ }
+ }
}
- bubbleProperties(workInProgress);
- return null;
+ _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
+ return updateMemoComponent(
+ current,
+ workInProgress,
+ _type2,
+ _resolvedProps3,
+ renderLanes
+ );
}
- case ScopeComponent: {
- break;
+ case SimpleMemoComponent: {
+ return updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ workInProgress.type,
+ workInProgress.pendingProps,
+ renderLanes
+ );
}
- case OffscreenComponent:
- case LegacyHiddenComponent: {
- popRenderLanes(workInProgress);
- var _nextState = workInProgress.memoizedState;
- var nextIsHidden = _nextState !== null;
+ case IncompleteClassComponent: {
+ var _Component2 = workInProgress.type;
+ var _unresolvedProps4 = workInProgress.pendingProps;
- if (current !== null) {
- var _prevState = current.memoizedState;
- var prevIsHidden = _prevState !== null;
+ var _resolvedProps4 =
+ workInProgress.elementType === _Component2
+ ? _unresolvedProps4
+ : resolveDefaultProps(_Component2, _unresolvedProps4);
- if (
- prevIsHidden !== nextIsHidden &&
- newProps.mode !== "unstable-defer-without-hiding"
- ) {
- workInProgress.flags |= Update;
- }
- } // Don't bubble properties for hidden children.
+ return mountIncompleteClassComponent(
+ current,
+ workInProgress,
+ _Component2,
+ _resolvedProps4,
+ renderLanes
+ );
+ }
- if (
- !nextIsHidden ||
- includesSomeLane(subtreeRenderLanes, OffscreenLane) ||
- (workInProgress.mode & ConcurrentMode) === NoMode
- ) {
- bubbleProperties(workInProgress);
- }
+ case SuspenseListComponent: {
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
+ }
- return null;
+ case ScopeComponent: {
+ break;
}
- }
- {
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
+ case OffscreenComponent: {
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
+ }
}
+
+ throw new Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in " +
+ "React. Please file an issue."
+ );
}
-function unwindWork(workInProgress, renderLanes) {
+function unwindWork(current, workInProgress, renderLanes) {
+ // Note: This intentionally doesn't check if we're hydrating because comparing
+ // to the current tree provider fiber is just as fast and less error-prone.
+ // Ideally we would have a special version of the work loop only
+ // for hydration.
+ popTreeContext(workInProgress);
+
switch (workInProgress.tag) {
case ClassComponent: {
var Component = workInProgress.type;
@@ -16586,14 +17166,17 @@ function unwindWork(workInProgress, renderLanes) {
resetWorkInProgressVersions();
var _flags = workInProgress.flags;
- if (!((_flags & DidCapture) === NoFlags)) {
- throw Error(
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
- );
- }
+ if (
+ (_flags & ShouldCapture) !== NoFlags &&
+ (_flags & DidCapture) === NoFlags
+ ) {
+ // There was an error during render that wasn't captured by a suspense
+ // boundary. Do a second pass on the root to unmount the children.
+ workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture;
+ return workInProgress;
+ } // We unwound to the root without completing it. Exit.
- workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture;
- return workInProgress;
+ return null;
}
case HostComponent: {
@@ -16650,7 +17233,13 @@ function unwindWork(workInProgress, renderLanes) {
}
}
-function unwindInterruptedWork(interruptedWork, renderLanes) {
+function unwindInterruptedWork(current, interruptedWork, renderLanes) {
+ // Note: This intentionally doesn't check if we're hydrating because comparing
+ // to the current tree provider fiber is just as fast and less error-prone.
+ // Ideally we would have a special version of the work loop only
+ // for hydration.
+ popTreeContext(interruptedWork);
+
switch (interruptedWork.tag) {
case ClassComponent: {
var childContextTypes = interruptedWork.type.childContextTypes;
@@ -16710,6 +17299,20 @@ var nextEffect = null; // Used for Profiling builds to track updaters.
var inProgressLanes = null;
var inProgressRoot = null;
+function reportUncaughtErrorInDEV(error) {
+ // Wrapping each small part of the commit phase into a guarded
+ // callback is a bit too slow (https://github.com/facebook/react/pull/21666).
+ // But we rely on it to surface errors to DEV tools like overlays
+ // (https://github.com/facebook/react/issues/21712).
+ // As a compromise, rethrow only caught errors in a guard.
+ {
+ invokeGuardedCallback(null, function() {
+ throw error;
+ });
+ clearCaughtError();
+ }
+}
+
var callComponentWillUnmountWithTimer = function(current, instance) {
instance.props = current.memoizedProps;
instance.state = current.memoizedState;
@@ -16733,8 +17336,9 @@ function safelyCallComponentWillUnmount(
) {
try {
callComponentWillUnmountWithTimer(current, instance);
- } catch (unmountError) {
- captureCommitPhaseError(current, nearestMountedAncestor, unmountError);
+ } catch (error) {
+ reportUncaughtErrorInDEV(error);
+ captureCommitPhaseError(current, nearestMountedAncestor, error);
}
} // Capture errors so they don't interrupt mounting.
@@ -16743,6 +17347,8 @@ function safelyDetachRef(current, nearestMountedAncestor) {
if (ref !== null) {
if (typeof ref === "function") {
+ var retVal;
+
try {
if (
enableProfilerTimer &&
@@ -16751,16 +17357,27 @@ function safelyDetachRef(current, nearestMountedAncestor) {
) {
try {
startLayoutEffectTimer();
- ref(null);
+ retVal = ref(null);
} finally {
recordLayoutEffectDuration(current);
}
} else {
- ref(null);
+ retVal = ref(null);
}
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(current, nearestMountedAncestor, error);
}
+
+ {
+ if (typeof retVal === "function") {
+ error(
+ "Unexpected return value from a callback ref in %s. " +
+ "A callback ref should not return a function.",
+ getComponentNameFromFiber(current)
+ );
+ }
+ }
} else {
ref.current = null;
}
@@ -16771,6 +17388,7 @@ function safelyCallDestroy(current, nearestMountedAncestor, destroy) {
try {
destroy();
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(current, nearestMountedAncestor, error);
}
}
@@ -16814,6 +17432,7 @@ function commitBeforeMutationEffects_complete() {
try {
commitBeforeMutationEffectsOnFiber(fiber);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -16920,11 +17539,10 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) {
break;
default: {
- {
- 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."
- );
- }
+ throw new 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."
+ );
}
}
@@ -16960,7 +17578,7 @@ function commitHookEffectListUnmount(
}
}
-function commitHookEffectListMount(tag, finishedWork) {
+function commitHookEffectListMount(flags, finishedWork) {
var updateQueue = finishedWork.updateQueue;
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
@@ -16969,8 +17587,7 @@ function commitHookEffectListMount(tag, finishedWork) {
var effect = firstEffect;
do {
- if ((effect.tag & tag) === tag) {
- // Mount
+ if ((effect.tag & flags) === flags) {
var create = effect.create;
effect.destroy = create();
@@ -16978,6 +17595,16 @@ function commitHookEffectListMount(tag, finishedWork) {
var destroy = effect.destroy;
if (destroy !== undefined && typeof destroy !== "function") {
+ var hookName = void 0;
+
+ if ((effect.tag & Layout) !== NoFlags) {
+ hookName = "useLayoutEffect";
+ } else if ((effect.tag & Insertion) !== NoFlags) {
+ hookName = "useInsertionEffect";
+ } else {
+ hookName = "useEffect";
+ }
+
var addendum = void 0;
if (destroy === null) {
@@ -16986,10 +17613,13 @@ function commitHookEffectListMount(tag, finishedWork) {
"up, return undefined (or nothing).";
} else if (typeof destroy.then === "function") {
addendum =
- "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " +
+ "\n\nIt looks like you wrote " +
+ hookName +
+ "(async () => ...) or returned a Promise. " +
"Instead, write the async function inside your effect " +
"and call it immediately:\n\n" +
- "useEffect(() => {\n" +
+ hookName +
+ "(() => {\n" +
" async function fetchData() {\n" +
" // You can await here\n" +
" const response = await MyAPI.getData(someId);\n" +
@@ -17003,8 +17633,9 @@ function commitHookEffectListMount(tag, finishedWork) {
}
error(
- "An effect function must not return anything besides a function, " +
+ "%s must not return anything besides a function, " +
"which is used for clean-up.%s",
+ hookName,
addendum
);
}
@@ -17074,24 +17705,26 @@ function commitLayoutEffectOnFiber(
finishedWork,
committedLanes
) {
- if ((finishedWork.flags & (Update | Callback)) !== NoFlags) {
+ if ((finishedWork.flags & LayoutMask) !== NoFlags) {
switch (finishedWork.tag) {
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent: {
- // At this point layout effects have already been destroyed (during mutation phase).
- // This is done to prevent sibling component effects from interfering with each other,
- // e.g. a destroy function in one component should never override a ref set
- // by a create function in another component during the same commit.
- if (finishedWork.mode & ProfileMode) {
- try {
- startLayoutEffectTimer();
+ {
+ // At this point layout effects have already been destroyed (during mutation phase).
+ // This is done to prevent sibling component effects from interfering with each other,
+ // e.g. a destroy function in one component should never override a ref set
+ // by a create function in another component during the same commit.
+ if (finishedWork.mode & ProfileMode) {
+ try {
+ startLayoutEffectTimer();
+ commitHookEffectListMount(Layout | HasEffect, finishedWork);
+ } finally {
+ recordLayoutEffectDuration(finishedWork);
+ }
+ } else {
commitHookEffectListMount(Layout | HasEffect, finishedWork);
- } finally {
- recordLayoutEffectDuration(finishedWork);
}
- } else {
- commitHookEffectListMount(Layout | HasEffect, finishedWork);
}
break;
@@ -17101,104 +17734,109 @@ function commitLayoutEffectOnFiber(
var instance = finishedWork.stateNode;
if (finishedWork.flags & Update) {
- if (current === null) {
- // 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 &&
- !didWarnAboutReassigningProps
- ) {
- if (instance.props !== finishedWork.memoizedProps) {
- error(
- "Expected %s props to match memoized props before " +
- "componentDidMount. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.props`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
- }
+ {
+ if (current === null) {
+ // 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 &&
+ !didWarnAboutReassigningProps
+ ) {
+ if (instance.props !== finishedWork.memoizedProps) {
+ error(
+ "Expected %s props to match memoized props before " +
+ "componentDidMount. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.props`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
- if (instance.state !== finishedWork.memoizedState) {
- error(
- "Expected %s state to match memoized state before " +
- "componentDidMount. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.state`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
+ if (instance.state !== finishedWork.memoizedState) {
+ error(
+ "Expected %s state to match memoized state before " +
+ "componentDidMount. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.state`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
}
}
- }
- if (finishedWork.mode & ProfileMode) {
- try {
- startLayoutEffectTimer();
+ if (finishedWork.mode & ProfileMode) {
+ try {
+ startLayoutEffectTimer();
+ instance.componentDidMount();
+ } finally {
+ recordLayoutEffectDuration(finishedWork);
+ }
+ } else {
instance.componentDidMount();
- } finally {
- recordLayoutEffectDuration(finishedWork);
}
} else {
- instance.componentDidMount();
- }
- } else {
- var prevProps =
- finishedWork.elementType === finishedWork.type
- ? current.memoizedProps
- : resolveDefaultProps(finishedWork.type, current.memoizedProps);
- 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.
+ var prevProps =
+ finishedWork.elementType === finishedWork.type
+ ? current.memoizedProps
+ : resolveDefaultProps(
+ finishedWork.type,
+ current.memoizedProps
+ );
+ 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.
- {
- if (
- finishedWork.type === finishedWork.elementType &&
- !didWarnAboutReassigningProps
- ) {
- if (instance.props !== finishedWork.memoizedProps) {
- error(
- "Expected %s props to match memoized props before " +
- "componentDidUpdate. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.props`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
- }
+ {
+ if (
+ finishedWork.type === finishedWork.elementType &&
+ !didWarnAboutReassigningProps
+ ) {
+ if (instance.props !== finishedWork.memoizedProps) {
+ error(
+ "Expected %s props to match memoized props before " +
+ "componentDidUpdate. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.props`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
- if (instance.state !== finishedWork.memoizedState) {
- error(
- "Expected %s state to match memoized state before " +
- "componentDidUpdate. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.state`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
+ if (instance.state !== finishedWork.memoizedState) {
+ error(
+ "Expected %s state to match memoized state before " +
+ "componentDidUpdate. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.state`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
}
}
- }
- if (finishedWork.mode & ProfileMode) {
- try {
- startLayoutEffectTimer();
+ if (finishedWork.mode & ProfileMode) {
+ try {
+ startLayoutEffectTimer();
+ instance.componentDidUpdate(
+ prevProps,
+ prevState,
+ instance.__reactInternalSnapshotBeforeUpdate
+ );
+ } finally {
+ recordLayoutEffectDuration(finishedWork);
+ }
+ } else {
instance.componentDidUpdate(
prevProps,
prevState,
instance.__reactInternalSnapshotBeforeUpdate
);
- } finally {
- recordLayoutEffectDuration(finishedWork);
}
- } else {
- instance.componentDidUpdate(
- prevProps,
- prevState,
- instance.__reactInternalSnapshotBeforeUpdate
- );
}
}
} // TODO: I think this is now always non-null by the time it reaches the
@@ -17367,20 +18005,23 @@ function commitLayoutEffectOnFiber(
case IncompleteClassComponent:
case ScopeComponent:
case OffscreenComponent:
- case LegacyHiddenComponent:
+ case LegacyHiddenComponent: {
break;
+ }
- default: {
- 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."
+ default:
+ throw new 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."
);
- }
}
}
{
- if (finishedWork.flags & Ref) {
- commitAttachRef(finishedWork);
+ {
+ if (finishedWork.flags & Ref) {
+ commitAttachRef(finishedWork);
+ }
}
}
}
@@ -17402,15 +18043,27 @@ function commitAttachRef(finishedWork) {
} // Moved outside to ensure DCE works with this flag
if (typeof ref === "function") {
+ var retVal;
+
if (finishedWork.mode & ProfileMode) {
try {
startLayoutEffectTimer();
- ref(instanceToUse);
+ retVal = ref(instanceToUse);
} finally {
recordLayoutEffectDuration(finishedWork);
}
} else {
- ref(instanceToUse);
+ retVal = ref(instanceToUse);
+ }
+
+ {
+ if (typeof retVal === "function") {
+ error(
+ "Unexpected return value from a callback ref in %s. " +
+ "A callback ref should not return a function.",
+ getComponentNameFromFiber(finishedWork)
+ );
+ }
}
} else {
{
@@ -17474,7 +18127,9 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
tag = _effect.tag;
if (destroy !== undefined) {
- if ((tag & Layout) !== NoFlags$1) {
+ if ((tag & Insertion) !== NoFlags$1) {
+ safelyCallDestroy(current, nearestMountedAncestor, destroy);
+ } else if ((tag & Layout) !== NoFlags$1) {
if (current.mode & ProfileMode) {
startLayoutEffectTimer();
safelyCallDestroy(current, nearestMountedAncestor, destroy);
@@ -17679,11 +18334,10 @@ function commitContainer(finishedWork) {
}
}
- {
- 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."
- );
- }
+ throw new 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 commitDeletion(finishedRoot, current, nearestMountedAncestor) {
@@ -17702,11 +18356,22 @@ function commitWork(current, finishedWork) {
case ForwardRef:
case MemoComponent:
case SimpleMemoComponent: {
- // Layout effects are destroyed during the mutation phase so that all
+ commitHookEffectListUnmount(
+ Insertion | HasEffect,
+ finishedWork,
+ finishedWork.return
+ );
+ commitHookEffectListMount(Insertion | HasEffect, finishedWork); // Layout effects are destroyed during the mutation phase so that all
// destroy functions for all fibers are called before any create functions.
// This prevents sibling component effects from interfering with each other,
// e.g. a destroy function in one component should never override a ref set
// by a create function in another component during the same commit.
+ // TODO: Check if we're inside an Offscreen subtree that disappeared
+ // during this commit. If so, we would have already unmounted its
+ // layout hooks. (However, since we null out the `destroy` function
+ // right before calling it, the behavior is already correct, so this
+ // would mostly be for modeling purposes.)
+
if (finishedWork.mode & ProfileMode) {
try {
startLayoutEffectTimer();
@@ -17734,7 +18399,7 @@ function commitWork(current, finishedWork) {
}
case SuspenseComponent: {
- commitSuspenseComponent(finishedWork);
+ commitSuspenseCallback(finishedWork);
attachSuspenseRetryListeners(finishedWork);
return;
}
@@ -17759,12 +18424,9 @@ function commitWork(current, finishedWork) {
}
}
-function commitSuspenseComponent(finishedWork) {
+function commitSuspenseCallback(finishedWork) {
+ // TODO: Move this to passive phase
var newState = finishedWork.memoizedState;
-
- if (newState !== null) {
- markCommitTimeOfFallback();
- }
}
function attachSuspenseRetryListeners(finishedWork) {
@@ -17811,12 +18473,12 @@ function commitMutationEffects(root, firstChild, committedLanes) {
inProgressLanes = committedLanes;
inProgressRoot = root;
nextEffect = firstChild;
- commitMutationEffects_begin(root);
+ commitMutationEffects_begin(root, committedLanes);
inProgressLanes = null;
inProgressRoot = null;
}
-function commitMutationEffects_begin(root) {
+function commitMutationEffects_begin(root, lanes) {
while (nextEffect !== null) {
var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization
@@ -17829,6 +18491,7 @@ function commitMutationEffects_begin(root) {
try {
commitDeletion(root, childToDelete, fiber);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(childToDelete, fiber, error);
}
}
@@ -17840,19 +18503,20 @@ function commitMutationEffects_begin(root) {
ensureCorrectReturnPointer(child, fiber);
nextEffect = child;
} else {
- commitMutationEffects_complete(root);
+ commitMutationEffects_complete(root, lanes);
}
}
}
-function commitMutationEffects_complete(root) {
+function commitMutationEffects_complete(root, lanes) {
while (nextEffect !== null) {
var fiber = nextEffect;
setCurrentFiber(fiber);
try {
- commitMutationEffectsOnFiber(fiber, root);
+ commitMutationEffectsOnFiber(fiber, root, lanes);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -17869,7 +18533,11 @@ function commitMutationEffects_complete(root) {
}
}
-function commitMutationEffectsOnFiber(finishedWork, root) {
+function commitMutationEffectsOnFiber(finishedWork, root, lanes) {
+ // TODO: The factoring of this phase could probably be improved. Consider
+ // switching on the type of work before checking the flags. That's what
+ // we do in all the other phases. I think this one is only different
+ // because of the shared reconciliation logic below.
var flags = finishedWork.flags;
if (flags & Ref) {
@@ -17878,6 +18546,35 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
if (current !== null) {
commitDetachRef(current);
}
+ }
+
+ if (flags & Visibility) {
+ switch (finishedWork.tag) {
+ case SuspenseComponent: {
+ var newState = finishedWork.memoizedState;
+ var isHidden = newState !== null;
+
+ if (isHidden) {
+ var _current = finishedWork.alternate;
+ var wasHidden = _current !== null && _current.memoizedState !== null;
+
+ if (!wasHidden) {
+ // TODO: Move to passive phase
+ markCommitTimeOfFallback();
+ }
+ }
+
+ break;
+ }
+
+ case OffscreenComponent: {
+ var _newState = finishedWork.memoizedState;
+
+ var _current2 = finishedWork.alternate;
+
+ var _wasHidden = _current2 !== null && _current2.memoizedState !== null;
+ }
+ }
} // 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
@@ -17900,8 +18597,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
finishedWork.flags &= ~Placement; // Update
- var _current = finishedWork.alternate;
- commitWork(_current, finishedWork);
+ var _current3 = finishedWork.alternate;
+ commitWork(_current3, finishedWork);
break;
}
@@ -17913,14 +18610,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
case HydratingAndUpdate: {
finishedWork.flags &= ~Hydrating; // Update
- var _current2 = finishedWork.alternate;
- commitWork(_current2, finishedWork);
+ var _current4 = finishedWork.alternate;
+ commitWork(_current4, finishedWork);
break;
}
case Update: {
- var _current3 = finishedWork.alternate;
- commitWork(_current3, finishedWork);
+ var _current5 = finishedWork.alternate;
+ commitWork(_current5, finishedWork);
break;
}
}
@@ -17953,9 +18650,6 @@ function commitLayoutEffects_begin(subtreeRoot, root, committedLanes) {
}
function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) {
- // Suspense layout effects semantics don't change for legacy roots.
- var isModernRoot = (subtreeRoot.mode & ConcurrentMode) !== NoMode;
-
while (nextEffect !== null) {
var fiber = nextEffect;
@@ -17966,6 +18660,7 @@ function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) {
try {
commitLayoutEffectOnFiber(root, current, fiber, committedLanes);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -18018,6 +18713,7 @@ function commitPassiveMountEffects_complete(subtreeRoot, root) {
try {
commitPassiveMountOnFiber(root, fiber);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -18267,7 +18963,7 @@ function ensureCorrectReturnPointer(fiber, expectedReturnFiber) {
// anything, by checking the warning logs for the above invariant
fiber.return = expectedReturnFiber;
-}
+} // TODO: Reuse reappearLayoutEffects traversal here?
var COMPONENT_TYPE = 0;
var HAS_PSEUDO_CLASS_TYPE = 1;
@@ -18276,43 +18972,71 @@ 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 symbolFor = Symbol.for;
+ COMPONENT_TYPE = symbolFor("selector.component");
+ HAS_PSEUDO_CLASS_TYPE = symbolFor("selector.has_pseudo_class");
+ ROLE_TYPE = symbolFor("selector.role");
+ TEST_NAME_TYPE = symbolFor("selector.test_id");
+ TEXT_TYPE = symbolFor("selector.text");
+}
+
+var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue;
+function isLegacyActEnvironment(fiber) {
+ {
+ // Legacy mode. We preserve the behavior of React 17's act. It assumes an
+ // act environment whenever `jest` is defined, but you can still turn off
+ // spurious warnings by setting IS_REACT_ACT_ENVIRONMENT explicitly
+ // to false.
+ var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
+ typeof IS_REACT_ACT_ENVIRONMENT !== "undefined"
+ ? IS_REACT_ACT_ENVIRONMENT
+ : undefined; // $FlowExpectedError - Flow doesn't know about jest
+ return warnsIfNotActing;
+ }
+}
+function isConcurrentActEnvironment() {
+ {
+ var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
+ typeof IS_REACT_ACT_ENVIRONMENT !== "undefined"
+ ? IS_REACT_ACT_ENVIRONMENT
+ : undefined;
+
+ if (!isReactActEnvironmentGlobal && ReactCurrentActQueue.current !== null) {
+ // TODO: Include link to relevant documentation page.
+ error(
+ "The current testing environment is not configured to support " +
+ "act(...)"
+ );
+ }
+
+ return isReactActEnvironmentGlobal;
+ }
}
var ceil = Math.ceil;
var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig,
- IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
+ ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue;
var NoContext =
/* */
0;
var BatchedContext =
/* */
1;
-var LegacyUnbatchedContext =
- /* */
- 4;
var RenderContext =
/* */
- 8;
+ 2;
var CommitContext =
/* */
- 16;
-var RetryAfterError =
- /* */
- 32;
-var RootIncomplete = 0;
+ 4;
+var RootInProgress = 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 RootCompleted = 5;
+var RootDidNotComplete = 6; // Describes where we are in the React execution stack
var executionContext = NoContext; // The root we're working on
@@ -18332,7 +19056,7 @@ var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to
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 workInProgressRootExitStatus = RootInProgress; // A fatal error, if one is thrown
var workInProgressRootFatalError = 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
@@ -18344,9 +19068,14 @@ var workInProgressRootIncludedLanes = NoLanes; // The work left over by componen
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 workInProgressRootInterleavedUpdatedLanes = NoLanes; // Lanes that were updated during the render phase (*not* an interleaved event).
+
+var workInProgressRootPingedLanes = NoLanes; // Errors that are thrown during the render phase.
-var workInProgressRootPingedLanes = NoLanes; // The most recent time we committed a fallback. This lets us ensure a train
+var workInProgressRootConcurrentErrors = null; // These are errors that we recovered from without surfacing them to the UI.
+// We will log them once the tree commits.
+
+var workInProgressRootRecoverableErrors = 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;
@@ -18371,7 +19100,7 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Only used when enableProfi
var rootDoesHavePassiveEffects = false;
var rootWithPendingPassiveEffects = null;
var pendingPassiveEffectsLanes = NoLanes;
-var pendingPassiveProfilerEffects = []; // Use these to prevent an infinite loop of nested updates
+var pendingPassiveProfilerEffects = [];
var NESTED_UPDATE_LIMIT = 50;
var nestedUpdateCount = 0;
@@ -18382,10 +19111,7 @@ var nestedPassiveUpdateCount = 0; // If two updates are scheduled within the sam
// between the first and second call.
var currentEventTime = NoTimestamp;
-var currentEventTransitionLane = 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 currentEventTransitionLane = NoLanes;
function getWorkInProgressRoot() {
return workInProgressRoot;
}
@@ -18428,13 +19154,22 @@ function requestUpdateLane(fiber) {
var isTransition = requestCurrentTransition() !== NoTransition;
if (isTransition) {
- // The algorithm for assigning an update to a lane should be stable for all
+ if (ReactCurrentBatchConfig$2.transition !== null) {
+ var transition = ReactCurrentBatchConfig$2.transition;
+
+ if (!transition._updatedFibers) {
+ transition._updatedFibers = new Set();
+ }
+
+ transition._updatedFibers.add(fiber);
+ } // 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.
//
// 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.
+
if (currentEventTransitionLane === NoLane) {
// All transitions within the same event are assigned the same lane.
currentEventTransitionLane = claimNextTransitionLane();
@@ -18479,79 +19214,80 @@ function requestRetryLane(fiber) {
function scheduleUpdateOnFiber(fiber, lane, eventTime) {
checkForNestedUpdates();
- warnAboutRenderPhaseUpdatesInDEV(fiber);
var root = markUpdateLaneFromFiberToRoot(fiber, lane);
if (root === null) {
- warnAboutUpdateOnUnmountedFiberInDEV(fiber);
return null;
- }
-
- {
- if (isDevToolsPresent) {
- addFiberToLanesMap(root, fiber, lane);
- }
} // 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.
- if ((executionContext & RenderContext) === NoContext) {
- workInProgressRootUpdatedLanes = mergeLanes(
- workInProgressRootUpdatedLanes,
- lane
- );
+ if (
+ (executionContext & RenderContext) !== NoLanes &&
+ root === workInProgressRoot
+ ) {
+ // This update was dispatched during the render phase. This is a mistake
+ // if the update originates from user space (with the exception of local
+ // hook updates, which are handled differently and don't reach this
+ // function), but there are some internal React features that use this as
+ // an implementation detail, like selective hydration.
+ warnAboutRenderPhaseUpdatesInDEV(fiber); // Track lanes that were updated during the render phase
+ } else {
+ // This is a normal update, scheduled from outside the render phase. For
+ // example, during an input event.
+ {
+ if (isDevToolsPresent) {
+ addFiberToLanesMap(root, fiber, 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);
+ warnIfUpdatesNotWrappedWithActDEV(fiber);
+
+ if (root === workInProgressRoot) {
+ // TODO: Consolidate with `isInterleavedUpdate` check
+ // 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.
+ if ((executionContext & RenderContext) === NoContext) {
+ workInProgressRootInterleavedUpdatedLanes = mergeLanes(
+ workInProgressRootInterleavedUpdatedLanes,
+ 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);
+ }
}
- }
- if (lane === SyncLane) {
+ ensureRootIsScheduled(root, eventTime);
+
if (
- // Check if we're inside unbatchedUpdates
- (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
- (executionContext & (RenderContext | CommitContext)) === NoContext
+ lane === SyncLane &&
+ executionContext === NoContext &&
+ (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
+ !ReactCurrentActQueue$1.isBatchingLegacy
) {
- // 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);
-
- if (
- executionContext === NoContext &&
- (fiber.mode & ConcurrentMode) === NoMode
- ) {
- // 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.
- resetRenderTimer();
- flushSyncCallbacksOnlyInLegacyMode();
- }
+ // 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.
+ resetRenderTimer();
+ flushSyncCallbacksOnlyInLegacyMode();
}
- } else {
- // Schedule other updates after in case the callback is sync.
- ensureRootIsScheduled(root, eventTime);
}
return 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.
@@ -18635,7 +19371,7 @@ function ensureRootIsScheduled(root, currentTime) {
if (nextLanes === NoLanes) {
// Special case: There's nothing to work on.
if (existingCallbackNode !== null) {
- cancelCallback(existingCallbackNode);
+ cancelCallback$1(existingCallbackNode);
}
root.callbackNode = null;
@@ -18647,7 +19383,15 @@ function ensureRootIsScheduled(root, currentTime) {
var existingCallbackPriority = root.callbackPriority;
- if (existingCallbackPriority === newCallbackPriority) {
+ if (
+ existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a
+ // Scheduler task, rather than an `act` task, cancel it and re-scheduled
+ // on the `act` queue.
+ !(
+ ReactCurrentActQueue$1.current !== null &&
+ existingCallbackNode !== fakeActCallbackNode
+ )
+ ) {
{
// If we're going to re-use an existing task, it needs to exist.
// Assume that discrete update microtasks are non-cancellable and null.
@@ -18667,7 +19411,7 @@ function ensureRootIsScheduled(root, currentTime) {
if (existingCallbackNode != null) {
// Cancel the existing callback. We'll schedule a new one below.
- cancelCallback(existingCallbackNode);
+ cancelCallback$1(existingCallbackNode);
} // Schedule a new callback.
var newCallbackNode;
@@ -18676,6 +19420,10 @@ function ensureRootIsScheduled(root, currentTime) {
// Special case: Sync React callbacks are scheduled on a special
// internal queue
if (root.tag === LegacyRoot) {
+ if (ReactCurrentActQueue$1.isBatchingLegacy !== null) {
+ ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
+ }
+
scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root));
} else {
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
@@ -18683,7 +19431,7 @@ function ensureRootIsScheduled(root, currentTime) {
{
// Flush the queue in an Immediate task.
- scheduleCallback(ImmediatePriority, flushSyncCallbacks);
+ scheduleCallback$1(ImmediatePriority, flushSyncCallbacks);
}
newCallbackNode = null;
@@ -18712,7 +19460,7 @@ function ensureRootIsScheduled(root, currentTime) {
break;
}
- newCallbackNode = scheduleCallback(
+ newCallbackNode = scheduleCallback$1(
schedulerPriorityLevel,
performConcurrentWorkOnRoot.bind(null, root)
);
@@ -18732,8 +19480,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
currentEventTime = NoTimestamp;
currentEventTransitionLane = NoLanes;
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Should not already be working.");
} // Flush any pending passive effects before deciding which lanes to work on,
// in case they schedule additional work.
@@ -18767,34 +19515,25 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
// bug we're still investigating. Once the bug in Scheduler is fixed,
// we can remove this, since we track expiration ourselves.
- var exitStatus =
- shouldTimeSlice(root, lanes) && !didTimeout
- ? renderRootConcurrent(root, lanes)
- : renderRootSync(root, lanes);
+ var shouldTimeSlice =
+ !includesBlockingLane(root, lanes) &&
+ !includesExpiredLane(root, lanes) &&
+ !didTimeout;
+ var exitStatus = shouldTimeSlice
+ ? renderRootConcurrent(root, lanes)
+ : renderRootSync(root, lanes);
- if (exitStatus !== RootIncomplete) {
+ if (exitStatus !== RootInProgress) {
if (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;
-
- {
- errorHydratingContainer(root.containerInfo);
- }
-
- 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 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 errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
if (errorRetryLanes !== NoLanes) {
lanes = errorRetryLanes;
- exitStatus = renderRootSync(root, errorRetryLanes);
+ exitStatus = recoverFromConcurrentError(root, errorRetryLanes);
}
}
@@ -18804,13 +19543,59 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
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.
+ }
+
+ if (exitStatus === RootDidNotComplete) {
+ // The render unwound without completing the tree. This happens in special
+ // cases where need to exit the current render without producing a
+ // consistent tree or committing.
+ //
+ // This should only happen during a concurrent render, not a discrete or
+ // synchronous update. We should have already checked for this when we
+ // unwound the stack.
+ markRootSuspended$1(root, lanes);
+ } else {
+ // The render completed.
+ // Check if this render may have yielded to a concurrent event, and if so,
+ // confirm that any newly rendered stores are consistent.
+ // TODO: It's possible that even a concurrent render may never have yielded
+ // to the main thread, if it was fast enough, or if it expired. We could
+ // skip the consistency check in that case, too.
+ var renderWasConcurrent = !includesBlockingLane(root, lanes);
+ var finishedWork = root.current.alternate;
+
+ if (
+ renderWasConcurrent &&
+ !isRenderConsistentWithExternalStores(finishedWork)
+ ) {
+ // A store was mutated in an interleaved event. Render again,
+ // synchronously, to block further mutations.
+ exitStatus = renderRootSync(root, lanes); // We need to check again if something threw
+
+ if (exitStatus === RootErrored) {
+ var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
+
+ if (_errorRetryLanes !== NoLanes) {
+ lanes = _errorRetryLanes;
+ exitStatus = recoverFromConcurrentError(root, _errorRetryLanes); // We assume the tree is now consistent because we didn't yield to any
+ // concurrent events.
+ }
+ }
+
+ 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 finishedWork = root.current.alternate;
- root.finishedWork = finishedWork;
- root.finishedLanes = lanes;
- finishConcurrentRender(root, exitStatus, lanes);
+ root.finishedWork = finishedWork;
+ root.finishedLanes = lanes;
+ finishConcurrentRender(root, exitStatus, lanes);
+ }
}
ensureRootIsScheduled(root, now());
@@ -18824,13 +19609,67 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
return null;
}
+function recoverFromConcurrentError(root, errorRetryLanes) {
+ // If an error occurred during hydration, discard server response and fall
+ // back to client side render.
+ // Before rendering again, save the errors from the previous attempt.
+ var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
+
+ if (isRootDehydrated(root)) {
+ // The shell failed to hydrate. Set a flag to force a client rendering
+ // during the next attempt. To do this, we call prepareFreshStack now
+ // to create the root work-in-progress fiber. This is a bit weird in terms
+ // of factoring, because it relies on renderRootSync not calling
+ // prepareFreshStack again in the call below, which happens because the
+ // root and lanes haven't changed.
+ //
+ // TODO: I think what we should do is set ForceClientRender inside
+ // throwException, like we do for nested Suspense boundaries. The reason
+ // it's here instead is so we can switch to the synchronous work loop, too.
+ // Something to consider for a future refactor.
+ var rootWorkInProgress = prepareFreshStack(root, errorRetryLanes);
+ rootWorkInProgress.flags |= ForceClientRender;
+
+ {
+ errorHydratingContainer(root.containerInfo);
+ }
+ }
+
+ var exitStatus = renderRootSync(root, errorRetryLanes);
+
+ if (exitStatus !== RootErrored) {
+ // Successfully finished rendering on retry
+ // The errors from the failed first attempt have been recovered. Add
+ // them to the collection of recoverable errors. We'll log them in the
+ // commit phase.
+ var errorsFromSecondAttempt = workInProgressRootRecoverableErrors;
+ workInProgressRootRecoverableErrors = errorsFromFirstAttempt; // The errors from the second attempt should be queued after the errors
+ // from the first attempt, to preserve the causal sequence.
+
+ if (errorsFromSecondAttempt !== null) {
+ queueRecoverableErrors(errorsFromSecondAttempt);
+ }
+ }
+
+ return exitStatus;
+}
+
+function queueRecoverableErrors(errors) {
+ if (workInProgressRootRecoverableErrors === null) {
+ workInProgressRootRecoverableErrors = errors;
+ } else {
+ workInProgressRootRecoverableErrors.push.apply(
+ workInProgressRootRecoverableErrors,
+ errors
+ );
+ }
+}
+
function finishConcurrentRender(root, exitStatus, lanes) {
switch (exitStatus) {
- case RootIncomplete:
+ case RootInProgress:
case RootFatalErrored: {
- {
- throw Error("Root did not complete. This is a bug in React.");
- }
+ throw new 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
@@ -18839,7 +19678,7 @@ function finishConcurrentRender(root, exitStatus, lanes) {
case RootErrored: {
// We should have already attempted to retry this tree. If we reached
// this point, it errored again. Commit it.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
@@ -18879,14 +19718,14 @@ function finishConcurrentRender(root, exitStatus, lanes) {
// immediately, wait for more data to arrive.
root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
msUntilTimeout
);
break;
}
} // The work expired. Commit immediately.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
@@ -18917,38 +19756,101 @@ function finishConcurrentRender(root, exitStatus, lanes) {
// Instead of committing the fallback immediately, wait for more data
// to arrive.
root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
_msUntilTimeout
);
break;
}
} // Commit the placeholder.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
case RootCompleted: {
// The work completed. Ready to commit.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
default: {
- {
- throw Error("Unknown root exit status.");
- }
+ throw new Error("Unknown root exit status.");
}
}
}
+function isRenderConsistentWithExternalStores(finishedWork) {
+ // Search the rendered tree for external store reads, and check whether the
+ // stores were mutated in a concurrent event. Intentionally using an iterative
+ // loop instead of recursion so we can exit early.
+ var node = finishedWork;
+
+ while (true) {
+ if (node.flags & StoreConsistency) {
+ var updateQueue = node.updateQueue;
+
+ if (updateQueue !== null) {
+ var checks = updateQueue.stores;
+
+ if (checks !== null) {
+ for (var i = 0; i < checks.length; i++) {
+ var check = checks[i];
+ var getSnapshot = check.getSnapshot;
+ var renderedValue = check.value;
+
+ try {
+ if (!objectIs(getSnapshot(), renderedValue)) {
+ // Found an inconsistent store.
+ return false;
+ }
+ } catch (error) {
+ // If `getSnapshot` throws, return `false`. This will schedule
+ // a re-render, and the error will be rethrown during render.
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ var child = node.child;
+
+ if (node.subtreeFlags & StoreConsistency && child !== null) {
+ child.return = node;
+ node = child;
+ continue;
+ }
+
+ if (node === finishedWork) {
+ return true;
+ }
+
+ while (node.sibling === null) {
+ if (node.return === null || node.return === finishedWork) {
+ return true;
+ }
+
+ node = node.return;
+ }
+
+ node.sibling.return = node.return;
+ node = node.sibling;
+ } // Flow doesn't know this is unreachable, but eslint does
+ // eslint-disable-next-line no-unreachable
+
+ return true;
+}
+
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);
+ suspendedLanes = removeLanes(
+ suspendedLanes,
+ workInProgressRootInterleavedUpdatedLanes
+ );
markRootSuspended(root, suspendedLanes);
} // This is the entry point for synchronous tasks that don't go
// through Scheduler
@@ -18958,8 +19860,8 @@ function performSyncWorkOnRoot(root) {
syncNestedUpdateFlag();
}
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Should not already be working.");
}
flushPassiveEffects();
@@ -18974,27 +19876,15 @@ function performSyncWorkOnRoot(root) {
var exitStatus = renderRootSync(root, lanes);
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;
-
- {
- errorHydratingContainer(root.containerInfo);
- }
-
- clearContainer(root.containerInfo);
- } // If something threw an error, try rendering one more time. We'll render
+ // 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 errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
if (errorRetryLanes !== NoLanes) {
lanes = errorRetryLanes;
- exitStatus = renderRootSync(root, lanes);
+ exitStatus = recoverFromConcurrentError(root, errorRetryLanes);
}
}
@@ -19004,13 +19894,17 @@ function performSyncWorkOnRoot(root) {
markRootSuspended$1(root, lanes);
ensureRootIsScheduled(root, now());
throw fatalError;
+ }
+
+ if (exitStatus === RootDidNotComplete) {
+ throw new Error("Root did not complete. This is a bug in React.");
} // 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
+ commitRoot(root, workInProgressRootRecoverableErrors); // Before exiting, make sure there's a callback scheduled for the next
// pending level.
ensureRootIsScheduled(root, now());
@@ -19026,24 +19920,40 @@ function batchedUpdates$1(fn, a) {
executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.
- if (executionContext === NoContext) {
+ if (
+ executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
+ !ReactCurrentActQueue$1.isBatchingLegacy
+ ) {
resetRenderTimer();
flushSyncCallbacksOnlyInLegacyMode();
}
}
}
-function flushSync(fn, a) {
+// Warning, this opts-out of checking the function body.
+
+// eslint-disable-next-line no-redeclare
+function flushSync(fn) {
+ // In legacy mode, we flush pending passive effects at the beginning of the
+ // next event, not at the end of the previous one.
+ if (
+ rootWithPendingPassiveEffects !== null &&
+ rootWithPendingPassiveEffects.tag === LegacyRoot &&
+ (executionContext & (RenderContext | CommitContext)) === NoContext
+ ) {
+ flushPassiveEffects();
+ }
+
var prevExecutionContext = executionContext;
executionContext |= BatchedContext;
var prevTransition = ReactCurrentBatchConfig$2.transition;
var previousPriority = getCurrentUpdatePriority();
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
setCurrentUpdatePriority(DiscreteEventPriority);
if (fn) {
- return fn(a);
+ return fn();
} else {
return undefined;
}
@@ -19056,14 +19966,6 @@ function flushSync(fn, a) {
if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
flushSyncCallbacks();
- } else {
- {
- 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."
- );
- }
}
}
}
@@ -19097,24 +19999,30 @@ function prepareFreshStack(root, lanes) {
var interruptedWork = workInProgress.return;
while (interruptedWork !== null) {
- unwindInterruptedWork(interruptedWork);
+ var current = interruptedWork.alternate;
+ unwindInterruptedWork(current, interruptedWork);
interruptedWork = interruptedWork.return;
}
}
workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
+ var rootWorkInProgress = createWorkInProgress(root.current, null);
+ workInProgress = rootWorkInProgress;
workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
- workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootExitStatus = RootInProgress;
workInProgressRootFatalError = null;
workInProgressRootSkippedLanes = NoLanes;
- workInProgressRootUpdatedLanes = NoLanes;
+ workInProgressRootInterleavedUpdatedLanes = NoLanes;
workInProgressRootPingedLanes = NoLanes;
+ workInProgressRootConcurrentErrors = null;
+ workInProgressRootRecoverableErrors = null;
enqueueInterleavedUpdates();
{
ReactStrictModeWarnings.discardPendingWarnings();
}
+
+ return rootWorkInProgress;
}
function handleError(root, thrownValue) {
@@ -19154,6 +20062,29 @@ function handleError(root, thrownValue) {
stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
}
+ if (enableSchedulingProfiler) {
+ markComponentRenderStopped();
+
+ if (
+ thrownValue !== null &&
+ typeof thrownValue === "object" &&
+ typeof thrownValue.then === "function"
+ ) {
+ var wakeable = thrownValue;
+ markComponentSuspended(
+ erroredWork,
+ wakeable,
+ workInProgressRootRenderLanes
+ );
+ } else {
+ markComponentErrored(
+ erroredWork,
+ thrownValue,
+ workInProgressRootRenderLanes
+ );
+ }
+ }
+
throwException(
root,
erroredWork.return,
@@ -19210,14 +20141,15 @@ function markSkippedUpdateLanes(lane) {
);
}
function renderDidSuspend() {
- if (workInProgressRootExitStatus === RootIncomplete) {
+ if (workInProgressRootExitStatus === RootInProgress) {
workInProgressRootExitStatus = RootSuspended;
}
}
function renderDidSuspendDelayIfPossible() {
if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
+ workInProgressRootExitStatus === RootInProgress ||
+ workInProgressRootExitStatus === RootSuspended ||
+ workInProgressRootExitStatus === RootErrored
) {
workInProgressRootExitStatus = RootSuspendedWithDelay;
} // Check if there are updates that we skipped tree that might have unblocked
@@ -19226,7 +20158,7 @@ function renderDidSuspendDelayIfPossible() {
if (
workInProgressRoot !== null &&
(includesNonIdleWork(workInProgressRootSkippedLanes) ||
- includesNonIdleWork(workInProgressRootUpdatedLanes))
+ includesNonIdleWork(workInProgressRootInterleavedUpdatedLanes))
) {
// 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
@@ -19238,17 +20170,23 @@ function renderDidSuspendDelayIfPossible() {
markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
}
}
-function renderDidError() {
- if (workInProgressRootExitStatus !== RootCompleted) {
+function renderDidError(error) {
+ if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
workInProgressRootExitStatus = RootErrored;
}
+
+ if (workInProgressRootConcurrentErrors === null) {
+ workInProgressRootConcurrentErrors = [error];
+ } else {
+ workInProgressRootConcurrentErrors.push(error);
+ }
} // Called during render to determine if anything has suspended.
// Returns false if we're not sure.
function renderHasNotSuspendedYet() {
// If something errored or completed, we can't really be sure,
// so those are false.
- return workInProgressRootExitStatus === RootIncomplete;
+ return workInProgressRootExitStatus === RootInProgress;
}
function renderRootSync(root, lanes) {
@@ -19273,7 +20211,6 @@ function renderRootSync(root, lanes) {
movePendingFibersToMemoized(root, lanes);
}
}
-
prepareFreshStack(root, lanes);
}
@@ -19292,11 +20229,10 @@ function renderRootSync(root, lanes) {
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."
- );
- }
+ throw new Error(
+ "Cannot commit an incomplete root. This error is likely caused by a " +
+ "bug in React. Please file an issue."
+ );
}
workInProgressRoot = null;
@@ -19335,7 +20271,6 @@ function renderRootConcurrent(root, lanes) {
movePendingFibersToMemoized(root, lanes);
}
}
-
resetRenderTimer();
prepareFreshStack(root, lanes);
}
@@ -19354,7 +20289,7 @@ function renderRootConcurrent(root, lanes) {
executionContext = prevExecutionContext;
if (workInProgress !== null) {
- return RootIncomplete;
+ return RootInProgress;
} else {
workInProgressRoot = null;
workInProgressRootRenderLanes = NoLanes; // Return the final exit status.
@@ -19436,7 +20371,7 @@ function completeUnitOfWork(unitOfWork) {
// 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 lanes.
+ var _next = unwindWork(current, completedWork); // Because this fiber did not complete, don't reset its lanes.
if (_next !== null) {
// If completing this work spawned new work, do that next. We'll come
@@ -19468,6 +20403,11 @@ function completeUnitOfWork(unitOfWork) {
returnFiber.flags |= Incomplete;
returnFiber.subtreeFlags = NoFlags;
returnFiber.deletions = null;
+ } else {
+ // We've unwound all the way to the root.
+ workInProgressRootExitStatus = RootDidNotComplete;
+ workInProgress = null;
+ return;
}
}
@@ -19484,21 +20424,21 @@ function completeUnitOfWork(unitOfWork) {
workInProgress = completedWork;
} while (completedWork !== null); // We've reached the root.
- if (workInProgressRootExitStatus === RootIncomplete) {
+ if (workInProgressRootExitStatus === RootInProgress) {
workInProgressRootExitStatus = RootCompleted;
}
}
-function commitRoot(root) {
+function commitRoot(root, recoverableErrors) {
// TODO: This no longer makes any sense. We already wrap the mutation and
// layout phases. Should be able to remove.
var previousUpdateLanePriority = getCurrentUpdatePriority();
var prevTransition = ReactCurrentBatchConfig$2.transition;
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
setCurrentUpdatePriority(DiscreteEventPriority);
- commitRootImpl(root, previousUpdateLanePriority);
+ commitRootImpl(root, recoverableErrors, previousUpdateLanePriority);
} finally {
ReactCurrentBatchConfig$2.transition = prevTransition;
setCurrentUpdatePriority(previousUpdateLanePriority);
@@ -19507,7 +20447,7 @@ function commitRoot(root) {
return null;
}
-function commitRootImpl(root, renderPriorityLevel) {
+function commitRootImpl(root, recoverableErrors, renderPriorityLevel) {
do {
// `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
// means `flushPassiveEffects` will sometimes result in additional
@@ -19520,8 +20460,8 @@ function commitRootImpl(root, renderPriorityLevel) {
flushRenderPhaseStrictModeWarningsInDEV();
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Should not already be working.");
}
var finishedWork = root.finishedWork;
@@ -19543,9 +20483,10 @@ function commitRootImpl(root, renderPriorityLevel) {
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."
+ if (finishedWork === root.current) {
+ throw new 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.
@@ -19574,8 +20515,11 @@ function commitRootImpl(root, renderPriorityLevel) {
) {
if (!rootDoesHavePassiveEffects) {
rootDoesHavePassiveEffects = true;
- scheduleCallback(NormalPriority, function() {
- flushPassiveEffects();
+ scheduleCallback$1(NormalPriority, function() {
+ flushPassiveEffects(); // This render triggered passive effects: release the root cache pool
+ // *after* passive effects fire to avoid freeing a cache pool that may
+ // be referenced by a node in the tree (HostRoot, Cache boundary etc)
+
return null;
});
}
@@ -19596,7 +20540,7 @@ function commitRootImpl(root, renderPriorityLevel) {
if (subtreeHasEffects || rootHasEffect) {
var prevTransition = ReactCurrentBatchConfig$2.transition;
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
var previousPriority = getCurrentUpdatePriority();
setCurrentUpdatePriority(DiscreteEventPriority);
var prevExecutionContext = executionContext;
@@ -19657,6 +20601,15 @@ function commitRootImpl(root, renderPriorityLevel) {
} // Read this again, since an effect might have updated it
remainingLanes = root.pendingLanes; // Check if there's remaining work on this root
+ // TODO: This is part of the `componentDidCatch` implementation. Its purpose
+ // is to detect whether something might have called setState inside
+ // `componentDidCatch`. The mechanism is known to be flawed because `setState`
+ // inside `componentDidCatch` is itself flawed — that's why we recommend
+ // `getDerivedStateFromError` instead. However, it could be improved by
+ // checking if remainingLanes includes Sync work, instead of whether there's
+ // any work remaining at all (which would also include stuff like Suspense
+ // retries or transitions). It's been like this for a while, though, so fixing
+ // it probably isn't that urgent.
if (remainingLanes === NoLanes) {
// If there's no remaining work, we can clear the set of already failed
@@ -19664,22 +20617,6 @@ function commitRootImpl(root, renderPriorityLevel) {
legacyErrorBoundariesThatAlreadyFailed = null;
}
- if (includesSomeLane(remainingLanes, SyncLane)) {
- {
- markNestedUpdateScheduled();
- } // 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;
- }
-
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
{
@@ -19691,19 +20628,22 @@ function commitRootImpl(root, renderPriorityLevel) {
ensureRootIsScheduled(root, now());
+ if (recoverableErrors !== null) {
+ // There were errors during this render, but recovered from them without
+ // needing to surface it to the UI. We log them here.
+ var onRecoverableError = root.onRecoverableError;
+
+ for (var i = 0; i < recoverableErrors.length; i++) {
+ var recoverableError = recoverableErrors[i];
+ onRecoverableError(recoverableError);
+ }
+ }
+
if (hasUncaughtError) {
hasUncaughtError = false;
var error$1 = firstUncaughtError;
firstUncaughtError = null;
throw error$1;
- }
-
- 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.
-
- return null;
} // If the passive effects are the result of a discrete render, flush them
// synchronously at the end of the current task so that the result is
// immediately observable. Otherwise, we assume that they are not
@@ -19718,6 +20658,24 @@ function commitRootImpl(root, renderPriorityLevel) {
root.tag !== LegacyRoot
) {
flushPassiveEffects();
+ } // Read this again, since a passive effect might have updated it
+
+ remainingLanes = root.pendingLanes;
+
+ if (includesSomeLane(remainingLanes, SyncLane)) {
+ {
+ markNestedUpdateScheduled();
+ } // 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 layout work was scheduled, flush it now.
flushSyncCallbacks();
@@ -19739,12 +20697,12 @@ function flushPassiveEffects() {
var previousPriority = getCurrentUpdatePriority();
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
setCurrentUpdatePriority(priority);
return flushPassiveEffectsImpl();
} finally {
setCurrentUpdatePriority(previousPriority);
- ReactCurrentBatchConfig$2.transition = prevTransition;
+ ReactCurrentBatchConfig$2.transition = prevTransition; // Once passive effects have run for the tree - giving components a
}
}
@@ -19756,7 +20714,7 @@ function enqueuePendingPassiveProfilerEffect(fiber) {
if (!rootDoesHavePassiveEffects) {
rootDoesHavePassiveEffects = true;
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
});
@@ -19776,12 +20734,8 @@ function flushPassiveEffectsImpl() {
pendingPassiveEffectsLanes = NoLanes;
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Cannot flush passive effects while already rendering.");
- }
-
- {
- isFlushingPassiveEffects = true;
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Cannot flush passive effects while already rendering.");
}
var prevExecutionContext = executionContext;
@@ -19799,10 +20753,6 @@ function flushPassiveEffectsImpl() {
}
}
- {
- isFlushingPassiveEffects = false;
- }
-
executionContext = prevExecutionContext;
flushSyncCallbacks(); // If additional passive effects were scheduled, increment a counter. If this
// exceeds the limit, we'll fire a warning.
@@ -19929,6 +20879,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) {
var eventTime = requestEventTime();
markRootPinged(root, pingedLanes);
+ warnIfSuspenseResolutionNotWrappedWithActDEV(root);
if (
workInProgressRoot === root &&
@@ -20027,12 +20978,12 @@ function checkForNestedUpdates() {
if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
nestedUpdateCount = 0;
rootWithNestedUpdates = 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."
- );
- }
+ throw new 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."
+ );
}
{
@@ -20095,107 +21046,27 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
return;
}
- didWarnStateUpdateForNotYetMountedComponent.add(componentName);
- } else {
- didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
- }
-
- 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 didWarnStateUpdateForUnmountedComponent = null;
-
-function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
- {
- var tag = fiber.tag;
-
- if (
- tag !== HostRoot &&
- tag !== ClassComponent &&
- tag !== FunctionComponent &&
- tag !== ForwardRef &&
- tag !== MemoComponent &&
- tag !== SimpleMemoComponent
- ) {
- // Only warn for user-defined components, not internal ones like Suspense.
- return;
- }
-
- if ((fiber.flags & PassiveStatic) !== NoFlags) {
- var updateQueue = fiber.updateQueue;
-
- if (updateQueue !== null) {
- var lastEffect = updateQueue.lastEffect;
-
- if (lastEffect !== null) {
- var firstEffect = lastEffect.next;
- var effect = firstEffect;
-
- do {
- if (effect.destroy !== undefined) {
- if ((effect.tag & Passive$1) !== NoFlags$1) {
- return;
- }
- }
-
- effect = effect.next;
- } while (effect !== firstEffect);
- }
- }
- } // We show the whole stack but dedupe on the top component's name because
- // the problematic code almost always lies inside that component.
-
- var componentName = getComponentNameFromFiber(fiber) || "ReactComponent";
-
- if (didWarnStateUpdateForUnmountedComponent !== null) {
- if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
- return;
- }
-
- didWarnStateUpdateForUnmountedComponent.add(componentName);
+ didWarnStateUpdateForNotYetMountedComponent.add(componentName);
} else {
- didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
+ didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
}
- if (isFlushingPassiveEffects);
- else {
- var previousFiber = current;
+ var previousFiber = current;
- try {
- setCurrentFiber(fiber);
+ 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();
- }
+ 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();
}
}
}
@@ -20235,7 +21106,7 @@ var beginWork$1;
// same fiber again.
// Unwind the failed stack frame
- unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
+ unwindInterruptedWork(current, unitOfWork); // Restore the original properties of the fiber.
assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
@@ -20261,7 +21132,7 @@ var beginWork$1;
originalError._suppressLogging = true;
}
} // We always throw the original error in case the second render pass is not idempotent.
- // This can happen if a memoized function or CommonJS module doesn't throw after first invokation.
+ // This can happen if a memoized function or CommonJS module doesn't throw after first invocation.
throw originalError;
}
@@ -20277,11 +21148,7 @@ var didWarnAboutUpdateInRenderForAnotherComponent;
function warnAboutRenderPhaseUpdatesInDEV(fiber) {
{
- if (
- isRendering &&
- (executionContext & RenderContext) !== NoContext &&
- !getIsUpdatingOpaqueValueInRenderPhaseInDEV()
- ) {
+ if (isRendering && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) {
switch (fiber.tag) {
case FunctionComponent:
case ForwardRef:
@@ -20326,7 +21193,8 @@ function warnAboutRenderPhaseUpdatesInDEV(fiber) {
}
}
}
-} // a 'shared' variable that changes when act() opens/closes in tests.
+}
+
function restorePendingUpdaters(root, lanes) {
{
if (isDevToolsPresent) {
@@ -20339,42 +21207,122 @@ function restorePendingUpdaters(root, lanes) {
}
}
}
+var fakeActCallbackNode = {};
-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 scheduleCallback$1(priorityLevel, callback) {
+ {
+ // If we're currently inside an `act` scope, bypass Scheduler and push to
+ // the `act` queue instead.
+ var actQueue = ReactCurrentActQueue$1.current;
+
+ if (actQueue !== null) {
+ actQueue.push(callback);
+ return fakeActCallbackNode;
+ } else {
+ return scheduleCallback(priorityLevel, callback);
+ }
+ }
+}
+
+function cancelCallback$1(callbackNode) {
+ if (callbackNode === fakeActCallbackNode) {
+ return;
+ } // In production, always call Scheduler. This function will be stripped out.
-function warnIfUnmockedScheduler(fiber) {
+ return cancelCallback(callbackNode);
+}
+
+function shouldForceFlushFallbacksInDEV() {
+ // Never force flush in production. This function should get stripped out.
+ return ReactCurrentActQueue$1.current !== null;
+}
+
+function warnIfUpdatesNotWrappedWithActDEV(fiber) {
{
- if (
- didWarnAboutUnmockedScheduler === false &&
- Scheduler.unstable_flushAllWithoutAsserting === undefined
- ) {
- if (fiber.mode & ConcurrentMode) {
- didWarnAboutUnmockedScheduler = true;
+ if (fiber.mode & ConcurrentMode) {
+ if (!isConcurrentActEnvironment()) {
+ // Not in an act environment. No need to warn.
+ return;
+ }
+ } else {
+ // Legacy mode has additional cases where we suppress a warning.
+ if (!isLegacyActEnvironment()) {
+ // Not in an act environment. No need to warn.
+ return;
+ }
+
+ if (executionContext !== NoContext) {
+ // Legacy mode doesn't warn if the update is batched, i.e.
+ // batchedUpdates or flushSync.
+ return;
+ }
+
+ if (
+ fiber.tag !== FunctionComponent &&
+ fiber.tag !== ForwardRef &&
+ fiber.tag !== SimpleMemoComponent
+ ) {
+ // For backwards compatibility with pre-hooks code, legacy mode only
+ // warns for updates that originate from a hook.
+ return;
+ }
+ }
+
+ if (ReactCurrentActQueue$1.current === null) {
+ var previousFiber = current;
+
+ try {
+ setCurrentFiber(fiber);
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://reactjs.org/link/mock-scheduler"
+ "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://reactjs.org/link/wrap-tests-with-act",
+ getComponentNameFromFiber(fiber)
);
+ } finally {
+ if (previousFiber) {
+ setCurrentFiber(fiber);
+ } else {
+ resetCurrentFiber();
+ }
}
}
}
-} // `act` testing API
-
-function shouldForceFlushFallbacksInDEV() {
- // Never force flush in production. This function should get stripped out.
- return actingUpdatesScopeDepth > 0;
}
-// so we can tell if any async act() calls try to run in parallel.
-var actingUpdatesScopeDepth = 0;
+function warnIfSuspenseResolutionNotWrappedWithActDEV(root) {
+ {
+ if (
+ root.tag !== LegacyRoot &&
+ isConcurrentActEnvironment() &&
+ ReactCurrentActQueue$1.current === null
+ ) {
+ error(
+ "A suspended resource finished loading inside a test, but the event " +
+ "was not wrapped in act(...).\n\n" +
+ "When testing, code that resolves suspended data should be wrapped " +
+ "into act(...):\n\n" +
+ "act(() => {\n" +
+ " /* finish loading suspended data */\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://reactjs.org/link/wrap-tests-with-act"
+ );
+ }
+ }
+}
+/* eslint-disable react-internal/prod-error-codes */
var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
var failedBoundaries = null;
@@ -21162,11 +22110,6 @@ function createFiberFromTypeAndProps(
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_DEBUG_TRACING_MODE_TYPE:
- fiberTag = Mode;
- mode |= DebugTracingMode;
- break;
-
case REACT_STRICT_MODE_TYPE:
fiberTag = Mode;
mode |= StrictLegacyMode;
@@ -21186,7 +22129,8 @@ function createFiberFromTypeAndProps(
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
case REACT_LEGACY_HIDDEN_TYPE:
- return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
+
+ // eslint-disable-next-line no-fallthrough
case REACT_SCOPE_TYPE:
@@ -21196,6 +22140,14 @@ function createFiberFromTypeAndProps(
// eslint-disable-next-line no-fallthrough
+ case REACT_TRACING_MARKER_TYPE:
+
+ // eslint-disable-next-line no-fallthrough
+
+ case REACT_DEBUG_TRACING_MODE_TYPE:
+
+ // eslint-disable-next-line no-fallthrough
+
default: {
if (typeof type === "object" && type !== null) {
switch (type.$$typeof) {
@@ -21250,14 +22202,11 @@ function createFiberFromTypeAndProps(
}
}
- {
- throw Error(
- "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- (type == null ? type : typeof type) +
- "." +
- info
- );
- }
+ throw new Error(
+ "Element type is invalid: expected a string (for built-in " +
+ "components) or a class/function (for composite components) " +
+ ("but got: " + (type == null ? type : typeof type) + "." + info)
+ );
}
}
}
@@ -21345,12 +22294,8 @@ function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
var fiber = createFiber(OffscreenComponent, pendingProps, key, mode);
fiber.elementType = REACT_OFFSCREEN_TYPE;
fiber.lanes = lanes;
- return fiber;
-}
-function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) {
- var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode);
- fiber.elementType = REACT_LEGACY_HIDDEN_TYPE;
- fiber.lanes = lanes;
+ var primaryChildInstance = {};
+ fiber.stateNode = primaryChildInstance;
return fiber;
}
function createFiberFromText(content, mode, lanes) {
@@ -21419,7 +22364,13 @@ function assignFiberPropertiesInDEV(target, source) {
return target;
}
-function FiberRootNode(containerInfo, tag, hydrate) {
+function FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+) {
this.tag = tag;
this.containerInfo = containerInfo;
this.pendingChildren = null;
@@ -21429,7 +22380,6 @@ function FiberRootNode(containerInfo, tag, hydrate) {
this.timeoutHandle = noTimeout;
this.context = null;
this.pendingContext = null;
- this.hydrate = hydrate;
this.callbackNode = null;
this.callbackPriority = NoLane;
this.eventTimes = createLaneMap(NoLanes);
@@ -21442,6 +22392,8 @@ function FiberRootNode(containerInfo, tag, hydrate) {
this.finishedLanes = NoLanes;
this.entangledLanes = NoLanes;
this.entanglements = createLaneMap(NoLanes);
+ this.identifierPrefix = identifierPrefix;
+ this.onRecoverableError = onRecoverableError;
{
this.effectDuration = 0;
@@ -21452,7 +22404,7 @@ function FiberRootNode(containerInfo, tag, hydrate) {
this.memoizedUpdaters = new Set();
var pendingUpdatersLaneMap = (this.pendingUpdatersLaneMap = []);
- for (var i = 0; i < TotalLanes; i++) {
+ for (var _i = 0; _i < TotalLanes; _i++) {
pendingUpdatersLaneMap.push(new Set());
}
}
@@ -21460,11 +22412,11 @@ function FiberRootNode(containerInfo, tag, hydrate) {
{
switch (tag) {
case ConcurrentRoot:
- this._debugRootType = "createRoot()";
+ this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;
case LegacyRoot:
- this._debugRootType = "createLegacyRoot()";
+ this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
}
}
@@ -21474,11 +22426,24 @@ function createFiberRoot(
containerInfo,
tag,
hydrate,
+ initialChildren,
hydrationCallbacks,
isStrictMode,
- concurrentUpdatesByDefaultOverride
+ concurrentUpdatesByDefaultOverride, // TODO: We have several of these arguments that are conceptually part of the
+ // host config, but because they are passed in at runtime, we have to thread
+ // them through the root constructor. Perhaps we should put them all into a
+ // single type, like a DynamicHostConfig that is defined by the renderer.
+ identifierPrefix,
+ onRecoverableError,
+ transitionCallbacks
) {
- var root = new FiberRootNode(containerInfo, tag, hydrate);
+ var root = new FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+ );
// stateNode is any.
var uninitializedFiber = createHostRootFiber(tag, isStrictMode);
@@ -21487,7 +22452,11 @@ function createFiberRoot(
{
var _initialState = {
- element: null
+ element: initialChildren,
+ isDehydrated: hydrate,
+ cache: null,
+ // not enabled yet
+ transitions: null
};
uninitializedFiber.memoizedState = _initialState;
}
@@ -21496,6 +22465,8 @@ function createFiberRoot(
return root;
}
+var ReactVersion = "18.0.0-34aa5cfe0-20220329";
+
function createPortal(
children,
containerInfo, // TODO: figure out the API for cross-renderer implementation.
@@ -21503,6 +22474,11 @@ function createPortal(
) {
var key =
arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
+
+ {
+ checkKeyStringCoercion(key);
+ }
+
return {
// This tag allow us to uniquely identify this as a React Portal
$$typeof: REACT_PORTAL_TYPE,
@@ -21546,16 +22522,12 @@ function findHostInstanceWithWarning(component, methodName) {
if (fiber === undefined) {
if (typeof component.render === "function") {
- {
- throw Error("Unable to find node on an unmounted component.");
- }
+ throw new Error("Unable to find node on an unmounted component.");
} else {
- {
- throw Error(
- "Argument appears to not be a ReactComponent. Keys: " +
- Object.keys(component)
- );
- }
+ var keys = Object.keys(component).join(",");
+ throw new Error(
+ "Argument appears to not be a ReactComponent. Keys: " + keys
+ );
}
}
@@ -21617,17 +22589,25 @@ function findHostInstanceWithWarning(component, methodName) {
function createContainer(
containerInfo,
tag,
- hydrate,
hydrationCallbacks,
isStrictMode,
- concurrentUpdatesByDefaultOverride
+ concurrentUpdatesByDefaultOverride,
+ identifierPrefix,
+ onRecoverableError,
+ transitionCallbacks
) {
+ var hydrate = false;
+ var initialChildren = null;
return createFiberRoot(
containerInfo,
tag,
hydrate,
+ initialChildren,
hydrationCallbacks,
- isStrictMode
+ isStrictMode,
+ concurrentUpdatesByDefaultOverride,
+ identifierPrefix,
+ onRecoverableError
);
}
function updateContainer(element, container, parentComponent, callback) {
@@ -21637,14 +22617,6 @@ function updateContainer(element, container, parentComponent, callback) {
var current$1 = container.current;
var eventTime = requestEventTime();
-
- {
- // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ("undefined" !== typeof jest) {
- warnIfUnmockedScheduler(current$1);
- }
- }
-
var lane = requestUpdateLane(current$1);
var context = getContextForSubtree(parentComponent);
@@ -21744,7 +22716,7 @@ var setSuspenseHandler = null;
{
var copyWithDeleteImpl = function(obj, path, index) {
var key = path[index];
- var updated = isArray(obj) ? obj.slice() : Object.assign({}, obj);
+ var updated = isArray(obj) ? obj.slice() : assign({}, obj);
if (index + 1 === path.length) {
if (isArray(updated)) {
@@ -21766,7 +22738,7 @@ var setSuspenseHandler = null;
var copyWithRenameImpl = function(obj, oldPath, newPath, index) {
var oldKey = oldPath[index];
- var updated = isArray(obj) ? obj.slice() : Object.assign({}, obj);
+ var updated = isArray(obj) ? obj.slice() : assign({}, obj);
if (index + 1 === oldPath.length) {
var newKey = newPath[index]; // $FlowFixMe number or string is fine here
@@ -21818,7 +22790,7 @@ var setSuspenseHandler = null;
}
var key = path[index];
- var updated = isArray(obj) ? obj.slice() : Object.assign({}, obj); // $FlowFixMe number or string is fine here
+ var updated = isArray(obj) ? obj.slice() : assign({}, obj); // $FlowFixMe number or string is fine here
updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
return updated;
@@ -21853,7 +22825,7 @@ var setSuspenseHandler = null;
// As a result though, React will see the scheduled update as a noop and bailout.
// Shallow cloning props works as a workaround for now to bypass the bailout check.
- fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
+ fiber.memoizedProps = assign({}, fiber.memoizedProps);
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
};
@@ -21870,7 +22842,7 @@ var setSuspenseHandler = null;
// As a result though, React will see the scheduled update as a noop and bailout.
// Shallow cloning props works as a workaround for now to bypass the bailout check.
- fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
+ fiber.memoizedProps = assign({}, fiber.memoizedProps);
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
};
@@ -21887,7 +22859,7 @@ var setSuspenseHandler = null;
// As a result though, React will see the scheduled update as a noop and bailout.
// Shallow cloning props works as a workaround for now to bypass the bailout check.
- fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
+ fiber.memoizedProps = assign({}, fiber.memoizedProps);
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
}; // Support DevTools props for function components, forwardRef, memo, host components, etc.
@@ -21999,65 +22971,16 @@ var emptyObject$1 = {};
Object.freeze(emptyObject$1);
}
-var getInspectorDataForViewTag;
-var getInspectorDataForViewAtPoint;
-
-{
- var traverseOwnerTreeUp = function(hierarchy, instance) {
- if (instance) {
- hierarchy.unshift(instance);
- traverseOwnerTreeUp(hierarchy, instance._debugOwner);
- }
- };
-
- var getOwnerHierarchy = function(instance) {
- var hierarchy = [];
- traverseOwnerTreeUp(hierarchy, instance);
- return hierarchy;
- };
-
- var lastNonHostInstance = function(hierarchy) {
- for (var i = hierarchy.length - 1; i > 1; i--) {
- var instance = hierarchy[i];
-
- if (instance.tag !== HostComponent) {
- return instance;
- }
- }
-
- return hierarchy[0];
- };
-
- var getHostProps = function(fiber) {
- var host = findCurrentHostFiber(fiber);
-
- if (host) {
- return host.memoizedProps || emptyObject$1;
- }
-
- return emptyObject$1;
- };
-
- var getHostNode = function(fiber, findNodeHandle) {
- var hostNode; // look for children first for the hostNode
- // as composite fibers do not have a hostNode
-
- while (fiber) {
- if (fiber.stateNode !== null && fiber.tag === HostComponent) {
- hostNode = findNodeHandle(fiber.stateNode);
- }
-
- if (hostNode) {
- return hostNode;
- }
-
- fiber = fiber.child;
- }
+var createHierarchy;
+var getHostNode;
+var getHostProps;
+var lastNonHostInstance;
- return null;
- };
+var getOwnerHierarchy;
+var traverseOwnerTreeUp;
- var createHierarchy = function(fiberHierarchy) {
+{
+ createHierarchy = function(fiberHierarchy) {
return fiberHierarchy.map(function(fiber) {
return {
name: getComponentNameFromType(fiber.type),
@@ -22088,7 +23011,36 @@ var getInspectorDataForViewAtPoint;
});
};
- var getInspectorDataForInstance = function(closestInstance) {
+ getHostNode = function(fiber, findNodeHandle) {
+ var hostNode; // look for children first for the hostNode
+ // as composite fibers do not have a hostNode
+
+ while (fiber) {
+ if (fiber.stateNode !== null && fiber.tag === HostComponent) {
+ hostNode = findNodeHandle(fiber.stateNode);
+ }
+
+ if (hostNode) {
+ return hostNode;
+ }
+
+ fiber = fiber.child;
+ }
+
+ return null;
+ };
+
+ getHostProps = function(fiber) {
+ var host = findCurrentHostFiber(fiber);
+
+ if (host) {
+ return host.memoizedProps || emptyObject$1;
+ }
+
+ return emptyObject$1;
+ };
+
+ exports.getInspectorDataForInstance = function(closestInstance) {
// Handle case where user clicks outside of ReactNative
if (!closestInstance) {
return {
@@ -22114,6 +23066,36 @@ var getInspectorDataForViewAtPoint;
};
};
+ getOwnerHierarchy = function(instance) {
+ var hierarchy = [];
+ traverseOwnerTreeUp(hierarchy, instance);
+ return hierarchy;
+ };
+
+ lastNonHostInstance = function(hierarchy) {
+ for (var i = hierarchy.length - 1; i > 1; i--) {
+ var instance = hierarchy[i];
+
+ if (instance.tag !== HostComponent) {
+ return instance;
+ }
+ }
+
+ return hierarchy[0];
+ };
+
+ traverseOwnerTreeUp = function(hierarchy, instance) {
+ if (instance) {
+ hierarchy.unshift(instance);
+ traverseOwnerTreeUp(hierarchy, instance._debugOwner);
+ }
+ };
+}
+
+var getInspectorDataForViewTag;
+var getInspectorDataForViewAtPoint;
+
+{
getInspectorDataForViewTag = function(viewTag) {
var closestInstance = getInstanceFromTag(viewTag); // Handle case where user clicks outside of ReactNative
@@ -22159,7 +23141,7 @@ var getInspectorDataForViewAtPoint;
function(internalInstanceHandle) {
if (internalInstanceHandle == null) {
callback(
- Object.assign(
+ assign(
{
pointerY: locationY,
frame: {
@@ -22169,7 +23151,7 @@ var getInspectorDataForViewAtPoint;
height: 0
}
},
- getInspectorDataForInstance(closestInstance)
+ exports.getInspectorDataForInstance(closestInstance)
)
);
}
@@ -22182,9 +23164,11 @@ var getInspectorDataForViewAtPoint;
nativeFabricUIManager.measure(
internalInstanceHandle.stateNode.node,
function(x, y, width, height, pageX, pageY) {
- var inspectorData = getInspectorDataForInstance(closestInstance);
+ var inspectorData = exports.getInspectorDataForInstance(
+ closestInstance
+ );
callback(
- Object.assign({}, inspectorData, {
+ assign({}, inspectorData, {
pointerY: locationY,
frame: {
left: pageX,
@@ -22205,11 +23189,11 @@ var getInspectorDataForViewAtPoint;
findNodeHandle(inspectedView),
[locationX, locationY],
function(nativeViewTag, left, top, width, height) {
- var inspectorData = getInspectorDataForInstance(
+ var inspectorData = exports.getInspectorDataForInstance(
getInstanceFromTag(nativeViewTag)
);
callback(
- Object.assign({}, inspectorData, {
+ assign({}, inspectorData, {
pointerY: locationY,
frame: {
left: left,
@@ -22360,12 +23344,12 @@ function dispatchCommand(handle, command, args) {
return;
}
- if (handle._internalInstanceHandle) {
- nativeFabricUIManager.dispatchCommand(
- handle._internalInstanceHandle.stateNode.node,
- command,
- args
- );
+ if (handle._internalInstanceHandle != null) {
+ var stateNode = handle._internalInstanceHandle.stateNode;
+
+ if (stateNode != null) {
+ nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
+ }
} else {
ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand(
handle._nativeTag,
@@ -22387,11 +23371,12 @@ function sendAccessibilityEvent(handle, eventType) {
return;
}
- if (handle._internalInstanceHandle) {
- nativeFabricUIManager.sendAccessibilityEvent(
- handle._internalInstanceHandle.stateNode.node,
- eventType
- );
+ if (handle._internalInstanceHandle != null) {
+ var stateNode = handle._internalInstanceHandle.stateNode;
+
+ if (stateNode != null) {
+ nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
+ }
} else {
ReactNativePrivateInterface.legacySendAccessibilityEvent(
handle._nativeTag,
@@ -22400,6 +23385,12 @@ function sendAccessibilityEvent(handle, eventType) {
}
}
+function onRecoverableError(error$1) {
+ // TODO: Expose onRecoverableError option to userspace
+ // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
+ error(error$1);
+}
+
function render(element, containerTag, callback, concurrentRoot) {
var root = roots.get(containerTag);
@@ -22409,9 +23400,11 @@ function render(element, containerTag, callback, concurrentRoot) {
root = createContainer(
containerTag,
concurrentRoot ? ConcurrentRoot : LegacyRoot,
+ null,
false,
null,
- false
+ "",
+ onRecoverableError
);
roots.set(containerTag, root);
}
@@ -22467,5 +23460,14 @@ exports.sendAccessibilityEvent = sendAccessibilityEvent;
exports.stopSurface = stopSurface;
exports.unmountComponentAtNode = unmountComponentAtNode;
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
+}
+
})();
}
diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.js b/Libraries/Renderer/implementations/ReactFabric-prod.js
index 058a5e17800710..679ac7c7a33f14 100644
--- a/Libraries/Renderer/implementations/ReactFabric-prod.js
+++ b/Libraries/Renderer/implementations/ReactFabric-prod.js
@@ -1,5 +1,5 @@
/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@@ -8,7 +8,7 @@
* @nolint
* @providesModule ReactFabric-prod
* @preventMunge
- * @generated SignedSource<<5749c2b90feb6b0a0271a28ccf62b138>>
+ * @generated SignedSource<<3337b7b8b4a72069e657cf2646bcff44>>
*/
"use strict";
@@ -87,6 +87,7 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
+var assign = Object.assign;
function functionThatReturnsTrue() {
return !0;
}
@@ -119,7 +120,7 @@ function SyntheticEvent(
this.isPropagationStopped = functionThatReturnsFalse;
return this;
}
-Object.assign(SyntheticEvent.prototype, {
+assign(SyntheticEvent.prototype, {
preventDefault: function() {
this.defaultPrevented = !0;
var event = this.nativeEvent;
@@ -173,10 +174,10 @@ SyntheticEvent.extend = function(Interface) {
var Super = this;
E.prototype = Super.prototype;
var prototype = new E();
- Object.assign(prototype, Class.prototype);
+ assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = Object.assign({}, Super.Interface, Interface);
+ Class.Interface = assign({}, Super.Interface, Interface);
Class.extend = Super.extend;
addEventPoolingTo(Class);
return Class;
@@ -783,18 +784,16 @@ function recomputePluginOrdering() {
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName],
pluginIndex = eventPluginOrder.indexOf(pluginName);
- if (!(-1 < pluginIndex))
+ if (-1 >= pluginIndex)
throw Error(
"EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" +
- pluginName +
- "`."
+ (pluginName + "`.")
);
if (!plugins[pluginIndex]) {
if (!pluginModule.extractEvents)
throw Error(
"EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" +
- pluginName +
- "` does not."
+ (pluginName + "` does not.")
);
plugins[pluginIndex] = pluginModule;
pluginIndex = pluginModule.eventTypes;
@@ -805,8 +804,7 @@ function recomputePluginOrdering() {
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same event name, `" +
- eventName$jscomp$0 +
- "`."
+ (eventName$jscomp$0 + "`.")
);
eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
@@ -846,18 +844,22 @@ function publishRegistrationName(registrationName, pluginModule) {
if (registrationNameModules[registrationName])
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" +
- registrationName +
- "`."
+ (registrationName + "`.")
);
registrationNameModules[registrationName] = pluginModule;
}
var plugins = [],
eventNameDispatchConfigs = {},
registrationNameModules = {};
-function getListener$1(inst, registrationName) {
- inst = inst.stateNode;
- if (null === inst) return null;
- inst = getFiberCurrentPropsFromNode(inst);
+function getListeners(
+ inst,
+ registrationName,
+ phase,
+ dispatchToImperativeListeners
+) {
+ var stateNode = inst.stateNode;
+ if (null === stateNode) return null;
+ inst = getFiberCurrentPropsFromNode(stateNode);
if (null === inst) return null;
if ((inst = inst[registrationName]) && "function" !== typeof inst)
throw Error(
@@ -867,7 +869,67 @@ function getListener$1(inst, registrationName) {
typeof inst +
"` type."
);
- return inst;
+ if (
+ !(
+ dispatchToImperativeListeners &&
+ stateNode.canonical &&
+ stateNode.canonical._eventListeners
+ )
+ )
+ return inst;
+ var listeners = [];
+ inst && listeners.push(inst);
+ var requestedPhaseIsCapture = "captured" === phase,
+ mangledImperativeRegistrationName = requestedPhaseIsCapture
+ ? "rn:" + registrationName.replace(/Capture$/, "")
+ : "rn:" + registrationName;
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName] &&
+ 0 <
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName]
+ .length &&
+ stateNode.canonical._eventListeners[
+ mangledImperativeRegistrationName
+ ].forEach(function(listenerObj) {
+ if (
+ (null != listenerObj.options.capture && listenerObj.options.capture) ===
+ requestedPhaseIsCapture
+ ) {
+ var listenerFnWrapper = function(syntheticEvent) {
+ var eventInst = new ReactNativePrivateInterface.CustomEvent(
+ mangledImperativeRegistrationName,
+ { detail: syntheticEvent.nativeEvent }
+ );
+ eventInst.isTrusted = !0;
+ eventInst.setSyntheticEvent(syntheticEvent);
+ for (
+ var _len = arguments.length,
+ args = Array(1 < _len ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ )
+ args[_key - 1] = arguments[_key];
+ listenerObj.listener.apply(listenerObj, [eventInst].concat(args));
+ };
+ listenerObj.options.once
+ ? listeners.push(function() {
+ stateNode.canonical.removeEventListener_unstable(
+ mangledImperativeRegistrationName,
+ listenerObj.listener,
+ listenerObj.capture
+ );
+ listenerObj.invalidated ||
+ ((listenerObj.invalidated = !0),
+ listenerObj.listener.apply(listenerObj, arguments));
+ })
+ : listeners.push(listenerFnWrapper);
+ }
+ });
+ return 0 === listeners.length
+ ? null
+ : 1 === listeners.length
+ ? listeners[0]
+ : listeners;
}
var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
@@ -875,50 +937,74 @@ var customBubblingEventTypes =
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateListenersAndInstances(inst, event, listeners) {
+ var listenersLength = listeners
+ ? isArrayImpl(listeners)
+ ? listeners.length
+ : 1
+ : 0;
+ if (0 < listenersLength)
+ if (
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listeners
+ )),
+ null == event._dispatchInstances && 1 === listenersLength)
+ )
+ event._dispatchInstances = inst;
+ else
+ for (
+ event._dispatchInstances = event._dispatchInstances || [],
+ isArrayImpl(event._dispatchInstances) ||
+ (event._dispatchInstances = [event._dispatchInstances]),
+ listeners = 0;
+ listeners < listenersLength;
+ listeners++
+ )
+ event._dispatchInstances.push(inst);
+}
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
- ));
+ phase = getListeners(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase],
+ phase,
+ !0
+ );
+ accumulateListenersAndInstances(inst, event, phase);
+}
+function traverseTwoPhase$1(inst, fn, arg, skipBubbling) {
+ for (var path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ if (skipBubbling) fn(path[0], "bubbled", arg);
+ else
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
}
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);
- }
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event,
+ !1
+ );
}
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
- )));
+ var listeners = getListeners(
+ inst,
+ event.dispatchConfig.registrationName,
+ "bubbled",
+ !1
+ );
+ accumulateListenersAndInstances(inst, event, listeners);
}
}
}
@@ -931,7 +1017,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_216 = {
+var injectedNamesToPlugins$jscomp$inline_215 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -955,10 +1041,21 @@ var injectedNamesToPlugins$jscomp$inline_216 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(
- topLevelType,
- accumulateTwoPhaseDispatchesSingle$1
- );
+ null != topLevelType &&
+ null != topLevelType.dispatchConfig.phasedRegistrationNames &&
+ topLevelType.dispatchConfig.phasedRegistrationNames.skipBubbling
+ ? topLevelType &&
+ topLevelType.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ topLevelType._targetInst,
+ accumulateDirectionalDispatches$1,
+ topLevelType,
+ !0
+ )
+ : forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
@@ -966,34 +1063,33 @@ var injectedNamesToPlugins$jscomp$inline_216 = {
}
}
},
- isOrderingDirty$jscomp$inline_217 = !1,
- pluginName$jscomp$inline_218;
-for (pluginName$jscomp$inline_218 in injectedNamesToPlugins$jscomp$inline_216)
+ isOrderingDirty$jscomp$inline_216 = !1,
+ pluginName$jscomp$inline_217;
+for (pluginName$jscomp$inline_217 in injectedNamesToPlugins$jscomp$inline_215)
if (
- injectedNamesToPlugins$jscomp$inline_216.hasOwnProperty(
- pluginName$jscomp$inline_218
+ injectedNamesToPlugins$jscomp$inline_215.hasOwnProperty(
+ pluginName$jscomp$inline_217
)
) {
- var pluginModule$jscomp$inline_219 =
- injectedNamesToPlugins$jscomp$inline_216[pluginName$jscomp$inline_218];
+ var pluginModule$jscomp$inline_218 =
+ injectedNamesToPlugins$jscomp$inline_215[pluginName$jscomp$inline_217];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_218) ||
- namesToPlugins[pluginName$jscomp$inline_218] !==
- pluginModule$jscomp$inline_219
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_217) ||
+ namesToPlugins[pluginName$jscomp$inline_217] !==
+ pluginModule$jscomp$inline_218
) {
- if (namesToPlugins[pluginName$jscomp$inline_218])
+ if (namesToPlugins[pluginName$jscomp$inline_217])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_218 +
- "`."
+ (pluginName$jscomp$inline_217 + "`.")
);
namesToPlugins[
- pluginName$jscomp$inline_218
- ] = pluginModule$jscomp$inline_219;
- isOrderingDirty$jscomp$inline_217 = !0;
+ pluginName$jscomp$inline_217
+ ] = pluginModule$jscomp$inline_218;
+ isOrderingDirty$jscomp$inline_216 = !0;
}
}
-isOrderingDirty$jscomp$inline_217 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_216 && recomputePluginOrdering();
function getInstanceFromInstance(instanceHandle) {
return instanceHandle;
}
@@ -1033,43 +1129,25 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
});
var ReactSharedInternals =
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_DEBUG_TRACING_MODE_TYPE = 60129,
- REACT_OFFSCREEN_TYPE = 60130,
- REACT_LEGACY_HIDDEN_TYPE = 60131,
- REACT_CACHE_TYPE = 60132;
-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");
- 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");
- REACT_CACHE_TYPE = symbolFor("react.cache");
-}
-var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ REACT_ELEMENT_TYPE = Symbol.for("react.element"),
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
+ REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
+ REACT_LAZY_TYPE = Symbol.for("react.lazy");
+Symbol.for("react.scope");
+Symbol.for("react.debug_trace_mode");
+var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
+Symbol.for("react.legacy_hidden");
+Symbol.for("react.cache");
+Symbol.for("react.tracing_marker");
+var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -1094,8 +1172,6 @@ function getComponentNameFromType(type) {
return "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
- case REACT_CACHE_TYPE:
- return "Cache";
}
if ("object" === typeof type)
switch (type.$$typeof) {
@@ -1156,8 +1232,6 @@ function getComponentNameFromFiber(fiber) {
return "Text";
case 16:
return getComponentNameFromType(type);
- case 23:
- return "LegacyHidden";
case 8:
return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode";
case 22:
@@ -1170,6 +1244,8 @@ function getComponentNameFromFiber(fiber) {
return "Suspense";
case 19:
return "SuspenseList";
+ case 25:
+ return "TracingMarker";
case 1:
case 0:
case 17:
@@ -1190,7 +1266,7 @@ function getNearestMountedFiber(fiber) {
fiber = node;
do
(node = fiber),
- 0 !== (node.flags & 2050) && (nearestMounted = node.return),
+ 0 !== (node.flags & 4098) && (nearestMounted = node.return),
(fiber = node.return);
while (fiber);
}
@@ -1562,7 +1638,10 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
null != stateNode && (eventTarget = stateNode.canonical);
}
batchedUpdates(function() {
- var JSCompiler_inline_result = eventTarget;
+ var event = { eventName: topLevelType, nativeEvent: nativeEvent };
+ ReactNativePrivateInterface.RawEventEmitter.emit(topLevelType, event);
+ ReactNativePrivateInterface.RawEventEmitter.emit("*", event);
+ event = eventTarget;
for (
var events = null, legacyPlugins = plugins, i = 0;
i < legacyPlugins.length;
@@ -1574,29 +1653,25 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
topLevelType,
target,
nativeEvent,
- JSCompiler_inline_result
+ event
)) &&
(events = accumulateInto(events, possiblePlugin));
}
- JSCompiler_inline_result = events;
- null !== JSCompiler_inline_result &&
- (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result));
- JSCompiler_inline_result = eventQueue;
+ event = events;
+ null !== event && (eventQueue = accumulateInto(eventQueue, event));
+ event = eventQueue;
eventQueue = null;
- if (JSCompiler_inline_result) {
- forEachAccumulated(
- JSCompiler_inline_result,
- executeDispatchesAndReleaseTopLevel
- );
+ if (event) {
+ forEachAccumulated(event, 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 ((JSCompiler_inline_result = rethrowError),
+ throw ((event = rethrowError),
(hasRethrowError = !1),
(rethrowError = null),
- JSCompiler_inline_result);
+ event);
}
});
}
@@ -1622,6 +1697,13 @@ function onCommitRoot(root) {
);
} catch (err) {}
}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(x) {
+ x >>>= 0;
+ return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0;
+}
var nextTransitionLane = 64,
nextRetryLane = 4194304;
function getHighestPriorityLanes(lanes) {
@@ -1800,12 +1882,6 @@ function markRootEntangled(root, entangledLanes) {
rootEntangledLanes &= ~lane;
}
}
-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 currentUpdatePriority = 0;
function lanesToEventPriority(lanes) {
lanes &= -lanes;
@@ -1817,11 +1893,6 @@ function lanesToEventPriority(lanes) {
: 4
: 1;
}
-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."
@@ -1869,28 +1940,81 @@ var ReactFabricHostComponent = (function() {
ReactNativePrivateInterface.TextInputState.focusTextInput(this);
};
_proto.measure = function(callback) {
- fabricMeasure(
- this._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, callback)
- );
+ var stateNode = this._internalInstanceHandle.stateNode;
+ null != stateNode &&
+ fabricMeasure(
+ stateNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, callback)
+ );
};
_proto.measureInWindow = function(callback) {
- fabricMeasureInWindow(
- this._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, callback)
- );
+ var stateNode = this._internalInstanceHandle.stateNode;
+ null != stateNode &&
+ fabricMeasureInWindow(
+ stateNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, callback)
+ );
};
_proto.measureLayout = function(relativeToNativeNode, onSuccess, onFail) {
- "number" !== typeof relativeToNativeNode &&
- relativeToNativeNode instanceof ReactFabricHostComponent &&
- fabricMeasureLayout(
- this._internalInstanceHandle.stateNode.node,
- relativeToNativeNode._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, onFail),
- mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)
- );
+ if (
+ "number" !== typeof relativeToNativeNode &&
+ relativeToNativeNode instanceof ReactFabricHostComponent
+ ) {
+ var toStateNode = this._internalInstanceHandle.stateNode;
+ relativeToNativeNode =
+ relativeToNativeNode._internalInstanceHandle.stateNode;
+ null != toStateNode &&
+ null != relativeToNativeNode &&
+ fabricMeasureLayout(
+ toStateNode.node,
+ relativeToNativeNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, onFail),
+ mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)
+ );
+ }
};
_proto.setNativeProps = function() {};
+ _proto.addEventListener_unstable = function(eventType, listener, options) {
+ if ("string" !== typeof eventType)
+ throw Error("addEventListener_unstable eventType must be a string");
+ if ("function" !== typeof listener)
+ throw Error("addEventListener_unstable listener must be a function");
+ var optionsObj =
+ "object" === typeof options && null !== options ? options : {};
+ options =
+ ("boolean" === typeof options ? options : optionsObj.capture) || !1;
+ var once = optionsObj.once || !1;
+ optionsObj = optionsObj.passive || !1;
+ var eventListeners = this._eventListeners || {};
+ null == this._eventListeners && (this._eventListeners = eventListeners);
+ var namedEventListeners = eventListeners[eventType] || [];
+ null == eventListeners[eventType] &&
+ (eventListeners[eventType] = namedEventListeners);
+ namedEventListeners.push({
+ listener: listener,
+ invalidated: !1,
+ options: {
+ capture: options,
+ once: once,
+ passive: optionsObj,
+ signal: null
+ }
+ });
+ };
+ _proto.removeEventListener_unstable = function(eventType, listener, options) {
+ var optionsObj =
+ "object" === typeof options && null !== options ? options : {},
+ capture =
+ ("boolean" === typeof options ? options : optionsObj.capture) || !1;
+ (options = this._eventListeners) &&
+ (optionsObj = options[eventType]) &&
+ (options[eventType] = optionsObj.filter(function(listenerObj) {
+ return !(
+ listenerObj.listener === listener &&
+ listenerObj.options.capture === capture
+ );
+ }));
+ };
return ReactFabricHostComponent;
})();
function createTextInstance(
@@ -1899,8 +2023,6 @@ function createTextInstance(
hostContext,
internalInstanceHandle
) {
- if (!hostContext.isInAParentText)
- throw Error("Text strings must be rendered within a component.");
hostContext = nextReactTag;
nextReactTag += 2;
return {
@@ -2004,7 +2126,7 @@ function processChildContext(fiber, type, parentContext) {
contextKey +
'" is not defined in childContextTypes.'
);
- return Object.assign({}, parentContext, instance);
+ return assign({}, parentContext, instance);
}
function pushContextProvider(workInProgress) {
workInProgress =
@@ -2035,7 +2157,11 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
-var syncQueue = null,
+function is(x, y) {
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
+}
+var objectIs = "function" === typeof Object.is ? Object.is : is,
+ syncQueue = null,
includesLegacySyncCallbacks = !1,
isFlushingSyncQueue = !1;
function flushSyncCallbacks() {
@@ -2064,10 +2190,6 @@ function flushSyncCallbacks() {
return null;
}
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
-function is(x, y) {
- return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
-}
-var objectIs = "function" === typeof Object.is ? Object.is : is;
function shallowEqual(objA, objB) {
if (objectIs(objA, objB)) return !0;
if (
@@ -2080,12 +2202,14 @@ function shallowEqual(objA, objB) {
var keysA = Object.keys(objA),
keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return !1;
- for (keysB = 0; keysB < keysA.length; keysB++)
+ for (keysB = 0; keysB < keysA.length; keysB++) {
+ var currentKey = keysA[keysB];
if (
- !hasOwnProperty.call(objB, keysA[keysB]) ||
- !objectIs(objA[keysA[keysB]], objB[keysA[keysB]])
+ !hasOwnProperty.call(objB, currentKey) ||
+ !objectIs(objA[currentKey], objB[currentKey])
)
return !1;
+ }
return !0;
}
function describeFiber(fiber) {
@@ -2112,7 +2236,7 @@ function describeFiber(fiber) {
}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
- baseProps = Object.assign({}, baseProps);
+ baseProps = assign({}, baseProps);
Component = Component.defaultProps;
for (var propName in Component)
void 0 === baseProps[propName] &&
@@ -2133,19 +2257,16 @@ function popProvider(context) {
pop(valueCursor);
context._currentValue2 = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderLanes) {
+function scheduleContextWorkOnParentPath(parent, renderLanes, propagationRoot) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- 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.childLanes & renderLanes) !== renderLanes
+ ? ((parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes))
+ : null !== alternate &&
+ (alternate.childLanes & renderLanes) !== renderLanes &&
+ (alternate.childLanes |= renderLanes);
+ if (parent === propagationRoot) break;
parent = parent.return;
}
}
@@ -2215,7 +2336,7 @@ function enqueueUpdate(fiber, update) {
((updateQueue = updateQueue.shared),
null !== workInProgressRoot &&
0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
+ 0 === (executionContext & 2)
? ((fiber = updateQueue.interleaved),
null === fiber
? ((update.next = update),
@@ -2352,7 +2473,7 @@ function processUpdateQueue(
newState = workInProgress;
break a;
case 3:
- workInProgress.flags = (workInProgress.flags & -16385) | 128;
+ workInProgress.flags = (workInProgress.flags & -65537) | 128;
case 0:
workInProgress = update.payload;
updateLane =
@@ -2360,7 +2481,7 @@ function processUpdateQueue(
? workInProgress.call(updateEventTime, newState, updateLane)
: workInProgress;
if (null === updateLane || void 0 === updateLane) break a;
- newState = Object.assign({}, newState, updateLane);
+ newState = assign({}, newState, updateLane);
break a;
case 2:
hasForceUpdate = !0;
@@ -2447,7 +2568,7 @@ function applyDerivedStateFromProps(
getDerivedStateFromProps =
null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps
? ctor
- : Object.assign({}, ctor, getDerivedStateFromProps);
+ : assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
@@ -2583,6 +2704,26 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
"function" === typeof instance.componentDidMount &&
(workInProgress.flags |= 4);
}
+var forkStack = [],
+ forkStackIndex = 0,
+ treeForkProvider = null,
+ idStack = [],
+ idStackIndex = 0,
+ treeContextProvider = null;
+function popTreeContext(workInProgress) {
+ for (; workInProgress === treeForkProvider; )
+ (treeForkProvider = forkStack[--forkStackIndex]),
+ (forkStack[forkStackIndex] = null),
+ --forkStackIndex,
+ (forkStack[forkStackIndex] = null);
+ for (; workInProgress === treeContextProvider; )
+ (treeContextProvider = idStack[--idStackIndex]),
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null);
+}
function coerceRef(returnFiber, current, element) {
returnFiber = element.ref;
if (
@@ -2605,7 +2746,8 @@ function coerceRef(returnFiber, current, element) {
returnFiber +
". This error is likely caused by a bug in React. Please file an issue."
);
- var stringRef = "" + returnFiber;
+ var resolvedInst = inst,
+ stringRef = "" + returnFiber;
if (
null !== current &&
null !== current.ref &&
@@ -2614,8 +2756,8 @@ function coerceRef(returnFiber, current, element) {
)
return current.ref;
current = function(value) {
- var refs = inst.refs;
- refs === emptyRefsObject && (refs = inst.refs = {});
+ var refs = resolvedInst.refs;
+ refs === emptyRefsObject && (refs = resolvedInst.refs = {});
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
};
current._stringRef = stringRef;
@@ -2676,7 +2818,8 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function placeChild(newFiber, lastPlacedIndex, newIndex) {
newFiber.index = newIndex;
- if (!shouldTrackSideEffects) return lastPlacedIndex;
+ if (!shouldTrackSideEffects)
+ return (newFiber.flags |= 1048576), lastPlacedIndex;
newIndex = newFiber.alternate;
if (null !== newIndex)
return (
@@ -2767,7 +2910,10 @@ function ChildReconciler(shouldTrackSideEffects) {
return current;
}
function createChild(returnFiber, newChild, lanes) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(newChild = createFiberFromText(
"" + newChild,
@@ -2821,7 +2967,10 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return null !== key
? null
: updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
@@ -2851,7 +3000,10 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild,
lanes
) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(existingChildren = existingChildren.get(newIdx) || null),
updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
@@ -3052,60 +3204,49 @@ function ChildReconciler(shouldTrackSideEffects) {
return iteratorFn;
}
return function(returnFiber, currentFirstChild, newChild, lanes) {
- var isUnkeyedTopLevelFragment =
- "object" === typeof newChild &&
+ "object" === typeof newChild &&
null !== newChild &&
newChild.type === REACT_FRAGMENT_TYPE &&
- null === newChild.key;
- isUnkeyedTopLevelFragment && (newChild = newChild.props.children);
+ null === newChild.key &&
+ (newChild = newChild.props.children);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
a: {
- var key = newChild.key;
for (
- isUnkeyedTopLevelFragment = currentFirstChild;
- null !== isUnkeyedTopLevelFragment;
+ var key = newChild.key, child = currentFirstChild;
+ null !== child;
) {
- if (isUnkeyedTopLevelFragment.key === key) {
+ if (child.key === key) {
key = newChild.type;
if (key === REACT_FRAGMENT_TYPE) {
- if (7 === isUnkeyedTopLevelFragment.tag) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
+ if (7 === child.tag) {
+ deleteRemainingChildren(returnFiber, child.sibling);
currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
+ child,
newChild.props.children
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- } else if (isUnkeyedTopLevelFragment.elementType === key) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
- currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
- newChild.props
- );
+ } else if (child.elementType === key) {
+ deleteRemainingChildren(returnFiber, child.sibling);
+ currentFirstChild = useFiber(child, newChild.props);
currentFirstChild.ref = coerceRef(
returnFiber,
- isUnkeyedTopLevelFragment,
+ child,
newChild
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment);
+ deleteRemainingChildren(returnFiber, child);
break;
- } else deleteChild(returnFiber, isUnkeyedTopLevelFragment);
- isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling;
+ } else deleteChild(returnFiber, child);
+ child = child.sibling;
}
newChild.type === REACT_FRAGMENT_TYPE
? ((currentFirstChild = createFiberFromFragment(
@@ -3135,12 +3276,8 @@ function ChildReconciler(shouldTrackSideEffects) {
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
a: {
- for (
- isUnkeyedTopLevelFragment = newChild.key;
- null !== currentFirstChild;
-
- ) {
- if (currentFirstChild.key === isUnkeyedTopLevelFragment)
+ for (child = newChild.key; null !== currentFirstChild; ) {
+ if (currentFirstChild.key === child)
if (
4 === currentFirstChild.tag &&
currentFirstChild.stateNode.containerInfo ===
@@ -3192,9 +3329,9 @@ function ChildReconciler(shouldTrackSideEffects) {
);
throwOnInvalidObjectType(returnFiber, newChild);
}
- if ("string" === typeof newChild || "number" === typeof newChild)
- return (
- (newChild = "" + newChild),
+ return ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ ? ((newChild = "" + newChild),
null !== currentFirstChild && 6 === currentFirstChild.tag
? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling),
(currentFirstChild = useFiber(currentFirstChild, newChild)),
@@ -3208,20 +3345,8 @@ function ChildReconciler(shouldTrackSideEffects) {
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
- placeSingleChild(returnFiber)
- );
- if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
- switch (returnFiber.tag) {
- case 1:
- case 0:
- case 11:
- case 15:
- throw Error(
- (getComponentNameFromFiber(returnFiber) || "Component") +
- "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."
- );
- }
- return deleteRemainingChildren(returnFiber, currentFirstChild);
+ placeSingleChild(returnFiber))
+ : deleteRemainingChildren(returnFiber, currentFirstChild);
};
}
var reconcileChildFibers = ChildReconciler(!0),
@@ -3308,7 +3433,8 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
currentHook = null,
workInProgressHook = null,
didScheduleRenderPhaseUpdate = !1,
- didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ didScheduleRenderPhaseUpdateDuringThisPass = !1,
+ globalClientIdCounter = 0;
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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
@@ -3342,7 +3468,7 @@ function renderWithHooks(
nextRenderLanes = 0;
do {
didScheduleRenderPhaseUpdateDuringThisPass = !1;
- if (!(25 > nextRenderLanes))
+ if (25 <= nextRenderLanes)
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
@@ -3443,19 +3569,18 @@ function updateReducer(reducer) {
(newBaseQueueLast = newBaseQueueLast.next = {
lane: 0,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
}),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ (current = update.hasEagerState
+ ? update.eagerState
+ : reducer(current, update.action));
else {
var clone = {
lane: updateLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
@@ -3512,109 +3637,77 @@ 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 may be 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."
+function updateMutableSource() {}
+function updateSyncExternalStore(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = updateWorkInProgressHook(),
+ nextSnapshot = getSnapshot(),
+ snapshotChanged = !objectIs(hook.memoizedState, nextSnapshot);
+ snapshotChanged &&
+ ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
+ hook = hook.queue;
+ updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [
+ subscribe
+ ]);
+ if (
+ hook.getSnapshot !== getSnapshot ||
+ snapshotChanged ||
+ (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1)
+ ) {
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot),
+ void 0,
+ null
);
- 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);
- objectIs(version, maybeNewVersion) ||
- ((maybeNewVersion = getSnapshot(source._source)),
- objectIs(snapshot, maybeNewVersion) ||
- (setSnapshot(maybeNewVersion),
- (maybeNewVersion = requestUpdateLane(fiber)),
- (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)),
- markRootEntangled(root, root.mutableReadLanes));
- },
- [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);
- 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,
- interleaved: null,
- lanes: 0,
- 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;
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ return nextSnapshot;
+}
+function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
+ fiber.flags |= 16384;
+ fiber = { getSnapshot: getSnapshot, value: renderedSnapshot };
+ getSnapshot = currentlyRenderingFiber$1.updateQueue;
+ null === getSnapshot
+ ? ((getSnapshot = { lastEffect: null, stores: null }),
+ (currentlyRenderingFiber$1.updateQueue = getSnapshot),
+ (getSnapshot.stores = [fiber]))
+ : ((renderedSnapshot = getSnapshot.stores),
+ null === renderedSnapshot
+ ? (getSnapshot.stores = [fiber])
+ : renderedSnapshot.push(fiber));
+}
+function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
+ inst.value = nextSnapshot;
+ inst.getSnapshot = getSnapshot;
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+}
+function subscribeToStore(fiber, inst, subscribe) {
+ return subscribe(function() {
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+ });
}
-function updateMutableSource(source, getSnapshot, subscribe) {
- var hook = updateWorkInProgressHook();
- return useMutableSource(hook, source, getSnapshot, subscribe);
+function checkIfSnapshotChanged(inst) {
+ var latestGetSnapshot = inst.getSnapshot;
+ inst = inst.value;
+ try {
+ var nextValue = latestGetSnapshot();
+ return !objectIs(inst, nextValue);
+ } catch (error) {
+ return !0;
+ }
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
- initialState = hook.queue = {
+ initialState = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3622,7 +3715,8 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
- initialState = initialState.dispatch = dispatchAction.bind(
+ hook.queue = initialState;
+ initialState = initialState.dispatch = dispatchSetState.bind(
null,
currentlyRenderingFiber$1,
initialState
@@ -3633,7 +3727,7 @@ function pushEffect(tag, create, destroy, deps) {
tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null };
create = currentlyRenderingFiber$1.updateQueue;
null === create
- ? ((create = { lastEffect: null }),
+ ? ((create = { lastEffect: null, stores: null }),
(currentlyRenderingFiber$1.updateQueue = create),
(create.lastEffect = tag.next = tag))
: ((destroy = create.lastEffect),
@@ -3674,14 +3768,17 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps);
}
function mountEffect(create, deps) {
- return mountEffectImpl(1049600, 4, create, deps);
+ return mountEffectImpl(8390656, 8, create, deps);
}
function updateEffect(create, deps) {
- return updateEffectImpl(1024, 4, create, deps);
+ return updateEffectImpl(2048, 8, create, deps);
}
-function updateLayoutEffect(create, deps) {
+function updateInsertionEffect(create, deps) {
return updateEffectImpl(4, 2, create, deps);
}
+function updateLayoutEffect(create, deps) {
+ return updateEffectImpl(4, 4, create, deps);
+}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
@@ -3704,7 +3801,7 @@ function updateImperativeHandle(ref, create, deps) {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return updateEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
@@ -3743,7 +3840,7 @@ function startTransition(setPending, callback) {
0 !== previousPriority && 4 > previousPriority ? previousPriority : 4;
setPending(!0);
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setPending(!1), callback();
} finally {
@@ -3751,47 +3848,38 @@ function startTransition(setPending, callback) {
(ReactCurrentBatchConfig$1.transition = prevTransition);
}
}
-function dispatchAction(fiber, queue, action) {
- var eventTime = requestEventTime(),
- lane = requestUpdateLane(fiber),
+function updateId() {
+ return updateWorkInProgressHook().memoizedState;
+}
+function dispatchReducerAction(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber);
+ action = {
+ lane: lane,
+ action: action,
+ hasEagerState: !1,
+ eagerState: null,
+ next: null
+ };
+ isRenderPhaseUpdate(fiber)
+ ? enqueueRenderPhaseUpdate(queue, action)
+ : (enqueueUpdate$1(fiber, queue, action),
+ (action = requestEventTime()),
+ (fiber = scheduleUpdateOnFiber(fiber, lane, action)),
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane));
+}
+function dispatchSetState(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber),
update = {
lane: lane,
action: action,
- eagerReducer: null,
+ hasEagerState: !1,
eagerState: null,
next: null
- },
- alternate = fiber.alternate;
- if (
- fiber === currentlyRenderingFiber$1 ||
- (null !== alternate && alternate === currentlyRenderingFiber$1)
- )
- (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0),
- (lane = queue.pending),
- null === lane
- ? (update.next = update)
- : ((update.next = lane.next), (lane.next = update)),
- (queue.pending = update);
+ };
+ if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update);
else {
- if (
- null !== workInProgressRoot &&
- 0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
- ) {
- var interleaved = queue.interleaved;
- null === interleaved
- ? ((update.next = update),
- null === interleavedQueues
- ? (interleavedQueues = [queue])
- : interleavedQueues.push(queue))
- : ((update.next = interleaved.next), (interleaved.next = update));
- queue.interleaved = update;
- } else
- (interleaved = queue.pending),
- null === interleaved
- ? (update.next = update)
- : ((update.next = interleaved.next), (interleaved.next = update)),
- (queue.pending = update);
+ enqueueUpdate$1(fiber, queue, update);
+ var alternate = fiber.alternate;
if (
0 === fiber.lanes &&
(null === alternate || 0 === alternate.lanes) &&
@@ -3800,20 +3888,57 @@ function dispatchAction(fiber, queue, action) {
try {
var currentState = queue.lastRenderedState,
eagerState = alternate(currentState, action);
- update.eagerReducer = alternate;
+ update.hasEagerState = !0;
update.eagerState = eagerState;
if (objectIs(eagerState, currentState)) return;
} catch (error) {
} finally {
}
- update = scheduleUpdateOnFiber(fiber, lane, eventTime);
- 0 !== (lane & 4194240) &&
- null !== update &&
- ((fiber = queue.lanes),
- (fiber &= update.pendingLanes),
- (lane |= fiber),
- (queue.lanes = lane),
- markRootEntangled(update, lane));
+ action = requestEventTime();
+ fiber = scheduleUpdateOnFiber(fiber, lane, action);
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane);
+ }
+}
+function isRenderPhaseUpdate(fiber) {
+ var alternate = fiber.alternate;
+ return (
+ fiber === currentlyRenderingFiber$1 ||
+ (null !== alternate && alternate === currentlyRenderingFiber$1)
+ );
+}
+function enqueueRenderPhaseUpdate(queue, update) {
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
+ var pending = queue.pending;
+ null === pending
+ ? (update.next = update)
+ : ((update.next = pending.next), (pending.next = update));
+ queue.pending = update;
+}
+function enqueueUpdate$1(fiber, queue, update) {
+ null !== workInProgressRoot &&
+ 0 !== (fiber.mode & 1) &&
+ 0 === (executionContext & 2)
+ ? ((fiber = queue.interleaved),
+ null === fiber
+ ? ((update.next = update),
+ null === interleavedQueues
+ ? (interleavedQueues = [queue])
+ : interleavedQueues.push(queue))
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.interleaved = update))
+ : ((fiber = queue.pending),
+ null === fiber
+ ? (update.next = update)
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.pending = update));
+}
+function entangleTransitionUpdate(root, queue, lane) {
+ if (0 !== (lane & 4194240)) {
+ var queueLanes = queue.lanes;
+ queueLanes &= root.pendingLanes;
+ lane |= queueLanes;
+ queue.lanes = lane;
+ markRootEntangled(root, lane);
}
}
var ContextOnlyDispatcher = {
@@ -3822,6 +3947,7 @@ var ContextOnlyDispatcher = {
useContext: throwInvalidHookError,
useEffect: throwInvalidHookError,
useImperativeHandle: throwInvalidHookError,
+ useInsertionEffect: throwInvalidHookError,
useLayoutEffect: throwInvalidHookError,
useMemo: throwInvalidHookError,
useReducer: throwInvalidHookError,
@@ -3831,7 +3957,8 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
- useOpaqueIdentifier: throwInvalidHookError,
+ useSyncExternalStore: throwInvalidHookError,
+ useId: throwInvalidHookError,
unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
@@ -3849,12 +3976,15 @@ var ContextOnlyDispatcher = {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return mountEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
},
useLayoutEffect: function(create, deps) {
+ return mountEffectImpl(4, 4, create, deps);
+ },
+ useInsertionEffect: function(create, deps) {
return mountEffectImpl(4, 2, create, deps);
},
useMemo: function(nextCreate, deps) {
@@ -3868,7 +3998,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
- reducer = hook.queue = {
+ reducer = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3876,7 +4006,8 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
- reducer = reducer.dispatch = dispatchAction.bind(
+ hook.queue = reducer;
+ reducer = reducer.dispatch = dispatchReducerAction.bind(
null,
currentlyRenderingFiber$1,
reducer
@@ -3897,7 +4028,7 @@ var ContextOnlyDispatcher = {
mountEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -3915,17 +4046,39 @@ var ContextOnlyDispatcher = {
mountWorkInProgressHook().memoizedState = _mountState2;
return [isPending, _mountState2];
},
- 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);
+ useMutableSource: function() {},
+ useSyncExternalStore: function(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = mountWorkInProgressHook();
+ var nextSnapshot = getSnapshot();
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ hook.memoizedState = nextSnapshot;
+ var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
+ hook.queue = inst;
+ mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [
+ subscribe
+ ]);
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ void 0,
+ null
+ );
+ return nextSnapshot;
},
- useOpaqueIdentifier: function() {
- throw Error("Not yet implemented");
+ useId: function() {
+ var hook = mountWorkInProgressHook(),
+ identifierPrefix = workInProgressRoot.identifierPrefix,
+ globalClientId = globalClientIdCounter++;
+ identifierPrefix =
+ ":" + identifierPrefix + "r" + globalClientId.toString(32) + ":";
+ return (hook.memoizedState = identifierPrefix);
},
unstable_isNewReconciler: !1
},
@@ -3935,6 +4088,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: updateReducer,
@@ -3950,7 +4104,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -3967,9 +4121,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return updateReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
@@ -3978,6 +4131,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: rerenderReducer,
@@ -3993,7 +4147,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -4010,9 +4164,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return rerenderReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
};
function createCapturedValue(value, source) {
@@ -4069,19 +4222,21 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
if ("function" === typeof getDerivedStateFromError) {
var error = errorInfo.value;
lane.payload = function() {
- logCapturedError(fiber, errorInfo);
return getDerivedStateFromError(error);
};
+ lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
+ };
}
var inst = fiber.stateNode;
null !== inst &&
"function" === typeof inst.componentDidCatch &&
(lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
"function" !== typeof getDerivedStateFromError &&
(null === legacyErrorBoundariesThatAlreadyFailed
? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logCapturedError(fiber, errorInfo));
+ : legacyErrorBoundariesThatAlreadyFailed.add(this));
var stack = errorInfo.stack;
this.componentDidCatch(errorInfo.value, {
componentStack: null !== stack ? stack : ""
@@ -4089,188 +4244,693 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
});
return lane;
}
-var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
- didReceiveUpdate = !1;
-function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
- workInProgress.child =
- null === current
- ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
- : reconcileChildFibers(
- workInProgress,
- current.child,
- nextChildren,
- renderLanes
- );
+function attachPingListener(root, wakeable, lanes) {
+ var pingCache = root.pingCache;
+ if (null === pingCache) {
+ pingCache = root.pingCache = new PossiblyWeakMap();
+ var threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
+ } else
+ (threadIDs = pingCache.get(wakeable)),
+ void 0 === threadIDs &&
+ ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs));
+ threadIDs.has(lanes) ||
+ (threadIDs.add(lanes),
+ (root = pingSuspendedRoot.bind(null, root, wakeable, lanes)),
+ wakeable.then(root, root));
}
-function updateForwardRef(
- current,
+function hadNoMutationsEffects(current, completedWork) {
+ if (null !== current && current.child === completedWork.child) return !0;
+ if (0 !== (completedWork.flags & 16)) return !1;
+ for (current = completedWork.child; null !== current; ) {
+ if (0 !== (current.flags & 12854) || 0 !== (current.subtreeFlags & 12854))
+ return !1;
+ current = current.sibling;
+ }
+ return !0;
+}
+var appendAllChildren, updateHostContainer, updateHostComponent, updateHostText;
+appendAllChildren = function(
+ parent,
workInProgress,
- Component,
- nextProps,
- renderLanes
+ needsVisibilityToggle,
+ isHidden
) {
- Component = Component.render;
- var ref = workInProgress.ref;
- prepareToReadContext(workInProgress, renderLanes);
- nextProps = renderWithHooks(
- current,
- workInProgress,
- Component,
- nextProps,
- ref,
- renderLanes
- );
- if (null !== current && !didReceiveUpdate)
- return (
- (workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
- (current.lanes &= ~renderLanes),
- bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
- );
- workInProgress.flags |= 1;
- reconcileChildren(current, workInProgress, nextProps, renderLanes);
- return workInProgress.child;
-}
-function updateMemoComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
-) {
- if (null === current) {
- var type = Component.type;
- if (
- "function" === typeof type &&
- !shouldConstruct(type) &&
- void 0 === type.defaultProps &&
- null === Component.compare &&
- void 0 === Component.defaultProps
- )
- return (
- (workInProgress.tag = 15),
- (workInProgress.type = type),
- updateSimpleMemoComponent(
- current,
- workInProgress,
- type,
- nextProps,
- updateLanes,
- renderLanes
- )
- );
- current = createFiberFromTypeAndProps(
- Component.type,
- null,
- nextProps,
- workInProgress,
- workInProgress.mode,
- renderLanes
- );
- current.ref = workInProgress.ref;
- current.return = workInProgress;
- return (workInProgress.child = current);
+ for (var node = workInProgress.child; null !== node; ) {
+ if (5 === node.tag) {
+ var instance = node.stateNode;
+ needsVisibilityToggle &&
+ isHidden &&
+ (instance = cloneHiddenInstance(instance));
+ appendChildNode(parent.node, instance.node);
+ } else if (6 === node.tag) {
+ instance = node.stateNode;
+ if (needsVisibilityToggle && isHidden)
+ throw Error("Not yet implemented.");
+ appendChildNode(parent.node, instance.node);
+ } else if (4 !== node.tag)
+ if (22 === node.tag && null !== node.memoizedState)
+ (instance = node.child),
+ null !== instance && (instance.return = node),
+ appendAllChildren(parent, node, !0, !0);
+ else if (null !== node.child) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ if (node === workInProgress) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === workInProgress) return;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
}
- type = current.child;
- if (
- 0 === (updateLanes & renderLanes) &&
- ((updateLanes = type.memoizedProps),
- (Component = Component.compare),
- (Component = null !== Component ? Component : shallowEqual),
- Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
- )
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- workInProgress.flags |= 1;
- current = createWorkInProgress(type, nextProps);
- current.ref = workInProgress.ref;
- current.return = workInProgress;
- return (workInProgress.child = current);
-}
-function updateSimpleMemoComponent(
- current,
+};
+function appendAllChildrenToContainer(
+ containerChildSet,
workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
+ needsVisibilityToggle,
+ isHidden
) {
- if (
- null !== current &&
- shallowEqual(current.memoizedProps, nextProps) &&
- current.ref === workInProgress.ref
- ) {
- didReceiveUpdate = !1;
- if (0 === (renderLanes & updateLanes))
- return (
- (workInProgress.lanes = current.lanes),
- bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
- );
- 0 !== (current.flags & 32768) && (didReceiveUpdate = !0);
- }
- 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 & 1))
- (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }),
- push(subtreeRenderLanesCursor, subtreeRenderLanes),
- (subtreeRenderLanes |= renderLanes);
- else {
- if (0 === (renderLanes & 1073741824))
- return (
- (current =
- null !== prevState
- ? prevState.baseLanes | renderLanes
- : renderLanes),
- (workInProgress.lanes = workInProgress.childLanes = 1073741824),
- (workInProgress.memoizedState = {
- baseLanes: current,
- cachePool: null
- }),
- (workInProgress.updateQueue = null),
- push(subtreeRenderLanesCursor, subtreeRenderLanes),
- (subtreeRenderLanes |= current),
- null
- );
- workInProgress.memoizedState = { baseLanes: 0, cachePool: null };
- nextProps = null !== prevState ? prevState.baseLanes : renderLanes;
- push(subtreeRenderLanesCursor, subtreeRenderLanes);
- subtreeRenderLanes |= nextProps;
+ for (var node = workInProgress.child; null !== node; ) {
+ if (5 === node.tag) {
+ var instance = node.stateNode;
+ needsVisibilityToggle &&
+ isHidden &&
+ (instance = cloneHiddenInstance(instance));
+ appendChildNodeToSet(containerChildSet, instance.node);
+ } else if (6 === node.tag) {
+ instance = node.stateNode;
+ if (needsVisibilityToggle && isHidden)
+ throw Error("Not yet implemented.");
+ appendChildNodeToSet(containerChildSet, instance.node);
+ } else if (4 !== node.tag)
+ if (22 === node.tag && null !== node.memoizedState)
+ (instance = node.child),
+ null !== instance && (instance.return = node),
+ appendAllChildrenToContainer(containerChildSet, node, !0, !0);
+ else if (null !== node.child) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ if (node === workInProgress) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === workInProgress) return;
+ node = node.return;
}
- else
- null !== prevState
- ? ((nextProps = prevState.baseLanes | renderLanes),
- (workInProgress.memoizedState = null))
- : (nextProps = renderLanes),
- push(subtreeRenderLanesCursor, subtreeRenderLanes),
- (subtreeRenderLanes |= nextProps);
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
}
-function markRef(current, workInProgress) {
- var ref = workInProgress.ref;
+updateHostContainer = function(current, workInProgress) {
+ var portalOrRoot = workInProgress.stateNode;
+ if (!hadNoMutationsEffects(current, workInProgress)) {
+ current = portalOrRoot.containerInfo;
+ var newChildSet = createChildNodeSet(current);
+ appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1);
+ portalOrRoot.pendingChildren = newChildSet;
+ workInProgress.flags |= 4;
+ completeRoot(current, newChildSet);
+ }
+};
+updateHostComponent = function(current, workInProgress, type, newProps) {
+ type = current.stateNode;
+ var oldProps = current.memoizedProps;
if (
- (null === current && null !== ref) ||
- (null !== current && current.ref !== ref)
+ (current = hadNoMutationsEffects(current, workInProgress)) &&
+ oldProps === newProps
)
- workInProgress.flags |= 256;
+ workInProgress.stateNode = type;
+ else {
+ var recyclableInstance = workInProgress.stateNode;
+ requiredContext(contextStackCursor$1.current);
+ var updatePayload = null;
+ oldProps !== newProps &&
+ ((oldProps = diffProperties(
+ null,
+ oldProps,
+ newProps,
+ recyclableInstance.canonical.viewConfig.validAttributes
+ )),
+ (recyclableInstance.canonical.currentProps = newProps),
+ (updatePayload = oldProps));
+ current && null === updatePayload
+ ? (workInProgress.stateNode = type)
+ : ((newProps = updatePayload),
+ (oldProps = type.node),
+ (type = {
+ node: current
+ ? null !== newProps
+ ? cloneNodeWithNewProps(oldProps, newProps)
+ : cloneNode(oldProps)
+ : null !== newProps
+ ? cloneNodeWithNewChildrenAndProps(oldProps, newProps)
+ : cloneNodeWithNewChildren(oldProps),
+ canonical: type.canonical
+ }),
+ (workInProgress.stateNode = type),
+ current
+ ? (workInProgress.flags |= 4)
+ : appendAllChildren(type, workInProgress, !1, !1));
+ }
+};
+updateHostText = function(current, workInProgress, oldText, newText) {
+ oldText !== newText
+ ? ((current = requiredContext(rootInstanceStackCursor.current)),
+ (oldText = requiredContext(contextStackCursor$1.current)),
+ (workInProgress.stateNode = createTextInstance(
+ newText,
+ current,
+ oldText,
+ workInProgress
+ )),
+ (workInProgress.flags |= 4))
+ : (workInProgress.stateNode = current.stateNode);
+};
+function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
+ switch (renderState.tailMode) {
+ case "hidden":
+ hasRenderedATailFallback = renderState.tail;
+ for (var lastTailNode = null; null !== hasRenderedATailFallback; )
+ null !== hasRenderedATailFallback.alternate &&
+ (lastTailNode = hasRenderedATailFallback),
+ (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
+ null === lastTailNode
+ ? (renderState.tail = null)
+ : (lastTailNode.sibling = null);
+ break;
+ case "collapsed":
+ lastTailNode = renderState.tail;
+ for (var lastTailNode$35 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$35 = lastTailNode),
+ (lastTailNode = lastTailNode.sibling);
+ null === lastTailNode$35
+ ? hasRenderedATailFallback || null === renderState.tail
+ ? (renderState.tail = null)
+ : (renderState.tail.sibling = null)
+ : (lastTailNode$35.sibling = null);
+ }
}
-function updateFunctionComponent(
- current,
- workInProgress,
+function bubbleProperties(completedWork) {
+ var didBailout =
+ null !== completedWork.alternate &&
+ completedWork.alternate.child === completedWork.child,
+ newChildLanes = 0,
+ subtreeFlags = 0;
+ if (didBailout)
+ for (var child$36 = completedWork.child; null !== child$36; )
+ (newChildLanes |= child$36.lanes | child$36.childLanes),
+ (subtreeFlags |= child$36.subtreeFlags & 14680064),
+ (subtreeFlags |= child$36.flags & 14680064),
+ (child$36.return = completedWork),
+ (child$36 = child$36.sibling);
+ else
+ for (child$36 = completedWork.child; null !== child$36; )
+ (newChildLanes |= child$36.lanes | child$36.childLanes),
+ (subtreeFlags |= child$36.subtreeFlags),
+ (subtreeFlags |= child$36.flags),
+ (child$36.return = completedWork),
+ (child$36 = child$36.sibling);
+ completedWork.subtreeFlags |= subtreeFlags;
+ completedWork.childLanes = newChildLanes;
+ return didBailout;
+}
+function completeWork(current, workInProgress, renderLanes) {
+ var newProps = workInProgress.pendingProps;
+ popTreeContext(workInProgress);
+ switch (workInProgress.tag) {
+ case 2:
+ case 16:
+ case 15:
+ case 0:
+ case 11:
+ case 7:
+ case 8:
+ case 12:
+ case 9:
+ case 14:
+ return bubbleProperties(workInProgress), null;
+ case 1:
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 3:
+ return (
+ (newProps = workInProgress.stateNode),
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ null === current ||
+ (current.memoizedState.isDehydrated &&
+ 0 === (workInProgress.flags & 256)) ||
+ (workInProgress.flags |= 1024),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 5:
+ popHostContext(workInProgress);
+ renderLanes = requiredContext(rootInstanceStackCursor.current);
+ var type = workInProgress.type;
+ if (null !== current && null != workInProgress.stateNode)
+ updateHostComponent(
+ current,
+ workInProgress,
+ type,
+ newProps,
+ renderLanes
+ ),
+ current.ref !== workInProgress.ref && (workInProgress.flags |= 512);
+ else {
+ if (!newProps) {
+ if (null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ }
+ requiredContext(contextStackCursor$1.current);
+ current = nextReactTag;
+ nextReactTag += 2;
+ type = getViewConfigForType(type);
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ newProps,
+ type.validAttributes
+ );
+ renderLanes = createNode(
+ current,
+ type.uiViewClassName,
+ renderLanes,
+ updatePayload,
+ workInProgress
+ );
+ current = new ReactFabricHostComponent(
+ current,
+ type,
+ newProps,
+ workInProgress
+ );
+ current = { node: renderLanes, canonical: current };
+ appendAllChildren(current, workInProgress, !1, !1);
+ workInProgress.stateNode = current;
+ null !== workInProgress.ref && (workInProgress.flags |= 512);
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 6:
+ if (current && null != workInProgress.stateNode)
+ updateHostText(
+ current,
+ workInProgress,
+ current.memoizedProps,
+ newProps
+ );
+ else {
+ if ("string" !== typeof newProps && null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ current = requiredContext(rootInstanceStackCursor.current);
+ renderLanes = requiredContext(contextStackCursor$1.current);
+ workInProgress.stateNode = createTextInstance(
+ newProps,
+ current,
+ renderLanes,
+ workInProgress
+ );
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 13:
+ pop(suspenseStackCursor);
+ newProps = workInProgress.memoizedState;
+ if (0 !== (workInProgress.flags & 128))
+ return (workInProgress.lanes = renderLanes), workInProgress;
+ renderLanes = !1;
+ null !== current && (renderLanes = null !== current.memoizedState);
+ null === newProps ||
+ renderLanes ||
+ ((workInProgress.child.flags |= 8192),
+ 0 !== (workInProgress.mode & 1) &&
+ (null === current || 0 !== (suspenseStackCursor.current & 1)
+ ? 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3)
+ : renderDidSuspendDelayIfPossible()));
+ null !== workInProgress.updateQueue && (workInProgress.flags |= 4);
+ bubbleProperties(workInProgress);
+ return null;
+ case 4:
+ return (
+ popHostContainer(),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 10:
+ return (
+ popProvider(workInProgress.type._context),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 17:
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 19:
+ pop(suspenseStackCursor);
+ type = workInProgress.memoizedState;
+ if (null === type) return bubbleProperties(workInProgress), null;
+ newProps = 0 !== (workInProgress.flags & 128);
+ updatePayload = type.rendering;
+ if (null === updatePayload)
+ if (newProps) cutOffTailIfNeeded(type, !1);
+ else {
+ if (
+ 0 !== workInProgressRootExitStatus ||
+ (null !== current && 0 !== (current.flags & 128))
+ )
+ for (current = workInProgress.child; null !== current; ) {
+ updatePayload = findFirstSuspended(current);
+ if (null !== updatePayload) {
+ workInProgress.flags |= 128;
+ cutOffTailIfNeeded(type, !1);
+ current = updatePayload.updateQueue;
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4));
+ workInProgress.subtreeFlags = 0;
+ current = renderLanes;
+ for (newProps = workInProgress.child; null !== newProps; )
+ (renderLanes = newProps),
+ (type = current),
+ (renderLanes.flags &= 14680066),
+ (updatePayload = renderLanes.alternate),
+ null === updatePayload
+ ? ((renderLanes.childLanes = 0),
+ (renderLanes.lanes = type),
+ (renderLanes.child = null),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.memoizedProps = null),
+ (renderLanes.memoizedState = null),
+ (renderLanes.updateQueue = null),
+ (renderLanes.dependencies = null),
+ (renderLanes.stateNode = null))
+ : ((renderLanes.childLanes = updatePayload.childLanes),
+ (renderLanes.lanes = updatePayload.lanes),
+ (renderLanes.child = updatePayload.child),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.deletions = null),
+ (renderLanes.memoizedProps =
+ updatePayload.memoizedProps),
+ (renderLanes.memoizedState =
+ updatePayload.memoizedState),
+ (renderLanes.updateQueue = updatePayload.updateQueue),
+ (renderLanes.type = updatePayload.type),
+ (type = updatePayload.dependencies),
+ (renderLanes.dependencies =
+ null === type
+ ? null
+ : {
+ lanes: type.lanes,
+ firstContext: type.firstContext
+ })),
+ (newProps = newProps.sibling);
+ push(
+ suspenseStackCursor,
+ (suspenseStackCursor.current & 1) | 2
+ );
+ return workInProgress.child;
+ }
+ current = current.sibling;
+ }
+ null !== type.tail &&
+ now() > workInProgressRootRenderTargetTime &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ }
+ else {
+ if (!newProps)
+ if (
+ ((current = findFirstSuspended(updatePayload)), null !== current)
+ ) {
+ if (
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ (current = current.updateQueue),
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4)),
+ cutOffTailIfNeeded(type, !0),
+ null === type.tail &&
+ "hidden" === type.tailMode &&
+ !updatePayload.alternate)
+ )
+ return bubbleProperties(workInProgress), null;
+ } else
+ 2 * now() - type.renderingStartTime >
+ workInProgressRootRenderTargetTime &&
+ 1073741824 !== renderLanes &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ type.isBackwards
+ ? ((updatePayload.sibling = workInProgress.child),
+ (workInProgress.child = updatePayload))
+ : ((current = type.last),
+ null !== current
+ ? (current.sibling = updatePayload)
+ : (workInProgress.child = updatePayload),
+ (type.last = updatePayload));
+ }
+ if (null !== type.tail)
+ return (
+ (workInProgress = type.tail),
+ (type.rendering = workInProgress),
+ (type.tail = workInProgress.sibling),
+ (type.renderingStartTime = now()),
+ (workInProgress.sibling = null),
+ (current = suspenseStackCursor.current),
+ push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
+ workInProgress
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ case 22:
+ case 23:
+ return (
+ popRenderLanes(),
+ (newProps = null !== workInProgress.memoizedState),
+ null !== current &&
+ (null !== current.memoizedState) !== newProps &&
+ (workInProgress.flags |= 8192),
+ newProps && 0 !== (workInProgress.mode & 1)
+ ? 0 !== (subtreeRenderLanes & 1073741824) &&
+ bubbleProperties(workInProgress)
+ : bubbleProperties(workInProgress),
+ null
+ );
+ case 24:
+ return null;
+ case 25:
+ return null;
+ }
+ throw Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in React. Please file an issue."
+ );
+}
+var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
+ didReceiveUpdate = !1;
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
+ workInProgress.child =
+ null === current
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
+ : reconcileChildFibers(
+ workInProgress,
+ current.child,
+ nextChildren,
+ renderLanes
+ );
+}
+function updateForwardRef(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ Component = Component.render;
+ var ref = workInProgress.ref;
+ prepareToReadContext(workInProgress, renderLanes);
+ nextProps = renderWithHooks(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ ref,
+ renderLanes
+ );
+ if (null !== current && !didReceiveUpdate)
+ return (
+ (workInProgress.updateQueue = current.updateQueue),
+ (workInProgress.flags &= -2053),
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
+ );
+ workInProgress.flags |= 1;
+ reconcileChildren(current, workInProgress, nextProps, renderLanes);
+ return workInProgress.child;
+}
+function updateMemoComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ if (null === current) {
+ var type = Component.type;
+ if (
+ "function" === typeof type &&
+ !shouldConstruct(type) &&
+ void 0 === type.defaultProps &&
+ null === Component.compare &&
+ void 0 === Component.defaultProps
+ )
+ return (
+ (workInProgress.tag = 15),
+ (workInProgress.type = type),
+ updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ type,
+ nextProps,
+ renderLanes
+ )
+ );
+ current = createFiberFromTypeAndProps(
+ Component.type,
+ null,
+ nextProps,
+ workInProgress,
+ workInProgress.mode,
+ renderLanes
+ );
+ current.ref = workInProgress.ref;
+ current.return = workInProgress;
+ return (workInProgress.child = current);
+ }
+ type = current.child;
+ if (0 === (current.lanes & renderLanes)) {
+ var prevProps = type.memoizedProps;
+ Component = Component.compare;
+ Component = null !== Component ? Component : shallowEqual;
+ if (Component(prevProps, nextProps) && current.ref === workInProgress.ref)
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
+ workInProgress.flags |= 1;
+ current = createWorkInProgress(type, nextProps);
+ current.ref = workInProgress.ref;
+ current.return = workInProgress;
+ return (workInProgress.child = current);
+}
+function updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ if (
+ null !== current &&
+ shallowEqual(current.memoizedProps, nextProps) &&
+ current.ref === workInProgress.ref
+ )
+ if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes)))
+ 0 !== (current.flags & 131072) && (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)
+ if (0 === (workInProgress.mode & 1))
+ (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }),
+ push(subtreeRenderLanesCursor, subtreeRenderLanes),
+ (subtreeRenderLanes |= renderLanes);
+ else {
+ if (0 === (renderLanes & 1073741824))
+ return (
+ (current =
+ null !== prevState
+ ? prevState.baseLanes | renderLanes
+ : renderLanes),
+ (workInProgress.lanes = workInProgress.childLanes = 1073741824),
+ (workInProgress.memoizedState = {
+ baseLanes: current,
+ cachePool: null
+ }),
+ (workInProgress.updateQueue = null),
+ push(subtreeRenderLanesCursor, subtreeRenderLanes),
+ (subtreeRenderLanes |= current),
+ null
+ );
+ workInProgress.memoizedState = { baseLanes: 0, cachePool: null };
+ nextProps = null !== prevState ? prevState.baseLanes : renderLanes;
+ push(subtreeRenderLanesCursor, subtreeRenderLanes);
+ subtreeRenderLanes |= nextProps;
+ }
+ else
+ null !== prevState
+ ? ((nextProps = prevState.baseLanes | renderLanes),
+ (workInProgress.memoizedState = null))
+ : (nextProps = renderLanes),
+ push(subtreeRenderLanesCursor, subtreeRenderLanes),
+ (subtreeRenderLanes |= nextProps);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
+function markRef$1(current, workInProgress) {
+ var ref = workInProgress.ref;
+ if (
+ (null === current && null !== ref) ||
+ (null !== current && current.ref !== ref)
+ )
+ workInProgress.flags |= 512;
+}
+function updateFunctionComponent(
+ current,
+ workInProgress,
Component,
nextProps,
renderLanes
@@ -4291,7 +4951,7 @@ function updateFunctionComponent(
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
+ (workInProgress.flags &= -2053),
(current.lanes &= ~renderLanes),
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
@@ -4467,7 +5127,7 @@ function updateClassComponent(
"function" === typeof instance.componentDidUpdate &&
(workInProgress.flags |= 4),
"function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.flags |= 512))
+ (workInProgress.flags |= 1024))
: ("function" !== typeof instance.componentDidUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
@@ -4475,7 +5135,7 @@ function updateClassComponent(
"function" !== typeof instance.getSnapshotBeforeUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
+ (workInProgress.flags |= 1024),
(workInProgress.memoizedProps = nextProps),
(workInProgress.memoizedState = newState)),
(instance.props = nextProps),
@@ -4489,7 +5149,7 @@ function updateClassComponent(
"function" !== typeof instance.getSnapshotBeforeUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
+ (workInProgress.flags |= 1024),
(nextProps = !1));
}
return finishClassComponent(
@@ -4509,7 +5169,7 @@ function finishClassComponent(
hasContext,
renderLanes
) {
- markRef(current, workInProgress);
+ markRef$1(current, workInProgress);
var didCaptureError = 0 !== (workInProgress.flags & 128);
if (!shouldUpdate && !didCaptureError)
return (
@@ -4553,7 +5213,7 @@ function pushHostRootContext(workInProgress) {
pushTopLevelContextObject(workInProgress, root.context, !1);
pushHostContainer(workInProgress, root.containerInfo);
}
-var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
+var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 };
function mountSuspenseOffscreenState(renderLanes) {
return { baseLanes: renderLanes, cachePool: null };
}
@@ -4567,49 +5227,47 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
null !== current && null === current.memoizedState
? !1
: 0 !== (suspenseContext & 2));
- JSCompiler_temp
- ? ((showFallback = !0), (workInProgress.flags &= -129))
- : (null !== current && null === current.memoizedState) ||
- void 0 === nextProps.fallback ||
- !0 === nextProps.unstable_avoidThisFallback ||
- (suspenseContext |= 1);
+ if (JSCompiler_temp) (showFallback = !0), (workInProgress.flags &= -129);
+ else if (null === current || null !== current.memoizedState)
+ suspenseContext |= 1;
push(suspenseStackCursor, suspenseContext & 1);
if (null === current) {
- current = nextProps.children;
- suspenseContext = nextProps.fallback;
+ suspenseContext = nextProps.children;
+ current = nextProps.fallback;
if (showFallback)
return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
- current,
- suspenseContext,
- renderLanes
- )),
- (workInProgress.child.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- )),
- (workInProgress.memoizedState = SUSPENDED_MARKER),
- current
- );
- if ("number" === typeof nextProps.unstable_expectedLoadTime)
- return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
+ (showFallback = workInProgress.mode),
+ (nextProps = workInProgress.child),
+ (suspenseContext = { mode: "hidden", children: suspenseContext }),
+ 0 === (showFallback & 1) && null !== nextProps
+ ? ((nextProps.childLanes = 0),
+ (nextProps.pendingProps = suspenseContext))
+ : (nextProps = createFiberFromOffscreen(
+ suspenseContext,
+ showFallback,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
current,
- suspenseContext,
- renderLanes
+ showFallback,
+ renderLanes,
+ null
)),
+ (nextProps.return = workInProgress),
+ (current.return = workInProgress),
+ (nextProps.sibling = current),
+ (workInProgress.child = nextProps),
(workInProgress.child.memoizedState = mountSuspenseOffscreenState(
renderLanes
)),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- (workInProgress.lanes = 4194304),
current
);
renderLanes = createFiberFromOffscreen(
- { mode: "visible", children: current },
+ { mode: "visible", children: suspenseContext },
workInProgress.mode,
- renderLanes,
+ 0,
null
);
renderLanes.return = workInProgress;
@@ -4618,25 +5276,25 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
if (null !== current.memoizedState) {
if (showFallback)
return (
- (nextProps = updateSuspenseFallbackChildren(
+ (showFallback = updateSuspenseFallbackChildren(
current,
workInProgress,
nextProps.children,
nextProps.fallback,
renderLanes
)),
- (showFallback = workInProgress.child),
+ (nextProps = workInProgress.child),
(suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
+ (nextProps.memoizedState =
null === suspenseContext
? mountSuspenseOffscreenState(renderLanes)
: {
baseLanes: suspenseContext.baseLanes | renderLanes,
cachePool: null
}),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
+ showFallback
);
renderLanes = updateSuspensePrimaryChildren(
current,
@@ -4649,25 +5307,25 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
}
if (showFallback)
return (
- (nextProps = updateSuspenseFallbackChildren(
+ (showFallback = updateSuspenseFallbackChildren(
current,
workInProgress,
nextProps.children,
nextProps.fallback,
renderLanes
)),
- (showFallback = workInProgress.child),
+ (nextProps = workInProgress.child),
(suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
+ (nextProps.memoizedState =
null === suspenseContext
? mountSuspenseOffscreenState(renderLanes)
: {
baseLanes: suspenseContext.baseLanes | renderLanes,
cachePool: null
}),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
+ showFallback
);
renderLanes = updateSuspensePrimaryChildren(
current,
@@ -4678,36 +5336,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
workInProgress.memoizedState = null;
return renderLanes;
}
-function mountSuspenseFallbackChildren(
- workInProgress,
- primaryChildren,
- fallbackChildren,
- renderLanes
-) {
- var mode = workInProgress.mode,
- progressedPrimaryFragment = workInProgress.child;
- primaryChildren = { mode: "hidden", children: primaryChildren };
- 0 === (mode & 1) && null !== progressedPrimaryFragment
- ? ((progressedPrimaryFragment.childLanes = 0),
- (progressedPrimaryFragment.pendingProps = primaryChildren))
- : (progressedPrimaryFragment = createFiberFromOffscreen(
- primaryChildren,
- mode,
- 0,
- null
- ));
- fallbackChildren = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- );
- progressedPrimaryFragment.return = workInProgress;
- fallbackChildren.return = workInProgress;
- progressedPrimaryFragment.sibling = fallbackChildren;
- workInProgress.child = progressedPrimaryFragment;
- return fallbackChildren;
-}
function updateSuspensePrimaryChildren(
current,
workInProgress,
@@ -4734,750 +5362,273 @@ function updateSuspenseFallbackChildren(
current,
workInProgress,
primaryChildren,
- fallbackChildren,
- renderLanes
-) {
- var mode = workInProgress.mode;
- current = current.child;
- var currentFallbackChildFragment = current.sibling,
- primaryChildProps = { mode: "hidden", children: primaryChildren };
- 0 === (mode & 1) && workInProgress.child !== current
- ? ((primaryChildren = workInProgress.child),
- (primaryChildren.childLanes = 0),
- (primaryChildren.pendingProps = primaryChildProps),
- (workInProgress.deletions = null))
- : ((primaryChildren = createWorkInProgress(current, primaryChildProps)),
- (primaryChildren.subtreeFlags = current.subtreeFlags & 1835008));
- null !== currentFallbackChildFragment
- ? (fallbackChildren = createWorkInProgress(
- currentFallbackChildFragment,
- fallbackChildren
- ))
- : ((fallbackChildren = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- )),
- (fallbackChildren.flags |= 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.lanes |= renderLanes);
- scheduleWorkOnParentPath(fiber.return, renderLanes);
-}
-function initSuspenseListRenderState(
- workInProgress,
- isBackwards,
- tail,
- lastContentRow,
- tailMode
-) {
- var renderState = workInProgress.memoizedState;
- null === renderState
- ? (workInProgress.memoizedState = {
- isBackwards: isBackwards,
- rendering: null,
- renderingStartTime: 0,
- last: lastContentRow,
- tail: tail,
- tailMode: tailMode
- })
- : ((renderState.isBackwards = isBackwards),
- (renderState.rendering = null),
- (renderState.renderingStartTime = 0),
- (renderState.last = lastContentRow),
- (renderState.tail = tail),
- (renderState.tailMode = tailMode));
-}
-function updateSuspenseListComponent(current, workInProgress, renderLanes) {
- var nextProps = workInProgress.pendingProps,
- revealOrder = nextProps.revealOrder,
- tailMode = nextProps.tail;
- reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
- nextProps = suspenseStackCursor.current;
- if (0 !== (nextProps & 2))
- (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128);
- else {
- if (null !== current && 0 !== (current.flags & 128))
- a: for (current = workInProgress.child; null !== current; ) {
- if (13 === current.tag)
- null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderLanes);
- else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
- else if (null !== current.child) {
- current.child.return = current;
- current = current.child;
- continue;
- }
- if (current === workInProgress) break a;
- for (; null === current.sibling; ) {
- if (null === current.return || current.return === workInProgress)
- break a;
- current = current.return;
- }
- current.sibling.return = current.return;
- current = current.sibling;
- }
- nextProps &= 1;
- }
- push(suspenseStackCursor, nextProps);
- if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null;
- else
- switch (revealOrder) {
- case "forwards":
- renderLanes = workInProgress.child;
- for (revealOrder = null; null !== renderLanes; )
- (current = renderLanes.alternate),
- null !== current &&
- null === findFirstSuspended(current) &&
- (revealOrder = renderLanes),
- (renderLanes = renderLanes.sibling);
- renderLanes = revealOrder;
- null === renderLanes
- ? ((revealOrder = workInProgress.child),
- (workInProgress.child = null))
- : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
- initSuspenseListRenderState(
- workInProgress,
- !1,
- revealOrder,
- renderLanes,
- tailMode
- );
- break;
- case "backwards":
- renderLanes = null;
- revealOrder = workInProgress.child;
- for (workInProgress.child = null; null !== revealOrder; ) {
- current = revealOrder.alternate;
- if (null !== current && null === findFirstSuspended(current)) {
- workInProgress.child = revealOrder;
- break;
- }
- current = revealOrder.sibling;
- revealOrder.sibling = renderLanes;
- renderLanes = revealOrder;
- revealOrder = current;
- }
- initSuspenseListRenderState(
- workInProgress,
- !0,
- renderLanes,
- null,
- tailMode
- );
- break;
- case "together":
- initSuspenseListRenderState(workInProgress, !1, null, null, void 0);
- break;
- default:
- workInProgress.memoizedState = null;
- }
- return workInProgress.child;
-}
-function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
- null !== current && (workInProgress.dependencies = current.dependencies);
- workInProgressRootSkippedLanes |= workInProgress.lanes;
- if (0 === (renderLanes & workInProgress.childLanes)) return null;
- 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;
-}
-function hadNoMutationsEffects(current, completedWork) {
- if (null !== current && current.child === completedWork.child) return !0;
- if (0 !== (completedWork.flags & 16)) return !1;
- for (current = completedWork.child; null !== current; ) {
- if (0 !== (current.flags & 6454) || 0 !== (current.subtreeFlags & 6454))
- return !1;
- current = current.sibling;
- }
- return !0;
-}
-var appendAllChildren,
- updateHostContainer,
- updateHostComponent$1,
- updateHostText$1;
-appendAllChildren = function(
- parent,
- workInProgress,
- needsVisibilityToggle,
- isHidden
-) {
- for (var node = workInProgress.child; null !== node; ) {
- if (5 === node.tag) {
- var instance = node.stateNode;
- needsVisibilityToggle &&
- isHidden &&
- (instance = cloneHiddenInstance(instance));
- appendChildNode(parent.node, instance.node);
- } else if (6 === node.tag) {
- instance = node.stateNode;
- if (needsVisibilityToggle && isHidden)
- throw Error("Not yet implemented.");
- appendChildNode(parent.node, instance.node);
- } else if (4 !== node.tag) {
- if (
- 13 === node.tag &&
- 0 !== (node.flags & 4) &&
- (instance = null !== node.memoizedState)
- ) {
- var primaryChildParent = node.child;
- if (
- null !== primaryChildParent &&
- (null !== primaryChildParent.child &&
- ((primaryChildParent.child.return = primaryChildParent),
- appendAllChildren(parent, primaryChildParent, !0, instance)),
- (instance = primaryChildParent.sibling),
- null !== instance)
- ) {
- instance.return = node;
- node = instance;
- continue;
- }
- }
- if (null !== node.child) {
- node.child.return = node;
- node = node.child;
- continue;
- }
- }
- if (node === workInProgress) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === workInProgress) return;
- node = node.return;
- }
- node.sibling.return = node.return;
- node = node.sibling;
- }
-};
-function appendAllChildrenToContainer(
- containerChildSet,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ current = current.child;
+ var currentFallbackChildFragment = current.sibling,
+ primaryChildProps = { mode: "hidden", children: primaryChildren };
+ 0 === (mode & 1) && workInProgress.child !== current
+ ? ((primaryChildren = workInProgress.child),
+ (primaryChildren.childLanes = 0),
+ (primaryChildren.pendingProps = primaryChildProps),
+ (workInProgress.deletions = null))
+ : ((primaryChildren = createWorkInProgress(current, primaryChildProps)),
+ (primaryChildren.subtreeFlags = current.subtreeFlags & 14680064));
+ null !== currentFallbackChildFragment
+ ? (fallbackChildren = createWorkInProgress(
+ currentFallbackChildFragment,
+ fallbackChildren
+ ))
+ : ((fallbackChildren = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ )),
+ (fallbackChildren.flags |= 2));
+ fallbackChildren.return = workInProgress;
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = fallbackChildren;
+ workInProgress.child = primaryChildren;
+ return fallbackChildren;
+}
+function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) {
+ fiber.lanes |= renderLanes;
+ var alternate = fiber.alternate;
+ null !== alternate && (alternate.lanes |= renderLanes);
+ scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot);
+}
+function initSuspenseListRenderState(
workInProgress,
- needsVisibilityToggle,
- isHidden
+ isBackwards,
+ tail,
+ lastContentRow,
+ tailMode
) {
- for (var node = workInProgress.child; null !== node; ) {
- if (5 === node.tag) {
- var instance = node.stateNode;
- needsVisibilityToggle &&
- isHidden &&
- (instance = cloneHiddenInstance(instance));
- appendChildNodeToSet(containerChildSet, instance.node);
- } else if (6 === node.tag) {
- instance = node.stateNode;
- if (needsVisibilityToggle && isHidden)
- throw Error("Not yet implemented.");
- appendChildNodeToSet(containerChildSet, instance.node);
- } else if (4 !== node.tag) {
- if (
- 13 === node.tag &&
- 0 !== (node.flags & 4) &&
- (instance = null !== node.memoizedState)
- ) {
- var primaryChildParent = node.child;
- if (
- null !== primaryChildParent &&
- (null !== primaryChildParent.child &&
- ((primaryChildParent.child.return = primaryChildParent),
- appendAllChildrenToContainer(
- containerChildSet,
- primaryChildParent,
- !0,
- instance
- )),
- (instance = primaryChildParent.sibling),
- null !== instance)
- ) {
- instance.return = node;
- node = instance;
+ var renderState = workInProgress.memoizedState;
+ null === renderState
+ ? (workInProgress.memoizedState = {
+ isBackwards: isBackwards,
+ rendering: null,
+ renderingStartTime: 0,
+ last: lastContentRow,
+ tail: tail,
+ tailMode: tailMode
+ })
+ : ((renderState.isBackwards = isBackwards),
+ (renderState.rendering = null),
+ (renderState.renderingStartTime = 0),
+ (renderState.last = lastContentRow),
+ (renderState.tail = tail),
+ (renderState.tailMode = tailMode));
+}
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
+ revealOrder = nextProps.revealOrder,
+ tailMode = nextProps.tail;
+ reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
+ nextProps = suspenseStackCursor.current;
+ if (0 !== (nextProps & 2))
+ (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128);
+ else {
+ if (null !== current && 0 !== (current.flags & 128))
+ a: for (current = workInProgress.child; null !== current; ) {
+ if (13 === current.tag)
+ null !== current.memoizedState &&
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
+ else if (19 === current.tag)
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
+ else if (null !== current.child) {
+ current.child.return = current;
+ current = current.child;
continue;
}
+ if (current === workInProgress) break a;
+ for (; null === current.sibling; ) {
+ if (null === current.return || current.return === workInProgress)
+ break a;
+ current = current.return;
+ }
+ current.sibling.return = current.return;
+ current = current.sibling;
}
- if (null !== node.child) {
- node.child.return = node;
- node = node.child;
- continue;
- }
- }
- if (node === workInProgress) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === workInProgress) return;
- node = node.return;
- }
- node.sibling.return = node.return;
- node = node.sibling;
- }
-}
-updateHostContainer = function(current, workInProgress) {
- var portalOrRoot = workInProgress.stateNode;
- if (!hadNoMutationsEffects(current, workInProgress)) {
- current = portalOrRoot.containerInfo;
- var newChildSet = createChildNodeSet(current);
- appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1);
- portalOrRoot.pendingChildren = newChildSet;
- workInProgress.flags |= 4;
- completeRoot(current, newChildSet);
- }
-};
-updateHostComponent$1 = function(current, workInProgress, type, newProps) {
- type = current.stateNode;
- var oldProps = current.memoizedProps;
- if (
- (current = hadNoMutationsEffects(current, workInProgress)) &&
- oldProps === newProps
- )
- workInProgress.stateNode = type;
- else {
- var recyclableInstance = workInProgress.stateNode;
- requiredContext(contextStackCursor$1.current);
- var updatePayload = null;
- oldProps !== newProps &&
- ((oldProps = diffProperties(
- null,
- oldProps,
- newProps,
- recyclableInstance.canonical.viewConfig.validAttributes
- )),
- (recyclableInstance.canonical.currentProps = newProps),
- (updatePayload = oldProps));
- current && null === updatePayload
- ? (workInProgress.stateNode = type)
- : ((newProps = updatePayload),
- (oldProps = type.node),
- (type = {
- node: current
- ? null !== newProps
- ? cloneNodeWithNewProps(oldProps, newProps)
- : cloneNode(oldProps)
- : null !== newProps
- ? cloneNodeWithNewChildrenAndProps(oldProps, newProps)
- : cloneNodeWithNewChildren(oldProps),
- canonical: type.canonical
- }),
- (workInProgress.stateNode = type),
- current
- ? (workInProgress.flags |= 4)
- : appendAllChildren(type, workInProgress, !1, !1));
- }
-};
-updateHostText$1 = function(current, workInProgress, oldText, newText) {
- oldText !== newText
- ? ((current = requiredContext(rootInstanceStackCursor.current)),
- (oldText = requiredContext(contextStackCursor$1.current)),
- (workInProgress.stateNode = createTextInstance(
- newText,
- current,
- oldText,
- workInProgress
- )),
- (workInProgress.flags |= 4))
- : (workInProgress.stateNode = current.stateNode);
-};
-function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
- switch (renderState.tailMode) {
- case "hidden":
- hasRenderedATailFallback = renderState.tail;
- for (var lastTailNode = null; null !== hasRenderedATailFallback; )
- null !== hasRenderedATailFallback.alternate &&
- (lastTailNode = hasRenderedATailFallback),
- (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
- null === lastTailNode
- ? (renderState.tail = null)
- : (lastTailNode.sibling = null);
- break;
- case "collapsed":
- lastTailNode = renderState.tail;
- for (var lastTailNode$69 = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (lastTailNode$69 = lastTailNode),
- (lastTailNode = lastTailNode.sibling);
- null === lastTailNode$69
- ? hasRenderedATailFallback || null === renderState.tail
- ? (renderState.tail = null)
- : (renderState.tail.sibling = null)
- : (lastTailNode$69.sibling = null);
+ nextProps &= 1;
}
-}
-function bubbleProperties(completedWork) {
- var didBailout =
- null !== completedWork.alternate &&
- completedWork.alternate.child === completedWork.child,
- newChildLanes = 0,
- subtreeFlags = 0;
- if (didBailout)
- for (var child$70 = completedWork.child; null !== child$70; )
- (newChildLanes |= child$70.lanes | child$70.childLanes),
- (subtreeFlags |= child$70.subtreeFlags & 1835008),
- (subtreeFlags |= child$70.flags & 1835008),
- (child$70.return = completedWork),
- (child$70 = child$70.sibling);
+ push(suspenseStackCursor, nextProps);
+ if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null;
else
- for (child$70 = completedWork.child; null !== child$70; )
- (newChildLanes |= child$70.lanes | child$70.childLanes),
- (subtreeFlags |= child$70.subtreeFlags),
- (subtreeFlags |= child$70.flags),
- (child$70.return = completedWork),
- (child$70 = child$70.sibling);
- completedWork.subtreeFlags |= subtreeFlags;
- completedWork.childLanes = newChildLanes;
- return didBailout;
-}
-function completeWork(current, workInProgress, renderLanes) {
- var newProps = workInProgress.pendingProps;
- switch (workInProgress.tag) {
- case 2:
- case 16:
- case 15:
- case 0:
- case 11:
- case 7:
- case 8:
- case 12:
- case 9:
- case 14:
- return bubbleProperties(workInProgress), null;
- case 1:
- return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
- );
- case 3:
- return (
- (newProps = workInProgress.stateNode),
- popHostContainer(),
- pop(didPerformWorkStackCursor),
- pop(contextStackCursor),
- resetWorkInProgressVersions(),
- newProps.pendingContext &&
- ((newProps.context = newProps.pendingContext),
- (newProps.pendingContext = null)),
- (null !== current && null !== current.child) ||
- newProps.hydrate ||
- (workInProgress.flags |= 512),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
- case 5:
- popHostContext(workInProgress);
- renderLanes = requiredContext(rootInstanceStackCursor.current);
- var type = workInProgress.type;
- if (null !== current && null != workInProgress.stateNode)
- updateHostComponent$1(
- current,
+ switch (revealOrder) {
+ case "forwards":
+ renderLanes = workInProgress.child;
+ for (revealOrder = null; null !== renderLanes; )
+ (current = renderLanes.alternate),
+ null !== current &&
+ null === findFirstSuspended(current) &&
+ (revealOrder = renderLanes),
+ (renderLanes = renderLanes.sibling);
+ renderLanes = revealOrder;
+ null === renderLanes
+ ? ((revealOrder = workInProgress.child),
+ (workInProgress.child = null))
+ : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
+ initSuspenseListRenderState(
workInProgress,
- type,
- newProps,
- renderLanes
- ),
- current.ref !== workInProgress.ref && (workInProgress.flags |= 256);
- else {
- if (!newProps) {
- if (null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- bubbleProperties(workInProgress);
- return null;
- }
- requiredContext(contextStackCursor$1.current);
- current = nextReactTag;
- nextReactTag += 2;
- type = getViewConfigForType(type);
- var updatePayload = diffProperties(
- null,
- emptyObject,
- newProps,
- type.validAttributes
- );
- renderLanes = createNode(
- current,
- type.uiViewClassName,
+ !1,
+ revealOrder,
renderLanes,
- updatePayload,
- workInProgress
- );
- current = new ReactFabricHostComponent(
- current,
- type,
- newProps,
- workInProgress
+ tailMode
);
- current = { node: renderLanes, canonical: current };
- appendAllChildren(current, workInProgress, !1, !1);
- workInProgress.stateNode = current;
- null !== workInProgress.ref && (workInProgress.flags |= 256);
- }
- bubbleProperties(workInProgress);
- return null;
- case 6:
- if (current && null != workInProgress.stateNode)
- updateHostText$1(
- current,
+ break;
+ case "backwards":
+ renderLanes = null;
+ revealOrder = workInProgress.child;
+ for (workInProgress.child = null; null !== revealOrder; ) {
+ current = revealOrder.alternate;
+ if (null !== current && null === findFirstSuspended(current)) {
+ workInProgress.child = revealOrder;
+ break;
+ }
+ current = revealOrder.sibling;
+ revealOrder.sibling = renderLanes;
+ renderLanes = revealOrder;
+ revealOrder = current;
+ }
+ initSuspenseListRenderState(
workInProgress,
- current.memoizedProps,
- newProps
- );
- else {
- if ("string" !== typeof newProps && null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- current = requiredContext(rootInstanceStackCursor.current);
- renderLanes = requiredContext(contextStackCursor$1.current);
- workInProgress.stateNode = createTextInstance(
- newProps,
- current,
+ !0,
renderLanes,
- workInProgress
+ null,
+ tailMode
);
- }
- bubbleProperties(workInProgress);
- return null;
- case 13:
- pop(suspenseStackCursor);
- newProps = workInProgress.memoizedState;
- if (0 !== (workInProgress.flags & 128))
- return (workInProgress.lanes = renderLanes), workInProgress;
- newProps = null !== newProps;
- renderLanes = !1;
- null !== current && (renderLanes = null !== current.memoizedState);
- if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1))
- if (
- (null === current &&
- !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
- 0 !== (suspenseStackCursor.current & 1)
- )
- 0 === workInProgressRootExitStatus &&
- (workInProgressRootExitStatus = 3);
- else {
- if (
- 0 === workInProgressRootExitStatus ||
- 3 === workInProgressRootExitStatus
- )
- workInProgressRootExitStatus = 4;
- null === workInProgressRoot ||
- (0 === (workInProgressRootSkippedLanes & 268435455) &&
- 0 === (workInProgressRootUpdatedLanes & 268435455)) ||
- markRootSuspended$1(
- workInProgressRoot,
- workInProgressRootRenderLanes
- );
- }
- newProps && (workInProgress.flags |= 4);
- bubbleProperties(workInProgress);
- return null;
- case 4:
- return (
- popHostContainer(),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
- case 10:
- return (
- popProvider(workInProgress.type._context),
- bubbleProperties(workInProgress),
- null
- );
- case 17:
- return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
- );
- case 19:
- pop(suspenseStackCursor);
- type = workInProgress.memoizedState;
- if (null === type) return bubbleProperties(workInProgress), null;
- newProps = 0 !== (workInProgress.flags & 128);
- updatePayload = type.rendering;
- if (null === updatePayload)
- if (newProps) cutOffTailIfNeeded(type, !1);
- else {
- if (
- 0 !== workInProgressRootExitStatus ||
- (null !== current && 0 !== (current.flags & 128))
- )
- for (current = workInProgress.child; null !== current; ) {
- updatePayload = findFirstSuspended(current);
- if (null !== updatePayload) {
- workInProgress.flags |= 128;
- cutOffTailIfNeeded(type, !1);
- current = updatePayload.updateQueue;
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4));
- workInProgress.subtreeFlags = 0;
- current = renderLanes;
- for (newProps = workInProgress.child; null !== newProps; )
- (renderLanes = newProps),
- (type = current),
- (renderLanes.flags &= 1835010),
- (updatePayload = renderLanes.alternate),
- null === updatePayload
- ? ((renderLanes.childLanes = 0),
- (renderLanes.lanes = type),
- (renderLanes.child = null),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.memoizedProps = null),
- (renderLanes.memoizedState = null),
- (renderLanes.updateQueue = null),
- (renderLanes.dependencies = null),
- (renderLanes.stateNode = null))
- : ((renderLanes.childLanes = updatePayload.childLanes),
- (renderLanes.lanes = updatePayload.lanes),
- (renderLanes.child = updatePayload.child),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.deletions = null),
- (renderLanes.memoizedProps =
- updatePayload.memoizedProps),
- (renderLanes.memoizedState =
- updatePayload.memoizedState),
- (renderLanes.updateQueue = updatePayload.updateQueue),
- (renderLanes.type = updatePayload.type),
- (type = updatePayload.dependencies),
- (renderLanes.dependencies =
- null === type
- ? null
- : {
- lanes: type.lanes,
- firstContext: type.firstContext
- })),
- (newProps = newProps.sibling);
- push(
- suspenseStackCursor,
- (suspenseStackCursor.current & 1) | 2
- );
- return workInProgress.child;
- }
- current = current.sibling;
- }
- null !== type.tail &&
- now() > workInProgressRootRenderTargetTime &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
- }
- else {
- if (!newProps)
- if (
- ((current = findFirstSuspended(updatePayload)), null !== current)
- ) {
- if (
- ((workInProgress.flags |= 128),
- (newProps = !0),
- (current = current.updateQueue),
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4)),
- cutOffTailIfNeeded(type, !0),
- null === type.tail &&
- "hidden" === type.tailMode &&
- !updatePayload.alternate)
- )
- return bubbleProperties(workInProgress), null;
- } else
- 2 * now() - type.renderingStartTime >
- workInProgressRootRenderTargetTime &&
- 1073741824 !== renderLanes &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
- type.isBackwards
- ? ((updatePayload.sibling = workInProgress.child),
- (workInProgress.child = updatePayload))
- : ((current = type.last),
- null !== current
- ? (current.sibling = updatePayload)
- : (workInProgress.child = updatePayload),
- (type.last = updatePayload));
- }
- if (null !== type.tail)
- return (
- (workInProgress = type.tail),
- (type.rendering = workInProgress),
- (type.tail = workInProgress.sibling),
- (type.renderingStartTime = now()),
- (workInProgress.sibling = null),
- (current = suspenseStackCursor.current),
- push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
- workInProgress
+ break;
+ case "together":
+ initSuspenseListRenderState(workInProgress, !1, null, null, void 0);
+ break;
+ default:
+ workInProgress.memoizedState = null;
+ }
+ return workInProgress.child;
+}
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
+ null !== current && (workInProgress.dependencies = current.dependencies);
+ workInProgressRootSkippedLanes |= workInProgress.lanes;
+ if (0 === (renderLanes & workInProgress.childLanes)) return null;
+ 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;
+}
+function attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+) {
+ 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:
+ var context = workInProgress.type._context,
+ nextValue = workInProgress.memoizedProps.value;
+ push(valueCursor, context._currentValue2);
+ context._currentValue2 = nextValue;
+ break;
+ case 13:
+ if (null !== workInProgress.memoizedState) {
+ if (0 !== (renderLanes & workInProgress.child.childLanes))
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ current = bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
);
- bubbleProperties(workInProgress);
- return null;
+ return null !== current ? current.sibling : null;
+ }
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
+ case 19:
+ context = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.flags & 128)) {
+ if (context)
+ return updateSuspenseListComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ workInProgress.flags |= 128;
+ }
+ nextValue = workInProgress.memoizedState;
+ null !== nextValue &&
+ ((nextValue.rendering = null),
+ (nextValue.tail = null),
+ (nextValue.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (context) break;
+ else return null;
case 22:
case 23:
return (
- popRenderLanes(),
- (renderLanes = null !== workInProgress.memoizedState),
- null !== current &&
- (null !== current.memoizedState) !== renderLanes &&
- "unstable-defer-without-hiding" !== newProps.mode &&
- (workInProgress.flags |= 4),
- (renderLanes &&
- 0 === (subtreeRenderLanes & 1073741824) &&
- 0 !== (workInProgress.mode & 1)) ||
- bubbleProperties(workInProgress),
- null
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
);
}
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
-function unwindWork(workInProgress) {
+function unwindWork(current, workInProgress) {
+ popTreeContext(workInProgress);
switch (workInProgress.tag) {
case 1:
- isContextProvider(workInProgress.type) && popContext();
- var flags = workInProgress.flags;
- return flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress)
- : null;
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
+ : null
+ );
case 3:
- popHostContainer();
- pop(didPerformWorkStackCursor);
- pop(contextStackCursor);
- resetWorkInProgressVersions();
- flags = workInProgress.flags;
- if (0 !== (flags & 128))
- throw Error(
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
- );
- workInProgress.flags = (flags & -16385) | 128;
- return workInProgress;
+ return (
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ (current = workInProgress.flags),
+ 0 !== (current & 65536) && 0 === (current & 128)
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
+ : null
+ );
case 5:
return popHostContext(workInProgress), null;
case 13:
return (
pop(suspenseStackCursor),
- (flags = workInProgress.flags),
- flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress)
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
: null
);
case 19:
@@ -5508,13 +5659,20 @@ function safelyDetachRef(current, nearestMountedAncestor) {
}
else ref.current = null;
}
+function safelyCallDestroy(current, nearestMountedAncestor, destroy) {
+ try {
+ destroy();
+ } catch (error) {
+ captureCommitPhaseError(current, nearestMountedAncestor, error);
+ }
+}
var shouldFireAfterActiveInstanceBlur = !1;
function commitBeforeMutationEffects(root, firstChild) {
for (nextEffect = firstChild; null !== nextEffect; )
if (
((root = nextEffect),
(firstChild = root.child),
- 0 !== (root.subtreeFlags & 516) && null !== firstChild)
+ 0 !== (root.subtreeFlags & 1028) && null !== firstChild)
)
(firstChild.return = root), (nextEffect = firstChild);
else
@@ -5522,7 +5680,7 @@ function commitBeforeMutationEffects(root, firstChild) {
root = nextEffect;
try {
var current = root.alternate;
- if (0 !== (root.flags & 512))
+ if (0 !== (root.flags & 1024))
switch (root.tag) {
case 0:
case 11:
@@ -5572,7 +5730,7 @@ function commitBeforeMutationEffects(root, firstChild) {
function commitHookEffectListUnmount(
flags,
finishedWork,
- nearestMountedAncestor$jscomp$0
+ nearestMountedAncestor
) {
var updateQueue = finishedWork.updateQueue;
updateQueue = null !== updateQueue ? updateQueue.lastEffect : null;
@@ -5582,29 +5740,22 @@ function commitHookEffectListUnmount(
if ((effect.tag & flags) === flags) {
var destroy = effect.destroy;
effect.destroy = void 0;
- if (void 0 !== destroy) {
- var current = finishedWork,
- nearestMountedAncestor = nearestMountedAncestor$jscomp$0;
- try {
- destroy();
- } catch (error) {
- captureCommitPhaseError(current, nearestMountedAncestor, error);
- }
- }
+ void 0 !== destroy &&
+ safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy);
}
effect = effect.next;
} while (effect !== updateQueue);
}
}
-function commitHookEffectListMount(tag, finishedWork) {
+function commitHookEffectListMount(flags, 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$82 = effect.create;
- effect.destroy = create$82();
+ if ((effect.tag & flags) === flags) {
+ var create$77 = effect.create;
+ effect.destroy = create$77();
}
effect = effect.next;
} while (effect !== finishedWork);
@@ -5633,12 +5784,12 @@ function commitWork(current, finishedWork) {
case 14:
case 15:
commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ commitHookEffectListMount(3, finishedWork);
+ commitHookEffectListUnmount(5, finishedWork, finishedWork.return);
return;
case 12:
return;
case 13:
- null !== finishedWork.memoizedState &&
- (globalMostRecentFallbackTime = now());
attachSuspenseRetryListeners(finishedWork);
return;
case 19:
@@ -5709,19 +5860,11 @@ function commitMutationEffects(root, firstChild) {
var _effect = effect,
destroy = _effect.destroy,
tag = _effect.tag;
- if (void 0 !== destroy && 0 !== (tag & 2)) {
- _effect = current;
- var nearestMountedAncestor = root;
- try {
- destroy();
- } catch (error) {
- captureCommitPhaseError(
- _effect,
- nearestMountedAncestor,
- error
- );
- }
- }
+ void 0 !== destroy &&
+ (0 !== (tag & 2)
+ ? safelyCallDestroy(current, root, destroy)
+ : 0 !== (tag & 4) &&
+ safelyCallDestroy(current, root, destroy));
effect = effect.next;
} while (effect !== firstEffect);
}
@@ -5737,8 +5880,8 @@ function commitMutationEffects(root, firstChild) {
(_effect.props = effect.memoizedProps),
(_effect.state = effect.memoizedState),
_effect.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(current, root, unmountError);
+ } catch (error) {
+ captureCommitPhaseError(current, root, error);
}
break;
case 5:
@@ -5768,14 +5911,14 @@ function commitMutationEffects(root, firstChild) {
}
}
firstChild = root.child;
- if (0 !== (root.subtreeFlags & 6454) && null !== firstChild)
+ if (0 !== (root.subtreeFlags & 12854) && null !== firstChild)
(firstChild.return = root), (nextEffect = firstChild);
else
for (; null !== nextEffect; ) {
root = nextEffect;
try {
var flags = root.flags;
- if (flags & 256) {
+ if (flags & 512) {
var current$jscomp$0 = root.alternate;
if (null !== current$jscomp$0) {
var currentRef = current$jscomp$0.ref;
@@ -5785,7 +5928,16 @@ function commitMutationEffects(root, firstChild) {
: (currentRef.current = null));
}
}
- switch (flags & 2054) {
+ if (flags & 8192)
+ switch (root.tag) {
+ case 13:
+ if (null !== root.memoizedState) {
+ var current$81 = root.alternate;
+ if (null === current$81 || null === current$81.memoizedState)
+ globalMostRecentFallbackTime = now();
+ }
+ }
+ switch (flags & 4102) {
case 2:
root.flags &= -3;
break;
@@ -5793,11 +5945,11 @@ function commitMutationEffects(root, firstChild) {
root.flags &= -3;
commitWork(root.alternate, root);
break;
- case 2048:
- root.flags &= -2049;
+ case 4096:
+ root.flags &= -4097;
break;
- case 2052:
- root.flags &= -2049;
+ case 4100:
+ root.flags &= -4097;
commitWork(root.alternate, root);
break;
case 4:
@@ -5820,20 +5972,20 @@ function commitLayoutEffects(finishedWork) {
for (nextEffect = finishedWork; null !== nextEffect; ) {
var fiber = nextEffect,
firstChild = fiber.child;
- if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild)
+ if (0 !== (fiber.subtreeFlags & 8772) && null !== firstChild)
(firstChild.return = fiber), (nextEffect = firstChild);
else
for (fiber = finishedWork; null !== nextEffect; ) {
firstChild = nextEffect;
- if (0 !== (firstChild.flags & 324)) {
+ if (0 !== (firstChild.flags & 8772)) {
var current = firstChild.alternate;
try {
- if (0 !== (firstChild.flags & 68))
+ if (0 !== (firstChild.flags & 8772))
switch (firstChild.tag) {
case 0:
case 11:
case 15:
- commitHookEffectListMount(3, firstChild);
+ commitHookEffectListMount(5, firstChild);
break;
case 1:
var instance = firstChild.stateNode;
@@ -5858,8 +6010,8 @@ function commitLayoutEffects(finishedWork) {
commitUpdateQueue(firstChild, updateQueue, instance);
break;
case 3:
- var updateQueue$83 = firstChild.updateQueue;
- if (null !== updateQueue$83) {
+ var updateQueue$78 = firstChild.updateQueue;
+ if (null !== updateQueue$78) {
current = null;
if (null !== firstChild.child)
switch (firstChild.child.tag) {
@@ -5869,11 +6021,14 @@ function commitLayoutEffects(finishedWork) {
case 1:
current = firstChild.child.stateNode;
}
- commitUpdateQueue(firstChild, updateQueue$83, current);
+ commitUpdateQueue(firstChild, updateQueue$78, current);
}
break;
case 5:
- null === current && firstChild.flags & 4 && shim();
+ if (null === current && firstChild.flags & 4)
+ throw Error(
+ "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue."
+ );
break;
case 6:
break;
@@ -5894,7 +6049,7 @@ function commitLayoutEffects(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."
);
}
- if (firstChild.flags & 256) {
+ if (firstChild.flags & 512) {
current = void 0;
var ref = firstChild.ref;
if (null !== ref) {
@@ -5942,8 +6097,10 @@ var ceil = Math.ceil,
workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
workInProgressRootSkippedLanes = 0,
- workInProgressRootUpdatedLanes = 0,
+ workInProgressRootInterleavedUpdatedLanes = 0,
workInProgressRootPingedLanes = 0,
+ workInProgressRootConcurrentErrors = null,
+ workInProgressRootRecoverableErrors = null,
globalMostRecentFallbackTime = 0,
workInProgressRootRenderTargetTime = Infinity,
hasUncaughtError = !1,
@@ -5957,7 +6114,7 @@ var ceil = Math.ceil,
currentEventTime = -1,
currentEventTransitionLane = 0;
function requestEventTime() {
- return 0 !== (executionContext & 24)
+ return 0 !== (executionContext & 6)
? now()
: -1 !== currentEventTime
? currentEventTime
@@ -5965,9 +6122,9 @@ function requestEventTime() {
}
function requestUpdateLane(fiber) {
if (0 === (fiber.mode & 1)) return 1;
- if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes)
+ if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes)
return workInProgressRootRenderLanes & -workInProgressRootRenderLanes;
- if (0 !== ReactCurrentBatchConfig.transition)
+ if (null !== ReactCurrentBatchConfig.transition)
return (
0 === currentEventTransitionLane &&
((fiber = nextTransitionLane),
@@ -6002,19 +6159,18 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) {
var root = markUpdateLaneFromFiberToRoot(fiber, lane);
if (null === root) return null;
markRootUpdated(root, lane, eventTime);
- root === workInProgressRoot &&
- (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane),
- 4 === workInProgressRootExitStatus &&
- markRootSuspended$1(root, workInProgressRootRenderLanes));
- 1 === lane
- ? 0 !== (executionContext & 4) && 0 === (executionContext & 24)
- ? performSyncWorkOnRoot(root)
- : (ensureRootIsScheduled(root, eventTime),
+ if (0 === (executionContext & 2) || root !== workInProgressRoot)
+ root === workInProgressRoot &&
+ (0 === (executionContext & 2) &&
+ (workInProgressRootInterleavedUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(root, workInProgressRootRenderLanes)),
+ ensureRootIsScheduled(root, eventTime),
+ 1 === lane &&
0 === executionContext &&
- 0 === (fiber.mode & 1) &&
- ((workInProgressRootRenderTargetTime = now() + 500),
- includesLegacySyncCallbacks && flushSyncCallbacks()))
- : ensureRootIsScheduled(root, eventTime);
+ 0 === (fiber.mode & 1) &&
+ ((workInProgressRootRenderTargetTime = now() + 500),
+ includesLegacySyncCallbacks && flushSyncCallbacks());
return root;
}
function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
@@ -6092,7 +6248,7 @@ function ensureRootIsScheduled(root, currentTime) {
default:
existingCallbackNode = NormalPriority;
}
- existingCallbackNode = scheduleCallback(
+ existingCallbackNode = scheduleCallback$1(
existingCallbackNode,
performConcurrentWorkOnRoot.bind(null, root)
);
@@ -6104,7 +6260,7 @@ function ensureRootIsScheduled(root, currentTime) {
function performConcurrentWorkOnRoot(root, didTimeout) {
currentEventTime = -1;
currentEventTransitionLane = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var originalCallbackNode = root.callbackNode;
if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
@@ -6114,12 +6270,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
root === workInProgressRoot ? workInProgressRootRenderLanes : 0
);
if (0 === lanes) return null;
- var JSCompiler_inline_result =
- 0 !== (lanes & root.expiredLanes) ? !1 : 0 === (lanes & 30);
- if (JSCompiler_inline_result && !didTimeout) {
+ if (0 !== (lanes & 30) || 0 !== (lanes & root.expiredLanes) || didTimeout)
+ didTimeout = renderRootSync(root, lanes);
+ else {
didTimeout = lanes;
- JSCompiler_inline_result = executionContext;
- executionContext |= 8;
+ var prevExecutionContext = executionContext;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
if (
workInProgressRoot !== root ||
@@ -6137,100 +6293,117 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
while (1);
resetContextDependencies();
ReactCurrentDispatcher$2.current = prevDispatcher;
- executionContext = JSCompiler_inline_result;
+ executionContext = prevExecutionContext;
null !== workInProgress
? (didTimeout = 0)
: ((workInProgressRoot = null),
(workInProgressRootRenderLanes = 0),
(didTimeout = workInProgressRootExitStatus));
- } else didTimeout = renderRootSync(root, lanes);
+ }
if (0 !== didTimeout) {
2 === didTimeout &&
- ((executionContext |= 32),
- root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)),
- (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)),
- 0 !== JSCompiler_inline_result &&
- ((lanes = JSCompiler_inline_result),
- (didTimeout = renderRootSync(root, JSCompiler_inline_result))));
+ ((prevExecutionContext = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevExecutionContext &&
+ ((lanes = prevExecutionContext),
+ (didTimeout = recoverFromConcurrentError(root, prevExecutionContext))));
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 2:
- commitRoot(root);
- break;
- case 3:
- markRootSuspended$1(root, lanes);
- if (
- (lanes & 130023424) === lanes &&
- ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
- 10 < didTimeout)
- ) {
- if (0 !== getNextLanes(root, 0)) break;
- JSCompiler_inline_result = root.suspendedLanes;
- if ((JSCompiler_inline_result & lanes) !== lanes) {
- requestEventTime();
- root.pingedLanes |= root.suspendedLanes & JSCompiler_inline_result;
+ if (6 === didTimeout) markRootSuspended$1(root, lanes);
+ else {
+ prevExecutionContext = root.current.alternate;
+ if (
+ 0 === (lanes & 30) &&
+ !isRenderConsistentWithExternalStores(prevExecutionContext) &&
+ ((didTimeout = renderRootSync(root, lanes)),
+ 2 === didTimeout &&
+ ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevDispatcher &&
+ ((lanes = prevDispatcher),
+ (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))),
+ 1 === didTimeout)
+ )
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = prevExecutionContext;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
+ throw Error("Root did not complete. This is a bug in React.");
+ case 2:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ case 3:
+ markRootSuspended$1(root, lanes);
+ if (
+ (lanes & 130023424) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
+ ) {
+ 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, workInProgressRootRecoverableErrors),
+ didTimeout
+ );
break;
}
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- didTimeout
- );
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 4:
- markRootSuspended$1(root, lanes);
- if ((lanes & 4194240) === lanes) break;
- didTimeout = root.eventTimes;
- for (JSCompiler_inline_result = -1; 0 < lanes; ) {
- var index$4 = 31 - clz32(lanes);
- prevDispatcher = 1 << index$4;
- index$4 = didTimeout[index$4];
- index$4 > JSCompiler_inline_result &&
- (JSCompiler_inline_result = index$4);
- lanes &= ~prevDispatcher;
- }
- lanes = JSCompiler_inline_result;
- lanes = now() - lanes;
- lanes =
- (120 > lanes
- ? 120
- : 480 > lanes
- ? 480
- : 1080 > lanes
- ? 1080
- : 1920 > lanes
- ? 1920
- : 3e3 > lanes
- ? 3e3
- : 4320 > lanes
- ? 4320
- : 1960 * ceil(lanes / 1960)) - lanes;
- if (10 < lanes) {
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- lanes
- );
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if ((lanes & 4194240) === lanes) break;
+ didTimeout = root.eventTimes;
+ for (prevExecutionContext = -1; 0 < lanes; ) {
+ var index$4 = 31 - clz32(lanes);
+ prevDispatcher = 1 << index$4;
+ index$4 = didTimeout[index$4];
+ index$4 > prevExecutionContext && (prevExecutionContext = index$4);
+ lanes &= ~prevDispatcher;
+ }
+ lanes = prevExecutionContext;
+ lanes = now() - lanes;
+ lanes =
+ (120 > lanes
+ ? 120
+ : 480 > lanes
+ ? 480
+ : 1080 > lanes
+ ? 1080
+ : 1920 > lanes
+ ? 1920
+ : 3e3 > lanes
+ ? 3e3
+ : 4320 > lanes
+ ? 4320
+ : 1960 * ceil(lanes / 1960)) - lanes;
+ if (10 < lanes) {
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
+ lanes
+ );
+ break;
+ }
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 5:
- commitRoot(root);
- break;
- default:
- throw Error("Unknown root exit status.");
+ case 5:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ default:
+ throw Error("Unknown root exit status.");
+ }
}
}
ensureRootIsScheduled(root, now());
@@ -6238,9 +6411,60 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function recoverFromConcurrentError(root, errorRetryLanes) {
+ var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
+ root.current.memoizedState.isDehydrated &&
+ (prepareFreshStack(root, errorRetryLanes).flags |= 256);
+ root = renderRootSync(root, errorRetryLanes);
+ 2 !== root &&
+ ((errorRetryLanes = workInProgressRootRecoverableErrors),
+ (workInProgressRootRecoverableErrors = errorsFromFirstAttempt),
+ null !== errorRetryLanes &&
+ (null === workInProgressRootRecoverableErrors
+ ? (workInProgressRootRecoverableErrors = errorRetryLanes)
+ : workInProgressRootRecoverableErrors.push.apply(
+ workInProgressRootRecoverableErrors,
+ errorRetryLanes
+ )));
+ return root;
+}
+function isRenderConsistentWithExternalStores(finishedWork) {
+ for (var node = finishedWork; ; ) {
+ if (node.flags & 16384) {
+ var updateQueue = node.updateQueue;
+ if (
+ null !== updateQueue &&
+ ((updateQueue = updateQueue.stores), null !== updateQueue)
+ )
+ for (var i = 0; i < updateQueue.length; i++) {
+ var check = updateQueue[i],
+ getSnapshot = check.getSnapshot;
+ check = check.value;
+ try {
+ if (!objectIs(getSnapshot(), check)) return !1;
+ } catch (error) {
+ return !1;
+ }
+ }
+ }
+ updateQueue = node.child;
+ if (node.subtreeFlags & 16384 && null !== updateQueue)
+ (updateQueue.return = node), (node = updateQueue);
+ else {
+ if (node === finishedWork) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === finishedWork) return !0;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+ }
+ return !0;
+}
function markRootSuspended$1(root, suspendedLanes) {
suspendedLanes &= ~workInProgressRootPingedLanes;
- suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes;
root.suspendedLanes |= suspendedLanes;
root.pingedLanes &= ~suspendedLanes;
for (root = root.expirationTimes; 0 < suspendedLanes; ) {
@@ -6251,18 +6475,17 @@ function markRootSuspended$1(root, suspendedLanes) {
}
}
function performSyncWorkOnRoot(root) {
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
flushPassiveEffects();
var lanes = getNextLanes(root, 0);
if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null;
var exitStatus = renderRootSync(root, lanes);
if (0 !== root.tag && 2 === exitStatus) {
- executionContext |= 32;
- root.hydrate && ((root.hydrate = !1), shim(root.containerInfo));
var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
0 !== errorRetryLanes &&
- ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes)));
+ ((lanes = errorRetryLanes),
+ (exitStatus = recoverFromConcurrentError(root, errorRetryLanes)));
}
if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
@@ -6270,9 +6493,11 @@ function performSyncWorkOnRoot(root) {
markRootSuspended$1(root, lanes),
ensureRootIsScheduled(root, now()),
exitStatus);
+ if (6 === exitStatus)
+ throw Error("Root did not complete. This is a bug in React.");
root.finishedWork = root.current.alternate;
root.finishedLanes = lanes;
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
ensureRootIsScheduled(root, now());
return null;
}
@@ -6289,6 +6514,7 @@ function prepareFreshStack(root, lanes) {
if (null !== workInProgress)
for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) {
var interruptedWork = timeoutHandle;
+ popTreeContext(interruptedWork);
switch (interruptedWork.tag) {
case 1:
interruptedWork = interruptedWork.type.childContextTypes;
@@ -6324,30 +6550,32 @@ function prepareFreshStack(root, lanes) {
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
+ workInProgress = root = createWorkInProgress(root.current, null);
workInProgressRootRenderLanes = subtreeRenderLanes = lanes;
workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootPingedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors = null;
if (null !== interleavedQueues) {
- for (root = 0; root < interleavedQueues.length; root++)
+ for (lanes = 0; lanes < interleavedQueues.length; lanes++)
if (
- ((lanes = interleavedQueues[root]),
- (timeoutHandle = lanes.interleaved),
- null !== timeoutHandle)
+ ((timeoutHandle = interleavedQueues[lanes]),
+ (interruptedWork = timeoutHandle.interleaved),
+ null !== interruptedWork)
) {
- lanes.interleaved = null;
- interruptedWork = timeoutHandle.next;
- var lastPendingUpdate = lanes.pending;
+ timeoutHandle.interleaved = null;
+ var firstInterleavedUpdate = interruptedWork.next,
+ lastPendingUpdate = timeoutHandle.pending;
if (null !== lastPendingUpdate) {
var firstPendingUpdate = lastPendingUpdate.next;
- lastPendingUpdate.next = interruptedWork;
- timeoutHandle.next = firstPendingUpdate;
+ lastPendingUpdate.next = firstInterleavedUpdate;
+ interruptedWork.next = firstPendingUpdate;
}
- lanes.pending = timeoutHandle;
+ timeoutHandle.pending = interruptedWork;
}
interleavedQueues = null;
}
+ return root;
}
function handleError(root$jscomp$0, thrownValue) {
do {
@@ -6383,61 +6611,59 @@ function handleError(root$jscomp$0, thrownValue) {
sourceFiber = erroredWork,
value = thrownValue;
thrownValue = workInProgressRootRenderLanes;
- sourceFiber.flags |= 8192;
+ sourceFiber.flags |= 32768;
if (
null !== value &&
"object" === typeof value &&
"function" === typeof value.then
) {
var wakeable = value,
- tag = sourceFiber.tag;
+ sourceFiber$jscomp$0 = sourceFiber,
+ tag = sourceFiber$jscomp$0.tag;
if (
- 0 === (sourceFiber.mode & 1) &&
+ 0 === (sourceFiber$jscomp$0.mode & 1) &&
(0 === tag || 11 === tag || 15 === tag)
) {
- var currentSource = sourceFiber.alternate;
+ var currentSource = sourceFiber$jscomp$0.alternate;
currentSource
- ? ((sourceFiber.updateQueue = currentSource.updateQueue),
- (sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.lanes = currentSource.lanes))
- : ((sourceFiber.updateQueue = null),
- (sourceFiber.memoizedState = null));
+ ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue),
+ (sourceFiber$jscomp$0.memoizedState =
+ currentSource.memoizedState),
+ (sourceFiber$jscomp$0.lanes = currentSource.lanes))
+ : ((sourceFiber$jscomp$0.updateQueue = null),
+ (sourceFiber$jscomp$0.memoizedState = null));
}
- var hasInvisibleParentBoundary =
- 0 !== (suspenseStackCursor.current & 1),
- workInProgress$30 = returnFiber;
- do {
- var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === workInProgress$30.tag)) {
- var nextState = workInProgress$30.memoizedState;
- if (null !== nextState)
- JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
- else {
- var props = workInProgress$30.memoizedProps;
+ b: {
+ sourceFiber$jscomp$0 = returnFiber;
+ do {
+ var JSCompiler_temp;
+ if ((JSCompiler_temp = 13 === sourceFiber$jscomp$0.tag)) {
+ var nextState = sourceFiber$jscomp$0.memoizedState;
JSCompiler_temp =
- void 0 === props.fallback
- ? !1
- : !0 !== props.unstable_avoidThisFallback
- ? !0
- : hasInvisibleParentBoundary
- ? !1
+ null !== nextState
+ ? null !== nextState.dehydrated
+ ? !0
+ : !1
: !0;
}
- }
- if (JSCompiler_temp) {
- var wakeables = workInProgress$30.updateQueue;
- if (null === wakeables) {
- var updateQueue = new Set();
- updateQueue.add(wakeable);
- workInProgress$30.updateQueue = updateQueue;
- } else wakeables.add(wakeable);
- if (
- 0 === (workInProgress$30.mode & 1) &&
- workInProgress$30 !== returnFiber
- ) {
- workInProgress$30.flags |= 128;
- sourceFiber.flags |= 32768;
- sourceFiber.flags &= -10053;
+ if (JSCompiler_temp) {
+ var suspenseBoundary = sourceFiber$jscomp$0;
+ break b;
+ }
+ sourceFiber$jscomp$0 = sourceFiber$jscomp$0.return;
+ } while (null !== sourceFiber$jscomp$0);
+ suspenseBoundary = null;
+ }
+ if (null !== suspenseBoundary) {
+ suspenseBoundary.flags &= -257;
+ value = suspenseBoundary;
+ sourceFiber$jscomp$0 = thrownValue;
+ if (0 === (value.mode & 1))
+ if (value === returnFiber) value.flags |= 65536;
+ else {
+ value.flags |= 128;
+ sourceFiber.flags |= 131072;
+ sourceFiber.flags &= -52805;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
@@ -6446,83 +6672,78 @@ function handleError(root$jscomp$0, thrownValue) {
enqueueUpdate(sourceFiber, update);
}
sourceFiber.lanes |= 1;
- break a;
- }
- value = void 0;
- sourceFiber = thrownValue;
- var pingCache = root.pingCache;
- null === pingCache
- ? ((pingCache = root.pingCache = new PossiblyWeakMap()),
- (value = new Set()),
- pingCache.set(wakeable, value))
- : ((value = pingCache.get(wakeable)),
- void 0 === value &&
- ((value = new Set()), pingCache.set(wakeable, value)));
- if (!value.has(sourceFiber)) {
- value.add(sourceFiber);
- var ping = pingSuspendedRoot.bind(
- null,
- root,
- wakeable,
- sourceFiber
- );
- wakeable.then(ping, ping);
}
- workInProgress$30.flags |= 16384;
- workInProgress$30.lanes = thrownValue;
+ else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0);
+ suspenseBoundary.mode & 1 &&
+ attachPingListener(root, wakeable, thrownValue);
+ thrownValue = suspenseBoundary;
+ root = wakeable;
+ var wakeables = thrownValue.updateQueue;
+ if (null === wakeables) {
+ var updateQueue = new Set();
+ updateQueue.add(root);
+ thrownValue.updateQueue = updateQueue;
+ } else wakeables.add(root);
+ break a;
+ } else {
+ if (0 === (thrownValue & 1)) {
+ attachPingListener(root, wakeable, thrownValue);
+ renderDidSuspendDelayIfPossible();
break a;
}
- workInProgress$30 = workInProgress$30.return;
- } while (null !== workInProgress$30);
- value = Error(
- (getComponentNameFromFiber(sourceFiber) || "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."
- );
+ value = Error(
+ "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition."
+ );
+ }
}
- 5 !== workInProgressRootExitStatus &&
+ root = value;
+ 4 !== workInProgressRootExitStatus &&
(workInProgressRootExitStatus = 2);
+ null === workInProgressRootConcurrentErrors
+ ? (workInProgressRootConcurrentErrors = [root])
+ : workInProgressRootConcurrentErrors.push(root);
value = createCapturedValue(value, sourceFiber);
- workInProgress$30 = returnFiber;
+ root = returnFiber;
do {
- switch (workInProgress$30.tag) {
+ switch (root.tag) {
case 3:
- root = value;
- workInProgress$30.flags |= 16384;
+ wakeable = value;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$30.lanes |= thrownValue;
- var update$31 = createRootErrorUpdate(
- workInProgress$30,
+ root.lanes |= thrownValue;
+ var update$jscomp$0 = createRootErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$30, update$31);
+ enqueueCapturedUpdate(root, update$jscomp$0);
break a;
case 1:
- root = value;
- var ctor = workInProgress$30.type,
- instance = workInProgress$30.stateNode;
+ wakeable = value;
+ var ctor = root.type,
+ instance = root.stateNode;
if (
- 0 === (workInProgress$30.flags & 128) &&
+ 0 === (root.flags & 128) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- workInProgress$30.flags |= 16384;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$30.lanes |= thrownValue;
- var update$34 = createClassErrorUpdate(
- workInProgress$30,
+ root.lanes |= thrownValue;
+ var update$31 = createClassErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$30, update$34);
+ enqueueCapturedUpdate(root, update$31);
break a;
}
}
- workInProgress$30 = workInProgress$30.return;
- } while (null !== workInProgress$30);
+ root = root.return;
+ } while (null !== root);
}
completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
@@ -6540,9 +6761,21 @@ function pushDispatcher() {
ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
+function renderDidSuspendDelayIfPossible() {
+ if (
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus ||
+ 2 === workInProgressRootExitStatus
+ )
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 268435455) &&
+ 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) ||
+ markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
+}
function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= 8;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
(workInProgressRoot === root && workInProgressRootRenderLanes === lanes) ||
prepareFreshStack(root, lanes);
@@ -6583,7 +6816,7 @@ function completeUnitOfWork(unitOfWork) {
do {
var current = completedWork.alternate;
unitOfWork = completedWork.return;
- if (0 === (completedWork.flags & 8192)) {
+ if (0 === (completedWork.flags & 32768)) {
if (
((current = completeWork(current, completedWork, subtreeRenderLanes)),
null !== current)
@@ -6592,16 +6825,21 @@ function completeUnitOfWork(unitOfWork) {
return;
}
} else {
- current = unwindWork(completedWork);
+ current = unwindWork(current, completedWork);
if (null !== current) {
- current.flags &= 8191;
+ current.flags &= 32767;
workInProgress = current;
return;
}
- null !== unitOfWork &&
- ((unitOfWork.flags |= 8192),
- (unitOfWork.subtreeFlags = 0),
- (unitOfWork.deletions = null));
+ if (null !== unitOfWork)
+ (unitOfWork.flags |= 32768),
+ (unitOfWork.subtreeFlags = 0),
+ (unitOfWork.deletions = null);
+ else {
+ workInProgressRootExitStatus = 6;
+ workInProgress = null;
+ return;
+ }
}
completedWork = completedWork.sibling;
if (null !== completedWork) {
@@ -6612,23 +6850,23 @@ function completeUnitOfWork(unitOfWork) {
} while (null !== completedWork);
0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
-function commitRoot(root) {
+function commitRoot(root, recoverableErrors) {
var previousUpdateLanePriority = currentUpdatePriority,
prevTransition = ReactCurrentBatchConfig$2.transition;
try {
- (ReactCurrentBatchConfig$2.transition = 0),
+ (ReactCurrentBatchConfig$2.transition = null),
(currentUpdatePriority = 1),
- commitRootImpl(root, previousUpdateLanePriority);
+ commitRootImpl(root, recoverableErrors, previousUpdateLanePriority);
} finally {
(ReactCurrentBatchConfig$2.transition = prevTransition),
(currentUpdatePriority = previousUpdateLanePriority);
}
return null;
}
-function commitRootImpl(root, renderPriorityLevel) {
+function commitRootImpl(root, recoverableErrors, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var finishedWork = root.finishedWork,
lanes = root.finishedLanes;
@@ -6646,25 +6884,25 @@ function commitRootImpl(root, renderPriorityLevel) {
root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
(workInProgressRootRenderLanes = 0));
- (0 === (finishedWork.subtreeFlags & 1040) &&
- 0 === (finishedWork.flags & 1040)) ||
+ (0 === (finishedWork.subtreeFlags & 2064) &&
+ 0 === (finishedWork.flags & 2064)) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
}));
- remainingLanes = 0 !== (finishedWork.flags & 8054);
- if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) {
+ remainingLanes = 0 !== (finishedWork.flags & 15990);
+ if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) {
remainingLanes = ReactCurrentBatchConfig$2.transition;
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
var previousPriority = currentUpdatePriority;
currentUpdatePriority = 1;
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
ReactCurrentOwner$2.current = null;
commitBeforeMutationEffects(root, finishedWork);
- commitMutationEffects(root, finishedWork);
+ commitMutationEffects(root, finishedWork, lanes);
root.current = finishedWork;
commitLayoutEffects(finishedWork, root, lanes);
requestPaint();
@@ -6678,22 +6916,29 @@ function commitRootImpl(root, renderPriorityLevel) {
(pendingPassiveEffectsLanes = lanes));
remainingLanes = root.pendingLanes;
0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
- 0 !== (remainingLanes & 1)
- ? root === rootWithNestedUpdates
- ? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
- : (nestedUpdateCount = 0);
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
ensureRootIsScheduled(root, now());
+ if (null !== recoverableErrors)
+ for (
+ renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
+ finishedWork < recoverableErrors.length;
+ finishedWork++
+ )
+ renderPriorityLevel(recoverableErrors[finishedWork]);
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
(root = firstUncaughtError),
(firstUncaughtError = null),
root);
- if (0 !== (executionContext & 4)) return null;
0 !== (pendingPassiveEffectsLanes & 1) &&
0 !== root.tag &&
flushPassiveEffects();
+ remainingLanes = root.pendingLanes;
+ 0 !== (remainingLanes & 1)
+ ? root === rootWithNestedUpdates
+ ? nestedUpdateCount++
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
+ : (nestedUpdateCount = 0);
flushSyncCallbacks();
return null;
}
@@ -6703,7 +6948,7 @@ function flushPassiveEffects() {
prevTransition = ReactCurrentBatchConfig$2.transition,
previousPriority = currentUpdatePriority;
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority;
if (null === rootWithPendingPassiveEffects)
var JSCompiler_inline_result = !1;
@@ -6711,10 +6956,10 @@ function flushPassiveEffects() {
renderPriority = rootWithPendingPassiveEffects;
rootWithPendingPassiveEffects = null;
pendingPassiveEffectsLanes = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
for (nextEffect = renderPriority.current; null !== nextEffect; ) {
var fiber = nextEffect,
child = fiber.child;
@@ -6729,7 +6974,7 @@ function flushPassiveEffects() {
case 0:
case 11:
case 15:
- commitHookEffectListUnmount(4, fiber$jscomp$0, fiber);
+ commitHookEffectListUnmount(8, fiber$jscomp$0, fiber);
}
var child$jscomp$0 = fiber$jscomp$0.child;
if (null !== child$jscomp$0)
@@ -6769,17 +7014,17 @@ function flushPassiveEffects() {
nextEffect = fiber;
}
}
- if (0 !== (fiber.subtreeFlags & 1040) && null !== child)
+ if (0 !== (fiber.subtreeFlags & 2064) && null !== child)
(child.return = fiber), (nextEffect = child);
else
b: for (; null !== nextEffect; ) {
fiber = nextEffect;
- if (0 !== (fiber.flags & 1024))
+ if (0 !== (fiber.flags & 2048))
switch (fiber.tag) {
case 0:
case 11:
case 15:
- commitHookEffectListUnmount(5, fiber, fiber.return);
+ commitHookEffectListUnmount(9, fiber, fiber.return);
}
var sibling$jscomp$0 = fiber.sibling;
if (null !== sibling$jscomp$0) {
@@ -6794,18 +7039,18 @@ function flushPassiveEffects() {
for (nextEffect = finishedWork; null !== nextEffect; ) {
child = nextEffect;
var firstChild = child.child;
- if (0 !== (child.subtreeFlags & 1040) && null !== firstChild)
+ if (0 !== (child.subtreeFlags & 2064) && null !== firstChild)
(firstChild.return = child), (nextEffect = firstChild);
else
b: for (child = finishedWork; null !== nextEffect; ) {
deletions = nextEffect;
- if (0 !== (deletions.flags & 1024))
+ if (0 !== (deletions.flags & 2048))
try {
switch (deletions.tag) {
case 0:
case 11:
case 15:
- commitHookEffectListMount(5, deletions);
+ commitHookEffectListMount(9, deletions);
}
} catch (error) {
captureCommitPhaseError(deletions, deletions.return, error);
@@ -6932,7 +7177,6 @@ function resolveRetryWakeable(boundaryFiber, wakeable) {
}
var beginWork$1;
beginWork$1 = function(current, workInProgress, renderLanes) {
- var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
@@ -6940,158 +7184,98 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
)
didReceiveUpdate = !0;
else {
- if (0 === (renderLanes & updateLanes)) {
- 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.type._context;
- var nextValue = workInProgress.memoizedProps.value;
- push(valueCursor, updateLanes._currentValue2);
- updateLanes._currentValue2 = nextValue;
- 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,
- renderLanes
- );
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
- if (0 !== (current.flags & 128)) {
- if (updateLanes)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderLanes
- );
- workInProgress.flags |= 128;
- }
- nextValue = workInProgress.memoizedState;
- null !== nextValue &&
- ((nextValue.rendering = null),
- (nextValue.tail = null),
- (nextValue.lastEffect = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (updateLanes) break;
- else return null;
- case 22:
- case 23:
- return (
- (workInProgress.lanes = 0),
- updateOffscreenComponent(current, workInProgress, renderLanes)
- );
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
+ if (
+ 0 === (current.lanes & renderLanes) &&
+ 0 === (workInProgress.flags & 128)
+ )
+ return (
+ (didReceiveUpdate = !1),
+ attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+ )
);
- }
- didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1;
+ didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1;
}
else didReceiveUpdate = !1;
workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateLanes = workInProgress.type;
+ var Component = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- nextValue = getMaskedContext(workInProgress, contextStackCursor.current);
+ var context = getMaskedContext(
+ workInProgress,
+ contextStackCursor.current
+ );
prepareToReadContext(workInProgress, renderLanes);
- nextValue = renderWithHooks(
+ context = renderWithHooks(
null,
workInProgress,
- updateLanes,
+ Component,
current,
- nextValue,
+ context,
renderLanes
);
workInProgress.flags |= 1;
if (
- "object" === typeof nextValue &&
- null !== nextValue &&
- "function" === typeof nextValue.render &&
- void 0 === nextValue.$$typeof
+ "object" === typeof context &&
+ null !== context &&
+ "function" === typeof context.render &&
+ void 0 === context.$$typeof
) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateLanes)) {
+ if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
workInProgress.memoizedState =
- null !== nextValue.state && void 0 !== nextValue.state
- ? nextValue.state
+ null !== context.state && void 0 !== context.state
+ ? context.state
: null;
initializeUpdateQueue(workInProgress);
- nextValue.updater = classComponentUpdater;
- workInProgress.stateNode = nextValue;
- nextValue._reactInternals = workInProgress;
- mountClassInstance(workInProgress, updateLanes, current, renderLanes);
+ context.updater = classComponentUpdater;
+ workInProgress.stateNode = context;
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, Component, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
hasContext,
renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(null, workInProgress, nextValue, renderLanes),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
- nextValue = workInProgress.elementType;
+ Component = workInProgress.elementType;
a: {
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- hasContext = nextValue._init;
- nextValue = hasContext(nextValue._payload);
- workInProgress.type = nextValue;
- hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue);
- current = resolveDefaultProps(nextValue, current);
- switch (hasContext) {
+ context = Component._init;
+ Component = context(Component._payload);
+ workInProgress.type = Component;
+ context = workInProgress.tag = resolveLazyComponentTag(Component);
+ current = resolveDefaultProps(Component, current);
+ switch (context) {
case 0:
workInProgress = updateFunctionComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7100,7 +7284,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateClassComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7109,7 +7293,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateForwardRef(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7118,79 +7302,75 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateMemoComponent(
null,
workInProgress,
- nextValue,
- resolveDefaultProps(nextValue.type, current),
- updateLanes,
+ Component,
+ resolveDefaultProps(Component.type, current),
renderLanes
);
break a;
}
throw Error(
"Element type is invalid. Received a promise that resolves to: " +
- nextValue +
+ Component +
". Lazy element type must resolve to a class or function."
);
}
return workInProgress;
case 0:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateFunctionComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 1:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateClassComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- 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."
- );
- nextValue = workInProgress.pendingProps;
- updateLanes = workInProgress.memoizedState.element;
+ if (null === current)
+ throw Error("Should have a current fiber. This is a bug in React.");
+ context = workInProgress.pendingProps;
+ Component = workInProgress.memoizedState.element;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextValue, null, renderLanes);
- nextValue = workInProgress.memoizedState.element;
- nextValue === updateLanes
+ processUpdateQueue(workInProgress, context, null, renderLanes);
+ context = workInProgress.memoizedState.element;
+ context === Component
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
renderLanes
))
- : (reconcileChildren(current, workInProgress, nextValue, renderLanes),
+ : (reconcileChildren(current, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateLanes = workInProgress.pendingProps.children),
- markRef(current, workInProgress),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ (Component = workInProgress.pendingProps.children),
+ markRef$1(current, workInProgress),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 6:
@@ -7203,35 +7383,30 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateLanes = workInProgress.pendingProps),
+ (Component = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateLanes,
+ Component,
renderLanes
))
- : reconcileChildren(
- current,
- workInProgress,
- updateLanes,
- renderLanes
- ),
+ : reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 11:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateForwardRef(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
@@ -7267,16 +7442,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
);
case 10:
a: {
- updateLanes = workInProgress.type._context;
- nextValue = workInProgress.pendingProps;
+ Component = workInProgress.type._context;
+ context = workInProgress.pendingProps;
hasContext = workInProgress.memoizedProps;
- var newValue = nextValue.value;
- push(valueCursor, updateLanes._currentValue2);
- updateLanes._currentValue2 = newValue;
+ var newValue = context.value;
+ push(valueCursor, Component._currentValue2);
+ Component._currentValue2 = newValue;
if (null !== hasContext)
if (objectIs(hasContext.value, newValue)) {
if (
- hasContext.children === nextValue.children &&
+ hasContext.children === context.children &&
!didPerformWorkStackCursor.current
) {
workInProgress = bailoutOnAlreadyFinishedWork(
@@ -7301,7 +7476,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
null !== dependency;
) {
- if (dependency.context === updateLanes) {
+ if (dependency.context === Component) {
if (1 === newValue.tag) {
dependency = createUpdate(-1, renderLanes & -renderLanes);
dependency.tag = 2;
@@ -7319,7 +7494,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
newValue.lanes |= renderLanes;
dependency = newValue.alternate;
null !== dependency && (dependency.lanes |= renderLanes);
- scheduleWorkOnParentPath(newValue.return, renderLanes);
+ scheduleContextWorkOnParentPath(
+ newValue.return,
+ renderLanes,
+ workInProgress
+ );
list.lanes |= renderLanes;
break;
}
@@ -7352,7 +7531,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
reconcileChildren(
current,
workInProgress,
- nextValue.children,
+ context.children,
renderLanes
);
workInProgress = workInProgress.child;
@@ -7360,29 +7539,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return workInProgress;
case 9:
return (
- (nextValue = workInProgress.type),
- (updateLanes = workInProgress.pendingProps.children),
+ (context = workInProgress.type),
+ (Component = workInProgress.pendingProps.children),
prepareToReadContext(workInProgress, renderLanes),
- (nextValue = readContext(nextValue)),
- (updateLanes = updateLanes(nextValue)),
+ (context = readContext(context)),
+ (Component = Component(context)),
(workInProgress.flags |= 1),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 14:
return (
- (nextValue = workInProgress.type),
- (hasContext = resolveDefaultProps(
- nextValue,
- workInProgress.pendingProps
- )),
- (hasContext = resolveDefaultProps(nextValue.type, hasContext)),
+ (Component = workInProgress.type),
+ (context = resolveDefaultProps(Component, workInProgress.pendingProps)),
+ (context = resolveDefaultProps(Component.type, context)),
updateMemoComponent(
current,
workInProgress,
- nextValue,
- hasContext,
- updateLanes,
+ Component,
+ context,
renderLanes
)
);
@@ -7392,32 +7567,31 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateLanes,
renderLanes
);
case 17:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateLanes)
+ isContextProvider(Component)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
prepareToReadContext(workInProgress, renderLanes),
- constructClassInstance(workInProgress, updateLanes, nextValue),
- mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes),
+ constructClassInstance(workInProgress, Component, context),
+ mountClassInstance(workInProgress, Component, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
current,
renderLanes
@@ -7427,8 +7601,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return updateSuspenseListComponent(current, workInProgress, renderLanes);
case 22:
return updateOffscreenComponent(current, workInProgress, renderLanes);
- case 23:
- return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -7436,6 +7608,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
"). This error is likely caused by a bug in React. Please file an issue."
);
};
+function scheduleCallback$1(priorityLevel, callback) {
+ return scheduleCallback(priorityLevel, callback);
+}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -7486,7 +7661,7 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.flags = 0),
(workInProgress.subtreeFlags = 0),
(workInProgress.deletions = null));
- workInProgress.flags = current.flags & 1835008;
+ workInProgress.flags = current.flags & 14680064;
workInProgress.childLanes = current.childLanes;
workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
@@ -7519,10 +7694,6 @@ function createFiberFromTypeAndProps(
a: switch (type) {
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_DEBUG_TRACING_MODE_TYPE:
- fiberTag = 8;
- mode |= 4;
- break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
mode |= 8;
@@ -7550,13 +7721,6 @@ function createFiberFromTypeAndProps(
);
case REACT_OFFSCREEN_TYPE:
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
- case REACT_LEGACY_HIDDEN_TYPE:
- return (
- (type = createFiber(23, pendingProps, key, mode)),
- (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
- (type.lanes = lanes),
- type
- );
default:
if ("object" === typeof type && null !== type)
switch (type.$$typeof) {
@@ -7579,8 +7743,7 @@ function createFiberFromTypeAndProps(
}
throw Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- (null == type ? type : typeof type) +
- "."
+ ((null == type ? type : typeof type) + ".")
);
}
key = createFiber(fiberTag, pendingProps, key, mode);
@@ -7598,6 +7761,7 @@ function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
pendingProps = createFiber(22, pendingProps, key, mode);
pendingProps.elementType = REACT_OFFSCREEN_TYPE;
pendingProps.lanes = lanes;
+ pendingProps.stateNode = {};
return pendingProps;
}
function createFiberFromText(content, mode, lanes) {
@@ -7620,19 +7784,25 @@ function createFiberFromPortal(portal, mode, lanes) {
};
return mode;
}
-function FiberRootNode(containerInfo, tag, hydrate) {
+function FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+) {
this.tag = tag;
this.containerInfo = containerInfo;
this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
- this.pendingContext = this.context = null;
- this.hydrate = hydrate;
- this.callbackNode = null;
+ this.callbackNode = this.pendingContext = this.context = null;
this.callbackPriority = 0;
this.eventTimes = createLaneMap(0);
this.expirationTimes = createLaneMap(-1);
this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
this.entanglements = createLaneMap(0);
+ this.identifierPrefix = identifierPrefix;
+ this.onRecoverableError = onRecoverableError;
}
function createPortal(children, containerInfo, implementation) {
var key =
@@ -7650,9 +7820,9 @@ function findHostInstance(component) {
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
+ component = Object.keys(component).join(",");
throw Error(
- "Argument appears to not be a ReactComponent. Keys: " +
- Object.keys(component)
+ "Argument appears to not be a ReactComponent. Keys: " + component
);
}
component = findCurrentHostFiber(fiber);
@@ -7734,6 +7904,9 @@ function findNodeHandle(componentOrHandle) {
? componentOrHandle.canonical._nativeTag
: componentOrHandle._nativeTag;
}
+function onRecoverableError(error) {
+ console.error(error);
+}
batchedUpdatesImpl = function(fn, a) {
var prevExecutionContext = executionContext;
executionContext |= 1;
@@ -7747,10 +7920,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
- devToolsConfig$jscomp$inline_939 = {
+ devToolsConfig$jscomp$inline_934 = {
findFiberByHostInstance: getInstanceFromInstance,
bundleType: 0,
- version: "18.0.0-experimental-568dc3532",
+ version: "18.0.0-experimental-34aa5cfe0-20220329",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@@ -7765,11 +7938,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
-var internals$jscomp$inline_1177 = {
- bundleType: devToolsConfig$jscomp$inline_939.bundleType,
- version: devToolsConfig$jscomp$inline_939.version,
- rendererPackageName: devToolsConfig$jscomp$inline_939.rendererPackageName,
- rendererConfig: devToolsConfig$jscomp$inline_939.rendererConfig,
+var internals$jscomp$inline_1178 = {
+ 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,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@@ -7785,26 +7958,26 @@ var internals$jscomp$inline_1177 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
- devToolsConfig$jscomp$inline_939.findFiberByHostInstance ||
+ devToolsConfig$jscomp$inline_934.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
- reconcilerVersion: "18.0.0-experimental-568dc3532"
+ reconcilerVersion: "18.0.0-experimental-34aa5cfe0-20220329"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
- var hook$jscomp$inline_1178 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ var hook$jscomp$inline_1179 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
- !hook$jscomp$inline_1178.isDisabled &&
- hook$jscomp$inline_1178.supportsFiber
+ !hook$jscomp$inline_1179.isDisabled &&
+ hook$jscomp$inline_1179.supportsFiber
)
try {
- (rendererID = hook$jscomp$inline_1178.inject(
- internals$jscomp$inline_1177
+ (rendererID = hook$jscomp$inline_1179.inject(
+ internals$jscomp$inline_1178
)),
- (injectedHook = hook$jscomp$inline_1178);
+ (injectedHook = hook$jscomp$inline_1179);
} catch (err) {}
}
exports.createPortal = function(children, containerTag) {
@@ -7817,12 +7990,10 @@ exports.createPortal = function(children, containerTag) {
};
exports.dispatchCommand = function(handle, command, args) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.dispatchCommand(
- handle._internalInstanceHandle.stateNode.node,
- command,
- args
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.dispatchCommand(handle.node, command, args))
: ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand(
handle._nativeTag,
command,
@@ -7842,15 +8013,27 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
: componentOrHandle;
};
exports.findNodeHandle = findNodeHandle;
+exports.getInspectorDataForInstance = void 0;
exports.render = function(element, containerTag, callback, concurrentRoot) {
var root = roots.get(containerTag);
root ||
((root = concurrentRoot ? 1 : 0),
- (concurrentRoot = new FiberRootNode(containerTag, root, !1)),
+ (concurrentRoot = new FiberRootNode(
+ containerTag,
+ root,
+ !1,
+ "",
+ onRecoverableError
+ )),
(root = createFiber(3, null, null, 1 === root ? 1 : 0)),
(concurrentRoot.current = root),
(root.stateNode = concurrentRoot),
- (root.memoizedState = { element: null }),
+ (root.memoizedState = {
+ element: null,
+ isDehydrated: !1,
+ cache: null,
+ transitions: null
+ }),
initializeUpdateQueue(root),
(root = concurrentRoot),
roots.set(containerTag, root));
@@ -7868,11 +8051,10 @@ exports.render = function(element, containerTag, callback, concurrentRoot) {
};
exports.sendAccessibilityEvent = function(handle, eventType) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.sendAccessibilityEvent(
- handle._internalInstanceHandle.stateNode.node,
- eventType
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType))
: ReactNativePrivateInterface.legacySendAccessibilityEvent(
handle._nativeTag,
eventType
diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.js b/Libraries/Renderer/implementations/ReactFabric-profiling.js
index 791e998cda8ad2..dee0ec43622f93 100644
--- a/Libraries/Renderer/implementations/ReactFabric-profiling.js
+++ b/Libraries/Renderer/implementations/ReactFabric-profiling.js
@@ -1,5 +1,5 @@
/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@@ -8,10 +8,21 @@
* @nolint
* @providesModule ReactFabric-profiling
* @preventMunge
- * @generated SignedSource<>
+ * @generated SignedSource<>
*/
-"use strict";
+
+ 'use strict';
+
+/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
+}
+ "use strict";
require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore");
var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"),
React = require("react"),
@@ -87,6 +98,7 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
+var assign = Object.assign;
function functionThatReturnsTrue() {
return !0;
}
@@ -119,7 +131,7 @@ function SyntheticEvent(
this.isPropagationStopped = functionThatReturnsFalse;
return this;
}
-Object.assign(SyntheticEvent.prototype, {
+assign(SyntheticEvent.prototype, {
preventDefault: function() {
this.defaultPrevented = !0;
var event = this.nativeEvent;
@@ -173,10 +185,10 @@ SyntheticEvent.extend = function(Interface) {
var Super = this;
E.prototype = Super.prototype;
var prototype = new E();
- Object.assign(prototype, Class.prototype);
+ assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = Object.assign({}, Super.Interface, Interface);
+ Class.Interface = assign({}, Super.Interface, Interface);
Class.extend = Super.extend;
addEventPoolingTo(Class);
return Class;
@@ -783,18 +795,16 @@ function recomputePluginOrdering() {
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName],
pluginIndex = eventPluginOrder.indexOf(pluginName);
- if (!(-1 < pluginIndex))
+ if (-1 >= pluginIndex)
throw Error(
"EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" +
- pluginName +
- "`."
+ (pluginName + "`.")
);
if (!plugins[pluginIndex]) {
if (!pluginModule.extractEvents)
throw Error(
"EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" +
- pluginName +
- "` does not."
+ (pluginName + "` does not.")
);
plugins[pluginIndex] = pluginModule;
pluginIndex = pluginModule.eventTypes;
@@ -805,8 +815,7 @@ function recomputePluginOrdering() {
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same event name, `" +
- eventName$jscomp$0 +
- "`."
+ (eventName$jscomp$0 + "`.")
);
eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
@@ -846,18 +855,22 @@ function publishRegistrationName(registrationName, pluginModule) {
if (registrationNameModules[registrationName])
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" +
- registrationName +
- "`."
+ (registrationName + "`.")
);
registrationNameModules[registrationName] = pluginModule;
}
var plugins = [],
eventNameDispatchConfigs = {},
registrationNameModules = {};
-function getListener$1(inst, registrationName) {
- inst = inst.stateNode;
- if (null === inst) return null;
- inst = getFiberCurrentPropsFromNode(inst);
+function getListeners(
+ inst,
+ registrationName,
+ phase,
+ dispatchToImperativeListeners
+) {
+ var stateNode = inst.stateNode;
+ if (null === stateNode) return null;
+ inst = getFiberCurrentPropsFromNode(stateNode);
if (null === inst) return null;
if ((inst = inst[registrationName]) && "function" !== typeof inst)
throw Error(
@@ -867,7 +880,67 @@ function getListener$1(inst, registrationName) {
typeof inst +
"` type."
);
- return inst;
+ if (
+ !(
+ dispatchToImperativeListeners &&
+ stateNode.canonical &&
+ stateNode.canonical._eventListeners
+ )
+ )
+ return inst;
+ var listeners = [];
+ inst && listeners.push(inst);
+ var requestedPhaseIsCapture = "captured" === phase,
+ mangledImperativeRegistrationName = requestedPhaseIsCapture
+ ? "rn:" + registrationName.replace(/Capture$/, "")
+ : "rn:" + registrationName;
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName] &&
+ 0 <
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName]
+ .length &&
+ stateNode.canonical._eventListeners[
+ mangledImperativeRegistrationName
+ ].forEach(function(listenerObj) {
+ if (
+ (null != listenerObj.options.capture && listenerObj.options.capture) ===
+ requestedPhaseIsCapture
+ ) {
+ var listenerFnWrapper = function(syntheticEvent) {
+ var eventInst = new ReactNativePrivateInterface.CustomEvent(
+ mangledImperativeRegistrationName,
+ { detail: syntheticEvent.nativeEvent }
+ );
+ eventInst.isTrusted = !0;
+ eventInst.setSyntheticEvent(syntheticEvent);
+ for (
+ var _len = arguments.length,
+ args = Array(1 < _len ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ )
+ args[_key - 1] = arguments[_key];
+ listenerObj.listener.apply(listenerObj, [eventInst].concat(args));
+ };
+ listenerObj.options.once
+ ? listeners.push(function() {
+ stateNode.canonical.removeEventListener_unstable(
+ mangledImperativeRegistrationName,
+ listenerObj.listener,
+ listenerObj.capture
+ );
+ listenerObj.invalidated ||
+ ((listenerObj.invalidated = !0),
+ listenerObj.listener.apply(listenerObj, arguments));
+ })
+ : listeners.push(listenerFnWrapper);
+ }
+ });
+ return 0 === listeners.length
+ ? null
+ : 1 === listeners.length
+ ? listeners[0]
+ : listeners;
}
var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
@@ -875,50 +948,74 @@ var customBubblingEventTypes =
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateListenersAndInstances(inst, event, listeners) {
+ var listenersLength = listeners
+ ? isArrayImpl(listeners)
+ ? listeners.length
+ : 1
+ : 0;
+ if (0 < listenersLength)
+ if (
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listeners
+ )),
+ null == event._dispatchInstances && 1 === listenersLength)
+ )
+ event._dispatchInstances = inst;
+ else
+ for (
+ event._dispatchInstances = event._dispatchInstances || [],
+ isArrayImpl(event._dispatchInstances) ||
+ (event._dispatchInstances = [event._dispatchInstances]),
+ listeners = 0;
+ listeners < listenersLength;
+ listeners++
+ )
+ event._dispatchInstances.push(inst);
+}
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
- ));
+ phase = getListeners(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase],
+ phase,
+ !0
+ );
+ accumulateListenersAndInstances(inst, event, phase);
+}
+function traverseTwoPhase$1(inst, fn, arg, skipBubbling) {
+ for (var path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ if (skipBubbling) fn(path[0], "bubbled", arg);
+ else
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
}
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);
- }
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event,
+ !1
+ );
}
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
- )));
+ var listeners = getListeners(
+ inst,
+ event.dispatchConfig.registrationName,
+ "bubbled",
+ !1
+ );
+ accumulateListenersAndInstances(inst, event, listeners);
}
}
}
@@ -931,7 +1028,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_224 = {
+var injectedNamesToPlugins$jscomp$inline_223 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -955,10 +1052,21 @@ var injectedNamesToPlugins$jscomp$inline_224 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(
- topLevelType,
- accumulateTwoPhaseDispatchesSingle$1
- );
+ null != topLevelType &&
+ null != topLevelType.dispatchConfig.phasedRegistrationNames &&
+ topLevelType.dispatchConfig.phasedRegistrationNames.skipBubbling
+ ? topLevelType &&
+ topLevelType.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ topLevelType._targetInst,
+ accumulateDirectionalDispatches$1,
+ topLevelType,
+ !0
+ )
+ : forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
@@ -966,34 +1074,33 @@ var injectedNamesToPlugins$jscomp$inline_224 = {
}
}
},
- isOrderingDirty$jscomp$inline_225 = !1,
- pluginName$jscomp$inline_226;
-for (pluginName$jscomp$inline_226 in injectedNamesToPlugins$jscomp$inline_224)
+ isOrderingDirty$jscomp$inline_224 = !1,
+ pluginName$jscomp$inline_225;
+for (pluginName$jscomp$inline_225 in injectedNamesToPlugins$jscomp$inline_223)
if (
- injectedNamesToPlugins$jscomp$inline_224.hasOwnProperty(
- pluginName$jscomp$inline_226
+ injectedNamesToPlugins$jscomp$inline_223.hasOwnProperty(
+ pluginName$jscomp$inline_225
)
) {
- var pluginModule$jscomp$inline_227 =
- injectedNamesToPlugins$jscomp$inline_224[pluginName$jscomp$inline_226];
+ var pluginModule$jscomp$inline_226 =
+ injectedNamesToPlugins$jscomp$inline_223[pluginName$jscomp$inline_225];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_226) ||
- namesToPlugins[pluginName$jscomp$inline_226] !==
- pluginModule$jscomp$inline_227
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_225) ||
+ namesToPlugins[pluginName$jscomp$inline_225] !==
+ pluginModule$jscomp$inline_226
) {
- if (namesToPlugins[pluginName$jscomp$inline_226])
+ if (namesToPlugins[pluginName$jscomp$inline_225])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_226 +
- "`."
+ (pluginName$jscomp$inline_225 + "`.")
);
namesToPlugins[
- pluginName$jscomp$inline_226
- ] = pluginModule$jscomp$inline_227;
- isOrderingDirty$jscomp$inline_225 = !0;
+ pluginName$jscomp$inline_225
+ ] = pluginModule$jscomp$inline_226;
+ isOrderingDirty$jscomp$inline_224 = !0;
}
}
-isOrderingDirty$jscomp$inline_225 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_224 && recomputePluginOrdering();
function getInstanceFromInstance(instanceHandle) {
return instanceHandle;
}
@@ -1033,43 +1140,25 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
});
var ReactSharedInternals =
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_DEBUG_TRACING_MODE_TYPE = 60129,
- REACT_OFFSCREEN_TYPE = 60130,
- REACT_LEGACY_HIDDEN_TYPE = 60131,
- REACT_CACHE_TYPE = 60132;
-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");
- 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");
- REACT_CACHE_TYPE = symbolFor("react.cache");
-}
-var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ REACT_ELEMENT_TYPE = Symbol.for("react.element"),
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
+ REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
+ REACT_LAZY_TYPE = Symbol.for("react.lazy");
+Symbol.for("react.scope");
+Symbol.for("react.debug_trace_mode");
+var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
+Symbol.for("react.legacy_hidden");
+Symbol.for("react.cache");
+Symbol.for("react.tracing_marker");
+var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -1094,8 +1183,6 @@ function getComponentNameFromType(type) {
return "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
- case REACT_CACHE_TYPE:
- return "Cache";
}
if ("object" === typeof type)
switch (type.$$typeof) {
@@ -1156,8 +1243,6 @@ function getComponentNameFromFiber(fiber) {
return "Text";
case 16:
return getComponentNameFromType(type);
- case 23:
- return "LegacyHidden";
case 8:
return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode";
case 22:
@@ -1170,6 +1255,8 @@ function getComponentNameFromFiber(fiber) {
return "Suspense";
case 19:
return "SuspenseList";
+ case 25:
+ return "TracingMarker";
case 1:
case 0:
case 17:
@@ -1190,7 +1277,7 @@ function getNearestMountedFiber(fiber) {
fiber = node;
do
(node = fiber),
- 0 !== (node.flags & 2050) && (nearestMounted = node.return),
+ 0 !== (node.flags & 4098) && (nearestMounted = node.return),
(fiber = node.return);
while (fiber);
}
@@ -1562,7 +1649,10 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
null != stateNode && (eventTarget = stateNode.canonical);
}
batchedUpdates(function() {
- var JSCompiler_inline_result = eventTarget;
+ var event = { eventName: topLevelType, nativeEvent: nativeEvent };
+ ReactNativePrivateInterface.RawEventEmitter.emit(topLevelType, event);
+ ReactNativePrivateInterface.RawEventEmitter.emit("*", event);
+ event = eventTarget;
for (
var events = null, legacyPlugins = plugins, i = 0;
i < legacyPlugins.length;
@@ -1574,29 +1664,25 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
topLevelType,
target,
nativeEvent,
- JSCompiler_inline_result
+ event
)) &&
(events = accumulateInto(events, possiblePlugin));
}
- JSCompiler_inline_result = events;
- null !== JSCompiler_inline_result &&
- (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result));
- JSCompiler_inline_result = eventQueue;
+ event = events;
+ null !== event && (eventQueue = accumulateInto(eventQueue, event));
+ event = eventQueue;
eventQueue = null;
- if (JSCompiler_inline_result) {
- forEachAccumulated(
- JSCompiler_inline_result,
- executeDispatchesAndReleaseTopLevel
- );
+ if (event) {
+ forEachAccumulated(event, 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 ((JSCompiler_inline_result = rethrowError),
+ throw ((event = rethrowError),
(hasRethrowError = !1),
(rethrowError = null),
- JSCompiler_inline_result);
+ event);
}
});
}
@@ -1640,6 +1726,13 @@ function onCommitRoot(root, eventPriority) {
);
} catch (err) {}
}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(x) {
+ x >>>= 0;
+ return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0;
+}
var nextTransitionLane = 64,
nextRetryLane = 4194304;
function getHighestPriorityLanes(lanes) {
@@ -1848,12 +1941,6 @@ function movePendingFibersToMemoized(root, lanes) {
lanes &= ~root;
}
}
-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 currentUpdatePriority = 0;
function lanesToEventPriority(lanes) {
lanes &= -lanes;
@@ -1865,11 +1952,6 @@ function lanesToEventPriority(lanes) {
: 4
: 1;
}
-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."
@@ -1917,28 +1999,81 @@ var ReactFabricHostComponent = (function() {
ReactNativePrivateInterface.TextInputState.focusTextInput(this);
};
_proto.measure = function(callback) {
- fabricMeasure(
- this._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, callback)
- );
+ var stateNode = this._internalInstanceHandle.stateNode;
+ null != stateNode &&
+ fabricMeasure(
+ stateNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, callback)
+ );
};
_proto.measureInWindow = function(callback) {
- fabricMeasureInWindow(
- this._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, callback)
- );
+ var stateNode = this._internalInstanceHandle.stateNode;
+ null != stateNode &&
+ fabricMeasureInWindow(
+ stateNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, callback)
+ );
};
_proto.measureLayout = function(relativeToNativeNode, onSuccess, onFail) {
- "number" !== typeof relativeToNativeNode &&
- relativeToNativeNode instanceof ReactFabricHostComponent &&
- fabricMeasureLayout(
- this._internalInstanceHandle.stateNode.node,
- relativeToNativeNode._internalInstanceHandle.stateNode.node,
- mountSafeCallback_NOT_REALLY_SAFE(this, onFail),
- mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)
- );
+ if (
+ "number" !== typeof relativeToNativeNode &&
+ relativeToNativeNode instanceof ReactFabricHostComponent
+ ) {
+ var toStateNode = this._internalInstanceHandle.stateNode;
+ relativeToNativeNode =
+ relativeToNativeNode._internalInstanceHandle.stateNode;
+ null != toStateNode &&
+ null != relativeToNativeNode &&
+ fabricMeasureLayout(
+ toStateNode.node,
+ relativeToNativeNode.node,
+ mountSafeCallback_NOT_REALLY_SAFE(this, onFail),
+ mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)
+ );
+ }
};
_proto.setNativeProps = function() {};
+ _proto.addEventListener_unstable = function(eventType, listener, options) {
+ if ("string" !== typeof eventType)
+ throw Error("addEventListener_unstable eventType must be a string");
+ if ("function" !== typeof listener)
+ throw Error("addEventListener_unstable listener must be a function");
+ var optionsObj =
+ "object" === typeof options && null !== options ? options : {};
+ options =
+ ("boolean" === typeof options ? options : optionsObj.capture) || !1;
+ var once = optionsObj.once || !1;
+ optionsObj = optionsObj.passive || !1;
+ var eventListeners = this._eventListeners || {};
+ null == this._eventListeners && (this._eventListeners = eventListeners);
+ var namedEventListeners = eventListeners[eventType] || [];
+ null == eventListeners[eventType] &&
+ (eventListeners[eventType] = namedEventListeners);
+ namedEventListeners.push({
+ listener: listener,
+ invalidated: !1,
+ options: {
+ capture: options,
+ once: once,
+ passive: optionsObj,
+ signal: null
+ }
+ });
+ };
+ _proto.removeEventListener_unstable = function(eventType, listener, options) {
+ var optionsObj =
+ "object" === typeof options && null !== options ? options : {},
+ capture =
+ ("boolean" === typeof options ? options : optionsObj.capture) || !1;
+ (options = this._eventListeners) &&
+ (optionsObj = options[eventType]) &&
+ (options[eventType] = optionsObj.filter(function(listenerObj) {
+ return !(
+ listenerObj.listener === listener &&
+ listenerObj.options.capture === capture
+ );
+ }));
+ };
return ReactFabricHostComponent;
})();
function createTextInstance(
@@ -1947,8 +2082,6 @@ function createTextInstance(
hostContext,
internalInstanceHandle
) {
- if (!hostContext.isInAParentText)
- throw Error("Text strings must be rendered within a component.");
hostContext = nextReactTag;
nextReactTag += 2;
return {
@@ -2052,7 +2185,7 @@ function processChildContext(fiber, type, parentContext) {
contextKey +
'" is not defined in childContextTypes.'
);
- return Object.assign({}, parentContext, instance);
+ return assign({}, parentContext, instance);
}
function pushContextProvider(workInProgress) {
workInProgress =
@@ -2083,7 +2216,11 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
-var syncQueue = null,
+function is(x, y) {
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
+}
+var objectIs = "function" === typeof Object.is ? Object.is : is,
+ syncQueue = null,
includesLegacySyncCallbacks = !1,
isFlushingSyncQueue = !1;
function flushSyncCallbacks() {
@@ -2112,10 +2249,6 @@ function flushSyncCallbacks() {
return null;
}
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
-function is(x, y) {
- return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
-}
-var objectIs = "function" === typeof Object.is ? Object.is : is;
function shallowEqual(objA, objB) {
if (objectIs(objA, objB)) return !0;
if (
@@ -2128,12 +2261,14 @@ function shallowEqual(objA, objB) {
var keysA = Object.keys(objA),
keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return !1;
- for (keysB = 0; keysB < keysA.length; keysB++)
+ for (keysB = 0; keysB < keysA.length; keysB++) {
+ var currentKey = keysA[keysB];
if (
- !hasOwnProperty.call(objB, keysA[keysB]) ||
- !objectIs(objA[keysA[keysB]], objB[keysA[keysB]])
+ !hasOwnProperty.call(objB, currentKey) ||
+ !objectIs(objA[currentKey], objB[currentKey])
)
return !1;
+ }
return !0;
}
function describeFiber(fiber) {
@@ -2160,7 +2295,7 @@ function describeFiber(fiber) {
}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
- baseProps = Object.assign({}, baseProps);
+ baseProps = assign({}, baseProps);
Component = Component.defaultProps;
for (var propName in Component)
void 0 === baseProps[propName] &&
@@ -2181,19 +2316,16 @@ function popProvider(context) {
pop(valueCursor);
context._currentValue2 = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderLanes) {
+function scheduleContextWorkOnParentPath(parent, renderLanes, propagationRoot) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- 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.childLanes & renderLanes) !== renderLanes
+ ? ((parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes))
+ : null !== alternate &&
+ (alternate.childLanes & renderLanes) !== renderLanes &&
+ (alternate.childLanes |= renderLanes);
+ if (parent === propagationRoot) break;
parent = parent.return;
}
}
@@ -2263,7 +2395,7 @@ function enqueueUpdate(fiber, update) {
((updateQueue = updateQueue.shared),
null !== workInProgressRoot &&
0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
+ 0 === (executionContext & 2)
? ((fiber = updateQueue.interleaved),
null === fiber
? ((update.next = update),
@@ -2400,7 +2532,7 @@ function processUpdateQueue(
newState = workInProgress;
break a;
case 3:
- workInProgress.flags = (workInProgress.flags & -16385) | 128;
+ workInProgress.flags = (workInProgress.flags & -65537) | 128;
case 0:
workInProgress = update.payload;
updateLane =
@@ -2408,7 +2540,7 @@ function processUpdateQueue(
? workInProgress.call(updateEventTime, newState, updateLane)
: workInProgress;
if (null === updateLane || void 0 === updateLane) break a;
- newState = Object.assign({}, newState, updateLane);
+ newState = assign({}, newState, updateLane);
break a;
case 2:
hasForceUpdate = !0;
@@ -2495,7 +2627,7 @@ function applyDerivedStateFromProps(
getDerivedStateFromProps =
null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps
? ctor
- : Object.assign({}, ctor, getDerivedStateFromProps);
+ : assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
@@ -2631,6 +2763,26 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
"function" === typeof instance.componentDidMount &&
(workInProgress.flags |= 4);
}
+var forkStack = [],
+ forkStackIndex = 0,
+ treeForkProvider = null,
+ idStack = [],
+ idStackIndex = 0,
+ treeContextProvider = null;
+function popTreeContext(workInProgress) {
+ for (; workInProgress === treeForkProvider; )
+ (treeForkProvider = forkStack[--forkStackIndex]),
+ (forkStack[forkStackIndex] = null),
+ --forkStackIndex,
+ (forkStack[forkStackIndex] = null);
+ for (; workInProgress === treeContextProvider; )
+ (treeContextProvider = idStack[--idStackIndex]),
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null);
+}
function coerceRef(returnFiber, current, element) {
returnFiber = element.ref;
if (
@@ -2653,7 +2805,8 @@ function coerceRef(returnFiber, current, element) {
returnFiber +
". This error is likely caused by a bug in React. Please file an issue."
);
- var stringRef = "" + returnFiber;
+ var resolvedInst = inst,
+ stringRef = "" + returnFiber;
if (
null !== current &&
null !== current.ref &&
@@ -2662,8 +2815,8 @@ function coerceRef(returnFiber, current, element) {
)
return current.ref;
current = function(value) {
- var refs = inst.refs;
- refs === emptyRefsObject && (refs = inst.refs = {});
+ var refs = resolvedInst.refs;
+ refs === emptyRefsObject && (refs = resolvedInst.refs = {});
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
};
current._stringRef = stringRef;
@@ -2724,7 +2877,8 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function placeChild(newFiber, lastPlacedIndex, newIndex) {
newFiber.index = newIndex;
- if (!shouldTrackSideEffects) return lastPlacedIndex;
+ if (!shouldTrackSideEffects)
+ return (newFiber.flags |= 1048576), lastPlacedIndex;
newIndex = newFiber.alternate;
if (null !== newIndex)
return (
@@ -2815,7 +2969,10 @@ function ChildReconciler(shouldTrackSideEffects) {
return current;
}
function createChild(returnFiber, newChild, lanes) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(newChild = createFiberFromText(
"" + newChild,
@@ -2869,7 +3026,10 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return null !== key
? null
: updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
@@ -2899,7 +3059,10 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild,
lanes
) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(existingChildren = existingChildren.get(newIdx) || null),
updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
@@ -3100,60 +3263,49 @@ function ChildReconciler(shouldTrackSideEffects) {
return iteratorFn;
}
return function(returnFiber, currentFirstChild, newChild, lanes) {
- var isUnkeyedTopLevelFragment =
- "object" === typeof newChild &&
+ "object" === typeof newChild &&
null !== newChild &&
newChild.type === REACT_FRAGMENT_TYPE &&
- null === newChild.key;
- isUnkeyedTopLevelFragment && (newChild = newChild.props.children);
+ null === newChild.key &&
+ (newChild = newChild.props.children);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
a: {
- var key = newChild.key;
for (
- isUnkeyedTopLevelFragment = currentFirstChild;
- null !== isUnkeyedTopLevelFragment;
+ var key = newChild.key, child = currentFirstChild;
+ null !== child;
) {
- if (isUnkeyedTopLevelFragment.key === key) {
+ if (child.key === key) {
key = newChild.type;
if (key === REACT_FRAGMENT_TYPE) {
- if (7 === isUnkeyedTopLevelFragment.tag) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
+ if (7 === child.tag) {
+ deleteRemainingChildren(returnFiber, child.sibling);
currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
+ child,
newChild.props.children
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- } else if (isUnkeyedTopLevelFragment.elementType === key) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
- currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
- newChild.props
- );
+ } else if (child.elementType === key) {
+ deleteRemainingChildren(returnFiber, child.sibling);
+ currentFirstChild = useFiber(child, newChild.props);
currentFirstChild.ref = coerceRef(
returnFiber,
- isUnkeyedTopLevelFragment,
+ child,
newChild
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment);
+ deleteRemainingChildren(returnFiber, child);
break;
- } else deleteChild(returnFiber, isUnkeyedTopLevelFragment);
- isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling;
+ } else deleteChild(returnFiber, child);
+ child = child.sibling;
}
newChild.type === REACT_FRAGMENT_TYPE
? ((currentFirstChild = createFiberFromFragment(
@@ -3183,12 +3335,8 @@ function ChildReconciler(shouldTrackSideEffects) {
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
a: {
- for (
- isUnkeyedTopLevelFragment = newChild.key;
- null !== currentFirstChild;
-
- ) {
- if (currentFirstChild.key === isUnkeyedTopLevelFragment)
+ for (child = newChild.key; null !== currentFirstChild; ) {
+ if (currentFirstChild.key === child)
if (
4 === currentFirstChild.tag &&
currentFirstChild.stateNode.containerInfo ===
@@ -3240,9 +3388,9 @@ function ChildReconciler(shouldTrackSideEffects) {
);
throwOnInvalidObjectType(returnFiber, newChild);
}
- if ("string" === typeof newChild || "number" === typeof newChild)
- return (
- (newChild = "" + newChild),
+ return ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ ? ((newChild = "" + newChild),
null !== currentFirstChild && 6 === currentFirstChild.tag
? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling),
(currentFirstChild = useFiber(currentFirstChild, newChild)),
@@ -3256,20 +3404,8 @@ function ChildReconciler(shouldTrackSideEffects) {
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
- placeSingleChild(returnFiber)
- );
- if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
- switch (returnFiber.tag) {
- case 1:
- case 0:
- case 11:
- case 15:
- throw Error(
- (getComponentNameFromFiber(returnFiber) || "Component") +
- "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."
- );
- }
- return deleteRemainingChildren(returnFiber, currentFirstChild);
+ placeSingleChild(returnFiber))
+ : deleteRemainingChildren(returnFiber, currentFirstChild);
};
}
var reconcileChildFibers = ChildReconciler(!0),
@@ -3356,7 +3492,8 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
currentHook = null,
workInProgressHook = null,
didScheduleRenderPhaseUpdate = !1,
- didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ didScheduleRenderPhaseUpdateDuringThisPass = !1,
+ globalClientIdCounter = 0;
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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
@@ -3390,7 +3527,7 @@ function renderWithHooks(
nextRenderLanes = 0;
do {
didScheduleRenderPhaseUpdateDuringThisPass = !1;
- if (!(25 > nextRenderLanes))
+ if (25 <= nextRenderLanes)
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
@@ -3491,19 +3628,18 @@ function updateReducer(reducer) {
(newBaseQueueLast = newBaseQueueLast.next = {
lane: 0,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
}),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ (current = update.hasEagerState
+ ? update.eagerState
+ : reducer(current, update.action));
else {
var clone = {
lane: updateLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
@@ -3560,109 +3696,77 @@ 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 may be 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."
+function updateMutableSource() {}
+function updateSyncExternalStore(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = updateWorkInProgressHook(),
+ nextSnapshot = getSnapshot(),
+ snapshotChanged = !objectIs(hook.memoizedState, nextSnapshot);
+ snapshotChanged &&
+ ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
+ hook = hook.queue;
+ updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [
+ subscribe
+ ]);
+ if (
+ hook.getSnapshot !== getSnapshot ||
+ snapshotChanged ||
+ (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1)
+ ) {
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot),
+ void 0,
+ null
);
- 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);
- objectIs(version, maybeNewVersion) ||
- ((maybeNewVersion = getSnapshot(source._source)),
- objectIs(snapshot, maybeNewVersion) ||
- (setSnapshot(maybeNewVersion),
- (maybeNewVersion = requestUpdateLane(fiber)),
- (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)),
- markRootEntangled(root, root.mutableReadLanes));
- },
- [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);
- 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,
- interleaved: null,
- lanes: 0,
- 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;
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ return nextSnapshot;
+}
+function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
+ fiber.flags |= 16384;
+ fiber = { getSnapshot: getSnapshot, value: renderedSnapshot };
+ getSnapshot = currentlyRenderingFiber$1.updateQueue;
+ null === getSnapshot
+ ? ((getSnapshot = { lastEffect: null, stores: null }),
+ (currentlyRenderingFiber$1.updateQueue = getSnapshot),
+ (getSnapshot.stores = [fiber]))
+ : ((renderedSnapshot = getSnapshot.stores),
+ null === renderedSnapshot
+ ? (getSnapshot.stores = [fiber])
+ : renderedSnapshot.push(fiber));
+}
+function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
+ inst.value = nextSnapshot;
+ inst.getSnapshot = getSnapshot;
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+}
+function subscribeToStore(fiber, inst, subscribe) {
+ return subscribe(function() {
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+ });
}
-function updateMutableSource(source, getSnapshot, subscribe) {
- var hook = updateWorkInProgressHook();
- return useMutableSource(hook, source, getSnapshot, subscribe);
+function checkIfSnapshotChanged(inst) {
+ var latestGetSnapshot = inst.getSnapshot;
+ inst = inst.value;
+ try {
+ var nextValue = latestGetSnapshot();
+ return !objectIs(inst, nextValue);
+ } catch (error) {
+ return !0;
+ }
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
- initialState = hook.queue = {
+ initialState = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3670,7 +3774,8 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
- initialState = initialState.dispatch = dispatchAction.bind(
+ hook.queue = initialState;
+ initialState = initialState.dispatch = dispatchSetState.bind(
null,
currentlyRenderingFiber$1,
initialState
@@ -3681,7 +3786,7 @@ function pushEffect(tag, create, destroy, deps) {
tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null };
create = currentlyRenderingFiber$1.updateQueue;
null === create
- ? ((create = { lastEffect: null }),
+ ? ((create = { lastEffect: null, stores: null }),
(currentlyRenderingFiber$1.updateQueue = create),
(create.lastEffect = tag.next = tag))
: ((destroy = create.lastEffect),
@@ -3722,14 +3827,17 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps);
}
function mountEffect(create, deps) {
- return mountEffectImpl(1049600, 4, create, deps);
+ return mountEffectImpl(8390656, 8, create, deps);
}
function updateEffect(create, deps) {
- return updateEffectImpl(1024, 4, create, deps);
+ return updateEffectImpl(2048, 8, create, deps);
}
-function updateLayoutEffect(create, deps) {
+function updateInsertionEffect(create, deps) {
return updateEffectImpl(4, 2, create, deps);
}
+function updateLayoutEffect(create, deps) {
+ return updateEffectImpl(4, 4, create, deps);
+}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
@@ -3752,7 +3860,7 @@ function updateImperativeHandle(ref, create, deps) {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return updateEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
@@ -3791,7 +3899,7 @@ function startTransition(setPending, callback) {
0 !== previousPriority && 4 > previousPriority ? previousPriority : 4;
setPending(!0);
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setPending(!1), callback();
} finally {
@@ -3799,47 +3907,38 @@ function startTransition(setPending, callback) {
(ReactCurrentBatchConfig$1.transition = prevTransition);
}
}
-function dispatchAction(fiber, queue, action) {
- var eventTime = requestEventTime(),
- lane = requestUpdateLane(fiber),
+function updateId() {
+ return updateWorkInProgressHook().memoizedState;
+}
+function dispatchReducerAction(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber);
+ action = {
+ lane: lane,
+ action: action,
+ hasEagerState: !1,
+ eagerState: null,
+ next: null
+ };
+ isRenderPhaseUpdate(fiber)
+ ? enqueueRenderPhaseUpdate(queue, action)
+ : (enqueueUpdate$1(fiber, queue, action),
+ (action = requestEventTime()),
+ (fiber = scheduleUpdateOnFiber(fiber, lane, action)),
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane));
+}
+function dispatchSetState(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber),
update = {
lane: lane,
action: action,
- eagerReducer: null,
+ hasEagerState: !1,
eagerState: null,
next: null
- },
- alternate = fiber.alternate;
- if (
- fiber === currentlyRenderingFiber$1 ||
- (null !== alternate && alternate === currentlyRenderingFiber$1)
- )
- (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0),
- (lane = queue.pending),
- null === lane
- ? (update.next = update)
- : ((update.next = lane.next), (lane.next = update)),
- (queue.pending = update);
+ };
+ if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update);
else {
- if (
- null !== workInProgressRoot &&
- 0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
- ) {
- var interleaved = queue.interleaved;
- null === interleaved
- ? ((update.next = update),
- null === interleavedQueues
- ? (interleavedQueues = [queue])
- : interleavedQueues.push(queue))
- : ((update.next = interleaved.next), (interleaved.next = update));
- queue.interleaved = update;
- } else
- (interleaved = queue.pending),
- null === interleaved
- ? (update.next = update)
- : ((update.next = interleaved.next), (interleaved.next = update)),
- (queue.pending = update);
+ enqueueUpdate$1(fiber, queue, update);
+ var alternate = fiber.alternate;
if (
0 === fiber.lanes &&
(null === alternate || 0 === alternate.lanes) &&
@@ -3848,20 +3947,57 @@ function dispatchAction(fiber, queue, action) {
try {
var currentState = queue.lastRenderedState,
eagerState = alternate(currentState, action);
- update.eagerReducer = alternate;
+ update.hasEagerState = !0;
update.eagerState = eagerState;
if (objectIs(eagerState, currentState)) return;
} catch (error) {
} finally {
}
- update = scheduleUpdateOnFiber(fiber, lane, eventTime);
- 0 !== (lane & 4194240) &&
- null !== update &&
- ((fiber = queue.lanes),
- (fiber &= update.pendingLanes),
- (lane |= fiber),
- (queue.lanes = lane),
- markRootEntangled(update, lane));
+ action = requestEventTime();
+ fiber = scheduleUpdateOnFiber(fiber, lane, action);
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane);
+ }
+}
+function isRenderPhaseUpdate(fiber) {
+ var alternate = fiber.alternate;
+ return (
+ fiber === currentlyRenderingFiber$1 ||
+ (null !== alternate && alternate === currentlyRenderingFiber$1)
+ );
+}
+function enqueueRenderPhaseUpdate(queue, update) {
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
+ var pending = queue.pending;
+ null === pending
+ ? (update.next = update)
+ : ((update.next = pending.next), (pending.next = update));
+ queue.pending = update;
+}
+function enqueueUpdate$1(fiber, queue, update) {
+ null !== workInProgressRoot &&
+ 0 !== (fiber.mode & 1) &&
+ 0 === (executionContext & 2)
+ ? ((fiber = queue.interleaved),
+ null === fiber
+ ? ((update.next = update),
+ null === interleavedQueues
+ ? (interleavedQueues = [queue])
+ : interleavedQueues.push(queue))
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.interleaved = update))
+ : ((fiber = queue.pending),
+ null === fiber
+ ? (update.next = update)
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.pending = update));
+}
+function entangleTransitionUpdate(root, queue, lane) {
+ if (0 !== (lane & 4194240)) {
+ var queueLanes = queue.lanes;
+ queueLanes &= root.pendingLanes;
+ lane |= queueLanes;
+ queue.lanes = lane;
+ markRootEntangled(root, lane);
}
}
var ContextOnlyDispatcher = {
@@ -3870,6 +4006,7 @@ var ContextOnlyDispatcher = {
useContext: throwInvalidHookError,
useEffect: throwInvalidHookError,
useImperativeHandle: throwInvalidHookError,
+ useInsertionEffect: throwInvalidHookError,
useLayoutEffect: throwInvalidHookError,
useMemo: throwInvalidHookError,
useReducer: throwInvalidHookError,
@@ -3879,7 +4016,8 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
- useOpaqueIdentifier: throwInvalidHookError,
+ useSyncExternalStore: throwInvalidHookError,
+ useId: throwInvalidHookError,
unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
@@ -3897,12 +4035,15 @@ var ContextOnlyDispatcher = {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return mountEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
},
useLayoutEffect: function(create, deps) {
+ return mountEffectImpl(4, 4, create, deps);
+ },
+ useInsertionEffect: function(create, deps) {
return mountEffectImpl(4, 2, create, deps);
},
useMemo: function(nextCreate, deps) {
@@ -3916,7 +4057,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
- reducer = hook.queue = {
+ reducer = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3924,7 +4065,8 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
- reducer = reducer.dispatch = dispatchAction.bind(
+ hook.queue = reducer;
+ reducer = reducer.dispatch = dispatchReducerAction.bind(
null,
currentlyRenderingFiber$1,
reducer
@@ -3945,7 +4087,7 @@ var ContextOnlyDispatcher = {
mountEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -3963,17 +4105,39 @@ var ContextOnlyDispatcher = {
mountWorkInProgressHook().memoizedState = _mountState2;
return [isPending, _mountState2];
},
- 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);
+ useMutableSource: function() {},
+ useSyncExternalStore: function(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = mountWorkInProgressHook();
+ var nextSnapshot = getSnapshot();
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ hook.memoizedState = nextSnapshot;
+ var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
+ hook.queue = inst;
+ mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [
+ subscribe
+ ]);
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ void 0,
+ null
+ );
+ return nextSnapshot;
},
- useOpaqueIdentifier: function() {
- throw Error("Not yet implemented");
+ useId: function() {
+ var hook = mountWorkInProgressHook(),
+ identifierPrefix = workInProgressRoot.identifierPrefix,
+ globalClientId = globalClientIdCounter++;
+ identifierPrefix =
+ ":" + identifierPrefix + "r" + globalClientId.toString(32) + ":";
+ return (hook.memoizedState = identifierPrefix);
},
unstable_isNewReconciler: !1
},
@@ -3983,6 +4147,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: updateReducer,
@@ -3998,7 +4163,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -4015,9 +4180,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return updateReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
@@ -4026,6 +4190,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: rerenderReducer,
@@ -4041,7 +4206,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -4058,9 +4223,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return rerenderReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
},
now$1 = Scheduler.unstable_now,
@@ -4175,19 +4339,21 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
if ("function" === typeof getDerivedStateFromError) {
var error = errorInfo.value;
lane.payload = function() {
- logCapturedError(fiber, errorInfo);
return getDerivedStateFromError(error);
};
+ lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
+ };
}
var inst = fiber.stateNode;
null !== inst &&
"function" === typeof inst.componentDidCatch &&
(lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
"function" !== typeof getDerivedStateFromError &&
(null === legacyErrorBoundariesThatAlreadyFailed
? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logCapturedError(fiber, errorInfo));
+ : legacyErrorBoundariesThatAlreadyFailed.add(this));
var stack = errorInfo.stack;
this.componentDidCatch(errorInfo.value, {
componentStack: null !== stack ? stack : ""
@@ -4195,1461 +4361,1466 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
});
return lane;
}
-var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
- didReceiveUpdate = !1;
-function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
- workInProgress.child =
- null === current
- ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
- : reconcileChildFibers(
- workInProgress,
- current.child,
- nextChildren,
- renderLanes
- );
+function attachPingListener(root, wakeable, lanes) {
+ var pingCache = root.pingCache;
+ if (null === pingCache) {
+ pingCache = root.pingCache = new PossiblyWeakMap();
+ var threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
+ } else
+ (threadIDs = pingCache.get(wakeable)),
+ void 0 === threadIDs &&
+ ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs));
+ threadIDs.has(lanes) ||
+ (threadIDs.add(lanes),
+ (pingCache = pingSuspendedRoot.bind(null, root, wakeable, lanes)),
+ isDevToolsPresent && restorePendingUpdaters(root, lanes),
+ wakeable.then(pingCache, pingCache));
}
-function updateForwardRef(
- current,
+function hadNoMutationsEffects(current, completedWork) {
+ if (null !== current && current.child === completedWork.child) return !0;
+ if (0 !== (completedWork.flags & 16)) return !1;
+ for (current = completedWork.child; null !== current; ) {
+ if (0 !== (current.flags & 12854) || 0 !== (current.subtreeFlags & 12854))
+ return !1;
+ current = current.sibling;
+ }
+ return !0;
+}
+var appendAllChildren, updateHostContainer, updateHostComponent, updateHostText;
+appendAllChildren = function(
+ parent,
workInProgress,
- Component,
- nextProps,
- renderLanes
+ needsVisibilityToggle,
+ isHidden
) {
- Component = Component.render;
- var ref = workInProgress.ref;
- prepareToReadContext(workInProgress, renderLanes);
- nextProps = renderWithHooks(
- current,
- workInProgress,
- Component,
- nextProps,
- ref,
- renderLanes
- );
- if (null !== current && !didReceiveUpdate)
- return (
- (workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
- (current.lanes &= ~renderLanes),
- bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
- );
- workInProgress.flags |= 1;
- reconcileChildren(current, workInProgress, nextProps, renderLanes);
- return workInProgress.child;
-}
-function updateMemoComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
-) {
- if (null === current) {
- var type = Component.type;
- if (
- "function" === typeof type &&
- !shouldConstruct(type) &&
- void 0 === type.defaultProps &&
- null === Component.compare &&
- void 0 === Component.defaultProps
- )
- return (
- (workInProgress.tag = 15),
- (workInProgress.type = type),
- updateSimpleMemoComponent(
- current,
- workInProgress,
- type,
- nextProps,
- updateLanes,
- renderLanes
- )
- );
- current = createFiberFromTypeAndProps(
- Component.type,
- null,
- nextProps,
- workInProgress,
- workInProgress.mode,
- renderLanes
- );
- current.ref = workInProgress.ref;
- current.return = workInProgress;
- return (workInProgress.child = current);
+ for (var node = workInProgress.child; null !== node; ) {
+ if (5 === node.tag) {
+ var instance = node.stateNode;
+ needsVisibilityToggle &&
+ isHidden &&
+ (instance = cloneHiddenInstance(instance));
+ appendChildNode(parent.node, instance.node);
+ } else if (6 === node.tag) {
+ instance = node.stateNode;
+ if (needsVisibilityToggle && isHidden)
+ throw Error("Not yet implemented.");
+ appendChildNode(parent.node, instance.node);
+ } else if (4 !== node.tag)
+ if (22 === node.tag && null !== node.memoizedState)
+ (instance = node.child),
+ null !== instance && (instance.return = node),
+ appendAllChildren(parent, node, !0, !0);
+ else if (null !== node.child) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ if (node === workInProgress) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === workInProgress) return;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
}
- type = current.child;
- if (
- 0 === (updateLanes & renderLanes) &&
- ((updateLanes = type.memoizedProps),
- (Component = Component.compare),
- (Component = null !== Component ? Component : shallowEqual),
- Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
- )
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- workInProgress.flags |= 1;
- current = createWorkInProgress(type, nextProps);
- current.ref = workInProgress.ref;
- current.return = workInProgress;
- return (workInProgress.child = current);
-}
-function updateSimpleMemoComponent(
- current,
+};
+function appendAllChildrenToContainer(
+ containerChildSet,
workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
+ needsVisibilityToggle,
+ isHidden
) {
- if (
- null !== current &&
- shallowEqual(current.memoizedProps, nextProps) &&
- current.ref === workInProgress.ref
- ) {
- didReceiveUpdate = !1;
- if (0 === (renderLanes & updateLanes))
- return (
- (workInProgress.lanes = current.lanes),
- bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
- );
- 0 !== (current.flags & 32768) && (didReceiveUpdate = !0);
+ for (var node = workInProgress.child; null !== node; ) {
+ if (5 === node.tag) {
+ var instance = node.stateNode;
+ needsVisibilityToggle &&
+ isHidden &&
+ (instance = cloneHiddenInstance(instance));
+ appendChildNodeToSet(containerChildSet, instance.node);
+ } else if (6 === node.tag) {
+ instance = node.stateNode;
+ if (needsVisibilityToggle && isHidden)
+ throw Error("Not yet implemented.");
+ appendChildNodeToSet(containerChildSet, instance.node);
+ } else if (4 !== node.tag)
+ if (22 === node.tag && null !== node.memoizedState)
+ (instance = node.child),
+ null !== instance && (instance.return = node),
+ appendAllChildrenToContainer(containerChildSet, node, !0, !0);
+ else if (null !== node.child) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ if (node === workInProgress) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === workInProgress) return;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
}
- 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;
+updateHostContainer = function(current, workInProgress) {
+ var portalOrRoot = workInProgress.stateNode;
+ if (!hadNoMutationsEffects(current, workInProgress)) {
+ current = portalOrRoot.containerInfo;
+ var newChildSet = createChildNodeSet(current);
+ appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1);
+ portalOrRoot.pendingChildren = newChildSet;
+ workInProgress.flags |= 4;
+ completeRoot(current, newChildSet);
+ }
+};
+updateHostComponent = function(current, workInProgress, type, newProps) {
+ type = current.stateNode;
+ var oldProps = current.memoizedProps;
if (
- "hidden" === nextProps.mode ||
- "unstable-defer-without-hiding" === nextProps.mode
+ (current = hadNoMutationsEffects(current, workInProgress)) &&
+ oldProps === newProps
)
- if (0 === (workInProgress.mode & 1))
- (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }),
- push(subtreeRenderLanesCursor, subtreeRenderLanes),
- (subtreeRenderLanes |= renderLanes);
- else {
- if (0 === (renderLanes & 1073741824))
- return (
- (current =
- null !== prevState
- ? prevState.baseLanes | renderLanes
- : renderLanes),
- (workInProgress.lanes = workInProgress.childLanes = 1073741824),
- (workInProgress.memoizedState = {
- baseLanes: current,
- cachePool: null
- }),
- (workInProgress.updateQueue = null),
- push(subtreeRenderLanesCursor, subtreeRenderLanes),
- (subtreeRenderLanes |= current),
- null
- );
- workInProgress.memoizedState = { baseLanes: 0, cachePool: null };
- nextProps = null !== prevState ? prevState.baseLanes : renderLanes;
- push(subtreeRenderLanesCursor, subtreeRenderLanes);
- subtreeRenderLanes |= nextProps;
- }
- else
- null !== prevState
- ? ((nextProps = prevState.baseLanes | renderLanes),
- (workInProgress.memoizedState = null))
- : (nextProps = renderLanes),
- push(subtreeRenderLanesCursor, subtreeRenderLanes),
- (subtreeRenderLanes |= nextProps);
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
+ workInProgress.stateNode = type;
+ else {
+ var recyclableInstance = workInProgress.stateNode;
+ requiredContext(contextStackCursor$1.current);
+ var updatePayload = null;
+ oldProps !== newProps &&
+ ((oldProps = diffProperties(
+ null,
+ oldProps,
+ newProps,
+ recyclableInstance.canonical.viewConfig.validAttributes
+ )),
+ (recyclableInstance.canonical.currentProps = newProps),
+ (updatePayload = oldProps));
+ current && null === updatePayload
+ ? (workInProgress.stateNode = type)
+ : ((newProps = updatePayload),
+ (oldProps = type.node),
+ (type = {
+ node: current
+ ? null !== newProps
+ ? cloneNodeWithNewProps(oldProps, newProps)
+ : cloneNode(oldProps)
+ : null !== newProps
+ ? cloneNodeWithNewChildrenAndProps(oldProps, newProps)
+ : cloneNodeWithNewChildren(oldProps),
+ canonical: type.canonical
+ }),
+ (workInProgress.stateNode = type),
+ current
+ ? (workInProgress.flags |= 4)
+ : appendAllChildren(type, workInProgress, !1, !1));
+ }
+};
+updateHostText = function(current, workInProgress, oldText, newText) {
+ oldText !== newText
+ ? ((current = requiredContext(rootInstanceStackCursor.current)),
+ (oldText = requiredContext(contextStackCursor$1.current)),
+ (workInProgress.stateNode = createTextInstance(
+ newText,
+ current,
+ oldText,
+ workInProgress
+ )),
+ (workInProgress.flags |= 4))
+ : (workInProgress.stateNode = current.stateNode);
+};
+function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
+ switch (renderState.tailMode) {
+ case "hidden":
+ hasRenderedATailFallback = renderState.tail;
+ for (var lastTailNode = null; null !== hasRenderedATailFallback; )
+ null !== hasRenderedATailFallback.alternate &&
+ (lastTailNode = hasRenderedATailFallback),
+ (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
+ null === lastTailNode
+ ? (renderState.tail = null)
+ : (lastTailNode.sibling = null);
+ break;
+ case "collapsed":
+ lastTailNode = renderState.tail;
+ for (var lastTailNode$37 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$37 = lastTailNode),
+ (lastTailNode = lastTailNode.sibling);
+ null === lastTailNode$37
+ ? hasRenderedATailFallback || null === renderState.tail
+ ? (renderState.tail = null)
+ : (renderState.tail.sibling = null)
+ : (lastTailNode$37.sibling = null);
+ }
}
-function markRef(current, workInProgress) {
- var ref = workInProgress.ref;
- if (
- (null === current && null !== ref) ||
- (null !== current && current.ref !== ref)
- )
- workInProgress.flags |= 256;
-}
-function updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- var context = isContextProvider(Component)
- ? previousContext
- : contextStackCursor.current;
- context = getMaskedContext(workInProgress, context);
- prepareToReadContext(workInProgress, renderLanes);
- Component = renderWithHooks(
- current,
- workInProgress,
- Component,
- nextProps,
- context,
- renderLanes
- );
- if (null !== current && !didReceiveUpdate)
- return (
- (workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
- (current.lanes &= ~renderLanes),
- bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
- );
- workInProgress.flags |= 1;
- reconcileChildren(current, workInProgress, Component, renderLanes);
- return workInProgress.child;
+function bubbleProperties(completedWork) {
+ var didBailout =
+ null !== completedWork.alternate &&
+ completedWork.alternate.child === completedWork.child,
+ newChildLanes = 0,
+ subtreeFlags = 0;
+ if (didBailout)
+ if (0 !== (completedWork.mode & 2)) {
+ for (
+ var treeBaseDuration$39 = completedWork.selfBaseDuration,
+ child$40 = completedWork.child;
+ null !== child$40;
+
+ )
+ (newChildLanes |= child$40.lanes | child$40.childLanes),
+ (subtreeFlags |= child$40.subtreeFlags & 14680064),
+ (subtreeFlags |= child$40.flags & 14680064),
+ (treeBaseDuration$39 += child$40.treeBaseDuration),
+ (child$40 = child$40.sibling);
+ completedWork.treeBaseDuration = treeBaseDuration$39;
+ } else
+ for (
+ treeBaseDuration$39 = completedWork.child;
+ null !== treeBaseDuration$39;
+
+ )
+ (newChildLanes |=
+ treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes),
+ (subtreeFlags |= treeBaseDuration$39.subtreeFlags & 14680064),
+ (subtreeFlags |= treeBaseDuration$39.flags & 14680064),
+ (treeBaseDuration$39.return = completedWork),
+ (treeBaseDuration$39 = treeBaseDuration$39.sibling);
+ else if (0 !== (completedWork.mode & 2)) {
+ treeBaseDuration$39 = completedWork.actualDuration;
+ child$40 = completedWork.selfBaseDuration;
+ for (var child = completedWork.child; null !== child; )
+ (newChildLanes |= child.lanes | child.childLanes),
+ (subtreeFlags |= child.subtreeFlags),
+ (subtreeFlags |= child.flags),
+ (treeBaseDuration$39 += child.actualDuration),
+ (child$40 += child.treeBaseDuration),
+ (child = child.sibling);
+ completedWork.actualDuration = treeBaseDuration$39;
+ completedWork.treeBaseDuration = child$40;
+ } else
+ for (
+ treeBaseDuration$39 = completedWork.child;
+ null !== treeBaseDuration$39;
+
+ )
+ (newChildLanes |=
+ treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes),
+ (subtreeFlags |= treeBaseDuration$39.subtreeFlags),
+ (subtreeFlags |= treeBaseDuration$39.flags),
+ (treeBaseDuration$39.return = completedWork),
+ (treeBaseDuration$39 = treeBaseDuration$39.sibling);
+ completedWork.subtreeFlags |= subtreeFlags;
+ completedWork.childLanes = newChildLanes;
+ return didBailout;
}
-function updateClassComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- if (isContextProvider(Component)) {
- var hasContext = !0;
- pushContextProvider(workInProgress);
- } else hasContext = !1;
- prepareToReadContext(workInProgress, renderLanes);
- if (null === workInProgress.stateNode)
- null !== current &&
- ((current.alternate = null),
- (workInProgress.alternate = null),
- (workInProgress.flags |= 2)),
- constructClassInstance(workInProgress, Component, nextProps),
- mountClassInstance(workInProgress, Component, nextProps, renderLanes),
- (nextProps = !0);
- else if (null === current) {
- var instance = workInProgress.stateNode,
- oldProps = workInProgress.memoizedProps;
- instance.props = oldProps;
- var oldContext = instance.context,
- contextType = Component.contextType;
- "object" === typeof contextType && null !== contextType
- ? (contextType = readContext(contextType))
- : ((contextType = isContextProvider(Component)
- ? previousContext
- : contextStackCursor.current),
- (contextType = getMaskedContext(workInProgress, contextType)));
- var getDerivedStateFromProps = Component.getDerivedStateFromProps,
- hasNewLifecycles =
- "function" === typeof getDerivedStateFromProps ||
- "function" === typeof instance.getSnapshotBeforeUpdate;
- hasNewLifecycles ||
- ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
- "function" !== typeof instance.componentWillReceiveProps) ||
- ((oldProps !== nextProps || oldContext !== contextType) &&
- callComponentWillReceiveProps(
+function completeWork(current, workInProgress, renderLanes) {
+ var newProps = workInProgress.pendingProps;
+ popTreeContext(workInProgress);
+ switch (workInProgress.tag) {
+ case 2:
+ case 16:
+ case 15:
+ case 0:
+ case 11:
+ case 7:
+ case 8:
+ case 12:
+ case 9:
+ case 14:
+ return bubbleProperties(workInProgress), null;
+ case 1:
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 3:
+ return (
+ (newProps = workInProgress.stateNode),
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ null === current ||
+ (current.memoizedState.isDehydrated &&
+ 0 === (workInProgress.flags & 256)) ||
+ (workInProgress.flags |= 1024),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 5:
+ popHostContext(workInProgress);
+ renderLanes = requiredContext(rootInstanceStackCursor.current);
+ var type = workInProgress.type;
+ if (null !== current && null != workInProgress.stateNode)
+ updateHostComponent(
+ current,
workInProgress,
- instance,
- nextProps,
- contextType
- ));
- hasForceUpdate = !1;
- var oldState = workInProgress.memoizedState;
- instance.state = oldState;
- processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
- oldContext = workInProgress.memoizedState;
- oldProps !== nextProps ||
- oldState !== oldContext ||
- didPerformWorkStackCursor.current ||
- hasForceUpdate
- ? ("function" === typeof getDerivedStateFromProps &&
- (applyDerivedStateFromProps(
- workInProgress,
- Component,
- getDerivedStateFromProps,
- nextProps
- ),
- (oldContext = workInProgress.memoizedState)),
- (oldProps =
- hasForceUpdate ||
- checkShouldComponentUpdate(
- workInProgress,
- Component,
- oldProps,
- nextProps,
- oldState,
- oldContext,
- contextType
- ))
- ? (hasNewLifecycles ||
- ("function" !== typeof instance.UNSAFE_componentWillMount &&
- "function" !== typeof instance.componentWillMount) ||
- ("function" === typeof instance.componentWillMount &&
- instance.componentWillMount(),
- "function" === typeof instance.UNSAFE_componentWillMount &&
- instance.UNSAFE_componentWillMount()),
- "function" === typeof instance.componentDidMount &&
- (workInProgress.flags |= 4))
- : ("function" === typeof instance.componentDidMount &&
- (workInProgress.flags |= 4),
- (workInProgress.memoizedProps = nextProps),
- (workInProgress.memoizedState = oldContext)),
- (instance.props = nextProps),
- (instance.state = oldContext),
- (instance.context = contextType),
- (nextProps = oldProps))
- : ("function" === typeof instance.componentDidMount &&
- (workInProgress.flags |= 4),
- (nextProps = !1));
- } 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(
+ type,
+ newProps,
+ renderLanes
+ ),
+ current.ref !== workInProgress.ref && (workInProgress.flags |= 512);
+ else {
+ if (!newProps) {
+ if (null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ }
+ requiredContext(contextStackCursor$1.current);
+ current = nextReactTag;
+ nextReactTag += 2;
+ type = getViewConfigForType(type);
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ newProps,
+ type.validAttributes
+ );
+ renderLanes = createNode(
+ current,
+ type.uiViewClassName,
+ renderLanes,
+ updatePayload,
+ workInProgress
+ );
+ current = new ReactFabricHostComponent(
+ current,
+ type,
+ newProps,
+ workInProgress
+ );
+ current = { node: renderLanes, canonical: current };
+ appendAllChildren(current, workInProgress, !1, !1);
+ workInProgress.stateNode = current;
+ null !== workInProgress.ref && (workInProgress.flags |= 512);
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 6:
+ if (current && null != workInProgress.stateNode)
+ updateHostText(
+ current,
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,
- Component,
- contextType,
- nextProps,
- oldState,
- newState,
- oldContext
- ) ||
- !1)
- ? (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.flags |= 4),
- "function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.flags |= 512))
- : ("function" !== typeof instance.componentDidUpdate ||
- (oldProps === current.memoizedProps &&
- oldState === current.memoizedState) ||
- (workInProgress.flags |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
- (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.flags |= 4),
- "function" !== typeof instance.getSnapshotBeforeUpdate ||
- (oldProps === current.memoizedProps &&
- oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
- (nextProps = !1));
- }
- return finishClassComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- hasContext,
- renderLanes
- );
-}
-function finishClassComponent(
- current,
- workInProgress,
- Component,
- shouldUpdate,
- hasContext,
- renderLanes
-) {
- markRef(current, workInProgress);
- var didCaptureError = 0 !== (workInProgress.flags & 128);
- if (!shouldUpdate && !didCaptureError)
- return (
- hasContext && invalidateContextProvider(workInProgress, Component, !1),
- bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
- );
- shouldUpdate = workInProgress.stateNode;
- ReactCurrentOwner$1.current = workInProgress;
- if (
- didCaptureError &&
- "function" !== typeof Component.getDerivedStateFromError
- ) {
- var nextChildren = null;
- profilerStartTime = -1;
- } else nextChildren = shouldUpdate.render();
- workInProgress.flags |= 1;
- null !== current && didCaptureError
- ? ((didCaptureError = nextChildren),
- (workInProgress.child = reconcileChildFibers(
- workInProgress,
- current.child,
- null,
- renderLanes
- )),
- (workInProgress.child = reconcileChildFibers(
- workInProgress,
- null,
- didCaptureError,
- renderLanes
- )))
- : reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- workInProgress.memoizedState = shouldUpdate.state;
- hasContext && invalidateContextProvider(workInProgress, Component, !0);
- return workInProgress.child;
-}
-function pushHostRootContext(workInProgress) {
- var root = workInProgress.stateNode;
- root.pendingContext
- ? pushTopLevelContextObject(
- workInProgress,
- root.pendingContext,
- root.pendingContext !== root.context
- )
- : root.context &&
- pushTopLevelContextObject(workInProgress, root.context, !1);
- pushHostContainer(workInProgress, root.containerInfo);
-}
-var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
-function mountSuspenseOffscreenState(renderLanes) {
- return { baseLanes: renderLanes, cachePool: null };
-}
-function updateSuspenseComponent(current, workInProgress, renderLanes) {
- var nextProps = workInProgress.pendingProps,
- suspenseContext = suspenseStackCursor.current,
- showFallback = !1,
- JSCompiler_temp;
- (JSCompiler_temp = 0 !== (workInProgress.flags & 128)) ||
- (JSCompiler_temp =
- null !== current && null === current.memoizedState
- ? !1
- : 0 !== (suspenseContext & 2));
- JSCompiler_temp
- ? ((showFallback = !0), (workInProgress.flags &= -129))
- : (null !== current && null === current.memoizedState) ||
- void 0 === nextProps.fallback ||
- !0 === nextProps.unstable_avoidThisFallback ||
- (suspenseContext |= 1);
- push(suspenseStackCursor, suspenseContext & 1);
- if (null === current) {
- current = nextProps.children;
- suspenseContext = nextProps.fallback;
- if (showFallback)
+ current.memoizedProps,
+ newProps
+ );
+ else {
+ if ("string" !== typeof newProps && null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ current = requiredContext(rootInstanceStackCursor.current);
+ renderLanes = requiredContext(contextStackCursor$1.current);
+ workInProgress.stateNode = createTextInstance(
+ newProps,
+ current,
+ renderLanes,
+ workInProgress
+ );
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 13:
+ pop(suspenseStackCursor);
+ newProps = workInProgress.memoizedState;
+ if (0 !== (workInProgress.flags & 128))
+ return (
+ (workInProgress.lanes = renderLanes),
+ 0 !== (workInProgress.mode & 2) &&
+ transferActualDuration(workInProgress),
+ workInProgress
+ );
+ newProps = null !== newProps;
+ renderLanes = !1;
+ null !== current && (renderLanes = null !== current.memoizedState);
+ newProps &&
+ !renderLanes &&
+ ((workInProgress.child.flags |= 8192),
+ 0 !== (workInProgress.mode & 1) &&
+ (null === current || 0 !== (suspenseStackCursor.current & 1)
+ ? 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3)
+ : renderDidSuspendDelayIfPossible()));
+ null !== workInProgress.updateQueue && (workInProgress.flags |= 4);
+ bubbleProperties(workInProgress);
+ 0 !== (workInProgress.mode & 2) &&
+ newProps &&
+ ((current = workInProgress.child),
+ null !== current &&
+ (workInProgress.treeBaseDuration -= current.treeBaseDuration));
+ return null;
+ case 4:
+ return (
+ popHostContainer(),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 10:
return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
- current,
- suspenseContext,
- renderLanes
- )),
- (workInProgress.child.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- )),
- (workInProgress.memoizedState = SUSPENDED_MARKER),
- current
+ popProvider(workInProgress.type._context),
+ bubbleProperties(workInProgress),
+ null
);
- if ("number" === typeof nextProps.unstable_expectedLoadTime)
+ case 17:
return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
- current,
- suspenseContext,
- renderLanes
- )),
- (workInProgress.child.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- )),
- (workInProgress.memoizedState = SUSPENDED_MARKER),
- (workInProgress.lanes = 4194304),
- current
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
);
- renderLanes = createFiberFromOffscreen(
- { mode: "visible", children: current },
- workInProgress.mode,
- renderLanes,
- null
- );
- renderLanes.return = workInProgress;
- return (workInProgress.child = renderLanes);
- }
- if (null !== current.memoizedState) {
- if (showFallback)
+ case 19:
+ pop(suspenseStackCursor);
+ type = workInProgress.memoizedState;
+ if (null === type) return bubbleProperties(workInProgress), null;
+ newProps = 0 !== (workInProgress.flags & 128);
+ updatePayload = type.rendering;
+ if (null === updatePayload)
+ if (newProps) cutOffTailIfNeeded(type, !1);
+ else {
+ if (
+ 0 !== workInProgressRootExitStatus ||
+ (null !== current && 0 !== (current.flags & 128))
+ )
+ for (current = workInProgress.child; null !== current; ) {
+ updatePayload = findFirstSuspended(current);
+ if (null !== updatePayload) {
+ workInProgress.flags |= 128;
+ cutOffTailIfNeeded(type, !1);
+ current = updatePayload.updateQueue;
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4));
+ workInProgress.subtreeFlags = 0;
+ current = renderLanes;
+ for (newProps = workInProgress.child; null !== newProps; )
+ (renderLanes = newProps),
+ (updatePayload = current),
+ (renderLanes.flags &= 14680066),
+ (type = renderLanes.alternate),
+ null === type
+ ? ((renderLanes.childLanes = 0),
+ (renderLanes.lanes = updatePayload),
+ (renderLanes.child = null),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.memoizedProps = null),
+ (renderLanes.memoizedState = null),
+ (renderLanes.updateQueue = null),
+ (renderLanes.dependencies = null),
+ (renderLanes.stateNode = null),
+ (renderLanes.selfBaseDuration = 0),
+ (renderLanes.treeBaseDuration = 0))
+ : ((renderLanes.childLanes = type.childLanes),
+ (renderLanes.lanes = type.lanes),
+ (renderLanes.child = type.child),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.deletions = null),
+ (renderLanes.memoizedProps = type.memoizedProps),
+ (renderLanes.memoizedState = type.memoizedState),
+ (renderLanes.updateQueue = type.updateQueue),
+ (renderLanes.type = type.type),
+ (updatePayload = type.dependencies),
+ (renderLanes.dependencies =
+ null === updatePayload
+ ? null
+ : {
+ lanes: updatePayload.lanes,
+ firstContext: updatePayload.firstContext
+ }),
+ (renderLanes.selfBaseDuration = type.selfBaseDuration),
+ (renderLanes.treeBaseDuration = type.treeBaseDuration)),
+ (newProps = newProps.sibling);
+ push(
+ suspenseStackCursor,
+ (suspenseStackCursor.current & 1) | 2
+ );
+ return workInProgress.child;
+ }
+ current = current.sibling;
+ }
+ null !== type.tail &&
+ now() > workInProgressRootRenderTargetTime &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ }
+ else {
+ if (!newProps)
+ if (
+ ((current = findFirstSuspended(updatePayload)), null !== current)
+ ) {
+ if (
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ (current = current.updateQueue),
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4)),
+ cutOffTailIfNeeded(type, !0),
+ null === type.tail &&
+ "hidden" === type.tailMode &&
+ !updatePayload.alternate)
+ )
+ return bubbleProperties(workInProgress), null;
+ } else
+ 2 * now() - type.renderingStartTime >
+ workInProgressRootRenderTargetTime &&
+ 1073741824 !== renderLanes &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ type.isBackwards
+ ? ((updatePayload.sibling = workInProgress.child),
+ (workInProgress.child = updatePayload))
+ : ((current = type.last),
+ null !== current
+ ? (current.sibling = updatePayload)
+ : (workInProgress.child = updatePayload),
+ (type.last = updatePayload));
+ }
+ if (null !== type.tail)
+ return (
+ (workInProgress = type.tail),
+ (type.rendering = workInProgress),
+ (type.tail = workInProgress.sibling),
+ (type.renderingStartTime = now()),
+ (workInProgress.sibling = null),
+ (current = suspenseStackCursor.current),
+ push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
+ workInProgress
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ case 22:
+ case 23:
return (
- (nextProps = updateSuspenseFallbackChildren(
- current,
- workInProgress,
- nextProps.children,
- nextProps.fallback,
- renderLanes
- )),
- (showFallback = workInProgress.child),
- (suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
- null === suspenseContext
- ? mountSuspenseOffscreenState(renderLanes)
- : {
- baseLanes: suspenseContext.baseLanes | renderLanes,
- cachePool: null
- }),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
- (workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
+ popRenderLanes(),
+ (newProps = null !== workInProgress.memoizedState),
+ null !== current &&
+ (null !== current.memoizedState) !== newProps &&
+ (workInProgress.flags |= 8192),
+ newProps && 0 !== (workInProgress.mode & 1)
+ ? 0 !== (subtreeRenderLanes & 1073741824) &&
+ bubbleProperties(workInProgress)
+ : bubbleProperties(workInProgress),
+ null
);
- renderLanes = updateSuspensePrimaryChildren(
- current,
- workInProgress,
- nextProps.children,
- renderLanes
- );
- workInProgress.memoizedState = null;
- return renderLanes;
+ case 24:
+ return null;
+ case 25:
+ return null;
}
- if (showFallback)
- return (
- (nextProps = updateSuspenseFallbackChildren(
- current,
- workInProgress,
- nextProps.children,
- nextProps.fallback,
- renderLanes
- )),
- (showFallback = workInProgress.child),
- (suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
- null === suspenseContext
- ? mountSuspenseOffscreenState(renderLanes)
- : {
- baseLanes: suspenseContext.baseLanes | renderLanes,
- cachePool: null
- }),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
- (workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
- );
- renderLanes = updateSuspensePrimaryChildren(
- current,
- workInProgress,
- nextProps.children,
- renderLanes
+ throw Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in React. Please file an issue."
);
- workInProgress.memoizedState = null;
- return renderLanes;
}
-function mountSuspenseFallbackChildren(
+var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
+ didReceiveUpdate = !1;
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
+ workInProgress.child =
+ null === current
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
+ : reconcileChildFibers(
+ workInProgress,
+ current.child,
+ nextChildren,
+ renderLanes
+ );
+}
+function updateForwardRef(
+ current,
workInProgress,
- primaryChildren,
- fallbackChildren,
+ Component,
+ nextProps,
renderLanes
) {
- var mode = workInProgress.mode,
- progressedPrimaryFragment = workInProgress.child;
- primaryChildren = { mode: "hidden", children: primaryChildren };
- 0 === (mode & 1) && null !== progressedPrimaryFragment
- ? ((progressedPrimaryFragment.childLanes = 0),
- (progressedPrimaryFragment.pendingProps = primaryChildren),
- workInProgress.mode & 2 &&
- ((progressedPrimaryFragment.actualDuration = 0),
- (progressedPrimaryFragment.actualStartTime = -1),
- (progressedPrimaryFragment.selfBaseDuration = 0),
- (progressedPrimaryFragment.treeBaseDuration = 0)))
- : (progressedPrimaryFragment = createFiberFromOffscreen(
- primaryChildren,
- mode,
- 0,
- null
- ));
- fallbackChildren = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- );
- progressedPrimaryFragment.return = workInProgress;
- fallbackChildren.return = workInProgress;
- progressedPrimaryFragment.sibling = fallbackChildren;
- workInProgress.child = progressedPrimaryFragment;
- return fallbackChildren;
+ Component = Component.render;
+ var ref = workInProgress.ref;
+ prepareToReadContext(workInProgress, renderLanes);
+ nextProps = renderWithHooks(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ ref,
+ renderLanes
+ );
+ if (null !== current && !didReceiveUpdate)
+ return (
+ (workInProgress.updateQueue = current.updateQueue),
+ (workInProgress.flags &= -2053),
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
+ );
+ workInProgress.flags |= 1;
+ reconcileChildren(current, workInProgress, nextProps, renderLanes);
+ return workInProgress.child;
}
-function updateSuspensePrimaryChildren(
+function updateMemoComponent(
current,
workInProgress,
- primaryChildren,
+ Component,
+ nextProps,
renderLanes
) {
- var currentPrimaryChildFragment = current.child;
- current = currentPrimaryChildFragment.sibling;
- primaryChildren = createWorkInProgress(currentPrimaryChildFragment, {
- mode: "visible",
- children: primaryChildren
- });
- 0 === (workInProgress.mode & 1) && (primaryChildren.lanes = renderLanes);
- primaryChildren.return = workInProgress;
- primaryChildren.sibling = null;
- null !== current &&
- ((renderLanes = workInProgress.deletions),
- null === renderLanes
- ? ((workInProgress.deletions = [current]), (workInProgress.flags |= 16))
- : renderLanes.push(current));
- return (workInProgress.child = primaryChildren);
+ if (null === current) {
+ var type = Component.type;
+ if (
+ "function" === typeof type &&
+ !shouldConstruct(type) &&
+ void 0 === type.defaultProps &&
+ null === Component.compare &&
+ void 0 === Component.defaultProps
+ )
+ return (
+ (workInProgress.tag = 15),
+ (workInProgress.type = type),
+ updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ type,
+ nextProps,
+ renderLanes
+ )
+ );
+ current = createFiberFromTypeAndProps(
+ Component.type,
+ null,
+ nextProps,
+ workInProgress,
+ workInProgress.mode,
+ renderLanes
+ );
+ current.ref = workInProgress.ref;
+ current.return = workInProgress;
+ return (workInProgress.child = current);
+ }
+ type = current.child;
+ if (0 === (current.lanes & renderLanes)) {
+ var prevProps = type.memoizedProps;
+ Component = Component.compare;
+ Component = null !== Component ? Component : shallowEqual;
+ if (Component(prevProps, nextProps) && current.ref === workInProgress.ref)
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
+ workInProgress.flags |= 1;
+ current = createWorkInProgress(type, nextProps);
+ current.ref = workInProgress.ref;
+ current.return = workInProgress;
+ return (workInProgress.child = current);
}
-function updateSuspenseFallbackChildren(
+function updateSimpleMemoComponent(
current,
workInProgress,
- primaryChildren,
- fallbackChildren,
+ Component,
+ nextProps,
renderLanes
) {
- var mode = workInProgress.mode;
- current = current.child;
- var currentFallbackChildFragment = current.sibling,
- primaryChildProps = { mode: "hidden", children: primaryChildren };
- 0 === (mode & 1) && workInProgress.child !== current
- ? ((primaryChildren = workInProgress.child),
- (primaryChildren.childLanes = 0),
- (primaryChildren.pendingProps = primaryChildProps),
- workInProgress.mode & 2 &&
- ((primaryChildren.actualDuration = 0),
- (primaryChildren.actualStartTime = -1),
- (primaryChildren.selfBaseDuration = current.selfBaseDuration),
- (primaryChildren.treeBaseDuration = current.treeBaseDuration)),
- (workInProgress.deletions = null))
- : ((primaryChildren = createWorkInProgress(current, primaryChildProps)),
- (primaryChildren.subtreeFlags = current.subtreeFlags & 1835008));
- null !== currentFallbackChildFragment
- ? (fallbackChildren = createWorkInProgress(
- currentFallbackChildFragment,
- fallbackChildren
- ))
- : ((fallbackChildren = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- )),
- (fallbackChildren.flags |= 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.lanes |= renderLanes);
- scheduleWorkOnParentPath(fiber.return, renderLanes);
-}
-function initSuspenseListRenderState(
- workInProgress,
- isBackwards,
- tail,
- lastContentRow,
- tailMode
-) {
- var renderState = workInProgress.memoizedState;
- null === renderState
- ? (workInProgress.memoizedState = {
- isBackwards: isBackwards,
- rendering: null,
- renderingStartTime: 0,
- last: lastContentRow,
- tail: tail,
- tailMode: tailMode
- })
- : ((renderState.isBackwards = isBackwards),
- (renderState.rendering = null),
- (renderState.renderingStartTime = 0),
- (renderState.last = lastContentRow),
- (renderState.tail = tail),
- (renderState.tailMode = tailMode));
+ if (
+ null !== current &&
+ shallowEqual(current.memoizedProps, nextProps) &&
+ current.ref === workInProgress.ref
+ )
+ if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes)))
+ 0 !== (current.flags & 131072) && (didReceiveUpdate = !0);
+ else
+ return (
+ (workInProgress.lanes = current.lanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
+ );
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
}
-function updateSuspenseListComponent(current, workInProgress, renderLanes) {
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
var nextProps = workInProgress.pendingProps,
- revealOrder = nextProps.revealOrder,
- tailMode = nextProps.tail;
- reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
- nextProps = suspenseStackCursor.current;
- if (0 !== (nextProps & 2))
- (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128);
- else {
- if (null !== current && 0 !== (current.flags & 128))
- a: for (current = workInProgress.child; null !== current; ) {
- if (13 === current.tag)
- null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderLanes);
- else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
- else if (null !== current.child) {
- current.child.return = current;
- current = current.child;
- continue;
- }
- if (current === workInProgress) break a;
- for (; null === current.sibling; ) {
- if (null === current.return || current.return === workInProgress)
- break a;
- current = current.return;
- }
- current.sibling.return = current.return;
- current = current.sibling;
- }
- nextProps &= 1;
- }
- push(suspenseStackCursor, nextProps);
- if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null;
- else
- switch (revealOrder) {
- case "forwards":
- renderLanes = workInProgress.child;
- for (revealOrder = null; null !== renderLanes; )
- (current = renderLanes.alternate),
- null !== current &&
- null === findFirstSuspended(current) &&
- (revealOrder = renderLanes),
- (renderLanes = renderLanes.sibling);
- renderLanes = revealOrder;
- null === renderLanes
- ? ((revealOrder = workInProgress.child),
- (workInProgress.child = null))
- : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
- initSuspenseListRenderState(
- workInProgress,
- !1,
- revealOrder,
- renderLanes,
- tailMode
- );
- break;
- case "backwards":
- renderLanes = null;
- revealOrder = workInProgress.child;
- for (workInProgress.child = null; null !== revealOrder; ) {
- current = revealOrder.alternate;
- if (null !== current && null === findFirstSuspended(current)) {
- workInProgress.child = revealOrder;
- break;
- }
- current = revealOrder.sibling;
- revealOrder.sibling = renderLanes;
- renderLanes = revealOrder;
- revealOrder = current;
- }
- initSuspenseListRenderState(
- workInProgress,
- !0,
- renderLanes,
- null,
- tailMode
+ nextChildren = nextProps.children,
+ prevState = null !== current ? current.memoizedState : null;
+ if ("hidden" === nextProps.mode)
+ if (0 === (workInProgress.mode & 1))
+ (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }),
+ push(subtreeRenderLanesCursor, subtreeRenderLanes),
+ (subtreeRenderLanes |= renderLanes);
+ else {
+ if (0 === (renderLanes & 1073741824))
+ return (
+ (current =
+ null !== prevState
+ ? prevState.baseLanes | renderLanes
+ : renderLanes),
+ (workInProgress.lanes = workInProgress.childLanes = 1073741824),
+ (workInProgress.memoizedState = {
+ baseLanes: current,
+ cachePool: null
+ }),
+ (workInProgress.updateQueue = null),
+ push(subtreeRenderLanesCursor, subtreeRenderLanes),
+ (subtreeRenderLanes |= current),
+ null
);
- break;
- case "together":
- initSuspenseListRenderState(workInProgress, !1, null, null, void 0);
- break;
- default:
- workInProgress.memoizedState = null;
+ workInProgress.memoizedState = { baseLanes: 0, cachePool: null };
+ nextProps = null !== prevState ? prevState.baseLanes : renderLanes;
+ push(subtreeRenderLanesCursor, subtreeRenderLanes);
+ subtreeRenderLanes |= nextProps;
}
+ else
+ null !== prevState
+ ? ((nextProps = prevState.baseLanes | renderLanes),
+ (workInProgress.memoizedState = null))
+ : (nextProps = renderLanes),
+ push(subtreeRenderLanesCursor, subtreeRenderLanes),
+ (subtreeRenderLanes |= nextProps);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
- null !== current && (workInProgress.dependencies = current.dependencies);
- profilerStartTime = -1;
- workInProgressRootSkippedLanes |= workInProgress.lanes;
- if (0 === (renderLanes & workInProgress.childLanes)) return null;
- 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;
- }
+function markRef$1(current, workInProgress) {
+ var ref = workInProgress.ref;
+ if (
+ (null === current && null !== ref) ||
+ (null !== current && current.ref !== ref)
+ )
+ workInProgress.flags |= 512;
+}
+function updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ var context = isContextProvider(Component)
+ ? previousContext
+ : contextStackCursor.current;
+ context = getMaskedContext(workInProgress, context);
+ prepareToReadContext(workInProgress, renderLanes);
+ Component = renderWithHooks(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ context,
+ renderLanes
+ );
+ if (null !== current && !didReceiveUpdate)
+ return (
+ (workInProgress.updateQueue = current.updateQueue),
+ (workInProgress.flags &= -2053),
+ (current.lanes &= ~renderLanes),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
+ );
+ workInProgress.flags |= 1;
+ reconcileChildren(current, workInProgress, Component, renderLanes);
return workInProgress.child;
}
-function hadNoMutationsEffects(current, completedWork) {
- if (null !== current && current.child === completedWork.child) return !0;
- if (0 !== (completedWork.flags & 16)) return !1;
- for (current = completedWork.child; null !== current; ) {
- if (0 !== (current.flags & 6454) || 0 !== (current.subtreeFlags & 6454))
- return !1;
- current = current.sibling;
+function updateClassComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ if (isContextProvider(Component)) {
+ var hasContext = !0;
+ pushContextProvider(workInProgress);
+ } else hasContext = !1;
+ prepareToReadContext(workInProgress, renderLanes);
+ if (null === workInProgress.stateNode)
+ null !== current &&
+ ((current.alternate = null),
+ (workInProgress.alternate = null),
+ (workInProgress.flags |= 2)),
+ constructClassInstance(workInProgress, Component, nextProps),
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes),
+ (nextProps = !0);
+ else if (null === current) {
+ var instance = workInProgress.stateNode,
+ oldProps = workInProgress.memoizedProps;
+ instance.props = oldProps;
+ var oldContext = instance.context,
+ contextType = Component.contextType;
+ "object" === typeof contextType && null !== contextType
+ ? (contextType = readContext(contextType))
+ : ((contextType = isContextProvider(Component)
+ ? previousContext
+ : contextStackCursor.current),
+ (contextType = getMaskedContext(workInProgress, contextType)));
+ var getDerivedStateFromProps = Component.getDerivedStateFromProps,
+ hasNewLifecycles =
+ "function" === typeof getDerivedStateFromProps ||
+ "function" === typeof instance.getSnapshotBeforeUpdate;
+ hasNewLifecycles ||
+ ("function" !== typeof instance.UNSAFE_componentWillReceiveProps &&
+ "function" !== typeof instance.componentWillReceiveProps) ||
+ ((oldProps !== nextProps || oldContext !== contextType) &&
+ callComponentWillReceiveProps(
+ workInProgress,
+ instance,
+ nextProps,
+ contextType
+ ));
+ hasForceUpdate = !1;
+ var oldState = workInProgress.memoizedState;
+ instance.state = oldState;
+ processUpdateQueue(workInProgress, nextProps, instance, renderLanes);
+ oldContext = workInProgress.memoizedState;
+ oldProps !== nextProps ||
+ oldState !== oldContext ||
+ didPerformWorkStackCursor.current ||
+ hasForceUpdate
+ ? ("function" === typeof getDerivedStateFromProps &&
+ (applyDerivedStateFromProps(
+ workInProgress,
+ Component,
+ getDerivedStateFromProps,
+ nextProps
+ ),
+ (oldContext = workInProgress.memoizedState)),
+ (oldProps =
+ hasForceUpdate ||
+ checkShouldComponentUpdate(
+ workInProgress,
+ Component,
+ oldProps,
+ nextProps,
+ oldState,
+ oldContext,
+ contextType
+ ))
+ ? (hasNewLifecycles ||
+ ("function" !== typeof instance.UNSAFE_componentWillMount &&
+ "function" !== typeof instance.componentWillMount) ||
+ ("function" === typeof instance.componentWillMount &&
+ instance.componentWillMount(),
+ "function" === typeof instance.UNSAFE_componentWillMount &&
+ instance.UNSAFE_componentWillMount()),
+ "function" === typeof instance.componentDidMount &&
+ (workInProgress.flags |= 4))
+ : ("function" === typeof instance.componentDidMount &&
+ (workInProgress.flags |= 4),
+ (workInProgress.memoizedProps = nextProps),
+ (workInProgress.memoizedState = oldContext)),
+ (instance.props = nextProps),
+ (instance.state = oldContext),
+ (instance.context = contextType),
+ (nextProps = oldProps))
+ : ("function" === typeof instance.componentDidMount &&
+ (workInProgress.flags |= 4),
+ (nextProps = !1));
+ } 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,
+ Component,
+ contextType,
+ nextProps,
+ oldState,
+ newState,
+ oldContext
+ ) ||
+ !1)
+ ? (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.flags |= 4),
+ "function" === typeof instance.getSnapshotBeforeUpdate &&
+ (workInProgress.flags |= 1024))
+ : ("function" !== typeof instance.componentDidUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.flags |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.flags |= 1024),
+ (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.flags |= 4),
+ "function" !== typeof instance.getSnapshotBeforeUpdate ||
+ (oldProps === current.memoizedProps &&
+ oldState === current.memoizedState) ||
+ (workInProgress.flags |= 1024),
+ (nextProps = !1));
}
- return !0;
+ return finishClassComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ hasContext,
+ renderLanes
+ );
}
-var appendAllChildren,
- updateHostContainer,
- updateHostComponent$1,
- updateHostText$1;
-appendAllChildren = function(
- parent,
- workInProgress,
- needsVisibilityToggle,
- isHidden
-) {
- for (var node = workInProgress.child; null !== node; ) {
- if (5 === node.tag) {
- var instance = node.stateNode;
- needsVisibilityToggle &&
- isHidden &&
- (instance = cloneHiddenInstance(instance));
- appendChildNode(parent.node, instance.node);
- } else if (6 === node.tag) {
- instance = node.stateNode;
- if (needsVisibilityToggle && isHidden)
- throw Error("Not yet implemented.");
- appendChildNode(parent.node, instance.node);
- } else if (4 !== node.tag) {
- if (
- 13 === node.tag &&
- 0 !== (node.flags & 4) &&
- (instance = null !== node.memoizedState)
- ) {
- var primaryChildParent = node.child;
- if (
- null !== primaryChildParent &&
- (null !== primaryChildParent.child &&
- ((primaryChildParent.child.return = primaryChildParent),
- appendAllChildren(parent, primaryChildParent, !0, instance)),
- (instance = primaryChildParent.sibling),
- null !== instance)
- ) {
- instance.return = node;
- node = instance;
- continue;
- }
- }
- if (null !== node.child) {
- node.child.return = node;
- node = node.child;
- continue;
- }
- }
- if (node === workInProgress) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === workInProgress) return;
- node = node.return;
- }
- node.sibling.return = node.return;
- node = node.sibling;
- }
-};
-function appendAllChildrenToContainer(
- containerChildSet,
+function finishClassComponent(
+ current,
workInProgress,
- needsVisibilityToggle,
- isHidden
+ Component,
+ shouldUpdate,
+ hasContext,
+ renderLanes
) {
- for (var node = workInProgress.child; null !== node; ) {
- if (5 === node.tag) {
- var instance = node.stateNode;
- needsVisibilityToggle &&
- isHidden &&
- (instance = cloneHiddenInstance(instance));
- appendChildNodeToSet(containerChildSet, instance.node);
- } else if (6 === node.tag) {
- instance = node.stateNode;
- if (needsVisibilityToggle && isHidden)
- throw Error("Not yet implemented.");
- appendChildNodeToSet(containerChildSet, instance.node);
- } else if (4 !== node.tag) {
- if (
- 13 === node.tag &&
- 0 !== (node.flags & 4) &&
- (instance = null !== node.memoizedState)
- ) {
- var primaryChildParent = node.child;
- if (
- null !== primaryChildParent &&
- (null !== primaryChildParent.child &&
- ((primaryChildParent.child.return = primaryChildParent),
- appendAllChildrenToContainer(
- containerChildSet,
- primaryChildParent,
- !0,
- instance
- )),
- (instance = primaryChildParent.sibling),
- null !== instance)
- ) {
- instance.return = node;
- node = instance;
- continue;
- }
- }
- if (null !== node.child) {
- node.child.return = node;
- node = node.child;
- continue;
- }
- }
- if (node === workInProgress) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === workInProgress) return;
- node = node.return;
- }
- node.sibling.return = node.return;
- node = node.sibling;
- }
-}
-updateHostContainer = function(current, workInProgress) {
- var portalOrRoot = workInProgress.stateNode;
- if (!hadNoMutationsEffects(current, workInProgress)) {
- current = portalOrRoot.containerInfo;
- var newChildSet = createChildNodeSet(current);
- appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1);
- portalOrRoot.pendingChildren = newChildSet;
- workInProgress.flags |= 4;
- completeRoot(current, newChildSet);
- }
-};
-updateHostComponent$1 = function(current, workInProgress, type, newProps) {
- type = current.stateNode;
- var oldProps = current.memoizedProps;
+ markRef$1(current, workInProgress);
+ var didCaptureError = 0 !== (workInProgress.flags & 128);
+ if (!shouldUpdate && !didCaptureError)
+ return (
+ hasContext && invalidateContextProvider(workInProgress, Component, !1),
+ bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
+ );
+ shouldUpdate = workInProgress.stateNode;
+ ReactCurrentOwner$1.current = workInProgress;
if (
- (current = hadNoMutationsEffects(current, workInProgress)) &&
- oldProps === newProps
- )
- workInProgress.stateNode = type;
- else {
- var recyclableInstance = workInProgress.stateNode;
- requiredContext(contextStackCursor$1.current);
- var updatePayload = null;
- oldProps !== newProps &&
- ((oldProps = diffProperties(
+ didCaptureError &&
+ "function" !== typeof Component.getDerivedStateFromError
+ ) {
+ var nextChildren = null;
+ profilerStartTime = -1;
+ } else nextChildren = shouldUpdate.render();
+ workInProgress.flags |= 1;
+ null !== current && didCaptureError
+ ? ((didCaptureError = nextChildren),
+ (workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ current.child,
null,
- oldProps,
- newProps,
- recyclableInstance.canonical.viewConfig.validAttributes
- )),
- (recyclableInstance.canonical.currentProps = newProps),
- (updatePayload = oldProps));
- current && null === updatePayload
- ? (workInProgress.stateNode = type)
- : ((newProps = updatePayload),
- (oldProps = type.node),
- (type = {
- node: current
- ? null !== newProps
- ? cloneNodeWithNewProps(oldProps, newProps)
- : cloneNode(oldProps)
- : null !== newProps
- ? cloneNodeWithNewChildrenAndProps(oldProps, newProps)
- : cloneNodeWithNewChildren(oldProps),
- canonical: type.canonical
- }),
- (workInProgress.stateNode = type),
- current
- ? (workInProgress.flags |= 4)
- : appendAllChildren(type, workInProgress, !1, !1));
- }
-};
-updateHostText$1 = function(current, workInProgress, oldText, newText) {
- oldText !== newText
- ? ((current = requiredContext(rootInstanceStackCursor.current)),
- (oldText = requiredContext(contextStackCursor$1.current)),
- (workInProgress.stateNode = createTextInstance(
- newText,
- current,
- oldText,
- workInProgress
+ renderLanes
)),
- (workInProgress.flags |= 4))
- : (workInProgress.stateNode = current.stateNode);
-};
-function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
- switch (renderState.tailMode) {
- case "hidden":
- hasRenderedATailFallback = renderState.tail;
- for (var lastTailNode = null; null !== hasRenderedATailFallback; )
- null !== hasRenderedATailFallback.alternate &&
- (lastTailNode = hasRenderedATailFallback),
- (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
- null === lastTailNode
- ? (renderState.tail = null)
- : (lastTailNode.sibling = null);
- break;
- case "collapsed":
- lastTailNode = renderState.tail;
- for (var lastTailNode$72 = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (lastTailNode$72 = lastTailNode),
- (lastTailNode = lastTailNode.sibling);
- null === lastTailNode$72
- ? hasRenderedATailFallback || null === renderState.tail
- ? (renderState.tail = null)
- : (renderState.tail.sibling = null)
- : (lastTailNode$72.sibling = null);
- }
-}
-function bubbleProperties(completedWork) {
- var didBailout =
- null !== completedWork.alternate &&
- completedWork.alternate.child === completedWork.child,
- newChildLanes = 0,
- subtreeFlags = 0;
- if (didBailout)
- if (0 !== (completedWork.mode & 2)) {
- for (
- var treeBaseDuration$74 = completedWork.selfBaseDuration,
- child$75 = completedWork.child;
- null !== child$75;
-
- )
- (newChildLanes |= child$75.lanes | child$75.childLanes),
- (subtreeFlags |= child$75.subtreeFlags & 1835008),
- (subtreeFlags |= child$75.flags & 1835008),
- (treeBaseDuration$74 += child$75.treeBaseDuration),
- (child$75 = child$75.sibling);
- completedWork.treeBaseDuration = treeBaseDuration$74;
- } else
- for (
- treeBaseDuration$74 = completedWork.child;
- null !== treeBaseDuration$74;
-
- )
- (newChildLanes |=
- treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes),
- (subtreeFlags |= treeBaseDuration$74.subtreeFlags & 1835008),
- (subtreeFlags |= treeBaseDuration$74.flags & 1835008),
- (treeBaseDuration$74.return = completedWork),
- (treeBaseDuration$74 = treeBaseDuration$74.sibling);
- else if (0 !== (completedWork.mode & 2)) {
- treeBaseDuration$74 = completedWork.actualDuration;
- child$75 = completedWork.selfBaseDuration;
- for (var child = completedWork.child; null !== child; )
- (newChildLanes |= child.lanes | child.childLanes),
- (subtreeFlags |= child.subtreeFlags),
- (subtreeFlags |= child.flags),
- (treeBaseDuration$74 += child.actualDuration),
- (child$75 += child.treeBaseDuration),
- (child = child.sibling);
- completedWork.actualDuration = treeBaseDuration$74;
- completedWork.treeBaseDuration = child$75;
- } else
- for (
- treeBaseDuration$74 = completedWork.child;
- null !== treeBaseDuration$74;
-
- )
- (newChildLanes |=
- treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes),
- (subtreeFlags |= treeBaseDuration$74.subtreeFlags),
- (subtreeFlags |= treeBaseDuration$74.flags),
- (treeBaseDuration$74.return = completedWork),
- (treeBaseDuration$74 = treeBaseDuration$74.sibling);
- completedWork.subtreeFlags |= subtreeFlags;
- completedWork.childLanes = newChildLanes;
- return didBailout;
+ (workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ null,
+ didCaptureError,
+ renderLanes
+ )))
+ : reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ workInProgress.memoizedState = shouldUpdate.state;
+ hasContext && invalidateContextProvider(workInProgress, Component, !0);
+ return workInProgress.child;
}
-function completeWork(current, workInProgress, renderLanes) {
- var newProps = workInProgress.pendingProps;
- switch (workInProgress.tag) {
- case 2:
- case 16:
- case 15:
- case 0:
- case 11:
- case 7:
- case 8:
- case 12:
- case 9:
- case 14:
- return bubbleProperties(workInProgress), null;
- case 1:
+function pushHostRootContext(workInProgress) {
+ var root = workInProgress.stateNode;
+ root.pendingContext
+ ? pushTopLevelContextObject(
+ workInProgress,
+ root.pendingContext,
+ root.pendingContext !== root.context
+ )
+ : root.context &&
+ pushTopLevelContextObject(workInProgress, root.context, !1);
+ pushHostContainer(workInProgress, root.containerInfo);
+}
+var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 };
+function mountSuspenseOffscreenState(renderLanes) {
+ return { baseLanes: renderLanes, cachePool: null };
+}
+function updateSuspenseComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
+ suspenseContext = suspenseStackCursor.current,
+ showFallback = !1,
+ JSCompiler_temp;
+ (JSCompiler_temp = 0 !== (workInProgress.flags & 128)) ||
+ (JSCompiler_temp =
+ null !== current && null === current.memoizedState
+ ? !1
+ : 0 !== (suspenseContext & 2));
+ if (JSCompiler_temp) (showFallback = !0), (workInProgress.flags &= -129);
+ else if (null === current || null !== current.memoizedState)
+ suspenseContext |= 1;
+ push(suspenseStackCursor, suspenseContext & 1);
+ if (null === current) {
+ suspenseContext = nextProps.children;
+ current = nextProps.fallback;
+ if (showFallback)
return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
+ (showFallback = workInProgress.mode),
+ (nextProps = workInProgress.child),
+ (suspenseContext = { mode: "hidden", children: suspenseContext }),
+ 0 === (showFallback & 1) && null !== nextProps
+ ? ((nextProps.childLanes = 0),
+ (nextProps.pendingProps = suspenseContext),
+ workInProgress.mode & 2 &&
+ ((nextProps.actualDuration = 0),
+ (nextProps.actualStartTime = -1),
+ (nextProps.selfBaseDuration = 0),
+ (nextProps.treeBaseDuration = 0)))
+ : (nextProps = createFiberFromOffscreen(
+ suspenseContext,
+ showFallback,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
+ current,
+ showFallback,
+ renderLanes,
+ null
+ )),
+ (nextProps.return = workInProgress),
+ (current.return = workInProgress),
+ (nextProps.sibling = current),
+ (workInProgress.child = nextProps),
+ (workInProgress.child.memoizedState = mountSuspenseOffscreenState(
+ renderLanes
+ )),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ current
);
- case 3:
+ renderLanes = createFiberFromOffscreen(
+ { mode: "visible", children: suspenseContext },
+ workInProgress.mode,
+ 0,
+ null
+ );
+ renderLanes.return = workInProgress;
+ return (workInProgress.child = renderLanes);
+ }
+ if (null !== current.memoizedState) {
+ if (showFallback)
return (
- (newProps = workInProgress.stateNode),
- popHostContainer(),
- pop(didPerformWorkStackCursor),
- pop(contextStackCursor),
- resetWorkInProgressVersions(),
- newProps.pendingContext &&
- ((newProps.context = newProps.pendingContext),
- (newProps.pendingContext = null)),
- (null !== current && null !== current.child) ||
- newProps.hydrate ||
- (workInProgress.flags |= 512),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
- case 5:
- popHostContext(workInProgress);
- renderLanes = requiredContext(rootInstanceStackCursor.current);
- var type = workInProgress.type;
- if (null !== current && null != workInProgress.stateNode)
- updateHostComponent$1(
+ (showFallback = updateSuspenseFallbackChildren(
current,
workInProgress,
- type,
- newProps,
+ nextProps.children,
+ nextProps.fallback,
renderLanes
- ),
- current.ref !== workInProgress.ref && (workInProgress.flags |= 256);
- else {
- if (!newProps) {
- if (null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- bubbleProperties(workInProgress);
- return null;
- }
- requiredContext(contextStackCursor$1.current);
- current = nextReactTag;
- nextReactTag += 2;
- type = getViewConfigForType(type);
- var updatePayload = diffProperties(
- null,
- emptyObject,
- newProps,
- type.validAttributes
- );
- renderLanes = createNode(
- current,
- type.uiViewClassName,
- renderLanes,
- updatePayload,
- workInProgress
- );
- current = new ReactFabricHostComponent(
- current,
- type,
- newProps,
- workInProgress
- );
- current = { node: renderLanes, canonical: current };
- appendAllChildren(current, workInProgress, !1, !1);
- workInProgress.stateNode = current;
- null !== workInProgress.ref && (workInProgress.flags |= 256);
+ )),
+ (nextProps = workInProgress.child),
+ (suspenseContext = current.child.memoizedState),
+ (nextProps.memoizedState =
+ null === suspenseContext
+ ? mountSuspenseOffscreenState(renderLanes)
+ : {
+ baseLanes: suspenseContext.baseLanes | renderLanes,
+ cachePool: null
+ }),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ showFallback
+ );
+ renderLanes = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ renderLanes
+ );
+ workInProgress.memoizedState = null;
+ return renderLanes;
+ }
+ if (showFallback)
+ return (
+ (showFallback = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ nextProps.fallback,
+ renderLanes
+ )),
+ (nextProps = workInProgress.child),
+ (suspenseContext = current.child.memoizedState),
+ (nextProps.memoizedState =
+ null === suspenseContext
+ ? mountSuspenseOffscreenState(renderLanes)
+ : {
+ baseLanes: suspenseContext.baseLanes | renderLanes,
+ cachePool: null
+ }),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
+ (workInProgress.memoizedState = SUSPENDED_MARKER),
+ showFallback
+ );
+ renderLanes = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ nextProps.children,
+ renderLanes
+ );
+ workInProgress.memoizedState = null;
+ return renderLanes;
+}
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ current = currentPrimaryChildFragment.sibling;
+ primaryChildren = createWorkInProgress(currentPrimaryChildFragment, {
+ mode: "visible",
+ children: primaryChildren
+ });
+ 0 === (workInProgress.mode & 1) && (primaryChildren.lanes = renderLanes);
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = null;
+ null !== current &&
+ ((renderLanes = workInProgress.deletions),
+ null === renderLanes
+ ? ((workInProgress.deletions = [current]), (workInProgress.flags |= 16))
+ : renderLanes.push(current));
+ return (workInProgress.child = primaryChildren);
+}
+function updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ fallbackChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ current = current.child;
+ var currentFallbackChildFragment = current.sibling,
+ primaryChildProps = { mode: "hidden", children: primaryChildren };
+ 0 === (mode & 1) && workInProgress.child !== current
+ ? ((primaryChildren = workInProgress.child),
+ (primaryChildren.childLanes = 0),
+ (primaryChildren.pendingProps = primaryChildProps),
+ workInProgress.mode & 2 &&
+ ((primaryChildren.actualDuration = 0),
+ (primaryChildren.actualStartTime = -1),
+ (primaryChildren.selfBaseDuration = current.selfBaseDuration),
+ (primaryChildren.treeBaseDuration = current.treeBaseDuration)),
+ (workInProgress.deletions = null))
+ : ((primaryChildren = createWorkInProgress(current, primaryChildProps)),
+ (primaryChildren.subtreeFlags = current.subtreeFlags & 14680064));
+ null !== currentFallbackChildFragment
+ ? (fallbackChildren = createWorkInProgress(
+ currentFallbackChildFragment,
+ fallbackChildren
+ ))
+ : ((fallbackChildren = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ )),
+ (fallbackChildren.flags |= 2));
+ fallbackChildren.return = workInProgress;
+ primaryChildren.return = workInProgress;
+ primaryChildren.sibling = fallbackChildren;
+ workInProgress.child = primaryChildren;
+ return fallbackChildren;
+}
+function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) {
+ fiber.lanes |= renderLanes;
+ var alternate = fiber.alternate;
+ null !== alternate && (alternate.lanes |= renderLanes);
+ scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot);
+}
+function initSuspenseListRenderState(
+ workInProgress,
+ isBackwards,
+ tail,
+ lastContentRow,
+ tailMode
+) {
+ var renderState = workInProgress.memoizedState;
+ null === renderState
+ ? (workInProgress.memoizedState = {
+ isBackwards: isBackwards,
+ rendering: null,
+ renderingStartTime: 0,
+ last: lastContentRow,
+ tail: tail,
+ tailMode: tailMode
+ })
+ : ((renderState.isBackwards = isBackwards),
+ (renderState.rendering = null),
+ (renderState.renderingStartTime = 0),
+ (renderState.last = lastContentRow),
+ (renderState.tail = tail),
+ (renderState.tailMode = tailMode));
+}
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps,
+ revealOrder = nextProps.revealOrder,
+ tailMode = nextProps.tail;
+ reconcileChildren(current, workInProgress, nextProps.children, renderLanes);
+ nextProps = suspenseStackCursor.current;
+ if (0 !== (nextProps & 2))
+ (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128);
+ else {
+ if (null !== current && 0 !== (current.flags & 128))
+ a: for (current = workInProgress.child; null !== current; ) {
+ if (13 === current.tag)
+ null !== current.memoizedState &&
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
+ else if (19 === current.tag)
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
+ else if (null !== current.child) {
+ current.child.return = current;
+ current = current.child;
+ continue;
+ }
+ if (current === workInProgress) break a;
+ for (; null === current.sibling; ) {
+ if (null === current.return || current.return === workInProgress)
+ break a;
+ current = current.return;
+ }
+ current.sibling.return = current.return;
+ current = current.sibling;
}
- bubbleProperties(workInProgress);
- return null;
- case 6:
- if (current && null != workInProgress.stateNode)
- updateHostText$1(
- current,
+ nextProps &= 1;
+ }
+ push(suspenseStackCursor, nextProps);
+ if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null;
+ else
+ switch (revealOrder) {
+ case "forwards":
+ renderLanes = workInProgress.child;
+ for (revealOrder = null; null !== renderLanes; )
+ (current = renderLanes.alternate),
+ null !== current &&
+ null === findFirstSuspended(current) &&
+ (revealOrder = renderLanes),
+ (renderLanes = renderLanes.sibling);
+ renderLanes = revealOrder;
+ null === renderLanes
+ ? ((revealOrder = workInProgress.child),
+ (workInProgress.child = null))
+ : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null));
+ initSuspenseListRenderState(
workInProgress,
- current.memoizedProps,
- newProps
- );
- else {
- if ("string" !== typeof newProps && null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- current = requiredContext(rootInstanceStackCursor.current);
- renderLanes = requiredContext(contextStackCursor$1.current);
- workInProgress.stateNode = createTextInstance(
- newProps,
- current,
+ !1,
+ revealOrder,
renderLanes,
- workInProgress
- );
- }
- bubbleProperties(workInProgress);
- return null;
- case 13:
- pop(suspenseStackCursor);
- newProps = workInProgress.memoizedState;
- if (0 !== (workInProgress.flags & 128))
- return (
- (workInProgress.lanes = renderLanes),
- 0 !== (workInProgress.mode & 2) &&
- transferActualDuration(workInProgress),
- workInProgress
+ tailMode
);
- newProps = null !== newProps;
- renderLanes = !1;
- null !== current && (renderLanes = null !== current.memoizedState);
- if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1))
- if (
- (null === current &&
- !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
- 0 !== (suspenseStackCursor.current & 1)
- )
- 0 === workInProgressRootExitStatus &&
- (workInProgressRootExitStatus = 3);
- else {
- if (
- 0 === workInProgressRootExitStatus ||
- 3 === workInProgressRootExitStatus
- )
- workInProgressRootExitStatus = 4;
- null === workInProgressRoot ||
- (0 === (workInProgressRootSkippedLanes & 268435455) &&
- 0 === (workInProgressRootUpdatedLanes & 268435455)) ||
- markRootSuspended$1(
- workInProgressRoot,
- workInProgressRootRenderLanes
- );
- }
- newProps && (workInProgress.flags |= 4);
- bubbleProperties(workInProgress);
- 0 !== (workInProgress.mode & 2) &&
- newProps &&
- ((current = workInProgress.child),
- null !== current &&
- (workInProgress.treeBaseDuration -= current.treeBaseDuration));
- return null;
- case 4:
- return (
- popHostContainer(),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
- case 10:
- return (
- popProvider(workInProgress.type._context),
- bubbleProperties(workInProgress),
- null
- );
- case 17:
- return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
- );
- case 19:
- pop(suspenseStackCursor);
- type = workInProgress.memoizedState;
- if (null === type) return bubbleProperties(workInProgress), null;
- newProps = 0 !== (workInProgress.flags & 128);
- updatePayload = type.rendering;
- if (null === updatePayload)
- if (newProps) cutOffTailIfNeeded(type, !1);
- else {
- if (
- 0 !== workInProgressRootExitStatus ||
- (null !== current && 0 !== (current.flags & 128))
- )
- for (current = workInProgress.child; null !== current; ) {
- updatePayload = findFirstSuspended(current);
- if (null !== updatePayload) {
- workInProgress.flags |= 128;
- cutOffTailIfNeeded(type, !1);
- current = updatePayload.updateQueue;
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4));
- workInProgress.subtreeFlags = 0;
- current = renderLanes;
- for (newProps = workInProgress.child; null !== newProps; )
- (renderLanes = newProps),
- (updatePayload = current),
- (renderLanes.flags &= 1835010),
- (type = renderLanes.alternate),
- null === type
- ? ((renderLanes.childLanes = 0),
- (renderLanes.lanes = updatePayload),
- (renderLanes.child = null),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.memoizedProps = null),
- (renderLanes.memoizedState = null),
- (renderLanes.updateQueue = null),
- (renderLanes.dependencies = null),
- (renderLanes.stateNode = null),
- (renderLanes.selfBaseDuration = 0),
- (renderLanes.treeBaseDuration = 0))
- : ((renderLanes.childLanes = type.childLanes),
- (renderLanes.lanes = type.lanes),
- (renderLanes.child = type.child),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.deletions = null),
- (renderLanes.memoizedProps = type.memoizedProps),
- (renderLanes.memoizedState = type.memoizedState),
- (renderLanes.updateQueue = type.updateQueue),
- (renderLanes.type = type.type),
- (updatePayload = type.dependencies),
- (renderLanes.dependencies =
- null === updatePayload
- ? null
- : {
- lanes: updatePayload.lanes,
- firstContext: updatePayload.firstContext
- }),
- (renderLanes.selfBaseDuration = type.selfBaseDuration),
- (renderLanes.treeBaseDuration = type.treeBaseDuration)),
- (newProps = newProps.sibling);
- push(
- suspenseStackCursor,
- (suspenseStackCursor.current & 1) | 2
- );
- return workInProgress.child;
- }
- current = current.sibling;
- }
- null !== type.tail &&
- now() > workInProgressRootRenderTargetTime &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
+ break;
+ case "backwards":
+ renderLanes = null;
+ revealOrder = workInProgress.child;
+ for (workInProgress.child = null; null !== revealOrder; ) {
+ current = revealOrder.alternate;
+ if (null !== current && null === findFirstSuspended(current)) {
+ workInProgress.child = revealOrder;
+ break;
+ }
+ current = revealOrder.sibling;
+ revealOrder.sibling = renderLanes;
+ renderLanes = revealOrder;
+ revealOrder = current;
}
- else {
- if (!newProps)
- if (
- ((current = findFirstSuspended(updatePayload)), null !== current)
- ) {
- if (
- ((workInProgress.flags |= 128),
- (newProps = !0),
- (current = current.updateQueue),
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4)),
- cutOffTailIfNeeded(type, !0),
- null === type.tail &&
- "hidden" === type.tailMode &&
- !updatePayload.alternate)
- )
- return bubbleProperties(workInProgress), null;
- } else
- 2 * now() - type.renderingStartTime >
- workInProgressRootRenderTargetTime &&
- 1073741824 !== renderLanes &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
- type.isBackwards
- ? ((updatePayload.sibling = workInProgress.child),
- (workInProgress.child = updatePayload))
- : ((current = type.last),
- null !== current
- ? (current.sibling = updatePayload)
- : (workInProgress.child = updatePayload),
- (type.last = updatePayload));
- }
- if (null !== type.tail)
- return (
- (workInProgress = type.tail),
- (type.rendering = workInProgress),
- (type.tail = workInProgress.sibling),
- (type.renderingStartTime = now()),
- (workInProgress.sibling = null),
- (current = suspenseStackCursor.current),
- push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
- workInProgress
+ initSuspenseListRenderState(
+ workInProgress,
+ !0,
+ renderLanes,
+ null,
+ tailMode
+ );
+ break;
+ case "together":
+ initSuspenseListRenderState(workInProgress, !1, null, null, void 0);
+ break;
+ default:
+ workInProgress.memoizedState = null;
+ }
+ return workInProgress.child;
+}
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
+ null !== current && (workInProgress.dependencies = current.dependencies);
+ profilerStartTime = -1;
+ workInProgressRootSkippedLanes |= workInProgress.lanes;
+ if (0 === (renderLanes & workInProgress.childLanes)) return null;
+ 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;
+}
+function attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+) {
+ 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:
+ var context = workInProgress.type._context,
+ nextValue = workInProgress.memoizedProps.value;
+ push(valueCursor, context._currentValue2);
+ context._currentValue2 = nextValue;
+ break;
+ case 12:
+ 0 !== (renderLanes & workInProgress.childLanes) &&
+ (workInProgress.flags |= 4);
+ context = workInProgress.stateNode;
+ context.effectDuration = 0;
+ context.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);
+ current = bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
);
- bubbleProperties(workInProgress);
- return null;
+ return null !== current ? current.sibling : null;
+ }
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
+ case 19:
+ context = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.flags & 128)) {
+ if (context)
+ return updateSuspenseListComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ workInProgress.flags |= 128;
+ }
+ nextValue = workInProgress.memoizedState;
+ null !== nextValue &&
+ ((nextValue.rendering = null),
+ (nextValue.tail = null),
+ (nextValue.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (context) break;
+ else return null;
case 22:
case 23:
return (
- popRenderLanes(),
- (renderLanes = null !== workInProgress.memoizedState),
- null !== current &&
- (null !== current.memoizedState) !== renderLanes &&
- "unstable-defer-without-hiding" !== newProps.mode &&
- (workInProgress.flags |= 4),
- (renderLanes &&
- 0 === (subtreeRenderLanes & 1073741824) &&
- 0 !== (workInProgress.mode & 1)) ||
- bubbleProperties(workInProgress),
- null
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
);
}
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
-function unwindWork(workInProgress) {
+function unwindWork(current, workInProgress) {
+ popTreeContext(workInProgress);
switch (workInProgress.tag) {
case 1:
- isContextProvider(workInProgress.type) && popContext();
- var flags = workInProgress.flags;
- return flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128),
- 0 !== (workInProgress.mode & 2) &&
- transferActualDuration(workInProgress),
- workInProgress)
- : null;
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128),
+ 0 !== (workInProgress.mode & 2) &&
+ transferActualDuration(workInProgress),
+ workInProgress)
+ : null
+ );
case 3:
- popHostContainer();
- pop(didPerformWorkStackCursor);
- pop(contextStackCursor);
- resetWorkInProgressVersions();
- flags = workInProgress.flags;
- if (0 !== (flags & 128))
- throw Error(
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
- );
- workInProgress.flags = (flags & -16385) | 128;
- return workInProgress;
+ return (
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ (current = workInProgress.flags),
+ 0 !== (current & 65536) && 0 === (current & 128)
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
+ : null
+ );
case 5:
return popHostContext(workInProgress), null;
case 13:
return (
pop(suspenseStackCursor),
- (flags = workInProgress.flags),
- flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128),
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128),
0 !== (workInProgress.mode & 2) &&
transferActualDuration(workInProgress),
workInProgress)
@@ -5704,7 +5875,7 @@ function commitBeforeMutationEffects(root, firstChild) {
if (
((root = nextEffect),
(firstChild = root.child),
- 0 !== (root.subtreeFlags & 516) && null !== firstChild)
+ 0 !== (root.subtreeFlags & 1028) && null !== firstChild)
)
(firstChild.return = root), (nextEffect = firstChild);
else
@@ -5712,7 +5883,7 @@ function commitBeforeMutationEffects(root, firstChild) {
root = nextEffect;
try {
var current = root.alternate;
- if (0 !== (root.flags & 512))
+ if (0 !== (root.flags & 1024))
switch (root.tag) {
case 0:
case 11:
@@ -5779,15 +5950,15 @@ function commitHookEffectListUnmount(
} while (effect !== updateQueue);
}
}
-function commitHookEffectListMount(tag, finishedWork) {
+function commitHookEffectListMount(flags, 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$88 = effect.create;
- effect.destroy = create$88();
+ if ((effect.tag & flags) === flags) {
+ var create$83 = effect.create;
+ effect.destroy = create$83();
}
effect = effect.next;
} while (effect !== finishedWork);
@@ -5815,20 +5986,20 @@ function commitWork(current, finishedWork) {
case 11:
case 14:
case 15:
+ commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ commitHookEffectListMount(3, finishedWork);
if (finishedWork.mode & 2)
try {
startLayoutEffectTimer(),
- commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ commitHookEffectListUnmount(5, finishedWork, finishedWork.return);
} finally {
recordLayoutEffectDuration(finishedWork);
}
- else commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ else commitHookEffectListUnmount(5, finishedWork, finishedWork.return);
return;
case 12:
return;
case 13:
- null !== finishedWork.memoizedState &&
- (globalMostRecentFallbackTime = now());
attachSuspenseRetryListeners(finishedWork);
return;
case 19:
@@ -5915,12 +6086,14 @@ function commitMutationEffects(root, firstChild, committedLanes) {
destroy = _effect.destroy,
tag = _effect.tag;
void 0 !== destroy &&
- 0 !== (tag & 2) &&
- (current.mode & 2
- ? (startLayoutEffectTimer(),
- safelyCallDestroy(current, root, destroy),
- recordLayoutEffectDuration(current))
- : safelyCallDestroy(current, root, destroy));
+ (0 !== (tag & 2)
+ ? safelyCallDestroy(current, root, destroy)
+ : 0 !== (tag & 4) &&
+ (current.mode & 2
+ ? (startLayoutEffectTimer(),
+ safelyCallDestroy(current, root, destroy),
+ recordLayoutEffectDuration(current))
+ : safelyCallDestroy(current, root, destroy)));
effect = effect.next;
} while (effect !== firstEffect);
}
@@ -5945,8 +6118,8 @@ function commitMutationEffects(root, firstChild, committedLanes) {
recordLayoutEffectDuration(effect);
}
else _effect.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(current, root, unmountError);
+ } catch (error) {
+ captureCommitPhaseError(current, root, error);
}
break;
case 5:
@@ -5976,14 +6149,14 @@ function commitMutationEffects(root, firstChild, committedLanes) {
}
}
firstChild = root.child;
- if (0 !== (root.subtreeFlags & 6454) && null !== firstChild)
+ if (0 !== (root.subtreeFlags & 12854) && null !== firstChild)
(firstChild.return = root), (nextEffect = firstChild);
else
for (; null !== nextEffect; ) {
root = nextEffect;
try {
var flags = root.flags;
- if (flags & 256) {
+ if (flags & 512) {
var current$jscomp$0 = root.alternate;
if (null !== current$jscomp$0) {
firstChild = current$jscomp$0;
@@ -6000,7 +6173,16 @@ function commitMutationEffects(root, firstChild, committedLanes) {
else currentRef.current = null;
}
}
- switch (flags & 2054) {
+ if (flags & 8192)
+ switch (root.tag) {
+ case 13:
+ if (null !== root.memoizedState) {
+ var current$89 = root.alternate;
+ if (null === current$89 || null === current$89.memoizedState)
+ globalMostRecentFallbackTime = now();
+ }
+ }
+ switch (flags & 4102) {
case 2:
root.flags &= -3;
break;
@@ -6008,11 +6190,11 @@ function commitMutationEffects(root, firstChild, committedLanes) {
root.flags &= -3;
commitWork(root.alternate, root);
break;
- case 2048:
- root.flags &= -2049;
+ case 4096:
+ root.flags &= -4097;
break;
- case 2052:
- root.flags &= -2049;
+ case 4100:
+ root.flags &= -4097;
commitWork(root.alternate, root);
break;
case 4:
@@ -6039,16 +6221,16 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
if (
((root = nextEffect),
(committedLanes = root.child),
- 0 !== (root.subtreeFlags & 324) && null !== committedLanes)
+ 0 !== (root.subtreeFlags & 8772) && null !== committedLanes)
)
(committedLanes.return = root), (nextEffect = committedLanes);
else
for (root = finishedWork; null !== nextEffect; ) {
committedLanes = nextEffect;
- if (0 !== (committedLanes.flags & 324)) {
+ if (0 !== (committedLanes.flags & 8772)) {
var current = committedLanes.alternate;
try {
- if (0 !== (committedLanes.flags & 68))
+ if (0 !== (committedLanes.flags & 8772))
switch (committedLanes.tag) {
case 0:
case 11:
@@ -6056,11 +6238,11 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
if (committedLanes.mode & 2)
try {
startLayoutEffectTimer(),
- commitHookEffectListMount(3, committedLanes);
+ commitHookEffectListMount(5, committedLanes);
} finally {
recordLayoutEffectDuration(committedLanes);
}
- else commitHookEffectListMount(3, committedLanes);
+ else commitHookEffectListMount(5, committedLanes);
break;
case 1:
var instance = committedLanes.stateNode;
@@ -6106,27 +6288,30 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
commitUpdateQueue(committedLanes, updateQueue, instance);
break;
case 3:
- var updateQueue$90 = committedLanes.updateQueue;
- if (null !== updateQueue$90) {
- var instance$91 = null;
+ var updateQueue$85 = committedLanes.updateQueue;
+ if (null !== updateQueue$85) {
+ var instance$86 = null;
if (null !== committedLanes.child)
switch (committedLanes.child.tag) {
case 5:
- instance$91 =
+ instance$86 =
committedLanes.child.stateNode.canonical;
break;
case 1:
- instance$91 = committedLanes.child.stateNode;
+ instance$86 = committedLanes.child.stateNode;
}
commitUpdateQueue(
committedLanes,
- updateQueue$90,
- instance$91
+ updateQueue$85,
+ instance$86
);
}
break;
case 5:
- null === current && committedLanes.flags & 4 && shim();
+ if (null === current && committedLanes.flags & 4)
+ throw Error(
+ "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue."
+ );
break;
case 6:
break;
@@ -6137,7 +6322,7 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
onCommit = _finishedWork$memoize2.onCommit,
onRender = _finishedWork$memoize2.onRender,
effectDuration = committedLanes.stateNode.effectDuration;
- instance$91 = commitTime;
+ instance$86 = commitTime;
current = null === current ? "mount" : "update";
currentUpdateIsNested && (current = "nested-update");
"function" === typeof onRender &&
@@ -6147,14 +6332,14 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
committedLanes.actualDuration,
committedLanes.treeBaseDuration,
committedLanes.actualStartTime,
- instance$91
+ instance$86
);
"function" === typeof onCommit &&
onCommit(
committedLanes.memoizedProps.id,
current,
effectDuration,
- instance$91
+ instance$86
);
enqueuePendingPassiveProfilerEffect(committedLanes);
var parentFiber = committedLanes.return;
@@ -6183,28 +6368,28 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
- if (committedLanes.flags & 256) {
- instance$91 = void 0;
+ if (committedLanes.flags & 512) {
+ instance$86 = void 0;
current = committedLanes;
var ref = current.ref;
if (null !== ref) {
var instance$jscomp$0 = current.stateNode;
switch (current.tag) {
case 5:
- instance$91 = instance$jscomp$0.canonical;
+ instance$86 = instance$jscomp$0.canonical;
break;
default:
- instance$91 = instance$jscomp$0;
+ instance$86 = instance$jscomp$0;
}
if ("function" === typeof ref)
if (current.mode & 2)
try {
- startLayoutEffectTimer(), ref(instance$91);
+ startLayoutEffectTimer(), ref(instance$86);
} finally {
recordLayoutEffectDuration(current);
}
- else ref(instance$91);
- else ref.current = instance$91;
+ else ref(instance$86);
+ else ref.current = instance$86;
}
}
} catch (error) {
@@ -6219,10 +6404,10 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
nextEffect = null;
break;
}
- instance$91 = committedLanes.sibling;
- if (null !== instance$91) {
- instance$91.return = committedLanes.return;
- nextEffect = instance$91;
+ instance$86 = committedLanes.sibling;
+ if (null !== instance$86) {
+ instance$86.return = committedLanes.return;
+ nextEffect = instance$86;
break;
}
nextEffect = committedLanes.return;
@@ -6242,8 +6427,10 @@ var ceil = Math.ceil,
workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
workInProgressRootSkippedLanes = 0,
- workInProgressRootUpdatedLanes = 0,
+ workInProgressRootInterleavedUpdatedLanes = 0,
workInProgressRootPingedLanes = 0,
+ workInProgressRootConcurrentErrors = null,
+ workInProgressRootRecoverableErrors = null,
globalMostRecentFallbackTime = 0,
workInProgressRootRenderTargetTime = Infinity,
hasUncaughtError = !1,
@@ -6258,7 +6445,7 @@ var ceil = Math.ceil,
currentEventTime = -1,
currentEventTransitionLane = 0;
function requestEventTime() {
- return 0 !== (executionContext & 24)
+ return 0 !== (executionContext & 6)
? now()
: -1 !== currentEventTime
? currentEventTime
@@ -6266,9 +6453,9 @@ function requestEventTime() {
}
function requestUpdateLane(fiber) {
if (0 === (fiber.mode & 1)) return 1;
- if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes)
+ if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes)
return workInProgressRootRenderLanes & -workInProgressRootRenderLanes;
- if (0 !== ReactCurrentBatchConfig.transition)
+ if (null !== ReactCurrentBatchConfig.transition)
return (
0 === currentEventTransitionLane &&
((fiber = nextTransitionLane),
@@ -6302,21 +6489,20 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) {
));
var root = markUpdateLaneFromFiberToRoot(fiber, lane);
if (null === root) return null;
- isDevToolsPresent && addFiberToLanesMap(root, fiber, lane);
markRootUpdated(root, lane, eventTime);
- root === workInProgressRoot &&
- (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane),
- 4 === workInProgressRootExitStatus &&
- markRootSuspended$1(root, workInProgressRootRenderLanes));
- 1 === lane
- ? 0 !== (executionContext & 4) && 0 === (executionContext & 24)
- ? performSyncWorkOnRoot(root)
- : (ensureRootIsScheduled(root, eventTime),
+ if (0 === (executionContext & 2) || root !== workInProgressRoot)
+ isDevToolsPresent && addFiberToLanesMap(root, fiber, lane),
+ root === workInProgressRoot &&
+ (0 === (executionContext & 2) &&
+ (workInProgressRootInterleavedUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(root, workInProgressRootRenderLanes)),
+ ensureRootIsScheduled(root, eventTime),
+ 1 === lane &&
0 === executionContext &&
- 0 === (fiber.mode & 1) &&
- ((workInProgressRootRenderTargetTime = now() + 500),
- includesLegacySyncCallbacks && flushSyncCallbacks()))
- : ensureRootIsScheduled(root, eventTime);
+ 0 === (fiber.mode & 1) &&
+ ((workInProgressRootRenderTargetTime = now() + 500),
+ includesLegacySyncCallbacks && flushSyncCallbacks());
return root;
}
function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
@@ -6394,7 +6580,7 @@ function ensureRootIsScheduled(root, currentTime) {
default:
existingCallbackNode = NormalPriority;
}
- existingCallbackNode = scheduleCallback(
+ existingCallbackNode = scheduleCallback$1(
existingCallbackNode,
performConcurrentWorkOnRoot.bind(null, root)
);
@@ -6407,7 +6593,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
nestedUpdateScheduled = currentUpdateIsNested = !1;
currentEventTime = -1;
currentEventTransitionLane = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var originalCallbackNode = root.callbackNode;
if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
@@ -6417,12 +6603,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
root === workInProgressRoot ? workInProgressRootRenderLanes : 0
);
if (0 === lanes) return null;
- var JSCompiler_inline_result =
- 0 !== (lanes & root.expiredLanes) ? !1 : 0 === (lanes & 30);
- if (JSCompiler_inline_result && !didTimeout) {
+ if (0 !== (lanes & 30) || 0 !== (lanes & root.expiredLanes) || didTimeout)
+ didTimeout = renderRootSync(root, lanes);
+ else {
didTimeout = lanes;
- JSCompiler_inline_result = executionContext;
- executionContext |= 8;
+ var prevExecutionContext = executionContext;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
if (
workInProgressRoot !== root ||
@@ -6448,99 +6634,117 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
while (1);
resetContextDependencies();
ReactCurrentDispatcher$2.current = prevDispatcher;
- executionContext = JSCompiler_inline_result;
+ executionContext = prevExecutionContext;
null !== workInProgress
? (didTimeout = 0)
: ((workInProgressRoot = null),
(workInProgressRootRenderLanes = 0),
(didTimeout = workInProgressRootExitStatus));
- } else didTimeout = renderRootSync(root, lanes);
+ }
if (0 !== didTimeout) {
2 === didTimeout &&
- ((executionContext |= 32),
- root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)),
- (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)),
- 0 !== JSCompiler_inline_result &&
- ((lanes = JSCompiler_inline_result),
- (didTimeout = renderRootSync(root, JSCompiler_inline_result))));
+ ((prevExecutionContext = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevExecutionContext &&
+ ((lanes = prevExecutionContext),
+ (didTimeout = recoverFromConcurrentError(root, prevExecutionContext))));
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 2:
- commitRoot(root);
- break;
- case 3:
- markRootSuspended$1(root, lanes);
- if (
- (lanes & 130023424) === lanes &&
- ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
- 10 < didTimeout)
- ) {
- if (0 !== getNextLanes(root, 0)) break;
- JSCompiler_inline_result = root.suspendedLanes;
- if ((JSCompiler_inline_result & lanes) !== lanes) {
- requestEventTime();
- root.pingedLanes |= root.suspendedLanes & JSCompiler_inline_result;
+ if (6 === didTimeout) markRootSuspended$1(root, lanes);
+ else {
+ prevExecutionContext = root.current.alternate;
+ if (
+ 0 === (lanes & 30) &&
+ !isRenderConsistentWithExternalStores(prevExecutionContext) &&
+ ((didTimeout = renderRootSync(root, lanes)),
+ 2 === didTimeout &&
+ ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevDispatcher &&
+ ((lanes = prevDispatcher),
+ (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))),
+ 1 === didTimeout)
+ )
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = prevExecutionContext;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
+ throw Error("Root did not complete. This is a bug in React.");
+ case 2:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ case 3:
+ markRootSuspended$1(root, lanes);
+ if (
+ (lanes & 130023424) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
+ ) {
+ 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, workInProgressRootRecoverableErrors),
+ didTimeout
+ );
break;
}
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- didTimeout
- );
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 4:
- markRootSuspended$1(root, lanes);
- if ((lanes & 4194240) === lanes) break;
- didTimeout = root.eventTimes;
- for (JSCompiler_inline_result = -1; 0 < lanes; )
- (memoizedUpdaters = 31 - clz32(lanes)),
- (prevDispatcher = 1 << memoizedUpdaters),
- (memoizedUpdaters = didTimeout[memoizedUpdaters]),
- memoizedUpdaters > JSCompiler_inline_result &&
- (JSCompiler_inline_result = memoizedUpdaters),
- (lanes &= ~prevDispatcher);
- lanes = JSCompiler_inline_result;
- lanes = now() - lanes;
- lanes =
- (120 > lanes
- ? 120
- : 480 > lanes
- ? 480
- : 1080 > lanes
- ? 1080
- : 1920 > lanes
- ? 1920
- : 3e3 > lanes
- ? 3e3
- : 4320 > lanes
- ? 4320
- : 1960 * ceil(lanes / 1960)) - lanes;
- if (10 < lanes) {
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- lanes
- );
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if ((lanes & 4194240) === lanes) break;
+ didTimeout = root.eventTimes;
+ for (prevExecutionContext = -1; 0 < lanes; )
+ (memoizedUpdaters = 31 - clz32(lanes)),
+ (prevDispatcher = 1 << memoizedUpdaters),
+ (memoizedUpdaters = didTimeout[memoizedUpdaters]),
+ memoizedUpdaters > prevExecutionContext &&
+ (prevExecutionContext = memoizedUpdaters),
+ (lanes &= ~prevDispatcher);
+ lanes = prevExecutionContext;
+ lanes = now() - lanes;
+ lanes =
+ (120 > lanes
+ ? 120
+ : 480 > lanes
+ ? 480
+ : 1080 > lanes
+ ? 1080
+ : 1920 > lanes
+ ? 1920
+ : 3e3 > lanes
+ ? 3e3
+ : 4320 > lanes
+ ? 4320
+ : 1960 * ceil(lanes / 1960)) - lanes;
+ if (10 < lanes) {
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
+ lanes
+ );
+ break;
+ }
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 5:
- commitRoot(root);
- break;
- default:
- throw Error("Unknown root exit status.");
+ case 5:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ default:
+ throw Error("Unknown root exit status.");
+ }
}
}
ensureRootIsScheduled(root, now());
@@ -6548,9 +6752,60 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function recoverFromConcurrentError(root, errorRetryLanes) {
+ var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
+ root.current.memoizedState.isDehydrated &&
+ (prepareFreshStack(root, errorRetryLanes).flags |= 256);
+ root = renderRootSync(root, errorRetryLanes);
+ 2 !== root &&
+ ((errorRetryLanes = workInProgressRootRecoverableErrors),
+ (workInProgressRootRecoverableErrors = errorsFromFirstAttempt),
+ null !== errorRetryLanes &&
+ (null === workInProgressRootRecoverableErrors
+ ? (workInProgressRootRecoverableErrors = errorRetryLanes)
+ : workInProgressRootRecoverableErrors.push.apply(
+ workInProgressRootRecoverableErrors,
+ errorRetryLanes
+ )));
+ return root;
+}
+function isRenderConsistentWithExternalStores(finishedWork) {
+ for (var node = finishedWork; ; ) {
+ if (node.flags & 16384) {
+ var updateQueue = node.updateQueue;
+ if (
+ null !== updateQueue &&
+ ((updateQueue = updateQueue.stores), null !== updateQueue)
+ )
+ for (var i = 0; i < updateQueue.length; i++) {
+ var check = updateQueue[i],
+ getSnapshot = check.getSnapshot;
+ check = check.value;
+ try {
+ if (!objectIs(getSnapshot(), check)) return !1;
+ } catch (error) {
+ return !1;
+ }
+ }
+ }
+ updateQueue = node.child;
+ if (node.subtreeFlags & 16384 && null !== updateQueue)
+ (updateQueue.return = node), (node = updateQueue);
+ else {
+ if (node === finishedWork) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === finishedWork) return !0;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+ }
+ return !0;
+}
function markRootSuspended$1(root, suspendedLanes) {
suspendedLanes &= ~workInProgressRootPingedLanes;
- suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes;
root.suspendedLanes |= suspendedLanes;
root.pingedLanes &= ~suspendedLanes;
for (root = root.expirationTimes; 0 < suspendedLanes; ) {
@@ -6563,18 +6818,17 @@ function markRootSuspended$1(root, suspendedLanes) {
function performSyncWorkOnRoot(root) {
currentUpdateIsNested = nestedUpdateScheduled;
nestedUpdateScheduled = !1;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
flushPassiveEffects();
var lanes = getNextLanes(root, 0);
if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null;
var exitStatus = renderRootSync(root, lanes);
if (0 !== root.tag && 2 === exitStatus) {
- executionContext |= 32;
- root.hydrate && ((root.hydrate = !1), shim(root.containerInfo));
var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
0 !== errorRetryLanes &&
- ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes)));
+ ((lanes = errorRetryLanes),
+ (exitStatus = recoverFromConcurrentError(root, errorRetryLanes)));
}
if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
@@ -6582,9 +6836,11 @@ function performSyncWorkOnRoot(root) {
markRootSuspended$1(root, lanes),
ensureRootIsScheduled(root, now()),
exitStatus);
+ if (6 === exitStatus)
+ throw Error("Root did not complete. This is a bug in React.");
root.finishedWork = root.current.alternate;
root.finishedLanes = lanes;
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
ensureRootIsScheduled(root, now());
return null;
}
@@ -6601,6 +6857,7 @@ function prepareFreshStack(root, lanes) {
if (null !== workInProgress)
for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) {
var interruptedWork = timeoutHandle;
+ popTreeContext(interruptedWork);
switch (interruptedWork.tag) {
case 1:
interruptedWork = interruptedWork.type.childContextTypes;
@@ -6636,30 +6893,32 @@ function prepareFreshStack(root, lanes) {
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
+ workInProgress = root = createWorkInProgress(root.current, null);
workInProgressRootRenderLanes = subtreeRenderLanes = lanes;
workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootPingedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors = null;
if (null !== interleavedQueues) {
- for (root = 0; root < interleavedQueues.length; root++)
+ for (lanes = 0; lanes < interleavedQueues.length; lanes++)
if (
- ((lanes = interleavedQueues[root]),
- (timeoutHandle = lanes.interleaved),
- null !== timeoutHandle)
+ ((timeoutHandle = interleavedQueues[lanes]),
+ (interruptedWork = timeoutHandle.interleaved),
+ null !== interruptedWork)
) {
- lanes.interleaved = null;
- interruptedWork = timeoutHandle.next;
- var lastPendingUpdate = lanes.pending;
+ timeoutHandle.interleaved = null;
+ var firstInterleavedUpdate = interruptedWork.next,
+ lastPendingUpdate = timeoutHandle.pending;
if (null !== lastPendingUpdate) {
var firstPendingUpdate = lastPendingUpdate.next;
- lastPendingUpdate.next = interruptedWork;
- timeoutHandle.next = firstPendingUpdate;
+ lastPendingUpdate.next = firstInterleavedUpdate;
+ interruptedWork.next = firstPendingUpdate;
}
- lanes.pending = timeoutHandle;
+ timeoutHandle.pending = interruptedWork;
}
interleavedQueues = null;
}
+ return root;
}
function handleError(root$jscomp$0, thrownValue) {
do {
@@ -6697,7 +6956,7 @@ function handleError(root$jscomp$0, thrownValue) {
sourceFiber = erroredWork,
value = thrownValue;
thrownValue = workInProgressRootRenderLanes;
- sourceFiber.flags |= 8192;
+ sourceFiber.flags |= 32768;
isDevToolsPresent && restorePendingUpdaters(root, thrownValue);
if (
null !== value &&
@@ -6705,54 +6964,52 @@ function handleError(root$jscomp$0, thrownValue) {
"function" === typeof value.then
) {
var wakeable = value,
- tag = sourceFiber.tag;
+ sourceFiber$jscomp$0 = sourceFiber,
+ tag = sourceFiber$jscomp$0.tag;
if (
- 0 === (sourceFiber.mode & 1) &&
+ 0 === (sourceFiber$jscomp$0.mode & 1) &&
(0 === tag || 11 === tag || 15 === tag)
) {
- var currentSource = sourceFiber.alternate;
+ var currentSource = sourceFiber$jscomp$0.alternate;
currentSource
- ? ((sourceFiber.updateQueue = currentSource.updateQueue),
- (sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.lanes = currentSource.lanes))
- : ((sourceFiber.updateQueue = null),
- (sourceFiber.memoizedState = null));
+ ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue),
+ (sourceFiber$jscomp$0.memoizedState =
+ currentSource.memoizedState),
+ (sourceFiber$jscomp$0.lanes = currentSource.lanes))
+ : ((sourceFiber$jscomp$0.updateQueue = null),
+ (sourceFiber$jscomp$0.memoizedState = null));
}
- var hasInvisibleParentBoundary =
- 0 !== (suspenseStackCursor.current & 1),
- workInProgress$32 = returnFiber;
- do {
- var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === workInProgress$32.tag)) {
- var nextState = workInProgress$32.memoizedState;
- if (null !== nextState)
- JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
- else {
- var props = workInProgress$32.memoizedProps;
+ b: {
+ sourceFiber$jscomp$0 = returnFiber;
+ do {
+ var JSCompiler_temp;
+ if ((JSCompiler_temp = 13 === sourceFiber$jscomp$0.tag)) {
+ var nextState = sourceFiber$jscomp$0.memoizedState;
JSCompiler_temp =
- void 0 === props.fallback
- ? !1
- : !0 !== props.unstable_avoidThisFallback
- ? !0
- : hasInvisibleParentBoundary
- ? !1
+ null !== nextState
+ ? null !== nextState.dehydrated
+ ? !0
+ : !1
: !0;
}
- }
- if (JSCompiler_temp) {
- var wakeables = workInProgress$32.updateQueue;
- if (null === wakeables) {
- var updateQueue = new Set();
- updateQueue.add(wakeable);
- workInProgress$32.updateQueue = updateQueue;
- } else wakeables.add(wakeable);
- if (
- 0 === (workInProgress$32.mode & 1) &&
- workInProgress$32 !== returnFiber
- ) {
- workInProgress$32.flags |= 128;
- sourceFiber.flags |= 32768;
- sourceFiber.flags &= -10053;
+ if (JSCompiler_temp) {
+ var suspenseBoundary = sourceFiber$jscomp$0;
+ break b;
+ }
+ sourceFiber$jscomp$0 = sourceFiber$jscomp$0.return;
+ } while (null !== sourceFiber$jscomp$0);
+ suspenseBoundary = null;
+ }
+ if (null !== suspenseBoundary) {
+ suspenseBoundary.flags &= -257;
+ value = suspenseBoundary;
+ sourceFiber$jscomp$0 = thrownValue;
+ if (0 === (value.mode & 1))
+ if (value === returnFiber) value.flags |= 65536;
+ else {
+ value.flags |= 128;
+ sourceFiber.flags |= 131072;
+ sourceFiber.flags &= -52805;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
@@ -6761,84 +7018,78 @@ function handleError(root$jscomp$0, thrownValue) {
enqueueUpdate(sourceFiber, update);
}
sourceFiber.lanes |= 1;
- break a;
}
- value = void 0;
- sourceFiber = thrownValue;
- var pingCache = root.pingCache;
- null === pingCache
- ? ((pingCache = root.pingCache = new PossiblyWeakMap()),
- (value = new Set()),
- pingCache.set(wakeable, value))
- : ((value = pingCache.get(wakeable)),
- void 0 === value &&
- ((value = new Set()), pingCache.set(wakeable, value)));
- if (!value.has(sourceFiber)) {
- value.add(sourceFiber);
- var ping = pingSuspendedRoot.bind(
- null,
- root,
- wakeable,
- sourceFiber
- );
- isDevToolsPresent && restorePendingUpdaters(root, sourceFiber);
- wakeable.then(ping, ping);
- }
- workInProgress$32.flags |= 16384;
- workInProgress$32.lanes = thrownValue;
+ else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0);
+ suspenseBoundary.mode & 1 &&
+ attachPingListener(root, wakeable, thrownValue);
+ thrownValue = suspenseBoundary;
+ root = wakeable;
+ var wakeables = thrownValue.updateQueue;
+ if (null === wakeables) {
+ var updateQueue = new Set();
+ updateQueue.add(root);
+ thrownValue.updateQueue = updateQueue;
+ } else wakeables.add(root);
+ break a;
+ } else {
+ if (0 === (thrownValue & 1)) {
+ attachPingListener(root, wakeable, thrownValue);
+ renderDidSuspendDelayIfPossible();
break a;
}
- workInProgress$32 = workInProgress$32.return;
- } while (null !== workInProgress$32);
- value = Error(
- (getComponentNameFromFiber(sourceFiber) || "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."
- );
+ value = Error(
+ "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition."
+ );
+ }
}
- 5 !== workInProgressRootExitStatus &&
+ root = value;
+ 4 !== workInProgressRootExitStatus &&
(workInProgressRootExitStatus = 2);
+ null === workInProgressRootConcurrentErrors
+ ? (workInProgressRootConcurrentErrors = [root])
+ : workInProgressRootConcurrentErrors.push(root);
value = createCapturedValue(value, sourceFiber);
- workInProgress$32 = returnFiber;
+ root = returnFiber;
do {
- switch (workInProgress$32.tag) {
+ switch (root.tag) {
case 3:
- root = value;
- workInProgress$32.flags |= 16384;
+ wakeable = value;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$32.lanes |= thrownValue;
- var update$33 = createRootErrorUpdate(
- workInProgress$32,
+ root.lanes |= thrownValue;
+ var update$jscomp$0 = createRootErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$32, update$33);
+ enqueueCapturedUpdate(root, update$jscomp$0);
break a;
case 1:
- root = value;
- var ctor = workInProgress$32.type,
- instance = workInProgress$32.stateNode;
+ wakeable = value;
+ var ctor = root.type,
+ instance = root.stateNode;
if (
- 0 === (workInProgress$32.flags & 128) &&
+ 0 === (root.flags & 128) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- workInProgress$32.flags |= 16384;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$32.lanes |= thrownValue;
- var update$36 = createClassErrorUpdate(
- workInProgress$32,
+ root.lanes |= thrownValue;
+ var update$33 = createClassErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$32, update$36);
+ enqueueCapturedUpdate(root, update$33);
break a;
}
}
- workInProgress$32 = workInProgress$32.return;
- } while (null !== workInProgress$32);
+ root = root.return;
+ } while (null !== root);
}
completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
@@ -6856,9 +7107,21 @@ function pushDispatcher() {
ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
+function renderDidSuspendDelayIfPossible() {
+ if (
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus ||
+ 2 === workInProgressRootExitStatus
+ )
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 268435455) &&
+ 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) ||
+ markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
+}
function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= 8;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
if (isDevToolsPresent) {
@@ -6915,7 +7178,7 @@ function completeUnitOfWork(unitOfWork) {
do {
var current = completedWork.alternate;
unitOfWork = completedWork.return;
- if (0 === (completedWork.flags & 8192)) {
+ if (0 === (completedWork.flags & 32768)) {
if (0 === (completedWork.mode & 2))
current = completeWork(current, completedWork, subtreeRenderLanes);
else {
@@ -6930,9 +7193,9 @@ function completeUnitOfWork(unitOfWork) {
return;
}
} else {
- current = unwindWork(completedWork);
+ current = unwindWork(current, completedWork);
if (null !== current) {
- current.flags &= 8191;
+ current.flags &= 32767;
workInProgress = current;
return;
}
@@ -6943,10 +7206,15 @@ function completeUnitOfWork(unitOfWork) {
(current += fiber.actualDuration), (fiber = fiber.sibling);
completedWork.actualDuration = current;
}
- null !== unitOfWork &&
- ((unitOfWork.flags |= 8192),
- (unitOfWork.subtreeFlags = 0),
- (unitOfWork.deletions = null));
+ if (null !== unitOfWork)
+ (unitOfWork.flags |= 32768),
+ (unitOfWork.subtreeFlags = 0),
+ (unitOfWork.deletions = null);
+ else {
+ workInProgressRootExitStatus = 6;
+ workInProgress = null;
+ return;
+ }
}
completedWork = completedWork.sibling;
if (null !== completedWork) {
@@ -6957,23 +7225,23 @@ function completeUnitOfWork(unitOfWork) {
} while (null !== completedWork);
0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
-function commitRoot(root) {
+function commitRoot(root, recoverableErrors) {
var previousUpdateLanePriority = currentUpdatePriority,
prevTransition = ReactCurrentBatchConfig$2.transition;
try {
- (ReactCurrentBatchConfig$2.transition = 0),
+ (ReactCurrentBatchConfig$2.transition = null),
(currentUpdatePriority = 1),
- commitRootImpl(root, previousUpdateLanePriority);
+ commitRootImpl(root, recoverableErrors, previousUpdateLanePriority);
} finally {
(ReactCurrentBatchConfig$2.transition = prevTransition),
(currentUpdatePriority = previousUpdateLanePriority);
}
return null;
}
-function commitRootImpl(root, renderPriorityLevel) {
+function commitRootImpl(root, recoverableErrors, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var finishedWork = root.finishedWork,
lanes = root.finishedLanes;
@@ -6991,22 +7259,22 @@ function commitRootImpl(root, renderPriorityLevel) {
root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
(workInProgressRootRenderLanes = 0));
- (0 === (finishedWork.subtreeFlags & 1040) &&
- 0 === (finishedWork.flags & 1040)) ||
+ (0 === (finishedWork.subtreeFlags & 2064) &&
+ 0 === (finishedWork.flags & 2064)) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
}));
- remainingLanes = 0 !== (finishedWork.flags & 8054);
- if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) {
+ remainingLanes = 0 !== (finishedWork.flags & 15990);
+ if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) {
remainingLanes = ReactCurrentBatchConfig$2.transition;
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
var previousPriority = currentUpdatePriority;
currentUpdatePriority = 1;
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
ReactCurrentOwner$2.current = null;
commitBeforeMutationEffects(root, finishedWork);
commitTime = now$1();
@@ -7024,24 +7292,31 @@ function commitRootImpl(root, renderPriorityLevel) {
(pendingPassiveEffectsLanes = lanes));
remainingLanes = root.pendingLanes;
0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
- 0 !== (remainingLanes & 1)
- ? ((nestedUpdateScheduled = !0),
- root === rootWithNestedUpdates
- ? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)))
- : (nestedUpdateCount = 0);
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
isDevToolsPresent && root.memoizedUpdaters.clear();
ensureRootIsScheduled(root, now());
+ if (null !== recoverableErrors)
+ for (
+ renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
+ finishedWork < recoverableErrors.length;
+ finishedWork++
+ )
+ renderPriorityLevel(recoverableErrors[finishedWork]);
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
(root = firstUncaughtError),
(firstUncaughtError = null),
root);
- if (0 !== (executionContext & 4)) return null;
0 !== (pendingPassiveEffectsLanes & 1) &&
0 !== root.tag &&
flushPassiveEffects();
+ remainingLanes = root.pendingLanes;
+ 0 !== (remainingLanes & 1)
+ ? ((nestedUpdateScheduled = !0),
+ root === rootWithNestedUpdates
+ ? nestedUpdateCount++
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)))
+ : (nestedUpdateCount = 0);
flushSyncCallbacks();
return null;
}
@@ -7051,7 +7326,7 @@ function flushPassiveEffects() {
prevTransition = ReactCurrentBatchConfig$2.transition,
previousPriority = currentUpdatePriority;
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority;
if (null === rootWithPendingPassiveEffects)
var JSCompiler_inline_result = !1;
@@ -7059,10 +7334,10 @@ function flushPassiveEffects() {
renderPriority = rootWithPendingPassiveEffects;
rootWithPendingPassiveEffects = null;
pendingPassiveEffectsLanes = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
for (nextEffect = renderPriority.current; null !== nextEffect; ) {
var fiber = nextEffect,
child = fiber.child;
@@ -7080,9 +7355,9 @@ function flushPassiveEffects() {
case 15:
current.mode & 2
? ((passiveEffectStartTime = now$1()),
- commitHookEffectListUnmount(4, current, fiber),
+ commitHookEffectListUnmount(8, current, fiber),
recordPassiveEffectDuration(current))
- : commitHookEffectListUnmount(4, current, fiber);
+ : commitHookEffectListUnmount(8, current, fiber);
}
var child$jscomp$0 = fiber$jscomp$0.child;
if (null !== child$jscomp$0)
@@ -7122,21 +7397,21 @@ function flushPassiveEffects() {
nextEffect = fiber;
}
}
- if (0 !== (fiber.subtreeFlags & 1040) && null !== child)
+ if (0 !== (fiber.subtreeFlags & 2064) && null !== child)
(child.return = fiber), (nextEffect = child);
else
b: for (; null !== nextEffect; ) {
fiber = nextEffect;
- if (0 !== (fiber.flags & 1024))
+ if (0 !== (fiber.flags & 2048))
switch (((i = fiber), i.tag)) {
case 0:
case 11:
case 15:
i.mode & 2
? ((passiveEffectStartTime = now$1()),
- commitHookEffectListUnmount(5, i, i.return),
+ commitHookEffectListUnmount(9, i, i.return),
recordPassiveEffectDuration(i))
- : commitHookEffectListUnmount(5, i, i.return);
+ : commitHookEffectListUnmount(9, i, i.return);
}
var sibling$jscomp$0 = fiber.sibling;
if (null !== sibling$jscomp$0) {
@@ -7151,12 +7426,12 @@ function flushPassiveEffects() {
for (nextEffect = finishedWork; null !== nextEffect; ) {
child = nextEffect;
var firstChild = child.child;
- if (0 !== (child.subtreeFlags & 1040) && null !== firstChild)
+ if (0 !== (child.subtreeFlags & 2064) && null !== firstChild)
(firstChild.return = child), (nextEffect = firstChild);
else
b: for (child = finishedWork; null !== nextEffect; ) {
deletions = nextEffect;
- if (0 !== (deletions.flags & 1024))
+ if (0 !== (deletions.flags & 2048))
try {
switch (((fiberToDelete = deletions), fiberToDelete.tag)) {
case 0:
@@ -7165,11 +7440,11 @@ function flushPassiveEffects() {
if (fiberToDelete.mode & 2) {
passiveEffectStartTime = now$1();
try {
- commitHookEffectListMount(5, fiberToDelete);
+ commitHookEffectListMount(9, fiberToDelete);
} finally {
recordPassiveEffectDuration(fiberToDelete);
}
- } else commitHookEffectListMount(5, fiberToDelete);
+ } else commitHookEffectListMount(9, fiberToDelete);
}
} catch (error) {
captureCommitPhaseError(deletions, deletions.return, error);
@@ -7250,7 +7525,7 @@ function enqueuePendingPassiveProfilerEffect(fiber) {
pendingPassiveProfilerEffects.push(fiber);
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
}));
@@ -7345,7 +7620,6 @@ function resolveRetryWakeable(boundaryFiber, wakeable) {
}
var beginWork$1;
beginWork$1 = function(current, workInProgress, renderLanes) {
- var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
@@ -7353,165 +7627,98 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
)
didReceiveUpdate = !0;
else {
- if (0 === (renderLanes & updateLanes)) {
- 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.type._context;
- var nextValue = workInProgress.memoizedProps.value;
- push(valueCursor, updateLanes._currentValue2);
- updateLanes._currentValue2 = nextValue;
- break;
- case 12:
- 0 !== (renderLanes & workInProgress.childLanes) &&
- (workInProgress.flags |= 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,
- renderLanes
- );
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
- if (0 !== (current.flags & 128)) {
- if (updateLanes)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderLanes
- );
- workInProgress.flags |= 128;
- }
- nextValue = workInProgress.memoizedState;
- null !== nextValue &&
- ((nextValue.rendering = null),
- (nextValue.tail = null),
- (nextValue.lastEffect = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (updateLanes) break;
- else return null;
- case 22:
- case 23:
- return (
- (workInProgress.lanes = 0),
- updateOffscreenComponent(current, workInProgress, renderLanes)
- );
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
+ if (
+ 0 === (current.lanes & renderLanes) &&
+ 0 === (workInProgress.flags & 128)
+ )
+ return (
+ (didReceiveUpdate = !1),
+ attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+ )
);
- }
- didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1;
+ didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1;
}
else didReceiveUpdate = !1;
workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateLanes = workInProgress.type;
+ var Component = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- nextValue = getMaskedContext(workInProgress, contextStackCursor.current);
+ var context = getMaskedContext(
+ workInProgress,
+ contextStackCursor.current
+ );
prepareToReadContext(workInProgress, renderLanes);
- nextValue = renderWithHooks(
+ context = renderWithHooks(
null,
workInProgress,
- updateLanes,
+ Component,
current,
- nextValue,
+ context,
renderLanes
);
workInProgress.flags |= 1;
if (
- "object" === typeof nextValue &&
- null !== nextValue &&
- "function" === typeof nextValue.render &&
- void 0 === nextValue.$$typeof
+ "object" === typeof context &&
+ null !== context &&
+ "function" === typeof context.render &&
+ void 0 === context.$$typeof
) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateLanes)) {
+ if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
workInProgress.memoizedState =
- null !== nextValue.state && void 0 !== nextValue.state
- ? nextValue.state
+ null !== context.state && void 0 !== context.state
+ ? context.state
: null;
initializeUpdateQueue(workInProgress);
- nextValue.updater = classComponentUpdater;
- workInProgress.stateNode = nextValue;
- nextValue._reactInternals = workInProgress;
- mountClassInstance(workInProgress, updateLanes, current, renderLanes);
+ context.updater = classComponentUpdater;
+ workInProgress.stateNode = context;
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, Component, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
hasContext,
renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(null, workInProgress, nextValue, renderLanes),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
- nextValue = workInProgress.elementType;
+ Component = workInProgress.elementType;
a: {
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- hasContext = nextValue._init;
- nextValue = hasContext(nextValue._payload);
- workInProgress.type = nextValue;
- hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue);
- current = resolveDefaultProps(nextValue, current);
- switch (hasContext) {
+ context = Component._init;
+ Component = context(Component._payload);
+ workInProgress.type = Component;
+ context = workInProgress.tag = resolveLazyComponentTag(Component);
+ current = resolveDefaultProps(Component, current);
+ switch (context) {
case 0:
workInProgress = updateFunctionComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7520,7 +7727,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateClassComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7529,7 +7736,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateForwardRef(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7538,79 +7745,75 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateMemoComponent(
null,
workInProgress,
- nextValue,
- resolveDefaultProps(nextValue.type, current),
- updateLanes,
+ Component,
+ resolveDefaultProps(Component.type, current),
renderLanes
);
break a;
}
throw Error(
"Element type is invalid. Received a promise that resolves to: " +
- nextValue +
+ Component +
". Lazy element type must resolve to a class or function."
);
}
return workInProgress;
case 0:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateFunctionComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 1:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateClassComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- 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."
- );
- nextValue = workInProgress.pendingProps;
- updateLanes = workInProgress.memoizedState.element;
+ if (null === current)
+ throw Error("Should have a current fiber. This is a bug in React.");
+ context = workInProgress.pendingProps;
+ Component = workInProgress.memoizedState.element;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextValue, null, renderLanes);
- nextValue = workInProgress.memoizedState.element;
- nextValue === updateLanes
+ processUpdateQueue(workInProgress, context, null, renderLanes);
+ context = workInProgress.memoizedState.element;
+ context === Component
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
renderLanes
))
- : (reconcileChildren(current, workInProgress, nextValue, renderLanes),
+ : (reconcileChildren(current, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateLanes = workInProgress.pendingProps.children),
- markRef(current, workInProgress),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ (Component = workInProgress.pendingProps.children),
+ markRef$1(current, workInProgress),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 6:
@@ -7623,35 +7826,30 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateLanes = workInProgress.pendingProps),
+ (Component = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateLanes,
+ Component,
renderLanes
))
- : reconcileChildren(
- current,
- workInProgress,
- updateLanes,
- renderLanes
- ),
+ : reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 11:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateForwardRef(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
@@ -7678,9 +7876,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
case 12:
return (
(workInProgress.flags |= 4),
- (updateLanes = workInProgress.stateNode),
- (updateLanes.effectDuration = 0),
- (updateLanes.passiveEffectDuration = 0),
+ (Component = workInProgress.stateNode),
+ (Component.effectDuration = 0),
+ (Component.passiveEffectDuration = 0),
reconcileChildren(
current,
workInProgress,
@@ -7691,16 +7889,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
);
case 10:
a: {
- updateLanes = workInProgress.type._context;
- nextValue = workInProgress.pendingProps;
+ Component = workInProgress.type._context;
+ context = workInProgress.pendingProps;
hasContext = workInProgress.memoizedProps;
- var newValue = nextValue.value;
- push(valueCursor, updateLanes._currentValue2);
- updateLanes._currentValue2 = newValue;
+ var newValue = context.value;
+ push(valueCursor, Component._currentValue2);
+ Component._currentValue2 = newValue;
if (null !== hasContext)
if (objectIs(hasContext.value, newValue)) {
if (
- hasContext.children === nextValue.children &&
+ hasContext.children === context.children &&
!didPerformWorkStackCursor.current
) {
workInProgress = bailoutOnAlreadyFinishedWork(
@@ -7725,7 +7923,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
null !== dependency;
) {
- if (dependency.context === updateLanes) {
+ if (dependency.context === Component) {
if (1 === newValue.tag) {
dependency = createUpdate(-1, renderLanes & -renderLanes);
dependency.tag = 2;
@@ -7743,7 +7941,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
newValue.lanes |= renderLanes;
dependency = newValue.alternate;
null !== dependency && (dependency.lanes |= renderLanes);
- scheduleWorkOnParentPath(newValue.return, renderLanes);
+ scheduleContextWorkOnParentPath(
+ newValue.return,
+ renderLanes,
+ workInProgress
+ );
list.lanes |= renderLanes;
break;
}
@@ -7776,7 +7978,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
reconcileChildren(
current,
workInProgress,
- nextValue.children,
+ context.children,
renderLanes
);
workInProgress = workInProgress.child;
@@ -7784,29 +7986,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return workInProgress;
case 9:
return (
- (nextValue = workInProgress.type),
- (updateLanes = workInProgress.pendingProps.children),
+ (context = workInProgress.type),
+ (Component = workInProgress.pendingProps.children),
prepareToReadContext(workInProgress, renderLanes),
- (nextValue = readContext(nextValue)),
- (updateLanes = updateLanes(nextValue)),
+ (context = readContext(context)),
+ (Component = Component(context)),
(workInProgress.flags |= 1),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 14:
return (
- (nextValue = workInProgress.type),
- (hasContext = resolveDefaultProps(
- nextValue,
- workInProgress.pendingProps
- )),
- (hasContext = resolveDefaultProps(nextValue.type, hasContext)),
+ (Component = workInProgress.type),
+ (context = resolveDefaultProps(Component, workInProgress.pendingProps)),
+ (context = resolveDefaultProps(Component.type, context)),
updateMemoComponent(
current,
workInProgress,
- nextValue,
- hasContext,
- updateLanes,
+ Component,
+ context,
renderLanes
)
);
@@ -7816,32 +8014,31 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateLanes,
renderLanes
);
case 17:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateLanes)
+ isContextProvider(Component)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
prepareToReadContext(workInProgress, renderLanes),
- constructClassInstance(workInProgress, updateLanes, nextValue),
- mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes),
+ constructClassInstance(workInProgress, Component, context),
+ mountClassInstance(workInProgress, Component, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
current,
renderLanes
@@ -7851,8 +8048,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return updateSuspenseListComponent(current, workInProgress, renderLanes);
case 22:
return updateOffscreenComponent(current, workInProgress, renderLanes);
- case 23:
- return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -7866,6 +8061,9 @@ function restorePendingUpdaters(root, lanes) {
addFiberToLanesMap(root, schedulingFiber, lanes);
});
}
+function scheduleCallback$1(priorityLevel, callback) {
+ return scheduleCallback(priorityLevel, callback);
+}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -7921,7 +8119,7 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.deletions = null),
(workInProgress.actualDuration = 0),
(workInProgress.actualStartTime = -1));
- workInProgress.flags = current.flags & 1835008;
+ workInProgress.flags = current.flags & 14680064;
workInProgress.childLanes = current.childLanes;
workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
@@ -7956,10 +8154,6 @@ function createFiberFromTypeAndProps(
a: switch (type) {
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_DEBUG_TRACING_MODE_TYPE:
- fiberTag = 8;
- mode |= 4;
- break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
mode |= 8;
@@ -7988,13 +8182,6 @@ function createFiberFromTypeAndProps(
);
case REACT_OFFSCREEN_TYPE:
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
- case REACT_LEGACY_HIDDEN_TYPE:
- return (
- (type = createFiber(23, pendingProps, key, mode)),
- (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
- (type.lanes = lanes),
- type
- );
default:
if ("object" === typeof type && null !== type)
switch (type.$$typeof) {
@@ -8017,8 +8204,7 @@ function createFiberFromTypeAndProps(
}
throw Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- (null == type ? type : typeof type) +
- "."
+ ((null == type ? type : typeof type) + ".")
);
}
key = createFiber(fiberTag, pendingProps, key, mode);
@@ -8036,6 +8222,7 @@ function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
pendingProps = createFiber(22, pendingProps, key, mode);
pendingProps.elementType = REACT_OFFSCREEN_TYPE;
pendingProps.lanes = lanes;
+ pendingProps.stateNode = {};
return pendingProps;
}
function createFiberFromText(content, mode, lanes) {
@@ -8058,19 +8245,25 @@ function createFiberFromPortal(portal, mode, lanes) {
};
return mode;
}
-function FiberRootNode(containerInfo, tag, hydrate) {
+function FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+) {
this.tag = tag;
this.containerInfo = containerInfo;
this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
- this.pendingContext = this.context = null;
- this.hydrate = hydrate;
- this.callbackNode = null;
+ this.callbackNode = this.pendingContext = this.context = null;
this.callbackPriority = 0;
this.eventTimes = createLaneMap(0);
this.expirationTimes = createLaneMap(-1);
this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
this.entanglements = createLaneMap(0);
+ this.identifierPrefix = identifierPrefix;
+ this.onRecoverableError = onRecoverableError;
this.passiveEffectDuration = this.effectDuration = 0;
this.memoizedUpdaters = new Set();
containerInfo = this.pendingUpdatersLaneMap = [];
@@ -8092,9 +8285,9 @@ function findHostInstance(component) {
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
+ component = Object.keys(component).join(",");
throw Error(
- "Argument appears to not be a ReactComponent. Keys: " +
- Object.keys(component)
+ "Argument appears to not be a ReactComponent. Keys: " + component
);
}
component = findCurrentHostFiber(fiber);
@@ -8176,6 +8369,9 @@ function findNodeHandle(componentOrHandle) {
? componentOrHandle.canonical._nativeTag
: componentOrHandle._nativeTag;
}
+function onRecoverableError(error) {
+ console.error(error);
+}
batchedUpdatesImpl = function(fn, a) {
var prevExecutionContext = executionContext;
executionContext |= 1;
@@ -8189,10 +8385,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
- devToolsConfig$jscomp$inline_969 = {
+ devToolsConfig$jscomp$inline_974 = {
findFiberByHostInstance: getInstanceFromInstance,
bundleType: 0,
- version: "18.0.0-experimental-568dc3532",
+ version: "18.0.0-experimental-34aa5cfe0-20220329",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@@ -8207,11 +8403,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
-var internals$jscomp$inline_1227 = {
- bundleType: devToolsConfig$jscomp$inline_969.bundleType,
- version: devToolsConfig$jscomp$inline_969.version,
- rendererPackageName: devToolsConfig$jscomp$inline_969.rendererPackageName,
- rendererConfig: devToolsConfig$jscomp$inline_969.rendererConfig,
+var internals$jscomp$inline_1238 = {
+ bundleType: devToolsConfig$jscomp$inline_974.bundleType,
+ version: devToolsConfig$jscomp$inline_974.version,
+ rendererPackageName: devToolsConfig$jscomp$inline_974.rendererPackageName,
+ rendererConfig: devToolsConfig$jscomp$inline_974.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@@ -8227,26 +8423,26 @@ var internals$jscomp$inline_1227 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
- devToolsConfig$jscomp$inline_969.findFiberByHostInstance ||
+ devToolsConfig$jscomp$inline_974.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
- reconcilerVersion: "18.0.0-experimental-568dc3532"
+ reconcilerVersion: "18.0.0-experimental-34aa5cfe0-20220329"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
- var hook$jscomp$inline_1228 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ var hook$jscomp$inline_1239 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
- !hook$jscomp$inline_1228.isDisabled &&
- hook$jscomp$inline_1228.supportsFiber
+ !hook$jscomp$inline_1239.isDisabled &&
+ hook$jscomp$inline_1239.supportsFiber
)
try {
- (rendererID = hook$jscomp$inline_1228.inject(
- internals$jscomp$inline_1227
+ (rendererID = hook$jscomp$inline_1239.inject(
+ internals$jscomp$inline_1238
)),
- (injectedHook = hook$jscomp$inline_1228);
+ (injectedHook = hook$jscomp$inline_1239);
} catch (err) {}
}
exports.createPortal = function(children, containerTag) {
@@ -8259,12 +8455,10 @@ exports.createPortal = function(children, containerTag) {
};
exports.dispatchCommand = function(handle, command, args) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.dispatchCommand(
- handle._internalInstanceHandle.stateNode.node,
- command,
- args
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.dispatchCommand(handle.node, command, args))
: ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand(
handle._nativeTag,
command,
@@ -8284,17 +8478,29 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
: componentOrHandle;
};
exports.findNodeHandle = findNodeHandle;
+exports.getInspectorDataForInstance = void 0;
exports.render = function(element, containerTag, callback, concurrentRoot) {
var root = roots.get(containerTag);
root ||
((root = concurrentRoot ? 1 : 0),
- (concurrentRoot = new FiberRootNode(containerTag, root, !1)),
+ (concurrentRoot = new FiberRootNode(
+ containerTag,
+ root,
+ !1,
+ "",
+ onRecoverableError
+ )),
(root = 1 === root ? 1 : 0),
isDevToolsPresent && (root |= 2),
(root = createFiber(3, null, null, root)),
(concurrentRoot.current = root),
(root.stateNode = concurrentRoot),
- (root.memoizedState = { element: null }),
+ (root.memoizedState = {
+ element: null,
+ isDehydrated: !1,
+ cache: null,
+ transitions: null
+ }),
initializeUpdateQueue(root),
(root = concurrentRoot),
roots.set(containerTag, root));
@@ -8312,11 +8518,10 @@ exports.render = function(element, containerTag, callback, concurrentRoot) {
};
exports.sendAccessibilityEvent = function(handle, eventType) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.sendAccessibilityEvent(
- handle._internalInstanceHandle.stateNode.node,
- eventType
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType))
: ReactNativePrivateInterface.legacySendAccessibilityEvent(
handle._nativeTag,
eventType
@@ -8332,3 +8537,13 @@ exports.stopSurface = function(containerTag) {
exports.unmountComponentAtNode = function(containerTag) {
this.stopSurface(containerTag);
};
+
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
+}
+
diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js
index a03c9ebe004f13..fb9a73c8ddb4fc 100644
--- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js
+++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js
@@ -1,5 +1,5 @@
/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@@ -8,14 +8,25 @@
* @nolint
* @providesModule ReactNativeRenderer-dev
* @preventMunge
- * @generated SignedSource<<2293994bcf1885347cabc2a323cb920e>>
+ * @generated SignedSource<<241f2ea4a27fb05d58e884b59ece93fe>>
*/
'use strict';
if (__DEV__) {
(function() {
-"use strict";
+
+ 'use strict';
+
+/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
+}
+ "use strict";
var React = require("react");
require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore");
@@ -32,32 +43,36 @@ var ReactSharedInternals =
function warn(format) {
{
- for (
- var _len = arguments.length,
- args = new Array(_len > 1 ? _len - 1 : 0),
- _key = 1;
- _key < _len;
- _key++
- ) {
- args[_key - 1] = arguments[_key];
- }
+ {
+ for (
+ var _len = arguments.length,
+ args = new Array(_len > 1 ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ ) {
+ args[_key - 1] = arguments[_key];
+ }
- printWarning("warn", format, args);
+ printWarning("warn", format, args);
+ }
}
}
function error(format) {
{
- for (
- var _len2 = arguments.length,
- args = new Array(_len2 > 1 ? _len2 - 1 : 0),
- _key2 = 1;
- _key2 < _len2;
- _key2++
- ) {
- args[_key2 - 1] = arguments[_key2];
- }
+ {
+ for (
+ var _len2 = arguments.length,
+ args = new Array(_len2 > 1 ? _len2 - 1 : 0),
+ _key2 = 1;
+ _key2 < _len2;
+ _key2++
+ ) {
+ args[_key2 - 1] = arguments[_key2];
+ }
- printWarning("error", format, args);
+ printWarning("error", format, args);
+ }
}
}
@@ -71,10 +86,10 @@ function printWarning(level, format, args) {
if (stack !== "") {
format += "%s";
args = args.concat([stack]);
- }
+ } // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function(item) {
- return "" + item;
+ return String(item);
}); // Careful: RN currently depends on this prefix
argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it
@@ -141,9 +156,15 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
// when we call document.createEvent(). However this can cause confusing
// errors: https://github.com/facebook/create-react-app/issues/3482
// So we preemptively throw with a better message instead.
- if (!(typeof document !== "undefined")) {
- throw Error(
- "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."
+ if (typeof document === "undefined" || document === null) {
+ throw new Error(
+ "The `document` global was defined when React was initialized, but is not " +
+ "defined anymore. This can happen in a test environment if a component " +
+ "schedules an update from an asynchronous callback, but the test has already " +
+ "finished running. To solve this, you can either unmount the component at " +
+ "the end of your test (and ensure that any asynchronous operations get " +
+ "canceled in `componentWillUnmount`), or you can change the test itself " +
+ "to be asynchronous."
);
}
@@ -249,6 +270,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
if (didCall && didError) {
if (!didSetError) {
// The callback errored, but the error event never fired.
+ // eslint-disable-next-line react-internal/prod-error-codes
error = new Error(
"An error was thrown inside one of your components, but React " +
"doesn't know what it was. This is likely due to browser " +
@@ -260,6 +282,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
"actually an issue with React, please file an issue."
);
} else if (isCrossOriginError) {
+ // eslint-disable-next-line react-internal/prod-error-codes
error = new Error(
"A cross-origin error was thrown. React doesn't have access to " +
"the actual error object in development. " +
@@ -372,11 +395,10 @@ function clearCaughtError() {
caughtError = null;
return error;
} else {
- {
- throw Error(
- "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."
- );
- }
+ throw new Error(
+ "clearCaughtError was called but no error was captured. This error " +
+ "is likely caused by a bug in React. Please file an issue."
+ );
}
}
@@ -533,8 +555,8 @@ function executeDirectDispatch(event) {
var dispatchListener = event._dispatchListeners;
var dispatchInstance = event._dispatchInstances;
- if (!!isArray(dispatchListener)) {
- throw Error("executeDirectDispatch(...): Invalid `event`.");
+ if (isArray(dispatchListener)) {
+ throw new Error("executeDirectDispatch(...): Invalid `event`.");
}
event.currentTarget = dispatchListener
@@ -555,6 +577,8 @@ function hasDispatches(event) {
return !!event._dispatchListeners;
}
+var assign = Object.assign;
+
var EVENT_POOL_SIZE = 10;
/**
* @interface Event
@@ -663,7 +687,7 @@ function SyntheticEvent(
return this;
}
-Object.assign(SyntheticEvent.prototype, {
+assign(SyntheticEvent.prototype, {
preventDefault: function() {
this.defaultPrevented = true;
var event = this.nativeEvent;
@@ -793,10 +817,10 @@ SyntheticEvent.extend = function(Interface) {
return Super.apply(this, arguments);
}
- Object.assign(prototype, Class.prototype);
+ assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = Object.assign({}, Super.Interface, Interface);
+ Class.Interface = assign({}, Super.Interface, Interface);
Class.extend = Super.extend;
addEventPoolingTo(Class);
return Class;
@@ -881,7 +905,7 @@ function releasePooledEvent(event) {
var EventConstructor = this;
if (!(event instanceof EventConstructor)) {
- throw Error(
+ throw new Error(
"Trying to release an event instance into a pool of a different type."
);
}
@@ -990,8 +1014,8 @@ function resetTouchRecord(touchRecord, touch) {
function getTouchIdentifier(_ref) {
var identifier = _ref.identifier;
- if (!(identifier != null)) {
- throw Error("Touch object is missing identifier.");
+ if (identifier == null) {
+ throw new Error("Touch object is missing identifier.");
}
{
@@ -1149,8 +1173,8 @@ var ResponderTouchHistoryStore = {
*/
function accumulate(current, next) {
- if (!(next != null)) {
- throw Error(
+ if (next == null) {
+ throw new Error(
"accumulate(...): Accumulated items must not be null or undefined."
);
}
@@ -1185,8 +1209,8 @@ function accumulate(current, next) {
*/
function accumulateInto(current, next) {
- if (!(next != null)) {
- throw Error(
+ if (next == null) {
+ throw new Error(
"accumulateInto(...): Accumulated items must not be null or undefined."
);
}
@@ -1258,6 +1282,7 @@ var ScopeComponent = 21;
var OffscreenComponent = 22;
var LegacyHiddenComponent = 23;
var CacheComponent = 24;
+var TracingMarkerComponent = 25;
/**
* Instance of element that should respond to touch/move types of interactions,
@@ -1492,8 +1517,8 @@ function getListener(inst, registrationName) {
var listener = props[registrationName];
- if (!(!listener || typeof listener === "function")) {
- throw Error(
+ if (listener && typeof listener !== "function") {
+ throw new Error(
"Expected `" +
registrationName +
"` listener to be a function, instead got a value of `" +
@@ -2075,11 +2100,10 @@ function recomputePluginOrdering() {
var pluginModule = namesToPlugins[pluginName];
var pluginIndex = eventPluginOrder.indexOf(pluginName);
- if (!(pluginIndex > -1)) {
- throw Error(
- "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" +
- pluginName +
- "`."
+ if (pluginIndex <= -1) {
+ throw new Error(
+ "EventPluginRegistry: Cannot inject event plugins that do not exist in " +
+ ("the plugin ordering, `" + pluginName + "`.")
);
}
@@ -2088,10 +2112,9 @@ function recomputePluginOrdering() {
}
if (!pluginModule.extractEvents) {
- throw Error(
- "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" +
- pluginName +
- "` does not."
+ throw new Error(
+ "EventPluginRegistry: Event plugins must implement an `extractEvents` " +
+ ("method, but `" + pluginName + "` does not.")
);
}
@@ -2106,7 +2129,7 @@ function recomputePluginOrdering() {
eventName
)
) {
- throw Error(
+ throw new Error(
"EventPluginRegistry: Failed to publish event `" +
eventName +
"` for plugin `" +
@@ -2127,11 +2150,10 @@ function recomputePluginOrdering() {
*/
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
- if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
- throw Error(
- "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" +
- eventName +
- "`."
+ if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
+ throw new Error(
+ "EventPluginRegistry: More than one plugin attempted to publish the same " +
+ ("event name, `" + eventName + "`.")
);
}
@@ -2171,11 +2193,10 @@ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
*/
function publishRegistrationName(registrationName, pluginModule, eventName) {
- if (!!registrationNameModules[registrationName]) {
- throw Error(
- "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" +
- registrationName +
- "`."
+ if (registrationNameModules[registrationName]) {
+ throw new Error(
+ "EventPluginRegistry: More than one plugin attempted to publish the same " +
+ ("registration name, `" + registrationName + "`.")
);
}
@@ -2222,9 +2243,10 @@ var registrationNameDependencies = {};
*/
function injectEventPluginOrder(injectedEventPluginOrder) {
- 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."
+ if (eventPluginOrder) {
+ throw new Error(
+ "EventPluginRegistry: Cannot inject event plugin ordering more than " +
+ "once. You are likely trying to load more than one copy of React."
);
} // Clone the ordering so it cannot be dynamically mutated.
@@ -2255,11 +2277,10 @@ function injectEventPluginsByName(injectedNamesToPlugins) {
!namesToPlugins.hasOwnProperty(pluginName) ||
namesToPlugins[pluginName] !== pluginModule
) {
- if (!!namesToPlugins[pluginName]) {
- throw Error(
- "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName +
- "`."
+ if (namesToPlugins[pluginName]) {
+ throw new Error(
+ "EventPluginRegistry: Cannot inject two different event plugins " +
+ ("using the same name, `" + pluginName + "`.")
);
}
@@ -2273,13 +2294,35 @@ function injectEventPluginsByName(injectedNamesToPlugins) {
}
}
-function getListener$1(inst, registrationName) {
+/**
+ * Get a list of listeners for a specific event, in-order.
+ * For React Native we treat the props-based function handlers
+ * as the first-class citizens, and they are always executed first
+ * for both capture and bubbling phase.
+ *
+ * We need "phase" propagated to this point to support the HostComponent
+ * EventEmitter API, which does not mutate the name of the handler based
+ * on phase (whereas prop handlers are registered as `onMyEvent` and `onMyEvent_Capture`).
+ *
+ * Native system events emitted into React Native
+ * will be emitted both to the prop handler function and to imperative event
+ * listeners.
+ *
+ * This will either return null, a single Function without an array, or
+ * an array of 2+ items.
+ */
+
+function getListeners(
+ inst,
+ registrationName,
+ phase,
+ dispatchToImperativeListeners
+) {
var stateNode = inst.stateNode;
if (stateNode === null) {
- // Work in progress (ex: onload events in incremental mode).
return null;
- }
+ } // If null: Work in progress (ex: onload events in incremental mode).
var props = getFiberCurrentPropsFromNode(stateNode);
@@ -2290,17 +2333,133 @@ function getListener$1(inst, registrationName) {
var listener = props[registrationName];
- if (!(!listener || typeof listener === "function")) {
- throw Error(
+ if (listener && typeof listener !== "function") {
+ throw new Error(
"Expected `" +
registrationName +
"` listener to be a function, instead got a value of `" +
typeof listener +
"` type."
);
+ } // If there are no imperative listeners, early exit.
+
+ if (
+ !(
+ dispatchToImperativeListeners &&
+ stateNode.canonical &&
+ stateNode.canonical._eventListeners
+ )
+ ) {
+ return listener;
+ } // Below this is the de-optimized path.
+ // If you are using _eventListeners, we do not (yet)
+ // expect this to be as performant as the props-only path.
+ // If/when this becomes a bottleneck, it can be refactored
+ // to avoid unnecessary closures and array allocations.
+ //
+ // Previously, there was only one possible listener for an event:
+ // the onEventName property in props.
+ // Now, it is also possible to have N listeners
+ // for a specific event on a node. Thus, we accumulate all of the listeners,
+ // including the props listener, and return a function that calls them all in
+ // order, starting with the handler prop and then the listeners in order.
+ // We return either a non-empty array or null.
+
+ var listeners = [];
+
+ if (listener) {
+ listeners.push(listener);
+ } // TODO: for now, all of these events get an `rn:` prefix to enforce
+ // that the user knows they're only getting non-W3C-compliant events
+ // through this imperative event API.
+ // Events might not necessarily be noncompliant, but we currently have
+ // no verification that /any/ events are compliant.
+ // Thus, we prefix to ensure no collision with W3C event names.
+
+ var requestedPhaseIsCapture = phase === "captured";
+ var mangledImperativeRegistrationName = requestedPhaseIsCapture
+ ? "rn:" + registrationName.replace(/Capture$/, "")
+ : "rn:" + registrationName; // Get imperative event listeners for this event
+
+ if (
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName] &&
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName]
+ .length > 0
+ ) {
+ var eventListeners =
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName];
+ eventListeners.forEach(function(listenerObj) {
+ // Make sure phase of listener matches requested phase
+ var isCaptureEvent =
+ listenerObj.options.capture != null && listenerObj.options.capture;
+
+ if (isCaptureEvent !== requestedPhaseIsCapture) {
+ return;
+ } // For now (this is an area of future optimization) we must wrap
+ // all imperative event listeners in a function to unwrap the SyntheticEvent
+ // and pass them an Event.
+ // When this API is more stable and used more frequently, we can revisit.
+
+ var listenerFnWrapper = function(syntheticEvent) {
+ var eventInst = new ReactNativePrivateInterface.CustomEvent(
+ mangledImperativeRegistrationName,
+ {
+ detail: syntheticEvent.nativeEvent
+ }
+ );
+ eventInst.isTrusted = true; // setSyntheticEvent is present on the React Native Event shim.
+ // It is used to forward method calls on Event to the underlying SyntheticEvent.
+ // $FlowFixMe
+
+ eventInst.setSyntheticEvent(syntheticEvent);
+
+ for (
+ var _len = arguments.length,
+ args = new Array(_len > 1 ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ ) {
+ args[_key - 1] = arguments[_key];
+ }
+
+ listenerObj.listener.apply(listenerObj, [eventInst].concat(args));
+ }; // Only call once?
+ // If so, we ensure that it's only called once by setting a flag
+ // and by removing it from eventListeners once it is called (but only
+ // when it's actually been executed).
+
+ if (listenerObj.options.once) {
+ listeners.push(function() {
+ // Remove from the event listener once it's been called
+ stateNode.canonical.removeEventListener_unstable(
+ mangledImperativeRegistrationName,
+ listenerObj.listener,
+ listenerObj.capture
+ ); // Guard against function being called more than once in
+ // case there are somehow multiple in-flight references to
+ // it being processed
+
+ if (!listenerObj.invalidated) {
+ listenerObj.invalidated = true;
+ listenerObj.listener.apply(listenerObj, arguments);
+ }
+ });
+ } else {
+ listeners.push(listenerFnWrapper);
+ }
+ });
}
- return listener;
+ if (listeners.length === 0) {
+ return null;
+ }
+
+ if (listeners.length === 1) {
+ return listeners[0];
+ }
+
+ return listeners;
}
var customBubblingEventTypes =
@@ -2312,10 +2471,39 @@ var customBubblingEventTypes =
// EventPropagator.js, as they deviated from ReactDOM's newer
// implementations.
-function listenerAtPhase$1(inst, event, propagationPhase) {
+function listenersAtPhase(inst, event, propagationPhase) {
var registrationName =
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
- return getListener$1(inst, registrationName);
+ return getListeners(inst, registrationName, propagationPhase, true);
+}
+
+function accumulateListenersAndInstances(inst, event, listeners) {
+ var listenersLength = listeners
+ ? isArray(listeners)
+ ? listeners.length
+ : 1
+ : 0;
+
+ if (listenersLength > 0) {
+ event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listeners
+ ); // Avoid allocating additional arrays here
+
+ if (event._dispatchInstances == null && listenersLength === 1) {
+ event._dispatchInstances = inst;
+ } else {
+ event._dispatchInstances = event._dispatchInstances || [];
+
+ if (!isArray(event._dispatchInstances)) {
+ event._dispatchInstances = [event._dispatchInstances];
+ }
+
+ for (var i = 0; i < listenersLength; i++) {
+ event._dispatchInstances.push(inst);
+ }
+ }
+ }
}
function accumulateDirectionalDispatches$1(inst, phase, event) {
@@ -2325,15 +2513,8 @@ function accumulateDirectionalDispatches$1(inst, phase, event) {
}
}
- var listener = listenerAtPhase$1(inst, event, phase);
-
- if (listener) {
- event._dispatchListeners = accumulateInto(
- event._dispatchListeners,
- listener
- );
- event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
- }
+ var listeners = listenersAtPhase(inst, event, phase);
+ accumulateListenersAndInstances(inst, event, listeners);
}
function getParent$1(inst) {
@@ -2355,7 +2536,7 @@ function getParent$1(inst) {
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
*/
-function traverseTwoPhase$1(inst, fn, arg) {
+function traverseTwoPhase$1(inst, fn, arg, skipBubbling) {
var path = [];
while (inst) {
@@ -2369,8 +2550,13 @@ function traverseTwoPhase$1(inst, fn, arg) {
fn(path[i], "captured", arg);
}
- for (i = 0; i < path.length; i++) {
- fn(path[i], "bubbled", arg);
+ if (skipBubbling) {
+ // Dispatch on target only
+ fn(path[0], "bubbled", arg);
+ } else {
+ for (i = 0; i < path.length; i++) {
+ fn(path[i], "bubbled", arg);
+ }
}
}
@@ -2379,7 +2565,8 @@ function accumulateTwoPhaseDispatchesSingle$1(event) {
traverseTwoPhase$1(
event._targetInst,
accumulateDirectionalDispatches$1,
- event
+ event,
+ false
);
}
}
@@ -2387,6 +2574,17 @@ function accumulateTwoPhaseDispatchesSingle$1(event) {
function accumulateTwoPhaseDispatches$1(events) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1);
}
+
+function accumulateCapturePhaseDispatches(event) {
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event,
+ true
+ );
+ }
+}
/**
* Accumulates without regard to direction, does not look for phased
* registration names. Same as `accumulateDirectDispatchesSingle` but without
@@ -2396,15 +2594,8 @@ function accumulateTwoPhaseDispatches$1(events) {
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);
- }
+ var listeners = getListeners(inst, registrationName, "bubbled", false);
+ accumulateListenersAndInstances(inst, event, listeners);
}
}
/**
@@ -2439,8 +2630,8 @@ var ReactNativeBridgeEventPlugin = {
var bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
var directDispatchConfig = customDirectEventTypes[topLevelType];
- if (!(bubbleDispatchConfig || directDispatchConfig)) {
- throw Error(
+ if (!bubbleDispatchConfig && !directDispatchConfig) {
+ throw new Error( // $FlowFixMe - Flow doesn't like this string coercion because DOMTopLevelEventType is opaque
'Unsupported top level event type "' + topLevelType + '" dispatched'
);
}
@@ -2453,7 +2644,16 @@ var ReactNativeBridgeEventPlugin = {
);
if (bubbleDispatchConfig) {
- accumulateTwoPhaseDispatches$1(event);
+ var skipBubbling =
+ event != null &&
+ event.dispatchConfig.phasedRegistrationNames != null &&
+ event.dispatchConfig.phasedRegistrationNames.skipBubbling;
+
+ if (skipBubbling) {
+ accumulateCapturePhaseDispatches(event);
+ } else {
+ accumulateTwoPhaseDispatches$1(event);
+ }
} else if (directDispatchConfig) {
accumulateDirectDispatches$1(event);
} else {
@@ -2514,7 +2714,7 @@ function getTagFromInstance(inst) {
}
if (!tag) {
- throw Error("All native instances should have a tag.");
+ throw new Error("All native instances should have a tag.");
}
return nativeInstance;
@@ -2535,6 +2735,7 @@ function updateFiberProps(tag, props) {
var batchedUpdatesImpl = function(fn, bookkeeping) {
return fn(bookkeeping);
};
+
var isInsideEventHandler = false;
function batchedUpdates(fn, bookkeeping) {
if (isInsideEventHandler) {
@@ -2551,11 +2752,7 @@ function batchedUpdates(fn, bookkeeping) {
isInsideEventHandler = false;
}
}
-function setBatchingImplementation(
- _batchedUpdatesImpl,
- _discreteUpdatesImpl,
- _batchedEventUpdatesImpl
-) {
+function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl) {
batchedUpdatesImpl = _batchedUpdatesImpl;
}
@@ -2601,9 +2798,10 @@ function runEventsInBatch(events) {
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
- if (!!eventQueue) {
- throw Error(
- "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
+ if (eventQueue) {
+ throw new Error(
+ "processEventQueue(): Additional events were enqueued while processing " +
+ "an event queue. Support for this has not yet been implemented."
);
} // This would be a good time to rethrow if any of the event handlers threw.
@@ -2863,53 +3061,39 @@ function set(key, value) {
key._reactInternals = value;
}
+var enableSchedulingProfiler = false;
+var enableProfilerTimer = true;
+var enableProfilerCommitHooks = true;
+var enableLazyElements = false;
+var warnAboutStringRefs = false;
+var enableSuspenseAvoidThisFallback = false;
+var enableNewReconciler = false;
+var enableLazyContextPropagation = false;
+var enableLegacyHidden = false;
+
// 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 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_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;
-var REACT_CACHE_TYPE = 0xeae4;
-
-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_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");
- REACT_CACHE_TYPE = symbolFor("react.cache");
-}
-
-var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
+// The Symbol used to tag the ReactElement-like types.
+var REACT_ELEMENT_TYPE = Symbol.for("react.element");
+var REACT_PORTAL_TYPE = Symbol.for("react.portal");
+var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
+var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
+var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
+var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
+var REACT_CONTEXT_TYPE = Symbol.for("react.context");
+var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
+var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
+var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
+var REACT_MEMO_TYPE = Symbol.for("react.memo");
+var REACT_LAZY_TYPE = Symbol.for("react.lazy");
+var REACT_SCOPE_TYPE = Symbol.for("react.scope");
+var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for("react.debug_trace_mode");
+var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
+var REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden");
+var REACT_CACHE_TYPE = Symbol.for("react.cache");
+var REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker");
+var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
function getIteratorFn(maybeIterable) {
if (maybeIterable === null || typeof maybeIterable !== "object") {
@@ -2985,9 +3169,6 @@ function getComponentNameFromType(type) {
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
-
- case REACT_CACHE_TYPE:
- return "Cache";
}
if (typeof type === "object") {
@@ -3023,6 +3204,8 @@ function getComponentNameFromType(type) {
return null;
}
}
+
+ // eslint-disable-next-line no-fallthrough
}
}
@@ -3083,9 +3266,6 @@ function getComponentNameFromFiber(fiber) {
// Name comes from the type in this case; we don't have a tag.
return getComponentNameFromType(type);
- case LegacyHiddenComponent:
- return "LegacyHidden";
-
case Mode:
if (type === REACT_STRICT_MODE_TYPE) {
// Don't be less specific than shared/getComponentNameFromType
@@ -3108,6 +3288,9 @@ function getComponentNameFromFiber(fiber) {
case SuspenseListComponent:
return "SuspenseList";
+
+ case TracingMarkerComponent:
+ return "TracingMarker";
// The display name for this tags come from the user-provided type:
case ClassComponent:
@@ -3130,13 +3313,6 @@ function getComponentNameFromFiber(fiber) {
return null;
}
-var enableProfilerTimer = true;
-var enableProfilerCommitHooks = true;
-var enableLazyElements = false;
-var warnAboutStringRefs = false;
-var enableNewReconciler = false;
-var enableLazyContextPropagation = false;
-
// Don't change these two values. They're used by React Dev Tools.
var NoFlags =
/* */
@@ -3166,39 +3342,49 @@ var Callback =
var DidCapture =
/* */
128;
+var ForceClientRender =
+ /* */
+ 256;
var Ref =
/* */
- 256;
+ 512;
var Snapshot =
/* */
- 512;
+ 1024;
var Passive =
/* */
- 1024;
+ 2048;
var Hydrating =
/* */
- 2048;
+ 4096;
var HydratingAndUpdate =
/* */
Hydrating | Update;
var Visibility =
/* */
- 4096;
-var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit)
+ 8192;
+var StoreConsistency =
+ /* */
+ 16384;
+var LifecycleEffectMask =
+ Passive | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit)
var HostEffectMask =
/* */
- 8191; // These are not really side effects, but we still reuse this field.
+ 32767; // These are not really side effects, but we still reuse this field.
var Incomplete =
/* */
- 8192;
+ 32768;
var ShouldCapture =
/* */
- 16384;
+ 65536;
var ForceUpdateForLegacySuspense =
/* */
- 32768;
+ 131072;
+var Forked =
+ /* */
+ 1048576; // Static tags describe aspects of a fiber that are not specific to a render,
// e.g. a fiber uses a passive effect (even if there are no updates on this particular render).
// This enables us to defer more work in the unmount case,
// since we can defer traversing the tree during layout to look for Passive effects,
@@ -3206,16 +3392,16 @@ var ForceUpdateForLegacySuspense =
var RefStatic =
/* */
- 262144;
+ 2097152;
var LayoutStatic =
/* */
- 524288;
+ 4194304;
var PassiveStatic =
/* */
- 1048576; // These flags allow us to traverse to fibers that have effects on mount
+ 8388608; // These flags allow us to traverse to fibers that have effects on mount
// don't contain effects, by checking subtreeFlags.
-var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visiblity
+var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility
// flag logic (see #20043)
Update | Snapshot | 0;
var MutationMask =
@@ -3226,10 +3412,10 @@ var MutationMask =
Ref |
Hydrating |
Visibility;
-var LayoutMask = Update | Callback | Ref; // TODO: Split into PassiveMountMask and PassiveUnmountMask
+var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask
var PassiveMask = Passive | ChildDeletion; // Union of tags that don't get reset on clones.
-// This allows certain concepts to persist without recalculting them,
+// This allows certain concepts to persist without recalculating them,
// e.g. whether a subtree contains passive effects or portals.
var StaticMask = LayoutStatic | PassiveStatic | RefStatic;
@@ -3307,8 +3493,8 @@ function isMounted(component) {
}
function assertIsMounted(fiber) {
- if (!(getNearestMountedFiber(fiber) === fiber)) {
- throw Error("Unable to find node on an unmounted component.");
+ if (getNearestMountedFiber(fiber) !== fiber) {
+ throw new Error("Unable to find node on an unmounted component.");
}
}
@@ -3319,8 +3505,8 @@ function findCurrentFiberUsingSlowPath(fiber) {
// If there is no alternate, then we only need to check if it is mounted.
var nearestMounted = getNearestMountedFiber(fiber);
- if (!(nearestMounted !== null)) {
- throw Error("Unable to find node on an unmounted component.");
+ if (nearestMounted === null) {
+ throw new Error("Unable to find node on an unmounted component.");
}
if (nearestMounted !== fiber) {
@@ -3382,9 +3568,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
} // We should never have an alternate for any mounting node. So the only
// way this could possibly happen is if this was unmounted, if at all.
- {
- throw Error("Unable to find node on an unmounted component.");
- }
+ throw new Error("Unable to find node on an unmounted component.");
}
if (a.return !== b.return) {
@@ -3444,23 +3628,25 @@ function findCurrentFiberUsingSlowPath(fiber) {
}
if (!didFindChild) {
- throw Error(
- "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."
+ throw new Error(
+ "Child was not found in either parent set. This indicates a bug " +
+ "in React related to the return pointer. Please file an issue."
);
}
}
}
- if (!(a.alternate === b)) {
- throw Error(
- "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."
+ if (a.alternate !== b) {
+ throw new Error(
+ "Return fibers should always be each others' alternates. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
} // If the root is not a host container, we're in a disconnected tree. I.e.
// unmounted.
- if (!(a.tag === HostRoot)) {
- throw Error("Unable to find node on an unmounted component.");
+ if (a.tag !== HostRoot) {
+ throw new Error("Unable to find node on an unmounted component.");
}
if (a.stateNode.current === a) {
@@ -4143,6 +4329,16 @@ function injectInternals(internals) {
}
try {
+ if (enableSchedulingProfiler) {
+ // Conditionally inject these hooks only if Timeline profiler is supported by this build.
+ // This gives DevTools a way to feature detect that isn't tied to version number
+ // (since profiling and timeline are controlled by different feature flags).
+ internals = assign({}, internals, {
+ getLaneLabelMap: getLaneLabelMap,
+ injectProfilingHooks: injectProfilingHooks
+ });
+ }
+
rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
injectedHook = hook;
@@ -4151,9 +4347,15 @@ function injectInternals(internals) {
{
error("React instrumentation encountered an error: %s.", err);
}
- } // DevTools exists
+ }
- return true;
+ if (hook.checkDCE) {
+ // This is the real DevTools.
+ return true;
+ } else {
+ // This is likely a hook installed by Fast Refresh runtime.
+ return false;
+ }
}
function onScheduleRoot(root, children) {
{
@@ -4257,6 +4459,17 @@ function onCommitUnmount(fiber) {
}
}
+function injectProfilingHooks(profilingHooks) {}
+
+function getLaneLabelMap() {
+ {
+ return null;
+ }
+}
+function markComponentRenderStopped() {}
+function markComponentErrored(fiber, thrownValue, lanes) {}
+function markComponentSuspended(fiber, wakeable, lanes) {}
+
var NoMode =
/* */
0; // TODO: Remove ConcurrentMode by reading from the root tag instead
@@ -4267,13 +4480,28 @@ var ConcurrentMode =
var ProfileMode =
/* */
2;
-var DebugTracingMode =
- /* */
- 4;
var StrictLegacyMode =
/* */
8;
+// TODO: This is pretty well supported by browsers. Maybe we can drop it.
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros.
+// 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(x) {
+ var asUint = x >>> 0;
+
+ if (asUint === 0) {
+ return 32;
+ }
+
+ return (31 - ((log(asUint) / LN2) | 0)) | 0;
+}
+
// If those values are changed that package should be rebuilt and redeployed.
var TotalLanes = 31;
@@ -4385,7 +4613,7 @@ var IdleLane =
536870912;
var OffscreenLane =
/* */
- 1073741824; // This function is used for the experimental scheduling profiler (react-devtools-scheduling-profiler)
+ 1073741824; // This function is used for the experimental timeline (react-devtools-timeline)
var NoTimestamp = -1;
var nextTransitionLane = TransitionLane1;
var nextRetryLane = RetryLane1;
@@ -4705,6 +4933,9 @@ function getLanesToRetrySynchronouslyOnError(root) {
return NoLanes;
}
+function includesSyncLane(lanes) {
+ return (lanes & SyncLane) !== NoLanes;
+}
function includesNonIdleWork(lanes) {
return (lanes & NonIdleLanes) !== NoLanes;
}
@@ -4714,19 +4945,18 @@ function includesOnlyRetries(lanes) {
function includesOnlyTransitions(lanes) {
return (lanes & TransitionLanes) === lanes;
}
-function shouldTimeSlice(root, lanes) {
- if ((lanes & root.expiredLanes) !== NoLanes) {
- // At least one of these lanes expired. To prevent additional starvation,
- // finish rendering without yielding execution.
- return false;
- }
-
+function includesBlockingLane(root, lanes) {
var SyncDefaultLanes =
InputContinuousHydrationLane |
InputContinuousLane |
DefaultHydrationLane |
DefaultLane;
- return (lanes & SyncDefaultLanes) === NoLanes;
+ return (lanes & SyncDefaultLanes) !== NoLanes;
+}
+function includesExpiredLane(root, lanes) {
+ // This is a separate check from includesBlockingLane because a lane can
+ // expire after a render has already started.
+ return (lanes & root.expiredLanes) !== NoLanes;
}
function isTransitionLane(lane) {
return (lane & TransitionLanes) !== 0;
@@ -4846,9 +5076,6 @@ function markRootSuspended(root, suspendedLanes) {
function markRootPinged(root, pingedLanes, eventTime) {
root.pingedLanes |= root.suspendedLanes & pingedLanes;
}
-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
@@ -4858,7 +5085,6 @@ function markRootFinished(root, remainingLanes) {
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
@@ -4947,20 +5173,6 @@ function movePendingFibersToMemoized(root, lanes) {
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;
-}
var DiscreteEventPriority = SyncLane;
var ContinuousEventPriority = InputContinuousLane;
@@ -5000,14 +5212,14 @@ function lanesToEventPriority(lanes) {
return IdleEventPriority;
}
+// Renderers that don't support hydration
// can re-export everything from this module.
-
function shim() {
- {
- throw Error(
- "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue."
- );
- }
+ throw new Error(
+ "The current renderer does not support hydration. " +
+ "This error is likely caused by a bug in React. " +
+ "Please file an issue."
+ );
} // Hydration (when unsupported)
var isSuspenseInstancePending = shim;
var isSuspenseInstanceFallback = shim;
@@ -5095,7 +5307,7 @@ function createTextInstance(
internalInstanceHandle
) {
if (!hostContext.isInAParentText) {
- throw Error("Text strings must be rendered within a component.");
+ throw new Error("Text strings must be rendered within a component.");
}
var tag = allocateTag();
@@ -5294,8 +5506,8 @@ function insertInContainerBefore(parentInstance, child, beforeChild) {
// We create a wrapper object for the container in ReactNative render()
// Or we refactor to remove wrapper objects entirely.
// For more info on pros/cons see PR #8560 description.
- if (!(typeof parentInstance !== "number")) {
- throw Error("Container does not support insertBefore operation");
+ if (typeof parentInstance === "number") {
+ throw new Error("Container does not support insertBefore operation");
}
}
function removeChild(parentInstance, child) {
@@ -5348,7 +5560,7 @@ function hideTextInstance(textInstance) {
function unhideInstance(instance, props) {
var viewConfig = instance.viewConfig;
var updatePayload = diff(
- Object.assign({}, props, {
+ assign({}, props, {
style: [
props.style,
{
@@ -5372,9 +5584,6 @@ function clearContainer(container) {
function unhideTextInstance(textInstance, text) {
throw new Error("Not yet implemented.");
}
-function makeClientIdInDEV(warnOnAccessInDEV) {
- throw new Error("Not yet implemented");
-}
function preparePortalMount(portalInstance) {
// noop
}
@@ -5538,6 +5747,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) {
// 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") {
+ // eslint-disable-next-line react-internal/prod-error-codes
var err = Error(
(componentName || "React class") +
": " +
@@ -5769,9 +5979,10 @@ function popTopLevelContextObject(fiber) {
function pushTopLevelContextObject(fiber, context, didChange) {
{
- if (!(contextStackCursor.current === emptyContextObject)) {
- throw Error(
- "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."
+ if (contextStackCursor.current !== emptyContextObject) {
+ throw new Error(
+ "Unexpected context found on stack. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -5810,7 +6021,7 @@ function processChildContext(fiber, type, parentContext) {
for (var contextKey in childContext) {
if (!(contextKey in childContextTypes)) {
- throw Error(
+ throw new Error(
(getComponentNameFromFiber(fiber) || "Unknown") +
'.getChildContext(): key "' +
contextKey +
@@ -5824,7 +6035,7 @@ function processChildContext(fiber, type, parentContext) {
checkPropTypes(childContextTypes, childContext, "child context", name);
}
- return Object.assign({}, parentContext, childContext);
+ return assign({}, parentContext, childContext);
}
}
@@ -5855,8 +6066,9 @@ function invalidateContextProvider(workInProgress, type, didChange) {
var instance = workInProgress.stateNode;
if (!instance) {
- throw Error(
- "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."
+ throw new Error(
+ "Expected to have an instance by this point. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -5888,9 +6100,10 @@ function findCurrentUnmaskedContext(fiber) {
{
// Currently this is only used with renderSubtreeIntoContainer; not sure if it
// makes sense elsewhere
- if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
- 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."
+ if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) {
+ throw new Error(
+ "Expected subtree parent to be a mounted class component. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -5915,17 +6128,28 @@ function findCurrentUnmaskedContext(fiber) {
node = node.return;
} while (node !== null);
- {
- throw Error(
- "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
- );
- }
+ throw new Error(
+ "Found unexpected detached subtree parent. " +
+ "This error is likely caused by a bug in React. Please file an issue."
+ );
}
}
var LegacyRoot = 0;
var ConcurrentRoot = 1;
+/**
+ * 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
+ );
+}
+
+var objectIs = typeof Object.is === "function" ? Object.is : is;
+
var syncQueue = null;
var includesLegacySyncCallbacks = false;
var isFlushingSyncQueue = false;
@@ -5956,7 +6180,7 @@ function flushSyncCallbacksOnlyInLegacyMode() {
}
function flushSyncCallbacks() {
if (!isFlushingSyncQueue && syncQueue !== null) {
- // Prevent re-entrancy.
+ // Prevent re-entrance.
isFlushingSyncQueue = true;
var i = 0;
var previousUpdatePriority = getCurrentUpdatePriority();
@@ -5995,45 +6219,24 @@ function flushSyncCallbacks() {
return null;
}
-var NoFlags$1 =
- /* */
- 0; // Represents whether effect should fire.
-
-var HasEffect =
- /* */
- 1; // Represents the phase in which the effect (not the clean-up) fires.
-
-var Layout =
- /* */
- 2;
-var Passive$1 =
- /* */
- 4;
-
-var ReactVersion = "18.0.0-experimental-568dc3532";
+// This is imported by the event replaying implementation in React DOM. It's
+// in a separate file to break a circular dependency between the renderer and
+// the reconciler.
+function isRootDehydrated(root) {
+ var currentState = root.current.memoizedState;
+ return currentState.isDehydrated;
+}
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
-var NoTransition = 0;
+var NoTransition = null;
function requestCurrentTransition() {
return ReactCurrentBatchConfig.transition;
}
/**
- * 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
- );
-}
-
-var objectIs = typeof Object.is === "function" ? Object.is : is;
-
-/**
- * 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.
+ * 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.
*/
function shallowEqual(objA, objB) {
@@ -6058,9 +6261,11 @@ function shallowEqual(objA, objB) {
} // Test for A's keys different from B.
for (var i = 0; i < keysA.length; i++) {
+ var currentKey = keysA[i];
+
if (
- !hasOwnProperty.call(objB, keysA[i]) ||
- !objectIs(objA[keysA[i]], objB[keysA[i]])
+ !hasOwnProperty.call(objB, currentKey) ||
+ !objectIs(objA[currentKey], objB[currentKey])
) {
return false;
}
@@ -6167,11 +6372,6 @@ function setIsRendering(rendering) {
isRendering = rendering;
}
}
-function getIsRendering() {
- {
- return isRendering;
- }
-}
var ReactStrictModeWarnings = {
recordUnsafeLifecycleWarnings: function(fiber, instance) {},
@@ -6521,10 +6721,97 @@ var ReactStrictModeWarnings = {
};
}
+/*
+ * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
+ * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
+ *
+ * The functions in this module will throw an easier-to-understand,
+ * easier-to-debug exception with a clear errors message message explaining the
+ * problem. (Instead of a confusing exception thrown inside the implementation
+ * of the `value` object).
+ */
+// $FlowFixMe only called in DEV, so void return is not possible.
+function typeName(value) {
+ {
+ // toStringTag is needed for namespaced types like Temporal.Instant
+ var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
+ var type =
+ (hasToStringTag && value[Symbol.toStringTag]) ||
+ value.constructor.name ||
+ "Object";
+ return type;
+ }
+} // $FlowFixMe only called in DEV, so void return is not possible.
+
+function willCoercionThrow(value) {
+ {
+ try {
+ testStringCoercion(value);
+ return false;
+ } catch (e) {
+ return true;
+ }
+ }
+}
+
+function testStringCoercion(value) {
+ // If you ended up here by following an exception call stack, here's what's
+ // happened: you supplied an object or symbol value to React (as a prop, key,
+ // DOM attribute, CSS property, string ref, etc.) and when React tried to
+ // coerce it to a string using `'' + value`, an exception was thrown.
+ //
+ // The most common types that will cause this exception are `Symbol` instances
+ // and Temporal objects like `Temporal.Instant`. But any object that has a
+ // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
+ // exception. (Library authors do this to prevent users from using built-in
+ // numeric operators like `+` or comparison operators like `>=` because custom
+ // methods are needed to perform accurate arithmetic or comparison.)
+ //
+ // To fix the problem, coerce this object or symbol value to a string before
+ // passing it to React. The most reliable way is usually `String(value)`.
+ //
+ // To find which value is throwing, check the browser or debugger console.
+ // Before this exception was thrown, there should be `console.error` output
+ // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
+ // problem and how that type was used: key, atrribute, input value prop, etc.
+ // In most cases, this console output also shows the component and its
+ // ancestor components where the exception happened.
+ //
+ // eslint-disable-next-line react-internal/safe-string-coercion
+ return "" + value;
+}
+function checkKeyStringCoercion(value) {
+ {
+ if (willCoercionThrow(value)) {
+ error(
+ "The provided key is an unsupported type %s." +
+ " This value must be coerced to a string before before using it here.",
+ typeName(value)
+ );
+
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
+ }
+ }
+}
+function checkPropStringCoercion(value, propName) {
+ {
+ if (willCoercionThrow(value)) {
+ error(
+ "The provided `%s` prop is an unsupported type %s." +
+ " This value must be coerced to a string before before using it here.",
+ propName,
+ typeName(value)
+ );
+
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
+ }
+ }
+}
+
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
// Resolve default props. Taken from ReactElement
- var props = Object.assign({}, baseProps);
+ var props = assign({}, baseProps);
var defaultProps = Component.defaultProps;
for (var propName in defaultProps) {
@@ -6598,10 +6885,12 @@ function popProvider(context, providerFiber) {
pop(valueCursor, providerFiber);
{
- context._currentValue = currentValue;
+ {
+ context._currentValue = currentValue;
+ }
}
}
-function scheduleWorkOnParentPath(parent, renderLanes) {
+function scheduleContextWorkOnParentPath(parent, renderLanes, propagationRoot) {
// Update the child lanes of all the ancestors, including the alternates.
var node = parent;
@@ -6619,14 +6908,23 @@ function scheduleWorkOnParentPath(parent, renderLanes) {
!isSubsetOfLanes(alternate.childLanes, renderLanes)
) {
alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
- } else {
- // Neither alternate was updated, which means the rest of the
- // ancestor path already has sufficient priority.
+ }
+
+ if (node === propagationRoot) {
break;
}
node = node.return;
}
+
+ {
+ if (node !== propagationRoot) {
+ error(
+ "Expected to find the propagation root when scheduling context work. " +
+ "This error is likely caused by a bug in React. Please file an issue."
+ );
+ }
+ }
}
function propagateContextChange(workInProgress, context, renderLanes) {
{
@@ -6691,7 +6989,11 @@ function propagateContextChange_eager(workInProgress, context, renderLanes) {
alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
}
- scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too.
+ scheduleContextWorkOnParentPath(
+ fiber.return,
+ renderLanes,
+ workInProgress
+ ); // Mark the updated lanes on the list, too.
list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the
// dependency list.
@@ -6785,9 +7087,12 @@ function readContext(context) {
};
if (lastContextDependency === null) {
- if (!(currentlyRenderingFiber !== null)) {
- throw Error(
- "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
+ if (currentlyRenderingFiber === null) {
+ throw new Error(
+ "Context can only be read while React is rendering. " +
+ "In classes, you can read it in the render method or getDerivedStateFromProps. " +
+ "In function components, you can read it directly in the function body, but not " +
+ "inside Hooks like useReducer() or useMemo()."
);
} // This is the first dependency for this component. Create a new list.
@@ -7127,7 +7432,7 @@ function getStateFromUpdate(
return prevState;
} // Merge the partial state and the previous state.
- return Object.assign({}, prevState, partialState);
+ return assign({}, prevState, partialState);
}
case ForceUpdate: {
@@ -7335,10 +7640,10 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) {
}
function callCallback(callback, context) {
- if (!(typeof callback === "function")) {
- throw Error(
- "Invalid argument passed as callback. Expected a function. Instead received: " +
- callback
+ if (typeof callback !== "function") {
+ throw new Error(
+ "Invalid argument passed as callback. Expected a function. Instead " +
+ ("received: " + callback)
);
}
@@ -7437,11 +7742,14 @@ var didWarnAboutInvalidateContextType;
Object.defineProperty(fakeInternalInstance, "_processChildContext", {
enumerable: false,
value: function() {
- {
- throw Error(
- "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)."
- );
- }
+ throw new Error(
+ "_processChildContext is not available in React 16+. This likely " +
+ "means you have multiple copies of React and are attempting to nest " +
+ "a React 15 tree inside a React 16 tree using " +
+ "unstable_renderSubtreeIntoContainer, which isn't supported. Try " +
+ "to make sure you have only one copy of React (and ideally, switch " +
+ "to ReactDOM.createPortal)."
+ );
}
});
Object.freeze(fakeInternalInstance);
@@ -7454,7 +7762,6 @@ function applyDerivedStateFromProps(
nextProps
) {
var prevState = workInProgress.memoizedState;
-
var partialState = getDerivedStateFromProps(nextProps, prevState);
{
@@ -7464,7 +7771,7 @@ function applyDerivedStateFromProps(
var memoizedState =
partialState === null || partialState === undefined
? prevState
- : Object.assign({}, prevState, partialState);
+ : assign({}, prevState, partialState);
workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
// base state.
@@ -7879,9 +8186,10 @@ function constructClassInstance(workInProgress, ctor, props) {
context = isLegacyContextConsumer
? getMaskedContext(workInProgress, unmaskedContext)
: emptyContextObject;
- } // Instantiate twice to help detect side-effects.
+ }
+
+ var instance = new ctor(props, context); // Instantiate twice to help detect side-effects.
- var instance = new ctor(props, context);
var state = (workInProgress.memoizedState =
instance.state !== null && instance.state !== undefined
? instance.state
@@ -8437,6 +8745,78 @@ function updateClassInstance(
return shouldUpdate;
}
+// TODO: Use the unified fiber stack module instead of this local one?
+// Intentionally not using it yet to derisk the initial implementation, because
+// the way we push/pop these values is a bit unusual. If there's a mistake, I'd
+// rather the ids be wrong than crash the whole reconciler.
+var forkStack = [];
+var forkStackIndex = 0;
+var treeForkProvider = null;
+var treeForkCount = 0;
+var idStack = [];
+var idStackIndex = 0;
+var treeContextProvider = null;
+var treeContextId = 1;
+var treeContextOverflow = "";
+
+function popTreeContext(workInProgress) {
+ // Restore the previous values.
+ // This is a bit more complicated than other context-like modules in Fiber
+ // because the same Fiber may appear on the stack multiple times and for
+ // different reasons. We have to keep popping until the work-in-progress is
+ // no longer at the top of the stack.
+ while (workInProgress === treeForkProvider) {
+ treeForkProvider = forkStack[--forkStackIndex];
+ forkStack[forkStackIndex] = null;
+ treeForkCount = forkStack[--forkStackIndex];
+ forkStack[forkStackIndex] = null;
+ }
+
+ while (workInProgress === treeContextProvider) {
+ treeContextProvider = idStack[--idStackIndex];
+ idStack[idStackIndex] = null;
+ treeContextOverflow = idStack[--idStackIndex];
+ idStack[idStackIndex] = null;
+ treeContextId = idStack[--idStackIndex];
+ idStack[idStackIndex] = null;
+ }
+}
+
+var isHydrating = false;
+
+function prepareToHydrateHostInstance(
+ fiber,
+ rootContainerInstance,
+ hostContext
+) {
+ {
+ throw new 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 new 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;
+}
+
var didWarnAboutMaps;
var didWarnAboutGenerators;
var didWarnAboutStringRefs;
@@ -8467,9 +8847,10 @@ var warnForMissingKey = function(child, returnFiber) {};
return;
}
- if (!(typeof child._store === "object")) {
- throw Error(
- "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue."
+ if (typeof child._store !== "object") {
+ throw new Error(
+ "React Component in warnForMissingKey should have a _store. " +
+ "This error is likely caused by a bug in React. Please file an issue."
);
}
@@ -8538,9 +8919,12 @@ function coerceRef(returnFiber, current, element) {
if (owner) {
var ownerFiber = owner;
- if (!(ownerFiber.tag === ClassComponent)) {
- throw Error(
- "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
+ if (ownerFiber.tag !== ClassComponent) {
+ throw new Error(
+ "Function components cannot have string refs. " +
+ "We recommend using useRef() instead. " +
+ "Learn more about using refs safely here: " +
+ "https://reactjs.org/link/strict-mode-string-ref"
);
}
@@ -8548,11 +8932,18 @@ function coerceRef(returnFiber, current, element) {
}
if (!inst) {
- throw Error(
+ throw new Error(
"Missing owner for string ref " +
mixedRef +
- ". This error is likely caused by a bug in React. Please file an issue."
+ ". This error is likely caused by a " +
+ "bug in React. Please file an issue."
);
+ } // Assigning this to a const so Flow knows it won't change in the closure
+
+ var resolvedInst = inst;
+
+ {
+ checkPropStringCoercion(mixedRef, "ref");
}
var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref
@@ -8567,11 +8958,11 @@ function coerceRef(returnFiber, current, element) {
}
var ref = function(value) {
- var refs = inst.refs;
+ var refs = resolvedInst.refs;
if (refs === emptyRefsObject) {
// This is a lazy pooled frozen object, so we need to initialize.
- refs = inst.refs = {};
+ refs = resolvedInst.refs = {};
}
if (value === null) {
@@ -8584,17 +8975,22 @@ function coerceRef(returnFiber, current, element) {
ref._stringRef = stringRef;
return ref;
} else {
- if (!(typeof mixedRef === "string")) {
- throw Error(
+ if (typeof mixedRef !== "string") {
+ throw new Error(
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
);
}
if (!element._owner) {
- throw Error(
+ throw new Error(
"Element ref was specified as a string (" +
mixedRef +
- ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
+ ") but no owner was set. This could happen for one of" +
+ " the following reasons:\n" +
+ "1. You may be adding a ref to a function component\n" +
+ "2. You may be adding a ref to a component that was not created inside a component's render method\n" +
+ "3. You have multiple copies of React loaded\n" +
+ "See https://reactjs.org/link/refs-must-have-owner for more information."
);
}
}
@@ -8605,16 +9001,15 @@ function coerceRef(returnFiber, current, element) {
function throwOnInvalidObjectType(returnFiber, newChild) {
var childString = Object.prototype.toString.call(newChild);
-
- {
- throw Error(
- "Objects are not valid as a React child (found: " +
- (childString === "[object Object]"
- ? "object with keys {" + Object.keys(newChild).join(", ") + "}"
- : childString) +
- "). If you meant to render a collection of children, use an array instead."
- );
- }
+ throw new Error(
+ "Objects are not valid as a React child (found: " +
+ (childString === "[object Object]"
+ ? "object with keys {" + Object.keys(newChild).join(", ") + "}"
+ : childString) +
+ "). " +
+ "If you meant to render a collection of children, use an array " +
+ "instead."
+ );
}
function warnOnFunctionType(returnFiber) {
@@ -8705,7 +9100,9 @@ function ChildReconciler(shouldTrackSideEffects) {
newFiber.index = newIndex;
if (!shouldTrackSideEffects) {
- // Noop.
+ // During hydration, the useId algorithm needs to know which fibers are
+ // part of a list of children (arrays, iterators).
+ newFiber.flags |= Forked;
return lastPlacedIndex;
}
@@ -8834,7 +9231,10 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function createChild(returnFiber, newChild, lanes) {
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ 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.
@@ -8897,7 +9297,10 @@ function ChildReconciler(shouldTrackSideEffects) {
// Update the fiber if the keys match, otherwise return null.
var key = oldFiber !== null ? oldFiber.key : null;
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ 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.
@@ -8954,7 +9357,10 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild,
lanes
) {
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ 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;
@@ -9145,6 +9551,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (newIdx === newChildren.length) {
// We've reached the end of the new children. We can delete the rest.
deleteRemainingChildren(returnFiber, oldFiber);
+
return resultingFirstChild;
}
@@ -9230,9 +9637,10 @@ function ChildReconciler(shouldTrackSideEffects) {
// but using the iterator instead.
var iteratorFn = getIteratorFn(newChildrenIterable);
- if (!(typeof iteratorFn === "function")) {
- throw Error(
- "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue."
+ if (typeof iteratorFn !== "function") {
+ throw new Error(
+ "An object is not an iterable. This error is likely caused by a bug in " +
+ "React. Please file an issue."
);
}
@@ -9284,8 +9692,8 @@ function ChildReconciler(shouldTrackSideEffects) {
var newChildren = iteratorFn.call(newChildrenIterable);
- if (!(newChildren != null)) {
- throw Error("An iterable object provided no iterator.");
+ if (newChildren == null) {
+ throw new Error("An iterable object provided no iterator.");
}
var resultingFirstChild = null;
@@ -9350,6 +9758,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (step.done) {
// We've reached the end of the new children. We can delete the rest.
deleteRemainingChildren(returnFiber, oldFiber);
+
return resultingFirstChild;
}
@@ -9636,7 +10045,10 @@ function ChildReconciler(shouldTrackSideEffects) {
throwOnInvalidObjectType(returnFiber, newChild);
}
- if (typeof newChild === "string" || typeof newChild === "number") {
+ if (
+ (typeof newChild === "string" && newChild !== "") ||
+ typeof newChild === "number"
+ ) {
return placeSingleChild(
reconcileSingleTextNode(
returnFiber,
@@ -9651,38 +10063,6 @@ function ChildReconciler(shouldTrackSideEffects) {
if (typeof newChild === "function") {
warnOnFunctionType(returnFiber);
}
- }
-
- if (typeof newChild === "undefined" && !isUnkeyedTopLevelFragment) {
- // If the new child is undefined, and the return fiber is a composite
- // component, throw an error. If Fiber return types are disabled,
- // we already threw above.
- switch (returnFiber.tag) {
- case ClassComponent: {
- {
- var instance = returnFiber.stateNode;
-
- if (instance.render._isMockFunction) {
- // We allow auto-mocks to proceed as if they're returning null.
- break;
- }
- }
- }
- // Intentionally fall through to the next case, which handles both
- // functions and classes
- // eslint-disable-next-lined no-fallthrough
-
- case FunctionComponent:
- case ForwardRef:
- case SimpleMemoComponent: {
- {
- throw Error(
- (getComponentNameFromFiber(returnFiber) || "Component") +
- "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."
- );
- }
- }
- }
} // Remaining cases are all treated as empty.
return deleteRemainingChildren(returnFiber, currentFirstChild);
@@ -9694,8 +10074,8 @@ function ChildReconciler(shouldTrackSideEffects) {
var reconcileChildFibers = ChildReconciler(true);
var mountChildFibers = ChildReconciler(false);
function cloneChildFibers(current, workInProgress) {
- if (!(current === null || workInProgress.child === current.child)) {
- throw Error("Resuming work not yet implemented.");
+ if (current !== null && workInProgress.child !== current.child) {
+ throw new Error("Resuming work not yet implemented.");
}
if (workInProgress.child === null) {
@@ -9734,9 +10114,10 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT);
var rootInstanceStackCursor = createCursor(NO_CONTEXT);
function requiredContext(c) {
- if (!(c !== NO_CONTEXT)) {
- throw Error(
- "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."
+ if (c === NO_CONTEXT) {
+ throw new Error(
+ "Expected host context to exist. This error is likely caused by a bug " +
+ "in React. Please file an issue."
);
}
@@ -9855,22 +10236,11 @@ function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
return false;
}
- var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
-
- if (props.fallback === undefined) {
- return false;
- } // Regular boundaries always capture.
+ var props = workInProgress.memoizedProps; // Regular boundaries always capture.
- if (props.unstable_avoidThisFallback !== true) {
+ {
return true;
} // If it's a boundary we should avoid, then we prefer to bubble up to the
- // parent boundary if it is currently invisible.
-
- if (hasInvisibleParent) {
- return false;
- } // If the parent is not able to handle it, we must handle it.
-
- return true;
}
function findFirstSuspended(row) {
var node = row;
@@ -9925,63 +10295,28 @@ function findFirstSuspended(row) {
return null;
}
-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();
-}
+var NoFlags$1 =
+ /* */
+ 0; // Represents whether effect should fire.
-function popHydrationState(fiber) {
- {
- return false;
- }
-}
+var HasEffect =
+ /* */
+ 1; // Represents the phase in which the effect (not the clean-up) fires.
-function getIsHydrating() {
- return isHydrating;
-}
+var Insertion =
+ /* */
+ 2;
+var Layout =
+ /* */
+ 4;
+var Passive$1 =
+ /* */
+ 8;
// 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];
@@ -9993,46 +10328,13 @@ function resetWorkInProgressVersions() {
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.
-
-function getSuspendedCachePool() {
- {
- return null;
- } // We check the cache on the stack first, since that's the one any new Caches
-}
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
var didWarnAboutMismatchedHooksForComponent;
-var didWarnAboutUseOpaqueIdentifier;
+var didWarnUncachedGetSnapshot;
{
- didWarnAboutUseOpaqueIdentifier = {};
didWarnAboutMismatchedHooksForComponent = new Set();
}
@@ -10056,7 +10358,11 @@ var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only
// TODO: Maybe there's some way to consolidate this with
// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`.
-var didScheduleRenderPhaseUpdateDuringThisPass = false;
+var didScheduleRenderPhaseUpdateDuringThisPass = false; // Counts the number of useId hooks in this component.
+// hydration). This counter is global, so client ids are not stable across
+// render attempts.
+
+var globalClientIdCounter = 0;
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.
@@ -10154,11 +10460,14 @@ function warnOnHookMismatchInDev(currentHookName) {
}
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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
- );
- }
+ throw new 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:\n" +
+ "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" +
+ "2. You might be breaking the Rules of Hooks\n" +
+ "3. You might have more than one copy of React in the same app\n" +
+ "See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
+ );
}
function areHookInputsEqual(nextDeps, prevDeps) {
@@ -10234,6 +10543,7 @@ function renderWithHooks(
// currentHook = null;
// workInProgressHook = null;
// didScheduleRenderPhaseUpdate = false;
+ // localIdCounter = 0;
// TODO Warn if no hooks are used at all during mount, then some are used during update.
// Currently we will identify the update render as a mount because memoizedState === null.
// This is tricky because it's valid for certain types of components (e.g. React.lazy)
@@ -10266,9 +10576,10 @@ function renderWithHooks(
do {
didScheduleRenderPhaseUpdateDuringThisPass = false;
- if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
- throw Error(
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
+ if (numberOfReRenders >= RE_RENDER_LIMIT) {
+ throw new Error(
+ "Too many re-renders. React limits the number of renders to prevent " +
+ "an infinite loop."
);
}
@@ -10293,7 +10604,7 @@ function renderWithHooks(
children = Component(props, secondArg);
} 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.
+ // at the beginning of the render phase and there's no re-entrance.
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -10332,11 +10643,13 @@ function renderWithHooks(
}
}
- didScheduleRenderPhaseUpdate = false;
+ didScheduleRenderPhaseUpdate = false; // This is reset by checkDidRenderIdHook
+ // localIdCounter = 0;
- if (!!didRenderTooFewHooks) {
- throw Error(
- "Rendered fewer hooks than expected. This may be caused by an accidental early return statement."
+ if (didRenderTooFewHooks) {
+ throw new Error(
+ "Rendered fewer hooks than expected. This may be caused by an accidental " +
+ "early return statement."
);
}
@@ -10354,7 +10667,7 @@ function bailoutHooks(current, workInProgress, 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.
+ // at the beginning of the render phase and there's no re-entrance.
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
if (didScheduleRenderPhaseUpdate) {
@@ -10451,8 +10764,8 @@ function updateWorkInProgressHook() {
currentHook = nextCurrentHook;
} else {
// Clone from the current hook.
- if (!(nextCurrentHook !== null)) {
- throw Error("Rendered more hooks than during the previous render.");
+ if (nextCurrentHook === null) {
+ throw new Error("Rendered more hooks than during the previous render.");
}
currentHook = nextCurrentHook;
@@ -10478,7 +10791,8 @@ function updateWorkInProgressHook() {
function createFunctionComponentUpdateQueue() {
return {
- lastEffect: null
+ lastEffect: null,
+ stores: null
};
}
@@ -10498,15 +10812,16 @@ function mountReducer(reducer, initialArg, init) {
}
hook.memoizedState = hook.baseState = initialState;
- var queue = (hook.queue = {
+ var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: reducer,
lastRenderedState: initialState
- });
- var dispatch = (queue.dispatch = dispatchAction.bind(
+ };
+ hook.queue = queue;
+ var dispatch = (queue.dispatch = dispatchReducerAction.bind(
null,
currentlyRenderingFiber$1,
queue
@@ -10518,8 +10833,8 @@ function updateReducer(reducer, initialArg, init) {
var hook = updateWorkInProgressHook();
var queue = hook.queue;
- if (!(queue !== null)) {
- throw Error(
+ if (queue === null) {
+ throw new Error(
"Should have a queue. This is likely a bug in React. Please file an issue."
);
}
@@ -10576,7 +10891,7 @@ function updateReducer(reducer, initialArg, init) {
var clone = {
lane: updateLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
@@ -10604,16 +10919,16 @@ function updateReducer(reducer, initialArg, init) {
// this will never be skipped by the check above.
lane: NoLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
newBaseQueueLast = newBaseQueueLast.next = _clone;
} // Process this update.
- if (update.eagerReducer === reducer) {
- // If this update was processed eagerly, and its reducer matches the
- // current reducer, we can use the eagerly computed state.
+ if (update.hasEagerState) {
+ // If this update is a state update (not a reducer) and was processed eagerly,
+ // we can use the eagerly computed state
newState = update.eagerState;
} else {
var action = update.action;
@@ -10671,8 +10986,8 @@ function rerenderReducer(reducer, initialArg, init) {
var hook = updateWorkInProgressHook();
var queue = hook.queue;
- if (!(queue !== null)) {
- throw Error(
+ if (queue === null) {
+ throw new Error(
"Should have a queue. This is likely a bug in React. Please file an issue."
);
}
@@ -10719,290 +11034,221 @@ function rerenderReducer(reducer, initialArg, init) {
return [newState, dispatch];
}
-function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
+function mountMutableSource(source, getSnapshot, subscribe) {
+ {
+ return undefined;
+ }
+}
+
+function updateMutableSource(source, getSnapshot, subscribe) {
{
- warnAboutMultipleRenderersDEV(source);
+ return undefined;
}
+}
+
+function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
+ var fiber = currentlyRenderingFiber$1;
+ var hook = mountWorkInProgressHook();
+ var nextSnapshot;
- var getVersion = source._getVersion;
- var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render?
+ {
+ nextSnapshot = getSnapshot();
- 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.
+ {
+ if (!didWarnUncachedGetSnapshot) {
+ var cachedSnapshot = getSnapshot();
- var currentRenderVersion = getWorkInProgressVersion(source);
+ if (!objectIs(nextSnapshot, cachedSnapshot)) {
+ error(
+ "The result of getSnapshot should be cached to avoid an infinite loop"
+ );
- 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.
+ didWarnUncachedGetSnapshot = true;
+ }
+ }
+ } // Unless we're rendering a blocking lane, schedule a consistency check.
+ // Right before committing, we will walk the tree and check if any of the
+ // stores were mutated.
//
- // 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
- );
+ // We won't do this if we're hydrating server-rendered content, because if
+ // the content is stale, it's already visible anyway. Instead we'll patch
+ // it up in a passive effect.
+
+ var root = getWorkInProgressRoot();
- 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 (root === null) {
+ throw new Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
}
- }
- if (isSafeToReadFromSource) {
- var snapshot = getSnapshot(source._source);
+ if (!includesBlockingLane(root, renderLanes)) {
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ } // Read the current snapshot from the store on every render. This breaks the
+ // normal rules of React, and only works because store updates are
+ // always synchronous.
- {
- 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."
- );
- }
- }
+ hook.memoizedState = nextSnapshot;
+ var inst = {
+ value: nextSnapshot,
+ getSnapshot: getSnapshot
+ };
+ hook.queue = inst; // Schedule an effect to subscribe to the store.
+
+ mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); // Schedule an effect to update the mutable instance fields. We will update
+ // this whenever subscribe, getSnapshot, or value changes. Because there's no
+ // clean-up function, and we track the deps correctly, we can call pushEffect
+ // directly, without storing any additional state. For the same reason, we
+ // don't need to set a static flag, either.
+ // TODO: We can move this to the passive phase once we add a pre-commit
+ // consistency check. See the next comment.
+
+ fiber.flags |= Passive;
+ pushEffect(
+ HasEffect | Passive$1,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ undefined,
+ null
+ );
+ return nextSnapshot;
+}
- 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); // Intentioally throw an error to force React to retry synchronously. During
- // the synchronous retry, it will block interleaved mutations, so we should
- // get a consistent read. Therefore, the following error should never be
- // visible to the user.
- //
- // If it were to become visible to the user, it suggests one of two things:
- // a bug in React, or (more likely), a mutation during the render phase that
- // caused the second re-render attempt to be different from the first.
- //
- // We know it's the second case if the logs are currently disabled. So in
- // dev, we can present a more accurate error message.
+function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
+ var fiber = currentlyRenderingFiber$1;
+ var hook = updateWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the
+ // normal rules of React, and only works because store updates are
+ // always synchronous.
- {
- // eslint-disable-next-line react-internal/no-production-logging
- if (console.log.__reactDisabledLog) {
- // If the logs are disabled, this is the dev-only double render. This is
- // only reachable if there was a mutation during render. Show a helpful
- // error message.
- //
- // Something interesting to note: because we only double render in
- // development, this error will never happen during production. This is
- // actually true of all errors that occur during a double render,
- // because if the first render had thrown, we would have exited the
- // begin phase without double rendering. We should consider suppressing
- // any error from a double render (with a warning) to more closely match
- // the production behavior.
- var componentName = getComponentNameFromFiber(
- currentlyRenderingFiber$1
+ var nextSnapshot = getSnapshot();
+
+ {
+ if (!didWarnUncachedGetSnapshot) {
+ var cachedSnapshot = getSnapshot();
+
+ if (!objectIs(nextSnapshot, cachedSnapshot)) {
+ error(
+ "The result of getSnapshot should be cached to avoid an infinite loop"
);
- {
- throw Error(
- "A mutable source was mutated while the " +
- componentName +
- " component was rendering. This is not supported. Move any mutations into event handlers or effects."
- );
- }
+ didWarnUncachedGetSnapshot = true;
}
- } // We expect this error not to be thrown during the synchronous retry,
- // because we blocked interleaved mutations.
-
- {
- throw Error(
- "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue."
- );
}
}
-}
-function useMutableSource(hook, source, getSnapshot, subscribe) {
- var root = getWorkInProgressRoot();
+ var prevSnapshot = hook.memoizedState;
+ var snapshotChanged = !objectIs(prevSnapshot, nextSnapshot);
- if (!(root !== null)) {
- throw Error(
- "Expected a work-in-progress root. This is a bug in React. Please file an issue."
- );
+ if (snapshotChanged) {
+ hook.memoizedState = nextSnapshot;
+ markWorkInProgressReceivedUpdate();
}
- 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.
+ var inst = hook.queue;
+ updateEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [
+ subscribe
+ ]); // Whenever getSnapshot or subscribe changes, we need to check in the
+ // commit phase if there was an interleaved mutation. In concurrent mode
+ // this can happen all the time, but even in synchronous mode, an earlier
+ // effect may have mutated the store.
- 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.
+ if (
+ inst.getSnapshot !== getSnapshot ||
+ snapshotChanged || // Check if the susbcribe function changed. We can save some memory by
+ // checking whether we scheduled a subscription effect above.
+ (workInProgressHook !== null &&
+ workInProgressHook.memoizedState.tag & HasEffect)
+ ) {
+ fiber.flags |= Passive;
+ pushEffect(
+ HasEffect | Passive$1,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ undefined,
+ null
+ ); // Unless we're rendering a blocking lane, schedule a consistency check.
+ // Right before committing, we will walk the tree and check if any of the
+ // stores were mutated.
- refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now.
+ var root = getWorkInProgressRoot();
- var maybeNewVersion = getVersion(source._source);
+ if (root === null) {
+ throw new Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ }
- if (!objectIs(version, maybeNewVersion)) {
- var maybeNewSnapshot = getSnapshot(source._source);
+ if (!includesBlockingLane(root, renderLanes)) {
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ }
- {
- 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."
- );
- }
- }
+ return nextSnapshot;
+}
- if (!objectIs(snapshot, maybeNewSnapshot)) {
- setSnapshot(maybeNewSnapshot);
- var lane = requestUpdateLane(fiber);
- 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.
+function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
+ fiber.flags |= StoreConsistency;
+ var check = {
+ getSnapshot: getSnapshot,
+ value: renderedSnapshot
+ };
+ var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
- markRootEntangled(root, root.mutableReadLanes);
- }
- },
- [getSnapshot, source, subscribe]
- ); // If we got a new source or subscribe function, re-subscribe in a passive effect.
+ if (componentUpdateQueue === null) {
+ componentUpdateQueue = createFunctionComponentUpdateQueue();
+ currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
+ componentUpdateQueue.stores = [check];
+ } else {
+ var stores = componentUpdateQueue.stores;
- dispatcher.useEffect(
- function() {
- var handleChange = function() {
- var latestGetSnapshot = refs.getSnapshot;
- var latestSetSnapshot = refs.setSnapshot;
+ if (stores === null) {
+ componentUpdateQueue.stores = [check];
+ } else {
+ stores.push(check);
+ }
+ }
+}
- try {
- latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time.
+function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
+ // These are updated in the passive phase
+ inst.value = nextSnapshot;
+ inst.getSnapshot = getSnapshot; // Something may have been mutated in between render and commit. This could
+ // have been in an event that fired before the passive effects, or it could
+ // have been in a layout effect. In that case, we would have used the old
+ // snapsho and getSnapshot values to bail out. We need to check one more time.
- var lane = requestUpdateLane(fiber);
- 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;
- });
- }
- };
+ if (checkIfSnapshotChanged(inst)) {
+ // Force a re-render.
+ forceStoreRerender(fiber);
+ }
+}
- var unsubscribe = subscribe(source._source, handleChange);
+function subscribeToStore(fiber, inst, subscribe) {
+ var handleStoreChange = function() {
+ // The store changed. Check if the snapshot changed since the last time we
+ // read from the store.
+ if (checkIfSnapshotChanged(inst)) {
+ // Force a re-render.
+ forceStoreRerender(fiber);
+ }
+ }; // Subscribe to the store and return a clean-up function.
- {
- if (typeof unsubscribe !== "function") {
- error(
- "Mutable source subscribe function must return an unsubscribe function."
- );
- }
- }
+ return subscribe(handleStoreChange);
+}
- 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.
+function checkIfSnapshotChanged(inst) {
+ var latestGetSnapshot = inst.getSnapshot;
+ var prevValue = inst.value;
- 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,
- interleaved: null,
- lanes: NoLanes,
- 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;
+ try {
+ var nextValue = latestGetSnapshot();
+ return !objectIs(prevValue, nextValue);
+ } catch (error) {
+ return true;
}
-
- 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 forceStoreRerender(fiber) {
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
function mountState(initialState) {
@@ -11014,15 +11260,16 @@ function mountState(initialState) {
}
hook.memoizedState = hook.baseState = initialState;
- var queue = (hook.queue = {
+ var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
- });
- var dispatch = (queue.dispatch = dispatchAction.bind(
+ };
+ hook.queue = queue;
+ var dispatch = (queue.dispatch = dispatchSetState.bind(
null,
currentlyRenderingFiber$1,
queue
@@ -11127,29 +11374,23 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
}
function mountEffect(create, deps) {
- {
- // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ("undefined" !== typeof jest) {
- warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
- }
- }
-
{
return mountEffectImpl(Passive | PassiveStatic, Passive$1, create, deps);
}
}
function updateEffect(create, deps) {
- {
- // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ("undefined" !== typeof jest) {
- warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
- }
- }
-
return updateEffectImpl(Passive, Passive$1, create, deps);
}
+function mountInsertionEffect(create, deps) {
+ return mountEffectImpl(Update, Insertion, create, deps);
+}
+
+function updateInsertionEffect(create, deps) {
+ return updateEffectImpl(Update, Insertion, create, deps);
+}
+
function mountLayoutEffect(create, deps) {
var fiberFlags = Update;
@@ -11307,7 +11548,7 @@ function mountDeferredValue(value) {
mountEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
@@ -11328,7 +11569,7 @@ function updateDeferredValue(value) {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
@@ -11349,7 +11590,7 @@ function rerenderDeferredValue(value) {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
@@ -11362,14 +11603,19 @@ function rerenderDeferredValue(value) {
return prevValue;
}
-function startTransition(setPending, callback) {
+function startTransition(setPending, callback, options) {
var previousPriority = getCurrentUpdatePriority();
setCurrentUpdatePriority(
higherEventPriority(previousPriority, ContinuousEventPriority)
);
setPending(true);
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
+ var currentTransition = ReactCurrentBatchConfig$1.transition;
+
+ {
+ ReactCurrentBatchConfig$1.transition._updatedFibers = new Set();
+ }
try {
setPending(false);
@@ -11377,6 +11623,22 @@ function startTransition(setPending, callback) {
} finally {
setCurrentUpdatePriority(previousPriority);
ReactCurrentBatchConfig$1.transition = prevTransition;
+
+ {
+ if (prevTransition === null && currentTransition._updatedFibers) {
+ var updatedFibersCount = currentTransition._updatedFibers.size;
+
+ if (updatedFibersCount > 10) {
+ warn(
+ "Detected a large number of updates inside startTransition. " +
+ "If this is due to a subscription please re-write it to use React provided hooks. " +
+ "Otherwise concurrent mode guarantees are off the table."
+ );
+ }
+
+ currentTransition._updatedFibers.clear();
+ }
+ }
}
}
@@ -11416,48 +11678,34 @@ function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
}
}
-function warnOnOpaqueIdentifierAccessInDEV(fiber) {
- {
- // TODO: Should warn in effects and callbacks, too
- var name = getComponentNameFromFiber(fiber) || "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 mountId() {
+ var hook = mountWorkInProgressHook();
+ var root = getWorkInProgressRoot(); // TODO: In Fizz, id generation is specific to each server config. Maybe we
+ // should do this in Fiber, too? Deferring this decision for now because
+ // there's no other place to store the prefix except for an internal field on
+ // the public createRoot object, which the fiber tree does not currently have
+ // a reference to.
-function mountOpaqueIdentifier() {
- var makeId = makeClientIdInDEV.bind(
- null,
- warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)
- );
+ var identifierPrefix = root.identifierPrefix;
+ var id;
{
- var _id = makeId();
-
- mountState(_id);
- return _id;
+ // Use a lowercase r prefix for client-generated ids.
+ var globalClientId = globalClientIdCounter++;
+ id = ":" + identifierPrefix + "r" + globalClientId.toString(32) + ":";
}
-}
-function updateOpaqueIdentifier() {
- var id = updateState()[0];
+ hook.memoizedState = id;
return id;
}
-function rerenderOpaqueIdentifier() {
- var id = rerenderState()[0];
+function updateId() {
+ var hook = updateWorkInProgressHook();
+ var id = hook.memoizedState;
return id;
}
-function dispatchAction(fiber, queue, action) {
+function dispatchReducerAction(fiber, queue, action) {
{
if (typeof arguments[3] === "function") {
error(
@@ -11468,65 +11716,53 @@ function dispatchAction(fiber, queue, action) {
}
}
- var eventTime = requestEventTime();
var lane = requestUpdateLane(fiber);
var update = {
lane: lane,
action: action,
- eagerReducer: null,
+ hasEagerState: false,
eagerState: null,
next: null
};
- var alternate = fiber.alternate;
-
- if (
- fiber === currentlyRenderingFiber$1 ||
- (alternate !== null && alternate === currentlyRenderingFiber$1)
- ) {
- // 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.
- didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
- var pending = queue.pending;
-
- if (pending === null) {
- // This is the first update. Create a circular list.
- update.next = update;
- } else {
- update.next = pending.next;
- pending.next = update;
- }
- queue.pending = update;
+ if (isRenderPhaseUpdate(fiber)) {
+ enqueueRenderPhaseUpdate(queue, update);
} else {
- if (isInterleavedUpdate(fiber)) {
- var interleaved = queue.interleaved;
-
- if (interleaved === null) {
- // This is the first update. Create a circular list.
- update.next = update; // At the end of the current render, this queue's interleaved updates will
- // be transferred to the pending queue.
+ enqueueUpdate$1(fiber, queue, update);
+ var eventTime = requestEventTime();
+ var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
- pushInterleavedQueue(queue);
- } else {
- update.next = interleaved.next;
- interleaved.next = update;
- }
+ if (root !== null) {
+ entangleTransitionUpdate(root, queue, lane);
+ }
+ }
+}
- queue.interleaved = update;
- } else {
- var _pending = queue.pending;
+function dispatchSetState(fiber, queue, action) {
+ {
+ if (typeof arguments[3] === "function") {
+ error(
+ "State updates from the useState() and useReducer() Hooks don't support the " +
+ "second callback argument. To execute a side effect after " +
+ "rendering, declare it in the component body with useEffect()."
+ );
+ }
+ }
- if (_pending === null) {
- // This is the first update. Create a circular list.
- update.next = update;
- } else {
- update.next = _pending.next;
- _pending.next = update;
- }
+ var lane = requestUpdateLane(fiber);
+ var update = {
+ lane: lane,
+ action: action,
+ hasEagerState: false,
+ eagerState: null,
+ next: null
+ };
- queue.pending = update;
- }
+ if (isRenderPhaseUpdate(fiber)) {
+ enqueueRenderPhaseUpdate(queue, update);
+ } else {
+ enqueueUpdate$1(fiber, queue, update);
+ var alternate = fiber.alternate;
if (
fiber.lanes === NoLanes &&
@@ -11552,7 +11788,7 @@ function dispatchAction(fiber, queue, action) {
// time we enter the render phase, then the eager state can be used
// without calling the reducer again.
- update.eagerReducer = lastRenderedReducer;
+ update.hasEagerState = true;
update.eagerState = eagerState;
if (objectIs(eagerState, currentState)) {
@@ -11572,32 +11808,88 @@ function dispatchAction(fiber, queue, action) {
}
}
- {
- // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ("undefined" !== typeof jest) {
- warnIfNotScopedWithMatchingAct(fiber);
- warnIfNotCurrentlyActingUpdatesInDev(fiber);
- }
+ var eventTime = requestEventTime();
+ var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
+
+ if (root !== null) {
+ entangleTransitionUpdate(root, queue, lane);
}
+ }
+}
- var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
+function isRenderPhaseUpdate(fiber) {
+ var alternate = fiber.alternate;
+ return (
+ fiber === currentlyRenderingFiber$1 ||
+ (alternate !== null && alternate === currentlyRenderingFiber$1)
+ );
+}
+
+function enqueueRenderPhaseUpdate(queue, update) {
+ // 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.
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
+ var pending = queue.pending;
- if (isTransitionLane(lane) && root !== null) {
- var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they
- // must have finished. We can remove them from the shared queue, which
- // represents a superset of the actually pending lanes. In some cases we
- // may entangle more than we need to, but that's OK. In fact it's worse if
- // we *don't* entangle when we should.
+ if (pending === null) {
+ // This is the first update. Create a circular list.
+ update.next = update;
+ } else {
+ update.next = pending.next;
+ pending.next = update;
+ }
+
+ queue.pending = update;
+}
+
+function enqueueUpdate$1(fiber, queue, update, lane) {
+ if (isInterleavedUpdate(fiber)) {
+ var interleaved = queue.interleaved;
+
+ if (interleaved === null) {
+ // This is the first update. Create a circular list.
+ update.next = update; // At the end of the current render, this queue's interleaved updates will
+ // be transferred to the pending queue.
- queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes.
+ pushInterleavedQueue(queue);
+ } else {
+ update.next = interleaved.next;
+ interleaved.next = update;
+ }
- var newQueueLanes = mergeLanes(queueLanes, lane);
- queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if
- // the lane finished since the last time we entangled it. So we need to
- // entangle it again, just to be sure.
+ queue.interleaved = update;
+ } else {
+ var pending = queue.pending;
- markRootEntangled(root, newQueueLanes);
+ if (pending === null) {
+ // This is the first update. Create a circular list.
+ update.next = update;
+ } else {
+ update.next = pending.next;
+ pending.next = update;
}
+
+ queue.pending = update;
+ }
+}
+
+function entangleTransitionUpdate(root, queue, lane) {
+ if (isTransitionLane(lane)) {
+ var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they
+ // must have finished. We can remove them from the shared queue, which
+ // represents a superset of the actually pending lanes. In some cases we
+ // may entangle more than we need to, but that's OK. In fact it's worse if
+ // we *don't* entangle when we should.
+
+ queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes.
+
+ var newQueueLanes = mergeLanes(queueLanes, lane);
+ queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if
+ // the lane finished since the last time we entangled it. So we need to
+ // entangle it again, just to be sure.
+
+ markRootEntangled(root, newQueueLanes);
}
}
@@ -11607,6 +11899,7 @@ var ContextOnlyDispatcher = {
useContext: throwInvalidHookError,
useEffect: throwInvalidHookError,
useImperativeHandle: throwInvalidHookError,
+ useInsertionEffect: throwInvalidHookError,
useLayoutEffect: throwInvalidHookError,
useMemo: throwInvalidHookError,
useReducer: throwInvalidHookError,
@@ -11616,7 +11909,8 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
- useOpaqueIdentifier: throwInvalidHookError,
+ useSyncExternalStore: throwInvalidHookError,
+ useId: throwInvalidHookError,
unstable_isNewReconciler: enableNewReconciler
};
@@ -11674,6 +11968,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
checkDepsAreArrayDev(deps);
return mountImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ mountHookTypesDev();
+ checkDepsAreArrayDev(deps);
+ return mountInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
mountHookTypesDev();
@@ -11740,12 +12040,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
mountHookTypesDev();
- return mountMutableSource(source, getSnapshot, subscribe);
+ return mountMutableSource();
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
mountHookTypesDev();
- return mountOpaqueIdentifier();
+ return mountSyncExternalStore(subscribe, getSnapshot);
+ },
+ useId: function() {
+ currentHookNameInDev = "useId";
+ mountHookTypesDev();
+ return mountId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11774,6 +12079,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return mountImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ updateHookTypesDev();
+ return mountInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
updateHookTypesDev();
@@ -11838,12 +12148,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return mountMutableSource(source, getSnapshot, subscribe);
+ return mountMutableSource();
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
- return mountOpaqueIdentifier();
+ return mountSyncExternalStore(subscribe, getSnapshot);
+ },
+ useId: function() {
+ currentHookNameInDev = "useId";
+ updateHookTypesDev();
+ return mountId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11872,6 +12187,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
updateHookTypesDev();
@@ -11936,12 +12256,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
- return updateOpaqueIdentifier();
+ return updateSyncExternalStore(subscribe, getSnapshot);
+ },
+ useId: function() {
+ currentHookNameInDev = "useId";
+ updateHookTypesDev();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -11970,6 +12295,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
updateHookTypesDev();
@@ -12034,12 +12364,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
useMutableSource: function(source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
- return rerenderOpaqueIdentifier();
+ return updateSyncExternalStore(subscribe, getSnapshot);
+ },
+ useId: function() {
+ currentHookNameInDev = "useId";
+ updateHookTypesDev();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -12073,8 +12408,14 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountImperativeHandle(ref, create, deps);
},
- useLayoutEffect: function(create, deps) {
- currentHookNameInDev = "useLayoutEffect";
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ warnInvalidHookAccess();
+ mountHookTypesDev();
+ return mountInsertionEffect(create, deps);
+ },
+ useLayoutEffect: function(create, deps) {
+ currentHookNameInDev = "useLayoutEffect";
warnInvalidHookAccess();
mountHookTypesDev();
return mountLayoutEffect(create, deps);
@@ -12146,13 +12487,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
mountHookTypesDev();
- return mountMutableSource(source, getSnapshot, subscribe);
+ return mountMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ warnInvalidHookAccess();
+ mountHookTypesDev();
+ return mountSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
warnInvalidHookAccess();
mountHookTypesDev();
- return mountOpaqueIdentifier();
+ return mountId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -12186,6 +12533,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
warnInvalidHookAccess();
@@ -12259,13 +12612,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateOpaqueIdentifier();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -12299,6 +12658,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateImperativeHandle(ref, create, deps);
},
+ useInsertionEffect: function(create, deps) {
+ currentHookNameInDev = "useInsertionEffect";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateInsertionEffect(create, deps);
+ },
useLayoutEffect: function(create, deps) {
currentHookNameInDev = "useLayoutEffect";
warnInvalidHookAccess();
@@ -12372,13 +12737,19 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
- return updateMutableSource(source, getSnapshot, subscribe);
+ return updateMutableSource();
+ },
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
+ currentHookNameInDev = "useSyncExternalStore";
+ warnInvalidHookAccess();
+ updateHookTypesDev();
+ return updateSyncExternalStore(subscribe, getSnapshot);
},
- useOpaqueIdentifier: function() {
- currentHookNameInDev = "useOpaqueIdentifier";
+ useId: function() {
+ currentHookNameInDev = "useId";
warnInvalidHookAccess();
updateHookTypesDev();
- return rerenderOpaqueIdentifier();
+ return updateId();
},
unstable_isNewReconciler: enableNewReconciler
};
@@ -12560,12 +12931,10 @@ function createCapturedValue(value, source) {
}
if (
- !(
- typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog ===
- "function"
- )
+ typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog !==
+ "function"
) {
- throw Error(
+ throw new Error(
"Expected ReactFiberErrorDialog.showErrorDialog to be a function."
);
}
@@ -12694,9 +13063,16 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
var error$1 = errorInfo.value;
update.payload = function() {
- logCapturedError(fiber, errorInfo);
return getDerivedStateFromError(error$1);
};
+
+ update.callback = function() {
+ {
+ markFailedErrorBoundaryForHotReloading(fiber);
+ }
+
+ logCapturedError(fiber, errorInfo);
+ };
}
var inst = fiber.stateNode;
@@ -12707,15 +13083,15 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
markFailedErrorBoundaryForHotReloading(fiber);
}
+ logCapturedError(fiber, errorInfo);
+
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);
+ markLegacyErrorBoundaryAsFailed(this);
}
var error$1 = errorInfo.value;
@@ -12739,19 +13115,24 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
}
}
};
- } 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).
+ // Attach a ping listener
+ //
+ // The data might resolve before we have a chance to commit the fallback. Or,
+ // in the case of a refresh, we'll never commit a fallback. So we need to
+ // attach a listener now. When it resolves ("pings"), we can decide whether to
+ // try rendering the tree again.
+ //
+ // Only attach a listener if one does not already exist for the lanes
+ // we're currently rendering (which acts like a "thread ID" here).
+ //
+ // We only need to do this in concurrent mode. Legacy Suspense always
+ // commits fallbacks synchronously, so there are no pings.
var pingCache = root.pingCache;
var threadIDs;
@@ -12784,6 +13165,180 @@ function attachPingListener(root, wakeable, lanes) {
}
}
+function attachRetryListener(suspenseBoundary, root, wakeable, lanes) {
+ // Retry listener
+ //
+ // If the fallback does commit, we need to attach a different type of
+ // listener. This one schedules an update on the Suspense boundary to turn
+ // the fallback state off.
+ //
+ // Stash the wakeable on the boundary fiber so we can access it in the
+ // commit phase.
+ //
+ // When the wakeable resolves, we'll attempt to render the boundary
+ // again ("retry").
+ var wakeables = suspenseBoundary.updateQueue;
+
+ if (wakeables === null) {
+ var updateQueue = new Set();
+ updateQueue.add(wakeable);
+ suspenseBoundary.updateQueue = updateQueue;
+ } else {
+ wakeables.add(wakeable);
+ }
+}
+
+function resetSuspendedComponent(sourceFiber, rootRenderLanes) {
+ // A legacy mode Suspense quirk, only relevant to hook components.
+
+ var tag = sourceFiber.tag;
+
+ if (
+ (sourceFiber.mode & ConcurrentMode) === NoMode &&
+ (tag === FunctionComponent ||
+ tag === ForwardRef ||
+ tag === SimpleMemoComponent)
+ ) {
+ var currentSource = sourceFiber.alternate;
+
+ if (currentSource) {
+ sourceFiber.updateQueue = currentSource.updateQueue;
+ sourceFiber.memoizedState = currentSource.memoizedState;
+ sourceFiber.lanes = currentSource.lanes;
+ } else {
+ sourceFiber.updateQueue = null;
+ sourceFiber.memoizedState = null;
+ }
+ }
+}
+
+function getNearestSuspenseBoundaryToCapture(returnFiber) {
+ var node = returnFiber;
+
+ do {
+ if (node.tag === SuspenseComponent && shouldCaptureSuspense(node)) {
+ return node;
+ } // This boundary already captured during this render. Continue to the next
+ // boundary.
+
+ node = node.return;
+ } while (node !== null);
+
+ return null;
+}
+
+function markSuspenseBoundaryShouldCapture(
+ suspenseBoundary,
+ returnFiber,
+ sourceFiber,
+ root,
+ rootRenderLanes
+) {
+ // This marks a Suspense boundary so that when we're unwinding the stack,
+ // it captures the suspended "exception" and does a second (fallback) pass.
+ if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) {
+ // Legacy Mode Suspense
+ //
+ // If the boundary is in legacy mode, we should *not*
+ // suspend the commit. Pretend as if the suspended component rendered
+ // null and keep rendering. When the Suspense boundary completes,
+ // we'll do a second pass to render the fallback.
+ if (suspenseBoundary === returnFiber) {
+ // Special case where we suspended while reconciling the children of
+ // a Suspense boundary's inner Offscreen wrapper fiber. This happens
+ // when a React.lazy component is a direct child of a
+ // Suspense boundary.
+ //
+ // Suspense boundaries are implemented as multiple fibers, but they
+ // are a single conceptual unit. The legacy mode behavior where we
+ // pretend the suspended fiber committed as `null` won't work,
+ // because in this case the "suspended" fiber is the inner
+ // Offscreen wrapper.
+ //
+ // Because the contents of the boundary haven't started rendering
+ // yet (i.e. nothing in the tree has partially rendered) we can
+ // switch to the regular, concurrent mode behavior: mark the
+ // boundary with ShouldCapture and enter the unwind phase.
+ suspenseBoundary.flags |= ShouldCapture;
+ } else {
+ suspenseBoundary.flags |= DidCapture;
+ sourceFiber.flags |= 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.
+
+ sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
+
+ if (sourceFiber.tag === ClassComponent) {
+ var currentSourceFiber = sourceFiber.alternate;
+
+ 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);
+ 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.
+
+ sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane);
+ }
+
+ return suspenseBoundary;
+ } // 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. Transitions apply
+ // 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.
+
+ suspenseBoundary.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in
+ // the begin phase to prevent an early bailout.
+
+ suspenseBoundary.lanes = rootRenderLanes;
+ return suspenseBoundary;
+}
+
function throwException(
root,
returnFiber,
@@ -12806,163 +13361,62 @@ function throwException(
typeof value === "object" &&
typeof value.then === "function"
) {
+ // This is a wakeable. The component suspended.
var wakeable = value;
- // A legacy mode Suspense quirk, only relevant to hook components.
+ resetSuspendedComponent(sourceFiber);
- var tag = sourceFiber.tag;
+ var suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
- if (
- (sourceFiber.mode & ConcurrentMode) === NoMode &&
- (tag === FunctionComponent ||
- tag === ForwardRef ||
- tag === SimpleMemoComponent)
- ) {
- var currentSource = sourceFiber.alternate;
+ if (suspenseBoundary !== null) {
+ suspenseBoundary.flags &= ~ForceClientRender;
+ markSuspenseBoundaryShouldCapture(
+ suspenseBoundary,
+ returnFiber,
+ sourceFiber,
+ root,
+ rootRenderLanes
+ ); // We only attach ping listeners in concurrent mode. Legacy Suspense always
+ // commits fallbacks synchronously, so there are no pings.
- if (currentSource) {
- sourceFiber.updateQueue = currentSource.updateQueue;
- sourceFiber.memoizedState = currentSource.memoizedState;
- sourceFiber.lanes = currentSource.lanes;
- } else {
- sourceFiber.updateQueue = null;
- sourceFiber.memoizedState = null;
+ if (suspenseBoundary.mode & ConcurrentMode) {
+ attachPingListener(root, wakeable, rootRenderLanes);
}
- }
-
- var hasInvisibleParentBoundary = hasSuspenseContext(
- suspenseStackCursor.current,
- InvisibleParentSuspenseContext
- ); // Schedule the nearest Suspense to re-render the timed out view.
-
- var _workInProgress = returnFiber;
-
- 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;
-
- if (wakeables === null) {
- var updateQueue = new Set();
- updateQueue.add(wakeable);
- _workInProgress.updateQueue = updateQueue;
- } else {
- wakeables.add(wakeable);
- } // If the boundary is in legacy 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 concurrent mode tree. If the Suspense is outside of it, we
- // should *not* suspend the commit.
- //
- // If the suspense boundary suspended itself suspended, we don't have to
- // do this trick because nothing was partially started. We can just
- // directly do a second pass over the fallback in this render and
- // pretend we meant to render that directly.
-
- if (
- (_workInProgress.mode & ConcurrentMode) === NoMode &&
- _workInProgress !== returnFiber
- ) {
- _workInProgress.flags |= DidCapture;
- sourceFiber.flags |= 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.
- sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
-
- if (sourceFiber.tag === ClassComponent) {
- var _currentSourceFiber = sourceFiber.alternate;
-
- 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);
- 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.
-
- sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending.
-
- 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. Transitions apply
- // 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".
+ attachRetryListener(suspenseBoundary, root, wakeable);
+ return;
+ } else {
+ // No boundary was found. Unless this is a sync update, this is OK.
+ // We can suspend and wait for more data to arrive.
+ if (!includesSyncLane(rootRenderLanes)) {
+ // This is not a sync update. Suspend. Since we're not activating a
+ // Suspense boundary, this will unwind all the way to the root without
+ // performing a second pass to render a fallback. (This is arguably how
+ // refresh transitions should work, too, since we're not going to commit
+ // the fallbacks anyway.)
//
- // 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.
-
+ // This case also applies to initial hydration.
attachPingListener(root, wakeable, rootRenderLanes);
- _workInProgress.flags |= ShouldCapture;
- _workInProgress.lanes = rootRenderLanes;
+ renderDidSuspendDelayIfPossible();
return;
- } // This boundary already captured during this render. Continue to the next
- // boundary.
+ } // This is a sync/discrete update. We treat this case like an error
+ // because discrete renders are expected to produce a complete tree
+ // synchronously to maintain consistency with external state.
- _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 uncaughtSuspenseError = new Error(
+ "A component suspended while responding to synchronous input. This " +
+ "will cause the UI to be replaced with a loading indicator. To " +
+ "fix, updates that suspend should be wrapped " +
+ "with startTransition."
+ ); // If we're outside a transition, fall through to the regular error path.
+ // The error will be caught by the nearest suspense boundary.
- value = new Error(
- (getComponentNameFromFiber(sourceFiber) || "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."
- );
+ value = uncaughtSuspenseError;
+ }
} // 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.
- renderDidError();
+ renderDidError(value);
value = createCapturedValue(value, sourceFiber);
var workInProgress = returnFiber;
@@ -12973,10 +13427,8 @@ function throwException(
workInProgress.flags |= ShouldCapture;
var lane = pickArbitraryLane(rootRenderLanes);
workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
-
- var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
-
- enqueueCapturedUpdate(workInProgress, _update);
+ var update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
+ enqueueCapturedUpdate(workInProgress, update);
return;
}
@@ -12999,13 +13451,13 @@ function throwException(
workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state
- var _update2 = createClassErrorUpdate(
+ var _update = createClassErrorUpdate(
workInProgress,
errorInfo,
_lane
);
- enqueueCapturedUpdate(workInProgress, _update2);
+ enqueueCapturedUpdate(workInProgress, _update);
return;
}
@@ -13016,3612 +13468,3630 @@ function throwException(
} while (workInProgress !== null);
}
-var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
-var didReceiveUpdate = false;
-var didWarnAboutBadClass;
-var didWarnAboutModulePatternComponent;
-var didWarnAboutContextTypeOnFunctionComponent;
-var didWarnAboutGetDerivedStateOnFunctionComponent;
-var didWarnAboutFunctionRefs;
-var didWarnAboutReassigningProps;
-var didWarnAboutRevealOrder;
-var didWarnAboutTailOptions;
+function getSuspendedCache() {
+ {
+ return null;
+ } // This function is called when a Suspense boundary suspends. It returns the
+}
-{
- didWarnAboutBadClass = {};
- didWarnAboutModulePatternComponent = {};
- didWarnAboutContextTypeOnFunctionComponent = {};
- didWarnAboutGetDerivedStateOnFunctionComponent = {};
- didWarnAboutFunctionRefs = {};
- didWarnAboutReassigningProps = false;
- didWarnAboutRevealOrder = {};
- didWarnAboutTailOptions = {};
+function markUpdate(workInProgress) {
+ // Tag the fiber with an update effect. This turns a Placement into
+ // a PlacementAndUpdate.
+ workInProgress.flags |= Update;
}
-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,
- // we will add them all to the child before it gets rendered. That means
- // we can optimize this reconciliation pass by not tracking side-effects.
- workInProgress.child = mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderLanes
- );
- } else {
- // If the current child is the same as the work in progress, it means that
- // we haven't yet started any work on these children. Therefore, we use
- // the clone algorithm to create a copy of all the current children.
- // If we had any progressed work already, that is invalid at this point so
- // let's throw it out.
- workInProgress.child = reconcileChildFibers(
- workInProgress,
- current.child,
- nextChildren,
- renderLanes
- );
- }
+function markRef(workInProgress) {
+ workInProgress.flags |= Ref;
}
-function forceUnmountCurrentAndReconcile(
- current,
- workInProgress,
- nextChildren,
- 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
- // effect of all current children being unmounted; even if the type and key
- // are the same, the old child is unmounted and a new child is created.
- //
- // To do this, we're going to go through the reconcile algorithm twice. In
- // the first pass, we schedule a deletion for all the current children by
- // passing null.
- workInProgress.child = reconcileChildFibers(
- workInProgress,
- current.child,
- null,
- 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
- // identities match.
+var appendAllChildren;
+var updateHostContainer;
+var updateHostComponent;
+var updateHostText;
- workInProgress.child = reconcileChildFibers(
+{
+ // Mutation mode
+ appendAllChildren = function(
+ parent,
workInProgress,
- null,
- nextChildren,
- renderLanes
- );
-}
+ needsVisibilityToggle,
+ isHidden
+ ) {
+ // We only have the top Fiber that was created but we need recurse down its
+ // children to find all the terminal nodes.
+ var node = workInProgress.child;
-function updateForwardRef(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- // TODO: current can be non-null here even if the component
- // hasn't yet mounted. This happens after the first render suspends.
- // We'll need to figure out if this is fine or can cause issues.
- {
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var innerPropTypes = Component.propTypes;
+ while (node !== null) {
+ if (node.tag === HostComponent || node.tag === HostText) {
+ appendInitialChild(parent, node.stateNode);
+ } else if (node.tag === HostPortal);
+ else if (node.child !== null) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
- if (innerPropTypes) {
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(Component)
- );
+ if (node === workInProgress) {
+ return;
+ }
+
+ while (node.sibling === null) {
+ if (node.return === null || node.return === workInProgress) {
+ return;
+ }
+
+ node = node.return;
}
+
+ node.sibling.return = node.return;
+ node = node.sibling;
}
- }
+ };
- var render = Component.render;
- var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
+ updateHostContainer = function(current, workInProgress) {
+ // Noop
+ };
- var nextChildren;
- prepareToReadContext(workInProgress, renderLanes);
+ updateHostComponent = function(
+ current,
+ workInProgress,
+ type,
+ newProps,
+ rootContainerInstance
+ ) {
+ // If we have an alternate, that means this is an update and we need to
+ // schedule a side-effect to do the updates.
+ var oldProps = current.memoizedProps;
- {
- ReactCurrentOwner$1.current = workInProgress;
- setIsRendering(true);
- nextChildren = renderWithHooks(
- current,
- workInProgress,
- render,
- nextProps,
- ref,
- renderLanes
- );
+ if (oldProps === newProps) {
+ // In mutation mode, this is sufficient for a bailout because
+ // we won't touch this node even if children changed.
+ return;
+ } // If we get updated because one of our children updated, we don't
+ // have newProps so we'll have to reuse them.
+ // TODO: Split the update API as separate for the props vs. children.
+ // Even better would be if children weren't special cased at all tho.
- setIsRendering(false);
- }
+ var instance = workInProgress.stateNode;
+ var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
+ // component is hitting the resume path. Figure out why. Possibly
+ // related to `hidden`.
- if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderLanes);
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- } // React DevTools reads this flag.
+ var updatePayload = prepareUpdate(); // TODO: Type this specific to this type of component.
- workInProgress.flags |= PerformedWork;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
+ // is a new ref we mark this as an update. All the work is done in commitWork.
-function updateMemoComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
-) {
- if (current === null) {
- var type = Component.type;
+ if (updatePayload) {
+ markUpdate(workInProgress);
+ }
+ };
- if (
- isSimpleFunctionComponent(type) &&
- Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
- Component.defaultProps === undefined
- ) {
- var resolvedType = type;
+ updateHostText = function(current, workInProgress, oldText, newText) {
+ // If the text differs, mark it as an update. All the work in done in commitWork.
+ if (oldText !== newText) {
+ markUpdate(workInProgress);
+ }
+ };
+}
- {
- resolvedType = resolveFunctionForHotReloading(type);
- } // If this is a plain function component without default props,
- // and with only the default shallow comparison, we upgrade it
- // to a SimpleMemoComponent to allow fast path updates.
+function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
+ switch (renderState.tailMode) {
+ case "hidden": {
+ // Any insertions at the end of the tail list after this point
+ // should be invisible. If there are already mounted boundaries
+ // anything before them are not considered for collapsing.
+ // Therefore we need to go through the whole tail to find if
+ // there are any.
+ var tailNode = renderState.tail;
+ var lastTailNode = null;
- workInProgress.tag = SimpleMemoComponent;
- workInProgress.type = resolvedType;
+ while (tailNode !== null) {
+ if (tailNode.alternate !== null) {
+ lastTailNode = tailNode;
+ }
- {
- validateFunctionComponentInDev(workInProgress, type);
+ tailNode = tailNode.sibling;
+ } // Next we're simply going to delete all insertions after the
+ // last rendered item.
+
+ if (lastTailNode === null) {
+ // All remaining items in the tail are insertions.
+ renderState.tail = null;
+ } else {
+ // Detach the insertion after the last node that was already
+ // inserted.
+ lastTailNode.sibling = null;
}
- return updateSimpleMemoComponent(
- current,
- workInProgress,
- resolvedType,
- nextProps,
- updateLanes,
- renderLanes
- );
+ break;
}
- {
- var innerPropTypes = type.propTypes;
+ case "collapsed": {
+ // Any insertions at the end of the tail list after this point
+ // should be invisible. If there are already mounted boundaries
+ // anything before them are not considered for collapsing.
+ // Therefore we need to go through the whole tail to find if
+ // there are any.
+ var _tailNode = renderState.tail;
+ var _lastTailNode = null;
- if (innerPropTypes) {
- // Inner memo component props aren't currently validated in createElement.
- // We could move it there, but we'd still need this for lazy code path.
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(type)
- );
- }
- }
+ while (_tailNode !== null) {
+ if (_tailNode.alternate !== null) {
+ _lastTailNode = _tailNode;
+ }
- var child = createFiberFromTypeAndProps(
- Component.type,
- null,
- nextProps,
- workInProgress,
- workInProgress.mode,
- renderLanes
- );
- child.ref = workInProgress.ref;
- child.return = workInProgress;
- workInProgress.child = child;
- return child;
- }
+ _tailNode = _tailNode.sibling;
+ } // Next we're simply going to delete all insertions after the
+ // last rendered item.
- {
- var _type = Component.type;
- var _innerPropTypes = _type.propTypes;
+ if (_lastTailNode === null) {
+ // All remaining items in the tail are insertions.
+ if (!hasRenderedATailFallback && renderState.tail !== null) {
+ // We suspended during the head. We want to show at least one
+ // row at the tail. So we'll keep on and cut off the rest.
+ renderState.tail.sibling = null;
+ } else {
+ renderState.tail = null;
+ }
+ } else {
+ // Detach the insertion after the last node that was already
+ // inserted.
+ _lastTailNode.sibling = null;
+ }
- if (_innerPropTypes) {
- // Inner memo component props aren't currently validated in createElement.
- // We could move it there, but we'd still need this for lazy code path.
- checkPropTypes(
- _innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(_type)
- );
+ break;
}
}
+}
- var currentChild = current.child; // This is always exactly one child
-
- 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
+function bubbleProperties(completedWork) {
+ var didBailout =
+ completedWork.alternate !== null &&
+ completedWork.alternate.child === completedWork.child;
+ var newChildLanes = NoLanes;
+ var subtreeFlags = NoFlags;
- var compare = Component.compare;
- compare = compare !== null ? compare : shallowEqual;
+ if (!didBailout) {
+ // Bubble up the earliest expiration time.
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // In profiling mode, resetChildExpirationTime is also used to reset
+ // profiler durations.
+ var actualDuration = completedWork.actualDuration;
+ var treeBaseDuration = completedWork.selfBaseDuration;
+ var child = completedWork.child;
- if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- }
- } // React DevTools reads this flag.
+ while (child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(child.lanes, child.childLanes)
+ );
+ subtreeFlags |= child.subtreeFlags;
+ subtreeFlags |= child.flags; // 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.
- workInProgress.flags |= PerformedWork;
- var newChild = createWorkInProgress(currentChild, nextProps);
- newChild.ref = workInProgress.ref;
- newChild.return = workInProgress;
- workInProgress.child = newChild;
- return newChild;
-}
+ actualDuration += child.actualDuration;
+ treeBaseDuration += child.treeBaseDuration;
+ child = child.sibling;
+ }
-function updateSimpleMemoComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- updateLanes,
- renderLanes
-) {
- // TODO: current can be non-null here even if the component
- // hasn't yet mounted. This happens when the inner render suspends.
- // We'll need to figure out if this is fine or can cause issues.
- {
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var outerMemoType = workInProgress.elementType;
+ completedWork.actualDuration = actualDuration;
+ completedWork.treeBaseDuration = treeBaseDuration;
+ } else {
+ var _child = completedWork.child;
- if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
- // 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.
- var lazyComponent = outerMemoType;
- var payload = lazyComponent._payload;
- var init = lazyComponent._init;
+ while (_child !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child.lanes, _child.childLanes)
+ );
+ subtreeFlags |= _child.subtreeFlags;
+ subtreeFlags |= _child.flags; // Update the return pointer so the tree is consistent. This is a code
+ // smell because it assumes the commit phase is never concurrent with
+ // the render phase. Will address during refactor to alternate model.
- try {
- outerMemoType = init(payload);
- } catch (x) {
- outerMemoType = null;
- } // Inner propTypes will be validated in the function component path.
+ _child.return = completedWork;
+ _child = _child.sibling;
+ }
+ }
- var outerPropTypes = outerMemoType && outerMemoType.propTypes;
+ completedWork.subtreeFlags |= subtreeFlags;
+ } else {
+ // Bubble up the earliest expiration time.
+ if ((completedWork.mode & ProfileMode) !== NoMode) {
+ // In profiling mode, resetChildExpirationTime is also used to reset
+ // profiler durations.
+ var _treeBaseDuration = completedWork.selfBaseDuration;
+ var _child2 = completedWork.child;
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
- "prop",
- getComponentNameFromType(outerMemoType)
- );
- }
+ while (_child2 !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child2.lanes, _child2.childLanes)
+ ); // "Static" flags share the lifetime of the fiber/hook they belong to,
+ // so we should bubble those up even during a bailout. All the other
+ // flags have a lifetime only of a single render + commit, so we should
+ // ignore them.
+
+ subtreeFlags |= _child2.subtreeFlags & StaticMask;
+ subtreeFlags |= _child2.flags & StaticMask;
+ _treeBaseDuration += _child2.treeBaseDuration;
+ _child2 = _child2.sibling;
}
- }
- }
- if (current !== null) {
- var prevProps = current.memoizedProps;
+ completedWork.treeBaseDuration = _treeBaseDuration;
+ } else {
+ var _child3 = completedWork.child;
- if (
- shallowEqual(prevProps, nextProps) &&
- current.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload.
- workInProgress.type === current.type
- ) {
- didReceiveUpdate = false;
+ while (_child3 !== null) {
+ newChildLanes = mergeLanes(
+ newChildLanes,
+ mergeLanes(_child3.lanes, _child3.childLanes)
+ ); // "Static" flags share the lifetime of the fiber/hook they belong to,
+ // so we should bubble those up even during a bailout. All the other
+ // flags have a lifetime only of a single render + commit, so we should
+ // ignore them.
- 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 accumulated 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
- // to account for it here, too. Reset to the value of the current fiber.
- // NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
- // because a MemoComponent fiber does not have hooks or an update queue;
- // rather, it wraps around an inner component, which may or may not
- // contains hooks.
- // TODO: Move the reset at in beginWork out of the common path so that
- // this is no longer necessary.
- workInProgress.lanes = current.lanes;
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
- );
- } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
- // This is a special case that only exists for legacy mode.
- // See https://github.com/facebook/react/pull/19216.
- didReceiveUpdate = true;
+ subtreeFlags |= _child3.subtreeFlags & StaticMask;
+ subtreeFlags |= _child3.flags & StaticMask; // Update the return pointer so the tree is consistent. This is a code
+ // smell because it assumes the commit phase is never concurrent with
+ // the render phase. Will address during refactor to alternate model.
+
+ _child3.return = completedWork;
+ _child3 = _child3.sibling;
}
}
+
+ completedWork.subtreeFlags |= subtreeFlags;
}
- return updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
- );
+ completedWork.childLanes = newChildLanes;
+ return didBailout;
}
-function updateOffscreenComponent(current, workInProgress, renderLanes) {
- var nextProps = workInProgress.pendingProps;
- var nextChildren = nextProps.children;
- var prevState = current !== null ? current.memoizedState : null; // If this is not null, this is a cache pool that was carried over from the
- // previous render. We will push this to the cache pool context so that we can
- // resume in-flight requests.
-
- var spawnedCachePool = null;
+function completeWork(current, workInProgress, renderLanes) {
+ var newProps = workInProgress.pendingProps; // Note: This intentionally doesn't check if we're hydrating because comparing
+ // to the current tree provider fiber is just as fast and less error-prone.
+ // Ideally we would have a special version of the work loop only
+ // for hydration.
- if (
- nextProps.mode === "hidden" ||
- nextProps.mode === "unstable-defer-without-hiding"
- ) {
- // Rendering a hidden tree.
- if ((workInProgress.mode & ConcurrentMode) === NoMode) {
- // In legacy sync mode, don't defer the subtree. Render it now.
- var nextState = {
- baseLanes: NoLanes,
- cachePool: null
- };
- workInProgress.memoizedState = nextState;
- pushRenderLanes(workInProgress, renderLanes);
- } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
- // We're hidden, and we're not rendering at Offscreen. We will bail out
- // and resume this tree later.
- var nextBaseLanes;
+ popTreeContext(workInProgress);
- 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.
+ switch (workInProgress.tag) {
+ case IndeterminateComponent:
+ case LazyComponent:
+ case SimpleMemoComponent:
+ case FunctionComponent:
+ case ForwardRef:
+ case Fragment:
+ case Mode:
+ case Profiler:
+ case ContextConsumer:
+ case MemoComponent:
+ bubbleProperties(workInProgress);
+ return null;
- workInProgress.lanes = workInProgress.childLanes = laneToLanes(
- OffscreenLane
- );
- var _nextState = {
- baseLanes: nextBaseLanes,
- cachePool: spawnedCachePool
- };
- workInProgress.memoizedState = _nextState;
- workInProgress.updateQueue = null; // We're about to bail out, but we need to push this to the stack anyway
- // to avoid a push/pop misalignment.
+ case ClassComponent: {
+ var Component = workInProgress.type;
- pushRenderLanes(workInProgress, nextBaseLanes);
+ if (isContextProvider(Component)) {
+ popContext(workInProgress);
+ }
+ bubbleProperties(workInProgress);
return null;
- } else {
- var _nextState2 = {
- baseLanes: NoLanes,
- cachePool: null
- };
- workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out.
-
- var subtreeRenderLanes =
- prevState !== null ? prevState.baseLanes : renderLanes;
- pushRenderLanes(workInProgress, subtreeRenderLanes);
}
- } else {
- // Rendering a visible tree.
- var _subtreeRenderLanes;
- if (prevState !== null) {
- // We're going from hidden -> visible.
- _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes);
+ case HostRoot: {
+ var fiberRoot = workInProgress.stateNode;
- 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;
- }
+ popHostContainer(workInProgress);
+ popTopLevelContextObject(workInProgress);
+ resetWorkInProgressVersions();
- pushRenderLanes(workInProgress, _subtreeRenderLanes);
- }
+ if (fiberRoot.pendingContext) {
+ fiberRoot.context = fiberRoot.pendingContext;
+ fiberRoot.pendingContext = null;
+ }
- 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.
+ if (current === null || current.child === null) {
+ // If we hydrated, pop so that we can delete any remaining children
+ // that weren't hydrated.
+ var wasHydrated = popHydrationState();
-var updateLegacyHiddenComponent = updateOffscreenComponent;
+ if (wasHydrated) {
+ // If we hydrated, then we'll need to schedule an update for
+ // the commit side-effects on the root.
+ markUpdate(workInProgress);
+ } else {
+ if (current !== null) {
+ var prevState = current.memoizedState;
-function updateFragment(current, workInProgress, renderLanes) {
- var nextChildren = workInProgress.pendingProps;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ if (
+ // Check if this is a client root
+ !prevState.isDehydrated || // Check if we reverted to client rendering (e.g. due to an error)
+ (workInProgress.flags & ForceClientRender) !== NoFlags
+ ) {
+ // 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 container would already
+ // be empty).
+ workInProgress.flags |= Snapshot; // If this was a forced client render, there may have been
+ }
+ }
+ }
+ }
-function updateMode(current, workInProgress, renderLanes) {
- var nextChildren = workInProgress.pendingProps.children;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ updateHostContainer(current, workInProgress);
+ bubbleProperties(workInProgress);
+ return null;
+ }
-function updateProfiler(current, workInProgress, renderLanes) {
- {
- workInProgress.flags |= Update;
+ case HostComponent: {
+ popHostContext(workInProgress);
+ var rootContainerInstance = getRootHostContainer();
+ var type = workInProgress.type;
- {
- // 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,
- var stateNode = workInProgress.stateNode;
- stateNode.effectDuration = 0;
- stateNode.passiveEffectDuration = 0;
- }
- }
+ if (current !== null && workInProgress.stateNode != null) {
+ updateHostComponent(
+ current,
+ workInProgress,
+ type,
+ newProps,
+ rootContainerInstance
+ );
- var nextProps = workInProgress.pendingProps;
- var nextChildren = nextProps.children;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ if (current.ref !== workInProgress.ref) {
+ markRef(workInProgress);
+ }
+ } else {
+ if (!newProps) {
+ if (workInProgress.stateNode === null) {
+ throw new Error(
+ "We must have new props for new mounts. This error is likely " +
+ "caused by a bug in React. Please file an issue."
+ );
+ } // This can happen when we abort work.
-function markRef(current, workInProgress) {
- var ref = workInProgress.ref;
+ bubbleProperties(workInProgress);
+ return null;
+ }
- if (
- (current === null && ref !== null) ||
- (current !== null && current.ref !== ref)
- ) {
- // Schedule a Ref effect
- workInProgress.flags |= Ref;
- }
-}
+ var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
+ // "stack" as the parent. Then append children as we go in beginWork
+ // or completeWork depending on whether we want to add them top->down or
+ // bottom->up. Top->down is faster in IE11.
-function updateFunctionComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- {
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var innerPropTypes = Component.propTypes;
+ var _wasHydrated = popHydrationState();
- if (innerPropTypes) {
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(Component)
- );
+ if (_wasHydrated) {
+ // TODO: Move this and createInstance step into the beginPhase
+ // to consolidate.
+ if (prepareToHydrateHostInstance()) {
+ // If changes to the hydrated node need to be applied at the
+ // commit-phase we mark this as such.
+ markUpdate(workInProgress);
+ }
+ } else {
+ var instance = createInstance(
+ type,
+ newProps,
+ rootContainerInstance,
+ currentHostContext,
+ workInProgress
+ );
+ appendAllChildren(instance, workInProgress, false, false);
+ workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount.
+ // (eg DOM renderer supports auto-focus for certain elements).
+ // Make sure such renderers get scheduled for later work.
+
+ if (finalizeInitialChildren(instance)) {
+ markUpdate(workInProgress);
+ }
+ }
+
+ if (workInProgress.ref !== null) {
+ // If there is a ref on a host node we need to schedule a callback
+ markRef(workInProgress);
+ }
}
+
+ bubbleProperties(workInProgress);
+ return null;
}
- }
- var context;
+ case HostText: {
+ var newText = newProps;
- {
- var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
- context = getMaskedContext(workInProgress, unmaskedContext);
- }
+ if (current && workInProgress.stateNode != null) {
+ var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
+ // to schedule a side-effect to do the updates.
- var nextChildren;
- prepareToReadContext(workInProgress, renderLanes);
+ updateHostText(current, workInProgress, oldText, newText);
+ } else {
+ if (typeof newText !== "string") {
+ if (workInProgress.stateNode === null) {
+ throw new Error(
+ "We must have new props for new mounts. This error is likely " +
+ "caused by a bug in React. Please file an issue."
+ );
+ } // This can happen when we abort work.
+ }
- {
- ReactCurrentOwner$1.current = workInProgress;
- setIsRendering(true);
- nextChildren = renderWithHooks(
- current,
- workInProgress,
- Component,
- nextProps,
- context,
- renderLanes
- );
+ var _rootContainerInstance = getRootHostContainer();
- setIsRendering(false);
- }
+ var _currentHostContext = getHostContext();
- if (current !== null && !didReceiveUpdate) {
- bailoutHooks(current, workInProgress, renderLanes);
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- } // React DevTools reads this flag.
+ var _wasHydrated2 = popHydrationState();
- workInProgress.flags |= PerformedWork;
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ if (_wasHydrated2) {
+ if (prepareToHydrateHostTextInstance()) {
+ markUpdate(workInProgress);
+ }
+ } else {
+ workInProgress.stateNode = createTextInstance(
+ newText,
+ _rootContainerInstance,
+ _currentHostContext,
+ workInProgress
+ );
+ }
+ }
-function updateClassComponent(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- {
- // This is used by DevTools to force a boundary to error.
- switch (shouldError(workInProgress)) {
- case false: {
- var _instance = workInProgress.stateNode;
- var ctor = workInProgress.type; // TODO This way of resetting the error boundary state is a hack.
- // Is there a better way to do this?
+ bubbleProperties(workInProgress);
+ return null;
+ }
- var tempInstance = new ctor(
- workInProgress.memoizedProps,
- _instance.context
- );
- var state = tempInstance.state;
+ case SuspenseComponent: {
+ popSuspenseContext(workInProgress);
+ var nextState = workInProgress.memoizedState;
- _instance.updater.enqueueSetState(_instance, state, null);
+ if ((workInProgress.flags & DidCapture) !== NoFlags) {
+ // Something suspended. Re-render with the fallback children.
+ workInProgress.lanes = renderLanes; // Do not reset the effect list.
- break;
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ transferActualDuration(workInProgress);
+ } // Don't bubble properties in this case.
+
+ return workInProgress;
}
- case true: {
- workInProgress.flags |= DidCapture;
- workInProgress.flags |= ShouldCapture;
- var error$1 = new Error("Simulated error coming from DevTools");
- var lane = pickArbitraryLane(renderLanes);
- workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state
+ var nextDidTimeout = nextState !== null;
+ var prevDidTimeout = false;
- var update = createClassErrorUpdate(
- workInProgress,
- createCapturedValue(error$1, workInProgress),
- lane
- );
- enqueueCapturedUpdate(workInProgress, update);
- break;
+ if (current === null);
+ else {
+ var _prevState = current.memoizedState;
+ prevDidTimeout = _prevState !== null;
}
- }
+ // an effect to toggle the subtree's visibility. When we switch from
+ // fallback -> primary, the inner Offscreen fiber schedules this effect
+ // as part of its normal complete phase. But when we switch from
+ // primary -> fallback, the inner Offscreen fiber does not have a complete
+ // phase. So we need to schedule its effect here.
+ //
+ // We also use this flag to connect/disconnect the effects, but the same
+ // logic applies: when re-connecting, the Offscreen fiber's complete
+ // phase will handle scheduling the effect. It's only when the fallback
+ // is active that we have to do anything special.
- if (workInProgress.type !== workInProgress.elementType) {
- // Lazy component props can't be validated in createElement
- // because they're only guaranteed to be resolved here.
- var innerPropTypes = Component.propTypes;
+ if (nextDidTimeout && !prevDidTimeout) {
+ var _offscreenFiber = workInProgress.child;
+ _offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything
+ // in the concurrent tree already suspended during this render.
+ // This is a known bug.
- if (innerPropTypes) {
- checkPropTypes(
- innerPropTypes,
- nextProps, // Resolved props
- "prop",
- getComponentNameFromType(Component)
- );
+ if ((workInProgress.mode & ConcurrentMode) !== NoMode) {
+ // TODO: Move this back to throwException because this is too late
+ // if this is a large tree which is common for initial loads. We
+ // don't know if we should restart a render or not until we get
+ // this marker, and this is too late.
+ // If this render already had a ping or lower pri updates,
+ // and this is the first time we know we're going to suspend we
+ // should be able to immediately restart from within throwException.
+ var hasInvisibleChildContext =
+ current === null &&
+ (workInProgress.memoizedProps.unstable_avoidThisFallback !== true ||
+ !enableSuspenseAvoidThisFallback);
+
+ if (
+ hasInvisibleChildContext ||
+ hasSuspenseContext(
+ suspenseStackCursor.current,
+ InvisibleParentSuspenseContext
+ )
+ ) {
+ // If this was in an invisible tree or a new render, then showing
+ // this boundary is ok.
+ renderDidSuspend();
+ } else {
+ // Otherwise, we're going to have to hide content so we should
+ // suspend for longer if possible.
+ renderDidSuspendDelayIfPossible();
+ }
+ }
}
- }
- } // Push context providers early to prevent context stack mismatches.
- // During mounting we don't know the child context yet as the instance doesn't exist.
- // We will invalidate the child context in finishClassComponent() right after rendering.
- var hasContext;
+ var wakeables = workInProgress.updateQueue;
- if (isContextProvider(Component)) {
- hasContext = true;
- pushContextProvider(workInProgress);
- } else {
- hasContext = false;
- }
-
- prepareToReadContext(workInProgress, renderLanes);
- var instance = workInProgress.stateNode;
- var shouldUpdate;
-
- if (instance === null) {
- if (current !== null) {
- // A class component without an instance only mounts if it suspended
- // inside a non-concurrent tree, in an inconsistent state. We want to
- // treat it like a new mount, even though an empty version of it already
- // committed. Disconnect the alternate pointers.
- current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
-
- workInProgress.flags |= Placement;
- } // In the initial pass we might need to construct the instance.
-
- constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(workInProgress, Component, nextProps, renderLanes);
- shouldUpdate = true;
- } else if (current === null) {
- // In a resume, we'll already have an instance we can reuse.
- shouldUpdate = resumeMountClassInstance(
- workInProgress,
- Component,
- nextProps,
- renderLanes
- );
- } else {
- shouldUpdate = updateClassInstance(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
- );
- }
+ if (wakeables !== null) {
+ // Schedule an effect to attach a retry listener to the promise.
+ // TODO: Move to passive phase
+ workInProgress.flags |= Update;
+ }
- var nextUnitOfWork = finishClassComponent(
- current,
- workInProgress,
- Component,
- shouldUpdate,
- hasContext,
- renderLanes
- );
+ bubbleProperties(workInProgress);
- {
- var inst = workInProgress.stateNode;
+ {
+ if ((workInProgress.mode & ProfileMode) !== NoMode) {
+ if (nextDidTimeout) {
+ // Don't count time spent in a timed out Suspense subtree as part of the base duration.
+ var _primaryChildFragment2 = workInProgress.child;
- if (shouldUpdate && inst.props !== nextProps) {
- if (!didWarnAboutReassigningProps) {
- error(
- "It looks like %s is reassigning its own `this.props` while rendering. " +
- "This is not supported and can lead to confusing bugs.",
- getComponentNameFromFiber(workInProgress) || "a component"
- );
+ if (_primaryChildFragment2 !== null) {
+ // $FlowFixMe Flow doesn't support type casting in combination with the -= operator
+ workInProgress.treeBaseDuration -=
+ _primaryChildFragment2.treeBaseDuration;
+ }
+ }
+ }
}
- didWarnAboutReassigningProps = true;
+ return null;
}
- }
- return nextUnitOfWork;
-}
-
-function finishClassComponent(
- current,
- workInProgress,
- Component,
- shouldUpdate,
- hasContext,
- renderLanes
-) {
- // Refs should update even if shouldComponentUpdate returns false
- markRef(current, workInProgress);
- var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags;
+ case HostPortal:
+ popHostContainer(workInProgress);
+ updateHostContainer(current, workInProgress);
- if (!shouldUpdate && !didCaptureError) {
- // Context providers should defer to sCU for rendering
- if (hasContext) {
- invalidateContextProvider(workInProgress, Component, false);
- }
+ if (current === null) {
+ preparePortalMount(workInProgress.stateNode.containerInfo);
+ }
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- }
+ bubbleProperties(workInProgress);
+ return null;
- var instance = workInProgress.stateNode; // Rerender
+ case ContextProvider:
+ // Pop provider fiber
+ var context = workInProgress.type._context;
+ popProvider(context, workInProgress);
+ bubbleProperties(workInProgress);
+ return null;
- ReactCurrentOwner$1.current = workInProgress;
- var nextChildren;
+ case IncompleteClassComponent: {
+ // Same as class component case. I put it down here so that the tags are
+ // sequential to ensure this switch is compiled to a jump table.
+ var _Component = workInProgress.type;
- if (
- didCaptureError &&
- typeof Component.getDerivedStateFromError !== "function"
- ) {
- // If we captured an error, but getDerivedStateFromError is not defined,
- // unmount all the children. componentDidCatch will schedule an update to
- // re-render a fallback. This is temporary until we migrate everyone to
- // the new API.
- // TODO: Warn in a future release.
- nextChildren = null;
+ if (isContextProvider(_Component)) {
+ popContext(workInProgress);
+ }
- {
- stopProfilerTimerIfRunning();
+ bubbleProperties(workInProgress);
+ return null;
}
- } else {
- {
- setIsRendering(true);
- nextChildren = instance.render();
- setIsRendering(false);
- }
- } // React DevTools reads this flag.
+ case SuspenseListComponent: {
+ popSuspenseContext(workInProgress);
+ var renderState = workInProgress.memoizedState;
- workInProgress.flags |= PerformedWork;
+ if (renderState === null) {
+ // We're running in the default, "independent" mode.
+ // We don't do anything in this mode.
+ bubbleProperties(workInProgress);
+ return null;
+ }
- if (current !== null && didCaptureError) {
- // If we're recovering from an error, reconcile without reusing any of
- // the existing children. Conceptually, the normal children and the children
- // that are shown on error are two different sets, so we shouldn't reuse
- // normal children even if their identities match.
- forceUnmountCurrentAndReconcile(
- current,
- workInProgress,
- nextChildren,
- renderLanes
- );
- } else {
- 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.
+ var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags;
+ var renderedTail = renderState.rendering;
- workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
+ if (renderedTail === null) {
+ // We just rendered the head.
+ if (!didSuspendAlready) {
+ // This is the first pass. We need to figure out if anything is still
+ // suspended in the rendered set.
+ // If new content unsuspended, but there's still some content that
+ // didn't. Then we need to do a second pass that forces everything
+ // to keep showing their fallbacks.
+ // We might be suspended if something in this render pass suspended, or
+ // something in the previous committed pass suspended. Otherwise,
+ // there's no chance so we can skip the expensive call to
+ // findFirstSuspended.
+ var cannotBeSuspended =
+ renderHasNotSuspendedYet() &&
+ (current === null || (current.flags & DidCapture) === NoFlags);
- if (hasContext) {
- invalidateContextProvider(workInProgress, Component, true);
- }
+ if (!cannotBeSuspended) {
+ var row = workInProgress.child;
- return workInProgress.child;
-}
+ while (row !== null) {
+ var suspended = findFirstSuspended(row);
-function pushHostRootContext(workInProgress) {
- var root = workInProgress.stateNode;
+ if (suspended !== null) {
+ didSuspendAlready = true;
+ workInProgress.flags |= DidCapture;
+ cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
+ // part of the second pass. In that case nothing will subscribe to
+ // its thenables. Instead, we'll transfer its thenables to the
+ // SuspenseList so that it can retry if they resolve.
+ // There might be multiple of these in the list but since we're
+ // going to wait for all of them anyway, it doesn't really matter
+ // which ones gets to ping. In theory we could get clever and keep
+ // track of how many dependencies remain but it gets tricky because
+ // in the meantime, we can add/remove/change items and dependencies.
+ // We might bail out of the loop before finding any but that
+ // doesn't matter since that means that the other boundaries that
+ // we did find already has their listeners attached.
- if (root.pendingContext) {
- pushTopLevelContextObject(
- workInProgress,
- root.pendingContext,
- root.pendingContext !== root.context
- );
- } else if (root.context) {
- // Should always be set
- pushTopLevelContextObject(workInProgress, root.context, false);
- }
+ var newThenables = suspended.updateQueue;
- pushHostContainer(workInProgress, root.containerInfo);
-}
+ if (newThenables !== null) {
+ workInProgress.updateQueue = newThenables;
+ workInProgress.flags |= Update;
+ } // Rerender the whole list, but this time, we'll force fallbacks
+ // to stay in place.
+ // Reset the effect flags before doing the second pass since that's now invalid.
+ // Reset the child fibers to their original state.
-function updateHostRoot(current, workInProgress, renderLanes) {
- pushHostRootContext(workInProgress);
- var updateQueue = workInProgress.updateQueue;
+ workInProgress.subtreeFlags = NoFlags;
+ resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
+ // rerender the children.
- if (!(current !== null && updateQueue !== null)) {
- 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."
- );
- }
+ pushSuspenseContext(
+ workInProgress,
+ setShallowSuspenseContext(
+ suspenseStackCursor.current,
+ ForceSuspenseFallback
+ )
+ ); // Don't bubble properties in this case.
- var nextProps = workInProgress.pendingProps;
- var prevState = workInProgress.memoizedState;
- var prevChildren = prevState.element;
- cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextProps, null, renderLanes);
- var nextState = workInProgress.memoizedState;
- var root = workInProgress.stateNode;
- // being called "element".
+ return workInProgress.child;
+ }
- var nextChildren = nextState.element;
+ row = row.sibling;
+ }
+ }
- if (nextChildren === prevChildren) {
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- }
+ if (renderState.tail !== null && now() > getRenderTargetTime()) {
+ // We have already passed our CPU deadline but we still have rows
+ // left in the tail. We'll just give up further attempts to render
+ // the main content and only render fallbacks.
+ workInProgress.flags |= DidCapture;
+ didSuspendAlready = true;
+ cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
+ // to get it started back up to attempt the next item. While in terms
+ // of priority this work has the same priority as this current render,
+ // it's not part of the same transition once the transition has
+ // committed. If it's sync, we still want to yield so that it can be
+ // painted. Conceptually, this is really the same as pinging.
+ // We can use any RetryLane even if it's the one currently rendering
+ // since we're leaving it behind on this node.
- if (root.hydrate && enterHydrationState()) {
- var child = mountChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderLanes
- );
- workInProgress.child = child;
- var node = child;
-
- while (node) {
- // Mark each child as hydrating. This is a fast path to know whether this
- // tree is part of a hydrating tree. This is used to determine if a child
- // node has fully mounted yet, and for scheduling event replaying.
- // Conceptually this is similar to Placement in that a new subtree is
- // inserted into the React tree here. It just happens to not need DOM
- // mutations because it already exists.
- node.flags = (node.flags & ~Placement) | Hydrating;
- node = node.sibling;
- }
- } else {
- // Otherwise reset hydration state in case we aborted and resumed another
- // root.
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- }
+ workInProgress.lanes = SomeRetryLane;
+ }
+ } else {
+ cutOffTailIfNeeded(renderState, false);
+ } // Next we're going to render the tail.
+ } else {
+ // Append the rendered row to the child list.
+ if (!didSuspendAlready) {
+ var _suspended = findFirstSuspended(renderedTail);
- return workInProgress.child;
-}
+ if (_suspended !== null) {
+ workInProgress.flags |= DidCapture;
+ didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't
+ // get lost if this row ends up dropped during a second pass.
-function updateHostComponent(current, workInProgress, renderLanes) {
- pushHostContext(workInProgress);
+ var _newThenables = _suspended.updateQueue;
- var type = workInProgress.type;
- var nextProps = workInProgress.pendingProps;
- var prevProps = current !== null ? current.memoizedProps : null;
- var nextChildren = nextProps.children;
+ if (_newThenables !== null) {
+ workInProgress.updateQueue = _newThenables;
+ workInProgress.flags |= Update;
+ }
- if (prevProps !== null && shouldSetTextContent()) {
- // If we're switching from a direct text child to a normal child, or to
- // empty, we need to schedule the text content to be reset.
- workInProgress.flags |= ContentReset;
- }
+ cutOffTailIfNeeded(renderState, true); // This might have been modified.
- markRef(current, workInProgress);
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- return workInProgress.child;
-}
+ if (
+ renderState.tail === null &&
+ renderState.tailMode === "hidden" &&
+ !renderedTail.alternate &&
+ !getIsHydrating() // We don't cut it if we're hydrating.
+ ) {
+ // We're done.
+ bubbleProperties(workInProgress);
+ return null;
+ }
+ } else if (
+ // The time it took to render last row is greater than the remaining
+ // time we have to render. So rendering one more row would likely
+ // exceed it.
+ now() * 2 - renderState.renderingStartTime >
+ getRenderTargetTime() &&
+ 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.
+ // The assumption is that this is usually faster.
+ workInProgress.flags |= DidCapture;
+ didSuspendAlready = true;
+ cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
+ // to get it started back up to attempt the next item. While in terms
+ // of priority this work has the same priority as this current render,
+ // it's not part of the same transition once the transition has
+ // committed. If it's sync, we still want to yield so that it can be
+ // painted. Conceptually, this is really the same as pinging.
+ // We can use any RetryLane even if it's the one currently rendering
+ // since we're leaving it behind on this node.
-function updateHostText(current, workInProgress) {
- // immediately after.
+ workInProgress.lanes = SomeRetryLane;
+ }
+ }
- return null;
-}
+ if (renderState.isBackwards) {
+ // The effect list of the backwards tail will have been added
+ // to the end. This breaks the guarantee that life-cycles fire in
+ // sibling order but that isn't a strong guarantee promised by React.
+ // Especially since these might also just pop in during future commits.
+ // Append to the beginning of the list.
+ renderedTail.sibling = workInProgress.child;
+ workInProgress.child = renderedTail;
+ } else {
+ var previousSibling = renderState.last;
-function mountLazyComponent(
- _current,
- workInProgress,
- elementType,
- updateLanes,
- renderLanes
-) {
- if (_current !== null) {
- // A lazy component only mounts if it suspended inside a non-
- // concurrent tree, in an inconsistent state. We want to treat it like
- // a new mount, even though an empty version of it already committed.
- // Disconnect the alternate pointers.
- _current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
+ if (previousSibling !== null) {
+ previousSibling.sibling = renderedTail;
+ } else {
+ workInProgress.child = renderedTail;
+ }
- workInProgress.flags |= Placement;
- }
+ renderState.last = renderedTail;
+ }
+ }
- 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.
+ if (renderState.tail !== null) {
+ // We still have tail rows to render.
+ // Pop a row.
+ var next = renderState.tail;
+ renderState.rendering = next;
+ renderState.tail = next.sibling;
+ renderState.renderingStartTime = now();
+ next.sibling = null; // Restore the context.
+ // TODO: We can probably just avoid popping it instead and only
+ // setting it the first time we go from not suspended to suspended.
- workInProgress.type = Component;
- var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component));
- var resolvedProps = resolveDefaultProps(Component, props);
- var child;
+ var suspenseContext = suspenseStackCursor.current;
- switch (resolvedTag) {
- case FunctionComponent: {
- {
- validateFunctionComponentInDev(workInProgress, Component);
- workInProgress.type = Component = resolveFunctionForHotReloading(
- Component
- );
- }
+ if (didSuspendAlready) {
+ suspenseContext = setShallowSuspenseContext(
+ suspenseContext,
+ ForceSuspenseFallback
+ );
+ } else {
+ suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
+ }
- child = updateFunctionComponent(
- null,
- workInProgress,
- Component,
- resolvedProps,
- renderLanes
- );
- return child;
- }
+ pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
+ // Don't bubble properties in this case.
- case ClassComponent: {
- {
- workInProgress.type = Component = resolveClassForHotReloading(
- Component
- );
+ return next;
}
- child = updateClassComponent(
- null,
- workInProgress,
- Component,
- resolvedProps,
- renderLanes
- );
- return child;
+ bubbleProperties(workInProgress);
+ return null;
}
- case ForwardRef: {
- {
- workInProgress.type = Component = resolveForwardRefForHotReloading(
- Component
- );
- }
-
- child = updateForwardRef(
- null,
- workInProgress,
- Component,
- resolvedProps,
- renderLanes
- );
- return child;
+ case ScopeComponent: {
+ break;
}
- case MemoComponent: {
- {
- if (workInProgress.type !== workInProgress.elementType) {
- var outerPropTypes = Component.propTypes;
+ case OffscreenComponent:
+ case LegacyHiddenComponent: {
+ popRenderLanes(workInProgress);
+ var _nextState = workInProgress.memoizedState;
+ var nextIsHidden = _nextState !== null;
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- resolvedProps, // Resolved for outer only
- "prop",
- getComponentNameFromType(Component)
- );
+ if (current !== null) {
+ var _prevState2 = current.memoizedState;
+ var prevIsHidden = _prevState2 !== null;
+
+ if (
+ prevIsHidden !== nextIsHidden && // LegacyHidden doesn't do any hiding — it only pre-renders.
+ !enableLegacyHidden
+ ) {
+ workInProgress.flags |= Visibility;
+ }
+ }
+
+ if (!nextIsHidden || (workInProgress.mode & ConcurrentMode) === NoMode) {
+ bubbleProperties(workInProgress);
+ } else {
+ // Don't bubble properties for hidden children unless we're rendering
+ // at offscreen priority.
+ if (includesSomeLane(subtreeRenderLanes, OffscreenLane)) {
+ bubbleProperties(workInProgress);
+
+ {
+ // Check if there was an insertion or update in the hidden subtree.
+ // If so, we need to hide those nodes in the commit phase, so
+ // schedule a visibility effect.
+ if (workInProgress.subtreeFlags & (Placement | Update)) {
+ workInProgress.flags |= Visibility;
+ }
}
}
}
- child = updateMemoComponent(
- null,
- workInProgress,
- Component,
- resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
- updateLanes,
- renderLanes
- );
- return child;
+ return null;
}
- }
- var hint = "";
+ case CacheComponent: {
+ return null;
+ }
- {
- if (
- Component !== null &&
- typeof Component === "object" &&
- Component.$$typeof === REACT_LAZY_TYPE
- ) {
- hint = " Did you wrap a component in React.lazy() more than once?";
+ case TracingMarkerComponent: {
+ return null;
}
- } // This message intentionally doesn't mention ForwardRef or MemoComponent
- // because the fact that it's a separate type of work is an
- // implementation detail.
-
- {
- throw Error(
- "Element type is invalid. Received a promise that resolves to: " +
- Component +
- ". Lazy element type must resolve to a class or function." +
- hint
- );
}
-}
-
-function mountIncompleteClassComponent(
- _current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
-) {
- if (_current !== null) {
- // An incomplete component only mounts if it suspended inside a non-
- // concurrent tree, in an inconsistent state. We want to treat it like
- // a new mount, even though an empty version of it already committed.
- // Disconnect the alternate pointers.
- _current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
- workInProgress.flags |= Placement;
- } // Promote the fiber to a class and try rendering again.
+ throw new Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in " +
+ "React. Please file an issue."
+ );
+}
- workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
- // Push context providers early to prevent context stack mismatches.
- // During mounting we don't know the child context yet as the instance doesn't exist.
- // We will invalidate the child context in finishClassComponent() right after rendering.
+var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
+var didReceiveUpdate = false;
+var didWarnAboutBadClass;
+var didWarnAboutModulePatternComponent;
+var didWarnAboutContextTypeOnFunctionComponent;
+var didWarnAboutGetDerivedStateOnFunctionComponent;
+var didWarnAboutFunctionRefs;
+var didWarnAboutReassigningProps;
+var didWarnAboutRevealOrder;
+var didWarnAboutTailOptions;
- var hasContext;
+{
+ didWarnAboutBadClass = {};
+ didWarnAboutModulePatternComponent = {};
+ didWarnAboutContextTypeOnFunctionComponent = {};
+ didWarnAboutGetDerivedStateOnFunctionComponent = {};
+ didWarnAboutFunctionRefs = {};
+ didWarnAboutReassigningProps = false;
+ didWarnAboutRevealOrder = {};
+ didWarnAboutTailOptions = {};
+}
- if (isContextProvider(Component)) {
- hasContext = true;
- pushContextProvider(workInProgress);
+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,
+ // we will add them all to the child before it gets rendered. That means
+ // we can optimize this reconciliation pass by not tracking side-effects.
+ workInProgress.child = mountChildFibers(
+ workInProgress,
+ null,
+ nextChildren,
+ renderLanes
+ );
} else {
- hasContext = false;
+ // If the current child is the same as the work in progress, it means that
+ // we haven't yet started any work on these children. Therefore, we use
+ // the clone algorithm to create a copy of all the current children.
+ // If we had any progressed work already, that is invalid at this point so
+ // let's throw it out.
+ workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ current.child,
+ nextChildren,
+ renderLanes
+ );
}
+}
- prepareToReadContext(workInProgress, renderLanes);
- constructClassInstance(workInProgress, Component, nextProps);
- mountClassInstance(workInProgress, Component, nextProps, renderLanes);
- return finishClassComponent(
+function forceUnmountCurrentAndReconcile(
+ current,
+ workInProgress,
+ nextChildren,
+ 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
+ // effect of all current children being unmounted; even if the type and key
+ // are the same, the old child is unmounted and a new child is created.
+ //
+ // To do this, we're going to go through the reconcile algorithm twice. In
+ // the first pass, we schedule a deletion for all the current children by
+ // passing null.
+ workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ current.child,
null,
+ 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
+ // identities match.
+
+ workInProgress.child = reconcileChildFibers(
workInProgress,
- Component,
- true,
- hasContext,
+ null,
+ nextChildren,
renderLanes
);
}
-function mountIndeterminateComponent(
- _current,
+function updateForwardRef(
+ current,
workInProgress,
Component,
+ nextProps,
renderLanes
) {
- if (_current !== null) {
- // An indeterminate component only mounts if it suspended inside a non-
- // concurrent tree, in an inconsistent state. We want to treat it like
- // a new mount, even though an empty version of it already committed.
- // Disconnect the alternate pointers.
- _current.alternate = null;
- workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
+ // TODO: current can be non-null here even if the component
+ // hasn't yet mounted. This happens after the first render suspends.
+ // We'll need to figure out if this is fine or can cause issues.
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var innerPropTypes = Component.propTypes;
- workInProgress.flags |= Placement;
+ if (innerPropTypes) {
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(Component)
+ );
+ }
+ }
}
- var props = workInProgress.pendingProps;
- var context;
+ var render = Component.render;
+ var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
+
+ var nextChildren;
+ prepareToReadContext(workInProgress, renderLanes);
{
- var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
- context = getMaskedContext(workInProgress, unmaskedContext);
+ ReactCurrentOwner$1.current = workInProgress;
+ setIsRendering(true);
+ nextChildren = renderWithHooks(
+ current,
+ workInProgress,
+ render,
+ nextProps,
+ ref,
+ renderLanes
+ );
+
+ setIsRendering(false);
}
- prepareToReadContext(workInProgress, renderLanes);
- var value;
+ if (current !== null && !didReceiveUpdate) {
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
+
+ workInProgress.flags |= PerformedWork;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
+
+function updateMemoComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ if (current === null) {
+ var type = Component.type;
- {
if (
- Component.prototype &&
- typeof Component.prototype.render === "function"
+ isSimpleFunctionComponent(type) &&
+ Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
+ Component.defaultProps === undefined
) {
- var componentName = getComponentNameFromType(Component) || "Unknown";
+ var resolvedType = type;
- if (!didWarnAboutBadClass[componentName]) {
- error(
- "The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
- "This is likely to cause errors. Change %s to extend React.Component instead.",
- componentName,
- componentName
- );
+ {
+ resolvedType = resolveFunctionForHotReloading(type);
+ } // If this is a plain function component without default props,
+ // and with only the default shallow comparison, we upgrade it
+ // to a SimpleMemoComponent to allow fast path updates.
- didWarnAboutBadClass[componentName] = true;
+ workInProgress.tag = SimpleMemoComponent;
+ workInProgress.type = resolvedType;
+
+ {
+ validateFunctionComponentInDev(workInProgress, type);
}
+
+ return updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ resolvedType,
+ nextProps,
+ renderLanes
+ );
}
- if (workInProgress.mode & StrictLegacyMode) {
- ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
+ {
+ var innerPropTypes = type.propTypes;
+
+ if (innerPropTypes) {
+ // Inner memo component props aren't currently validated in createElement.
+ // We could move it there, but we'd still need this for lazy code path.
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(type)
+ );
+ }
}
- setIsRendering(true);
- ReactCurrentOwner$1.current = workInProgress;
- value = renderWithHooks(
+ var child = createFiberFromTypeAndProps(
+ Component.type,
null,
+ nextProps,
workInProgress,
- Component,
- props,
- context,
+ workInProgress.mode,
renderLanes
);
- setIsRendering(false);
- } // React DevTools reads this flag.
-
- workInProgress.flags |= PerformedWork;
+ child.ref = workInProgress.ref;
+ child.return = workInProgress;
+ workInProgress.child = child;
+ return child;
+ }
{
- // 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 = getComponentNameFromType(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
- );
+ var _type = Component.type;
+ var _innerPropTypes = _type.propTypes;
- didWarnAboutModulePatternComponent[_componentName] = true;
- }
+ if (_innerPropTypes) {
+ // Inner memo component props aren't currently validated in createElement.
+ // We could move it there, but we'd still need this for lazy code path.
+ checkPropTypes(
+ _innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(_type)
+ );
}
}
- 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 _componentName2 = getComponentNameFromType(Component) || "Unknown";
-
- 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.",
- _componentName2,
- _componentName2,
- _componentName2
- );
-
- didWarnAboutModulePatternComponent[_componentName2] = true;
- }
- } // Proceed under the assumption that this is a class instance
-
- workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
-
- workInProgress.memoizedState = null;
- workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches.
- // During mounting we don't know the child context yet as the instance doesn't exist.
- // We will invalidate the child context in finishClassComponent() right after rendering.
-
- var hasContext = false;
+ var currentChild = current.child; // This is always exactly one child
- if (isContextProvider(Component)) {
- hasContext = true;
- pushContextProvider(workInProgress);
- } else {
- hasContext = false;
- }
+ var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(
+ current,
+ renderLanes
+ );
- workInProgress.memoizedState =
- value.state !== null && value.state !== undefined ? value.state : null;
- initializeUpdateQueue(workInProgress);
- adoptClassInstance(workInProgress, value);
- mountClassInstance(workInProgress, Component, props, renderLanes);
- return finishClassComponent(
- null,
- workInProgress,
- Component,
- true,
- hasContext,
- renderLanes
- );
- } else {
- // Proceed under the assumption that this is a function component
- workInProgress.tag = FunctionComponent;
+ if (!hasScheduledUpdateOrContext) {
+ // 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
- reconcileChildren(null, workInProgress, value, renderLanes);
+ var compare = Component.compare;
+ compare = compare !== null ? compare : shallowEqual;
- {
- validateFunctionComponentInDev(workInProgress, Component);
+ if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
+ } // React DevTools reads this flag.
- return workInProgress.child;
- }
+ workInProgress.flags |= PerformedWork;
+ var newChild = createWorkInProgress(currentChild, nextProps);
+ newChild.ref = workInProgress.ref;
+ newChild.return = workInProgress;
+ workInProgress.child = newChild;
+ return newChild;
}
-function validateFunctionComponentInDev(workInProgress, Component) {
+function updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ // TODO: current can be non-null here even if the component
+ // hasn't yet mounted. This happens when the inner render suspends.
+ // We'll need to figure out if this is fine or can cause issues.
{
- if (Component) {
- if (Component.childContextTypes) {
- error(
- "%s(...): childContextTypes cannot be defined on a function component.",
- Component.displayName || Component.name || "Component"
- );
- }
- }
-
- if (workInProgress.ref !== null) {
- var info = "";
- var ownerName = getCurrentFiberOwnerNameInDevOrNull();
-
- if (ownerName) {
- info += "\n\nCheck the render method of `" + ownerName + "`.";
- }
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var outerMemoType = workInProgress.elementType;
- var warningKey = ownerName || "";
- var debugSource = workInProgress._debugSource;
+ if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
+ // 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.
+ var lazyComponent = outerMemoType;
+ var payload = lazyComponent._payload;
+ var init = lazyComponent._init;
- if (debugSource) {
- warningKey = debugSource.fileName + ":" + debugSource.lineNumber;
- }
+ try {
+ outerMemoType = init(payload);
+ } catch (x) {
+ outerMemoType = null;
+ } // Inner propTypes will be validated in the function component path.
- if (!didWarnAboutFunctionRefs[warningKey]) {
- didWarnAboutFunctionRefs[warningKey] = true;
+ var outerPropTypes = outerMemoType && outerMemoType.propTypes;
- error(
- "Function components cannot be given refs. " +
- "Attempts to access this ref will fail. " +
- "Did you mean to use React.forwardRef()?%s",
- info
- );
+ if (outerPropTypes) {
+ checkPropTypes(
+ outerPropTypes,
+ nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
+ "prop",
+ getComponentNameFromType(outerMemoType)
+ );
+ }
}
}
+ }
- if (typeof Component.getDerivedStateFromProps === "function") {
- var _componentName3 = getComponentNameFromType(Component) || "Unknown";
-
- if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
- error(
- "%s: Function components do not support getDerivedStateFromProps.",
- _componentName3
- );
-
- didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
- }
- }
+ if (current !== null) {
+ var prevProps = current.memoizedProps;
if (
- typeof Component.contextType === "object" &&
- Component.contextType !== null
+ shallowEqual(prevProps, nextProps) &&
+ current.ref === workInProgress.ref && // Prevent bailout if the implementation changed due to hot reload.
+ workInProgress.type === current.type
) {
- var _componentName4 = getComponentNameFromType(Component) || "Unknown";
+ didReceiveUpdate = false;
- if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
- error(
- "%s: Function components do not support contextType.",
- _componentName4
+ if (!checkScheduledUpdateOrContext(current, renderLanes)) {
+ // 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 accumulated 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
+ // to account for it here, too. Reset to the value of the current fiber.
+ // NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
+ // because a MemoComponent fiber does not have hooks or an update queue;
+ // rather, it wraps around an inner component, which may or may not
+ // contains hooks.
+ // TODO: Move the reset at in beginWork out of the common path so that
+ // this is no longer necessary.
+ workInProgress.lanes = current.lanes;
+ return bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
);
-
- didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
+ } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
+ // This is a special case that only exists for legacy mode.
+ // See https://github.com/facebook/react/pull/19216.
+ didReceiveUpdate = true;
}
}
}
-}
-
-var SUSPENDED_MARKER = {
- dehydrated: null,
- retryLane: NoLane
-};
-function mountSuspenseOffscreenState(renderLanes) {
- return {
- baseLanes: renderLanes,
- cachePool: getSuspendedCachePool()
- };
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
}
-function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
- var cachePool = null;
-
- return {
- baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes),
- cachePool: cachePool
- };
-} // TODO: Probably should inline this back
+function updateOffscreenComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps;
+ var nextChildren = nextProps.children;
+ var prevState = current !== null ? current.memoizedState : null;
-function shouldRemainOnFallback(
- suspenseContext,
- current,
- workInProgress,
- renderLanes
-) {
- // 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 (nextProps.mode === "hidden" || enableLegacyHidden) {
+ // Rendering a hidden tree.
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ // In legacy sync mode, don't defer the subtree. Render it now.
+ var nextState = {
+ baseLanes: NoLanes,
+ cachePool: null
+ };
+ workInProgress.memoizedState = nextState;
- 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;
+ pushRenderLanes(workInProgress, renderLanes);
+ } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
+ var spawnedCachePool = null; // We're hidden, and we're not rendering at Offscreen. We will bail out
+ // and resume this tree later.
+
+ 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.
+
+ workInProgress.lanes = workInProgress.childLanes = laneToLanes(
+ OffscreenLane
+ );
+ var _nextState = {
+ baseLanes: nextBaseLanes,
+ cachePool: spawnedCachePool
+ };
+ workInProgress.memoizedState = _nextState;
+ workInProgress.updateQueue = null;
+ // to avoid a push/pop misalignment.
+
+ pushRenderLanes(workInProgress, nextBaseLanes);
+
+ return null;
+ } else {
+ // This is the second render. The surrounding visible content has already
+ // committed. Now we resume rendering the hidden tree.
+ // Rendering at offscreen, so we can clear the base lanes.
+ var _nextState2 = {
+ baseLanes: NoLanes,
+ cachePool: null
+ };
+ workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out.
+
+ var subtreeRenderLanes =
+ prevState !== null ? prevState.baseLanes : renderLanes;
+
+ pushRenderLanes(workInProgress, subtreeRenderLanes);
}
- } // Not currently showing content. Consult the Suspense context.
+ } else {
+ // Rendering a visible tree.
+ var _subtreeRenderLanes;
- return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
+ if (prevState !== null) {
+ // We're going from hidden -> visible.
+ _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes);
+
+ 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;
+ }
}
-function getRemainingWorkInPrimaryTree(current, renderLanes) {
- // TODO: Should not remove render lanes that were pinged during this render
- return removeLanes(current.childLanes, renderLanes);
+function updateFragment(current, workInProgress, renderLanes) {
+ var nextChildren = workInProgress.pendingProps;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
}
-function updateSuspenseComponent(current, workInProgress, renderLanes) {
- var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
+function updateMode(current, workInProgress, renderLanes) {
+ var nextChildren = workInProgress.pendingProps.children;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
+function updateProfiler(current, workInProgress, renderLanes) {
{
- if (shouldSuspend(workInProgress)) {
- workInProgress.flags |= DidCapture;
+ workInProgress.flags |= 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,
+ var stateNode = workInProgress.stateNode;
+ stateNode.effectDuration = 0;
+ stateNode.passiveEffectDuration = 0;
}
}
- var suspenseContext = suspenseStackCursor.current;
- var showFallback = false;
- var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags;
+ var nextProps = workInProgress.pendingProps;
+ var nextChildren = nextProps.children;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
- if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
- // Something in this boundary's subtree already suspended. Switch to
- // rendering the fallback children.
- showFallback = true;
- workInProgress.flags &= ~DidCapture;
- } else {
- // Attempting the main content
- if (current === null || current.memoizedState !== null) {
- // This is a new mount or this boundary is already showing a fallback state.
- // Mark this subtree context as having at least one invisible parent that could
- // handle the fallback state.
- // Boundaries without fallbacks or should be avoided are not considered since
- // they cannot handle preferred fallback states.
- if (
- nextProps.fallback !== undefined &&
- nextProps.unstable_avoidThisFallback !== true
- ) {
- suspenseContext = addSubtreeSuspenseContext(
- suspenseContext,
- InvisibleParentSuspenseContext
+function markRef$1(current, workInProgress) {
+ var ref = workInProgress.ref;
+
+ if (
+ (current === null && ref !== null) ||
+ (current !== null && current.ref !== ref)
+ ) {
+ // Schedule a Ref effect
+ workInProgress.flags |= Ref;
+ }
+}
+
+function updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var innerPropTypes = Component.propTypes;
+
+ if (innerPropTypes) {
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(Component)
);
}
}
}
- suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
- 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.
- //
- // 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).
- //
- // 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.
- //
- // 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.
+ var context;
- 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);
+ {
+ var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
+ context = getMaskedContext(workInProgress, unmaskedContext);
+ }
- var nextPrimaryChildren = nextProps.children;
- var nextFallbackChildren = nextProps.fallback;
+ var nextChildren;
+ prepareToReadContext(workInProgress, renderLanes);
- if (showFallback) {
- var fallbackFragment = mountSuspenseFallbackChildren(
- workInProgress,
- nextPrimaryChildren,
- nextFallbackChildren,
- renderLanes
- );
- var primaryChildFragment = workInProgress.child;
- primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- );
- workInProgress.memoizedState = SUSPENDED_MARKER;
- return fallbackFragment;
- } else if (typeof nextProps.unstable_expectedLoadTime === "number") {
- // This is a CPU-bound tree. Skip this tree and show a placeholder to
- // unblock the surrounding content. Then immediately retry after the
- // initial commit.
- var _fallbackFragment = mountSuspenseFallbackChildren(
- workInProgress,
- nextPrimaryChildren,
- nextFallbackChildren,
- renderLanes
- );
+ {
+ ReactCurrentOwner$1.current = workInProgress;
+ setIsRendering(true);
+ nextChildren = renderWithHooks(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ context,
+ renderLanes
+ );
- var _primaryChildFragment = workInProgress.child;
- _primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- );
- workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to
- // get it started back up to attempt the next item. While in terms of
- // priority this work has the same priority as this current render, it's
- // not part of the same transition once the transition has committed. If
- // it's sync, we still want to yield so that it can be painted.
- // Conceptually, this is really the same as pinging. We can use any
- // RetryLane even if it's the one currently rendering since we're leaving
- // it behind on this node.
-
- workInProgress.lanes = SomeRetryLane;
- return _fallbackFragment;
- } else {
- return mountSuspensePrimaryChildren(
- workInProgress,
- nextPrimaryChildren,
- renderLanes
- );
- }
- } else {
- // This is an update.
- // If the current fiber has a SuspenseState, that means it's already showing
- // a fallback.
- var prevState = current.memoizedState;
+ setIsRendering(false);
+ }
- if (prevState !== null) {
- if (showFallback) {
- var _nextFallbackChildren2 = nextProps.fallback;
- var _nextPrimaryChildren2 = nextProps.children;
+ if (current !== null && !didReceiveUpdate) {
+ bailoutHooks(current, workInProgress, renderLanes);
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
- var _fallbackChildFragment = updateSuspenseFallbackChildren(
- current,
- workInProgress,
- _nextPrimaryChildren2,
- _nextFallbackChildren2,
- renderLanes
- );
+ workInProgress.flags |= PerformedWork;
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
+}
- var _primaryChildFragment3 = workInProgress.child;
- var prevOffscreenState = current.child.memoizedState;
- _primaryChildFragment3.memoizedState =
- prevOffscreenState === null
- ? mountSuspenseOffscreenState(renderLanes)
- : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
- _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(
- current,
- renderLanes
- );
- workInProgress.memoizedState = SUSPENDED_MARKER;
- return _fallbackChildFragment;
- } else {
- var _nextPrimaryChildren3 = nextProps.children;
+function updateClassComponent(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ {
+ // This is used by DevTools to force a boundary to error.
+ switch (shouldError(workInProgress)) {
+ case false: {
+ var _instance = workInProgress.stateNode;
+ var ctor = workInProgress.type; // TODO This way of resetting the error boundary state is a hack.
+ // Is there a better way to do this?
- var _primaryChildFragment4 = updateSuspensePrimaryChildren(
- current,
- workInProgress,
- _nextPrimaryChildren3,
- renderLanes
+ var tempInstance = new ctor(
+ workInProgress.memoizedProps,
+ _instance.context
);
+ var state = tempInstance.state;
- workInProgress.memoizedState = null;
- return _primaryChildFragment4;
+ _instance.updater.enqueueSetState(_instance, state, null);
+
+ break;
}
- } else {
- // The current tree is not already showing a fallback.
- if (showFallback) {
- // Timed out.
- var _nextFallbackChildren3 = nextProps.fallback;
- var _nextPrimaryChildren4 = nextProps.children;
- var _fallbackChildFragment2 = updateSuspenseFallbackChildren(
- current,
+ case true: {
+ workInProgress.flags |= DidCapture;
+ workInProgress.flags |= ShouldCapture; // eslint-disable-next-line react-internal/prod-error-codes
+
+ var error$1 = new Error("Simulated error coming from DevTools");
+ var lane = pickArbitraryLane(renderLanes);
+ workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state
+
+ var update = createClassErrorUpdate(
workInProgress,
- _nextPrimaryChildren4,
- _nextFallbackChildren3,
- renderLanes
+ createCapturedValue(error$1, workInProgress),
+ lane
);
+ enqueueCapturedUpdate(workInProgress, update);
+ break;
+ }
+ }
- var _primaryChildFragment5 = workInProgress.child;
- var _prevOffscreenState = current.child.memoizedState;
- _primaryChildFragment5.memoizedState =
- _prevOffscreenState === null
- ? mountSuspenseOffscreenState(renderLanes)
- : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
- _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(
- current,
- renderLanes
- ); // Skip the primary children, and continue working on the
- // fallback children.
+ if (workInProgress.type !== workInProgress.elementType) {
+ // Lazy component props can't be validated in createElement
+ // because they're only guaranteed to be resolved here.
+ var innerPropTypes = Component.propTypes;
+
+ if (innerPropTypes) {
+ checkPropTypes(
+ innerPropTypes,
+ nextProps, // Resolved props
+ "prop",
+ getComponentNameFromType(Component)
+ );
+ }
+ }
+ } // Push context providers early to prevent context stack mismatches.
+ // During mounting we don't know the child context yet as the instance doesn't exist.
+ // We will invalidate the child context in finishClassComponent() right after rendering.
+
+ var hasContext;
+
+ if (isContextProvider(Component)) {
+ hasContext = true;
+ pushContextProvider(workInProgress);
+ } else {
+ hasContext = false;
+ }
+
+ prepareToReadContext(workInProgress, renderLanes);
+ var instance = workInProgress.stateNode;
+ var shouldUpdate;
+
+ if (instance === null) {
+ if (current !== null) {
+ // A class component without an instance only mounts if it suspended
+ // inside a non-concurrent tree, in an inconsistent state. We want to
+ // treat it like a new mount, even though an empty version of it already
+ // committed. Disconnect the alternate pointers.
+ current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
+
+ workInProgress.flags |= Placement;
+ } // In the initial pass we might need to construct the instance.
+
+ constructClassInstance(workInProgress, Component, nextProps);
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
+ shouldUpdate = true;
+ } else if (current === null) {
+ // In a resume, we'll already have an instance we can reuse.
+ shouldUpdate = resumeMountClassInstance(
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
+ } else {
+ shouldUpdate = updateClassInstance(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+ );
+ }
+
+ var nextUnitOfWork = finishClassComponent(
+ current,
+ workInProgress,
+ Component,
+ shouldUpdate,
+ hasContext,
+ renderLanes
+ );
- workInProgress.memoizedState = SUSPENDED_MARKER;
- return _fallbackChildFragment2;
- } else {
- // Still haven't timed out. Continue rendering the children, like we
- // normally do.
- var _nextPrimaryChildren5 = nextProps.children;
+ {
+ var inst = workInProgress.stateNode;
- var _primaryChildFragment6 = updateSuspensePrimaryChildren(
- current,
- workInProgress,
- _nextPrimaryChildren5,
- renderLanes
+ if (shouldUpdate && inst.props !== nextProps) {
+ if (!didWarnAboutReassigningProps) {
+ error(
+ "It looks like %s is reassigning its own `this.props` while rendering. " +
+ "This is not supported and can lead to confusing bugs.",
+ getComponentNameFromFiber(workInProgress) || "a component"
);
-
- workInProgress.memoizedState = null;
- return _primaryChildFragment6;
}
+
+ didWarnAboutReassigningProps = true;
}
}
-}
-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;
+ return nextUnitOfWork;
}
-function mountSuspenseFallbackChildren(
+function finishClassComponent(
+ current,
workInProgress,
- primaryChildren,
- fallbackChildren,
+ Component,
+ shouldUpdate,
+ hasContext,
renderLanes
) {
- var mode = workInProgress.mode;
- var progressedPrimaryFragment = workInProgress.child;
- var primaryChildProps = {
- mode: "hidden",
- children: primaryChildren
- };
- var primaryChildFragment;
- var fallbackChildFragment;
-
- if (
- (mode & ConcurrentMode) === 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;
+ // Refs should update even if shouldComponentUpdate returns false
+ markRef$1(current, workInProgress);
+ var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags;
- 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;
+ if (!shouldUpdate && !didCaptureError) {
+ // Context providers should defer to sCU for rendering
+ if (hasContext) {
+ invalidateContextProvider(workInProgress, Component, false);
}
- fallbackChildFragment = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- );
- } else {
- primaryChildFragment = createFiberFromOffscreen(
- primaryChildProps,
- mode,
- NoLanes,
- null
- );
- fallbackChildFragment = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
- primaryChildFragment.return = workInProgress;
- fallbackChildFragment.return = workInProgress;
- primaryChildFragment.sibling = fallbackChildFragment;
- workInProgress.child = primaryChildFragment;
- return fallbackChildFragment;
-}
+ var instance = workInProgress.stateNode; // Rerender
-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);
-}
+ ReactCurrentOwner$1.current = workInProgress;
+ var nextChildren;
+
+ if (
+ didCaptureError &&
+ typeof Component.getDerivedStateFromError !== "function"
+ ) {
+ // If we captured an error, but getDerivedStateFromError is not defined,
+ // unmount all the children. componentDidCatch will schedule an update to
+ // re-render a fallback. This is temporary until we migrate everyone to
+ // the new API.
+ // TODO: Warn in a future release.
+ nextChildren = null;
-function updateSuspensePrimaryChildren(
- current,
- workInProgress,
- primaryChildren,
- renderLanes
-) {
- var currentPrimaryChildFragment = current.child;
- var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
- var primaryChildFragment = createWorkInProgressOffscreenFiber(
- currentPrimaryChildFragment,
{
- mode: "visible",
- children: primaryChildren
+ stopProfilerTimerIfRunning();
}
- );
+ } else {
+ {
+ setIsRendering(true);
+ nextChildren = instance.render();
- if ((workInProgress.mode & ConcurrentMode) === NoMode) {
- primaryChildFragment.lanes = renderLanes;
- }
+ setIsRendering(false);
+ }
+ } // React DevTools reads this flag.
- primaryChildFragment.return = workInProgress;
- primaryChildFragment.sibling = null;
+ workInProgress.flags |= PerformedWork;
- if (currentFallbackChildFragment !== null) {
- // Delete the fallback child fragment
- var deletions = workInProgress.deletions;
+ if (current !== null && didCaptureError) {
+ // If we're recovering from an error, reconcile without reusing any of
+ // the existing children. Conceptually, the normal children and the children
+ // that are shown on error are two different sets, so we shouldn't reuse
+ // normal children even if their identities match.
+ forceUnmountCurrentAndReconcile(
+ current,
+ workInProgress,
+ nextChildren,
+ renderLanes
+ );
+ } else {
+ 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.
- if (deletions === null) {
- workInProgress.deletions = [currentFallbackChildFragment];
- workInProgress.flags |= ChildDeletion;
- } else {
- deletions.push(currentFallbackChildFragment);
- }
+ workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
+
+ if (hasContext) {
+ invalidateContextProvider(workInProgress, Component, true);
}
- workInProgress.child = primaryChildFragment;
- return primaryChildFragment;
+ return workInProgress.child;
}
-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;
+function pushHostRootContext(workInProgress) {
+ var root = workInProgress.stateNode;
- if (
- // In legacy mode, we commit the primary tree as if it successfully
- // completed, even though it's in an inconsistent state.
- (mode & ConcurrentMode) === 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 (root.pendingContext) {
+ pushTopLevelContextObject(
+ workInProgress,
+ root.pendingContext,
+ root.pendingContext !== root.context
+ );
+ } else if (root.context) {
+ // Should always be set
+ pushTopLevelContextObject(workInProgress, root.context, false);
+ }
- 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 during the first pass.
- // However, since we're going to remain on the fallback, we no longer want
- // to delete it.
+ pushHostContainer(workInProgress, root.containerInfo);
+}
- workInProgress.deletions = null;
- } else {
- primaryChildFragment = createWorkInProgressOffscreenFiber(
- currentPrimaryChildFragment,
- primaryChildProps
- ); // Since we're reusing a current tree, we need to reuse the flags, too.
- // (We don't do this in legacy mode, because in legacy mode we don't re-use
- // the current tree; see previous branch.)
+function updateHostRoot(current, workInProgress, renderLanes) {
+ pushHostRootContext(workInProgress);
- primaryChildFragment.subtreeFlags =
- currentPrimaryChildFragment.subtreeFlags & StaticMask;
+ if (current === null) {
+ throw new Error("Should have a current fiber. This is a bug in React.");
}
- var fallbackChildFragment;
+ var nextProps = workInProgress.pendingProps;
+ var prevState = workInProgress.memoizedState;
+ var prevChildren = prevState.element;
+ cloneUpdateQueue(current, workInProgress);
+ processUpdateQueue(workInProgress, nextProps, null, renderLanes);
+ var nextState = workInProgress.memoizedState;
+ var root = workInProgress.stateNode;
+ // being called "element".
- 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.
+ var nextChildren = nextState.element;
- fallbackChildFragment.flags |= Placement;
+ {
+ if (nextChildren === prevChildren) {
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
+
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
}
- fallbackChildFragment.return = workInProgress;
- primaryChildFragment.return = workInProgress;
- primaryChildFragment.sibling = fallbackChildFragment;
- workInProgress.child = primaryChildFragment;
- return fallbackChildFragment;
+ return workInProgress.child;
}
-function scheduleWorkOnFiber(fiber, renderLanes) {
- fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
- var alternate = fiber.alternate;
+function updateHostComponent$1(current, workInProgress, renderLanes) {
+ pushHostContext(workInProgress);
- if (alternate !== null) {
- alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
+ var type = workInProgress.type;
+ var nextProps = workInProgress.pendingProps;
+ var prevProps = current !== null ? current.memoizedProps : null;
+ var nextChildren = nextProps.children;
+
+ if (prevProps !== null && shouldSetTextContent()) {
+ // If we're switching from a direct text child to a normal child, or to
+ // empty, we need to schedule the text content to be reset.
+ workInProgress.flags |= ContentReset;
}
- scheduleWorkOnParentPath(fiber.return, renderLanes);
+ markRef$1(current, workInProgress);
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ return workInProgress.child;
}
-function propagateSuspenseContextChange(
+function updateHostText$1(current, workInProgress) {
+ // immediately after.
+
+ return null;
+}
+
+function mountLazyComponent(
+ _current,
workInProgress,
- firstChild,
+ elementType,
renderLanes
) {
- // Mark any Suspense boundaries with fallbacks as having work to do.
- // If they were previously forced into fallbacks, they may now be able
- // to unblock.
- var node = firstChild;
+ if (_current !== null) {
+ // A lazy component only mounts if it suspended inside a non-
+ // concurrent tree, in an inconsistent state. We want to treat it like
+ // a new mount, even though an empty version of it already committed.
+ // Disconnect the alternate pointers.
+ _current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
- while (node !== null) {
- if (node.tag === SuspenseComponent) {
- var state = node.memoizedState;
+ workInProgress.flags |= Placement;
+ }
- if (state !== null) {
- scheduleWorkOnFiber(node, renderLanes);
+ 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));
+ var resolvedProps = resolveDefaultProps(Component, props);
+ var child;
+
+ switch (resolvedTag) {
+ case FunctionComponent: {
+ {
+ validateFunctionComponentInDev(workInProgress, Component);
+ workInProgress.type = Component = resolveFunctionForHotReloading(
+ Component
+ );
}
- } else if (node.tag === SuspenseListComponent) {
- // If the tail is hidden there might not be an Suspense boundaries
- // to schedule work on. In this case we have to schedule it on the
- // 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, renderLanes);
- } else if (node.child !== null) {
- node.child.return = node;
- node = node.child;
- continue;
+
+ child = updateFunctionComponent(
+ null,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ return child;
}
- if (node === workInProgress) {
- return;
+ case ClassComponent: {
+ {
+ workInProgress.type = Component = resolveClassForHotReloading(
+ Component
+ );
+ }
+
+ child = updateClassComponent(
+ null,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ return child;
}
- while (node.sibling === null) {
- if (node.return === null || node.return === workInProgress) {
- return;
+ case ForwardRef: {
+ {
+ workInProgress.type = Component = resolveForwardRefForHotReloading(
+ Component
+ );
}
- node = node.return;
+ child = updateForwardRef(
+ null,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ return child;
}
- node.sibling.return = node.return;
- node = node.sibling;
+ case MemoComponent: {
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ var outerPropTypes = Component.propTypes;
+
+ if (outerPropTypes) {
+ checkPropTypes(
+ outerPropTypes,
+ resolvedProps, // Resolved for outer only
+ "prop",
+ getComponentNameFromType(Component)
+ );
+ }
+ }
+ }
+
+ child = updateMemoComponent(
+ null,
+ workInProgress,
+ Component,
+ resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
+ renderLanes
+ );
+ return child;
+ }
+ }
+
+ var hint = "";
+
+ {
+ if (
+ Component !== null &&
+ typeof Component === "object" &&
+ Component.$$typeof === REACT_LAZY_TYPE
+ ) {
+ hint = " Did you wrap a component in React.lazy() more than once?";
+ }
+ } // This message intentionally doesn't mention ForwardRef or MemoComponent
+ // because the fact that it's a separate type of work is an
+ // implementation detail.
+
+ throw new Error(
+ "Element type is invalid. Received a promise that resolves to: " +
+ Component +
+ ". " +
+ ("Lazy element type must resolve to a class or function." + hint)
+ );
+}
+
+function mountIncompleteClassComponent(
+ _current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
+) {
+ if (_current !== null) {
+ // An incomplete component only mounts if it suspended inside a non-
+ // concurrent tree, in an inconsistent state. We want to treat it like
+ // a new mount, even though an empty version of it already committed.
+ // Disconnect the alternate pointers.
+ _current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
+
+ workInProgress.flags |= Placement;
+ } // Promote the fiber to a class and try rendering again.
+
+ workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
+ // Push context providers early to prevent context stack mismatches.
+ // During mounting we don't know the child context yet as the instance doesn't exist.
+ // We will invalidate the child context in finishClassComponent() right after rendering.
+
+ var hasContext;
+
+ if (isContextProvider(Component)) {
+ hasContext = true;
+ pushContextProvider(workInProgress);
+ } else {
+ hasContext = false;
}
+
+ prepareToReadContext(workInProgress, renderLanes);
+ constructClassInstance(workInProgress, Component, nextProps);
+ mountClassInstance(workInProgress, Component, nextProps, renderLanes);
+ return finishClassComponent(
+ null,
+ workInProgress,
+ Component,
+ true,
+ hasContext,
+ renderLanes
+ );
}
-function findLastContentRow(firstChild) {
- // This is going to find the last row among these children that is already
- // showing content on the screen, as opposed to being in fallback state or
- // new. If a row has multiple Suspense boundaries, any of them being in the
- // fallback state, counts as the whole row being in a fallback state.
- // Note that the "rows" will be workInProgress, but any nested children
- // will still be current since we haven't rendered them yet. The mounted
- // order may not be the same as the new order. We use the new order.
- var row = firstChild;
- var lastContentRow = null;
+function mountIndeterminateComponent(
+ _current,
+ workInProgress,
+ Component,
+ renderLanes
+) {
+ if (_current !== null) {
+ // An indeterminate component only mounts if it suspended inside a non-
+ // concurrent tree, in an inconsistent state. We want to treat it like
+ // a new mount, even though an empty version of it already committed.
+ // Disconnect the alternate pointers.
+ _current.alternate = null;
+ workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
- while (row !== null) {
- var currentRow = row.alternate; // New rows can't be content rows.
+ workInProgress.flags |= Placement;
+ }
- if (currentRow !== null && findFirstSuspended(currentRow) === null) {
- lastContentRow = row;
- }
+ var props = workInProgress.pendingProps;
+ var context;
- row = row.sibling;
+ {
+ var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
+ context = getMaskedContext(workInProgress, unmaskedContext);
}
- return lastContentRow;
-}
+ prepareToReadContext(workInProgress, renderLanes);
+ var value;
-function validateRevealOrder(revealOrder) {
{
if (
- revealOrder !== undefined &&
- revealOrder !== "forwards" &&
- revealOrder !== "backwards" &&
- revealOrder !== "together" &&
- !didWarnAboutRevealOrder[revealOrder]
+ Component.prototype &&
+ typeof Component.prototype.render === "function"
) {
- didWarnAboutRevealOrder[revealOrder] = true;
-
- if (typeof revealOrder === "string") {
- switch (revealOrder.toLowerCase()) {
- case "together":
- case "forwards":
- case "backwards": {
- error(
- '"%s" is not a valid value for revealOrder on . ' +
- 'Use lowercase "%s" instead.',
- revealOrder,
- revealOrder.toLowerCase()
- );
-
- break;
- }
-
- case "forward":
- case "backward": {
- error(
- '"%s" is not a valid value for revealOrder on . ' +
- 'React uses the -s suffix in the spelling. Use "%ss" instead.',
- revealOrder,
- revealOrder.toLowerCase()
- );
-
- break;
- }
-
- default:
- error(
- '"%s" is not a supported revealOrder on . ' +
- 'Did you mean "together", "forwards" or "backwards"?',
- revealOrder
- );
-
- break;
- }
- } else {
- error(
- "%s is not a supported value for revealOrder on . " +
- 'Did you mean "together", "forwards" or "backwards"?',
- revealOrder
- );
- }
- }
- }
-}
-
-function validateTailOptions(tailMode, revealOrder) {
- {
- if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
- if (tailMode !== "collapsed" && tailMode !== "hidden") {
- didWarnAboutTailOptions[tailMode] = true;
+ var componentName = getComponentNameFromType(Component) || "Unknown";
+ if (!didWarnAboutBadClass[componentName]) {
error(
- '"%s" is not a supported value for tail on . ' +
- 'Did you mean "collapsed" or "hidden"?',
- tailMode
+ "The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
+ "This is likely to cause errors. Change %s to extend React.Component instead.",
+ componentName,
+ componentName
);
- } else if (revealOrder !== "forwards" && revealOrder !== "backwards") {
- didWarnAboutTailOptions[tailMode] = true;
- error(
- ' is only valid if revealOrder is ' +
- '"forwards" or "backwards". ' +
- 'Did you mean to specify revealOrder="forwards"?',
- tailMode
- );
+ didWarnAboutBadClass[componentName] = true;
}
}
- }
-}
-
-function validateSuspenseListNestedChild(childSlot, index) {
- {
- var isAnArray = isArray(childSlot);
- var isIterable =
- !isAnArray && typeof getIteratorFn(childSlot) === "function";
- if (isAnArray || isIterable) {
- var type = isAnArray ? "array" : "iterable";
-
- error(
- "A nested %s was passed to row #%s in . Wrap it in " +
- "an additional SuspenseList to configure its revealOrder: " +
- " ... " +
- "{%s} ... " +
- "",
- type,
- index,
- type
- );
-
- return false;
+ if (workInProgress.mode & StrictLegacyMode) {
+ ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
}
+
+ setIsRendering(true);
+ ReactCurrentOwner$1.current = workInProgress;
+ value = renderWithHooks(
+ null,
+ workInProgress,
+ Component,
+ props,
+ context,
+ renderLanes
+ );
+ setIsRendering(false);
}
- return true;
-}
+ workInProgress.flags |= PerformedWork;
-function validateSuspenseListChildren(children, revealOrder) {
{
+ // 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 (
- (revealOrder === "forwards" || revealOrder === "backwards") &&
- children !== undefined &&
- children !== null &&
- children !== false
+ typeof value === "object" &&
+ value !== null &&
+ typeof value.render === "function" &&
+ value.$$typeof === undefined
) {
- if (isArray(children)) {
- for (var i = 0; i < children.length; i++) {
- if (!validateSuspenseListNestedChild(children[i], i)) {
- return;
- }
- }
- } else {
- var iteratorFn = getIteratorFn(children);
-
- if (typeof iteratorFn === "function") {
- var childrenIterator = iteratorFn.call(children);
-
- if (childrenIterator) {
- var step = childrenIterator.next();
- var _i = 0;
+ var _componentName = getComponentNameFromType(Component) || "Unknown";
- for (; !step.done; step = childrenIterator.next()) {
- if (!validateSuspenseListNestedChild(step.value, _i)) {
- return;
- }
+ 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
+ );
- _i++;
- }
- }
- } else {
- error(
- 'A single row was passed to a . ' +
- "This is not useful since it needs multiple rows. " +
- "Did you mean to pass multiple children or an array?",
- revealOrder
- );
- }
+ didWarnAboutModulePatternComponent[_componentName] = true;
}
}
}
-}
-function initSuspenseListRenderState(
- workInProgress,
- isBackwards,
- tail,
- lastContentRow,
- tailMode
-) {
- var renderState = workInProgress.memoizedState;
+ 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 _componentName2 = getComponentNameFromType(Component) || "Unknown";
- if (renderState === null) {
- workInProgress.memoizedState = {
- isBackwards: isBackwards,
- rendering: null,
- renderingStartTime: 0,
- last: lastContentRow,
- tail: tail,
- tailMode: tailMode
- };
- } else {
- // We can reuse the existing object from previous renders.
- renderState.isBackwards = isBackwards;
- renderState.rendering = null;
- renderState.renderingStartTime = 0;
- renderState.last = lastContentRow;
- renderState.tail = tail;
- renderState.tailMode = tailMode;
- }
-} // This can end up rendering this component multiple passes.
-// The first pass splits the children fibers into two sets. A head and tail.
-// We first render the head. If anything is in fallback state, we do another
-// pass through beginWork to rerender all children (including the tail) with
-// the force suspend context. If the first render didn't have anything in
-// 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.
+ 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.",
+ _componentName2,
+ _componentName2,
+ _componentName2
+ );
+
+ didWarnAboutModulePatternComponent[_componentName2] = true;
+ }
+ } // Proceed under the assumption that this is a class instance
-function updateSuspenseListComponent(current, workInProgress, renderLanes) {
- var nextProps = workInProgress.pendingProps;
- var revealOrder = nextProps.revealOrder;
- var tailMode = nextProps.tail;
- var newChildren = nextProps.children;
- validateRevealOrder(revealOrder);
- validateTailOptions(tailMode, revealOrder);
- validateSuspenseListChildren(newChildren, revealOrder);
- reconcileChildren(current, workInProgress, newChildren, renderLanes);
- var suspenseContext = suspenseStackCursor.current;
- var shouldForceFallback = hasSuspenseContext(
- suspenseContext,
- ForceSuspenseFallback
- );
+ workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
- if (shouldForceFallback) {
- suspenseContext = setShallowSuspenseContext(
- suspenseContext,
- ForceSuspenseFallback
- );
- workInProgress.flags |= DidCapture;
- } else {
- var didSuspendBefore =
- current !== null && (current.flags & DidCapture) !== NoFlags;
+ workInProgress.memoizedState = null;
+ workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches.
+ // During mounting we don't know the child context yet as the instance doesn't exist.
+ // We will invalidate the child context in finishClassComponent() right after rendering.
- if (didSuspendBefore) {
- // If we previously forced a fallback, we need to schedule work
- // on any nested boundaries to let them know to try to render
- // again. This is the same as context updating.
- propagateSuspenseContextChange(
- workInProgress,
- workInProgress.child,
- renderLanes
- );
+ var hasContext = false;
+
+ if (isContextProvider(Component)) {
+ hasContext = true;
+ pushContextProvider(workInProgress);
+ } else {
+ hasContext = false;
}
- suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
- }
+ workInProgress.memoizedState =
+ value.state !== null && value.state !== undefined ? value.state : null;
+ initializeUpdateQueue(workInProgress);
+ adoptClassInstance(workInProgress, value);
+ mountClassInstance(workInProgress, Component, props, renderLanes);
+ return finishClassComponent(
+ null,
+ workInProgress,
+ Component,
+ true,
+ hasContext,
+ renderLanes
+ );
+ } else {
+ // Proceed under the assumption that this is a function component
+ workInProgress.tag = FunctionComponent;
- pushSuspenseContext(workInProgress, suspenseContext);
+ reconcileChildren(null, workInProgress, value, renderLanes);
- if ((workInProgress.mode & ConcurrentMode) === NoMode) {
- // 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 {
- switch (revealOrder) {
- case "forwards": {
- var lastContentRow = findLastContentRow(workInProgress.child);
- var tail;
+ {
+ validateFunctionComponentInDev(workInProgress, Component);
+ }
- if (lastContentRow === null) {
- // The whole list is part of the tail.
- // TODO: We could fast path by just rendering the tail now.
- tail = workInProgress.child;
- workInProgress.child = null;
- } else {
- // Disconnect the tail rows after the content row.
- // We're going to render them separately later.
- tail = lastContentRow.sibling;
- lastContentRow.sibling = null;
- }
+ return workInProgress.child;
+ }
+}
- initSuspenseListRenderState(
- workInProgress,
- false, // isBackwards
- tail,
- lastContentRow,
- tailMode
+function validateFunctionComponentInDev(workInProgress, Component) {
+ {
+ if (Component) {
+ if (Component.childContextTypes) {
+ error(
+ "%s(...): childContextTypes cannot be defined on a function component.",
+ Component.displayName || Component.name || "Component"
);
- break;
}
+ }
- case "backwards": {
- // We're going to find the first row that has existing content.
- // At the same time we're going to reverse the list of everything
- // we pass in the meantime. That's going to be our tail in reverse
- // order.
- var _tail = null;
- var row = workInProgress.child;
- workInProgress.child = null;
+ if (workInProgress.ref !== null) {
+ var info = "";
+ var ownerName = getCurrentFiberOwnerNameInDevOrNull();
- while (row !== null) {
- var currentRow = row.alternate; // New rows can't be content rows.
+ if (ownerName) {
+ info += "\n\nCheck the render method of `" + ownerName + "`.";
+ }
- if (currentRow !== null && findFirstSuspended(currentRow) === null) {
- // This is the beginning of the main content.
- workInProgress.child = row;
- break;
- }
+ var warningKey = ownerName || "";
+ var debugSource = workInProgress._debugSource;
- var nextRow = row.sibling;
- row.sibling = _tail;
- _tail = row;
- row = nextRow;
- } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
+ if (debugSource) {
+ warningKey = debugSource.fileName + ":" + debugSource.lineNumber;
+ }
- initSuspenseListRenderState(
- workInProgress,
- true, // isBackwards
- _tail,
- null, // last
- tailMode
+ if (!didWarnAboutFunctionRefs[warningKey]) {
+ didWarnAboutFunctionRefs[warningKey] = true;
+
+ error(
+ "Function components cannot be given refs. " +
+ "Attempts to access this ref will fail. " +
+ "Did you mean to use React.forwardRef()?%s",
+ info
);
- break;
}
+ }
- case "together": {
- initSuspenseListRenderState(
- workInProgress,
- false, // isBackwards
- null, // tail
- null, // last
- undefined
+ if (typeof Component.getDerivedStateFromProps === "function") {
+ var _componentName3 = getComponentNameFromType(Component) || "Unknown";
+
+ if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
+ error(
+ "%s: Function components do not support getDerivedStateFromProps.",
+ _componentName3
);
- break;
+
+ didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
}
+ }
- default: {
- // The default reveal order is the same as not having
- // a boundary.
- workInProgress.memoizedState = null;
+ if (
+ typeof Component.contextType === "object" &&
+ Component.contextType !== null
+ ) {
+ var _componentName4 = getComponentNameFromType(Component) || "Unknown";
+
+ if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
+ error(
+ "%s: Function components do not support contextType.",
+ _componentName4
+ );
+
+ didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
}
}
}
+}
- return workInProgress.child;
+var SUSPENDED_MARKER = {
+ dehydrated: null,
+ treeContext: null,
+ retryLane: NoLane
+};
+
+function mountSuspenseOffscreenState(renderLanes) {
+ return {
+ baseLanes: renderLanes,
+ cachePool: getSuspendedCache()
+ };
}
-function updatePortalComponent(current, workInProgress, renderLanes) {
- pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
- var nextChildren = workInProgress.pendingProps;
+function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
+ var cachePool = null;
- if (current === null) {
- // Portals are special because we don't append the children during mount
- // but at commit. Therefore we need to track insertions which the normal
- // flow doesn't do during mount. This doesn't happen at the root because
- // the root always starts with a "current" with a null child.
- // TODO: Consider unifying this with how the root works.
- workInProgress.child = reconcileChildFibers(
- workInProgress,
- null,
- nextChildren,
- renderLanes
- );
- } else {
- reconcileChildren(current, workInProgress, nextChildren, renderLanes);
- }
+ return {
+ baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes),
+ cachePool: cachePool
+ };
+} // TODO: Probably should inline this back
- return workInProgress.child;
-}
+function shouldRemainOnFallback(
+ suspenseContext,
+ current,
+ workInProgress,
+ renderLanes
+) {
+ // 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;
-var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
+ if (suspenseState === null) {
+ // Currently showing content. Don't hide it, even if ForceSuspenseFallback
+ // 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.
-function updateContextProvider(current, workInProgress, renderLanes) {
- var providerType = workInProgress.type;
- var context = providerType._context;
- var newProps = workInProgress.pendingProps;
- var oldProps = workInProgress.memoizedProps;
- var newValue = newProps.value;
+ 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.
{
- if (!("value" in newProps)) {
- if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
- hasWarnedAboutUsingNoValuePropOnContextProvider = true;
+ if (shouldSuspend(workInProgress)) {
+ workInProgress.flags |= DidCapture;
+ }
+ }
- error(
- "The `value` prop is required for the ``. Did you misspell it or forget to pass it?"
+ var suspenseContext = suspenseStackCursor.current;
+ var showFallback = false;
+ var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags;
+
+ if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
+ // Something in this boundary's subtree already suspended. Switch to
+ // rendering the fallback children.
+ showFallback = true;
+ workInProgress.flags &= ~DidCapture;
+ } else {
+ // Attempting the main content
+ if (current === null || current.memoizedState !== null) {
+ // This is a new mount or this boundary is already showing a fallback state.
+ // Mark this subtree context as having at least one invisible parent that could
+ // handle the fallback state.
+ // Avoided boundaries are not considered since they cannot handle preferred fallback states.
+ {
+ suspenseContext = addSubtreeSuspenseContext(
+ suspenseContext,
+ InvisibleParentSuspenseContext
);
}
}
+ }
- var providerPropTypes = workInProgress.type.propTypes;
+ suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
+ pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense
+ // boundary's children. This involves some custom reconciliation logic. Two
+ // main reasons this is so complicated.
+ //
+ // 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).
+ //
+ // 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.
+ //
+ // 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 (providerPropTypes) {
- checkPropTypes(providerPropTypes, newProps, "prop", "Context.Provider");
+ if (current === null) {
+ var nextPrimaryChildren = nextProps.children;
+ var nextFallbackChildren = nextProps.fallback;
+
+ if (showFallback) {
+ var fallbackFragment = mountSuspenseFallbackChildren(
+ workInProgress,
+ nextPrimaryChildren,
+ nextFallbackChildren,
+ renderLanes
+ );
+ var primaryChildFragment = workInProgress.child;
+ primaryChildFragment.memoizedState = mountSuspenseOffscreenState(
+ renderLanes
+ );
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return fallbackFragment;
+ } else {
+ return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren);
}
- }
+ } else {
+ // This is an update.
+ // If the current fiber has a SuspenseState, that means it's already showing
+ // a fallback.
+ var prevState = current.memoizedState;
- pushProvider(workInProgress, context, newValue);
+ if (prevState !== null) {
+ if (showFallback) {
+ var _nextFallbackChildren2 = nextProps.fallback;
+ var _nextPrimaryChildren2 = nextProps.children;
- {
- if (oldProps !== null) {
- var oldValue = oldProps.value;
+ var _fallbackChildFragment = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren2,
+ _nextFallbackChildren2,
+ renderLanes
+ );
- if (objectIs(oldValue, newValue)) {
- // No change. Bailout early if children are the same.
- if (oldProps.children === newProps.children && !hasContextChanged()) {
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
- );
- }
+ var _primaryChildFragment3 = workInProgress.child;
+ var prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment3.memoizedState =
+ prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
+ _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ );
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return _fallbackChildFragment;
} else {
- // The context value changed. Search for matching consumers and schedule
- // them to update.
- propagateContextChange(workInProgress, context, renderLanes);
+ var _nextPrimaryChildren3 = nextProps.children;
+
+ var _primaryChildFragment4 = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren3,
+ renderLanes
+ );
+
+ workInProgress.memoizedState = null;
+ return _primaryChildFragment4;
}
- }
- }
+ } else {
+ // The current tree is not already showing a fallback.
+ if (showFallback) {
+ // Timed out.
+ var _nextFallbackChildren3 = nextProps.fallback;
+ var _nextPrimaryChildren4 = nextProps.children;
- var newChildren = newProps.children;
- reconcileChildren(current, workInProgress, newChildren, renderLanes);
- return workInProgress.child;
-}
+ var _fallbackChildFragment2 = updateSuspenseFallbackChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren4,
+ _nextFallbackChildren3,
+ renderLanes
+ );
-var hasWarnedAboutUsingContextAsConsumer = false;
+ var _primaryChildFragment5 = workInProgress.child;
+ var _prevOffscreenState = current.child.memoizedState;
+ _primaryChildFragment5.memoizedState =
+ _prevOffscreenState === null
+ ? mountSuspenseOffscreenState(renderLanes)
+ : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
+ _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(
+ current,
+ renderLanes
+ ); // Skip the primary children, and continue working on the
+ // fallback children.
-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
- // so we use the old behaviour (Context.Consumer references Context) to
- // reduce size and overhead. The separate object references context via
- // a property called "_context", which also gives us the ability to check
- // in DEV mode if this property exists or not and warn if it does not.
+ workInProgress.memoizedState = SUSPENDED_MARKER;
+ return _fallbackChildFragment2;
+ } else {
+ // Still haven't timed out. Continue rendering the children, like we
+ // normally do.
+ var _nextPrimaryChildren5 = nextProps.children;
- {
- if (context._context === undefined) {
- // This may be because it's a Context (rather than a Consumer).
- // Or it may be because it's older React where they're the same thing.
- // We only want to warn if we're sure it's a new React.
- if (context !== context.Consumer) {
- if (!hasWarnedAboutUsingContextAsConsumer) {
- hasWarnedAboutUsingContextAsConsumer = true;
+ var _primaryChildFragment6 = updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ _nextPrimaryChildren5,
+ renderLanes
+ );
- error(
- "Rendering directly is not supported and will be removed in " +
- "a future major release. Did you mean to render instead?"
- );
- }
+ workInProgress.memoizedState = null;
+ return _primaryChildFragment6;
}
- } else {
- context = context._context;
}
}
+}
- var newProps = workInProgress.pendingProps;
- var render = newProps.children;
+function mountSuspensePrimaryChildren(
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var mode = workInProgress.mode;
+ var primaryChildProps = {
+ mode: "visible",
+ children: primaryChildren
+ };
+ var primaryChildFragment = mountWorkInProgressOffscreenFiber(
+ primaryChildProps,
+ mode
+ );
+ primaryChildFragment.return = workInProgress;
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
+}
- {
- if (typeof render !== "function") {
- error(
- "A context consumer was rendered with multiple children, or a child " +
- "that isn't a function. A context consumer expects a single child " +
- "that is a function. If you did pass a function, make sure there " +
- "is no trailing or leading whitespace around it."
- );
+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 & ConcurrentMode) === 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;
}
- }
-
- prepareToReadContext(workInProgress, renderLanes);
- var newValue = readContext(context);
- var newChildren;
- {
- ReactCurrentOwner$1.current = workInProgress;
- setIsRendering(true);
- newChildren = render(newValue);
- setIsRendering(false);
- } // React DevTools reads this flag.
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ } else {
+ primaryChildFragment = mountWorkInProgressOffscreenFiber(
+ primaryChildProps,
+ mode
+ );
+ fallbackChildFragment = createFiberFromFragment(
+ fallbackChildren,
+ mode,
+ renderLanes,
+ null
+ );
+ }
- workInProgress.flags |= PerformedWork;
- reconcileChildren(current, workInProgress, newChildren, renderLanes);
- return workInProgress.child;
+ primaryChildFragment.return = workInProgress;
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
}
-function markWorkInProgressReceivedUpdate() {
- didReceiveUpdate = true;
+function mountWorkInProgressOffscreenFiber(offscreenProps, mode, renderLanes) {
+ // The props argument to `createFiberFromOffscreen` is `any` typed, so we use
+ // this wrapper function to constrain it.
+ return createFiberFromOffscreen(offscreenProps, mode, NoLanes, null);
}
-function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
- if (current !== null) {
- // Reuse previous dependencies
- workInProgress.dependencies = current.dependencies;
- }
-
- {
- // Don't update "base" render times for bailouts.
- stopProfilerTimerIfRunning();
- }
-
- markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.
+function updateWorkInProgressOffscreenFiber(current, offscreenProps) {
+ // The props argument to `createWorkInProgress` is `any` typed, so we use this
+ // wrapper function to constrain it.
+ return createWorkInProgress(current, offscreenProps);
+}
- 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.
+function updateSuspensePrimaryChildren(
+ current,
+ workInProgress,
+ primaryChildren,
+ renderLanes
+) {
+ var currentPrimaryChildFragment = current.child;
+ var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
+ var primaryChildFragment = updateWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
{
- return null;
+ mode: "visible",
+ children: primaryChildren
}
- } // This fiber doesn't have work, but its subtree does. Clone the child
- // fibers and continue.
-
- cloneChildFibers(current, workInProgress);
- return workInProgress.child;
-}
-
-function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
- {
- var returnFiber = oldWorkInProgress.return;
-
- if (returnFiber === null) {
- throw new Error("Cannot swap the root fiber.");
- } // Disconnect from the old current.
- // It will get deleted.
-
- current.alternate = null;
- oldWorkInProgress.alternate = null; // Connect to the new tree.
-
- newWorkInProgress.index = oldWorkInProgress.index;
- newWorkInProgress.sibling = oldWorkInProgress.sibling;
- newWorkInProgress.return = oldWorkInProgress.return;
- newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
-
- if (oldWorkInProgress === returnFiber.child) {
- returnFiber.child = newWorkInProgress;
- } else {
- var prevSibling = returnFiber.child;
-
- if (prevSibling === null) {
- throw new Error("Expected parent to have a child.");
- }
-
- while (prevSibling.sibling !== oldWorkInProgress) {
- prevSibling = prevSibling.sibling;
+ );
- if (prevSibling === null) {
- throw new Error("Expected to find the previous sibling.");
- }
- }
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ primaryChildFragment.lanes = renderLanes;
+ }
- prevSibling.sibling = newWorkInProgress;
- } // Delete the old fiber and place the new one.
- // Since the old fiber is disconnected, we have to schedule it manually.
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = null;
- var deletions = returnFiber.deletions;
+ if (currentFallbackChildFragment !== null) {
+ // Delete the fallback child fragment
+ var deletions = workInProgress.deletions;
if (deletions === null) {
- returnFiber.deletions = [current];
- returnFiber.flags |= ChildDeletion;
+ workInProgress.deletions = [currentFallbackChildFragment];
+ workInProgress.flags |= ChildDeletion;
} else {
- deletions.push(current);
+ deletions.push(currentFallbackChildFragment);
}
-
- newWorkInProgress.flags |= Placement; // Restart work from the new fiber.
-
- return newWorkInProgress;
}
+
+ workInProgress.child = primaryChildFragment;
+ return primaryChildFragment;
}
-function beginWork(current, workInProgress, renderLanes) {
- var updateLanes = workInProgress.lanes;
+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;
- {
- if (workInProgress._debugNeedsRemount && current !== null) {
- // This will restart the begin phase with a new fiber.
- return remountFiber(
- current,
- workInProgress,
- createFiberFromTypeAndProps(
- workInProgress.type,
- workInProgress.key,
- workInProgress.pendingProps,
- workInProgress._debugOwner || null,
- workInProgress.mode,
- workInProgress.lanes
- )
- );
+ if (
+ // In legacy mode, we commit the primary tree as if it successfully
+ // completed, even though it's in an inconsistent state.
+ (mode & ConcurrentMode) === 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;
}
- }
+ // However, since we're going to remain on the fallback, we no longer want
+ // to delete it.
- if (current !== null) {
- var oldProps = current.memoizedProps;
- var newProps = workInProgress.pendingProps;
+ workInProgress.deletions = null;
+ } else {
+ primaryChildFragment = updateWorkInProgressOffscreenFiber(
+ currentPrimaryChildFragment,
+ primaryChildProps
+ );
+ // (We don't do this in legacy mode, because in legacy mode we don't re-use
+ // the current tree; see previous branch.)
- if (
- oldProps !== newProps ||
- hasContextChanged() || // Force a re-render if the implementation changed due to hot reload:
- workInProgress.type !== current.type
- ) {
- // 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 (!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.
+ primaryChildFragment.subtreeFlags =
+ currentPrimaryChildFragment.subtreeFlags & StaticMask;
+ }
- switch (workInProgress.tag) {
- case HostRoot:
- pushHostRootContext(workInProgress);
- break;
+ var fallbackChildFragment;
- case HostComponent:
- pushHostContext(workInProgress);
- break;
+ 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.
- case ClassComponent: {
- var Component = workInProgress.type;
+ fallbackChildFragment.flags |= Placement;
+ }
- if (isContextProvider(Component)) {
- pushContextProvider(workInProgress);
- }
+ fallbackChildFragment.return = workInProgress;
+ primaryChildFragment.return = workInProgress;
+ primaryChildFragment.sibling = fallbackChildFragment;
+ workInProgress.child = primaryChildFragment;
+ return fallbackChildFragment;
+}
- break;
- }
+function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) {
+ fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
+ var alternate = fiber.alternate;
+
+ if (alternate !== null) {
+ alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
+ }
- case HostPortal:
- pushHostContainer(
- workInProgress,
- workInProgress.stateNode.containerInfo
- );
- break;
+ scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot);
+}
- case ContextProvider: {
- var newValue = workInProgress.memoizedProps.value;
- var context = workInProgress.type._context;
- pushProvider(workInProgress, context, newValue);
- break;
- }
+function propagateSuspenseContextChange(
+ workInProgress,
+ firstChild,
+ renderLanes
+) {
+ // Mark any Suspense boundaries with fallbacks as having work to do.
+ // If they were previously forced into fallbacks, they may now be able
+ // to unblock.
+ var node = firstChild;
- case Profiler:
- {
- // Profiler should only call onRender when one of its descendants actually rendered.
- var hasChildWork = includesSomeLane(
- renderLanes,
- workInProgress.childLanes
- );
+ while (node !== null) {
+ if (node.tag === SuspenseComponent) {
+ var state = node.memoizedState;
- if (hasChildWork) {
- workInProgress.flags |= Update;
- }
+ if (state !== null) {
+ scheduleSuspenseWorkOnFiber(node, renderLanes, workInProgress);
+ }
+ } else if (node.tag === SuspenseListComponent) {
+ // If the tail is hidden there might not be an Suspense boundaries
+ // to schedule work on. In this case we have to schedule it on the
+ // list itself.
+ // We don't have to traverse to the children of the list since
+ // the list will propagate the change when it rerenders.
+ scheduleSuspenseWorkOnFiber(node, renderLanes, workInProgress);
+ } else if (node.child !== null) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
- {
- // 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,
- var stateNode = workInProgress.stateNode;
- stateNode.effectDuration = 0;
- stateNode.passiveEffectDuration = 0;
- }
- }
+ if (node === workInProgress) {
+ return;
+ }
- break;
+ while (node.sibling === null) {
+ if (node.return === null || node.return === workInProgress) {
+ return;
+ }
- case SuspenseComponent: {
- var state = workInProgress.memoizedState;
+ node = node.return;
+ }
- if (state !== null) {
- // whether to retry the primary children, or to skip over it and
- // go straight to the fallback. Check the priority of the primary
- // child fragment.
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+}
- var primaryChildFragment = workInProgress.child;
- var primaryChildLanes = primaryChildFragment.childLanes;
+function findLastContentRow(firstChild) {
+ // This is going to find the last row among these children that is already
+ // showing content on the screen, as opposed to being in fallback state or
+ // new. If a row has multiple Suspense boundaries, any of them being in the
+ // fallback state, counts as the whole row being in a fallback state.
+ // Note that the "rows" will be workInProgress, but any nested children
+ // will still be current since we haven't rendered them yet. The mounted
+ // order may not be the same as the new order. We use the new order.
+ var row = firstChild;
+ var lastContentRow = null;
- 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,
- renderLanes
- );
- } else {
- // The primary child fragment does not have pending work marked
- // on it
- pushSuspenseContext(
- workInProgress,
- setDefaultShallowSuspenseContext(suspenseStackCursor.current)
- ); // The primary children do not have pending work with sufficient
- // priority. Bailout.
-
- var child = bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
- );
+ while (row !== null) {
+ var currentRow = row.alternate; // New rows can't be content rows.
- if (child !== null) {
- // The fallback children have pending work. Skip over the
- // primary children and work on the fallback.
- return child.sibling;
- } else {
- // Note: We can return `null` here because we already checked
- // whether there were nested context consumers, via the call to
- // `bailoutOnAlreadyFinishedWork` above.
- return null;
- }
- }
- } else {
- pushSuspenseContext(
- workInProgress,
- setDefaultShallowSuspenseContext(suspenseStackCursor.current)
- );
- }
+ if (currentRow !== null && findFirstSuspended(currentRow) === null) {
+ lastContentRow = row;
+ }
- break;
- }
+ row = row.sibling;
+ }
- case SuspenseListComponent: {
- var didSuspendBefore = (current.flags & DidCapture) !== NoFlags;
+ return lastContentRow;
+}
- var _hasChildWork = includesSomeLane(
- renderLanes,
- workInProgress.childLanes
- );
+function validateRevealOrder(revealOrder) {
+ {
+ if (
+ revealOrder !== undefined &&
+ revealOrder !== "forwards" &&
+ revealOrder !== "backwards" &&
+ revealOrder !== "together" &&
+ !didWarnAboutRevealOrder[revealOrder]
+ ) {
+ didWarnAboutRevealOrder[revealOrder] = true;
- if (didSuspendBefore) {
- if (_hasChildWork) {
- // If something was in fallback state last time, and we have all the
- // same children then we're still in progressive loading state.
- // Something might get unblocked by state updates or retries in the
- // tree which will affect the tail. So we need to use the normal
- // path to compute the correct tail.
- return updateSuspenseListComponent(
- current,
- workInProgress,
- 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
- // as before. We can fast bail out.
+ if (typeof revealOrder === "string") {
+ switch (revealOrder.toLowerCase()) {
+ case "together":
+ case "forwards":
+ case "backwards": {
+ error(
+ '"%s" is not a valid value for revealOrder on . ' +
+ 'Use lowercase "%s" instead.',
+ revealOrder,
+ revealOrder.toLowerCase()
+ );
- workInProgress.flags |= DidCapture;
- } // If nothing suspended before and we're rendering the same children,
- // then the tail doesn't matter. Anything new that suspends will work
- // in the "together" mode, so we can continue from the state we had.
-
- var renderState = workInProgress.memoizedState;
-
- if (renderState !== null) {
- // Reset to the "together" mode in case we've started a different
- // update in the past but didn't complete it.
- renderState.rendering = null;
- renderState.tail = null;
- renderState.lastEffect = null;
+ break;
}
- pushSuspenseContext(workInProgress, suspenseStackCursor.current);
+ case "forward":
+ case "backward": {
+ error(
+ '"%s" is not a valid value for revealOrder on . ' +
+ 'React uses the -s suffix in the spelling. Use "%ss" instead.',
+ revealOrder,
+ revealOrder.toLowerCase()
+ );
- if (_hasChildWork) {
break;
- } else {
- // 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
- // as before. We can fast bail out.
- 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);
- }
- }
+ default:
+ error(
+ '"%s" is not a supported revealOrder on . ' +
+ 'Did you mean "together", "forwards" or "backwards"?',
+ revealOrder
+ );
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
- } else {
- if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
- // This is a special case that only exists for legacy mode.
- // See https://github.com/facebook/react/pull/19216.
- didReceiveUpdate = true;
+ break;
+ }
} 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;
+ error(
+ "%s is not a supported value for revealOrder on . " +
+ 'Did you mean "together", "forwards" or "backwards"?',
+ revealOrder
+ );
}
}
- } else {
- didReceiveUpdate = false;
- } // Before entering the begin phase, clear pending update priority.
- // TODO: This assumes that we're about to evaluate the component and process
- // the update queue. However, there's an exception: SimpleMemoComponent
- // 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.lanes = NoLanes;
-
- switch (workInProgress.tag) {
- case IndeterminateComponent: {
- return mountIndeterminateComponent(
- current,
- workInProgress,
- workInProgress.type,
- renderLanes
- );
- }
-
- case LazyComponent: {
- var elementType = workInProgress.elementType;
- return mountLazyComponent(
- current,
- workInProgress,
- elementType,
- updateLanes,
- renderLanes
- );
- }
-
- case FunctionComponent: {
- var _Component = workInProgress.type;
- var unresolvedProps = workInProgress.pendingProps;
- var resolvedProps =
- workInProgress.elementType === _Component
- ? unresolvedProps
- : resolveDefaultProps(_Component, unresolvedProps);
- return updateFunctionComponent(
- current,
- workInProgress,
- _Component,
- resolvedProps,
- renderLanes
- );
- }
+ }
+}
- case ClassComponent: {
- var _Component2 = workInProgress.type;
- var _unresolvedProps = workInProgress.pendingProps;
+function validateTailOptions(tailMode, revealOrder) {
+ {
+ if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
+ if (tailMode !== "collapsed" && tailMode !== "hidden") {
+ didWarnAboutTailOptions[tailMode] = true;
- var _resolvedProps =
- workInProgress.elementType === _Component2
- ? _unresolvedProps
- : resolveDefaultProps(_Component2, _unresolvedProps);
+ error(
+ '"%s" is not a supported value for tail on . ' +
+ 'Did you mean "collapsed" or "hidden"?',
+ tailMode
+ );
+ } else if (revealOrder !== "forwards" && revealOrder !== "backwards") {
+ didWarnAboutTailOptions[tailMode] = true;
- return updateClassComponent(
- current,
- workInProgress,
- _Component2,
- _resolvedProps,
- renderLanes
- );
+ error(
+ ' is only valid if revealOrder is ' +
+ '"forwards" or "backwards". ' +
+ 'Did you mean to specify revealOrder="forwards"?',
+ tailMode
+ );
+ }
}
+ }
+}
- case HostRoot:
- return updateHostRoot(current, workInProgress, renderLanes);
-
- case HostComponent:
- return updateHostComponent(current, workInProgress, renderLanes);
-
- case HostText:
- return updateHostText();
-
- case SuspenseComponent:
- return updateSuspenseComponent(current, workInProgress, renderLanes);
-
- case HostPortal:
- return updatePortalComponent(current, workInProgress, renderLanes);
-
- case ForwardRef: {
- var type = workInProgress.type;
- var _unresolvedProps2 = workInProgress.pendingProps;
-
- var _resolvedProps2 =
- workInProgress.elementType === type
- ? _unresolvedProps2
- : resolveDefaultProps(type, _unresolvedProps2);
+function validateSuspenseListNestedChild(childSlot, index) {
+ {
+ var isAnArray = isArray(childSlot);
+ var isIterable =
+ !isAnArray && typeof getIteratorFn(childSlot) === "function";
- return updateForwardRef(
- current,
- workInProgress,
+ if (isAnArray || isIterable) {
+ var type = isAnArray ? "array" : "iterable";
+
+ error(
+ "A nested %s was passed to row #%s in . Wrap it in " +
+ "an additional SuspenseList to configure its revealOrder: " +
+ " ... " +
+ "{%s} ... " +
+ "",
type,
- _resolvedProps2,
- renderLanes
+ index,
+ type
);
- }
-
- case Fragment:
- return updateFragment(current, workInProgress, renderLanes);
- case Mode:
- return updateMode(current, workInProgress, renderLanes);
-
- case Profiler:
- return updateProfiler(current, workInProgress, renderLanes);
+ return false;
+ }
+ }
- case ContextProvider:
- return updateContextProvider(current, workInProgress, renderLanes);
+ return true;
+}
- case ContextConsumer:
- return updateContextConsumer(current, workInProgress, renderLanes);
+function validateSuspenseListChildren(children, revealOrder) {
+ {
+ if (
+ (revealOrder === "forwards" || revealOrder === "backwards") &&
+ children !== undefined &&
+ children !== null &&
+ children !== false
+ ) {
+ if (isArray(children)) {
+ for (var i = 0; i < children.length; i++) {
+ if (!validateSuspenseListNestedChild(children[i], i)) {
+ return;
+ }
+ }
+ } else {
+ var iteratorFn = getIteratorFn(children);
- case MemoComponent: {
- var _type2 = workInProgress.type;
- var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
+ if (typeof iteratorFn === "function") {
+ var childrenIterator = iteratorFn.call(children);
- var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
+ if (childrenIterator) {
+ var step = childrenIterator.next();
+ var _i = 0;
- {
- if (workInProgress.type !== workInProgress.elementType) {
- var outerPropTypes = _type2.propTypes;
+ for (; !step.done; step = childrenIterator.next()) {
+ if (!validateSuspenseListNestedChild(step.value, _i)) {
+ return;
+ }
- if (outerPropTypes) {
- checkPropTypes(
- outerPropTypes,
- _resolvedProps3, // Resolved for outer only
- "prop",
- getComponentNameFromType(_type2)
- );
+ _i++;
+ }
}
+ } else {
+ error(
+ 'A single row was passed to a . ' +
+ "This is not useful since it needs multiple rows. " +
+ "Did you mean to pass multiple children or an array?",
+ revealOrder
+ );
}
}
-
- _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
- return updateMemoComponent(
- current,
- workInProgress,
- _type2,
- _resolvedProps3,
- updateLanes,
- renderLanes
- );
}
+ }
+}
- case SimpleMemoComponent: {
- return updateSimpleMemoComponent(
- current,
- workInProgress,
- workInProgress.type,
- workInProgress.pendingProps,
- updateLanes,
- renderLanes
- );
- }
+function initSuspenseListRenderState(
+ workInProgress,
+ isBackwards,
+ tail,
+ lastContentRow,
+ tailMode
+) {
+ var renderState = workInProgress.memoizedState;
- case IncompleteClassComponent: {
- var _Component3 = workInProgress.type;
- var _unresolvedProps4 = workInProgress.pendingProps;
+ if (renderState === null) {
+ workInProgress.memoizedState = {
+ isBackwards: isBackwards,
+ rendering: null,
+ renderingStartTime: 0,
+ last: lastContentRow,
+ tail: tail,
+ tailMode: tailMode
+ };
+ } else {
+ // We can reuse the existing object from previous renders.
+ renderState.isBackwards = isBackwards;
+ renderState.rendering = null;
+ renderState.renderingStartTime = 0;
+ renderState.last = lastContentRow;
+ renderState.tail = tail;
+ renderState.tailMode = tailMode;
+ }
+} // This can end up rendering this component multiple passes.
+// The first pass splits the children fibers into two sets. A head and tail.
+// We first render the head. If anything is in fallback state, we do another
+// pass through beginWork to rerender all children (including the tail) with
+// the force suspend context. If the first render didn't have anything in
+// 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.
- var _resolvedProps4 =
- workInProgress.elementType === _Component3
- ? _unresolvedProps4
- : resolveDefaultProps(_Component3, _unresolvedProps4);
+function updateSuspenseListComponent(current, workInProgress, renderLanes) {
+ var nextProps = workInProgress.pendingProps;
+ var revealOrder = nextProps.revealOrder;
+ var tailMode = nextProps.tail;
+ var newChildren = nextProps.children;
+ validateRevealOrder(revealOrder);
+ validateTailOptions(tailMode, revealOrder);
+ validateSuspenseListChildren(newChildren, revealOrder);
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
+ var suspenseContext = suspenseStackCursor.current;
+ var shouldForceFallback = hasSuspenseContext(
+ suspenseContext,
+ ForceSuspenseFallback
+ );
- return mountIncompleteClassComponent(
- current,
+ if (shouldForceFallback) {
+ suspenseContext = setShallowSuspenseContext(
+ suspenseContext,
+ ForceSuspenseFallback
+ );
+ workInProgress.flags |= DidCapture;
+ } else {
+ var didSuspendBefore =
+ current !== null && (current.flags & DidCapture) !== NoFlags;
+
+ if (didSuspendBefore) {
+ // If we previously forced a fallback, we need to schedule work
+ // on any nested boundaries to let them know to try to render
+ // again. This is the same as context updating.
+ propagateSuspenseContextChange(
workInProgress,
- _Component3,
- _resolvedProps4,
+ workInProgress.child,
renderLanes
);
}
- case SuspenseListComponent: {
- return updateSuspenseListComponent(current, workInProgress, renderLanes);
- }
+ suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
+ }
- case ScopeComponent: {
- break;
- }
+ pushSuspenseContext(workInProgress, suspenseContext);
- case OffscreenComponent: {
- return updateOffscreenComponent(current, workInProgress, renderLanes);
- }
+ if ((workInProgress.mode & ConcurrentMode) === NoMode) {
+ // 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 {
+ switch (revealOrder) {
+ case "forwards": {
+ var lastContentRow = findLastContentRow(workInProgress.child);
+ var tail;
- case LegacyHiddenComponent: {
- return updateLegacyHiddenComponent(current, workInProgress, renderLanes);
- }
- }
+ if (lastContentRow === null) {
+ // The whole list is part of the tail.
+ // TODO: We could fast path by just rendering the tail now.
+ tail = workInProgress.child;
+ workInProgress.child = null;
+ } else {
+ // Disconnect the tail rows after the content row.
+ // We're going to render them separately later.
+ tail = lastContentRow.sibling;
+ lastContentRow.sibling = null;
+ }
- {
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
- }
-}
+ initSuspenseListRenderState(
+ workInProgress,
+ false, // isBackwards
+ tail,
+ lastContentRow,
+ tailMode
+ );
+ break;
+ }
-function markUpdate(workInProgress) {
- // Tag the fiber with an update effect. This turns a Placement into
- // a PlacementAndUpdate.
- workInProgress.flags |= Update;
-}
+ case "backwards": {
+ // We're going to find the first row that has existing content.
+ // At the same time we're going to reverse the list of everything
+ // we pass in the meantime. That's going to be our tail in reverse
+ // order.
+ var _tail = null;
+ var row = workInProgress.child;
+ workInProgress.child = null;
-function markRef$1(workInProgress) {
- workInProgress.flags |= Ref;
-}
+ while (row !== null) {
+ var currentRow = row.alternate; // New rows can't be content rows.
-var appendAllChildren;
-var updateHostContainer;
-var updateHostComponent$1;
-var updateHostText$1;
+ if (currentRow !== null && findFirstSuspended(currentRow) === null) {
+ // This is the beginning of the main content.
+ workInProgress.child = row;
+ break;
+ }
-{
- // Mutation mode
- appendAllChildren = function(
- parent,
- workInProgress,
- needsVisibilityToggle,
- isHidden
- ) {
- // We only have the top Fiber that was created but we need recurse down its
- // children to find all the terminal nodes.
- var node = workInProgress.child;
+ var nextRow = row.sibling;
+ row.sibling = _tail;
+ _tail = row;
+ row = nextRow;
+ } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
- while (node !== null) {
- if (node.tag === HostComponent || node.tag === HostText) {
- appendInitialChild(parent, node.stateNode);
- } else if (node.tag === HostPortal);
- else if (node.child !== null) {
- node.child.return = node;
- node = node.child;
- continue;
+ initSuspenseListRenderState(
+ workInProgress,
+ true, // isBackwards
+ _tail,
+ null, // last
+ tailMode
+ );
+ break;
}
- if (node === workInProgress) {
- return;
+ case "together": {
+ initSuspenseListRenderState(
+ workInProgress,
+ false, // isBackwards
+ null, // tail
+ null, // last
+ undefined
+ );
+ break;
}
- while (node.sibling === null) {
- if (node.return === null || node.return === workInProgress) {
- return;
- }
-
- node = node.return;
+ default: {
+ // The default reveal order is the same as not having
+ // a boundary.
+ workInProgress.memoizedState = null;
}
-
- node.sibling.return = node.return;
- node = node.sibling;
}
- };
-
- updateHostContainer = function(current, workInProgress) {
- // Noop
- };
-
- updateHostComponent$1 = function(
- current,
- workInProgress,
- type,
- newProps,
- rootContainerInstance
- ) {
- // If we have an alternate, that means this is an update and we need to
- // schedule a side-effect to do the updates.
- var oldProps = current.memoizedProps;
-
- if (oldProps === newProps) {
- // In mutation mode, this is sufficient for a bailout because
- // we won't touch this node even if children changed.
- return;
- } // If we get updated because one of our children updated, we don't
- // have newProps so we'll have to reuse them.
- // TODO: Split the update API as separate for the props vs. children.
- // Even better would be if children weren't special cased at all tho.
-
- var instance = workInProgress.stateNode;
- var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
- // component is hitting the resume path. Figure out why. Possibly
- // related to `hidden`.
+ }
- var updatePayload = prepareUpdate(); // TODO: Type this specific to this type of component.
+ return workInProgress.child;
+}
- workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
- // is a new ref we mark this as an update. All the work is done in commitWork.
+function updatePortalComponent(current, workInProgress, renderLanes) {
+ pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
+ var nextChildren = workInProgress.pendingProps;
- if (updatePayload) {
- markUpdate(workInProgress);
- }
- };
+ if (current === null) {
+ // Portals are special because we don't append the children during mount
+ // but at commit. Therefore we need to track insertions which the normal
+ // flow doesn't do during mount. This doesn't happen at the root because
+ // the root always starts with a "current" with a null child.
+ // TODO: Consider unifying this with how the root works.
+ workInProgress.child = reconcileChildFibers(
+ workInProgress,
+ null,
+ nextChildren,
+ renderLanes
+ );
+ } else {
+ reconcileChildren(current, workInProgress, nextChildren, renderLanes);
+ }
- updateHostText$1 = function(current, workInProgress, oldText, newText) {
- // If the text differs, mark it as an update. All the work in done in commitWork.
- if (oldText !== newText) {
- markUpdate(workInProgress);
- }
- };
+ return workInProgress.child;
}
-function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
- switch (renderState.tailMode) {
- case "hidden": {
- // Any insertions at the end of the tail list after this point
- // should be invisible. If there are already mounted boundaries
- // anything before them are not considered for collapsing.
- // Therefore we need to go through the whole tail to find if
- // there are any.
- var tailNode = renderState.tail;
- var lastTailNode = null;
+var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
- while (tailNode !== null) {
- if (tailNode.alternate !== null) {
- lastTailNode = tailNode;
- }
+function updateContextProvider(current, workInProgress, renderLanes) {
+ var providerType = workInProgress.type;
+ var context = providerType._context;
+ var newProps = workInProgress.pendingProps;
+ var oldProps = workInProgress.memoizedProps;
+ var newValue = newProps.value;
- tailNode = tailNode.sibling;
- } // Next we're simply going to delete all insertions after the
- // last rendered item.
+ {
+ if (!("value" in newProps)) {
+ if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
+ hasWarnedAboutUsingNoValuePropOnContextProvider = true;
- if (lastTailNode === null) {
- // All remaining items in the tail are insertions.
- renderState.tail = null;
- } else {
- // Detach the insertion after the last node that was already
- // inserted.
- lastTailNode.sibling = null;
+ error(
+ "The `value` prop is required for the ``. Did you misspell it or forget to pass it?"
+ );
}
-
- break;
}
- case "collapsed": {
- // Any insertions at the end of the tail list after this point
- // should be invisible. If there are already mounted boundaries
- // anything before them are not considered for collapsing.
- // Therefore we need to go through the whole tail to find if
- // there are any.
- var _tailNode = renderState.tail;
- var _lastTailNode = null;
+ var providerPropTypes = workInProgress.type.propTypes;
- while (_tailNode !== null) {
- if (_tailNode.alternate !== null) {
- _lastTailNode = _tailNode;
- }
+ if (providerPropTypes) {
+ checkPropTypes(providerPropTypes, newProps, "prop", "Context.Provider");
+ }
+ }
- _tailNode = _tailNode.sibling;
- } // Next we're simply going to delete all insertions after the
- // last rendered item.
+ pushProvider(workInProgress, context, newValue);
- if (_lastTailNode === null) {
- // All remaining items in the tail are insertions.
- if (!hasRenderedATailFallback && renderState.tail !== null) {
- // We suspended during the head. We want to show at least one
- // row at the tail. So we'll keep on and cut off the rest.
- renderState.tail.sibling = null;
- } else {
- renderState.tail = null;
+ {
+ if (oldProps !== null) {
+ var oldValue = oldProps.value;
+
+ if (objectIs(oldValue, newValue)) {
+ // No change. Bailout early if children are the same.
+ if (oldProps.children === newProps.children && !hasContextChanged()) {
+ return bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
+ );
}
} else {
- // Detach the insertion after the last node that was already
- // inserted.
- _lastTailNode.sibling = null;
+ // The context value changed. Search for matching consumers and schedule
+ // them to update.
+ propagateContextChange(workInProgress, context, renderLanes);
}
-
- break;
}
}
-}
-
-function bubbleProperties(completedWork) {
- var didBailout =
- completedWork.alternate !== null &&
- completedWork.alternate.child === completedWork.child;
- var newChildLanes = NoLanes;
- var subtreeFlags = NoFlags;
-
- if (!didBailout) {
- // Bubble up the earliest expiration time.
- if ((completedWork.mode & ProfileMode) !== NoMode) {
- // In profiling mode, resetChildExpirationTime is also used to reset
- // profiler durations.
- var actualDuration = completedWork.actualDuration;
- var treeBaseDuration = completedWork.selfBaseDuration;
- var child = completedWork.child;
- while (child !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(child.lanes, child.childLanes)
- );
- subtreeFlags |= child.subtreeFlags;
- subtreeFlags |= child.flags; // 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.
+ var newChildren = newProps.children;
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
+ return workInProgress.child;
+}
- actualDuration += child.actualDuration;
- treeBaseDuration += child.treeBaseDuration;
- child = child.sibling;
- }
+var hasWarnedAboutUsingContextAsConsumer = false;
- completedWork.actualDuration = actualDuration;
- completedWork.treeBaseDuration = treeBaseDuration;
- } else {
- var _child = completedWork.child;
+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
+ // so we use the old behaviour (Context.Consumer references Context) to
+ // reduce size and overhead. The separate object references context via
+ // a property called "_context", which also gives us the ability to check
+ // in DEV mode if this property exists or not and warn if it does not.
- while (_child !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(_child.lanes, _child.childLanes)
- );
- subtreeFlags |= _child.subtreeFlags;
- subtreeFlags |= _child.flags; // Update the return pointer so the tree is consistent. This is a code
- // smell because it assumes the commit phase is never concurrent with
- // the render phase. Will address during refactor to alternate model.
+ {
+ if (context._context === undefined) {
+ // This may be because it's a Context (rather than a Consumer).
+ // Or it may be because it's older React where they're the same thing.
+ // We only want to warn if we're sure it's a new React.
+ if (context !== context.Consumer) {
+ if (!hasWarnedAboutUsingContextAsConsumer) {
+ hasWarnedAboutUsingContextAsConsumer = true;
- _child.return = completedWork;
- _child = _child.sibling;
+ error(
+ "Rendering directly is not supported and will be removed in " +
+ "a future major release. Did you mean to render instead?"
+ );
+ }
}
+ } else {
+ context = context._context;
}
+ }
- completedWork.subtreeFlags |= subtreeFlags;
- } else {
- // Bubble up the earliest expiration time.
- if ((completedWork.mode & ProfileMode) !== NoMode) {
- // In profiling mode, resetChildExpirationTime is also used to reset
- // profiler durations.
- var _treeBaseDuration = completedWork.selfBaseDuration;
- var _child2 = completedWork.child;
+ var newProps = workInProgress.pendingProps;
+ var render = newProps.children;
- while (_child2 !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(_child2.lanes, _child2.childLanes)
- ); // "Static" flags share the lifetime of the fiber/hook they belong to,
- // so we should bubble those up even during a bailout. All the other
- // flags have a lifetime only of a single render + commit, so we should
- // ignore them.
+ {
+ if (typeof render !== "function") {
+ error(
+ "A context consumer was rendered with multiple children, or a child " +
+ "that isn't a function. A context consumer expects a single child " +
+ "that is a function. If you did pass a function, make sure there " +
+ "is no trailing or leading whitespace around it."
+ );
+ }
+ }
- subtreeFlags |= _child2.subtreeFlags & StaticMask;
- subtreeFlags |= _child2.flags & StaticMask;
- _treeBaseDuration += _child2.treeBaseDuration;
- _child2 = _child2.sibling;
- }
+ prepareToReadContext(workInProgress, renderLanes);
+ var newValue = readContext(context);
- completedWork.treeBaseDuration = _treeBaseDuration;
- } else {
- var _child3 = completedWork.child;
+ var newChildren;
- while (_child3 !== null) {
- newChildLanes = mergeLanes(
- newChildLanes,
- mergeLanes(_child3.lanes, _child3.childLanes)
- ); // "Static" flags share the lifetime of the fiber/hook they belong to,
- // so we should bubble those up even during a bailout. All the other
- // flags have a lifetime only of a single render + commit, so we should
- // ignore them.
+ {
+ ReactCurrentOwner$1.current = workInProgress;
+ setIsRendering(true);
+ newChildren = render(newValue);
+ setIsRendering(false);
+ }
- subtreeFlags |= _child3.subtreeFlags & StaticMask;
- subtreeFlags |= _child3.flags & StaticMask; // Update the return pointer so the tree is consistent. This is a code
- // smell because it assumes the commit phase is never concurrent with
- // the render phase. Will address during refactor to alternate model.
+ workInProgress.flags |= PerformedWork;
+ reconcileChildren(current, workInProgress, newChildren, renderLanes);
+ return workInProgress.child;
+}
- _child3.return = completedWork;
- _child3 = _child3.sibling;
- }
- }
+function markWorkInProgressReceivedUpdate() {
+ didReceiveUpdate = true;
+}
- completedWork.subtreeFlags |= subtreeFlags;
+function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
+ if (current !== null) {
+ // Reuse previous dependencies
+ workInProgress.dependencies = current.dependencies;
}
- completedWork.childLanes = newChildLanes;
- return didBailout;
-}
+ {
+ // Don't update "base" render times for bailouts.
+ stopProfilerTimerIfRunning();
+ }
-function completeWork(current, workInProgress, renderLanes) {
- var newProps = workInProgress.pendingProps;
+ markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.
- switch (workInProgress.tag) {
- case IndeterminateComponent:
- case LazyComponent:
- case SimpleMemoComponent:
- case FunctionComponent:
- case ForwardRef:
- case Fragment:
- case Mode:
- case Profiler:
- case ContextConsumer:
- case MemoComponent:
- bubbleProperties(workInProgress);
+ 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.
+ {
return null;
+ }
+ } // This fiber doesn't have work, but its subtree does. Clone the child
+ // fibers and continue.
- case ClassComponent: {
- var Component = workInProgress.type;
+ cloneChildFibers(current, workInProgress);
+ return workInProgress.child;
+}
- if (isContextProvider(Component)) {
- popContext(workInProgress);
- }
+function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
+ {
+ var returnFiber = oldWorkInProgress.return;
- bubbleProperties(workInProgress);
- return null;
- }
+ if (returnFiber === null) {
+ // eslint-disable-next-line react-internal/prod-error-codes
+ throw new Error("Cannot swap the root fiber.");
+ } // Disconnect from the old current.
+ // It will get deleted.
- case HostRoot: {
- var fiberRoot = workInProgress.stateNode;
+ current.alternate = null;
+ oldWorkInProgress.alternate = null; // Connect to the new tree.
- popHostContainer(workInProgress);
- popTopLevelContextObject(workInProgress);
- resetWorkInProgressVersions();
+ newWorkInProgress.index = oldWorkInProgress.index;
+ newWorkInProgress.sibling = oldWorkInProgress.sibling;
+ newWorkInProgress.return = oldWorkInProgress.return;
+ newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
- if (fiberRoot.pendingContext) {
- fiberRoot.context = fiberRoot.pendingContext;
- fiberRoot.pendingContext = null;
+ if (oldWorkInProgress === returnFiber.child) {
+ returnFiber.child = newWorkInProgress;
+ } else {
+ var prevSibling = returnFiber.child;
+
+ if (prevSibling === null) {
+ // eslint-disable-next-line react-internal/prod-error-codes
+ throw new Error("Expected parent to have a child.");
}
- if (current === null || current.child === null) {
- // If we hydrated, pop so that we can delete any remaining children
- // that weren't hydrated.
- var wasHydrated = popHydrationState();
+ while (prevSibling.sibling !== oldWorkInProgress) {
+ prevSibling = prevSibling.sibling;
- if (wasHydrated) {
- // 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.flags |= Snapshot;
+ if (prevSibling === null) {
+ // eslint-disable-next-line react-internal/prod-error-codes
+ throw new Error("Expected to find the previous sibling.");
}
}
- updateHostContainer(current, workInProgress);
- bubbleProperties(workInProgress);
- return null;
+ prevSibling.sibling = newWorkInProgress;
+ } // Delete the old fiber and place the new one.
+ // Since the old fiber is disconnected, we have to schedule it manually.
+
+ var deletions = returnFiber.deletions;
+
+ if (deletions === null) {
+ returnFiber.deletions = [current];
+ returnFiber.flags |= ChildDeletion;
+ } else {
+ deletions.push(current);
}
- case HostComponent: {
- popHostContext(workInProgress);
- var rootContainerInstance = getRootHostContainer();
- var type = workInProgress.type;
+ newWorkInProgress.flags |= Placement; // Restart work from the new fiber.
- if (current !== null && workInProgress.stateNode != null) {
- updateHostComponent$1(
- current,
- workInProgress,
- type,
- newProps,
- rootContainerInstance
- );
+ return newWorkInProgress;
+ }
+}
- if (current.ref !== workInProgress.ref) {
- markRef$1(workInProgress);
- }
- } else {
- if (!newProps) {
- if (!(workInProgress.stateNode !== null)) {
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- } // This can happen when we abort work.
+function checkScheduledUpdateOrContext(current, renderLanes) {
+ // Before performing an early bailout, we must check if there are pending
+ // updates or context.
+ var updateLanes = current.lanes;
- bubbleProperties(workInProgress);
- return null;
- }
+ if (includesSomeLane(updateLanes, renderLanes)) {
+ return true;
+ } // No pending update, but because context is propagated lazily, we need
- var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
- // "stack" as the parent. Then append children as we go in beginWork
- // or completeWork depending on whether we want to add them top->down or
- // bottom->up. Top->down is faster in IE11.
+ return false;
+}
- var _wasHydrated = popHydrationState();
+function attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+) {
+ // 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.
+ switch (workInProgress.tag) {
+ case HostRoot:
+ pushHostRootContext(workInProgress);
+ var root = workInProgress.stateNode;
+ break;
- if (_wasHydrated) {
- // TODO: Move this and createInstance step into the beginPhase
- // to consolidate.
- if (prepareToHydrateHostInstance()) {
- // If changes to the hydrated node need to be applied at the
- // commit-phase we mark this as such.
- markUpdate(workInProgress);
- }
- } else {
- var instance = createInstance(
- type,
- newProps,
- rootContainerInstance,
- currentHostContext,
- workInProgress
- );
- appendAllChildren(instance, workInProgress, false, false);
- workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount.
- // (eg DOM renderer supports auto-focus for certain elements).
- // Make sure such renderers get scheduled for later work.
+ case HostComponent:
+ pushHostContext(workInProgress);
+ break;
- if (finalizeInitialChildren(instance)) {
- markUpdate(workInProgress);
- }
- }
+ case ClassComponent: {
+ var Component = workInProgress.type;
- if (workInProgress.ref !== null) {
- // If there is a ref on a host node we need to schedule a callback
- markRef$1(workInProgress);
- }
+ if (isContextProvider(Component)) {
+ pushContextProvider(workInProgress);
}
- bubbleProperties(workInProgress);
- return null;
+ break;
}
- case HostText: {
- var newText = newProps;
-
- if (current && workInProgress.stateNode != null) {
- var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
- // to schedule a side-effect to do the updates.
-
- updateHostText$1(current, workInProgress, oldText, newText);
- } else {
- if (typeof newText !== "string") {
- if (!(workInProgress.stateNode !== null)) {
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- } // This can happen when we abort work.
- }
+ case HostPortal:
+ pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
+ break;
- var _rootContainerInstance = getRootHostContainer();
+ case ContextProvider: {
+ var newValue = workInProgress.memoizedProps.value;
+ var context = workInProgress.type._context;
+ pushProvider(workInProgress, context, newValue);
+ break;
+ }
- var _currentHostContext = getHostContext();
+ case Profiler:
+ {
+ // Profiler should only call onRender when one of its descendants actually rendered.
+ var hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
- var _wasHydrated2 = popHydrationState();
+ if (hasChildWork) {
+ workInProgress.flags |= Update;
+ }
- if (_wasHydrated2) {
- if (prepareToHydrateHostTextInstance()) {
- markUpdate(workInProgress);
- }
- } else {
- workInProgress.stateNode = createTextInstance(
- newText,
- _rootContainerInstance,
- _currentHostContext,
- workInProgress
- );
+ {
+ // 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,
+ var stateNode = workInProgress.stateNode;
+ stateNode.effectDuration = 0;
+ stateNode.passiveEffectDuration = 0;
}
}
- bubbleProperties(workInProgress);
- return null;
- }
+ break;
case SuspenseComponent: {
- popSuspenseContext(workInProgress);
- var nextState = workInProgress.memoizedState;
-
- if ((workInProgress.flags & DidCapture) !== NoFlags) {
- // Something suspended. Re-render with the fallback children.
- workInProgress.lanes = renderLanes; // Do not reset the effect list.
-
- if ((workInProgress.mode & ProfileMode) !== NoMode) {
- transferActualDuration(workInProgress);
- } // Don't bubble properties in this case.
+ var state = workInProgress.memoizedState;
- return workInProgress;
- }
+ if (state !== null) {
+ // whether to retry the primary children, or to skip over it and
+ // go straight to the fallback. Check the priority of the primary
+ // child fragment.
- var nextDidTimeout = nextState !== null;
- var prevDidTimeout = false;
+ var primaryChildFragment = workInProgress.child;
+ var primaryChildLanes = primaryChildFragment.childLanes;
- if (current === null) {
- if (workInProgress.memoizedProps.fallback !== undefined);
- } else {
- var prevState = current.memoizedState;
- prevDidTimeout = prevState !== null;
- }
+ 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, renderLanes);
+ } else {
+ // The primary child fragment does not have pending work marked
+ // on it
+ pushSuspenseContext(
+ workInProgress,
+ setDefaultShallowSuspenseContext(suspenseStackCursor.current)
+ ); // The primary children do not have pending work with sufficient
+ // priority. Bailout.
- if (nextDidTimeout && !prevDidTimeout) {
- // TODO: This will still suspend a synchronous tree if anything
- // in the concurrent tree already suspended during this render.
- // This is a known bug.
- if ((workInProgress.mode & ConcurrentMode) !== NoMode) {
- // TODO: Move this back to throwException because this is too late
- // if this is a large tree which is common for initial loads. We
- // don't know if we should restart a render or not until we get
- // this marker, and this is too late.
- // If this render already had a ping or lower pri updates,
- // and this is the first time we know we're going to suspend we
- // should be able to immediately restart from within throwException.
- var hasInvisibleChildContext =
- current === null &&
- workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
+ var child = bailoutOnAlreadyFinishedWork(
+ current,
+ workInProgress,
+ renderLanes
+ );
- if (
- hasInvisibleChildContext ||
- hasSuspenseContext(
- suspenseStackCursor.current,
- InvisibleParentSuspenseContext
- )
- ) {
- // If this was in an invisible tree or a new render, then showing
- // this boundary is ok.
- renderDidSuspend();
+ if (child !== null) {
+ // The fallback children have pending work. Skip over the
+ // primary children and work on the fallback.
+ return child.sibling;
} else {
- // Otherwise, we're going to have to hide content so we should
- // suspend for longer if possible.
- renderDidSuspendDelayIfPossible();
+ // Note: We can return `null` here because we already checked
+ // whether there were nested context consumers, via the call to
+ // `bailoutOnAlreadyFinishedWork` above.
+ return null;
}
}
+ } else {
+ pushSuspenseContext(
+ workInProgress,
+ setDefaultShallowSuspenseContext(suspenseStackCursor.current)
+ );
}
- {
- // TODO: Only schedule updates if these values are non equal, i.e. it changed.
- if (nextDidTimeout || prevDidTimeout) {
- // If this boundary just timed out, schedule an effect to attach a
- // retry listener to the promise. This flag is also used to hide the
- // primary children. In mutation mode, we also need the flag to
- // *unhide* children that were previously hidden, so check if this
- // is currently timed out, too.
- workInProgress.flags |= Update;
- }
- }
+ break;
+ }
- bubbleProperties(workInProgress);
+ case SuspenseListComponent: {
+ var didSuspendBefore = (current.flags & DidCapture) !== NoFlags;
- {
- if ((workInProgress.mode & ProfileMode) !== NoMode) {
- if (nextDidTimeout) {
- // Don't count time spent in a timed out Suspense subtree as part of the base duration.
- var _primaryChildFragment2 = workInProgress.child;
+ var _hasChildWork = includesSomeLane(
+ renderLanes,
+ workInProgress.childLanes
+ );
- if (_primaryChildFragment2 !== null) {
- // $FlowFixMe Flow doesn't support type casting in combination with the -= operator
- workInProgress.treeBaseDuration -=
- _primaryChildFragment2.treeBaseDuration;
- }
- }
- }
+ if (didSuspendBefore) {
+ if (_hasChildWork) {
+ // If something was in fallback state last time, and we have all the
+ // same children then we're still in progressive loading state.
+ // Something might get unblocked by state updates or retries in the
+ // tree which will affect the tail. So we need to use the normal
+ // path to compute the correct tail.
+ return updateSuspenseListComponent(
+ current,
+ workInProgress,
+ 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
+ // as before. We can fast bail out.
+
+ workInProgress.flags |= DidCapture;
+ } // If nothing suspended before and we're rendering the same children,
+ // then the tail doesn't matter. Anything new that suspends will work
+ // in the "together" mode, so we can continue from the state we had.
+
+ var renderState = workInProgress.memoizedState;
+
+ if (renderState !== null) {
+ // Reset to the "together" mode in case we've started a different
+ // update in the past but didn't complete it.
+ renderState.rendering = null;
+ renderState.tail = null;
+ renderState.lastEffect = null;
}
- return null;
+ pushSuspenseContext(workInProgress, suspenseStackCursor.current);
+
+ if (_hasChildWork) {
+ break;
+ } else {
+ // 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
+ // as before. We can fast bail out.
+ return null;
+ }
}
- case HostPortal:
- popHostContainer(workInProgress);
- updateHostContainer(current, workInProgress);
+ 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);
+ }
+ }
- if (current === null) {
- preparePortalMount(workInProgress.stateNode.containerInfo);
- }
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+}
- bubbleProperties(workInProgress);
- return null;
+function beginWork(current, workInProgress, renderLanes) {
+ {
+ if (workInProgress._debugNeedsRemount && current !== null) {
+ // This will restart the begin phase with a new fiber.
+ return remountFiber(
+ current,
+ workInProgress,
+ createFiberFromTypeAndProps(
+ workInProgress.type,
+ workInProgress.key,
+ workInProgress.pendingProps,
+ workInProgress._debugOwner || null,
+ workInProgress.mode,
+ workInProgress.lanes
+ )
+ );
+ }
+ }
- case ContextProvider:
- // Pop provider fiber
- var context = workInProgress.type._context;
- popProvider(context, workInProgress);
- bubbleProperties(workInProgress);
- return null;
+ if (current !== null) {
+ var oldProps = current.memoizedProps;
+ var newProps = workInProgress.pendingProps;
- case IncompleteClassComponent: {
- // Same as class component case. I put it down here so that the tags are
- // sequential to ensure this switch is compiled to a jump table.
- var _Component = workInProgress.type;
+ if (
+ oldProps !== newProps ||
+ hasContextChanged() || // Force a re-render if the implementation changed due to hot reload:
+ workInProgress.type !== current.type
+ ) {
+ // 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 {
+ // Neither props nor legacy context changes. Check if there's a pending
+ // update or context change.
+ var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(
+ current,
+ renderLanes
+ );
- if (isContextProvider(_Component)) {
- popContext(workInProgress);
+ if (
+ !hasScheduledUpdateOrContext && // If this is the second pass of an error or suspense boundary, there
+ // may not be work scheduled on `current`, so we check for this flag.
+ (workInProgress.flags & DidCapture) === NoFlags
+ ) {
+ // No pending updates or context. Bail out now.
+ didReceiveUpdate = false;
+ return attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+ );
}
- bubbleProperties(workInProgress);
- return null;
+ if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
+ // 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;
+ } // Before entering the begin phase, clear pending update priority.
+ // TODO: This assumes that we're about to evaluate the component and process
+ // the update queue. However, there's an exception: SimpleMemoComponent
+ // 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.
- case SuspenseListComponent: {
- popSuspenseContext(workInProgress);
- var renderState = workInProgress.memoizedState;
+ workInProgress.lanes = NoLanes;
- if (renderState === null) {
- // We're running in the default, "independent" mode.
- // We don't do anything in this mode.
- bubbleProperties(workInProgress);
- return null;
- }
+ switch (workInProgress.tag) {
+ case IndeterminateComponent: {
+ return mountIndeterminateComponent(
+ current,
+ workInProgress,
+ workInProgress.type,
+ renderLanes
+ );
+ }
- var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags;
- var renderedTail = renderState.rendering;
+ case LazyComponent: {
+ var elementType = workInProgress.elementType;
+ return mountLazyComponent(
+ current,
+ workInProgress,
+ elementType,
+ renderLanes
+ );
+ }
+
+ case FunctionComponent: {
+ var Component = workInProgress.type;
+ var unresolvedProps = workInProgress.pendingProps;
+ var resolvedProps =
+ workInProgress.elementType === Component
+ ? unresolvedProps
+ : resolveDefaultProps(Component, unresolvedProps);
+ return updateFunctionComponent(
+ current,
+ workInProgress,
+ Component,
+ resolvedProps,
+ renderLanes
+ );
+ }
- if (renderedTail === null) {
- // We just rendered the head.
- if (!didSuspendAlready) {
- // This is the first pass. We need to figure out if anything is still
- // suspended in the rendered set.
- // If new content unsuspended, but there's still some content that
- // didn't. Then we need to do a second pass that forces everything
- // to keep showing their fallbacks.
- // We might be suspended if something in this render pass suspended, or
- // something in the previous committed pass suspended. Otherwise,
- // there's no chance so we can skip the expensive call to
- // findFirstSuspended.
- var cannotBeSuspended =
- renderHasNotSuspendedYet() &&
- (current === null || (current.flags & DidCapture) === NoFlags);
+ case ClassComponent: {
+ var _Component = workInProgress.type;
+ var _unresolvedProps = workInProgress.pendingProps;
- if (!cannotBeSuspended) {
- var row = workInProgress.child;
+ var _resolvedProps =
+ workInProgress.elementType === _Component
+ ? _unresolvedProps
+ : resolveDefaultProps(_Component, _unresolvedProps);
- while (row !== null) {
- var suspended = findFirstSuspended(row);
+ return updateClassComponent(
+ current,
+ workInProgress,
+ _Component,
+ _resolvedProps,
+ renderLanes
+ );
+ }
- if (suspended !== null) {
- didSuspendAlready = true;
- workInProgress.flags |= DidCapture;
- cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
- // part of the second pass. In that case nothing will subscribe to
- // its thennables. Instead, we'll transfer its thennables to the
- // SuspenseList so that it can retry if they resolve.
- // There might be multiple of these in the list but since we're
- // going to wait for all of them anyway, it doesn't really matter
- // which ones gets to ping. In theory we could get clever and keep
- // track of how many dependencies remain but it gets tricky because
- // in the meantime, we can add/remove/change items and dependencies.
- // We might bail out of the loop before finding any but that
- // doesn't matter since that means that the other boundaries that
- // we did find already has their listeners attached.
+ case HostRoot:
+ return updateHostRoot(current, workInProgress, renderLanes);
- var newThennables = suspended.updateQueue;
+ case HostComponent:
+ return updateHostComponent$1(current, workInProgress, renderLanes);
- if (newThennables !== null) {
- workInProgress.updateQueue = newThennables;
- workInProgress.flags |= Update;
- } // Rerender the whole list, but this time, we'll force fallbacks
- // to stay in place.
- // Reset the effect flags before doing the second pass since that's now invalid.
- // Reset the child fibers to their original state.
+ case HostText:
+ return updateHostText$1();
- workInProgress.subtreeFlags = NoFlags;
- resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
- // rerender the children.
+ case SuspenseComponent:
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
- pushSuspenseContext(
- workInProgress,
- setShallowSuspenseContext(
- suspenseStackCursor.current,
- ForceSuspenseFallback
- )
- ); // Don't bubble properties in this case.
+ case HostPortal:
+ return updatePortalComponent(current, workInProgress, renderLanes);
- return workInProgress.child;
- }
+ case ForwardRef: {
+ var type = workInProgress.type;
+ var _unresolvedProps2 = workInProgress.pendingProps;
- row = row.sibling;
- }
- }
+ var _resolvedProps2 =
+ workInProgress.elementType === type
+ ? _unresolvedProps2
+ : resolveDefaultProps(type, _unresolvedProps2);
- if (renderState.tail !== null && now() > getRenderTargetTime()) {
- // We have already passed our CPU deadline but we still have rows
- // left in the tail. We'll just give up further attempts to render
- // the main content and only render fallbacks.
- workInProgress.flags |= DidCapture;
- didSuspendAlready = true;
- cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
- // to get it started back up to attempt the next item. While in terms
- // of priority this work has the same priority as this current render,
- // it's not part of the same transition once the transition has
- // committed. If it's sync, we still want to yield so that it can be
- // painted. Conceptually, this is really the same as pinging.
- // We can use any RetryLane even if it's the one currently rendering
- // since we're leaving it behind on this node.
+ return updateForwardRef(
+ current,
+ workInProgress,
+ type,
+ _resolvedProps2,
+ renderLanes
+ );
+ }
- workInProgress.lanes = SomeRetryLane;
- }
- } else {
- cutOffTailIfNeeded(renderState, false);
- } // Next we're going to render the tail.
- } else {
- // Append the rendered row to the child list.
- if (!didSuspendAlready) {
- var _suspended = findFirstSuspended(renderedTail);
+ case Fragment:
+ return updateFragment(current, workInProgress, renderLanes);
- if (_suspended !== null) {
- workInProgress.flags |= DidCapture;
- didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't
- // get lost if this row ends up dropped during a second pass.
+ case Mode:
+ return updateMode(current, workInProgress, renderLanes);
- var _newThennables = _suspended.updateQueue;
+ case Profiler:
+ return updateProfiler(current, workInProgress, renderLanes);
- if (_newThennables !== null) {
- workInProgress.updateQueue = _newThennables;
- workInProgress.flags |= Update;
- }
+ case ContextProvider:
+ return updateContextProvider(current, workInProgress, renderLanes);
- cutOffTailIfNeeded(renderState, true); // This might have been modified.
+ case ContextConsumer:
+ return updateContextConsumer(current, workInProgress, renderLanes);
- if (
- renderState.tail === null &&
- renderState.tailMode === "hidden" &&
- !renderedTail.alternate &&
- !getIsHydrating() // We don't cut it if we're hydrating.
- ) {
- // We're done.
- bubbleProperties(workInProgress);
- return null;
- }
- } else if (
- // The time it took to render last row is greater than the remaining
- // time we have to render. So rendering one more row would likely
- // exceed it.
- now() * 2 - renderState.renderingStartTime >
- getRenderTargetTime() &&
- 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.
- // The assumption is that this is usually faster.
- workInProgress.flags |= DidCapture;
- didSuspendAlready = true;
- cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
- // to get it started back up to attempt the next item. While in terms
- // of priority this work has the same priority as this current render,
- // it's not part of the same transition once the transition has
- // committed. If it's sync, we still want to yield so that it can be
- // painted. Conceptually, this is really the same as pinging.
- // We can use any RetryLane even if it's the one currently rendering
- // since we're leaving it behind on this node.
+ case MemoComponent: {
+ var _type2 = workInProgress.type;
+ var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
- workInProgress.lanes = SomeRetryLane;
- }
- }
+ var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
- if (renderState.isBackwards) {
- // The effect list of the backwards tail will have been added
- // to the end. This breaks the guarantee that life-cycles fire in
- // sibling order but that isn't a strong guarantee promised by React.
- // Especially since these might also just pop in during future commits.
- // Append to the beginning of the list.
- renderedTail.sibling = workInProgress.child;
- workInProgress.child = renderedTail;
- } else {
- var previousSibling = renderState.last;
+ {
+ if (workInProgress.type !== workInProgress.elementType) {
+ var outerPropTypes = _type2.propTypes;
- if (previousSibling !== null) {
- previousSibling.sibling = renderedTail;
- } else {
- workInProgress.child = renderedTail;
+ if (outerPropTypes) {
+ checkPropTypes(
+ outerPropTypes,
+ _resolvedProps3, // Resolved for outer only
+ "prop",
+ getComponentNameFromType(_type2)
+ );
}
-
- renderState.last = renderedTail;
}
}
- if (renderState.tail !== null) {
- // We still have tail rows to render.
- // Pop a row.
- var next = renderState.tail;
- renderState.rendering = next;
- renderState.tail = next.sibling;
- renderState.renderingStartTime = now();
- next.sibling = null; // Restore the context.
- // TODO: We can probably just avoid popping it instead and only
- // setting it the first time we go from not suspended to suspended.
+ _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
+ return updateMemoComponent(
+ current,
+ workInProgress,
+ _type2,
+ _resolvedProps3,
+ renderLanes
+ );
+ }
- var suspenseContext = suspenseStackCursor.current;
+ case SimpleMemoComponent: {
+ return updateSimpleMemoComponent(
+ current,
+ workInProgress,
+ workInProgress.type,
+ workInProgress.pendingProps,
+ renderLanes
+ );
+ }
- if (didSuspendAlready) {
- suspenseContext = setShallowSuspenseContext(
- suspenseContext,
- ForceSuspenseFallback
- );
- } else {
- suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
- }
+ case IncompleteClassComponent: {
+ var _Component2 = workInProgress.type;
+ var _unresolvedProps4 = workInProgress.pendingProps;
- pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
- // Don't bubble properties in this case.
+ var _resolvedProps4 =
+ workInProgress.elementType === _Component2
+ ? _unresolvedProps4
+ : resolveDefaultProps(_Component2, _unresolvedProps4);
- return next;
- }
+ return mountIncompleteClassComponent(
+ current,
+ workInProgress,
+ _Component2,
+ _resolvedProps4,
+ renderLanes
+ );
+ }
- bubbleProperties(workInProgress);
- return null;
+ case SuspenseListComponent: {
+ return updateSuspenseListComponent(current, workInProgress, renderLanes);
}
case ScopeComponent: {
break;
}
- case OffscreenComponent:
- case LegacyHiddenComponent: {
- popRenderLanes(workInProgress);
- var _nextState = workInProgress.memoizedState;
- var nextIsHidden = _nextState !== null;
-
- if (current !== null) {
- var _prevState = current.memoizedState;
- var prevIsHidden = _prevState !== null;
-
- if (
- prevIsHidden !== nextIsHidden &&
- newProps.mode !== "unstable-defer-without-hiding"
- ) {
- workInProgress.flags |= Update;
- }
- } // Don't bubble properties for hidden children.
-
- if (
- !nextIsHidden ||
- includesSomeLane(subtreeRenderLanes, OffscreenLane) ||
- (workInProgress.mode & ConcurrentMode) === NoMode
- ) {
- bubbleProperties(workInProgress);
- }
-
- return null;
+ case OffscreenComponent: {
+ return updateOffscreenComponent(current, workInProgress, renderLanes);
}
}
- {
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
- }
+ throw new Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in " +
+ "React. Please file an issue."
+ );
}
-function unwindWork(workInProgress, renderLanes) {
+function unwindWork(current, workInProgress, renderLanes) {
+ // Note: This intentionally doesn't check if we're hydrating because comparing
+ // to the current tree provider fiber is just as fast and less error-prone.
+ // Ideally we would have a special version of the work loop only
+ // for hydration.
+ popTreeContext(workInProgress);
+
switch (workInProgress.tag) {
case ClassComponent: {
var Component = workInProgress.type;
@@ -16651,14 +17121,17 @@ function unwindWork(workInProgress, renderLanes) {
resetWorkInProgressVersions();
var _flags = workInProgress.flags;
- if (!((_flags & DidCapture) === NoFlags)) {
- throw Error(
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
- );
- }
+ if (
+ (_flags & ShouldCapture) !== NoFlags &&
+ (_flags & DidCapture) === NoFlags
+ ) {
+ // There was an error during render that wasn't captured by a suspense
+ // boundary. Do a second pass on the root to unmount the children.
+ workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture;
+ return workInProgress;
+ } // We unwound to the root without completing it. Exit.
- workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture;
- return workInProgress;
+ return null;
}
case HostComponent: {
@@ -16715,7 +17188,13 @@ function unwindWork(workInProgress, renderLanes) {
}
}
-function unwindInterruptedWork(interruptedWork, renderLanes) {
+function unwindInterruptedWork(current, interruptedWork, renderLanes) {
+ // Note: This intentionally doesn't check if we're hydrating because comparing
+ // to the current tree provider fiber is just as fast and less error-prone.
+ // Ideally we would have a special version of the work loop only
+ // for hydration.
+ popTreeContext(interruptedWork);
+
switch (interruptedWork.tag) {
case ClassComponent: {
var childContextTypes = interruptedWork.type.childContextTypes;
@@ -16775,6 +17254,20 @@ var nextEffect = null; // Used for Profiling builds to track updaters.
var inProgressLanes = null;
var inProgressRoot = null;
+function reportUncaughtErrorInDEV(error) {
+ // Wrapping each small part of the commit phase into a guarded
+ // callback is a bit too slow (https://github.com/facebook/react/pull/21666).
+ // But we rely on it to surface errors to DEV tools like overlays
+ // (https://github.com/facebook/react/issues/21712).
+ // As a compromise, rethrow only caught errors in a guard.
+ {
+ invokeGuardedCallback(null, function() {
+ throw error;
+ });
+ clearCaughtError();
+ }
+}
+
var callComponentWillUnmountWithTimer = function(current, instance) {
instance.props = current.memoizedProps;
instance.state = current.memoizedState;
@@ -16798,8 +17291,9 @@ function safelyCallComponentWillUnmount(
) {
try {
callComponentWillUnmountWithTimer(current, instance);
- } catch (unmountError) {
- captureCommitPhaseError(current, nearestMountedAncestor, unmountError);
+ } catch (error) {
+ reportUncaughtErrorInDEV(error);
+ captureCommitPhaseError(current, nearestMountedAncestor, error);
}
} // Capture errors so they don't interrupt mounting.
@@ -16808,6 +17302,8 @@ function safelyDetachRef(current, nearestMountedAncestor) {
if (ref !== null) {
if (typeof ref === "function") {
+ var retVal;
+
try {
if (
enableProfilerTimer &&
@@ -16816,16 +17312,27 @@ function safelyDetachRef(current, nearestMountedAncestor) {
) {
try {
startLayoutEffectTimer();
- ref(null);
+ retVal = ref(null);
} finally {
recordLayoutEffectDuration(current);
}
} else {
- ref(null);
+ retVal = ref(null);
}
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(current, nearestMountedAncestor, error);
}
+
+ {
+ if (typeof retVal === "function") {
+ error(
+ "Unexpected return value from a callback ref in %s. " +
+ "A callback ref should not return a function.",
+ getComponentNameFromFiber(current)
+ );
+ }
+ }
} else {
ref.current = null;
}
@@ -16836,6 +17343,7 @@ function safelyCallDestroy(current, nearestMountedAncestor, destroy) {
try {
destroy();
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(current, nearestMountedAncestor, error);
}
}
@@ -16879,6 +17387,7 @@ function commitBeforeMutationEffects_complete() {
try {
commitBeforeMutationEffectsOnFiber(fiber);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -16990,11 +17499,10 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) {
break;
default: {
- {
- 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."
- );
- }
+ throw new 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."
+ );
}
}
@@ -17030,7 +17538,7 @@ function commitHookEffectListUnmount(
}
}
-function commitHookEffectListMount(tag, finishedWork) {
+function commitHookEffectListMount(flags, finishedWork) {
var updateQueue = finishedWork.updateQueue;
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
@@ -17039,8 +17547,7 @@ function commitHookEffectListMount(tag, finishedWork) {
var effect = firstEffect;
do {
- if ((effect.tag & tag) === tag) {
- // Mount
+ if ((effect.tag & flags) === flags) {
var create = effect.create;
effect.destroy = create();
@@ -17048,6 +17555,16 @@ function commitHookEffectListMount(tag, finishedWork) {
var destroy = effect.destroy;
if (destroy !== undefined && typeof destroy !== "function") {
+ var hookName = void 0;
+
+ if ((effect.tag & Layout) !== NoFlags) {
+ hookName = "useLayoutEffect";
+ } else if ((effect.tag & Insertion) !== NoFlags) {
+ hookName = "useInsertionEffect";
+ } else {
+ hookName = "useEffect";
+ }
+
var addendum = void 0;
if (destroy === null) {
@@ -17056,10 +17573,13 @@ function commitHookEffectListMount(tag, finishedWork) {
"up, return undefined (or nothing).";
} else if (typeof destroy.then === "function") {
addendum =
- "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " +
+ "\n\nIt looks like you wrote " +
+ hookName +
+ "(async () => ...) or returned a Promise. " +
"Instead, write the async function inside your effect " +
"and call it immediately:\n\n" +
- "useEffect(() => {\n" +
+ hookName +
+ "(() => {\n" +
" async function fetchData() {\n" +
" // You can await here\n" +
" const response = await MyAPI.getData(someId);\n" +
@@ -17073,8 +17593,9 @@ function commitHookEffectListMount(tag, finishedWork) {
}
error(
- "An effect function must not return anything besides a function, " +
+ "%s must not return anything besides a function, " +
"which is used for clean-up.%s",
+ hookName,
addendum
);
}
@@ -17144,24 +17665,26 @@ function commitLayoutEffectOnFiber(
finishedWork,
committedLanes
) {
- if ((finishedWork.flags & (Update | Callback)) !== NoFlags) {
+ if ((finishedWork.flags & LayoutMask) !== NoFlags) {
switch (finishedWork.tag) {
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent: {
- // At this point layout effects have already been destroyed (during mutation phase).
- // This is done to prevent sibling component effects from interfering with each other,
- // e.g. a destroy function in one component should never override a ref set
- // by a create function in another component during the same commit.
- if (finishedWork.mode & ProfileMode) {
- try {
- startLayoutEffectTimer();
+ {
+ // At this point layout effects have already been destroyed (during mutation phase).
+ // This is done to prevent sibling component effects from interfering with each other,
+ // e.g. a destroy function in one component should never override a ref set
+ // by a create function in another component during the same commit.
+ if (finishedWork.mode & ProfileMode) {
+ try {
+ startLayoutEffectTimer();
+ commitHookEffectListMount(Layout | HasEffect, finishedWork);
+ } finally {
+ recordLayoutEffectDuration(finishedWork);
+ }
+ } else {
commitHookEffectListMount(Layout | HasEffect, finishedWork);
- } finally {
- recordLayoutEffectDuration(finishedWork);
}
- } else {
- commitHookEffectListMount(Layout | HasEffect, finishedWork);
}
break;
@@ -17171,104 +17694,109 @@ function commitLayoutEffectOnFiber(
var instance = finishedWork.stateNode;
if (finishedWork.flags & Update) {
- if (current === null) {
- // 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 &&
- !didWarnAboutReassigningProps
- ) {
- if (instance.props !== finishedWork.memoizedProps) {
- error(
- "Expected %s props to match memoized props before " +
- "componentDidMount. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.props`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
- }
+ {
+ if (current === null) {
+ // 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 &&
+ !didWarnAboutReassigningProps
+ ) {
+ if (instance.props !== finishedWork.memoizedProps) {
+ error(
+ "Expected %s props to match memoized props before " +
+ "componentDidMount. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.props`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
- if (instance.state !== finishedWork.memoizedState) {
- error(
- "Expected %s state to match memoized state before " +
- "componentDidMount. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.state`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
+ if (instance.state !== finishedWork.memoizedState) {
+ error(
+ "Expected %s state to match memoized state before " +
+ "componentDidMount. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.state`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
}
}
- }
- if (finishedWork.mode & ProfileMode) {
- try {
- startLayoutEffectTimer();
+ if (finishedWork.mode & ProfileMode) {
+ try {
+ startLayoutEffectTimer();
+ instance.componentDidMount();
+ } finally {
+ recordLayoutEffectDuration(finishedWork);
+ }
+ } else {
instance.componentDidMount();
- } finally {
- recordLayoutEffectDuration(finishedWork);
}
} else {
- instance.componentDidMount();
- }
- } else {
- var prevProps =
- finishedWork.elementType === finishedWork.type
- ? current.memoizedProps
- : resolveDefaultProps(finishedWork.type, current.memoizedProps);
- 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.
+ var prevProps =
+ finishedWork.elementType === finishedWork.type
+ ? current.memoizedProps
+ : resolveDefaultProps(
+ finishedWork.type,
+ current.memoizedProps
+ );
+ 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.
- {
- if (
- finishedWork.type === finishedWork.elementType &&
- !didWarnAboutReassigningProps
- ) {
- if (instance.props !== finishedWork.memoizedProps) {
- error(
- "Expected %s props to match memoized props before " +
- "componentDidUpdate. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.props`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
- }
+ {
+ if (
+ finishedWork.type === finishedWork.elementType &&
+ !didWarnAboutReassigningProps
+ ) {
+ if (instance.props !== finishedWork.memoizedProps) {
+ error(
+ "Expected %s props to match memoized props before " +
+ "componentDidUpdate. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.props`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
- if (instance.state !== finishedWork.memoizedState) {
- error(
- "Expected %s state to match memoized state before " +
- "componentDidUpdate. " +
- "This might either be because of a bug in React, or because " +
- "a component reassigns its own `this.state`. " +
- "Please file an issue.",
- getComponentNameFromFiber(finishedWork) || "instance"
- );
+ if (instance.state !== finishedWork.memoizedState) {
+ error(
+ "Expected %s state to match memoized state before " +
+ "componentDidUpdate. " +
+ "This might either be because of a bug in React, or because " +
+ "a component reassigns its own `this.state`. " +
+ "Please file an issue.",
+ getComponentNameFromFiber(finishedWork) || "instance"
+ );
+ }
}
}
- }
- if (finishedWork.mode & ProfileMode) {
- try {
- startLayoutEffectTimer();
+ if (finishedWork.mode & ProfileMode) {
+ try {
+ startLayoutEffectTimer();
+ instance.componentDidUpdate(
+ prevProps,
+ prevState,
+ instance.__reactInternalSnapshotBeforeUpdate
+ );
+ } finally {
+ recordLayoutEffectDuration(finishedWork);
+ }
+ } else {
instance.componentDidUpdate(
prevProps,
prevState,
instance.__reactInternalSnapshotBeforeUpdate
);
- } finally {
- recordLayoutEffectDuration(finishedWork);
}
- } else {
- instance.componentDidUpdate(
- prevProps,
- prevState,
- instance.__reactInternalSnapshotBeforeUpdate
- );
}
}
} // TODO: I think this is now always non-null by the time it reaches the
@@ -17436,30 +17964,29 @@ function commitLayoutEffectOnFiber(
case IncompleteClassComponent:
case ScopeComponent:
case OffscreenComponent:
- case LegacyHiddenComponent:
+ case LegacyHiddenComponent: {
break;
+ }
- default: {
- 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."
+ default:
+ throw new 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."
);
- }
}
}
{
- if (finishedWork.flags & Ref) {
- commitAttachRef(finishedWork);
+ {
+ if (finishedWork.flags & Ref) {
+ commitAttachRef(finishedWork);
+ }
}
}
}
function hideOrUnhideAllChildren(finishedWork, isHidden) {
- // Suspense layout effects semantics don't change for legacy roots.
- var isModernRoot = (finishedWork.mode & ConcurrentMode) !== NoMode;
- var current = finishedWork.alternate;
- var wasHidden = current !== null && current.memoizedState !== null; // Only hide or unhide the top-most host nodes.
-
+ // Only hide or unhide the top-most host nodes.
var hostSubtreeRoot = null;
{
@@ -17544,15 +18071,27 @@ function commitAttachRef(finishedWork) {
} // Moved outside to ensure DCE works with this flag
if (typeof ref === "function") {
+ var retVal;
+
if (finishedWork.mode & ProfileMode) {
try {
startLayoutEffectTimer();
- ref(instanceToUse);
+ retVal = ref(instanceToUse);
} finally {
recordLayoutEffectDuration(finishedWork);
}
} else {
- ref(instanceToUse);
+ retVal = ref(instanceToUse);
+ }
+
+ {
+ if (typeof retVal === "function") {
+ error(
+ "Unexpected return value from a callback ref in %s. " +
+ "A callback ref should not return a function.",
+ getComponentNameFromFiber(finishedWork)
+ );
+ }
}
} else {
{
@@ -17616,7 +18155,9 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
tag = _effect.tag;
if (destroy !== undefined) {
- if ((tag & Layout) !== NoFlags$1) {
+ if ((tag & Insertion) !== NoFlags$1) {
+ safelyCallDestroy(current, nearestMountedAncestor, destroy);
+ } else if ((tag & Layout) !== NoFlags$1) {
if (current.mode & ProfileMode) {
startLayoutEffectTimer();
safelyCallDestroy(current, nearestMountedAncestor, destroy);
@@ -17809,11 +18350,10 @@ function getHostParentFiber(fiber) {
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."
- );
- }
+ throw new Error(
+ "Expected to find a host parent. This error is likely caused by a bug " +
+ "in React. Please file an issue."
+ );
}
function isHostParent(fiber) {
@@ -17877,45 +18417,37 @@ function getHostSibling(fiber) {
function commitPlacement(finishedWork) {
var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together.
- var parent;
- var isContainer;
- var parentStateNode = parentFiber.stateNode;
-
switch (parentFiber.tag) {
- case HostComponent:
- parent = parentStateNode;
- isContainer = false;
+ case HostComponent: {
+ var parent = parentFiber.stateNode;
+
+ if (parentFiber.flags & ContentReset) {
+ parentFiber.flags &= ~ContentReset;
+ }
+
+ var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
+ // children to find all the terminal nodes.
+
+ insertOrAppendPlacementNode(finishedWork, before, parent);
break;
+ }
case HostRoot:
- parent = parentStateNode.containerInfo;
- isContainer = true;
- break;
+ case HostPortal: {
+ var _parent = parentFiber.stateNode.containerInfo;
- case HostPortal:
- parent = parentStateNode.containerInfo;
- isContainer = true;
+ var _before = getHostSibling(finishedWork);
+
+ insertOrAppendPlacementNodeIntoContainer(finishedWork, _before, _parent);
break;
+ }
// eslint-disable-next-line-no-fallthrough
- default: {
- throw Error(
- "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue."
+ default:
+ throw new Error(
+ "Invalid host parent fiber. This error is likely caused by a bug " +
+ "in React. Please file an issue."
);
- }
- }
-
- if (parentFiber.flags & ContentReset) {
- parentFiber.flags &= ~ContentReset;
- }
-
- var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
- // children to find all the terminal nodes.
-
- if (isContainer) {
- insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent);
- } else {
- insertOrAppendPlacementNode(finishedWork, before, parent);
}
}
@@ -17991,9 +18523,10 @@ function unmountHostComponents(finishedRoot, current, nearestMountedAncestor) {
var parent = node.return;
findParent: while (true) {
- if (!(parent !== null)) {
- throw Error(
- "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."
+ if (parent === null) {
+ throw new Error(
+ "Expected to find a host parent. This error is likely caused by " +
+ "a bug in React. Please file an issue."
);
}
@@ -18091,11 +18624,17 @@ function commitWork(current, finishedWork) {
case ForwardRef:
case MemoComponent:
case SimpleMemoComponent: {
- // Layout effects are destroyed during the mutation phase so that all
+ commitHookEffectListUnmount(
+ Insertion | HasEffect,
+ finishedWork,
+ finishedWork.return
+ );
+ commitHookEffectListMount(Insertion | HasEffect, finishedWork); // Layout effects are destroyed during the mutation phase so that all
// destroy functions for all fibers are called before any create functions.
// This prevents sibling component effects from interfering with each other,
// e.g. a destroy function in one component should never override a ref set
// by a create function in another component during the same commit.
+
if (finishedWork.mode & ProfileMode) {
try {
startLayoutEffectTimer();
@@ -18146,9 +18685,10 @@ function commitWork(current, finishedWork) {
}
case HostText: {
- if (!(finishedWork.stateNode !== null)) {
- throw Error(
- "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue."
+ if (finishedWork.stateNode === null) {
+ throw new Error(
+ "This should have a text node initialized. This error is likely " +
+ "caused by a bug in React. Please file an issue."
);
}
@@ -18171,7 +18711,7 @@ function commitWork(current, finishedWork) {
}
case SuspenseComponent: {
- commitSuspenseComponent(finishedWork);
+ commitSuspenseCallback(finishedWork);
attachSuspenseRetryListeners(finishedWork);
return;
}
@@ -18184,47 +18724,17 @@ function commitWork(current, finishedWork) {
case IncompleteClassComponent: {
return;
}
-
- case ScopeComponent: {
- break;
- }
-
- case OffscreenComponent:
- case LegacyHiddenComponent: {
- var newState = finishedWork.memoizedState;
- var isHidden = newState !== null;
- hideOrUnhideAllChildren(finishedWork, isHidden);
- 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."
- );
- }
+ throw new 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 commitSuspenseComponent(finishedWork) {
+function commitSuspenseCallback(finishedWork) {
+ // TODO: Move this to passive phase
var newState = finishedWork.memoizedState;
-
- if (newState !== null) {
- markCommitTimeOfFallback();
-
- {
- // 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) {
@@ -18275,12 +18785,12 @@ function commitMutationEffects(root, firstChild, committedLanes) {
inProgressLanes = committedLanes;
inProgressRoot = root;
nextEffect = firstChild;
- commitMutationEffects_begin(root);
+ commitMutationEffects_begin(root, committedLanes);
inProgressLanes = null;
inProgressRoot = null;
}
-function commitMutationEffects_begin(root) {
+function commitMutationEffects_begin(root, lanes) {
while (nextEffect !== null) {
var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization
@@ -18293,6 +18803,7 @@ function commitMutationEffects_begin(root) {
try {
commitDeletion(root, childToDelete, fiber);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(childToDelete, fiber, error);
}
}
@@ -18304,19 +18815,20 @@ function commitMutationEffects_begin(root) {
ensureCorrectReturnPointer(child, fiber);
nextEffect = child;
} else {
- commitMutationEffects_complete(root);
+ commitMutationEffects_complete(root, lanes);
}
}
}
-function commitMutationEffects_complete(root) {
+function commitMutationEffects_complete(root, lanes) {
while (nextEffect !== null) {
var fiber = nextEffect;
setCurrentFiber(fiber);
try {
- commitMutationEffectsOnFiber(fiber, root);
+ commitMutationEffectsOnFiber(fiber, root, lanes);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -18333,7 +18845,11 @@ function commitMutationEffects_complete(root) {
}
}
-function commitMutationEffectsOnFiber(finishedWork, root) {
+function commitMutationEffectsOnFiber(finishedWork, root, lanes) {
+ // TODO: The factoring of this phase could probably be improved. Consider
+ // switching on the type of work before checking the flags. That's what
+ // we do in all the other phases. I think this one is only different
+ // because of the shared reconciliation logic below.
var flags = finishedWork.flags;
if (flags & ContentReset) {
@@ -18346,6 +18862,45 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
if (current !== null) {
commitDetachRef(current);
}
+ }
+
+ if (flags & Visibility) {
+ switch (finishedWork.tag) {
+ case SuspenseComponent: {
+ var newState = finishedWork.memoizedState;
+ var isHidden = newState !== null;
+
+ if (isHidden) {
+ var _current = finishedWork.alternate;
+ var wasHidden = _current !== null && _current.memoizedState !== null;
+
+ if (!wasHidden) {
+ // TODO: Move to passive phase
+ markCommitTimeOfFallback();
+ }
+ }
+
+ break;
+ }
+
+ case OffscreenComponent: {
+ var _newState = finishedWork.memoizedState;
+
+ var _isHidden = _newState !== null;
+
+ var _current2 = finishedWork.alternate;
+
+ var _wasHidden = _current2 !== null && _current2.memoizedState !== null;
+
+ var offscreenBoundary = finishedWork;
+
+ {
+ // TODO: This needs to run whenever there's an insertion or update
+ // inside a hidden Offscreen tree.
+ hideOrUnhideAllChildren(offscreenBoundary, _isHidden);
+ }
+ }
+ }
} // 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
@@ -18371,8 +18926,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
finishedWork.flags &= ~Placement; // Update
- var _current = finishedWork.alternate;
- commitWork(_current, finishedWork);
+ var _current3 = finishedWork.alternate;
+ commitWork(_current3, finishedWork);
break;
}
@@ -18384,14 +18939,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
case HydratingAndUpdate: {
finishedWork.flags &= ~Hydrating; // Update
- var _current2 = finishedWork.alternate;
- commitWork(_current2, finishedWork);
+ var _current4 = finishedWork.alternate;
+ commitWork(_current4, finishedWork);
break;
}
case Update: {
- var _current3 = finishedWork.alternate;
- commitWork(_current3, finishedWork);
+ var _current5 = finishedWork.alternate;
+ commitWork(_current5, finishedWork);
break;
}
}
@@ -18424,9 +18979,6 @@ function commitLayoutEffects_begin(subtreeRoot, root, committedLanes) {
}
function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) {
- // Suspense layout effects semantics don't change for legacy roots.
- var isModernRoot = (subtreeRoot.mode & ConcurrentMode) !== NoMode;
-
while (nextEffect !== null) {
var fiber = nextEffect;
@@ -18437,6 +18989,7 @@ function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) {
try {
commitLayoutEffectOnFiber(root, current, fiber, committedLanes);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -18489,6 +19042,7 @@ function commitPassiveMountEffects_complete(subtreeRoot, root) {
try {
commitPassiveMountOnFiber(root, fiber);
} catch (error) {
+ reportUncaughtErrorInDEV(error);
captureCommitPhaseError(fiber, fiber.return, error);
}
@@ -18738,7 +19292,7 @@ function ensureCorrectReturnPointer(fiber, expectedReturnFiber) {
// anything, by checking the warning logs for the above invariant
fiber.return = expectedReturnFiber;
-}
+} // TODO: Reuse reappearLayoutEffects traversal here?
var COMPONENT_TYPE = 0;
var HAS_PSEUDO_CLASS_TYPE = 1;
@@ -18747,43 +19301,73 @@ 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 symbolFor = Symbol.for;
+ COMPONENT_TYPE = symbolFor("selector.component");
+ HAS_PSEUDO_CLASS_TYPE = symbolFor("selector.has_pseudo_class");
+ ROLE_TYPE = symbolFor("selector.role");
+ TEST_NAME_TYPE = symbolFor("selector.test_id");
+ TEXT_TYPE = symbolFor("selector.text");
+}
+
+var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue;
+function isLegacyActEnvironment(fiber) {
+ {
+ // Legacy mode. We preserve the behavior of React 17's act. It assumes an
+ // act environment whenever `jest` is defined, but you can still turn off
+ // spurious warnings by setting IS_REACT_ACT_ENVIRONMENT explicitly
+ // to false.
+ var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
+ typeof IS_REACT_ACT_ENVIRONMENT !== "undefined"
+ ? IS_REACT_ACT_ENVIRONMENT
+ : undefined; // $FlowExpectedError - Flow doesn't know about jest
+
+ var jestIsDefined = typeof jest !== "undefined";
+ return jestIsDefined && isReactActEnvironmentGlobal !== false;
+ }
+}
+function isConcurrentActEnvironment() {
+ {
+ var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
+ typeof IS_REACT_ACT_ENVIRONMENT !== "undefined"
+ ? IS_REACT_ACT_ENVIRONMENT
+ : undefined;
+
+ if (!isReactActEnvironmentGlobal && ReactCurrentActQueue.current !== null) {
+ // TODO: Include link to relevant documentation page.
+ error(
+ "The current testing environment is not configured to support " +
+ "act(...)"
+ );
+ }
+
+ return isReactActEnvironmentGlobal;
+ }
}
var ceil = Math.ceil;
var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig,
- IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
+ ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue;
var NoContext =
/* */
0;
var BatchedContext =
/* */
1;
-var LegacyUnbatchedContext =
- /* */
- 4;
var RenderContext =
/* */
- 8;
+ 2;
var CommitContext =
/* */
- 16;
-var RetryAfterError =
- /* */
- 32;
-var RootIncomplete = 0;
+ 4;
+var RootInProgress = 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 RootCompleted = 5;
+var RootDidNotComplete = 6; // Describes where we are in the React execution stack
var executionContext = NoContext; // The root we're working on
@@ -18803,7 +19387,7 @@ var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to
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 workInProgressRootExitStatus = RootInProgress; // A fatal error, if one is thrown
var workInProgressRootFatalError = 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
@@ -18815,9 +19399,14 @@ var workInProgressRootIncludedLanes = NoLanes; // The work left over by componen
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 workInProgressRootInterleavedUpdatedLanes = NoLanes; // Lanes that were updated during the render phase (*not* an interleaved event).
+
+var workInProgressRootPingedLanes = NoLanes; // Errors that are thrown during the render phase.
+
+var workInProgressRootConcurrentErrors = null; // These are errors that we recovered from without surfacing them to the UI.
+// We will log them once the tree commits.
-var workInProgressRootPingedLanes = NoLanes; // The most recent time we committed a fallback. This lets us ensure a train
+var workInProgressRootRecoverableErrors = 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;
@@ -18842,7 +19431,7 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Only used when enableProfi
var rootDoesHavePassiveEffects = false;
var rootWithPendingPassiveEffects = null;
var pendingPassiveEffectsLanes = NoLanes;
-var pendingPassiveProfilerEffects = []; // Use these to prevent an infinite loop of nested updates
+var pendingPassiveProfilerEffects = [];
var NESTED_UPDATE_LIMIT = 50;
var nestedUpdateCount = 0;
@@ -18853,10 +19442,7 @@ var nestedPassiveUpdateCount = 0; // If two updates are scheduled within the sam
// between the first and second call.
var currentEventTime = NoTimestamp;
-var currentEventTransitionLane = 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 currentEventTransitionLane = NoLanes;
function getWorkInProgressRoot() {
return workInProgressRoot;
}
@@ -18899,13 +19485,22 @@ function requestUpdateLane(fiber) {
var isTransition = requestCurrentTransition() !== NoTransition;
if (isTransition) {
- // The algorithm for assigning an update to a lane should be stable for all
+ if (ReactCurrentBatchConfig$2.transition !== null) {
+ var transition = ReactCurrentBatchConfig$2.transition;
+
+ if (!transition._updatedFibers) {
+ transition._updatedFibers = new Set();
+ }
+
+ transition._updatedFibers.add(fiber);
+ } // 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.
//
// 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.
+
if (currentEventTransitionLane === NoLane) {
// All transitions within the same event are assigned the same lane.
currentEventTransitionLane = claimNextTransitionLane();
@@ -18950,79 +19545,80 @@ function requestRetryLane(fiber) {
function scheduleUpdateOnFiber(fiber, lane, eventTime) {
checkForNestedUpdates();
- warnAboutRenderPhaseUpdatesInDEV(fiber);
var root = markUpdateLaneFromFiberToRoot(fiber, lane);
if (root === null) {
- warnAboutUpdateOnUnmountedFiberInDEV(fiber);
return null;
- }
-
- {
- if (isDevToolsPresent) {
- addFiberToLanesMap(root, fiber, lane);
- }
} // 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.
- if ((executionContext & RenderContext) === NoContext) {
- workInProgressRootUpdatedLanes = mergeLanes(
- workInProgressRootUpdatedLanes,
- lane
- );
+ if (
+ (executionContext & RenderContext) !== NoLanes &&
+ root === workInProgressRoot
+ ) {
+ // This update was dispatched during the render phase. This is a mistake
+ // if the update originates from user space (with the exception of local
+ // hook updates, which are handled differently and don't reach this
+ // function), but there are some internal React features that use this as
+ // an implementation detail, like selective hydration.
+ warnAboutRenderPhaseUpdatesInDEV(fiber); // Track lanes that were updated during the render phase
+ } else {
+ // This is a normal update, scheduled from outside the render phase. For
+ // example, during an input event.
+ {
+ if (isDevToolsPresent) {
+ addFiberToLanesMap(root, fiber, 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);
- }
- }
+ warnIfUpdatesNotWrappedWithActDEV(fiber);
- if (lane === SyncLane) {
- if (
- // Check if we're inside unbatchedUpdates
- (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
- (executionContext & (RenderContext | CommitContext)) === NoContext
- ) {
- // 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);
+ if (root === workInProgressRoot) {
+ // TODO: Consolidate with `isInterleavedUpdate` check
+ // 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.
+ if ((executionContext & RenderContext) === NoContext) {
+ workInProgressRootInterleavedUpdatedLanes = mergeLanes(
+ workInProgressRootInterleavedUpdatedLanes,
+ lane
+ );
+ }
- if (
- executionContext === NoContext &&
- (fiber.mode & ConcurrentMode) === NoMode
- ) {
- // 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.
- resetRenderTimer();
- flushSyncCallbacksOnlyInLegacyMode();
+ 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);
}
}
- } else {
- // Schedule other updates after in case the callback is sync.
+
ensureRootIsScheduled(root, eventTime);
+
+ if (
+ lane === SyncLane &&
+ executionContext === NoContext &&
+ (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
+ !ReactCurrentActQueue$1.isBatchingLegacy
+ ) {
+ // 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.
+ resetRenderTimer();
+ flushSyncCallbacksOnlyInLegacyMode();
+ }
}
return 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.
@@ -19106,7 +19702,7 @@ function ensureRootIsScheduled(root, currentTime) {
if (nextLanes === NoLanes) {
// Special case: There's nothing to work on.
if (existingCallbackNode !== null) {
- cancelCallback(existingCallbackNode);
+ cancelCallback$1(existingCallbackNode);
}
root.callbackNode = null;
@@ -19118,7 +19714,15 @@ function ensureRootIsScheduled(root, currentTime) {
var existingCallbackPriority = root.callbackPriority;
- if (existingCallbackPriority === newCallbackPriority) {
+ if (
+ existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a
+ // Scheduler task, rather than an `act` task, cancel it and re-scheduled
+ // on the `act` queue.
+ !(
+ ReactCurrentActQueue$1.current !== null &&
+ existingCallbackNode !== fakeActCallbackNode
+ )
+ ) {
{
// If we're going to re-use an existing task, it needs to exist.
// Assume that discrete update microtasks are non-cancellable and null.
@@ -19138,7 +19742,7 @@ function ensureRootIsScheduled(root, currentTime) {
if (existingCallbackNode != null) {
// Cancel the existing callback. We'll schedule a new one below.
- cancelCallback(existingCallbackNode);
+ cancelCallback$1(existingCallbackNode);
} // Schedule a new callback.
var newCallbackNode;
@@ -19147,6 +19751,10 @@ function ensureRootIsScheduled(root, currentTime) {
// Special case: Sync React callbacks are scheduled on a special
// internal queue
if (root.tag === LegacyRoot) {
+ if (ReactCurrentActQueue$1.isBatchingLegacy !== null) {
+ ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
+ }
+
scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root));
} else {
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
@@ -19154,7 +19762,7 @@ function ensureRootIsScheduled(root, currentTime) {
{
// Flush the queue in an Immediate task.
- scheduleCallback(ImmediatePriority, flushSyncCallbacks);
+ scheduleCallback$1(ImmediatePriority, flushSyncCallbacks);
}
newCallbackNode = null;
@@ -19183,7 +19791,7 @@ function ensureRootIsScheduled(root, currentTime) {
break;
}
- newCallbackNode = scheduleCallback(
+ newCallbackNode = scheduleCallback$1(
schedulerPriorityLevel,
performConcurrentWorkOnRoot.bind(null, root)
);
@@ -19203,8 +19811,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
currentEventTime = NoTimestamp;
currentEventTransitionLane = NoLanes;
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Should not already be working.");
} // Flush any pending passive effects before deciding which lanes to work on,
// in case they schedule additional work.
@@ -19238,34 +19846,25 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
// bug we're still investigating. Once the bug in Scheduler is fixed,
// we can remove this, since we track expiration ourselves.
- var exitStatus =
- shouldTimeSlice(root, lanes) && !didTimeout
- ? renderRootConcurrent(root, lanes)
- : renderRootSync(root, lanes);
+ var shouldTimeSlice =
+ !includesBlockingLane(root, lanes) &&
+ !includesExpiredLane(root, lanes) &&
+ !didTimeout;
+ var exitStatus = shouldTimeSlice
+ ? renderRootConcurrent(root, lanes)
+ : renderRootSync(root, lanes);
- if (exitStatus !== RootIncomplete) {
+ if (exitStatus !== RootInProgress) {
if (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;
-
- {
- errorHydratingContainer(root.containerInfo);
- }
-
- 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 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 errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
if (errorRetryLanes !== NoLanes) {
lanes = errorRetryLanes;
- exitStatus = renderRootSync(root, errorRetryLanes);
+ exitStatus = recoverFromConcurrentError(root, errorRetryLanes);
}
}
@@ -19275,13 +19874,59 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
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.
+ }
+
+ if (exitStatus === RootDidNotComplete) {
+ // The render unwound without completing the tree. This happens in special
+ // cases where need to exit the current render without producing a
+ // consistent tree or committing.
+ //
+ // This should only happen during a concurrent render, not a discrete or
+ // synchronous update. We should have already checked for this when we
+ // unwound the stack.
+ markRootSuspended$1(root, lanes);
+ } else {
+ // The render completed.
+ // Check if this render may have yielded to a concurrent event, and if so,
+ // confirm that any newly rendered stores are consistent.
+ // TODO: It's possible that even a concurrent render may never have yielded
+ // to the main thread, if it was fast enough, or if it expired. We could
+ // skip the consistency check in that case, too.
+ var renderWasConcurrent = !includesBlockingLane(root, lanes);
+ var finishedWork = root.current.alternate;
- var finishedWork = root.current.alternate;
- root.finishedWork = finishedWork;
- root.finishedLanes = lanes;
- finishConcurrentRender(root, exitStatus, lanes);
+ if (
+ renderWasConcurrent &&
+ !isRenderConsistentWithExternalStores(finishedWork)
+ ) {
+ // A store was mutated in an interleaved event. Render again,
+ // synchronously, to block further mutations.
+ exitStatus = renderRootSync(root, lanes); // We need to check again if something threw
+
+ if (exitStatus === RootErrored) {
+ var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
+
+ if (_errorRetryLanes !== NoLanes) {
+ lanes = _errorRetryLanes;
+ exitStatus = recoverFromConcurrentError(root, _errorRetryLanes); // We assume the tree is now consistent because we didn't yield to any
+ // concurrent events.
+ }
+ }
+
+ 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.
+
+ root.finishedWork = finishedWork;
+ root.finishedLanes = lanes;
+ finishConcurrentRender(root, exitStatus, lanes);
+ }
}
ensureRootIsScheduled(root, now());
@@ -19295,13 +19940,67 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
return null;
}
+function recoverFromConcurrentError(root, errorRetryLanes) {
+ // If an error occurred during hydration, discard server response and fall
+ // back to client side render.
+ // Before rendering again, save the errors from the previous attempt.
+ var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
+
+ if (isRootDehydrated(root)) {
+ // The shell failed to hydrate. Set a flag to force a client rendering
+ // during the next attempt. To do this, we call prepareFreshStack now
+ // to create the root work-in-progress fiber. This is a bit weird in terms
+ // of factoring, because it relies on renderRootSync not calling
+ // prepareFreshStack again in the call below, which happens because the
+ // root and lanes haven't changed.
+ //
+ // TODO: I think what we should do is set ForceClientRender inside
+ // throwException, like we do for nested Suspense boundaries. The reason
+ // it's here instead is so we can switch to the synchronous work loop, too.
+ // Something to consider for a future refactor.
+ var rootWorkInProgress = prepareFreshStack(root, errorRetryLanes);
+ rootWorkInProgress.flags |= ForceClientRender;
+
+ {
+ errorHydratingContainer(root.containerInfo);
+ }
+ }
+
+ var exitStatus = renderRootSync(root, errorRetryLanes);
+
+ if (exitStatus !== RootErrored) {
+ // Successfully finished rendering on retry
+ // The errors from the failed first attempt have been recovered. Add
+ // them to the collection of recoverable errors. We'll log them in the
+ // commit phase.
+ var errorsFromSecondAttempt = workInProgressRootRecoverableErrors;
+ workInProgressRootRecoverableErrors = errorsFromFirstAttempt; // The errors from the second attempt should be queued after the errors
+ // from the first attempt, to preserve the causal sequence.
+
+ if (errorsFromSecondAttempt !== null) {
+ queueRecoverableErrors(errorsFromSecondAttempt);
+ }
+ }
+
+ return exitStatus;
+}
+
+function queueRecoverableErrors(errors) {
+ if (workInProgressRootRecoverableErrors === null) {
+ workInProgressRootRecoverableErrors = errors;
+ } else {
+ workInProgressRootRecoverableErrors.push.apply(
+ workInProgressRootRecoverableErrors,
+ errors
+ );
+ }
+}
+
function finishConcurrentRender(root, exitStatus, lanes) {
switch (exitStatus) {
- case RootIncomplete:
+ case RootInProgress:
case RootFatalErrored: {
- {
- throw Error("Root did not complete. This is a bug in React.");
- }
+ throw new 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
@@ -19310,7 +20009,7 @@ function finishConcurrentRender(root, exitStatus, lanes) {
case RootErrored: {
// We should have already attempted to retry this tree. If we reached
// this point, it errored again. Commit it.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
@@ -19350,14 +20049,14 @@ function finishConcurrentRender(root, exitStatus, lanes) {
// immediately, wait for more data to arrive.
root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
msUntilTimeout
);
break;
}
} // The work expired. Commit immediately.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
@@ -19388,38 +20087,101 @@ function finishConcurrentRender(root, exitStatus, lanes) {
// Instead of committing the fallback immediately, wait for more data
// to arrive.
root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
_msUntilTimeout
);
break;
}
} // Commit the placeholder.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
case RootCompleted: {
// The work completed. Ready to commit.
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
}
default: {
- {
- throw Error("Unknown root exit status.");
- }
+ throw new Error("Unknown root exit status.");
}
}
}
+function isRenderConsistentWithExternalStores(finishedWork) {
+ // Search the rendered tree for external store reads, and check whether the
+ // stores were mutated in a concurrent event. Intentionally using an iterative
+ // loop instead of recursion so we can exit early.
+ var node = finishedWork;
+
+ while (true) {
+ if (node.flags & StoreConsistency) {
+ var updateQueue = node.updateQueue;
+
+ if (updateQueue !== null) {
+ var checks = updateQueue.stores;
+
+ if (checks !== null) {
+ for (var i = 0; i < checks.length; i++) {
+ var check = checks[i];
+ var getSnapshot = check.getSnapshot;
+ var renderedValue = check.value;
+
+ try {
+ if (!objectIs(getSnapshot(), renderedValue)) {
+ // Found an inconsistent store.
+ return false;
+ }
+ } catch (error) {
+ // If `getSnapshot` throws, return `false`. This will schedule
+ // a re-render, and the error will be rethrown during render.
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ var child = node.child;
+
+ if (node.subtreeFlags & StoreConsistency && child !== null) {
+ child.return = node;
+ node = child;
+ continue;
+ }
+
+ if (node === finishedWork) {
+ return true;
+ }
+
+ while (node.sibling === null) {
+ if (node.return === null || node.return === finishedWork) {
+ return true;
+ }
+
+ node = node.return;
+ }
+
+ node.sibling.return = node.return;
+ node = node.sibling;
+ } // Flow doesn't know this is unreachable, but eslint does
+ // eslint-disable-next-line no-unreachable
+
+ return true;
+}
+
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);
+ suspendedLanes = removeLanes(
+ suspendedLanes,
+ workInProgressRootInterleavedUpdatedLanes
+ );
markRootSuspended(root, suspendedLanes);
} // This is the entry point for synchronous tasks that don't go
// through Scheduler
@@ -19429,8 +20191,8 @@ function performSyncWorkOnRoot(root) {
syncNestedUpdateFlag();
}
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Should not already be working.");
}
flushPassiveEffects();
@@ -19445,27 +20207,15 @@ function performSyncWorkOnRoot(root) {
var exitStatus = renderRootSync(root, lanes);
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;
-
- {
- errorHydratingContainer(root.containerInfo);
- }
-
- clearContainer(root.containerInfo);
- } // If something threw an error, try rendering one more time. We'll render
+ // 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 errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
if (errorRetryLanes !== NoLanes) {
lanes = errorRetryLanes;
- exitStatus = renderRootSync(root, lanes);
+ exitStatus = recoverFromConcurrentError(root, errorRetryLanes);
}
}
@@ -19475,13 +20225,17 @@ function performSyncWorkOnRoot(root) {
markRootSuspended$1(root, lanes);
ensureRootIsScheduled(root, now());
throw fatalError;
+ }
+
+ if (exitStatus === RootDidNotComplete) {
+ throw new Error("Root did not complete. This is a bug in React.");
} // 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
+ commitRoot(root, workInProgressRootRecoverableErrors); // Before exiting, make sure there's a callback scheduled for the next
// pending level.
ensureRootIsScheduled(root, now());
@@ -19497,24 +20251,40 @@ function batchedUpdates$1(fn, a) {
executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.
- if (executionContext === NoContext) {
+ if (
+ executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
+ !ReactCurrentActQueue$1.isBatchingLegacy
+ ) {
resetRenderTimer();
flushSyncCallbacksOnlyInLegacyMode();
}
}
}
-function flushSync(fn, a) {
+// Warning, this opts-out of checking the function body.
+
+// eslint-disable-next-line no-redeclare
+function flushSync(fn) {
+ // In legacy mode, we flush pending passive effects at the beginning of the
+ // next event, not at the end of the previous one.
+ if (
+ rootWithPendingPassiveEffects !== null &&
+ rootWithPendingPassiveEffects.tag === LegacyRoot &&
+ (executionContext & (RenderContext | CommitContext)) === NoContext
+ ) {
+ flushPassiveEffects();
+ }
+
var prevExecutionContext = executionContext;
executionContext |= BatchedContext;
var prevTransition = ReactCurrentBatchConfig$2.transition;
var previousPriority = getCurrentUpdatePriority();
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
setCurrentUpdatePriority(DiscreteEventPriority);
if (fn) {
- return fn(a);
+ return fn();
} else {
return undefined;
}
@@ -19527,14 +20297,6 @@ function flushSync(fn, a) {
if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
flushSyncCallbacks();
- } else {
- {
- 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."
- );
- }
}
}
}
@@ -19568,24 +20330,30 @@ function prepareFreshStack(root, lanes) {
var interruptedWork = workInProgress.return;
while (interruptedWork !== null) {
- unwindInterruptedWork(interruptedWork);
+ var current = interruptedWork.alternate;
+ unwindInterruptedWork(current, interruptedWork);
interruptedWork = interruptedWork.return;
}
}
workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
+ var rootWorkInProgress = createWorkInProgress(root.current, null);
+ workInProgress = rootWorkInProgress;
workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
- workInProgressRootExitStatus = RootIncomplete;
+ workInProgressRootExitStatus = RootInProgress;
workInProgressRootFatalError = null;
workInProgressRootSkippedLanes = NoLanes;
- workInProgressRootUpdatedLanes = NoLanes;
+ workInProgressRootInterleavedUpdatedLanes = NoLanes;
workInProgressRootPingedLanes = NoLanes;
+ workInProgressRootConcurrentErrors = null;
+ workInProgressRootRecoverableErrors = null;
enqueueInterleavedUpdates();
{
ReactStrictModeWarnings.discardPendingWarnings();
}
+
+ return rootWorkInProgress;
}
function handleError(root, thrownValue) {
@@ -19625,6 +20393,29 @@ function handleError(root, thrownValue) {
stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
}
+ if (enableSchedulingProfiler) {
+ markComponentRenderStopped();
+
+ if (
+ thrownValue !== null &&
+ typeof thrownValue === "object" &&
+ typeof thrownValue.then === "function"
+ ) {
+ var wakeable = thrownValue;
+ markComponentSuspended(
+ erroredWork,
+ wakeable,
+ workInProgressRootRenderLanes
+ );
+ } else {
+ markComponentErrored(
+ erroredWork,
+ thrownValue,
+ workInProgressRootRenderLanes
+ );
+ }
+ }
+
throwException(
root,
erroredWork.return,
@@ -19681,14 +20472,15 @@ function markSkippedUpdateLanes(lane) {
);
}
function renderDidSuspend() {
- if (workInProgressRootExitStatus === RootIncomplete) {
+ if (workInProgressRootExitStatus === RootInProgress) {
workInProgressRootExitStatus = RootSuspended;
}
}
function renderDidSuspendDelayIfPossible() {
if (
- workInProgressRootExitStatus === RootIncomplete ||
- workInProgressRootExitStatus === RootSuspended
+ workInProgressRootExitStatus === RootInProgress ||
+ workInProgressRootExitStatus === RootSuspended ||
+ workInProgressRootExitStatus === RootErrored
) {
workInProgressRootExitStatus = RootSuspendedWithDelay;
} // Check if there are updates that we skipped tree that might have unblocked
@@ -19697,7 +20489,7 @@ function renderDidSuspendDelayIfPossible() {
if (
workInProgressRoot !== null &&
(includesNonIdleWork(workInProgressRootSkippedLanes) ||
- includesNonIdleWork(workInProgressRootUpdatedLanes))
+ includesNonIdleWork(workInProgressRootInterleavedUpdatedLanes))
) {
// 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
@@ -19709,17 +20501,23 @@ function renderDidSuspendDelayIfPossible() {
markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
}
}
-function renderDidError() {
- if (workInProgressRootExitStatus !== RootCompleted) {
+function renderDidError(error) {
+ if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
workInProgressRootExitStatus = RootErrored;
}
+
+ if (workInProgressRootConcurrentErrors === null) {
+ workInProgressRootConcurrentErrors = [error];
+ } else {
+ workInProgressRootConcurrentErrors.push(error);
+ }
} // Called during render to determine if anything has suspended.
// Returns false if we're not sure.
function renderHasNotSuspendedYet() {
// If something errored or completed, we can't really be sure,
// so those are false.
- return workInProgressRootExitStatus === RootIncomplete;
+ return workInProgressRootExitStatus === RootInProgress;
}
function renderRootSync(root, lanes) {
@@ -19744,7 +20542,6 @@ function renderRootSync(root, lanes) {
movePendingFibersToMemoized(root, lanes);
}
}
-
prepareFreshStack(root, lanes);
}
@@ -19763,11 +20560,10 @@ function renderRootSync(root, lanes) {
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."
- );
- }
+ throw new Error(
+ "Cannot commit an incomplete root. This error is likely caused by a " +
+ "bug in React. Please file an issue."
+ );
}
workInProgressRoot = null;
@@ -19806,7 +20602,6 @@ function renderRootConcurrent(root, lanes) {
movePendingFibersToMemoized(root, lanes);
}
}
-
resetRenderTimer();
prepareFreshStack(root, lanes);
}
@@ -19825,7 +20620,7 @@ function renderRootConcurrent(root, lanes) {
executionContext = prevExecutionContext;
if (workInProgress !== null) {
- return RootIncomplete;
+ return RootInProgress;
} else {
workInProgressRoot = null;
workInProgressRootRenderLanes = NoLanes; // Return the final exit status.
@@ -19907,7 +20702,7 @@ function completeUnitOfWork(unitOfWork) {
// 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 lanes.
+ var _next = unwindWork(current, completedWork); // Because this fiber did not complete, don't reset its lanes.
if (_next !== null) {
// If completing this work spawned new work, do that next. We'll come
@@ -19939,6 +20734,11 @@ function completeUnitOfWork(unitOfWork) {
returnFiber.flags |= Incomplete;
returnFiber.subtreeFlags = NoFlags;
returnFiber.deletions = null;
+ } else {
+ // We've unwound all the way to the root.
+ workInProgressRootExitStatus = RootDidNotComplete;
+ workInProgress = null;
+ return;
}
}
@@ -19955,21 +20755,21 @@ function completeUnitOfWork(unitOfWork) {
workInProgress = completedWork;
} while (completedWork !== null); // We've reached the root.
- if (workInProgressRootExitStatus === RootIncomplete) {
+ if (workInProgressRootExitStatus === RootInProgress) {
workInProgressRootExitStatus = RootCompleted;
}
}
-function commitRoot(root) {
+function commitRoot(root, recoverableErrors) {
// TODO: This no longer makes any sense. We already wrap the mutation and
// layout phases. Should be able to remove.
var previousUpdateLanePriority = getCurrentUpdatePriority();
var prevTransition = ReactCurrentBatchConfig$2.transition;
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
setCurrentUpdatePriority(DiscreteEventPriority);
- commitRootImpl(root, previousUpdateLanePriority);
+ commitRootImpl(root, recoverableErrors, previousUpdateLanePriority);
} finally {
ReactCurrentBatchConfig$2.transition = prevTransition;
setCurrentUpdatePriority(previousUpdateLanePriority);
@@ -19978,7 +20778,7 @@ function commitRoot(root) {
return null;
}
-function commitRootImpl(root, renderPriorityLevel) {
+function commitRootImpl(root, recoverableErrors, renderPriorityLevel) {
do {
// `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
// means `flushPassiveEffects` will sometimes result in additional
@@ -19991,8 +20791,8 @@ function commitRootImpl(root, renderPriorityLevel) {
flushRenderPhaseStrictModeWarningsInDEV();
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Should not already be working.");
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Should not already be working.");
}
var finishedWork = root.finishedWork;
@@ -20014,9 +20814,10 @@ function commitRootImpl(root, renderPriorityLevel) {
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."
+ if (finishedWork === root.current) {
+ throw new 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.
@@ -20045,8 +20846,11 @@ function commitRootImpl(root, renderPriorityLevel) {
) {
if (!rootDoesHavePassiveEffects) {
rootDoesHavePassiveEffects = true;
- scheduleCallback(NormalPriority, function() {
- flushPassiveEffects();
+ scheduleCallback$1(NormalPriority, function() {
+ flushPassiveEffects(); // This render triggered passive effects: release the root cache pool
+ // *after* passive effects fire to avoid freeing a cache pool that may
+ // be referenced by a node in the tree (HostRoot, Cache boundary etc)
+
return null;
});
}
@@ -20067,7 +20871,7 @@ function commitRootImpl(root, renderPriorityLevel) {
if (subtreeHasEffects || rootHasEffect) {
var prevTransition = ReactCurrentBatchConfig$2.transition;
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
var previousPriority = getCurrentUpdatePriority();
setCurrentUpdatePriority(DiscreteEventPriority);
var prevExecutionContext = executionContext;
@@ -20128,6 +20932,15 @@ function commitRootImpl(root, renderPriorityLevel) {
} // Read this again, since an effect might have updated it
remainingLanes = root.pendingLanes; // Check if there's remaining work on this root
+ // TODO: This is part of the `componentDidCatch` implementation. Its purpose
+ // is to detect whether something might have called setState inside
+ // `componentDidCatch`. The mechanism is known to be flawed because `setState`
+ // inside `componentDidCatch` is itself flawed — that's why we recommend
+ // `getDerivedStateFromError` instead. However, it could be improved by
+ // checking if remainingLanes includes Sync work, instead of whether there's
+ // any work remaining at all (which would also include stuff like Suspense
+ // retries or transitions). It's been like this for a while, though, so fixing
+ // it probably isn't that urgent.
if (remainingLanes === NoLanes) {
// If there's no remaining work, we can clear the set of already failed
@@ -20135,22 +20948,6 @@ function commitRootImpl(root, renderPriorityLevel) {
legacyErrorBoundariesThatAlreadyFailed = null;
}
- if (includesSomeLane(remainingLanes, SyncLane)) {
- {
- markNestedUpdateScheduled();
- } // 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;
- }
-
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
{
@@ -20162,19 +20959,22 @@ function commitRootImpl(root, renderPriorityLevel) {
ensureRootIsScheduled(root, now());
+ if (recoverableErrors !== null) {
+ // There were errors during this render, but recovered from them without
+ // needing to surface it to the UI. We log them here.
+ var onRecoverableError = root.onRecoverableError;
+
+ for (var i = 0; i < recoverableErrors.length; i++) {
+ var recoverableError = recoverableErrors[i];
+ onRecoverableError(recoverableError);
+ }
+ }
+
if (hasUncaughtError) {
hasUncaughtError = false;
var error$1 = firstUncaughtError;
firstUncaughtError = null;
throw error$1;
- }
-
- 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.
-
- return null;
} // If the passive effects are the result of a discrete render, flush them
// synchronously at the end of the current task so that the result is
// immediately observable. Otherwise, we assume that they are not
@@ -20189,6 +20989,24 @@ function commitRootImpl(root, renderPriorityLevel) {
root.tag !== LegacyRoot
) {
flushPassiveEffects();
+ } // Read this again, since a passive effect might have updated it
+
+ remainingLanes = root.pendingLanes;
+
+ if (includesSomeLane(remainingLanes, SyncLane)) {
+ {
+ markNestedUpdateScheduled();
+ } // 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 layout work was scheduled, flush it now.
flushSyncCallbacks();
@@ -20210,12 +21028,12 @@ function flushPassiveEffects() {
var previousPriority = getCurrentUpdatePriority();
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
setCurrentUpdatePriority(priority);
return flushPassiveEffectsImpl();
} finally {
setCurrentUpdatePriority(previousPriority);
- ReactCurrentBatchConfig$2.transition = prevTransition;
+ ReactCurrentBatchConfig$2.transition = prevTransition; // Once passive effects have run for the tree - giving components a
}
}
@@ -20227,7 +21045,7 @@ function enqueuePendingPassiveProfilerEffect(fiber) {
if (!rootDoesHavePassiveEffects) {
rootDoesHavePassiveEffects = true;
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
});
@@ -20247,12 +21065,8 @@ function flushPassiveEffectsImpl() {
pendingPassiveEffectsLanes = NoLanes;
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
- throw Error("Cannot flush passive effects while already rendering.");
- }
-
- {
- isFlushingPassiveEffects = true;
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
+ throw new Error("Cannot flush passive effects while already rendering.");
}
var prevExecutionContext = executionContext;
@@ -20270,10 +21084,6 @@ function flushPassiveEffectsImpl() {
}
}
- {
- isFlushingPassiveEffects = false;
- }
-
executionContext = prevExecutionContext;
flushSyncCallbacks(); // If additional passive effects were scheduled, increment a counter. If this
// exceeds the limit, we'll fire a warning.
@@ -20400,6 +21210,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) {
var eventTime = requestEventTime();
markRootPinged(root, pingedLanes);
+ warnIfSuspenseResolutionNotWrappedWithActDEV(root);
if (
workInProgressRoot === root &&
@@ -20498,12 +21309,12 @@ function checkForNestedUpdates() {
if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
nestedUpdateCount = 0;
rootWithNestedUpdates = 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."
- );
- }
+ throw new 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."
+ );
}
{
@@ -20577,96 +21388,16 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
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 didWarnStateUpdateForUnmountedComponent = null;
-
-function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
- {
- var tag = fiber.tag;
-
- if (
- tag !== HostRoot &&
- tag !== ClassComponent &&
- tag !== FunctionComponent &&
- tag !== ForwardRef &&
- tag !== MemoComponent &&
- tag !== SimpleMemoComponent
- ) {
- // Only warn for user-defined components, not internal ones like Suspense.
- return;
- }
-
- if ((fiber.flags & PassiveStatic) !== NoFlags) {
- var updateQueue = fiber.updateQueue;
-
- if (updateQueue !== null) {
- var lastEffect = updateQueue.lastEffect;
-
- if (lastEffect !== null) {
- var firstEffect = lastEffect.next;
- var effect = firstEffect;
-
- do {
- if (effect.destroy !== undefined) {
- if ((effect.tag & Passive$1) !== NoFlags$1) {
- return;
- }
- }
-
- effect = effect.next;
- } while (effect !== firstEffect);
- }
- }
- } // We show the whole stack but dedupe on the top component's name because
- // the problematic code almost always lies inside that component.
-
- var componentName = getComponentNameFromFiber(fiber) || "ReactComponent";
-
- if (didWarnStateUpdateForUnmountedComponent !== null) {
- if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
- return;
- }
-
- didWarnStateUpdateForUnmountedComponent.add(componentName);
- } else {
- didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
- }
-
- if (isFlushingPassiveEffects);
- else {
- var previousFiber = current;
-
- 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();
- }
+ "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();
}
}
}
@@ -20706,7 +21437,7 @@ var beginWork$1;
// same fiber again.
// Unwind the failed stack frame
- unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
+ unwindInterruptedWork(current, unitOfWork); // Restore the original properties of the fiber.
assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
@@ -20732,7 +21463,7 @@ var beginWork$1;
originalError._suppressLogging = true;
}
} // We always throw the original error in case the second render pass is not idempotent.
- // This can happen if a memoized function or CommonJS module doesn't throw after first invokation.
+ // This can happen if a memoized function or CommonJS module doesn't throw after first invocation.
throw originalError;
}
@@ -20748,11 +21479,7 @@ var didWarnAboutUpdateInRenderForAnotherComponent;
function warnAboutRenderPhaseUpdatesInDEV(fiber) {
{
- if (
- isRendering &&
- (executionContext & RenderContext) !== NoContext &&
- !getIsUpdatingOpaqueValueInRenderPhaseInDEV()
- ) {
+ if (isRendering && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) {
switch (fiber.tag) {
case FunctionComponent:
case ForwardRef:
@@ -20797,11 +21524,8 @@ function warnAboutRenderPhaseUpdatesInDEV(fiber) {
}
}
}
-} // a 'shared' variable that changes when act() opens/closes in tests.
+}
-var IsThisRendererActing = {
- current: false
-};
function restorePendingUpdaters(root, lanes) {
{
if (isDevToolsPresent) {
@@ -20814,73 +21538,68 @@ function restorePendingUpdaters(root, lanes) {
}
}
}
-function warnIfNotScopedWithMatchingAct(fiber) {
- {
- if (
- IsSomeRendererActing.current === true &&
- IsThisRendererActing.current !== true
- ) {
- var previousFiber = current;
+var fakeActCallbackNode = {};
- try {
- setCurrentFiber(fiber);
+function scheduleCallback$1(priorityLevel, callback) {
+ {
+ // If we're currently inside an `act` scope, bypass Scheduler and push to
+ // the `act` queue instead.
+ var actQueue = ReactCurrentActQueue$1.current;
- 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();
- }
- }
+ if (actQueue !== null) {
+ actQueue.push(callback);
+ return fakeActCallbackNode;
+ } else {
+ return scheduleCallback(priorityLevel, callback);
}
}
}
-function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
- {
- if (
- (fiber.mode & StrictLegacyMode) !== 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://reactjs.org/link/wrap-tests-with-act",
- getComponentNameFromFiber(fiber)
- );
- }
- }
+
+function cancelCallback$1(callbackNode) {
+ if (callbackNode === fakeActCallbackNode) {
+ return;
+ } // In production, always call Scheduler. This function will be stripped out.
+
+ return cancelCallback(callbackNode);
+}
+
+function shouldForceFlushFallbacksInDEV() {
+ // Never force flush in production. This function should get stripped out.
+ return ReactCurrentActQueue$1.current !== null;
}
-function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
+function warnIfUpdatesNotWrappedWithActDEV(fiber) {
{
- if (
- executionContext === NoContext &&
- IsSomeRendererActing.current === false &&
- IsThisRendererActing.current === false
- ) {
+ if (fiber.mode & ConcurrentMode) {
+ if (!isConcurrentActEnvironment()) {
+ // Not in an act environment. No need to warn.
+ return;
+ }
+ } else {
+ // Legacy mode has additional cases where we suppress a warning.
+ if (!isLegacyActEnvironment()) {
+ // Not in an act environment. No need to warn.
+ return;
+ }
+
+ if (executionContext !== NoContext) {
+ // Legacy mode doesn't warn if the update is batched, i.e.
+ // batchedUpdates or flushSync.
+ return;
+ }
+
+ if (
+ fiber.tag !== FunctionComponent &&
+ fiber.tag !== ForwardRef &&
+ fiber.tag !== SimpleMemoComponent
+ ) {
+ // For backwards compatibility with pre-hooks code, legacy mode only
+ // warns for updates that originate from a hook.
+ return;
+ }
+ }
+
+ if (ReactCurrentActQueue$1.current === null) {
var previousFiber = current;
try {
@@ -20910,43 +21629,31 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
}
}
-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.
-
-function warnIfUnmockedScheduler(fiber) {
+function warnIfSuspenseResolutionNotWrappedWithActDEV(root) {
{
if (
- didWarnAboutUnmockedScheduler === false &&
- Scheduler.unstable_flushAllWithoutAsserting === undefined
+ root.tag !== LegacyRoot &&
+ isConcurrentActEnvironment() &&
+ ReactCurrentActQueue$1.current === null
) {
- if (fiber.mode & ConcurrentMode) {
- didWarnAboutUnmockedScheduler = true;
-
- 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://reactjs.org/link/mock-scheduler"
- );
- }
+ error(
+ "A suspended resource finished loading inside a test, but the event " +
+ "was not wrapped in act(...).\n\n" +
+ "When testing, code that resolves suspended data should be wrapped " +
+ "into act(...):\n\n" +
+ "act(() => {\n" +
+ " /* finish loading suspended data */\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://reactjs.org/link/wrap-tests-with-act"
+ );
}
}
-} // `act` testing API
-
-function shouldForceFlushFallbacksInDEV() {
- // Never force flush in production. This function should get stripped out.
- return actingUpdatesScopeDepth > 0;
}
-// so we can tell if any async act() calls try to run in parallel.
-
-var actingUpdatesScopeDepth = 0;
+/* eslint-disable react-internal/prod-error-codes */
var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
var failedBoundaries = null;
@@ -21734,11 +22441,6 @@ function createFiberFromTypeAndProps(
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_DEBUG_TRACING_MODE_TYPE:
- fiberTag = Mode;
- mode |= DebugTracingMode;
- break;
-
case REACT_STRICT_MODE_TYPE:
fiberTag = Mode;
mode |= StrictLegacyMode;
@@ -21758,7 +22460,8 @@ function createFiberFromTypeAndProps(
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
case REACT_LEGACY_HIDDEN_TYPE:
- return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
+
+ // eslint-disable-next-line no-fallthrough
case REACT_SCOPE_TYPE:
@@ -21768,6 +22471,14 @@ function createFiberFromTypeAndProps(
// eslint-disable-next-line no-fallthrough
+ case REACT_TRACING_MARKER_TYPE:
+
+ // eslint-disable-next-line no-fallthrough
+
+ case REACT_DEBUG_TRACING_MODE_TYPE:
+
+ // eslint-disable-next-line no-fallthrough
+
default: {
if (typeof type === "object" && type !== null) {
switch (type.$$typeof) {
@@ -21822,14 +22533,11 @@ function createFiberFromTypeAndProps(
}
}
- {
- throw Error(
- "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- (type == null ? type : typeof type) +
- "." +
- info
- );
- }
+ throw new Error(
+ "Element type is invalid: expected a string (for built-in " +
+ "components) or a class/function (for composite components) " +
+ ("but got: " + (type == null ? type : typeof type) + "." + info)
+ );
}
}
}
@@ -21917,12 +22625,8 @@ function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
var fiber = createFiber(OffscreenComponent, pendingProps, key, mode);
fiber.elementType = REACT_OFFSCREEN_TYPE;
fiber.lanes = lanes;
- return fiber;
-}
-function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) {
- var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode);
- fiber.elementType = REACT_LEGACY_HIDDEN_TYPE;
- fiber.lanes = lanes;
+ var primaryChildInstance = {};
+ fiber.stateNode = primaryChildInstance;
return fiber;
}
function createFiberFromText(content, mode, lanes) {
@@ -21991,7 +22695,13 @@ function assignFiberPropertiesInDEV(target, source) {
return target;
}
-function FiberRootNode(containerInfo, tag, hydrate) {
+function FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+) {
this.tag = tag;
this.containerInfo = containerInfo;
this.pendingChildren = null;
@@ -22001,7 +22711,6 @@ function FiberRootNode(containerInfo, tag, hydrate) {
this.timeoutHandle = noTimeout;
this.context = null;
this.pendingContext = null;
- this.hydrate = hydrate;
this.callbackNode = null;
this.callbackPriority = NoLane;
this.eventTimes = createLaneMap(NoLanes);
@@ -22014,6 +22723,8 @@ function FiberRootNode(containerInfo, tag, hydrate) {
this.finishedLanes = NoLanes;
this.entangledLanes = NoLanes;
this.entanglements = createLaneMap(NoLanes);
+ this.identifierPrefix = identifierPrefix;
+ this.onRecoverableError = onRecoverableError;
{
this.effectDuration = 0;
@@ -22024,7 +22735,7 @@ function FiberRootNode(containerInfo, tag, hydrate) {
this.memoizedUpdaters = new Set();
var pendingUpdatersLaneMap = (this.pendingUpdatersLaneMap = []);
- for (var i = 0; i < TotalLanes; i++) {
+ for (var _i = 0; _i < TotalLanes; _i++) {
pendingUpdatersLaneMap.push(new Set());
}
}
@@ -22032,11 +22743,11 @@ function FiberRootNode(containerInfo, tag, hydrate) {
{
switch (tag) {
case ConcurrentRoot:
- this._debugRootType = "createRoot()";
+ this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;
case LegacyRoot:
- this._debugRootType = "createLegacyRoot()";
+ this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
}
}
@@ -22046,11 +22757,24 @@ function createFiberRoot(
containerInfo,
tag,
hydrate,
+ initialChildren,
hydrationCallbacks,
isStrictMode,
- concurrentUpdatesByDefaultOverride
+ concurrentUpdatesByDefaultOverride, // TODO: We have several of these arguments that are conceptually part of the
+ // host config, but because they are passed in at runtime, we have to thread
+ // them through the root constructor. Perhaps we should put them all into a
+ // single type, like a DynamicHostConfig that is defined by the renderer.
+ identifierPrefix,
+ onRecoverableError,
+ transitionCallbacks
) {
- var root = new FiberRootNode(containerInfo, tag, hydrate);
+ var root = new FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+ );
// stateNode is any.
var uninitializedFiber = createHostRootFiber(tag, isStrictMode);
@@ -22059,7 +22783,11 @@ function createFiberRoot(
{
var _initialState = {
- element: null
+ element: initialChildren,
+ isDehydrated: hydrate,
+ cache: null,
+ // not enabled yet
+ transitions: null
};
uninitializedFiber.memoizedState = _initialState;
}
@@ -22068,6 +22796,8 @@ function createFiberRoot(
return root;
}
+var ReactVersion = "18.0.0-experimental-34aa5cfe0-20220329";
+
function createPortal(
children,
containerInfo, // TODO: figure out the API for cross-renderer implementation.
@@ -22075,6 +22805,11 @@ function createPortal(
) {
var key =
arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
+
+ {
+ checkKeyStringCoercion(key);
+ }
+
return {
// This tag allow us to uniquely identify this as a React Portal
$$typeof: REACT_PORTAL_TYPE,
@@ -22118,16 +22853,12 @@ function findHostInstanceWithWarning(component, methodName) {
if (fiber === undefined) {
if (typeof component.render === "function") {
- {
- throw Error("Unable to find node on an unmounted component.");
- }
+ throw new Error("Unable to find node on an unmounted component.");
} else {
- {
- throw Error(
- "Argument appears to not be a ReactComponent. Keys: " +
- Object.keys(component)
- );
- }
+ var keys = Object.keys(component).join(",");
+ throw new Error(
+ "Argument appears to not be a ReactComponent. Keys: " + keys
+ );
}
}
@@ -22189,17 +22920,25 @@ function findHostInstanceWithWarning(component, methodName) {
function createContainer(
containerInfo,
tag,
- hydrate,
hydrationCallbacks,
isStrictMode,
- concurrentUpdatesByDefaultOverride
+ concurrentUpdatesByDefaultOverride,
+ identifierPrefix,
+ onRecoverableError,
+ transitionCallbacks
) {
+ var hydrate = false;
+ var initialChildren = null;
return createFiberRoot(
containerInfo,
tag,
hydrate,
+ initialChildren,
hydrationCallbacks,
- isStrictMode
+ isStrictMode,
+ concurrentUpdatesByDefaultOverride,
+ identifierPrefix,
+ onRecoverableError
);
}
function updateContainer(element, container, parentComponent, callback) {
@@ -22209,15 +22948,6 @@ function updateContainer(element, container, parentComponent, callback) {
var current$1 = container.current;
var eventTime = requestEventTime();
-
- {
- // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ("undefined" !== typeof jest) {
- warnIfUnmockedScheduler(current$1);
- warnIfNotScopedWithMatchingAct(current$1);
- }
- }
-
var lane = requestUpdateLane(current$1);
var context = getContextForSubtree(parentComponent);
@@ -22317,7 +23047,7 @@ var setSuspenseHandler = null;
{
var copyWithDeleteImpl = function(obj, path, index) {
var key = path[index];
- var updated = isArray(obj) ? obj.slice() : Object.assign({}, obj);
+ var updated = isArray(obj) ? obj.slice() : assign({}, obj);
if (index + 1 === path.length) {
if (isArray(updated)) {
@@ -22339,7 +23069,7 @@ var setSuspenseHandler = null;
var copyWithRenameImpl = function(obj, oldPath, newPath, index) {
var oldKey = oldPath[index];
- var updated = isArray(obj) ? obj.slice() : Object.assign({}, obj);
+ var updated = isArray(obj) ? obj.slice() : assign({}, obj);
if (index + 1 === oldPath.length) {
var newKey = newPath[index]; // $FlowFixMe number or string is fine here
@@ -22391,7 +23121,7 @@ var setSuspenseHandler = null;
}
var key = path[index];
- var updated = isArray(obj) ? obj.slice() : Object.assign({}, obj); // $FlowFixMe number or string is fine here
+ var updated = isArray(obj) ? obj.slice() : assign({}, obj); // $FlowFixMe number or string is fine here
updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
return updated;
@@ -22426,7 +23156,7 @@ var setSuspenseHandler = null;
// As a result though, React will see the scheduled update as a noop and bailout.
// Shallow cloning props works as a workaround for now to bypass the bailout check.
- fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
+ fiber.memoizedProps = assign({}, fiber.memoizedProps);
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
};
@@ -22443,7 +23173,7 @@ var setSuspenseHandler = null;
// As a result though, React will see the scheduled update as a noop and bailout.
// Shallow cloning props works as a workaround for now to bypass the bailout check.
- fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
+ fiber.memoizedProps = assign({}, fiber.memoizedProps);
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
};
@@ -22460,7 +23190,7 @@ var setSuspenseHandler = null;
// As a result though, React will see the scheduled update as a noop and bailout.
// Shallow cloning props works as a workaround for now to bypass the bailout check.
- fiber.memoizedProps = Object.assign({}, fiber.memoizedProps);
+ fiber.memoizedProps = assign({}, fiber.memoizedProps);
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
}; // Support DevTools props for function components, forwardRef, memo, host components, etc.
@@ -22566,65 +23296,16 @@ var emptyObject$1 = {};
Object.freeze(emptyObject$1);
}
-var getInspectorDataForViewTag;
-var getInspectorDataForViewAtPoint;
-
-{
- var traverseOwnerTreeUp = function(hierarchy, instance) {
- if (instance) {
- hierarchy.unshift(instance);
- traverseOwnerTreeUp(hierarchy, instance._debugOwner);
- }
- };
-
- var getOwnerHierarchy = function(instance) {
- var hierarchy = [];
- traverseOwnerTreeUp(hierarchy, instance);
- return hierarchy;
- };
-
- var lastNonHostInstance = function(hierarchy) {
- for (var i = hierarchy.length - 1; i > 1; i--) {
- var instance = hierarchy[i];
-
- if (instance.tag !== HostComponent) {
- return instance;
- }
- }
-
- return hierarchy[0];
- };
-
- var getHostProps = function(fiber) {
- var host = findCurrentHostFiber(fiber);
-
- if (host) {
- return host.memoizedProps || emptyObject$1;
- }
-
- return emptyObject$1;
- };
-
- var getHostNode = function(fiber, findNodeHandle) {
- var hostNode; // look for children first for the hostNode
- // as composite fibers do not have a hostNode
-
- while (fiber) {
- if (fiber.stateNode !== null && fiber.tag === HostComponent) {
- hostNode = findNodeHandle(fiber.stateNode);
- }
-
- if (hostNode) {
- return hostNode;
- }
-
- fiber = fiber.child;
- }
+var createHierarchy;
+var getHostNode;
+var getHostProps;
+var lastNonHostInstance;
- return null;
- };
+var getOwnerHierarchy;
+var traverseOwnerTreeUp;
- var createHierarchy = function(fiberHierarchy) {
+{
+ createHierarchy = function(fiberHierarchy) {
return fiberHierarchy.map(function(fiber) {
return {
name: getComponentNameFromType(fiber.type),
@@ -22655,7 +23336,36 @@ var getInspectorDataForViewAtPoint;
});
};
- var getInspectorDataForInstance = function(closestInstance) {
+ getHostNode = function(fiber, findNodeHandle) {
+ var hostNode; // look for children first for the hostNode
+ // as composite fibers do not have a hostNode
+
+ while (fiber) {
+ if (fiber.stateNode !== null && fiber.tag === HostComponent) {
+ hostNode = findNodeHandle(fiber.stateNode);
+ }
+
+ if (hostNode) {
+ return hostNode;
+ }
+
+ fiber = fiber.child;
+ }
+
+ return null;
+ };
+
+ getHostProps = function(fiber) {
+ var host = findCurrentHostFiber(fiber);
+
+ if (host) {
+ return host.memoizedProps || emptyObject$1;
+ }
+
+ return emptyObject$1;
+ };
+
+ exports.getInspectorDataForInstance = function(closestInstance) {
// Handle case where user clicks outside of ReactNative
if (!closestInstance) {
return {
@@ -22681,6 +23391,36 @@ var getInspectorDataForViewAtPoint;
};
};
+ getOwnerHierarchy = function(instance) {
+ var hierarchy = [];
+ traverseOwnerTreeUp(hierarchy, instance);
+ return hierarchy;
+ };
+
+ lastNonHostInstance = function(hierarchy) {
+ for (var i = hierarchy.length - 1; i > 1; i--) {
+ var instance = hierarchy[i];
+
+ if (instance.tag !== HostComponent) {
+ return instance;
+ }
+ }
+
+ return hierarchy[0];
+ };
+
+ traverseOwnerTreeUp = function(hierarchy, instance) {
+ if (instance) {
+ hierarchy.unshift(instance);
+ traverseOwnerTreeUp(hierarchy, instance._debugOwner);
+ }
+ };
+}
+
+var getInspectorDataForViewTag;
+var getInspectorDataForViewAtPoint;
+
+{
getInspectorDataForViewTag = function(viewTag) {
var closestInstance = getInstanceFromTag(viewTag); // Handle case where user clicks outside of ReactNative
@@ -22726,7 +23466,7 @@ var getInspectorDataForViewAtPoint;
function(internalInstanceHandle) {
if (internalInstanceHandle == null) {
callback(
- Object.assign(
+ assign(
{
pointerY: locationY,
frame: {
@@ -22736,7 +23476,7 @@ var getInspectorDataForViewAtPoint;
height: 0
}
},
- getInspectorDataForInstance(closestInstance)
+ exports.getInspectorDataForInstance(closestInstance)
)
);
}
@@ -22749,9 +23489,11 @@ var getInspectorDataForViewAtPoint;
nativeFabricUIManager.measure(
internalInstanceHandle.stateNode.node,
function(x, y, width, height, pageX, pageY) {
- var inspectorData = getInspectorDataForInstance(closestInstance);
+ var inspectorData = exports.getInspectorDataForInstance(
+ closestInstance
+ );
callback(
- Object.assign({}, inspectorData, {
+ assign({}, inspectorData, {
pointerY: locationY,
frame: {
left: pageX,
@@ -22772,11 +23514,11 @@ var getInspectorDataForViewAtPoint;
findNodeHandle(inspectedView),
[locationX, locationY],
function(nativeViewTag, left, top, width, height) {
- var inspectorData = getInspectorDataForInstance(
+ var inspectorData = exports.getInspectorDataForInstance(
getInstanceFromTag(nativeViewTag)
);
callback(
- Object.assign({}, inspectorData, {
+ assign({}, inspectorData, {
pointerY: locationY,
frame: {
left: left,
@@ -22924,12 +23666,12 @@ function dispatchCommand(handle, command, args) {
return;
}
- if (handle._internalInstanceHandle) {
- nativeFabricUIManager.dispatchCommand(
- handle._internalInstanceHandle.stateNode.node,
- command,
- args
- );
+ if (handle._internalInstanceHandle != null) {
+ var stateNode = handle._internalInstanceHandle.stateNode;
+
+ if (stateNode != null) {
+ nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
+ }
} else {
ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand(
handle._nativeTag,
@@ -22951,11 +23693,12 @@ function sendAccessibilityEvent(handle, eventType) {
return;
}
- if (handle._internalInstanceHandle) {
- nativeFabricUIManager.sendAccessibilityEvent(
- handle._internalInstanceHandle.stateNode.node,
- eventType
- );
+ if (handle._internalInstanceHandle != null) {
+ var stateNode = handle._internalInstanceHandle.stateNode;
+
+ if (stateNode != null) {
+ nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
+ }
} else {
ReactNativePrivateInterface.legacySendAccessibilityEvent(
handle._nativeTag,
@@ -22964,13 +23707,27 @@ function sendAccessibilityEvent(handle, eventType) {
}
}
+function onRecoverableError(error$1) {
+ // TODO: Expose onRecoverableError option to userspace
+ // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
+ error(error$1);
+}
+
function render(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
// TODO (bvaughn): If we decide to keep the wrapper component,
// We could create a wrapper for containerTag as well to reduce special casing.
- root = createContainer(containerTag, LegacyRoot, false, null, false);
+ root = createContainer(
+ containerTag,
+ LegacyRoot,
+ null,
+ false,
+ null,
+ "",
+ onRecoverableError
+ );
roots.set(containerTag, root);
}
@@ -23043,5 +23800,14 @@ exports.unmountComponentAtNode = unmountComponentAtNode;
exports.unmountComponentAtNodeAndRemoveContainer = unmountComponentAtNodeAndRemoveContainer;
exports.unstable_batchedUpdates = batchedUpdates;
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
+}
+
})();
}
diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js
index 3fb794d73a7827..99e8fc66bc97bd 100644
--- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js
+++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js
@@ -1,5 +1,5 @@
/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@@ -8,7 +8,7 @@
* @nolint
* @providesModule ReactNativeRenderer-prod
* @preventMunge
- * @generated SignedSource<>
+ * @generated SignedSource<<08a279093988c36b477bd72fa59e144d>>
*/
"use strict";
@@ -87,6 +87,7 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
+var assign = Object.assign;
function functionThatReturnsTrue() {
return !0;
}
@@ -119,7 +120,7 @@ function SyntheticEvent(
this.isPropagationStopped = functionThatReturnsFalse;
return this;
}
-Object.assign(SyntheticEvent.prototype, {
+assign(SyntheticEvent.prototype, {
preventDefault: function() {
this.defaultPrevented = !0;
var event = this.nativeEvent;
@@ -173,10 +174,10 @@ SyntheticEvent.extend = function(Interface) {
var Super = this;
E.prototype = Super.prototype;
var prototype = new E();
- Object.assign(prototype, Class.prototype);
+ assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = Object.assign({}, Super.Interface, Interface);
+ Class.Interface = assign({}, Super.Interface, Interface);
Class.extend = Super.extend;
addEventPoolingTo(Class);
return Class;
@@ -783,18 +784,16 @@ function recomputePluginOrdering() {
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName],
pluginIndex = eventPluginOrder.indexOf(pluginName);
- if (!(-1 < pluginIndex))
+ if (-1 >= pluginIndex)
throw Error(
"EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" +
- pluginName +
- "`."
+ (pluginName + "`.")
);
if (!plugins[pluginIndex]) {
if (!pluginModule.extractEvents)
throw Error(
"EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" +
- pluginName +
- "` does not."
+ (pluginName + "` does not.")
);
plugins[pluginIndex] = pluginModule;
pluginIndex = pluginModule.eventTypes;
@@ -805,8 +804,7 @@ function recomputePluginOrdering() {
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same event name, `" +
- eventName$jscomp$0 +
- "`."
+ (eventName$jscomp$0 + "`.")
);
eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
@@ -846,18 +844,22 @@ function publishRegistrationName(registrationName, pluginModule) {
if (registrationNameModules[registrationName])
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" +
- registrationName +
- "`."
+ (registrationName + "`.")
);
registrationNameModules[registrationName] = pluginModule;
}
var plugins = [],
eventNameDispatchConfigs = {},
registrationNameModules = {};
-function getListener$1(inst, registrationName) {
- inst = inst.stateNode;
- if (null === inst) return null;
- inst = getFiberCurrentPropsFromNode(inst);
+function getListeners(
+ inst,
+ registrationName,
+ phase,
+ dispatchToImperativeListeners
+) {
+ var stateNode = inst.stateNode;
+ if (null === stateNode) return null;
+ inst = getFiberCurrentPropsFromNode(stateNode);
if (null === inst) return null;
if ((inst = inst[registrationName]) && "function" !== typeof inst)
throw Error(
@@ -867,7 +869,67 @@ function getListener$1(inst, registrationName) {
typeof inst +
"` type."
);
- return inst;
+ if (
+ !(
+ dispatchToImperativeListeners &&
+ stateNode.canonical &&
+ stateNode.canonical._eventListeners
+ )
+ )
+ return inst;
+ var listeners = [];
+ inst && listeners.push(inst);
+ var requestedPhaseIsCapture = "captured" === phase,
+ mangledImperativeRegistrationName = requestedPhaseIsCapture
+ ? "rn:" + registrationName.replace(/Capture$/, "")
+ : "rn:" + registrationName;
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName] &&
+ 0 <
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName]
+ .length &&
+ stateNode.canonical._eventListeners[
+ mangledImperativeRegistrationName
+ ].forEach(function(listenerObj) {
+ if (
+ (null != listenerObj.options.capture && listenerObj.options.capture) ===
+ requestedPhaseIsCapture
+ ) {
+ var listenerFnWrapper = function(syntheticEvent) {
+ var eventInst = new ReactNativePrivateInterface.CustomEvent(
+ mangledImperativeRegistrationName,
+ { detail: syntheticEvent.nativeEvent }
+ );
+ eventInst.isTrusted = !0;
+ eventInst.setSyntheticEvent(syntheticEvent);
+ for (
+ var _len = arguments.length,
+ args = Array(1 < _len ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ )
+ args[_key - 1] = arguments[_key];
+ listenerObj.listener.apply(listenerObj, [eventInst].concat(args));
+ };
+ listenerObj.options.once
+ ? listeners.push(function() {
+ stateNode.canonical.removeEventListener_unstable(
+ mangledImperativeRegistrationName,
+ listenerObj.listener,
+ listenerObj.capture
+ );
+ listenerObj.invalidated ||
+ ((listenerObj.invalidated = !0),
+ listenerObj.listener.apply(listenerObj, arguments));
+ })
+ : listeners.push(listenerFnWrapper);
+ }
+ });
+ return 0 === listeners.length
+ ? null
+ : 1 === listeners.length
+ ? listeners[0]
+ : listeners;
}
var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
@@ -875,50 +937,74 @@ var customBubblingEventTypes =
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateListenersAndInstances(inst, event, listeners) {
+ var listenersLength = listeners
+ ? isArrayImpl(listeners)
+ ? listeners.length
+ : 1
+ : 0;
+ if (0 < listenersLength)
+ if (
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listeners
+ )),
+ null == event._dispatchInstances && 1 === listenersLength)
+ )
+ event._dispatchInstances = inst;
+ else
+ for (
+ event._dispatchInstances = event._dispatchInstances || [],
+ isArrayImpl(event._dispatchInstances) ||
+ (event._dispatchInstances = [event._dispatchInstances]),
+ listeners = 0;
+ listeners < listenersLength;
+ listeners++
+ )
+ event._dispatchInstances.push(inst);
+}
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
- ));
+ phase = getListeners(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase],
+ phase,
+ !0
+ );
+ accumulateListenersAndInstances(inst, event, phase);
+}
+function traverseTwoPhase$1(inst, fn, arg, skipBubbling) {
+ for (var path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ if (skipBubbling) fn(path[0], "bubbled", arg);
+ else
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
}
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);
- }
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event,
+ !1
+ );
}
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
- )));
+ var listeners = getListeners(
+ inst,
+ event.dispatchConfig.registrationName,
+ "bubbled",
+ !1
+ );
+ accumulateListenersAndInstances(inst, event, listeners);
}
}
}
@@ -931,7 +1017,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_219 = {
+var injectedNamesToPlugins$jscomp$inline_220 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -955,10 +1041,21 @@ var injectedNamesToPlugins$jscomp$inline_219 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(
- topLevelType,
- accumulateTwoPhaseDispatchesSingle$1
- );
+ null != topLevelType &&
+ null != topLevelType.dispatchConfig.phasedRegistrationNames &&
+ topLevelType.dispatchConfig.phasedRegistrationNames.skipBubbling
+ ? topLevelType &&
+ topLevelType.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ topLevelType._targetInst,
+ accumulateDirectionalDispatches$1,
+ topLevelType,
+ !0
+ )
+ : forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
@@ -966,34 +1063,33 @@ var injectedNamesToPlugins$jscomp$inline_219 = {
}
}
},
- isOrderingDirty$jscomp$inline_220 = !1,
- pluginName$jscomp$inline_221;
-for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219)
+ isOrderingDirty$jscomp$inline_221 = !1,
+ pluginName$jscomp$inline_222;
+for (pluginName$jscomp$inline_222 in injectedNamesToPlugins$jscomp$inline_220)
if (
- injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty(
- pluginName$jscomp$inline_221
+ injectedNamesToPlugins$jscomp$inline_220.hasOwnProperty(
+ pluginName$jscomp$inline_222
)
) {
- var pluginModule$jscomp$inline_222 =
- injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221];
+ var pluginModule$jscomp$inline_223 =
+ injectedNamesToPlugins$jscomp$inline_220[pluginName$jscomp$inline_222];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) ||
- namesToPlugins[pluginName$jscomp$inline_221] !==
- pluginModule$jscomp$inline_222
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_222) ||
+ namesToPlugins[pluginName$jscomp$inline_222] !==
+ pluginModule$jscomp$inline_223
) {
- if (namesToPlugins[pluginName$jscomp$inline_221])
+ if (namesToPlugins[pluginName$jscomp$inline_222])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_221 +
- "`."
+ (pluginName$jscomp$inline_222 + "`.")
);
namesToPlugins[
- pluginName$jscomp$inline_221
- ] = pluginModule$jscomp$inline_222;
- isOrderingDirty$jscomp$inline_220 = !0;
+ pluginName$jscomp$inline_222
+ ] = pluginModule$jscomp$inline_223;
+ isOrderingDirty$jscomp$inline_221 = !0;
}
}
-isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_221 && recomputePluginOrdering();
var instanceCache = new Map(),
instanceProps = new Map();
function getInstanceFromTag(tag) {
@@ -1137,43 +1233,25 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
});
var ReactSharedInternals =
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_DEBUG_TRACING_MODE_TYPE = 60129,
- REACT_OFFSCREEN_TYPE = 60130,
- REACT_LEGACY_HIDDEN_TYPE = 60131,
- REACT_CACHE_TYPE = 60132;
-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");
- 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");
- REACT_CACHE_TYPE = symbolFor("react.cache");
-}
-var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ REACT_ELEMENT_TYPE = Symbol.for("react.element"),
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
+ REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
+ REACT_LAZY_TYPE = Symbol.for("react.lazy");
+Symbol.for("react.scope");
+Symbol.for("react.debug_trace_mode");
+var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
+Symbol.for("react.legacy_hidden");
+Symbol.for("react.cache");
+Symbol.for("react.tracing_marker");
+var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -1198,8 +1276,6 @@ function getComponentNameFromType(type) {
return "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
- case REACT_CACHE_TYPE:
- return "Cache";
}
if ("object" === typeof type)
switch (type.$$typeof) {
@@ -1260,8 +1336,6 @@ function getComponentNameFromFiber(fiber) {
return "Text";
case 16:
return getComponentNameFromType(type);
- case 23:
- return "LegacyHidden";
case 8:
return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode";
case 22:
@@ -1274,6 +1348,8 @@ function getComponentNameFromFiber(fiber) {
return "Suspense";
case 19:
return "SuspenseList";
+ case 25:
+ return "TracingMarker";
case 1:
case 0:
case 17:
@@ -1294,7 +1370,7 @@ function getNearestMountedFiber(fiber) {
fiber = node;
do
(node = fiber),
- 0 !== (node.flags & 2050) && (nearestMounted = node.return),
+ 0 !== (node.flags & 4098) && (nearestMounted = node.return),
(fiber = node.return);
while (fiber);
}
@@ -1703,6 +1779,13 @@ function onCommitRoot(root) {
);
} catch (err) {}
}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(x) {
+ x >>>= 0;
+ return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0;
+}
var nextTransitionLane = 64,
nextRetryLane = 4194304;
function getHighestPriorityLanes(lanes) {
@@ -1881,12 +1964,6 @@ function markRootEntangled(root, entangledLanes) {
rootEntangledLanes &= ~lane;
}
}
-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 currentUpdatePriority = 0;
function lanesToEventPriority(lanes) {
lanes &= -lanes;
@@ -2012,7 +2089,7 @@ function processChildContext(fiber, type, parentContext) {
contextKey +
'" is not defined in childContextTypes.'
);
- return Object.assign({}, parentContext, instance);
+ return assign({}, parentContext, instance);
}
function pushContextProvider(workInProgress) {
workInProgress =
@@ -2043,7 +2120,11 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
-var syncQueue = null,
+function is(x, y) {
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
+}
+var objectIs = "function" === typeof Object.is ? Object.is : is,
+ syncQueue = null,
includesLegacySyncCallbacks = !1,
isFlushingSyncQueue = !1;
function flushSyncCallbacks() {
@@ -2072,10 +2153,6 @@ function flushSyncCallbacks() {
return null;
}
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
-function is(x, y) {
- return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
-}
-var objectIs = "function" === typeof Object.is ? Object.is : is;
function shallowEqual(objA, objB) {
if (objectIs(objA, objB)) return !0;
if (
@@ -2088,12 +2165,14 @@ function shallowEqual(objA, objB) {
var keysA = Object.keys(objA),
keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return !1;
- for (keysB = 0; keysB < keysA.length; keysB++)
+ for (keysB = 0; keysB < keysA.length; keysB++) {
+ var currentKey = keysA[keysB];
if (
- !hasOwnProperty.call(objB, keysA[keysB]) ||
- !objectIs(objA[keysA[keysB]], objB[keysA[keysB]])
+ !hasOwnProperty.call(objB, currentKey) ||
+ !objectIs(objA[currentKey], objB[currentKey])
)
return !1;
+ }
return !0;
}
function describeFiber(fiber) {
@@ -2132,7 +2211,7 @@ function getStackByFiberInDevAndProd(workInProgress) {
}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
- baseProps = Object.assign({}, baseProps);
+ baseProps = assign({}, baseProps);
Component = Component.defaultProps;
for (var propName in Component)
void 0 === baseProps[propName] &&
@@ -2153,19 +2232,16 @@ function popProvider(context) {
pop(valueCursor);
context._currentValue = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderLanes) {
+function scheduleContextWorkOnParentPath(parent, renderLanes, propagationRoot) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- 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.childLanes & renderLanes) !== renderLanes
+ ? ((parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes))
+ : null !== alternate &&
+ (alternate.childLanes & renderLanes) !== renderLanes &&
+ (alternate.childLanes |= renderLanes);
+ if (parent === propagationRoot) break;
parent = parent.return;
}
}
@@ -2235,7 +2311,7 @@ function enqueueUpdate(fiber, update) {
((updateQueue = updateQueue.shared),
null !== workInProgressRoot &&
0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
+ 0 === (executionContext & 2)
? ((fiber = updateQueue.interleaved),
null === fiber
? ((update.next = update),
@@ -2372,7 +2448,7 @@ function processUpdateQueue(
newState = workInProgress;
break a;
case 3:
- workInProgress.flags = (workInProgress.flags & -16385) | 128;
+ workInProgress.flags = (workInProgress.flags & -65537) | 128;
case 0:
workInProgress = update.payload;
updateLane =
@@ -2380,7 +2456,7 @@ function processUpdateQueue(
? workInProgress.call(updateEventTime, newState, updateLane)
: workInProgress;
if (null === updateLane || void 0 === updateLane) break a;
- newState = Object.assign({}, newState, updateLane);
+ newState = assign({}, newState, updateLane);
break a;
case 2:
hasForceUpdate = !0;
@@ -2467,7 +2543,7 @@ function applyDerivedStateFromProps(
getDerivedStateFromProps =
null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps
? ctor
- : Object.assign({}, ctor, getDerivedStateFromProps);
+ : assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
@@ -2603,6 +2679,26 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
"function" === typeof instance.componentDidMount &&
(workInProgress.flags |= 4);
}
+var forkStack = [],
+ forkStackIndex = 0,
+ treeForkProvider = null,
+ idStack = [],
+ idStackIndex = 0,
+ treeContextProvider = null;
+function popTreeContext(workInProgress) {
+ for (; workInProgress === treeForkProvider; )
+ (treeForkProvider = forkStack[--forkStackIndex]),
+ (forkStack[forkStackIndex] = null),
+ --forkStackIndex,
+ (forkStack[forkStackIndex] = null);
+ for (; workInProgress === treeContextProvider; )
+ (treeContextProvider = idStack[--idStackIndex]),
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null);
+}
function coerceRef(returnFiber, current, element) {
returnFiber = element.ref;
if (
@@ -2625,7 +2721,8 @@ function coerceRef(returnFiber, current, element) {
returnFiber +
". This error is likely caused by a bug in React. Please file an issue."
);
- var stringRef = "" + returnFiber;
+ var resolvedInst = inst,
+ stringRef = "" + returnFiber;
if (
null !== current &&
null !== current.ref &&
@@ -2634,8 +2731,8 @@ function coerceRef(returnFiber, current, element) {
)
return current.ref;
current = function(value) {
- var refs = inst.refs;
- refs === emptyRefsObject && (refs = inst.refs = {});
+ var refs = resolvedInst.refs;
+ refs === emptyRefsObject && (refs = resolvedInst.refs = {});
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
};
current._stringRef = stringRef;
@@ -2696,7 +2793,8 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function placeChild(newFiber, lastPlacedIndex, newIndex) {
newFiber.index = newIndex;
- if (!shouldTrackSideEffects) return lastPlacedIndex;
+ if (!shouldTrackSideEffects)
+ return (newFiber.flags |= 1048576), lastPlacedIndex;
newIndex = newFiber.alternate;
if (null !== newIndex)
return (
@@ -2787,7 +2885,10 @@ function ChildReconciler(shouldTrackSideEffects) {
return current;
}
function createChild(returnFiber, newChild, lanes) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(newChild = createFiberFromText(
"" + newChild,
@@ -2841,7 +2942,10 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return null !== key
? null
: updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
@@ -2871,7 +2975,10 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild,
lanes
) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(existingChildren = existingChildren.get(newIdx) || null),
updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
@@ -3072,60 +3179,49 @@ function ChildReconciler(shouldTrackSideEffects) {
return iteratorFn;
}
return function(returnFiber, currentFirstChild, newChild, lanes) {
- var isUnkeyedTopLevelFragment =
- "object" === typeof newChild &&
+ "object" === typeof newChild &&
null !== newChild &&
newChild.type === REACT_FRAGMENT_TYPE &&
- null === newChild.key;
- isUnkeyedTopLevelFragment && (newChild = newChild.props.children);
+ null === newChild.key &&
+ (newChild = newChild.props.children);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
a: {
- var key = newChild.key;
for (
- isUnkeyedTopLevelFragment = currentFirstChild;
- null !== isUnkeyedTopLevelFragment;
+ var key = newChild.key, child = currentFirstChild;
+ null !== child;
) {
- if (isUnkeyedTopLevelFragment.key === key) {
+ if (child.key === key) {
key = newChild.type;
if (key === REACT_FRAGMENT_TYPE) {
- if (7 === isUnkeyedTopLevelFragment.tag) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
+ if (7 === child.tag) {
+ deleteRemainingChildren(returnFiber, child.sibling);
currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
+ child,
newChild.props.children
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- } else if (isUnkeyedTopLevelFragment.elementType === key) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
- currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
- newChild.props
- );
+ } else if (child.elementType === key) {
+ deleteRemainingChildren(returnFiber, child.sibling);
+ currentFirstChild = useFiber(child, newChild.props);
currentFirstChild.ref = coerceRef(
returnFiber,
- isUnkeyedTopLevelFragment,
+ child,
newChild
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment);
+ deleteRemainingChildren(returnFiber, child);
break;
- } else deleteChild(returnFiber, isUnkeyedTopLevelFragment);
- isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling;
+ } else deleteChild(returnFiber, child);
+ child = child.sibling;
}
newChild.type === REACT_FRAGMENT_TYPE
? ((currentFirstChild = createFiberFromFragment(
@@ -3155,12 +3251,8 @@ function ChildReconciler(shouldTrackSideEffects) {
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
a: {
- for (
- isUnkeyedTopLevelFragment = newChild.key;
- null !== currentFirstChild;
-
- ) {
- if (currentFirstChild.key === isUnkeyedTopLevelFragment)
+ for (child = newChild.key; null !== currentFirstChild; ) {
+ if (currentFirstChild.key === child)
if (
4 === currentFirstChild.tag &&
currentFirstChild.stateNode.containerInfo ===
@@ -3212,9 +3304,9 @@ function ChildReconciler(shouldTrackSideEffects) {
);
throwOnInvalidObjectType(returnFiber, newChild);
}
- if ("string" === typeof newChild || "number" === typeof newChild)
- return (
- (newChild = "" + newChild),
+ return ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ ? ((newChild = "" + newChild),
null !== currentFirstChild && 6 === currentFirstChild.tag
? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling),
(currentFirstChild = useFiber(currentFirstChild, newChild)),
@@ -3228,20 +3320,8 @@ function ChildReconciler(shouldTrackSideEffects) {
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
- placeSingleChild(returnFiber)
- );
- if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
- switch (returnFiber.tag) {
- case 1:
- case 0:
- case 11:
- case 15:
- throw Error(
- (getComponentNameFromFiber(returnFiber) || "Component") +
- "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."
- );
- }
- return deleteRemainingChildren(returnFiber, currentFirstChild);
+ placeSingleChild(returnFiber))
+ : deleteRemainingChildren(returnFiber, currentFirstChild);
};
}
var reconcileChildFibers = ChildReconciler(!0),
@@ -3328,7 +3408,8 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
currentHook = null,
workInProgressHook = null,
didScheduleRenderPhaseUpdate = !1,
- didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ didScheduleRenderPhaseUpdateDuringThisPass = !1,
+ globalClientIdCounter = 0;
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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
@@ -3362,7 +3443,7 @@ function renderWithHooks(
nextRenderLanes = 0;
do {
didScheduleRenderPhaseUpdateDuringThisPass = !1;
- if (!(25 > nextRenderLanes))
+ if (25 <= nextRenderLanes)
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
@@ -3463,19 +3544,18 @@ function updateReducer(reducer) {
(newBaseQueueLast = newBaseQueueLast.next = {
lane: 0,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
}),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ (current = update.hasEagerState
+ ? update.eagerState
+ : reducer(current, update.action));
else {
var clone = {
lane: updateLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
@@ -3532,109 +3612,77 @@ 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 may be 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."
+function updateMutableSource() {}
+function updateSyncExternalStore(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = updateWorkInProgressHook(),
+ nextSnapshot = getSnapshot(),
+ snapshotChanged = !objectIs(hook.memoizedState, nextSnapshot);
+ snapshotChanged &&
+ ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
+ hook = hook.queue;
+ updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [
+ subscribe
+ ]);
+ if (
+ hook.getSnapshot !== getSnapshot ||
+ snapshotChanged ||
+ (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1)
+ ) {
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot),
+ void 0,
+ null
);
- 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);
- objectIs(version, maybeNewVersion) ||
- ((maybeNewVersion = getSnapshot(source._source)),
- objectIs(snapshot, maybeNewVersion) ||
- (setSnapshot(maybeNewVersion),
- (maybeNewVersion = requestUpdateLane(fiber)),
- (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)),
- markRootEntangled(root, root.mutableReadLanes));
- },
- [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);
- 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,
- interleaved: null,
- lanes: 0,
- 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;
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ return nextSnapshot;
+}
+function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
+ fiber.flags |= 16384;
+ fiber = { getSnapshot: getSnapshot, value: renderedSnapshot };
+ getSnapshot = currentlyRenderingFiber$1.updateQueue;
+ null === getSnapshot
+ ? ((getSnapshot = { lastEffect: null, stores: null }),
+ (currentlyRenderingFiber$1.updateQueue = getSnapshot),
+ (getSnapshot.stores = [fiber]))
+ : ((renderedSnapshot = getSnapshot.stores),
+ null === renderedSnapshot
+ ? (getSnapshot.stores = [fiber])
+ : renderedSnapshot.push(fiber));
+}
+function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
+ inst.value = nextSnapshot;
+ inst.getSnapshot = getSnapshot;
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+}
+function subscribeToStore(fiber, inst, subscribe) {
+ return subscribe(function() {
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+ });
}
-function updateMutableSource(source, getSnapshot, subscribe) {
- var hook = updateWorkInProgressHook();
- return useMutableSource(hook, source, getSnapshot, subscribe);
+function checkIfSnapshotChanged(inst) {
+ var latestGetSnapshot = inst.getSnapshot;
+ inst = inst.value;
+ try {
+ var nextValue = latestGetSnapshot();
+ return !objectIs(inst, nextValue);
+ } catch (error) {
+ return !0;
+ }
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
- initialState = hook.queue = {
+ initialState = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3642,7 +3690,8 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
- initialState = initialState.dispatch = dispatchAction.bind(
+ hook.queue = initialState;
+ initialState = initialState.dispatch = dispatchSetState.bind(
null,
currentlyRenderingFiber$1,
initialState
@@ -3653,7 +3702,7 @@ function pushEffect(tag, create, destroy, deps) {
tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null };
create = currentlyRenderingFiber$1.updateQueue;
null === create
- ? ((create = { lastEffect: null }),
+ ? ((create = { lastEffect: null, stores: null }),
(currentlyRenderingFiber$1.updateQueue = create),
(create.lastEffect = tag.next = tag))
: ((destroy = create.lastEffect),
@@ -3694,14 +3743,17 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps);
}
function mountEffect(create, deps) {
- return mountEffectImpl(1049600, 4, create, deps);
+ return mountEffectImpl(8390656, 8, create, deps);
}
function updateEffect(create, deps) {
- return updateEffectImpl(1024, 4, create, deps);
+ return updateEffectImpl(2048, 8, create, deps);
}
-function updateLayoutEffect(create, deps) {
+function updateInsertionEffect(create, deps) {
return updateEffectImpl(4, 2, create, deps);
}
+function updateLayoutEffect(create, deps) {
+ return updateEffectImpl(4, 4, create, deps);
+}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
@@ -3724,7 +3776,7 @@ function updateImperativeHandle(ref, create, deps) {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return updateEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
@@ -3763,7 +3815,7 @@ function startTransition(setPending, callback) {
0 !== previousPriority && 4 > previousPriority ? previousPriority : 4;
setPending(!0);
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setPending(!1), callback();
} finally {
@@ -3771,47 +3823,38 @@ function startTransition(setPending, callback) {
(ReactCurrentBatchConfig$1.transition = prevTransition);
}
}
-function dispatchAction(fiber, queue, action) {
- var eventTime = requestEventTime(),
- lane = requestUpdateLane(fiber),
+function updateId() {
+ return updateWorkInProgressHook().memoizedState;
+}
+function dispatchReducerAction(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber);
+ action = {
+ lane: lane,
+ action: action,
+ hasEagerState: !1,
+ eagerState: null,
+ next: null
+ };
+ isRenderPhaseUpdate(fiber)
+ ? enqueueRenderPhaseUpdate(queue, action)
+ : (enqueueUpdate$1(fiber, queue, action),
+ (action = requestEventTime()),
+ (fiber = scheduleUpdateOnFiber(fiber, lane, action)),
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane));
+}
+function dispatchSetState(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber),
update = {
lane: lane,
action: action,
- eagerReducer: null,
+ hasEagerState: !1,
eagerState: null,
next: null
- },
- alternate = fiber.alternate;
- if (
- fiber === currentlyRenderingFiber$1 ||
- (null !== alternate && alternate === currentlyRenderingFiber$1)
- )
- (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0),
- (lane = queue.pending),
- null === lane
- ? (update.next = update)
- : ((update.next = lane.next), (lane.next = update)),
- (queue.pending = update);
+ };
+ if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update);
else {
- if (
- null !== workInProgressRoot &&
- 0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
- ) {
- var interleaved = queue.interleaved;
- null === interleaved
- ? ((update.next = update),
- null === interleavedQueues
- ? (interleavedQueues = [queue])
- : interleavedQueues.push(queue))
- : ((update.next = interleaved.next), (interleaved.next = update));
- queue.interleaved = update;
- } else
- (interleaved = queue.pending),
- null === interleaved
- ? (update.next = update)
- : ((update.next = interleaved.next), (interleaved.next = update)),
- (queue.pending = update);
+ enqueueUpdate$1(fiber, queue, update);
+ var alternate = fiber.alternate;
if (
0 === fiber.lanes &&
(null === alternate || 0 === alternate.lanes) &&
@@ -3820,20 +3863,57 @@ function dispatchAction(fiber, queue, action) {
try {
var currentState = queue.lastRenderedState,
eagerState = alternate(currentState, action);
- update.eagerReducer = alternate;
+ update.hasEagerState = !0;
update.eagerState = eagerState;
if (objectIs(eagerState, currentState)) return;
} catch (error) {
} finally {
}
- update = scheduleUpdateOnFiber(fiber, lane, eventTime);
- 0 !== (lane & 4194240) &&
- null !== update &&
- ((fiber = queue.lanes),
- (fiber &= update.pendingLanes),
- (lane |= fiber),
- (queue.lanes = lane),
- markRootEntangled(update, lane));
+ action = requestEventTime();
+ fiber = scheduleUpdateOnFiber(fiber, lane, action);
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane);
+ }
+}
+function isRenderPhaseUpdate(fiber) {
+ var alternate = fiber.alternate;
+ return (
+ fiber === currentlyRenderingFiber$1 ||
+ (null !== alternate && alternate === currentlyRenderingFiber$1)
+ );
+}
+function enqueueRenderPhaseUpdate(queue, update) {
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
+ var pending = queue.pending;
+ null === pending
+ ? (update.next = update)
+ : ((update.next = pending.next), (pending.next = update));
+ queue.pending = update;
+}
+function enqueueUpdate$1(fiber, queue, update) {
+ null !== workInProgressRoot &&
+ 0 !== (fiber.mode & 1) &&
+ 0 === (executionContext & 2)
+ ? ((fiber = queue.interleaved),
+ null === fiber
+ ? ((update.next = update),
+ null === interleavedQueues
+ ? (interleavedQueues = [queue])
+ : interleavedQueues.push(queue))
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.interleaved = update))
+ : ((fiber = queue.pending),
+ null === fiber
+ ? (update.next = update)
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.pending = update));
+}
+function entangleTransitionUpdate(root, queue, lane) {
+ if (0 !== (lane & 4194240)) {
+ var queueLanes = queue.lanes;
+ queueLanes &= root.pendingLanes;
+ lane |= queueLanes;
+ queue.lanes = lane;
+ markRootEntangled(root, lane);
}
}
var ContextOnlyDispatcher = {
@@ -3842,6 +3922,7 @@ var ContextOnlyDispatcher = {
useContext: throwInvalidHookError,
useEffect: throwInvalidHookError,
useImperativeHandle: throwInvalidHookError,
+ useInsertionEffect: throwInvalidHookError,
useLayoutEffect: throwInvalidHookError,
useMemo: throwInvalidHookError,
useReducer: throwInvalidHookError,
@@ -3851,7 +3932,8 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
- useOpaqueIdentifier: throwInvalidHookError,
+ useSyncExternalStore: throwInvalidHookError,
+ useId: throwInvalidHookError,
unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
@@ -3869,12 +3951,15 @@ var ContextOnlyDispatcher = {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return mountEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
},
useLayoutEffect: function(create, deps) {
+ return mountEffectImpl(4, 4, create, deps);
+ },
+ useInsertionEffect: function(create, deps) {
return mountEffectImpl(4, 2, create, deps);
},
useMemo: function(nextCreate, deps) {
@@ -3888,7 +3973,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
- reducer = hook.queue = {
+ reducer = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3896,7 +3981,8 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
- reducer = reducer.dispatch = dispatchAction.bind(
+ hook.queue = reducer;
+ reducer = reducer.dispatch = dispatchReducerAction.bind(
null,
currentlyRenderingFiber$1,
reducer
@@ -3917,7 +4003,7 @@ var ContextOnlyDispatcher = {
mountEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -3935,17 +4021,39 @@ var ContextOnlyDispatcher = {
mountWorkInProgressHook().memoizedState = _mountState2;
return [isPending, _mountState2];
},
- 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);
+ useMutableSource: function() {},
+ useSyncExternalStore: function(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = mountWorkInProgressHook();
+ var nextSnapshot = getSnapshot();
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ hook.memoizedState = nextSnapshot;
+ var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
+ hook.queue = inst;
+ mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [
+ subscribe
+ ]);
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ void 0,
+ null
+ );
+ return nextSnapshot;
},
- useOpaqueIdentifier: function() {
- throw Error("Not yet implemented");
+ useId: function() {
+ var hook = mountWorkInProgressHook(),
+ identifierPrefix = workInProgressRoot.identifierPrefix,
+ globalClientId = globalClientIdCounter++;
+ identifierPrefix =
+ ":" + identifierPrefix + "r" + globalClientId.toString(32) + ":";
+ return (hook.memoizedState = identifierPrefix);
},
unstable_isNewReconciler: !1
},
@@ -3955,6 +4063,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: updateReducer,
@@ -3970,7 +4079,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -3987,9 +4096,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return updateReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
@@ -3998,6 +4106,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: rerenderReducer,
@@ -4013,7 +4122,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -4030,9 +4139,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return rerenderReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
};
function createCapturedValue(value, source) {
@@ -4083,19 +4191,21 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
if ("function" === typeof getDerivedStateFromError) {
var error = errorInfo.value;
lane.payload = function() {
- logCapturedError(fiber, errorInfo);
return getDerivedStateFromError(error);
};
+ lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
+ };
}
var inst = fiber.stateNode;
null !== inst &&
"function" === typeof inst.componentDidCatch &&
(lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
"function" !== typeof getDerivedStateFromError &&
(null === legacyErrorBoundariesThatAlreadyFailed
? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logCapturedError(fiber, errorInfo));
+ : legacyErrorBoundariesThatAlreadyFailed.add(this));
var stack = errorInfo.stack;
this.componentDidCatch(errorInfo.value, {
componentStack: null !== stack ? stack : ""
@@ -4103,25 +4213,422 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
});
return lane;
}
-var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
- didReceiveUpdate = !1;
-function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
- workInProgress.child =
- null === current
- ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
- : reconcileChildFibers(
- workInProgress,
- current.child,
- nextChildren,
- renderLanes
- );
+function attachPingListener(root, wakeable, lanes) {
+ var pingCache = root.pingCache;
+ if (null === pingCache) {
+ pingCache = root.pingCache = new PossiblyWeakMap();
+ var threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
+ } else
+ (threadIDs = pingCache.get(wakeable)),
+ void 0 === threadIDs &&
+ ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs));
+ threadIDs.has(lanes) ||
+ (threadIDs.add(lanes),
+ (root = pingSuspendedRoot.bind(null, root, wakeable, lanes)),
+ wakeable.then(root, root));
+}
+var appendAllChildren, updateHostContainer, updateHostComponent, updateHostText;
+appendAllChildren = function(parent, workInProgress) {
+ for (var node = workInProgress.child; null !== node; ) {
+ if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode);
+ else if (4 !== node.tag && null !== node.child) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ if (node === workInProgress) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === workInProgress) return;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+};
+updateHostContainer = function() {};
+updateHostComponent = function(current, workInProgress, type, newProps) {
+ current.memoizedProps !== newProps &&
+ (requiredContext(contextStackCursor$1.current),
+ (workInProgress.updateQueue = UPDATE_SIGNAL)) &&
+ (workInProgress.flags |= 4);
+};
+updateHostText = function(current, workInProgress, oldText, newText) {
+ oldText !== newText && (workInProgress.flags |= 4);
+};
+function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
+ switch (renderState.tailMode) {
+ case "hidden":
+ hasRenderedATailFallback = renderState.tail;
+ for (var lastTailNode = null; null !== hasRenderedATailFallback; )
+ null !== hasRenderedATailFallback.alternate &&
+ (lastTailNode = hasRenderedATailFallback),
+ (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
+ null === lastTailNode
+ ? (renderState.tail = null)
+ : (lastTailNode.sibling = null);
+ break;
+ case "collapsed":
+ lastTailNode = renderState.tail;
+ for (var lastTailNode$35 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$35 = lastTailNode),
+ (lastTailNode = lastTailNode.sibling);
+ null === lastTailNode$35
+ ? hasRenderedATailFallback || null === renderState.tail
+ ? (renderState.tail = null)
+ : (renderState.tail.sibling = null)
+ : (lastTailNode$35.sibling = null);
+ }
}
-function updateForwardRef(
- current,
- workInProgress,
- Component,
- nextProps,
- renderLanes
+function bubbleProperties(completedWork) {
+ var didBailout =
+ null !== completedWork.alternate &&
+ completedWork.alternate.child === completedWork.child,
+ newChildLanes = 0,
+ subtreeFlags = 0;
+ if (didBailout)
+ for (var child$36 = completedWork.child; null !== child$36; )
+ (newChildLanes |= child$36.lanes | child$36.childLanes),
+ (subtreeFlags |= child$36.subtreeFlags & 14680064),
+ (subtreeFlags |= child$36.flags & 14680064),
+ (child$36.return = completedWork),
+ (child$36 = child$36.sibling);
+ else
+ for (child$36 = completedWork.child; null !== child$36; )
+ (newChildLanes |= child$36.lanes | child$36.childLanes),
+ (subtreeFlags |= child$36.subtreeFlags),
+ (subtreeFlags |= child$36.flags),
+ (child$36.return = completedWork),
+ (child$36 = child$36.sibling);
+ completedWork.subtreeFlags |= subtreeFlags;
+ completedWork.childLanes = newChildLanes;
+ return didBailout;
+}
+function completeWork(current, workInProgress, renderLanes) {
+ var newProps = workInProgress.pendingProps;
+ popTreeContext(workInProgress);
+ switch (workInProgress.tag) {
+ case 2:
+ case 16:
+ case 15:
+ case 0:
+ case 11:
+ case 7:
+ case 8:
+ case 12:
+ case 9:
+ case 14:
+ return bubbleProperties(workInProgress), null;
+ case 1:
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 3:
+ return (
+ (newProps = workInProgress.stateNode),
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ null === current ||
+ (current.memoizedState.isDehydrated &&
+ 0 === (workInProgress.flags & 256)) ||
+ (workInProgress.flags |= 1024),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 5:
+ popHostContext(workInProgress);
+ renderLanes = requiredContext(rootInstanceStackCursor.current);
+ var type = workInProgress.type;
+ if (null !== current && null != workInProgress.stateNode)
+ updateHostComponent(
+ current,
+ workInProgress,
+ type,
+ newProps,
+ renderLanes
+ ),
+ current.ref !== workInProgress.ref && (workInProgress.flags |= 512);
+ else {
+ if (!newProps) {
+ if (null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ }
+ requiredContext(contextStackCursor$1.current);
+ current = allocateTag();
+ type = getViewConfigForType(type);
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ newProps,
+ type.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.createView(
+ current,
+ type.uiViewClassName,
+ renderLanes,
+ updatePayload
+ );
+ renderLanes = new ReactNativeFiberHostComponent(
+ current,
+ type,
+ workInProgress
+ );
+ instanceCache.set(current, workInProgress);
+ instanceProps.set(current, newProps);
+ appendAllChildren(renderLanes, workInProgress, !1, !1);
+ workInProgress.stateNode = renderLanes;
+ finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4);
+ null !== workInProgress.ref && (workInProgress.flags |= 512);
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 6:
+ if (current && null != workInProgress.stateNode)
+ updateHostText(
+ current,
+ workInProgress,
+ current.memoizedProps,
+ newProps
+ );
+ else {
+ if ("string" !== typeof newProps && null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ current = requiredContext(rootInstanceStackCursor.current);
+ if (!requiredContext(contextStackCursor$1.current).isInAParentText)
+ throw Error(
+ "Text strings must be rendered within a component."
+ );
+ renderLanes = allocateTag();
+ ReactNativePrivateInterface.UIManager.createView(
+ renderLanes,
+ "RCTRawText",
+ current,
+ { text: newProps }
+ );
+ instanceCache.set(renderLanes, workInProgress);
+ workInProgress.stateNode = renderLanes;
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 13:
+ pop(suspenseStackCursor);
+ newProps = workInProgress.memoizedState;
+ if (0 !== (workInProgress.flags & 128))
+ return (workInProgress.lanes = renderLanes), workInProgress;
+ renderLanes = !1;
+ null !== current && (renderLanes = null !== current.memoizedState);
+ null === newProps ||
+ renderLanes ||
+ ((workInProgress.child.flags |= 8192),
+ 0 !== (workInProgress.mode & 1) &&
+ (null === current || 0 !== (suspenseStackCursor.current & 1)
+ ? 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3)
+ : renderDidSuspendDelayIfPossible()));
+ null !== workInProgress.updateQueue && (workInProgress.flags |= 4);
+ bubbleProperties(workInProgress);
+ return null;
+ case 4:
+ return (
+ popHostContainer(),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 10:
+ return (
+ popProvider(workInProgress.type._context),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 17:
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 19:
+ pop(suspenseStackCursor);
+ type = workInProgress.memoizedState;
+ if (null === type) return bubbleProperties(workInProgress), null;
+ newProps = 0 !== (workInProgress.flags & 128);
+ updatePayload = type.rendering;
+ if (null === updatePayload)
+ if (newProps) cutOffTailIfNeeded(type, !1);
+ else {
+ if (
+ 0 !== workInProgressRootExitStatus ||
+ (null !== current && 0 !== (current.flags & 128))
+ )
+ for (current = workInProgress.child; null !== current; ) {
+ updatePayload = findFirstSuspended(current);
+ if (null !== updatePayload) {
+ workInProgress.flags |= 128;
+ cutOffTailIfNeeded(type, !1);
+ current = updatePayload.updateQueue;
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4));
+ workInProgress.subtreeFlags = 0;
+ current = renderLanes;
+ for (newProps = workInProgress.child; null !== newProps; )
+ (renderLanes = newProps),
+ (type = current),
+ (renderLanes.flags &= 14680066),
+ (updatePayload = renderLanes.alternate),
+ null === updatePayload
+ ? ((renderLanes.childLanes = 0),
+ (renderLanes.lanes = type),
+ (renderLanes.child = null),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.memoizedProps = null),
+ (renderLanes.memoizedState = null),
+ (renderLanes.updateQueue = null),
+ (renderLanes.dependencies = null),
+ (renderLanes.stateNode = null))
+ : ((renderLanes.childLanes = updatePayload.childLanes),
+ (renderLanes.lanes = updatePayload.lanes),
+ (renderLanes.child = updatePayload.child),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.deletions = null),
+ (renderLanes.memoizedProps =
+ updatePayload.memoizedProps),
+ (renderLanes.memoizedState =
+ updatePayload.memoizedState),
+ (renderLanes.updateQueue = updatePayload.updateQueue),
+ (renderLanes.type = updatePayload.type),
+ (type = updatePayload.dependencies),
+ (renderLanes.dependencies =
+ null === type
+ ? null
+ : {
+ lanes: type.lanes,
+ firstContext: type.firstContext
+ })),
+ (newProps = newProps.sibling);
+ push(
+ suspenseStackCursor,
+ (suspenseStackCursor.current & 1) | 2
+ );
+ return workInProgress.child;
+ }
+ current = current.sibling;
+ }
+ null !== type.tail &&
+ now() > workInProgressRootRenderTargetTime &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ }
+ else {
+ if (!newProps)
+ if (
+ ((current = findFirstSuspended(updatePayload)), null !== current)
+ ) {
+ if (
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ (current = current.updateQueue),
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4)),
+ cutOffTailIfNeeded(type, !0),
+ null === type.tail &&
+ "hidden" === type.tailMode &&
+ !updatePayload.alternate)
+ )
+ return bubbleProperties(workInProgress), null;
+ } else
+ 2 * now() - type.renderingStartTime >
+ workInProgressRootRenderTargetTime &&
+ 1073741824 !== renderLanes &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ type.isBackwards
+ ? ((updatePayload.sibling = workInProgress.child),
+ (workInProgress.child = updatePayload))
+ : ((current = type.last),
+ null !== current
+ ? (current.sibling = updatePayload)
+ : (workInProgress.child = updatePayload),
+ (type.last = updatePayload));
+ }
+ if (null !== type.tail)
+ return (
+ (workInProgress = type.tail),
+ (type.rendering = workInProgress),
+ (type.tail = workInProgress.sibling),
+ (type.renderingStartTime = now()),
+ (workInProgress.sibling = null),
+ (current = suspenseStackCursor.current),
+ push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
+ workInProgress
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ case 22:
+ case 23:
+ return (
+ popRenderLanes(),
+ (newProps = null !== workInProgress.memoizedState),
+ null !== current &&
+ (null !== current.memoizedState) !== newProps &&
+ (workInProgress.flags |= 8192),
+ newProps && 0 !== (workInProgress.mode & 1)
+ ? 0 !== (subtreeRenderLanes & 1073741824) &&
+ (bubbleProperties(workInProgress),
+ workInProgress.subtreeFlags & 6 && (workInProgress.flags |= 8192))
+ : bubbleProperties(workInProgress),
+ null
+ );
+ case 24:
+ return null;
+ case 25:
+ return null;
+ }
+ throw Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in React. Please file an issue."
+ );
+}
+var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
+ didReceiveUpdate = !1;
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
+ workInProgress.child =
+ null === current
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
+ : reconcileChildFibers(
+ workInProgress,
+ current.child,
+ nextChildren,
+ renderLanes
+ );
+}
+function updateForwardRef(
+ current,
+ workInProgress,
+ Component,
+ nextProps,
+ renderLanes
) {
Component = Component.render;
var ref = workInProgress.ref;
@@ -4137,7 +4644,7 @@ function updateForwardRef(
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
+ (workInProgress.flags &= -2053),
(current.lanes &= ~renderLanes),
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
@@ -4150,7 +4657,6 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateLanes,
renderLanes
) {
if (null === current) {
@@ -4170,7 +4676,6 @@ function updateMemoComponent(
workInProgress,
type,
nextProps,
- updateLanes,
renderLanes
)
);
@@ -4187,14 +4692,13 @@ function updateMemoComponent(
return (workInProgress.child = current);
}
type = current.child;
- if (
- 0 === (updateLanes & renderLanes) &&
- ((updateLanes = type.memoizedProps),
- (Component = Component.compare),
- (Component = null !== Component ? Component : shallowEqual),
- Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
- )
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ if (0 === (current.lanes & renderLanes)) {
+ var prevProps = type.memoizedProps;
+ Component = Component.compare;
+ Component = null !== Component ? Component : shallowEqual;
+ if (Component(prevProps, nextProps) && current.ref === workInProgress.ref)
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
workInProgress.flags |= 1;
current = createWorkInProgress(type, nextProps);
current.ref = workInProgress.ref;
@@ -4206,22 +4710,20 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateLanes,
renderLanes
) {
if (
null !== current &&
shallowEqual(current.memoizedProps, nextProps) &&
current.ref === workInProgress.ref
- ) {
- didReceiveUpdate = !1;
- if (0 === (renderLanes & updateLanes))
+ )
+ if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes)))
+ 0 !== (current.flags & 131072) && (didReceiveUpdate = !0);
+ else
return (
(workInProgress.lanes = current.lanes),
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
- 0 !== (current.flags & 32768) && (didReceiveUpdate = !0);
- }
return updateFunctionComponent(
current,
workInProgress,
@@ -4234,10 +4736,7 @@ 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 ("hidden" === nextProps.mode)
if (0 === (workInProgress.mode & 1))
(workInProgress.memoizedState = { baseLanes: 0, cachePool: null }),
push(subtreeRenderLanesCursor, subtreeRenderLanes),
@@ -4274,13 +4773,13 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) {
reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function markRef(current, workInProgress) {
+function markRef$1(current, workInProgress) {
var ref = workInProgress.ref;
if (
(null === current && null !== ref) ||
(null !== current && current.ref !== ref)
)
- workInProgress.flags |= 256;
+ workInProgress.flags |= 512;
}
function updateFunctionComponent(
current,
@@ -4305,7 +4804,7 @@ function updateFunctionComponent(
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
+ (workInProgress.flags &= -2053),
(current.lanes &= ~renderLanes),
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
@@ -4481,7 +4980,7 @@ function updateClassComponent(
"function" === typeof instance.componentDidUpdate &&
(workInProgress.flags |= 4),
"function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.flags |= 512))
+ (workInProgress.flags |= 1024))
: ("function" !== typeof instance.componentDidUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
@@ -4489,7 +4988,7 @@ function updateClassComponent(
"function" !== typeof instance.getSnapshotBeforeUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
+ (workInProgress.flags |= 1024),
(workInProgress.memoizedProps = nextProps),
(workInProgress.memoizedState = newState)),
(instance.props = nextProps),
@@ -4503,7 +5002,7 @@ function updateClassComponent(
"function" !== typeof instance.getSnapshotBeforeUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
+ (workInProgress.flags |= 1024),
(nextProps = !1));
}
return finishClassComponent(
@@ -4523,7 +5022,7 @@ function finishClassComponent(
hasContext,
renderLanes
) {
- markRef(current, workInProgress);
+ markRef$1(current, workInProgress);
var didCaptureError = 0 !== (workInProgress.flags & 128);
if (!shouldUpdate && !didCaptureError)
return (
@@ -4567,7 +5066,7 @@ function pushHostRootContext(workInProgress) {
pushTopLevelContextObject(workInProgress, root.context, !1);
pushHostContainer(workInProgress, root.containerInfo);
}
-var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
+var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 };
function mountSuspenseOffscreenState(renderLanes) {
return { baseLanes: renderLanes, cachePool: null };
}
@@ -4581,49 +5080,47 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
null !== current && null === current.memoizedState
? !1
: 0 !== (suspenseContext & 2));
- JSCompiler_temp
- ? ((showFallback = !0), (workInProgress.flags &= -129))
- : (null !== current && null === current.memoizedState) ||
- void 0 === nextProps.fallback ||
- !0 === nextProps.unstable_avoidThisFallback ||
- (suspenseContext |= 1);
+ if (JSCompiler_temp) (showFallback = !0), (workInProgress.flags &= -129);
+ else if (null === current || null !== current.memoizedState)
+ suspenseContext |= 1;
push(suspenseStackCursor, suspenseContext & 1);
if (null === current) {
- current = nextProps.children;
- suspenseContext = nextProps.fallback;
+ suspenseContext = nextProps.children;
+ current = nextProps.fallback;
if (showFallback)
return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
- current,
- suspenseContext,
- renderLanes
- )),
- (workInProgress.child.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- )),
- (workInProgress.memoizedState = SUSPENDED_MARKER),
- current
- );
- if ("number" === typeof nextProps.unstable_expectedLoadTime)
- return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
+ (showFallback = workInProgress.mode),
+ (nextProps = workInProgress.child),
+ (suspenseContext = { mode: "hidden", children: suspenseContext }),
+ 0 === (showFallback & 1) && null !== nextProps
+ ? ((nextProps.childLanes = 0),
+ (nextProps.pendingProps = suspenseContext))
+ : (nextProps = createFiberFromOffscreen(
+ suspenseContext,
+ showFallback,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
current,
- suspenseContext,
- renderLanes
+ showFallback,
+ renderLanes,
+ null
)),
+ (nextProps.return = workInProgress),
+ (current.return = workInProgress),
+ (nextProps.sibling = current),
+ (workInProgress.child = nextProps),
(workInProgress.child.memoizedState = mountSuspenseOffscreenState(
renderLanes
)),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- (workInProgress.lanes = 4194304),
current
);
renderLanes = createFiberFromOffscreen(
- { mode: "visible", children: current },
+ { mode: "visible", children: suspenseContext },
workInProgress.mode,
- renderLanes,
+ 0,
null
);
renderLanes.return = workInProgress;
@@ -4632,25 +5129,25 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
if (null !== current.memoizedState) {
if (showFallback)
return (
- (nextProps = updateSuspenseFallbackChildren(
+ (showFallback = updateSuspenseFallbackChildren(
current,
workInProgress,
nextProps.children,
nextProps.fallback,
renderLanes
)),
- (showFallback = workInProgress.child),
+ (nextProps = workInProgress.child),
(suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
+ (nextProps.memoizedState =
null === suspenseContext
? mountSuspenseOffscreenState(renderLanes)
: {
baseLanes: suspenseContext.baseLanes | renderLanes,
cachePool: null
}),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
+ showFallback
);
renderLanes = updateSuspensePrimaryChildren(
current,
@@ -4663,25 +5160,25 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
}
if (showFallback)
return (
- (nextProps = updateSuspenseFallbackChildren(
+ (showFallback = updateSuspenseFallbackChildren(
current,
workInProgress,
nextProps.children,
nextProps.fallback,
renderLanes
)),
- (showFallback = workInProgress.child),
+ (nextProps = workInProgress.child),
(suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
+ (nextProps.memoizedState =
null === suspenseContext
? mountSuspenseOffscreenState(renderLanes)
: {
baseLanes: suspenseContext.baseLanes | renderLanes,
cachePool: null
}),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
+ showFallback
);
renderLanes = updateSuspensePrimaryChildren(
current,
@@ -4692,36 +5189,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
workInProgress.memoizedState = null;
return renderLanes;
}
-function mountSuspenseFallbackChildren(
- workInProgress,
- primaryChildren,
- fallbackChildren,
- renderLanes
-) {
- var mode = workInProgress.mode,
- progressedPrimaryFragment = workInProgress.child;
- primaryChildren = { mode: "hidden", children: primaryChildren };
- 0 === (mode & 1) && null !== progressedPrimaryFragment
- ? ((progressedPrimaryFragment.childLanes = 0),
- (progressedPrimaryFragment.pendingProps = primaryChildren))
- : (progressedPrimaryFragment = createFiberFromOffscreen(
- primaryChildren,
- mode,
- 0,
- null
- ));
- fallbackChildren = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- );
- progressedPrimaryFragment.return = workInProgress;
- fallbackChildren.return = workInProgress;
- progressedPrimaryFragment.sibling = fallbackChildren;
- workInProgress.child = progressedPrimaryFragment;
- return fallbackChildren;
-}
function updateSuspensePrimaryChildren(
current,
workInProgress,
@@ -4761,7 +5228,7 @@ function updateSuspenseFallbackChildren(
(primaryChildren.pendingProps = primaryChildProps),
(workInProgress.deletions = null))
: ((primaryChildren = createWorkInProgress(current, primaryChildProps)),
- (primaryChildren.subtreeFlags = current.subtreeFlags & 1835008));
+ (primaryChildren.subtreeFlags = current.subtreeFlags & 14680064));
null !== currentFallbackChildFragment
? (fallbackChildren = createWorkInProgress(
currentFallbackChildFragment,
@@ -4780,11 +5247,11 @@ function updateSuspenseFallbackChildren(
workInProgress.child = primaryChildren;
return fallbackChildren;
}
-function scheduleWorkOnFiber(fiber, renderLanes) {
+function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) {
fiber.lanes |= renderLanes;
var alternate = fiber.alternate;
null !== alternate && (alternate.lanes |= renderLanes);
- scheduleWorkOnParentPath(fiber.return, renderLanes);
+ scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot);
}
function initSuspenseListRenderState(
workInProgress,
@@ -4823,8 +5290,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) {
a: for (current = workInProgress.child; null !== current; ) {
if (13 === current.tag)
null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderLanes);
- else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
+ else if (19 === current.tag)
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
else if (null !== current.child) {
current.child.return = current;
current = current.child;
@@ -4917,427 +5385,103 @@ function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
}
return workInProgress.child;
}
-var appendAllChildren,
- updateHostContainer,
- updateHostComponent$1,
- updateHostText$1;
-appendAllChildren = function(parent, workInProgress) {
- for (var node = workInProgress.child; null !== node; ) {
- if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode);
- else if (4 !== node.tag && null !== node.child) {
- node.child.return = node;
- node = node.child;
- continue;
- }
- if (node === workInProgress) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === workInProgress) return;
- node = node.return;
- }
- node.sibling.return = node.return;
- node = node.sibling;
- }
-};
-updateHostContainer = function() {};
-updateHostComponent$1 = function(current, workInProgress, type, newProps) {
- current.memoizedProps !== newProps &&
- (requiredContext(contextStackCursor$1.current),
- (workInProgress.updateQueue = UPDATE_SIGNAL)) &&
- (workInProgress.flags |= 4);
-};
-updateHostText$1 = function(current, workInProgress, oldText, newText) {
- oldText !== newText && (workInProgress.flags |= 4);
-};
-function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
- switch (renderState.tailMode) {
- case "hidden":
- hasRenderedATailFallback = renderState.tail;
- for (var lastTailNode = null; null !== hasRenderedATailFallback; )
- null !== hasRenderedATailFallback.alternate &&
- (lastTailNode = hasRenderedATailFallback),
- (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
- null === lastTailNode
- ? (renderState.tail = null)
- : (lastTailNode.sibling = null);
- break;
- case "collapsed":
- lastTailNode = renderState.tail;
- for (var lastTailNode$69 = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (lastTailNode$69 = lastTailNode),
- (lastTailNode = lastTailNode.sibling);
- null === lastTailNode$69
- ? hasRenderedATailFallback || null === renderState.tail
- ? (renderState.tail = null)
- : (renderState.tail.sibling = null)
- : (lastTailNode$69.sibling = null);
- }
-}
-function bubbleProperties(completedWork) {
- var didBailout =
- null !== completedWork.alternate &&
- completedWork.alternate.child === completedWork.child,
- newChildLanes = 0,
- subtreeFlags = 0;
- if (didBailout)
- for (var child$70 = completedWork.child; null !== child$70; )
- (newChildLanes |= child$70.lanes | child$70.childLanes),
- (subtreeFlags |= child$70.subtreeFlags & 1835008),
- (subtreeFlags |= child$70.flags & 1835008),
- (child$70.return = completedWork),
- (child$70 = child$70.sibling);
- else
- for (child$70 = completedWork.child; null !== child$70; )
- (newChildLanes |= child$70.lanes | child$70.childLanes),
- (subtreeFlags |= child$70.subtreeFlags),
- (subtreeFlags |= child$70.flags),
- (child$70.return = completedWork),
- (child$70 = child$70.sibling);
- completedWork.subtreeFlags |= subtreeFlags;
- completedWork.childLanes = newChildLanes;
- return didBailout;
-}
-function completeWork(current, workInProgress, renderLanes) {
- var newProps = workInProgress.pendingProps;
+function attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+) {
switch (workInProgress.tag) {
- case 2:
- case 16:
- case 15:
- case 0:
- case 11:
- case 7:
- case 8:
- case 12:
- case 9:
- case 14:
- return bubbleProperties(workInProgress), null;
- case 1:
- return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
- );
case 3:
- return (
- (newProps = workInProgress.stateNode),
- popHostContainer(),
- pop(didPerformWorkStackCursor),
- pop(contextStackCursor),
- resetWorkInProgressVersions(),
- newProps.pendingContext &&
- ((newProps.context = newProps.pendingContext),
- (newProps.pendingContext = null)),
- (null !== current && null !== current.child) ||
- newProps.hydrate ||
- (workInProgress.flags |= 512),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
+ pushHostRootContext(workInProgress);
+ break;
case 5:
- popHostContext(workInProgress);
- renderLanes = requiredContext(rootInstanceStackCursor.current);
- var type = workInProgress.type;
- if (null !== current && null != workInProgress.stateNode)
- updateHostComponent$1(
+ pushHostContext(workInProgress);
+ break;
+ case 1:
+ isContextProvider(workInProgress.type) &&
+ pushContextProvider(workInProgress);
+ break;
+ case 4:
+ pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
+ break;
+ case 10:
+ var context = workInProgress.type._context,
+ nextValue = workInProgress.memoizedProps.value;
+ push(valueCursor, context._currentValue);
+ context._currentValue = nextValue;
+ break;
+ case 13:
+ if (null !== workInProgress.memoizedState) {
+ if (0 !== (renderLanes & workInProgress.child.childLanes))
+ return updateSuspenseComponent(current, workInProgress, renderLanes);
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ current = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- type,
- newProps,
renderLanes
- ),
- current.ref !== workInProgress.ref && (workInProgress.flags |= 256);
- else {
- if (!newProps) {
- if (null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- bubbleProperties(workInProgress);
- return null;
- }
- requiredContext(contextStackCursor$1.current);
- current = allocateTag();
- type = getViewConfigForType(type);
- var updatePayload = diffProperties(
- null,
- emptyObject,
- newProps,
- type.validAttributes
- );
- ReactNativePrivateInterface.UIManager.createView(
- current,
- type.uiViewClassName,
- renderLanes,
- updatePayload
- );
- renderLanes = new ReactNativeFiberHostComponent(
- current,
- type,
- workInProgress
- );
- instanceCache.set(current, workInProgress);
- instanceProps.set(current, newProps);
- appendAllChildren(renderLanes, workInProgress, !1, !1);
- workInProgress.stateNode = renderLanes;
- finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4);
- null !== workInProgress.ref && (workInProgress.flags |= 256);
- }
- bubbleProperties(workInProgress);
- return null;
- case 6:
- if (current && null != workInProgress.stateNode)
- updateHostText$1(
- current,
- workInProgress,
- current.memoizedProps,
- newProps
- );
- else {
- if ("string" !== typeof newProps && null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- current = requiredContext(rootInstanceStackCursor.current);
- if (!requiredContext(contextStackCursor$1.current).isInAParentText)
- throw Error(
- "Text strings must be rendered within a component."
- );
- renderLanes = allocateTag();
- ReactNativePrivateInterface.UIManager.createView(
- renderLanes,
- "RCTRawText",
- current,
- { text: newProps }
);
- instanceCache.set(renderLanes, workInProgress);
- workInProgress.stateNode = renderLanes;
+ return null !== current ? current.sibling : null;
}
- bubbleProperties(workInProgress);
- return null;
- case 13:
- pop(suspenseStackCursor);
- newProps = workInProgress.memoizedState;
- if (0 !== (workInProgress.flags & 128))
- return (workInProgress.lanes = renderLanes), workInProgress;
- newProps = null !== newProps;
- renderLanes = !1;
- null !== current && (renderLanes = null !== current.memoizedState);
- if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1))
- if (
- (null === current &&
- !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
- 0 !== (suspenseStackCursor.current & 1)
- )
- 0 === workInProgressRootExitStatus &&
- (workInProgressRootExitStatus = 3);
- else {
- if (
- 0 === workInProgressRootExitStatus ||
- 3 === workInProgressRootExitStatus
- )
- workInProgressRootExitStatus = 4;
- null === workInProgressRoot ||
- (0 === (workInProgressRootSkippedLanes & 268435455) &&
- 0 === (workInProgressRootUpdatedLanes & 268435455)) ||
- markRootSuspended$1(
- workInProgressRoot,
- workInProgressRootRenderLanes
- );
- }
- if (newProps || renderLanes) workInProgress.flags |= 4;
- bubbleProperties(workInProgress);
- return null;
- case 4:
- return (
- popHostContainer(),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
- case 10:
- return (
- popProvider(workInProgress.type._context),
- bubbleProperties(workInProgress),
- null
- );
- case 17:
- return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
- );
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
case 19:
- pop(suspenseStackCursor);
- type = workInProgress.memoizedState;
- if (null === type) return bubbleProperties(workInProgress), null;
- newProps = 0 !== (workInProgress.flags & 128);
- updatePayload = type.rendering;
- if (null === updatePayload)
- if (newProps) cutOffTailIfNeeded(type, !1);
- else {
- if (
- 0 !== workInProgressRootExitStatus ||
- (null !== current && 0 !== (current.flags & 128))
- )
- for (current = workInProgress.child; null !== current; ) {
- updatePayload = findFirstSuspended(current);
- if (null !== updatePayload) {
- workInProgress.flags |= 128;
- cutOffTailIfNeeded(type, !1);
- current = updatePayload.updateQueue;
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4));
- workInProgress.subtreeFlags = 0;
- current = renderLanes;
- for (newProps = workInProgress.child; null !== newProps; )
- (renderLanes = newProps),
- (type = current),
- (renderLanes.flags &= 1835010),
- (updatePayload = renderLanes.alternate),
- null === updatePayload
- ? ((renderLanes.childLanes = 0),
- (renderLanes.lanes = type),
- (renderLanes.child = null),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.memoizedProps = null),
- (renderLanes.memoizedState = null),
- (renderLanes.updateQueue = null),
- (renderLanes.dependencies = null),
- (renderLanes.stateNode = null))
- : ((renderLanes.childLanes = updatePayload.childLanes),
- (renderLanes.lanes = updatePayload.lanes),
- (renderLanes.child = updatePayload.child),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.deletions = null),
- (renderLanes.memoizedProps =
- updatePayload.memoizedProps),
- (renderLanes.memoizedState =
- updatePayload.memoizedState),
- (renderLanes.updateQueue = updatePayload.updateQueue),
- (renderLanes.type = updatePayload.type),
- (type = updatePayload.dependencies),
- (renderLanes.dependencies =
- null === type
- ? null
- : {
- lanes: type.lanes,
- firstContext: type.firstContext
- })),
- (newProps = newProps.sibling);
- push(
- suspenseStackCursor,
- (suspenseStackCursor.current & 1) | 2
- );
- return workInProgress.child;
- }
- current = current.sibling;
- }
- null !== type.tail &&
- now() > workInProgressRootRenderTargetTime &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
- }
- else {
- if (!newProps)
- if (
- ((current = findFirstSuspended(updatePayload)), null !== current)
- ) {
- if (
- ((workInProgress.flags |= 128),
- (newProps = !0),
- (current = current.updateQueue),
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4)),
- cutOffTailIfNeeded(type, !0),
- null === type.tail &&
- "hidden" === type.tailMode &&
- !updatePayload.alternate)
- )
- return bubbleProperties(workInProgress), null;
- } else
- 2 * now() - type.renderingStartTime >
- workInProgressRootRenderTargetTime &&
- 1073741824 !== renderLanes &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
- type.isBackwards
- ? ((updatePayload.sibling = workInProgress.child),
- (workInProgress.child = updatePayload))
- : ((current = type.last),
- null !== current
- ? (current.sibling = updatePayload)
- : (workInProgress.child = updatePayload),
- (type.last = updatePayload));
+ context = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.flags & 128)) {
+ if (context)
+ return updateSuspenseListComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ workInProgress.flags |= 128;
}
- if (null !== type.tail)
- return (
- (workInProgress = type.tail),
- (type.rendering = workInProgress),
- (type.tail = workInProgress.sibling),
- (type.renderingStartTime = now()),
- (workInProgress.sibling = null),
- (current = suspenseStackCursor.current),
- push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
- workInProgress
- );
- bubbleProperties(workInProgress);
- return null;
+ nextValue = workInProgress.memoizedState;
+ null !== nextValue &&
+ ((nextValue.rendering = null),
+ (nextValue.tail = null),
+ (nextValue.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (context) break;
+ else return null;
case 22:
case 23:
return (
- popRenderLanes(),
- (renderLanes = null !== workInProgress.memoizedState),
- null !== current &&
- (null !== current.memoizedState) !== renderLanes &&
- "unstable-defer-without-hiding" !== newProps.mode &&
- (workInProgress.flags |= 4),
- (renderLanes &&
- 0 === (subtreeRenderLanes & 1073741824) &&
- 0 !== (workInProgress.mode & 1)) ||
- bubbleProperties(workInProgress),
- null
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
);
}
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
-function unwindWork(workInProgress) {
+function unwindWork(current, workInProgress) {
+ popTreeContext(workInProgress);
switch (workInProgress.tag) {
case 1:
- isContextProvider(workInProgress.type) && popContext();
- var flags = workInProgress.flags;
- return flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress)
- : null;
- case 3:
- popHostContainer();
- pop(didPerformWorkStackCursor);
- pop(contextStackCursor);
- resetWorkInProgressVersions();
- flags = workInProgress.flags;
- if (0 !== (flags & 128))
- throw Error(
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
- );
- workInProgress.flags = (flags & -16385) | 128;
- return workInProgress;
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
+ : null
+ );
+ case 3:
+ return (
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ (current = workInProgress.flags),
+ 0 !== (current & 65536) && 0 === (current & 128)
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
+ : null
+ );
case 5:
return popHostContext(workInProgress), null;
case 13:
return (
pop(suspenseStackCursor),
- (flags = workInProgress.flags),
- flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress)
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
: null
);
case 19:
@@ -5368,13 +5512,20 @@ function safelyDetachRef(current, nearestMountedAncestor) {
}
else ref.current = null;
}
+function safelyCallDestroy(current, nearestMountedAncestor, destroy) {
+ try {
+ destroy();
+ } catch (error) {
+ captureCommitPhaseError(current, nearestMountedAncestor, error);
+ }
+}
var shouldFireAfterActiveInstanceBlur = !1;
function commitBeforeMutationEffects(root, firstChild) {
for (nextEffect = firstChild; null !== nextEffect; )
if (
((root = nextEffect),
(firstChild = root.child),
- 0 !== (root.subtreeFlags & 516) && null !== firstChild)
+ 0 !== (root.subtreeFlags & 1028) && null !== firstChild)
)
(firstChild.return = root), (nextEffect = firstChild);
else
@@ -5382,7 +5533,7 @@ function commitBeforeMutationEffects(root, firstChild) {
root = nextEffect;
try {
var current = root.alternate;
- if (0 !== (root.flags & 512))
+ if (0 !== (root.flags & 1024))
switch (root.tag) {
case 0:
case 11:
@@ -5432,7 +5583,7 @@ function commitBeforeMutationEffects(root, firstChild) {
function commitHookEffectListUnmount(
flags,
finishedWork,
- nearestMountedAncestor$jscomp$0
+ nearestMountedAncestor
) {
var updateQueue = finishedWork.updateQueue;
updateQueue = null !== updateQueue ? updateQueue.lastEffect : null;
@@ -5442,97 +5593,28 @@ function commitHookEffectListUnmount(
if ((effect.tag & flags) === flags) {
var destroy = effect.destroy;
effect.destroy = void 0;
- if (void 0 !== destroy) {
- var current = finishedWork,
- nearestMountedAncestor = nearestMountedAncestor$jscomp$0;
- try {
- destroy();
- } catch (error) {
- captureCommitPhaseError(current, nearestMountedAncestor, error);
- }
- }
+ void 0 !== destroy &&
+ safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy);
}
effect = effect.next;
} while (effect !== updateQueue);
}
}
-function commitHookEffectListMount(tag, finishedWork) {
+function commitHookEffectListMount(flags, 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$82 = effect.create;
- effect.destroy = create$82();
+ if ((effect.tag & flags) === flags) {
+ var create$77 = effect.create;
+ effect.destroy = create$77();
}
effect = effect.next;
} while (effect !== finishedWork);
}
}
-function hideOrUnhideAllChildren(finishedWork, isHidden) {
- for (var hostSubtreeRoot = null, node = finishedWork; ; ) {
- if (5 === node.tag) {
- if (null === hostSubtreeRoot) {
- hostSubtreeRoot = node;
- 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) {
- if (null === hostSubtreeRoot) throw Error("Not yet implemented.");
- } else if (
- ((22 !== node.tag && 23 !== 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;
- hostSubtreeRoot === node && (hostSubtreeRoot = null);
- node = node.return;
- }
- hostSubtreeRoot === node && (hostSubtreeRoot = null);
- node.sibling.return = node.return;
- node = node.sibling;
- }
-}
-function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) {
+function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount)
try {
injectedHook.onCommitFiberUnmount(rendererID, current);
@@ -5552,44 +5634,32 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) {
var _effect = effect,
destroy = _effect.destroy;
_effect = _effect.tag;
- if (void 0 !== destroy && 0 !== (_effect & 2)) {
- _effect = current;
- var nearestMountedAncestor = nearestMountedAncestor$jscomp$0;
- try {
- destroy();
- } catch (error) {
- captureCommitPhaseError(_effect, nearestMountedAncestor, error);
- }
- }
+ void 0 !== destroy &&
+ (0 !== (_effect & 2)
+ ? safelyCallDestroy(current, nearestMountedAncestor, destroy)
+ : 0 !== (_effect & 4) &&
+ safelyCallDestroy(current, nearestMountedAncestor, destroy));
effect = effect.next;
} while (effect !== finishedRoot);
}
break;
case 1:
- safelyDetachRef(current, nearestMountedAncestor$jscomp$0);
+ safelyDetachRef(current, nearestMountedAncestor);
finishedRoot = current.stateNode;
if ("function" === typeof finishedRoot.componentWillUnmount)
try {
(finishedRoot.props = current.memoizedProps),
(finishedRoot.state = current.memoizedState),
finishedRoot.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(
- current,
- nearestMountedAncestor$jscomp$0,
- unmountError
- );
+ } catch (error) {
+ captureCommitPhaseError(current, nearestMountedAncestor, error);
}
break;
case 5:
- safelyDetachRef(current, nearestMountedAncestor$jscomp$0);
+ safelyDetachRef(current, nearestMountedAncestor);
break;
case 4:
- unmountHostComponents(
- finishedRoot,
- current,
- nearestMountedAncestor$jscomp$0
- );
+ unmountHostComponents(finishedRoot, current, nearestMountedAncestor);
}
}
function detachFiberAfterEffects(fiber) {
@@ -5611,6 +5681,25 @@ function detachFiberAfterEffects(fiber) {
function isHostParent(fiber) {
return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag;
}
+function getHostSibling(fiber) {
+ a: for (;;) {
+ for (; null === fiber.sibling; ) {
+ if (null === fiber.return || isHostParent(fiber.return)) return null;
+ fiber = fiber.return;
+ }
+ fiber.sibling.return = fiber.return;
+ for (
+ fiber = fiber.sibling;
+ 5 !== fiber.tag && 6 !== fiber.tag && 18 !== fiber.tag;
+
+ ) {
+ if (fiber.flags & 2) continue a;
+ if (null === fiber.child || 4 === fiber.tag) continue a;
+ else (fiber.child.return = fiber), (fiber = fiber.child);
+ }
+ if (!(fiber.flags & 2)) return fiber.stateNode;
+ }
+}
function commitPlacement(finishedWork) {
a: {
for (var parent = finishedWork.return; null !== parent; ) {
@@ -5622,57 +5711,28 @@ function commitPlacement(finishedWork) {
);
}
var parentFiber = parent;
- parent = parentFiber.stateNode;
switch (parentFiber.tag) {
case 5:
- var isContainer = !1;
+ parent = parentFiber.stateNode;
+ parentFiber.flags & 32 && (parentFiber.flags &= -33);
+ parentFiber = getHostSibling(finishedWork);
+ insertOrAppendPlacementNode(finishedWork, parentFiber, parent);
break;
case 3:
- parent = parent.containerInfo;
- isContainer = !0;
- break;
case 4:
- parent = parent.containerInfo;
- isContainer = !0;
+ parent = parentFiber.stateNode.containerInfo;
+ parentFiber = getHostSibling(finishedWork);
+ insertOrAppendPlacementNodeIntoContainer(
+ finishedWork,
+ parentFiber,
+ parent
+ );
break;
default:
throw Error(
"Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue."
);
}
- parentFiber.flags & 32 && (parentFiber.flags &= -33);
- a: b: for (parentFiber = finishedWork; ; ) {
- for (; null === parentFiber.sibling; ) {
- if (null === parentFiber.return || isHostParent(parentFiber.return)) {
- parentFiber = null;
- break a;
- }
- parentFiber = parentFiber.return;
- }
- parentFiber.sibling.return = parentFiber.return;
- for (
- parentFiber = parentFiber.sibling;
- 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag;
-
- ) {
- if (parentFiber.flags & 2) continue b;
- if (null === parentFiber.child || 4 === parentFiber.tag) continue b;
- else
- (parentFiber.child.return = parentFiber),
- (parentFiber = parentFiber.child);
- }
- if (!(parentFiber.flags & 2)) {
- parentFiber = parentFiber.stateNode;
- break a;
- }
- }
- isContainer
- ? insertOrAppendPlacementNodeIntoContainer(
- finishedWork,
- parentFiber,
- parent
- )
- : insertOrAppendPlacementNode(finishedWork, parentFiber, parent);
}
function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
var tag = node.tag;
@@ -5879,6 +5939,8 @@ function commitWork(current, finishedWork) {
case 14:
case 15:
commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ commitHookEffectListMount(3, finishedWork);
+ commitHookEffectListUnmount(5, finishedWork, finishedWork.return);
return;
case 1:
return;
@@ -5922,9 +5984,6 @@ function commitWork(current, finishedWork) {
case 12:
return;
case 13:
- null !== finishedWork.memoizedState &&
- ((globalMostRecentFallbackTime = now()),
- hideOrUnhideAllChildren(finishedWork.child, !0));
attachSuspenseRetryListeners(finishedWork);
return;
case 19:
@@ -5932,13 +5991,6 @@ function commitWork(current, finishedWork) {
return;
case 17:
return;
- case 22:
- case 23:
- 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."
@@ -5975,14 +6027,14 @@ function commitMutationEffects(root, firstChild) {
}
}
deletions = firstChild.child;
- if (0 !== (firstChild.subtreeFlags & 6454) && null !== deletions)
+ if (0 !== (firstChild.subtreeFlags & 12854) && null !== deletions)
(deletions.return = firstChild), (nextEffect = deletions);
else
for (; null !== nextEffect; ) {
firstChild = nextEffect;
try {
var flags = firstChild.flags;
- if (flags & 256) {
+ if (flags & 512) {
var current = firstChild.alternate;
if (null !== current) {
var currentRef = current.ref;
@@ -5992,7 +6044,88 @@ function commitMutationEffects(root, firstChild) {
: (currentRef.current = null));
}
}
- switch (flags & 2054) {
+ if (flags & 8192)
+ switch (firstChild.tag) {
+ case 13:
+ if (null !== firstChild.memoizedState) {
+ var current$84 = firstChild.alternate;
+ if (null === current$84 || null === current$84.memoizedState)
+ globalMostRecentFallbackTime = now();
+ }
+ break;
+ case 22:
+ a: {
+ deletions = firstChild;
+ var isHidden = null !== firstChild.memoizedState;
+ i = null;
+ for (childToDelete = deletions; ; ) {
+ if (5 === childToDelete.tag) {
+ if (null === i) {
+ i = childToDelete;
+ var instance = childToDelete.stateNode;
+ if (isHidden) {
+ var instance$jscomp$0 = instance,
+ viewConfig = instance$jscomp$0.viewConfig;
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ { style: { display: "none" } },
+ viewConfig.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance$jscomp$0._nativeTag,
+ viewConfig.uiViewClassName,
+ updatePayload
+ );
+ } else {
+ var instance$jscomp$1 = childToDelete.stateNode,
+ props = childToDelete.memoizedProps,
+ viewConfig$jscomp$0 = instance$jscomp$1.viewConfig,
+ prevProps = assign({}, props, {
+ style: [props.style, { display: "none" }]
+ });
+ var updatePayload$jscomp$0 = diffProperties(
+ null,
+ prevProps,
+ props,
+ viewConfig$jscomp$0.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance$jscomp$1._nativeTag,
+ viewConfig$jscomp$0.uiViewClassName,
+ updatePayload$jscomp$0
+ );
+ }
+ }
+ } else if (6 === childToDelete.tag) {
+ if (null === i) throw Error("Not yet implemented.");
+ } else if (
+ ((22 !== childToDelete.tag && 23 !== childToDelete.tag) ||
+ null === childToDelete.memoizedState ||
+ childToDelete === deletions) &&
+ null !== childToDelete.child
+ ) {
+ childToDelete.child.return = childToDelete;
+ childToDelete = childToDelete.child;
+ continue;
+ }
+ if (childToDelete === deletions) break;
+ for (; null === childToDelete.sibling; ) {
+ if (
+ null === childToDelete.return ||
+ childToDelete.return === deletions
+ )
+ break a;
+ i === childToDelete && (i = null);
+ childToDelete = childToDelete.return;
+ }
+ i === childToDelete && (i = null);
+ childToDelete.sibling.return = childToDelete.return;
+ childToDelete = childToDelete.sibling;
+ }
+ }
+ }
+ switch (flags & 4102) {
case 2:
commitPlacement(firstChild);
firstChild.flags &= -3;
@@ -6002,11 +6135,11 @@ function commitMutationEffects(root, firstChild) {
firstChild.flags &= -3;
commitWork(firstChild.alternate, firstChild);
break;
- case 2048:
- firstChild.flags &= -2049;
+ case 4096:
+ firstChild.flags &= -4097;
break;
- case 2052:
- firstChild.flags &= -2049;
+ case 4100:
+ firstChild.flags &= -4097;
commitWork(firstChild.alternate, firstChild);
break;
case 4:
@@ -6029,20 +6162,20 @@ function commitLayoutEffects(finishedWork) {
for (nextEffect = finishedWork; null !== nextEffect; ) {
var fiber = nextEffect,
firstChild = fiber.child;
- if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild)
+ if (0 !== (fiber.subtreeFlags & 8772) && null !== firstChild)
(firstChild.return = fiber), (nextEffect = firstChild);
else
for (fiber = finishedWork; null !== nextEffect; ) {
firstChild = nextEffect;
- if (0 !== (firstChild.flags & 324)) {
+ if (0 !== (firstChild.flags & 8772)) {
var current = firstChild.alternate;
try {
- if (0 !== (firstChild.flags & 68))
+ if (0 !== (firstChild.flags & 8772))
switch (firstChild.tag) {
case 0:
case 11:
case 15:
- commitHookEffectListMount(3, firstChild);
+ commitHookEffectListMount(5, firstChild);
break;
case 1:
var instance = firstChild.stateNode;
@@ -6067,8 +6200,8 @@ function commitLayoutEffects(finishedWork) {
commitUpdateQueue(firstChild, updateQueue, instance);
break;
case 3:
- var updateQueue$83 = firstChild.updateQueue;
- if (null !== updateQueue$83) {
+ var updateQueue$78 = firstChild.updateQueue;
+ if (null !== updateQueue$78) {
current = null;
if (null !== firstChild.child)
switch (firstChild.child.tag) {
@@ -6078,7 +6211,7 @@ function commitLayoutEffects(finishedWork) {
case 1:
current = firstChild.child.stateNode;
}
- commitUpdateQueue(firstChild, updateQueue$83, current);
+ commitUpdateQueue(firstChild, updateQueue$78, current);
}
break;
case 5:
@@ -6102,7 +6235,7 @@ function commitLayoutEffects(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."
);
}
- if (firstChild.flags & 256) {
+ if (firstChild.flags & 512) {
current = void 0;
var ref = firstChild.ref;
if (null !== ref) {
@@ -6150,8 +6283,10 @@ var ceil = Math.ceil,
workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
workInProgressRootSkippedLanes = 0,
- workInProgressRootUpdatedLanes = 0,
+ workInProgressRootInterleavedUpdatedLanes = 0,
workInProgressRootPingedLanes = 0,
+ workInProgressRootConcurrentErrors = null,
+ workInProgressRootRecoverableErrors = null,
globalMostRecentFallbackTime = 0,
workInProgressRootRenderTargetTime = Infinity,
hasUncaughtError = !1,
@@ -6165,7 +6300,7 @@ var ceil = Math.ceil,
currentEventTime = -1,
currentEventTransitionLane = 0;
function requestEventTime() {
- return 0 !== (executionContext & 24)
+ return 0 !== (executionContext & 6)
? now()
: -1 !== currentEventTime
? currentEventTime
@@ -6173,9 +6308,9 @@ function requestEventTime() {
}
function requestUpdateLane(fiber) {
if (0 === (fiber.mode & 1)) return 1;
- if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes)
+ if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes)
return workInProgressRootRenderLanes & -workInProgressRootRenderLanes;
- if (0 !== ReactCurrentBatchConfig.transition)
+ if (null !== ReactCurrentBatchConfig.transition)
return (
0 === currentEventTransitionLane &&
((fiber = nextTransitionLane),
@@ -6197,19 +6332,18 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) {
var root = markUpdateLaneFromFiberToRoot(fiber, lane);
if (null === root) return null;
markRootUpdated(root, lane, eventTime);
- root === workInProgressRoot &&
- (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane),
- 4 === workInProgressRootExitStatus &&
- markRootSuspended$1(root, workInProgressRootRenderLanes));
- 1 === lane
- ? 0 !== (executionContext & 4) && 0 === (executionContext & 24)
- ? performSyncWorkOnRoot(root)
- : (ensureRootIsScheduled(root, eventTime),
+ if (0 === (executionContext & 2) || root !== workInProgressRoot)
+ root === workInProgressRoot &&
+ (0 === (executionContext & 2) &&
+ (workInProgressRootInterleavedUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(root, workInProgressRootRenderLanes)),
+ ensureRootIsScheduled(root, eventTime),
+ 1 === lane &&
0 === executionContext &&
- 0 === (fiber.mode & 1) &&
- ((workInProgressRootRenderTargetTime = now() + 500),
- includesLegacySyncCallbacks && flushSyncCallbacks()))
- : ensureRootIsScheduled(root, eventTime);
+ 0 === (fiber.mode & 1) &&
+ ((workInProgressRootRenderTargetTime = now() + 500),
+ includesLegacySyncCallbacks && flushSyncCallbacks());
return root;
}
function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
@@ -6287,7 +6421,7 @@ function ensureRootIsScheduled(root, currentTime) {
default:
existingCallbackNode = NormalPriority;
}
- existingCallbackNode = scheduleCallback(
+ existingCallbackNode = scheduleCallback$1(
existingCallbackNode,
performConcurrentWorkOnRoot.bind(null, root)
);
@@ -6299,7 +6433,7 @@ function ensureRootIsScheduled(root, currentTime) {
function performConcurrentWorkOnRoot(root, didTimeout) {
currentEventTime = -1;
currentEventTransitionLane = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var originalCallbackNode = root.callbackNode;
if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
@@ -6309,12 +6443,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
root === workInProgressRoot ? workInProgressRootRenderLanes : 0
);
if (0 === lanes) return null;
- var JSCompiler_inline_result =
- 0 !== (lanes & root.expiredLanes) ? !1 : 0 === (lanes & 30);
- if (JSCompiler_inline_result && !didTimeout) {
+ if (0 !== (lanes & 30) || 0 !== (lanes & root.expiredLanes) || didTimeout)
+ didTimeout = renderRootSync(root, lanes);
+ else {
didTimeout = lanes;
- JSCompiler_inline_result = executionContext;
- executionContext |= 8;
+ var prevExecutionContext = executionContext;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
if (
workInProgressRoot !== root ||
@@ -6332,100 +6466,117 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
while (1);
resetContextDependencies();
ReactCurrentDispatcher$2.current = prevDispatcher;
- executionContext = JSCompiler_inline_result;
+ executionContext = prevExecutionContext;
null !== workInProgress
? (didTimeout = 0)
: ((workInProgressRoot = null),
(workInProgressRootRenderLanes = 0),
(didTimeout = workInProgressRootExitStatus));
- } else didTimeout = renderRootSync(root, lanes);
+ }
if (0 !== didTimeout) {
2 === didTimeout &&
- ((executionContext |= 32),
- root.hydrate && (root.hydrate = !1),
- (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)),
- 0 !== JSCompiler_inline_result &&
- ((lanes = JSCompiler_inline_result),
- (didTimeout = renderRootSync(root, JSCompiler_inline_result))));
+ ((prevExecutionContext = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevExecutionContext &&
+ ((lanes = prevExecutionContext),
+ (didTimeout = recoverFromConcurrentError(root, prevExecutionContext))));
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 2:
- commitRoot(root);
- break;
- case 3:
- markRootSuspended$1(root, lanes);
- if (
- (lanes & 130023424) === lanes &&
- ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
- 10 < didTimeout)
- ) {
- if (0 !== getNextLanes(root, 0)) break;
- JSCompiler_inline_result = root.suspendedLanes;
- if ((JSCompiler_inline_result & lanes) !== lanes) {
- requestEventTime();
- root.pingedLanes |= root.suspendedLanes & JSCompiler_inline_result;
+ if (6 === didTimeout) markRootSuspended$1(root, lanes);
+ else {
+ prevExecutionContext = root.current.alternate;
+ if (
+ 0 === (lanes & 30) &&
+ !isRenderConsistentWithExternalStores(prevExecutionContext) &&
+ ((didTimeout = renderRootSync(root, lanes)),
+ 2 === didTimeout &&
+ ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevDispatcher &&
+ ((lanes = prevDispatcher),
+ (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))),
+ 1 === didTimeout)
+ )
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = prevExecutionContext;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
+ throw Error("Root did not complete. This is a bug in React.");
+ case 2:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ case 3:
+ markRootSuspended$1(root, lanes);
+ if (
+ (lanes & 130023424) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
+ ) {
+ 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, workInProgressRootRecoverableErrors),
+ didTimeout
+ );
break;
}
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- didTimeout
- );
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 4:
- markRootSuspended$1(root, lanes);
- if ((lanes & 4194240) === lanes) break;
- didTimeout = root.eventTimes;
- for (JSCompiler_inline_result = -1; 0 < lanes; ) {
- var index$5 = 31 - clz32(lanes);
- prevDispatcher = 1 << index$5;
- index$5 = didTimeout[index$5];
- index$5 > JSCompiler_inline_result &&
- (JSCompiler_inline_result = index$5);
- lanes &= ~prevDispatcher;
- }
- lanes = JSCompiler_inline_result;
- lanes = now() - lanes;
- lanes =
- (120 > lanes
- ? 120
- : 480 > lanes
- ? 480
- : 1080 > lanes
- ? 1080
- : 1920 > lanes
- ? 1920
- : 3e3 > lanes
- ? 3e3
- : 4320 > lanes
- ? 4320
- : 1960 * ceil(lanes / 1960)) - lanes;
- if (10 < lanes) {
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- lanes
- );
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if ((lanes & 4194240) === lanes) break;
+ didTimeout = root.eventTimes;
+ for (prevExecutionContext = -1; 0 < lanes; ) {
+ var index$5 = 31 - clz32(lanes);
+ prevDispatcher = 1 << index$5;
+ index$5 = didTimeout[index$5];
+ index$5 > prevExecutionContext && (prevExecutionContext = index$5);
+ lanes &= ~prevDispatcher;
+ }
+ lanes = prevExecutionContext;
+ lanes = now() - lanes;
+ lanes =
+ (120 > lanes
+ ? 120
+ : 480 > lanes
+ ? 480
+ : 1080 > lanes
+ ? 1080
+ : 1920 > lanes
+ ? 1920
+ : 3e3 > lanes
+ ? 3e3
+ : 4320 > lanes
+ ? 4320
+ : 1960 * ceil(lanes / 1960)) - lanes;
+ if (10 < lanes) {
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
+ lanes
+ );
+ break;
+ }
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 5:
- commitRoot(root);
- break;
- default:
- throw Error("Unknown root exit status.");
+ case 5:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ default:
+ throw Error("Unknown root exit status.");
+ }
}
}
ensureRootIsScheduled(root, now());
@@ -6433,9 +6584,60 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function recoverFromConcurrentError(root, errorRetryLanes) {
+ var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
+ root.current.memoizedState.isDehydrated &&
+ (prepareFreshStack(root, errorRetryLanes).flags |= 256);
+ root = renderRootSync(root, errorRetryLanes);
+ 2 !== root &&
+ ((errorRetryLanes = workInProgressRootRecoverableErrors),
+ (workInProgressRootRecoverableErrors = errorsFromFirstAttempt),
+ null !== errorRetryLanes &&
+ (null === workInProgressRootRecoverableErrors
+ ? (workInProgressRootRecoverableErrors = errorRetryLanes)
+ : workInProgressRootRecoverableErrors.push.apply(
+ workInProgressRootRecoverableErrors,
+ errorRetryLanes
+ )));
+ return root;
+}
+function isRenderConsistentWithExternalStores(finishedWork) {
+ for (var node = finishedWork; ; ) {
+ if (node.flags & 16384) {
+ var updateQueue = node.updateQueue;
+ if (
+ null !== updateQueue &&
+ ((updateQueue = updateQueue.stores), null !== updateQueue)
+ )
+ for (var i = 0; i < updateQueue.length; i++) {
+ var check = updateQueue[i],
+ getSnapshot = check.getSnapshot;
+ check = check.value;
+ try {
+ if (!objectIs(getSnapshot(), check)) return !1;
+ } catch (error) {
+ return !1;
+ }
+ }
+ }
+ updateQueue = node.child;
+ if (node.subtreeFlags & 16384 && null !== updateQueue)
+ (updateQueue.return = node), (node = updateQueue);
+ else {
+ if (node === finishedWork) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === finishedWork) return !0;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+ }
+ return !0;
+}
function markRootSuspended$1(root, suspendedLanes) {
suspendedLanes &= ~workInProgressRootPingedLanes;
- suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes;
root.suspendedLanes |= suspendedLanes;
root.pingedLanes &= ~suspendedLanes;
for (root = root.expirationTimes; 0 < suspendedLanes; ) {
@@ -6446,18 +6648,17 @@ function markRootSuspended$1(root, suspendedLanes) {
}
}
function performSyncWorkOnRoot(root) {
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
flushPassiveEffects();
var lanes = getNextLanes(root, 0);
if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null;
var exitStatus = renderRootSync(root, lanes);
if (0 !== root.tag && 2 === exitStatus) {
- executionContext |= 32;
- root.hydrate && (root.hydrate = !1);
var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
0 !== errorRetryLanes &&
- ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes)));
+ ((lanes = errorRetryLanes),
+ (exitStatus = recoverFromConcurrentError(root, errorRetryLanes)));
}
if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
@@ -6465,9 +6666,11 @@ function performSyncWorkOnRoot(root) {
markRootSuspended$1(root, lanes),
ensureRootIsScheduled(root, now()),
exitStatus);
+ if (6 === exitStatus)
+ throw Error("Root did not complete. This is a bug in React.");
root.finishedWork = root.current.alternate;
root.finishedLanes = lanes;
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
ensureRootIsScheduled(root, now());
return null;
}
@@ -6484,6 +6687,7 @@ function prepareFreshStack(root, lanes) {
if (null !== workInProgress)
for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) {
var interruptedWork = timeoutHandle;
+ popTreeContext(interruptedWork);
switch (interruptedWork.tag) {
case 1:
interruptedWork = interruptedWork.type.childContextTypes;
@@ -6519,30 +6723,32 @@ function prepareFreshStack(root, lanes) {
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
+ workInProgress = root = createWorkInProgress(root.current, null);
workInProgressRootRenderLanes = subtreeRenderLanes = lanes;
workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootPingedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors = null;
if (null !== interleavedQueues) {
- for (root = 0; root < interleavedQueues.length; root++)
+ for (lanes = 0; lanes < interleavedQueues.length; lanes++)
if (
- ((lanes = interleavedQueues[root]),
- (timeoutHandle = lanes.interleaved),
- null !== timeoutHandle)
+ ((timeoutHandle = interleavedQueues[lanes]),
+ (interruptedWork = timeoutHandle.interleaved),
+ null !== interruptedWork)
) {
- lanes.interleaved = null;
- interruptedWork = timeoutHandle.next;
- var lastPendingUpdate = lanes.pending;
+ timeoutHandle.interleaved = null;
+ var firstInterleavedUpdate = interruptedWork.next,
+ lastPendingUpdate = timeoutHandle.pending;
if (null !== lastPendingUpdate) {
var firstPendingUpdate = lastPendingUpdate.next;
- lastPendingUpdate.next = interruptedWork;
- timeoutHandle.next = firstPendingUpdate;
+ lastPendingUpdate.next = firstInterleavedUpdate;
+ interruptedWork.next = firstPendingUpdate;
}
- lanes.pending = timeoutHandle;
+ timeoutHandle.pending = interruptedWork;
}
interleavedQueues = null;
}
+ return root;
}
function handleError(root$jscomp$0, thrownValue) {
do {
@@ -6578,61 +6784,59 @@ function handleError(root$jscomp$0, thrownValue) {
sourceFiber = erroredWork,
value = thrownValue;
thrownValue = workInProgressRootRenderLanes;
- sourceFiber.flags |= 8192;
+ sourceFiber.flags |= 32768;
if (
null !== value &&
"object" === typeof value &&
"function" === typeof value.then
) {
var wakeable = value,
- tag = sourceFiber.tag;
+ sourceFiber$jscomp$0 = sourceFiber,
+ tag = sourceFiber$jscomp$0.tag;
if (
- 0 === (sourceFiber.mode & 1) &&
+ 0 === (sourceFiber$jscomp$0.mode & 1) &&
(0 === tag || 11 === tag || 15 === tag)
) {
- var currentSource = sourceFiber.alternate;
+ var currentSource = sourceFiber$jscomp$0.alternate;
currentSource
- ? ((sourceFiber.updateQueue = currentSource.updateQueue),
- (sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.lanes = currentSource.lanes))
- : ((sourceFiber.updateQueue = null),
- (sourceFiber.memoizedState = null));
+ ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue),
+ (sourceFiber$jscomp$0.memoizedState =
+ currentSource.memoizedState),
+ (sourceFiber$jscomp$0.lanes = currentSource.lanes))
+ : ((sourceFiber$jscomp$0.updateQueue = null),
+ (sourceFiber$jscomp$0.memoizedState = null));
}
- var hasInvisibleParentBoundary =
- 0 !== (suspenseStackCursor.current & 1),
- workInProgress$32 = returnFiber;
- do {
- var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === workInProgress$32.tag)) {
- var nextState = workInProgress$32.memoizedState;
- if (null !== nextState)
- JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
- else {
- var props = workInProgress$32.memoizedProps;
+ b: {
+ sourceFiber$jscomp$0 = returnFiber;
+ do {
+ var JSCompiler_temp;
+ if ((JSCompiler_temp = 13 === sourceFiber$jscomp$0.tag)) {
+ var nextState = sourceFiber$jscomp$0.memoizedState;
JSCompiler_temp =
- void 0 === props.fallback
- ? !1
- : !0 !== props.unstable_avoidThisFallback
- ? !0
- : hasInvisibleParentBoundary
- ? !1
+ null !== nextState
+ ? null !== nextState.dehydrated
+ ? !0
+ : !1
: !0;
}
- }
- if (JSCompiler_temp) {
- var wakeables = workInProgress$32.updateQueue;
- if (null === wakeables) {
- var updateQueue = new Set();
- updateQueue.add(wakeable);
- workInProgress$32.updateQueue = updateQueue;
- } else wakeables.add(wakeable);
- if (
- 0 === (workInProgress$32.mode & 1) &&
- workInProgress$32 !== returnFiber
- ) {
- workInProgress$32.flags |= 128;
- sourceFiber.flags |= 32768;
- sourceFiber.flags &= -10053;
+ if (JSCompiler_temp) {
+ var suspenseBoundary = sourceFiber$jscomp$0;
+ break b;
+ }
+ sourceFiber$jscomp$0 = sourceFiber$jscomp$0.return;
+ } while (null !== sourceFiber$jscomp$0);
+ suspenseBoundary = null;
+ }
+ if (null !== suspenseBoundary) {
+ suspenseBoundary.flags &= -257;
+ value = suspenseBoundary;
+ sourceFiber$jscomp$0 = thrownValue;
+ if (0 === (value.mode & 1))
+ if (value === returnFiber) value.flags |= 65536;
+ else {
+ value.flags |= 128;
+ sourceFiber.flags |= 131072;
+ sourceFiber.flags &= -52805;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
@@ -6641,83 +6845,78 @@ function handleError(root$jscomp$0, thrownValue) {
enqueueUpdate(sourceFiber, update);
}
sourceFiber.lanes |= 1;
- break a;
- }
- value = void 0;
- sourceFiber = thrownValue;
- var pingCache = root.pingCache;
- null === pingCache
- ? ((pingCache = root.pingCache = new PossiblyWeakMap()),
- (value = new Set()),
- pingCache.set(wakeable, value))
- : ((value = pingCache.get(wakeable)),
- void 0 === value &&
- ((value = new Set()), pingCache.set(wakeable, value)));
- if (!value.has(sourceFiber)) {
- value.add(sourceFiber);
- var ping = pingSuspendedRoot.bind(
- null,
- root,
- wakeable,
- sourceFiber
- );
- wakeable.then(ping, ping);
}
- workInProgress$32.flags |= 16384;
- workInProgress$32.lanes = thrownValue;
+ else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0);
+ suspenseBoundary.mode & 1 &&
+ attachPingListener(root, wakeable, thrownValue);
+ thrownValue = suspenseBoundary;
+ root = wakeable;
+ var wakeables = thrownValue.updateQueue;
+ if (null === wakeables) {
+ var updateQueue = new Set();
+ updateQueue.add(root);
+ thrownValue.updateQueue = updateQueue;
+ } else wakeables.add(root);
+ break a;
+ } else {
+ if (0 === (thrownValue & 1)) {
+ attachPingListener(root, wakeable, thrownValue);
+ renderDidSuspendDelayIfPossible();
break a;
}
- workInProgress$32 = workInProgress$32.return;
- } while (null !== workInProgress$32);
- value = Error(
- (getComponentNameFromFiber(sourceFiber) || "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."
- );
+ value = Error(
+ "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition."
+ );
+ }
}
- 5 !== workInProgressRootExitStatus &&
+ root = value;
+ 4 !== workInProgressRootExitStatus &&
(workInProgressRootExitStatus = 2);
+ null === workInProgressRootConcurrentErrors
+ ? (workInProgressRootConcurrentErrors = [root])
+ : workInProgressRootConcurrentErrors.push(root);
value = createCapturedValue(value, sourceFiber);
- workInProgress$32 = returnFiber;
+ root = returnFiber;
do {
- switch (workInProgress$32.tag) {
+ switch (root.tag) {
case 3:
- root = value;
- workInProgress$32.flags |= 16384;
+ wakeable = value;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$32.lanes |= thrownValue;
- var update$33 = createRootErrorUpdate(
- workInProgress$32,
+ root.lanes |= thrownValue;
+ var update$jscomp$0 = createRootErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$32, update$33);
+ enqueueCapturedUpdate(root, update$jscomp$0);
break a;
case 1:
- root = value;
- var ctor = workInProgress$32.type,
- instance = workInProgress$32.stateNode;
+ wakeable = value;
+ var ctor = root.type,
+ instance = root.stateNode;
if (
- 0 === (workInProgress$32.flags & 128) &&
+ 0 === (root.flags & 128) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- workInProgress$32.flags |= 16384;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$32.lanes |= thrownValue;
- var update$36 = createClassErrorUpdate(
- workInProgress$32,
+ root.lanes |= thrownValue;
+ var update$33 = createClassErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$32, update$36);
+ enqueueCapturedUpdate(root, update$33);
break a;
}
}
- workInProgress$32 = workInProgress$32.return;
- } while (null !== workInProgress$32);
+ root = root.return;
+ } while (null !== root);
}
completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
@@ -6735,9 +6934,21 @@ function pushDispatcher() {
ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
+function renderDidSuspendDelayIfPossible() {
+ if (
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus ||
+ 2 === workInProgressRootExitStatus
+ )
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 268435455) &&
+ 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) ||
+ markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
+}
function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= 8;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
(workInProgressRoot === root && workInProgressRootRenderLanes === lanes) ||
prepareFreshStack(root, lanes);
@@ -6778,7 +6989,7 @@ function completeUnitOfWork(unitOfWork) {
do {
var current = completedWork.alternate;
unitOfWork = completedWork.return;
- if (0 === (completedWork.flags & 8192)) {
+ if (0 === (completedWork.flags & 32768)) {
if (
((current = completeWork(current, completedWork, subtreeRenderLanes)),
null !== current)
@@ -6787,16 +6998,21 @@ function completeUnitOfWork(unitOfWork) {
return;
}
} else {
- current = unwindWork(completedWork);
+ current = unwindWork(current, completedWork);
if (null !== current) {
- current.flags &= 8191;
+ current.flags &= 32767;
workInProgress = current;
return;
}
- null !== unitOfWork &&
- ((unitOfWork.flags |= 8192),
- (unitOfWork.subtreeFlags = 0),
- (unitOfWork.deletions = null));
+ if (null !== unitOfWork)
+ (unitOfWork.flags |= 32768),
+ (unitOfWork.subtreeFlags = 0),
+ (unitOfWork.deletions = null);
+ else {
+ workInProgressRootExitStatus = 6;
+ workInProgress = null;
+ return;
+ }
}
completedWork = completedWork.sibling;
if (null !== completedWork) {
@@ -6807,23 +7023,23 @@ function completeUnitOfWork(unitOfWork) {
} while (null !== completedWork);
0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
-function commitRoot(root) {
+function commitRoot(root, recoverableErrors) {
var previousUpdateLanePriority = currentUpdatePriority,
prevTransition = ReactCurrentBatchConfig$2.transition;
try {
- (ReactCurrentBatchConfig$2.transition = 0),
+ (ReactCurrentBatchConfig$2.transition = null),
(currentUpdatePriority = 1),
- commitRootImpl(root, previousUpdateLanePriority);
+ commitRootImpl(root, recoverableErrors, previousUpdateLanePriority);
} finally {
(ReactCurrentBatchConfig$2.transition = prevTransition),
(currentUpdatePriority = previousUpdateLanePriority);
}
return null;
}
-function commitRootImpl(root, renderPriorityLevel) {
+function commitRootImpl(root, recoverableErrors, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var finishedWork = root.finishedWork,
lanes = root.finishedLanes;
@@ -6841,25 +7057,25 @@ function commitRootImpl(root, renderPriorityLevel) {
root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
(workInProgressRootRenderLanes = 0));
- (0 === (finishedWork.subtreeFlags & 1040) &&
- 0 === (finishedWork.flags & 1040)) ||
+ (0 === (finishedWork.subtreeFlags & 2064) &&
+ 0 === (finishedWork.flags & 2064)) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
}));
- remainingLanes = 0 !== (finishedWork.flags & 8054);
- if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) {
+ remainingLanes = 0 !== (finishedWork.flags & 15990);
+ if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) {
remainingLanes = ReactCurrentBatchConfig$2.transition;
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
var previousPriority = currentUpdatePriority;
currentUpdatePriority = 1;
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
ReactCurrentOwner$2.current = null;
commitBeforeMutationEffects(root, finishedWork);
- commitMutationEffects(root, finishedWork);
+ commitMutationEffects(root, finishedWork, lanes);
root.current = finishedWork;
commitLayoutEffects(finishedWork, root, lanes);
requestPaint();
@@ -6873,22 +7089,29 @@ function commitRootImpl(root, renderPriorityLevel) {
(pendingPassiveEffectsLanes = lanes));
remainingLanes = root.pendingLanes;
0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
- 0 !== (remainingLanes & 1)
- ? root === rootWithNestedUpdates
- ? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
- : (nestedUpdateCount = 0);
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
ensureRootIsScheduled(root, now());
+ if (null !== recoverableErrors)
+ for (
+ renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
+ finishedWork < recoverableErrors.length;
+ finishedWork++
+ )
+ renderPriorityLevel(recoverableErrors[finishedWork]);
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
(root = firstUncaughtError),
(firstUncaughtError = null),
root);
- if (0 !== (executionContext & 4)) return null;
0 !== (pendingPassiveEffectsLanes & 1) &&
0 !== root.tag &&
flushPassiveEffects();
+ remainingLanes = root.pendingLanes;
+ 0 !== (remainingLanes & 1)
+ ? root === rootWithNestedUpdates
+ ? nestedUpdateCount++
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))
+ : (nestedUpdateCount = 0);
flushSyncCallbacks();
return null;
}
@@ -6898,7 +7121,7 @@ function flushPassiveEffects() {
prevTransition = ReactCurrentBatchConfig$2.transition,
previousPriority = currentUpdatePriority;
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority;
if (null === rootWithPendingPassiveEffects)
var JSCompiler_inline_result = !1;
@@ -6906,10 +7129,10 @@ function flushPassiveEffects() {
renderPriority = rootWithPendingPassiveEffects;
rootWithPendingPassiveEffects = null;
pendingPassiveEffectsLanes = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
for (nextEffect = renderPriority.current; null !== nextEffect; ) {
var fiber = nextEffect,
child = fiber.child;
@@ -6924,7 +7147,7 @@ function flushPassiveEffects() {
case 0:
case 11:
case 15:
- commitHookEffectListUnmount(4, fiber$jscomp$0, fiber);
+ commitHookEffectListUnmount(8, fiber$jscomp$0, fiber);
}
var child$jscomp$0 = fiber$jscomp$0.child;
if (null !== child$jscomp$0)
@@ -6964,17 +7187,17 @@ function flushPassiveEffects() {
nextEffect = fiber;
}
}
- if (0 !== (fiber.subtreeFlags & 1040) && null !== child)
+ if (0 !== (fiber.subtreeFlags & 2064) && null !== child)
(child.return = fiber), (nextEffect = child);
else
b: for (; null !== nextEffect; ) {
fiber = nextEffect;
- if (0 !== (fiber.flags & 1024))
+ if (0 !== (fiber.flags & 2048))
switch (fiber.tag) {
case 0:
case 11:
case 15:
- commitHookEffectListUnmount(5, fiber, fiber.return);
+ commitHookEffectListUnmount(9, fiber, fiber.return);
}
var sibling$jscomp$0 = fiber.sibling;
if (null !== sibling$jscomp$0) {
@@ -6989,18 +7212,18 @@ function flushPassiveEffects() {
for (nextEffect = finishedWork; null !== nextEffect; ) {
child = nextEffect;
var firstChild = child.child;
- if (0 !== (child.subtreeFlags & 1040) && null !== firstChild)
+ if (0 !== (child.subtreeFlags & 2064) && null !== firstChild)
(firstChild.return = child), (nextEffect = firstChild);
else
b: for (child = finishedWork; null !== nextEffect; ) {
deletions = nextEffect;
- if (0 !== (deletions.flags & 1024))
+ if (0 !== (deletions.flags & 2048))
try {
switch (deletions.tag) {
case 0:
case 11:
case 15:
- commitHookEffectListMount(5, deletions);
+ commitHookEffectListMount(9, deletions);
}
} catch (error) {
captureCommitPhaseError(deletions, deletions.return, error);
@@ -7127,7 +7350,6 @@ function resolveRetryWakeable(boundaryFiber, wakeable) {
}
var beginWork$1;
beginWork$1 = function(current, workInProgress, renderLanes) {
- var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
@@ -7135,158 +7357,98 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
)
didReceiveUpdate = !0;
else {
- if (0 === (renderLanes & updateLanes)) {
- 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.type._context;
- var nextValue = workInProgress.memoizedProps.value;
- push(valueCursor, updateLanes._currentValue);
- updateLanes._currentValue = nextValue;
- 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,
- renderLanes
- );
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
- if (0 !== (current.flags & 128)) {
- if (updateLanes)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderLanes
- );
- workInProgress.flags |= 128;
- }
- nextValue = workInProgress.memoizedState;
- null !== nextValue &&
- ((nextValue.rendering = null),
- (nextValue.tail = null),
- (nextValue.lastEffect = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (updateLanes) break;
- else return null;
- case 22:
- case 23:
- return (
- (workInProgress.lanes = 0),
- updateOffscreenComponent(current, workInProgress, renderLanes)
- );
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
+ if (
+ 0 === (current.lanes & renderLanes) &&
+ 0 === (workInProgress.flags & 128)
+ )
+ return (
+ (didReceiveUpdate = !1),
+ attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+ )
);
- }
- didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1;
+ didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1;
}
else didReceiveUpdate = !1;
workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateLanes = workInProgress.type;
+ var Component = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- nextValue = getMaskedContext(workInProgress, contextStackCursor.current);
+ var context = getMaskedContext(
+ workInProgress,
+ contextStackCursor.current
+ );
prepareToReadContext(workInProgress, renderLanes);
- nextValue = renderWithHooks(
+ context = renderWithHooks(
null,
workInProgress,
- updateLanes,
+ Component,
current,
- nextValue,
+ context,
renderLanes
);
workInProgress.flags |= 1;
if (
- "object" === typeof nextValue &&
- null !== nextValue &&
- "function" === typeof nextValue.render &&
- void 0 === nextValue.$$typeof
+ "object" === typeof context &&
+ null !== context &&
+ "function" === typeof context.render &&
+ void 0 === context.$$typeof
) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateLanes)) {
+ if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
workInProgress.memoizedState =
- null !== nextValue.state && void 0 !== nextValue.state
- ? nextValue.state
+ null !== context.state && void 0 !== context.state
+ ? context.state
: null;
initializeUpdateQueue(workInProgress);
- nextValue.updater = classComponentUpdater;
- workInProgress.stateNode = nextValue;
- nextValue._reactInternals = workInProgress;
- mountClassInstance(workInProgress, updateLanes, current, renderLanes);
+ context.updater = classComponentUpdater;
+ workInProgress.stateNode = context;
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, Component, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
hasContext,
renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(null, workInProgress, nextValue, renderLanes),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
- nextValue = workInProgress.elementType;
+ Component = workInProgress.elementType;
a: {
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- hasContext = nextValue._init;
- nextValue = hasContext(nextValue._payload);
- workInProgress.type = nextValue;
- hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue);
- current = resolveDefaultProps(nextValue, current);
- switch (hasContext) {
+ context = Component._init;
+ Component = context(Component._payload);
+ workInProgress.type = Component;
+ context = workInProgress.tag = resolveLazyComponentTag(Component);
+ current = resolveDefaultProps(Component, current);
+ switch (context) {
case 0:
workInProgress = updateFunctionComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7295,7 +7457,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateClassComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7304,7 +7466,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateForwardRef(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7313,79 +7475,75 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateMemoComponent(
null,
workInProgress,
- nextValue,
- resolveDefaultProps(nextValue.type, current),
- updateLanes,
+ Component,
+ resolveDefaultProps(Component.type, current),
renderLanes
);
break a;
}
throw Error(
"Element type is invalid. Received a promise that resolves to: " +
- nextValue +
+ Component +
". Lazy element type must resolve to a class or function."
);
}
return workInProgress;
case 0:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateFunctionComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 1:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateClassComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- 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."
- );
- nextValue = workInProgress.pendingProps;
- updateLanes = workInProgress.memoizedState.element;
+ if (null === current)
+ throw Error("Should have a current fiber. This is a bug in React.");
+ context = workInProgress.pendingProps;
+ Component = workInProgress.memoizedState.element;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextValue, null, renderLanes);
- nextValue = workInProgress.memoizedState.element;
- nextValue === updateLanes
+ processUpdateQueue(workInProgress, context, null, renderLanes);
+ context = workInProgress.memoizedState.element;
+ context === Component
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
renderLanes
))
- : (reconcileChildren(current, workInProgress, nextValue, renderLanes),
+ : (reconcileChildren(current, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateLanes = workInProgress.pendingProps.children),
- markRef(current, workInProgress),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ (Component = workInProgress.pendingProps.children),
+ markRef$1(current, workInProgress),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 6:
@@ -7398,35 +7556,30 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateLanes = workInProgress.pendingProps),
+ (Component = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateLanes,
+ Component,
renderLanes
))
- : reconcileChildren(
- current,
- workInProgress,
- updateLanes,
- renderLanes
- ),
+ : reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 11:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateForwardRef(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
@@ -7462,16 +7615,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
);
case 10:
a: {
- updateLanes = workInProgress.type._context;
- nextValue = workInProgress.pendingProps;
+ Component = workInProgress.type._context;
+ context = workInProgress.pendingProps;
hasContext = workInProgress.memoizedProps;
- var newValue = nextValue.value;
- push(valueCursor, updateLanes._currentValue);
- updateLanes._currentValue = newValue;
+ var newValue = context.value;
+ push(valueCursor, Component._currentValue);
+ Component._currentValue = newValue;
if (null !== hasContext)
if (objectIs(hasContext.value, newValue)) {
if (
- hasContext.children === nextValue.children &&
+ hasContext.children === context.children &&
!didPerformWorkStackCursor.current
) {
workInProgress = bailoutOnAlreadyFinishedWork(
@@ -7496,7 +7649,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
null !== dependency;
) {
- if (dependency.context === updateLanes) {
+ if (dependency.context === Component) {
if (1 === newValue.tag) {
dependency = createUpdate(-1, renderLanes & -renderLanes);
dependency.tag = 2;
@@ -7514,7 +7667,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
newValue.lanes |= renderLanes;
dependency = newValue.alternate;
null !== dependency && (dependency.lanes |= renderLanes);
- scheduleWorkOnParentPath(newValue.return, renderLanes);
+ scheduleContextWorkOnParentPath(
+ newValue.return,
+ renderLanes,
+ workInProgress
+ );
list.lanes |= renderLanes;
break;
}
@@ -7547,7 +7704,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
reconcileChildren(
current,
workInProgress,
- nextValue.children,
+ context.children,
renderLanes
);
workInProgress = workInProgress.child;
@@ -7555,29 +7712,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return workInProgress;
case 9:
return (
- (nextValue = workInProgress.type),
- (updateLanes = workInProgress.pendingProps.children),
+ (context = workInProgress.type),
+ (Component = workInProgress.pendingProps.children),
prepareToReadContext(workInProgress, renderLanes),
- (nextValue = readContext(nextValue)),
- (updateLanes = updateLanes(nextValue)),
+ (context = readContext(context)),
+ (Component = Component(context)),
(workInProgress.flags |= 1),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 14:
return (
- (nextValue = workInProgress.type),
- (hasContext = resolveDefaultProps(
- nextValue,
- workInProgress.pendingProps
- )),
- (hasContext = resolveDefaultProps(nextValue.type, hasContext)),
+ (Component = workInProgress.type),
+ (context = resolveDefaultProps(Component, workInProgress.pendingProps)),
+ (context = resolveDefaultProps(Component.type, context)),
updateMemoComponent(
current,
workInProgress,
- nextValue,
- hasContext,
- updateLanes,
+ Component,
+ context,
renderLanes
)
);
@@ -7587,32 +7740,31 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateLanes,
renderLanes
);
case 17:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateLanes)
+ isContextProvider(Component)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
prepareToReadContext(workInProgress, renderLanes),
- constructClassInstance(workInProgress, updateLanes, nextValue),
- mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes),
+ constructClassInstance(workInProgress, Component, context),
+ mountClassInstance(workInProgress, Component, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
current,
renderLanes
@@ -7622,8 +7774,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return updateSuspenseListComponent(current, workInProgress, renderLanes);
case 22:
return updateOffscreenComponent(current, workInProgress, renderLanes);
- case 23:
- return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -7631,6 +7781,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
"). This error is likely caused by a bug in React. Please file an issue."
);
};
+function scheduleCallback$1(priorityLevel, callback) {
+ return scheduleCallback(priorityLevel, callback);
+}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -7681,7 +7834,7 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.flags = 0),
(workInProgress.subtreeFlags = 0),
(workInProgress.deletions = null));
- workInProgress.flags = current.flags & 1835008;
+ workInProgress.flags = current.flags & 14680064;
workInProgress.childLanes = current.childLanes;
workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
@@ -7714,10 +7867,6 @@ function createFiberFromTypeAndProps(
a: switch (type) {
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_DEBUG_TRACING_MODE_TYPE:
- fiberTag = 8;
- mode |= 4;
- break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
mode |= 8;
@@ -7745,13 +7894,6 @@ function createFiberFromTypeAndProps(
);
case REACT_OFFSCREEN_TYPE:
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
- case REACT_LEGACY_HIDDEN_TYPE:
- return (
- (type = createFiber(23, pendingProps, key, mode)),
- (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
- (type.lanes = lanes),
- type
- );
default:
if ("object" === typeof type && null !== type)
switch (type.$$typeof) {
@@ -7774,8 +7916,7 @@ function createFiberFromTypeAndProps(
}
throw Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- (null == type ? type : typeof type) +
- "."
+ ((null == type ? type : typeof type) + ".")
);
}
key = createFiber(fiberTag, pendingProps, key, mode);
@@ -7793,6 +7934,7 @@ function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
pendingProps = createFiber(22, pendingProps, key, mode);
pendingProps.elementType = REACT_OFFSCREEN_TYPE;
pendingProps.lanes = lanes;
+ pendingProps.stateNode = {};
return pendingProps;
}
function createFiberFromText(content, mode, lanes) {
@@ -7815,19 +7957,25 @@ function createFiberFromPortal(portal, mode, lanes) {
};
return mode;
}
-function FiberRootNode(containerInfo, tag, hydrate) {
+function FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+) {
this.tag = tag;
this.containerInfo = containerInfo;
this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
- this.pendingContext = this.context = null;
- this.hydrate = hydrate;
- this.callbackNode = null;
+ this.callbackNode = this.pendingContext = this.context = null;
this.callbackPriority = 0;
this.eventTimes = createLaneMap(0);
this.expirationTimes = createLaneMap(-1);
this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
this.entanglements = createLaneMap(0);
+ this.identifierPrefix = identifierPrefix;
+ this.onRecoverableError = onRecoverableError;
}
function createPortal(children, containerInfo, implementation) {
var key =
@@ -7845,9 +7993,9 @@ function findHostInstance(component) {
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
+ component = Object.keys(component).join(",");
throw Error(
- "Argument appears to not be a ReactComponent. Keys: " +
- Object.keys(component)
+ "Argument appears to not be a ReactComponent. Keys: " + component
);
}
component = findCurrentHostFiber(fiber);
@@ -7929,6 +8077,9 @@ function findNodeHandle(componentOrHandle) {
? componentOrHandle.canonical._nativeTag
: componentOrHandle._nativeTag;
}
+function onRecoverableError(error) {
+ console.error(error);
+}
function unmountComponentAtNode(containerTag) {
var root = roots.get(containerTag);
root &&
@@ -7949,10 +8100,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
- devToolsConfig$jscomp$inline_983 = {
+ devToolsConfig$jscomp$inline_963 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
- version: "18.0.0-experimental-568dc3532",
+ version: "18.0.0-experimental-34aa5cfe0-20220329",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@@ -7967,11 +8118,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
-var internals$jscomp$inline_1237 = {
- bundleType: devToolsConfig$jscomp$inline_983.bundleType,
- version: devToolsConfig$jscomp$inline_983.version,
- rendererPackageName: devToolsConfig$jscomp$inline_983.rendererPackageName,
- rendererConfig: devToolsConfig$jscomp$inline_983.rendererConfig,
+var internals$jscomp$inline_1217 = {
+ bundleType: devToolsConfig$jscomp$inline_963.bundleType,
+ version: devToolsConfig$jscomp$inline_963.version,
+ rendererPackageName: devToolsConfig$jscomp$inline_963.rendererPackageName,
+ rendererConfig: devToolsConfig$jscomp$inline_963.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@@ -7987,26 +8138,26 @@ var internals$jscomp$inline_1237 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
- devToolsConfig$jscomp$inline_983.findFiberByHostInstance ||
+ devToolsConfig$jscomp$inline_963.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
- reconcilerVersion: "18.0.0-experimental-568dc3532"
+ reconcilerVersion: "18.0.0-experimental-34aa5cfe0-20220329"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
- var hook$jscomp$inline_1238 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ var hook$jscomp$inline_1218 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
- !hook$jscomp$inline_1238.isDisabled &&
- hook$jscomp$inline_1238.supportsFiber
+ !hook$jscomp$inline_1218.isDisabled &&
+ hook$jscomp$inline_1218.supportsFiber
)
try {
- (rendererID = hook$jscomp$inline_1238.inject(
- internals$jscomp$inline_1237
+ (rendererID = hook$jscomp$inline_1218.inject(
+ internals$jscomp$inline_1217
)),
- (injectedHook = hook$jscomp$inline_1238);
+ (injectedHook = hook$jscomp$inline_1218);
} catch (err) {}
}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
@@ -8026,12 +8177,10 @@ exports.createPortal = function(children, containerTag) {
};
exports.dispatchCommand = function(handle, command, args) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.dispatchCommand(
- handle._internalInstanceHandle.stateNode.node,
- command,
- args
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.dispatchCommand(handle.node, command, args))
: ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand(
handle._nativeTag,
command,
@@ -8051,14 +8200,20 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
: componentOrHandle;
};
exports.findNodeHandle = findNodeHandle;
+exports.getInspectorDataForInstance = void 0;
exports.render = function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
- root = new FiberRootNode(containerTag, 0, !1);
+ root = new FiberRootNode(containerTag, 0, !1, "", onRecoverableError);
var JSCompiler_inline_result = createFiber(3, null, null, 0);
root.current = JSCompiler_inline_result;
JSCompiler_inline_result.stateNode = root;
- JSCompiler_inline_result.memoizedState = { element: null };
+ JSCompiler_inline_result.memoizedState = {
+ element: null,
+ isDehydrated: !1,
+ cache: null,
+ transitions: null
+ };
initializeUpdateQueue(JSCompiler_inline_result);
roots.set(containerTag, root);
}
@@ -8076,11 +8231,10 @@ exports.render = function(element, containerTag, callback) {
};
exports.sendAccessibilityEvent = function(handle, eventType) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.sendAccessibilityEvent(
- handle._internalInstanceHandle.stateNode.node,
- eventType
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType))
: ReactNativePrivateInterface.legacySendAccessibilityEvent(
handle._nativeTag,
eventType
diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js
index b875b0e8077321..917bd003a1c6e2 100644
--- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js
+++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js
@@ -1,5 +1,5 @@
/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@@ -8,10 +8,21 @@
* @nolint
* @providesModule ReactNativeRenderer-profiling
* @preventMunge
- * @generated SignedSource<>
+ * @generated SignedSource<<06200cf762f5eb0f48046de454a64107>>
*/
-"use strict";
+
+ 'use strict';
+
+/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
+}
+ "use strict";
require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore");
var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"),
React = require("react"),
@@ -87,6 +98,7 @@ function executeDirectDispatch(event) {
event._dispatchInstances = null;
return dispatchListener;
}
+var assign = Object.assign;
function functionThatReturnsTrue() {
return !0;
}
@@ -119,7 +131,7 @@ function SyntheticEvent(
this.isPropagationStopped = functionThatReturnsFalse;
return this;
}
-Object.assign(SyntheticEvent.prototype, {
+assign(SyntheticEvent.prototype, {
preventDefault: function() {
this.defaultPrevented = !0;
var event = this.nativeEvent;
@@ -173,10 +185,10 @@ SyntheticEvent.extend = function(Interface) {
var Super = this;
E.prototype = Super.prototype;
var prototype = new E();
- Object.assign(prototype, Class.prototype);
+ assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = Object.assign({}, Super.Interface, Interface);
+ Class.Interface = assign({}, Super.Interface, Interface);
Class.extend = Super.extend;
addEventPoolingTo(Class);
return Class;
@@ -783,18 +795,16 @@ function recomputePluginOrdering() {
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName],
pluginIndex = eventPluginOrder.indexOf(pluginName);
- if (!(-1 < pluginIndex))
+ if (-1 >= pluginIndex)
throw Error(
"EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" +
- pluginName +
- "`."
+ (pluginName + "`.")
);
if (!plugins[pluginIndex]) {
if (!pluginModule.extractEvents)
throw Error(
"EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" +
- pluginName +
- "` does not."
+ (pluginName + "` does not.")
);
plugins[pluginIndex] = pluginModule;
pluginIndex = pluginModule.eventTypes;
@@ -805,8 +815,7 @@ function recomputePluginOrdering() {
if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0))
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same event name, `" +
- eventName$jscomp$0 +
- "`."
+ (eventName$jscomp$0 + "`.")
);
eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
@@ -846,18 +855,22 @@ function publishRegistrationName(registrationName, pluginModule) {
if (registrationNameModules[registrationName])
throw Error(
"EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" +
- registrationName +
- "`."
+ (registrationName + "`.")
);
registrationNameModules[registrationName] = pluginModule;
}
var plugins = [],
eventNameDispatchConfigs = {},
registrationNameModules = {};
-function getListener$1(inst, registrationName) {
- inst = inst.stateNode;
- if (null === inst) return null;
- inst = getFiberCurrentPropsFromNode(inst);
+function getListeners(
+ inst,
+ registrationName,
+ phase,
+ dispatchToImperativeListeners
+) {
+ var stateNode = inst.stateNode;
+ if (null === stateNode) return null;
+ inst = getFiberCurrentPropsFromNode(stateNode);
if (null === inst) return null;
if ((inst = inst[registrationName]) && "function" !== typeof inst)
throw Error(
@@ -867,7 +880,67 @@ function getListener$1(inst, registrationName) {
typeof inst +
"` type."
);
- return inst;
+ if (
+ !(
+ dispatchToImperativeListeners &&
+ stateNode.canonical &&
+ stateNode.canonical._eventListeners
+ )
+ )
+ return inst;
+ var listeners = [];
+ inst && listeners.push(inst);
+ var requestedPhaseIsCapture = "captured" === phase,
+ mangledImperativeRegistrationName = requestedPhaseIsCapture
+ ? "rn:" + registrationName.replace(/Capture$/, "")
+ : "rn:" + registrationName;
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName] &&
+ 0 <
+ stateNode.canonical._eventListeners[mangledImperativeRegistrationName]
+ .length &&
+ stateNode.canonical._eventListeners[
+ mangledImperativeRegistrationName
+ ].forEach(function(listenerObj) {
+ if (
+ (null != listenerObj.options.capture && listenerObj.options.capture) ===
+ requestedPhaseIsCapture
+ ) {
+ var listenerFnWrapper = function(syntheticEvent) {
+ var eventInst = new ReactNativePrivateInterface.CustomEvent(
+ mangledImperativeRegistrationName,
+ { detail: syntheticEvent.nativeEvent }
+ );
+ eventInst.isTrusted = !0;
+ eventInst.setSyntheticEvent(syntheticEvent);
+ for (
+ var _len = arguments.length,
+ args = Array(1 < _len ? _len - 1 : 0),
+ _key = 1;
+ _key < _len;
+ _key++
+ )
+ args[_key - 1] = arguments[_key];
+ listenerObj.listener.apply(listenerObj, [eventInst].concat(args));
+ };
+ listenerObj.options.once
+ ? listeners.push(function() {
+ stateNode.canonical.removeEventListener_unstable(
+ mangledImperativeRegistrationName,
+ listenerObj.listener,
+ listenerObj.capture
+ );
+ listenerObj.invalidated ||
+ ((listenerObj.invalidated = !0),
+ listenerObj.listener.apply(listenerObj, arguments));
+ })
+ : listeners.push(listenerFnWrapper);
+ }
+ });
+ return 0 === listeners.length
+ ? null
+ : 1 === listeners.length
+ ? listeners[0]
+ : listeners;
}
var customBubblingEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
@@ -875,50 +948,74 @@ var customBubblingEventTypes =
customDirectEventTypes =
ReactNativePrivateInterface.ReactNativeViewConfigRegistry
.customDirectEventTypes;
+function accumulateListenersAndInstances(inst, event, listeners) {
+ var listenersLength = listeners
+ ? isArrayImpl(listeners)
+ ? listeners.length
+ : 1
+ : 0;
+ if (0 < listenersLength)
+ if (
+ ((event._dispatchListeners = accumulateInto(
+ event._dispatchListeners,
+ listeners
+ )),
+ null == event._dispatchInstances && 1 === listenersLength)
+ )
+ event._dispatchInstances = inst;
+ else
+ for (
+ event._dispatchInstances = event._dispatchInstances || [],
+ isArrayImpl(event._dispatchInstances) ||
+ (event._dispatchInstances = [event._dispatchInstances]),
+ listeners = 0;
+ listeners < listenersLength;
+ listeners++
+ )
+ event._dispatchInstances.push(inst);
+}
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
- ));
+ phase = getListeners(
+ inst,
+ event.dispatchConfig.phasedRegistrationNames[phase],
+ phase,
+ !0
+ );
+ accumulateListenersAndInstances(inst, event, phase);
+}
+function traverseTwoPhase$1(inst, fn, arg, skipBubbling) {
+ for (var path = []; inst; ) {
+ path.push(inst);
+ do inst = inst.return;
+ while (inst && 5 !== inst.tag);
+ inst = inst ? inst : null;
+ }
+ for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg);
+ if (skipBubbling) fn(path[0], "bubbled", arg);
+ else
+ for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg);
}
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);
- }
+ event &&
+ event.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ event._targetInst,
+ accumulateDirectionalDispatches$1,
+ event,
+ !1
+ );
}
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
- )));
+ var listeners = getListeners(
+ inst,
+ event.dispatchConfig.registrationName,
+ "bubbled",
+ !1
+ );
+ accumulateListenersAndInstances(inst, event, listeners);
}
}
}
@@ -931,7 +1028,7 @@ eventPluginOrder = Array.prototype.slice.call([
"ReactNativeBridgeEventPlugin"
]);
recomputePluginOrdering();
-var injectedNamesToPlugins$jscomp$inline_227 = {
+var injectedNamesToPlugins$jscomp$inline_228 = {
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: {
eventTypes: {},
@@ -955,10 +1052,21 @@ var injectedNamesToPlugins$jscomp$inline_227 = {
nativeEventTarget
);
if (bubbleDispatchConfig)
- forEachAccumulated(
- topLevelType,
- accumulateTwoPhaseDispatchesSingle$1
- );
+ null != topLevelType &&
+ null != topLevelType.dispatchConfig.phasedRegistrationNames &&
+ topLevelType.dispatchConfig.phasedRegistrationNames.skipBubbling
+ ? topLevelType &&
+ topLevelType.dispatchConfig.phasedRegistrationNames &&
+ traverseTwoPhase$1(
+ topLevelType._targetInst,
+ accumulateDirectionalDispatches$1,
+ topLevelType,
+ !0
+ )
+ : forEachAccumulated(
+ topLevelType,
+ accumulateTwoPhaseDispatchesSingle$1
+ );
else if (directDispatchConfig)
forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1);
else return null;
@@ -966,34 +1074,33 @@ var injectedNamesToPlugins$jscomp$inline_227 = {
}
}
},
- isOrderingDirty$jscomp$inline_228 = !1,
- pluginName$jscomp$inline_229;
-for (pluginName$jscomp$inline_229 in injectedNamesToPlugins$jscomp$inline_227)
+ isOrderingDirty$jscomp$inline_229 = !1,
+ pluginName$jscomp$inline_230;
+for (pluginName$jscomp$inline_230 in injectedNamesToPlugins$jscomp$inline_228)
if (
- injectedNamesToPlugins$jscomp$inline_227.hasOwnProperty(
- pluginName$jscomp$inline_229
+ injectedNamesToPlugins$jscomp$inline_228.hasOwnProperty(
+ pluginName$jscomp$inline_230
)
) {
- var pluginModule$jscomp$inline_230 =
- injectedNamesToPlugins$jscomp$inline_227[pluginName$jscomp$inline_229];
+ var pluginModule$jscomp$inline_231 =
+ injectedNamesToPlugins$jscomp$inline_228[pluginName$jscomp$inline_230];
if (
- !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_229) ||
- namesToPlugins[pluginName$jscomp$inline_229] !==
- pluginModule$jscomp$inline_230
+ !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_230) ||
+ namesToPlugins[pluginName$jscomp$inline_230] !==
+ pluginModule$jscomp$inline_231
) {
- if (namesToPlugins[pluginName$jscomp$inline_229])
+ if (namesToPlugins[pluginName$jscomp$inline_230])
throw Error(
"EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
- pluginName$jscomp$inline_229 +
- "`."
+ (pluginName$jscomp$inline_230 + "`.")
);
namesToPlugins[
- pluginName$jscomp$inline_229
- ] = pluginModule$jscomp$inline_230;
- isOrderingDirty$jscomp$inline_228 = !0;
+ pluginName$jscomp$inline_230
+ ] = pluginModule$jscomp$inline_231;
+ isOrderingDirty$jscomp$inline_229 = !0;
}
}
-isOrderingDirty$jscomp$inline_228 && recomputePluginOrdering();
+isOrderingDirty$jscomp$inline_229 && recomputePluginOrdering();
var instanceCache = new Map(),
instanceProps = new Map();
function getInstanceFromTag(tag) {
@@ -1137,43 +1244,25 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({
});
var ReactSharedInternals =
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_DEBUG_TRACING_MODE_TYPE = 60129,
- REACT_OFFSCREEN_TYPE = 60130,
- REACT_LEGACY_HIDDEN_TYPE = 60131,
- REACT_CACHE_TYPE = 60132;
-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");
- 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");
- REACT_CACHE_TYPE = symbolFor("react.cache");
-}
-var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
+ REACT_ELEMENT_TYPE = Symbol.for("react.element"),
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
+ REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
+ REACT_LAZY_TYPE = Symbol.for("react.lazy");
+Symbol.for("react.scope");
+Symbol.for("react.debug_trace_mode");
+var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
+Symbol.for("react.legacy_hidden");
+Symbol.for("react.cache");
+Symbol.for("react.tracing_marker");
+var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
maybeIterable =
@@ -1198,8 +1287,6 @@ function getComponentNameFromType(type) {
return "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
- case REACT_CACHE_TYPE:
- return "Cache";
}
if ("object" === typeof type)
switch (type.$$typeof) {
@@ -1260,8 +1347,6 @@ function getComponentNameFromFiber(fiber) {
return "Text";
case 16:
return getComponentNameFromType(type);
- case 23:
- return "LegacyHidden";
case 8:
return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode";
case 22:
@@ -1274,6 +1359,8 @@ function getComponentNameFromFiber(fiber) {
return "Suspense";
case 19:
return "SuspenseList";
+ case 25:
+ return "TracingMarker";
case 1:
case 0:
case 17:
@@ -1294,7 +1381,7 @@ function getNearestMountedFiber(fiber) {
fiber = node;
do
(node = fiber),
- 0 !== (node.flags & 2050) && (nearestMounted = node.return),
+ 0 !== (node.flags & 4098) && (nearestMounted = node.return),
(fiber = node.return);
while (fiber);
}
@@ -1721,6 +1808,13 @@ function onCommitRoot(root, eventPriority) {
);
} catch (err) {}
}
+var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
+ log = Math.log,
+ LN2 = Math.LN2;
+function clz32Fallback(x) {
+ x >>>= 0;
+ return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0;
+}
var nextTransitionLane = 64,
nextRetryLane = 4194304;
function getHighestPriorityLanes(lanes) {
@@ -1929,12 +2023,6 @@ function movePendingFibersToMemoized(root, lanes) {
lanes &= ~root;
}
}
-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 currentUpdatePriority = 0;
function lanesToEventPriority(lanes) {
lanes &= -lanes;
@@ -2060,7 +2148,7 @@ function processChildContext(fiber, type, parentContext) {
contextKey +
'" is not defined in childContextTypes.'
);
- return Object.assign({}, parentContext, instance);
+ return assign({}, parentContext, instance);
}
function pushContextProvider(workInProgress) {
workInProgress =
@@ -2091,7 +2179,11 @@ function invalidateContextProvider(workInProgress, type, didChange) {
: pop(didPerformWorkStackCursor);
push(didPerformWorkStackCursor, didChange);
}
-var syncQueue = null,
+function is(x, y) {
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
+}
+var objectIs = "function" === typeof Object.is ? Object.is : is,
+ syncQueue = null,
includesLegacySyncCallbacks = !1,
isFlushingSyncQueue = !1;
function flushSyncCallbacks() {
@@ -2120,10 +2212,6 @@ function flushSyncCallbacks() {
return null;
}
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
-function is(x, y) {
- return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
-}
-var objectIs = "function" === typeof Object.is ? Object.is : is;
function shallowEqual(objA, objB) {
if (objectIs(objA, objB)) return !0;
if (
@@ -2136,12 +2224,14 @@ function shallowEqual(objA, objB) {
var keysA = Object.keys(objA),
keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return !1;
- for (keysB = 0; keysB < keysA.length; keysB++)
+ for (keysB = 0; keysB < keysA.length; keysB++) {
+ var currentKey = keysA[keysB];
if (
- !hasOwnProperty.call(objB, keysA[keysB]) ||
- !objectIs(objA[keysA[keysB]], objB[keysA[keysB]])
+ !hasOwnProperty.call(objB, currentKey) ||
+ !objectIs(objA[currentKey], objB[currentKey])
)
return !1;
+ }
return !0;
}
function describeFiber(fiber) {
@@ -2180,7 +2270,7 @@ function getStackByFiberInDevAndProd(workInProgress) {
}
function resolveDefaultProps(Component, baseProps) {
if (Component && Component.defaultProps) {
- baseProps = Object.assign({}, baseProps);
+ baseProps = assign({}, baseProps);
Component = Component.defaultProps;
for (var propName in Component)
void 0 === baseProps[propName] &&
@@ -2201,19 +2291,16 @@ function popProvider(context) {
pop(valueCursor);
context._currentValue = currentValue;
}
-function scheduleWorkOnParentPath(parent, renderLanes) {
+function scheduleContextWorkOnParentPath(parent, renderLanes, propagationRoot) {
for (; null !== parent; ) {
var alternate = parent.alternate;
- 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.childLanes & renderLanes) !== renderLanes
+ ? ((parent.childLanes |= renderLanes),
+ null !== alternate && (alternate.childLanes |= renderLanes))
+ : null !== alternate &&
+ (alternate.childLanes & renderLanes) !== renderLanes &&
+ (alternate.childLanes |= renderLanes);
+ if (parent === propagationRoot) break;
parent = parent.return;
}
}
@@ -2283,7 +2370,7 @@ function enqueueUpdate(fiber, update) {
((updateQueue = updateQueue.shared),
null !== workInProgressRoot &&
0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
+ 0 === (executionContext & 2)
? ((fiber = updateQueue.interleaved),
null === fiber
? ((update.next = update),
@@ -2420,7 +2507,7 @@ function processUpdateQueue(
newState = workInProgress;
break a;
case 3:
- workInProgress.flags = (workInProgress.flags & -16385) | 128;
+ workInProgress.flags = (workInProgress.flags & -65537) | 128;
case 0:
workInProgress = update.payload;
updateLane =
@@ -2428,7 +2515,7 @@ function processUpdateQueue(
? workInProgress.call(updateEventTime, newState, updateLane)
: workInProgress;
if (null === updateLane || void 0 === updateLane) break a;
- newState = Object.assign({}, newState, updateLane);
+ newState = assign({}, newState, updateLane);
break a;
case 2:
hasForceUpdate = !0;
@@ -2515,7 +2602,7 @@ function applyDerivedStateFromProps(
getDerivedStateFromProps =
null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps
? ctor
- : Object.assign({}, ctor, getDerivedStateFromProps);
+ : assign({}, ctor, getDerivedStateFromProps);
workInProgress.memoizedState = getDerivedStateFromProps;
0 === workInProgress.lanes &&
(workInProgress.updateQueue.baseState = getDerivedStateFromProps);
@@ -2651,6 +2738,26 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
"function" === typeof instance.componentDidMount &&
(workInProgress.flags |= 4);
}
+var forkStack = [],
+ forkStackIndex = 0,
+ treeForkProvider = null,
+ idStack = [],
+ idStackIndex = 0,
+ treeContextProvider = null;
+function popTreeContext(workInProgress) {
+ for (; workInProgress === treeForkProvider; )
+ (treeForkProvider = forkStack[--forkStackIndex]),
+ (forkStack[forkStackIndex] = null),
+ --forkStackIndex,
+ (forkStack[forkStackIndex] = null);
+ for (; workInProgress === treeContextProvider; )
+ (treeContextProvider = idStack[--idStackIndex]),
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null),
+ --idStackIndex,
+ (idStack[idStackIndex] = null);
+}
function coerceRef(returnFiber, current, element) {
returnFiber = element.ref;
if (
@@ -2673,7 +2780,8 @@ function coerceRef(returnFiber, current, element) {
returnFiber +
". This error is likely caused by a bug in React. Please file an issue."
);
- var stringRef = "" + returnFiber;
+ var resolvedInst = inst,
+ stringRef = "" + returnFiber;
if (
null !== current &&
null !== current.ref &&
@@ -2682,8 +2790,8 @@ function coerceRef(returnFiber, current, element) {
)
return current.ref;
current = function(value) {
- var refs = inst.refs;
- refs === emptyRefsObject && (refs = inst.refs = {});
+ var refs = resolvedInst.refs;
+ refs === emptyRefsObject && (refs = resolvedInst.refs = {});
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
};
current._stringRef = stringRef;
@@ -2744,7 +2852,8 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function placeChild(newFiber, lastPlacedIndex, newIndex) {
newFiber.index = newIndex;
- if (!shouldTrackSideEffects) return lastPlacedIndex;
+ if (!shouldTrackSideEffects)
+ return (newFiber.flags |= 1048576), lastPlacedIndex;
newIndex = newFiber.alternate;
if (null !== newIndex)
return (
@@ -2835,7 +2944,10 @@ function ChildReconciler(shouldTrackSideEffects) {
return current;
}
function createChild(returnFiber, newChild, lanes) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(newChild = createFiberFromText(
"" + newChild,
@@ -2889,7 +3001,10 @@ function ChildReconciler(shouldTrackSideEffects) {
}
function updateSlot(returnFiber, oldFiber, newChild, lanes) {
var key = null !== oldFiber ? oldFiber.key : null;
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return null !== key
? null
: updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
@@ -2919,7 +3034,10 @@ function ChildReconciler(shouldTrackSideEffects) {
newChild,
lanes
) {
- if ("string" === typeof newChild || "number" === typeof newChild)
+ if (
+ ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ )
return (
(existingChildren = existingChildren.get(newIdx) || null),
updateTextNode(returnFiber, existingChildren, "" + newChild, lanes)
@@ -3120,60 +3238,49 @@ function ChildReconciler(shouldTrackSideEffects) {
return iteratorFn;
}
return function(returnFiber, currentFirstChild, newChild, lanes) {
- var isUnkeyedTopLevelFragment =
- "object" === typeof newChild &&
+ "object" === typeof newChild &&
null !== newChild &&
newChild.type === REACT_FRAGMENT_TYPE &&
- null === newChild.key;
- isUnkeyedTopLevelFragment && (newChild = newChild.props.children);
+ null === newChild.key &&
+ (newChild = newChild.props.children);
if ("object" === typeof newChild && null !== newChild) {
switch (newChild.$$typeof) {
case REACT_ELEMENT_TYPE:
a: {
- var key = newChild.key;
for (
- isUnkeyedTopLevelFragment = currentFirstChild;
- null !== isUnkeyedTopLevelFragment;
+ var key = newChild.key, child = currentFirstChild;
+ null !== child;
) {
- if (isUnkeyedTopLevelFragment.key === key) {
+ if (child.key === key) {
key = newChild.type;
if (key === REACT_FRAGMENT_TYPE) {
- if (7 === isUnkeyedTopLevelFragment.tag) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
+ if (7 === child.tag) {
+ deleteRemainingChildren(returnFiber, child.sibling);
currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
+ child,
newChild.props.children
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- } else if (isUnkeyedTopLevelFragment.elementType === key) {
- deleteRemainingChildren(
- returnFiber,
- isUnkeyedTopLevelFragment.sibling
- );
- currentFirstChild = useFiber(
- isUnkeyedTopLevelFragment,
- newChild.props
- );
+ } else if (child.elementType === key) {
+ deleteRemainingChildren(returnFiber, child.sibling);
+ currentFirstChild = useFiber(child, newChild.props);
currentFirstChild.ref = coerceRef(
returnFiber,
- isUnkeyedTopLevelFragment,
+ child,
newChild
);
currentFirstChild.return = returnFiber;
returnFiber = currentFirstChild;
break a;
}
- deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment);
+ deleteRemainingChildren(returnFiber, child);
break;
- } else deleteChild(returnFiber, isUnkeyedTopLevelFragment);
- isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling;
+ } else deleteChild(returnFiber, child);
+ child = child.sibling;
}
newChild.type === REACT_FRAGMENT_TYPE
? ((currentFirstChild = createFiberFromFragment(
@@ -3203,12 +3310,8 @@ function ChildReconciler(shouldTrackSideEffects) {
return placeSingleChild(returnFiber);
case REACT_PORTAL_TYPE:
a: {
- for (
- isUnkeyedTopLevelFragment = newChild.key;
- null !== currentFirstChild;
-
- ) {
- if (currentFirstChild.key === isUnkeyedTopLevelFragment)
+ for (child = newChild.key; null !== currentFirstChild; ) {
+ if (currentFirstChild.key === child)
if (
4 === currentFirstChild.tag &&
currentFirstChild.stateNode.containerInfo ===
@@ -3260,9 +3363,9 @@ function ChildReconciler(shouldTrackSideEffects) {
);
throwOnInvalidObjectType(returnFiber, newChild);
}
- if ("string" === typeof newChild || "number" === typeof newChild)
- return (
- (newChild = "" + newChild),
+ return ("string" === typeof newChild && "" !== newChild) ||
+ "number" === typeof newChild
+ ? ((newChild = "" + newChild),
null !== currentFirstChild && 6 === currentFirstChild.tag
? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling),
(currentFirstChild = useFiber(currentFirstChild, newChild)),
@@ -3276,20 +3379,8 @@ function ChildReconciler(shouldTrackSideEffects) {
)),
(currentFirstChild.return = returnFiber),
(returnFiber = currentFirstChild)),
- placeSingleChild(returnFiber)
- );
- if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment)
- switch (returnFiber.tag) {
- case 1:
- case 0:
- case 11:
- case 15:
- throw Error(
- (getComponentNameFromFiber(returnFiber) || "Component") +
- "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."
- );
- }
- return deleteRemainingChildren(returnFiber, currentFirstChild);
+ placeSingleChild(returnFiber))
+ : deleteRemainingChildren(returnFiber, currentFirstChild);
};
}
var reconcileChildFibers = ChildReconciler(!0),
@@ -3376,7 +3467,8 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
currentHook = null,
workInProgressHook = null,
didScheduleRenderPhaseUpdate = !1,
- didScheduleRenderPhaseUpdateDuringThisPass = !1;
+ didScheduleRenderPhaseUpdateDuringThisPass = !1,
+ globalClientIdCounter = 0;
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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
@@ -3410,7 +3502,7 @@ function renderWithHooks(
nextRenderLanes = 0;
do {
didScheduleRenderPhaseUpdateDuringThisPass = !1;
- if (!(25 > nextRenderLanes))
+ if (25 <= nextRenderLanes)
throw Error(
"Too many re-renders. React limits the number of renders to prevent an infinite loop."
);
@@ -3511,19 +3603,18 @@ function updateReducer(reducer) {
(newBaseQueueLast = newBaseQueueLast.next = {
lane: 0,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
}),
- (current =
- update.eagerReducer === reducer
- ? update.eagerState
- : reducer(current, update.action));
+ (current = update.hasEagerState
+ ? update.eagerState
+ : reducer(current, update.action));
else {
var clone = {
lane: updateLane,
action: update.action,
- eagerReducer: update.eagerReducer,
+ hasEagerState: update.hasEagerState,
eagerState: update.eagerState,
next: null
};
@@ -3580,109 +3671,77 @@ 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 may be 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."
+function updateMutableSource() {}
+function updateSyncExternalStore(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = updateWorkInProgressHook(),
+ nextSnapshot = getSnapshot(),
+ snapshotChanged = !objectIs(hook.memoizedState, nextSnapshot);
+ snapshotChanged &&
+ ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
+ hook = hook.queue;
+ updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [
+ subscribe
+ ]);
+ if (
+ hook.getSnapshot !== getSnapshot ||
+ snapshotChanged ||
+ (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1)
+ ) {
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot),
+ void 0,
+ null
);
- 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);
- objectIs(version, maybeNewVersion) ||
- ((maybeNewVersion = getSnapshot(source._source)),
- objectIs(snapshot, maybeNewVersion) ||
- (setSnapshot(maybeNewVersion),
- (maybeNewVersion = requestUpdateLane(fiber)),
- (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)),
- markRootEntangled(root, root.mutableReadLanes));
- },
- [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);
- 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,
- interleaved: null,
- lanes: 0,
- 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;
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ }
+ return nextSnapshot;
+}
+function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
+ fiber.flags |= 16384;
+ fiber = { getSnapshot: getSnapshot, value: renderedSnapshot };
+ getSnapshot = currentlyRenderingFiber$1.updateQueue;
+ null === getSnapshot
+ ? ((getSnapshot = { lastEffect: null, stores: null }),
+ (currentlyRenderingFiber$1.updateQueue = getSnapshot),
+ (getSnapshot.stores = [fiber]))
+ : ((renderedSnapshot = getSnapshot.stores),
+ null === renderedSnapshot
+ ? (getSnapshot.stores = [fiber])
+ : renderedSnapshot.push(fiber));
+}
+function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
+ inst.value = nextSnapshot;
+ inst.getSnapshot = getSnapshot;
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+}
+function subscribeToStore(fiber, inst, subscribe) {
+ return subscribe(function() {
+ checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
+ });
}
-function updateMutableSource(source, getSnapshot, subscribe) {
- var hook = updateWorkInProgressHook();
- return useMutableSource(hook, source, getSnapshot, subscribe);
+function checkIfSnapshotChanged(inst) {
+ var latestGetSnapshot = inst.getSnapshot;
+ inst = inst.value;
+ try {
+ var nextValue = latestGetSnapshot();
+ return !objectIs(inst, nextValue);
+ } catch (error) {
+ return !0;
+ }
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
- initialState = hook.queue = {
+ initialState = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3690,7 +3749,8 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
- initialState = initialState.dispatch = dispatchAction.bind(
+ hook.queue = initialState;
+ initialState = initialState.dispatch = dispatchSetState.bind(
null,
currentlyRenderingFiber$1,
initialState
@@ -3701,7 +3761,7 @@ function pushEffect(tag, create, destroy, deps) {
tag = { tag: tag, create: create, destroy: destroy, deps: deps, next: null };
create = currentlyRenderingFiber$1.updateQueue;
null === create
- ? ((create = { lastEffect: null }),
+ ? ((create = { lastEffect: null, stores: null }),
(currentlyRenderingFiber$1.updateQueue = create),
(create.lastEffect = tag.next = tag))
: ((destroy = create.lastEffect),
@@ -3742,14 +3802,17 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps);
}
function mountEffect(create, deps) {
- return mountEffectImpl(1049600, 4, create, deps);
+ return mountEffectImpl(8390656, 8, create, deps);
}
function updateEffect(create, deps) {
- return updateEffectImpl(1024, 4, create, deps);
+ return updateEffectImpl(2048, 8, create, deps);
}
-function updateLayoutEffect(create, deps) {
+function updateInsertionEffect(create, deps) {
return updateEffectImpl(4, 2, create, deps);
}
+function updateLayoutEffect(create, deps) {
+ return updateEffectImpl(4, 4, create, deps);
+}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
@@ -3772,7 +3835,7 @@ function updateImperativeHandle(ref, create, deps) {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return updateEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
@@ -3811,7 +3874,7 @@ function startTransition(setPending, callback) {
0 !== previousPriority && 4 > previousPriority ? previousPriority : 4;
setPending(!0);
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setPending(!1), callback();
} finally {
@@ -3819,47 +3882,38 @@ function startTransition(setPending, callback) {
(ReactCurrentBatchConfig$1.transition = prevTransition);
}
}
-function dispatchAction(fiber, queue, action) {
- var eventTime = requestEventTime(),
- lane = requestUpdateLane(fiber),
+function updateId() {
+ return updateWorkInProgressHook().memoizedState;
+}
+function dispatchReducerAction(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber);
+ action = {
+ lane: lane,
+ action: action,
+ hasEagerState: !1,
+ eagerState: null,
+ next: null
+ };
+ isRenderPhaseUpdate(fiber)
+ ? enqueueRenderPhaseUpdate(queue, action)
+ : (enqueueUpdate$1(fiber, queue, action),
+ (action = requestEventTime()),
+ (fiber = scheduleUpdateOnFiber(fiber, lane, action)),
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane));
+}
+function dispatchSetState(fiber, queue, action) {
+ var lane = requestUpdateLane(fiber),
update = {
lane: lane,
action: action,
- eagerReducer: null,
+ hasEagerState: !1,
eagerState: null,
next: null
- },
- alternate = fiber.alternate;
- if (
- fiber === currentlyRenderingFiber$1 ||
- (null !== alternate && alternate === currentlyRenderingFiber$1)
- )
- (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0),
- (lane = queue.pending),
- null === lane
- ? (update.next = update)
- : ((update.next = lane.next), (lane.next = update)),
- (queue.pending = update);
+ };
+ if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update);
else {
- if (
- null !== workInProgressRoot &&
- 0 !== (fiber.mode & 1) &&
- 0 === (executionContext & 8)
- ) {
- var interleaved = queue.interleaved;
- null === interleaved
- ? ((update.next = update),
- null === interleavedQueues
- ? (interleavedQueues = [queue])
- : interleavedQueues.push(queue))
- : ((update.next = interleaved.next), (interleaved.next = update));
- queue.interleaved = update;
- } else
- (interleaved = queue.pending),
- null === interleaved
- ? (update.next = update)
- : ((update.next = interleaved.next), (interleaved.next = update)),
- (queue.pending = update);
+ enqueueUpdate$1(fiber, queue, update);
+ var alternate = fiber.alternate;
if (
0 === fiber.lanes &&
(null === alternate || 0 === alternate.lanes) &&
@@ -3868,20 +3922,57 @@ function dispatchAction(fiber, queue, action) {
try {
var currentState = queue.lastRenderedState,
eagerState = alternate(currentState, action);
- update.eagerReducer = alternate;
+ update.hasEagerState = !0;
update.eagerState = eagerState;
if (objectIs(eagerState, currentState)) return;
} catch (error) {
} finally {
}
- update = scheduleUpdateOnFiber(fiber, lane, eventTime);
- 0 !== (lane & 4194240) &&
- null !== update &&
- ((fiber = queue.lanes),
- (fiber &= update.pendingLanes),
- (lane |= fiber),
- (queue.lanes = lane),
- markRootEntangled(update, lane));
+ action = requestEventTime();
+ fiber = scheduleUpdateOnFiber(fiber, lane, action);
+ null !== fiber && entangleTransitionUpdate(fiber, queue, lane);
+ }
+}
+function isRenderPhaseUpdate(fiber) {
+ var alternate = fiber.alternate;
+ return (
+ fiber === currentlyRenderingFiber$1 ||
+ (null !== alternate && alternate === currentlyRenderingFiber$1)
+ );
+}
+function enqueueRenderPhaseUpdate(queue, update) {
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0;
+ var pending = queue.pending;
+ null === pending
+ ? (update.next = update)
+ : ((update.next = pending.next), (pending.next = update));
+ queue.pending = update;
+}
+function enqueueUpdate$1(fiber, queue, update) {
+ null !== workInProgressRoot &&
+ 0 !== (fiber.mode & 1) &&
+ 0 === (executionContext & 2)
+ ? ((fiber = queue.interleaved),
+ null === fiber
+ ? ((update.next = update),
+ null === interleavedQueues
+ ? (interleavedQueues = [queue])
+ : interleavedQueues.push(queue))
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.interleaved = update))
+ : ((fiber = queue.pending),
+ null === fiber
+ ? (update.next = update)
+ : ((update.next = fiber.next), (fiber.next = update)),
+ (queue.pending = update));
+}
+function entangleTransitionUpdate(root, queue, lane) {
+ if (0 !== (lane & 4194240)) {
+ var queueLanes = queue.lanes;
+ queueLanes &= root.pendingLanes;
+ lane |= queueLanes;
+ queue.lanes = lane;
+ markRootEntangled(root, lane);
}
}
var ContextOnlyDispatcher = {
@@ -3890,6 +3981,7 @@ var ContextOnlyDispatcher = {
useContext: throwInvalidHookError,
useEffect: throwInvalidHookError,
useImperativeHandle: throwInvalidHookError,
+ useInsertionEffect: throwInvalidHookError,
useLayoutEffect: throwInvalidHookError,
useMemo: throwInvalidHookError,
useReducer: throwInvalidHookError,
@@ -3899,7 +3991,8 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
- useOpaqueIdentifier: throwInvalidHookError,
+ useSyncExternalStore: throwInvalidHookError,
+ useId: throwInvalidHookError,
unstable_isNewReconciler: !1
},
HooksDispatcherOnMount = {
@@ -3917,12 +4010,15 @@ var ContextOnlyDispatcher = {
deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null;
return mountEffectImpl(
4,
- 2,
+ 4,
imperativeHandleEffect.bind(null, create, ref),
deps
);
},
useLayoutEffect: function(create, deps) {
+ return mountEffectImpl(4, 4, create, deps);
+ },
+ useInsertionEffect: function(create, deps) {
return mountEffectImpl(4, 2, create, deps);
},
useMemo: function(nextCreate, deps) {
@@ -3936,7 +4032,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
- reducer = hook.queue = {
+ reducer = {
pending: null,
interleaved: null,
lanes: 0,
@@ -3944,7 +4040,8 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
- reducer = reducer.dispatch = dispatchAction.bind(
+ hook.queue = reducer;
+ reducer = reducer.dispatch = dispatchReducerAction.bind(
null,
currentlyRenderingFiber$1,
reducer
@@ -3965,7 +4062,7 @@ var ContextOnlyDispatcher = {
mountEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -3983,17 +4080,39 @@ var ContextOnlyDispatcher = {
mountWorkInProgressHook().memoizedState = _mountState2;
return [isPending, _mountState2];
},
- 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);
+ useMutableSource: function() {},
+ useSyncExternalStore: function(subscribe, getSnapshot) {
+ var fiber = currentlyRenderingFiber$1,
+ hook = mountWorkInProgressHook();
+ var nextSnapshot = getSnapshot();
+ if (null === workInProgressRoot)
+ throw Error(
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
+ );
+ 0 !== (renderLanes & 30) ||
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
+ hook.memoizedState = nextSnapshot;
+ var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
+ hook.queue = inst;
+ mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [
+ subscribe
+ ]);
+ fiber.flags |= 2048;
+ pushEffect(
+ 9,
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
+ void 0,
+ null
+ );
+ return nextSnapshot;
},
- useOpaqueIdentifier: function() {
- throw Error("Not yet implemented");
+ useId: function() {
+ var hook = mountWorkInProgressHook(),
+ identifierPrefix = workInProgressRoot.identifierPrefix,
+ globalClientId = globalClientIdCounter++;
+ identifierPrefix =
+ ":" + identifierPrefix + "r" + globalClientId.toString(32) + ":";
+ return (hook.memoizedState = identifierPrefix);
},
unstable_isNewReconciler: !1
},
@@ -4003,6 +4122,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: updateReducer,
@@ -4018,7 +4138,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -4035,9 +4155,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return updateReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
},
HooksDispatcherOnRerender = {
@@ -4046,6 +4165,7 @@ var ContextOnlyDispatcher = {
useContext: readContext,
useEffect: updateEffect,
useImperativeHandle: updateImperativeHandle,
+ useInsertionEffect: updateInsertionEffect,
useLayoutEffect: updateLayoutEffect,
useMemo: updateMemo,
useReducer: rerenderReducer,
@@ -4061,7 +4181,7 @@ var ContextOnlyDispatcher = {
updateEffect(
function() {
var prevTransition = ReactCurrentBatchConfig$1.transition;
- ReactCurrentBatchConfig$1.transition = 1;
+ ReactCurrentBatchConfig$1.transition = {};
try {
setValue(value);
} finally {
@@ -4078,9 +4198,8 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
- useOpaqueIdentifier: function() {
- return rerenderReducer(basicStateReducer)[0];
- },
+ useSyncExternalStore: updateSyncExternalStore,
+ useId: updateId,
unstable_isNewReconciler: !1
},
now$1 = Scheduler.unstable_now,
@@ -4189,19 +4308,21 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
if ("function" === typeof getDerivedStateFromError) {
var error = errorInfo.value;
lane.payload = function() {
- logCapturedError(fiber, errorInfo);
return getDerivedStateFromError(error);
};
+ lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
+ };
}
var inst = fiber.stateNode;
null !== inst &&
"function" === typeof inst.componentDidCatch &&
(lane.callback = function() {
+ logCapturedError(fiber, errorInfo);
"function" !== typeof getDerivedStateFromError &&
(null === legacyErrorBoundariesThatAlreadyFailed
? (legacyErrorBoundariesThatAlreadyFailed = new Set([this]))
- : legacyErrorBoundariesThatAlreadyFailed.add(this),
- logCapturedError(fiber, errorInfo));
+ : legacyErrorBoundariesThatAlreadyFailed.add(this));
var stack = errorInfo.stack;
this.componentDidCatch(errorInfo.value, {
componentStack: null !== stack ? stack : ""
@@ -4209,21 +4330,468 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
});
return lane;
}
-var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
- didReceiveUpdate = !1;
-function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
- workInProgress.child =
- null === current
- ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
- : reconcileChildFibers(
- workInProgress,
- current.child,
- nextChildren,
- renderLanes
- );
+function attachPingListener(root, wakeable, lanes) {
+ var pingCache = root.pingCache;
+ if (null === pingCache) {
+ pingCache = root.pingCache = new PossiblyWeakMap();
+ var threadIDs = new Set();
+ pingCache.set(wakeable, threadIDs);
+ } else
+ (threadIDs = pingCache.get(wakeable)),
+ void 0 === threadIDs &&
+ ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs));
+ threadIDs.has(lanes) ||
+ (threadIDs.add(lanes),
+ (pingCache = pingSuspendedRoot.bind(null, root, wakeable, lanes)),
+ isDevToolsPresent && restorePendingUpdaters(root, lanes),
+ wakeable.then(pingCache, pingCache));
+}
+var appendAllChildren, updateHostContainer, updateHostComponent, updateHostText;
+appendAllChildren = function(parent, workInProgress) {
+ for (var node = workInProgress.child; null !== node; ) {
+ if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode);
+ else if (4 !== node.tag && null !== node.child) {
+ node.child.return = node;
+ node = node.child;
+ continue;
+ }
+ if (node === workInProgress) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === workInProgress) return;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+};
+updateHostContainer = function() {};
+updateHostComponent = function(current, workInProgress, type, newProps) {
+ current.memoizedProps !== newProps &&
+ (requiredContext(contextStackCursor$1.current),
+ (workInProgress.updateQueue = UPDATE_SIGNAL)) &&
+ (workInProgress.flags |= 4);
+};
+updateHostText = function(current, workInProgress, oldText, newText) {
+ oldText !== newText && (workInProgress.flags |= 4);
+};
+function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
+ switch (renderState.tailMode) {
+ case "hidden":
+ hasRenderedATailFallback = renderState.tail;
+ for (var lastTailNode = null; null !== hasRenderedATailFallback; )
+ null !== hasRenderedATailFallback.alternate &&
+ (lastTailNode = hasRenderedATailFallback),
+ (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
+ null === lastTailNode
+ ? (renderState.tail = null)
+ : (lastTailNode.sibling = null);
+ break;
+ case "collapsed":
+ lastTailNode = renderState.tail;
+ for (var lastTailNode$37 = null; null !== lastTailNode; )
+ null !== lastTailNode.alternate && (lastTailNode$37 = lastTailNode),
+ (lastTailNode = lastTailNode.sibling);
+ null === lastTailNode$37
+ ? hasRenderedATailFallback || null === renderState.tail
+ ? (renderState.tail = null)
+ : (renderState.tail.sibling = null)
+ : (lastTailNode$37.sibling = null);
+ }
}
-function updateForwardRef(
- current,
+function bubbleProperties(completedWork) {
+ var didBailout =
+ null !== completedWork.alternate &&
+ completedWork.alternate.child === completedWork.child,
+ newChildLanes = 0,
+ subtreeFlags = 0;
+ if (didBailout)
+ if (0 !== (completedWork.mode & 2)) {
+ for (
+ var treeBaseDuration$39 = completedWork.selfBaseDuration,
+ child$40 = completedWork.child;
+ null !== child$40;
+
+ )
+ (newChildLanes |= child$40.lanes | child$40.childLanes),
+ (subtreeFlags |= child$40.subtreeFlags & 14680064),
+ (subtreeFlags |= child$40.flags & 14680064),
+ (treeBaseDuration$39 += child$40.treeBaseDuration),
+ (child$40 = child$40.sibling);
+ completedWork.treeBaseDuration = treeBaseDuration$39;
+ } else
+ for (
+ treeBaseDuration$39 = completedWork.child;
+ null !== treeBaseDuration$39;
+
+ )
+ (newChildLanes |=
+ treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes),
+ (subtreeFlags |= treeBaseDuration$39.subtreeFlags & 14680064),
+ (subtreeFlags |= treeBaseDuration$39.flags & 14680064),
+ (treeBaseDuration$39.return = completedWork),
+ (treeBaseDuration$39 = treeBaseDuration$39.sibling);
+ else if (0 !== (completedWork.mode & 2)) {
+ treeBaseDuration$39 = completedWork.actualDuration;
+ child$40 = completedWork.selfBaseDuration;
+ for (var child = completedWork.child; null !== child; )
+ (newChildLanes |= child.lanes | child.childLanes),
+ (subtreeFlags |= child.subtreeFlags),
+ (subtreeFlags |= child.flags),
+ (treeBaseDuration$39 += child.actualDuration),
+ (child$40 += child.treeBaseDuration),
+ (child = child.sibling);
+ completedWork.actualDuration = treeBaseDuration$39;
+ completedWork.treeBaseDuration = child$40;
+ } else
+ for (
+ treeBaseDuration$39 = completedWork.child;
+ null !== treeBaseDuration$39;
+
+ )
+ (newChildLanes |=
+ treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes),
+ (subtreeFlags |= treeBaseDuration$39.subtreeFlags),
+ (subtreeFlags |= treeBaseDuration$39.flags),
+ (treeBaseDuration$39.return = completedWork),
+ (treeBaseDuration$39 = treeBaseDuration$39.sibling);
+ completedWork.subtreeFlags |= subtreeFlags;
+ completedWork.childLanes = newChildLanes;
+ return didBailout;
+}
+function completeWork(current, workInProgress, renderLanes) {
+ var newProps = workInProgress.pendingProps;
+ popTreeContext(workInProgress);
+ switch (workInProgress.tag) {
+ case 2:
+ case 16:
+ case 15:
+ case 0:
+ case 11:
+ case 7:
+ case 8:
+ case 12:
+ case 9:
+ case 14:
+ return bubbleProperties(workInProgress), null;
+ case 1:
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 3:
+ return (
+ (newProps = workInProgress.stateNode),
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ newProps.pendingContext &&
+ ((newProps.context = newProps.pendingContext),
+ (newProps.pendingContext = null)),
+ (null !== current && null !== current.child) ||
+ null === current ||
+ (current.memoizedState.isDehydrated &&
+ 0 === (workInProgress.flags & 256)) ||
+ (workInProgress.flags |= 1024),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 5:
+ popHostContext(workInProgress);
+ renderLanes = requiredContext(rootInstanceStackCursor.current);
+ var type = workInProgress.type;
+ if (null !== current && null != workInProgress.stateNode)
+ updateHostComponent(
+ current,
+ workInProgress,
+ type,
+ newProps,
+ renderLanes
+ ),
+ current.ref !== workInProgress.ref && (workInProgress.flags |= 512);
+ else {
+ if (!newProps) {
+ if (null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ }
+ requiredContext(contextStackCursor$1.current);
+ current = allocateTag();
+ type = getViewConfigForType(type);
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ newProps,
+ type.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.createView(
+ current,
+ type.uiViewClassName,
+ renderLanes,
+ updatePayload
+ );
+ renderLanes = new ReactNativeFiberHostComponent(
+ current,
+ type,
+ workInProgress
+ );
+ instanceCache.set(current, workInProgress);
+ instanceProps.set(current, newProps);
+ appendAllChildren(renderLanes, workInProgress, !1, !1);
+ workInProgress.stateNode = renderLanes;
+ finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4);
+ null !== workInProgress.ref && (workInProgress.flags |= 512);
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 6:
+ if (current && null != workInProgress.stateNode)
+ updateHostText(
+ current,
+ workInProgress,
+ current.memoizedProps,
+ newProps
+ );
+ else {
+ if ("string" !== typeof newProps && null === workInProgress.stateNode)
+ throw Error(
+ "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
+ );
+ current = requiredContext(rootInstanceStackCursor.current);
+ if (!requiredContext(contextStackCursor$1.current).isInAParentText)
+ throw Error(
+ "Text strings must be rendered within a component."
+ );
+ renderLanes = allocateTag();
+ ReactNativePrivateInterface.UIManager.createView(
+ renderLanes,
+ "RCTRawText",
+ current,
+ { text: newProps }
+ );
+ instanceCache.set(renderLanes, workInProgress);
+ workInProgress.stateNode = renderLanes;
+ }
+ bubbleProperties(workInProgress);
+ return null;
+ case 13:
+ pop(suspenseStackCursor);
+ newProps = workInProgress.memoizedState;
+ if (0 !== (workInProgress.flags & 128))
+ return (
+ (workInProgress.lanes = renderLanes),
+ 0 !== (workInProgress.mode & 2) &&
+ transferActualDuration(workInProgress),
+ workInProgress
+ );
+ newProps = null !== newProps;
+ renderLanes = !1;
+ null !== current && (renderLanes = null !== current.memoizedState);
+ newProps &&
+ !renderLanes &&
+ ((workInProgress.child.flags |= 8192),
+ 0 !== (workInProgress.mode & 1) &&
+ (null === current || 0 !== (suspenseStackCursor.current & 1)
+ ? 0 === workInProgressRootExitStatus &&
+ (workInProgressRootExitStatus = 3)
+ : renderDidSuspendDelayIfPossible()));
+ null !== workInProgress.updateQueue && (workInProgress.flags |= 4);
+ bubbleProperties(workInProgress);
+ 0 !== (workInProgress.mode & 2) &&
+ newProps &&
+ ((current = workInProgress.child),
+ null !== current &&
+ (workInProgress.treeBaseDuration -= current.treeBaseDuration));
+ return null;
+ case 4:
+ return (
+ popHostContainer(),
+ updateHostContainer(current, workInProgress),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 10:
+ return (
+ popProvider(workInProgress.type._context),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 17:
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ bubbleProperties(workInProgress),
+ null
+ );
+ case 19:
+ pop(suspenseStackCursor);
+ type = workInProgress.memoizedState;
+ if (null === type) return bubbleProperties(workInProgress), null;
+ newProps = 0 !== (workInProgress.flags & 128);
+ updatePayload = type.rendering;
+ if (null === updatePayload)
+ if (newProps) cutOffTailIfNeeded(type, !1);
+ else {
+ if (
+ 0 !== workInProgressRootExitStatus ||
+ (null !== current && 0 !== (current.flags & 128))
+ )
+ for (current = workInProgress.child; null !== current; ) {
+ updatePayload = findFirstSuspended(current);
+ if (null !== updatePayload) {
+ workInProgress.flags |= 128;
+ cutOffTailIfNeeded(type, !1);
+ current = updatePayload.updateQueue;
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4));
+ workInProgress.subtreeFlags = 0;
+ current = renderLanes;
+ for (newProps = workInProgress.child; null !== newProps; )
+ (renderLanes = newProps),
+ (updatePayload = current),
+ (renderLanes.flags &= 14680066),
+ (type = renderLanes.alternate),
+ null === type
+ ? ((renderLanes.childLanes = 0),
+ (renderLanes.lanes = updatePayload),
+ (renderLanes.child = null),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.memoizedProps = null),
+ (renderLanes.memoizedState = null),
+ (renderLanes.updateQueue = null),
+ (renderLanes.dependencies = null),
+ (renderLanes.stateNode = null),
+ (renderLanes.selfBaseDuration = 0),
+ (renderLanes.treeBaseDuration = 0))
+ : ((renderLanes.childLanes = type.childLanes),
+ (renderLanes.lanes = type.lanes),
+ (renderLanes.child = type.child),
+ (renderLanes.subtreeFlags = 0),
+ (renderLanes.deletions = null),
+ (renderLanes.memoizedProps = type.memoizedProps),
+ (renderLanes.memoizedState = type.memoizedState),
+ (renderLanes.updateQueue = type.updateQueue),
+ (renderLanes.type = type.type),
+ (updatePayload = type.dependencies),
+ (renderLanes.dependencies =
+ null === updatePayload
+ ? null
+ : {
+ lanes: updatePayload.lanes,
+ firstContext: updatePayload.firstContext
+ }),
+ (renderLanes.selfBaseDuration = type.selfBaseDuration),
+ (renderLanes.treeBaseDuration = type.treeBaseDuration)),
+ (newProps = newProps.sibling);
+ push(
+ suspenseStackCursor,
+ (suspenseStackCursor.current & 1) | 2
+ );
+ return workInProgress.child;
+ }
+ current = current.sibling;
+ }
+ null !== type.tail &&
+ now() > workInProgressRootRenderTargetTime &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ }
+ else {
+ if (!newProps)
+ if (
+ ((current = findFirstSuspended(updatePayload)), null !== current)
+ ) {
+ if (
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ (current = current.updateQueue),
+ null !== current &&
+ ((workInProgress.updateQueue = current),
+ (workInProgress.flags |= 4)),
+ cutOffTailIfNeeded(type, !0),
+ null === type.tail &&
+ "hidden" === type.tailMode &&
+ !updatePayload.alternate)
+ )
+ return bubbleProperties(workInProgress), null;
+ } else
+ 2 * now() - type.renderingStartTime >
+ workInProgressRootRenderTargetTime &&
+ 1073741824 !== renderLanes &&
+ ((workInProgress.flags |= 128),
+ (newProps = !0),
+ cutOffTailIfNeeded(type, !1),
+ (workInProgress.lanes = 4194304));
+ type.isBackwards
+ ? ((updatePayload.sibling = workInProgress.child),
+ (workInProgress.child = updatePayload))
+ : ((current = type.last),
+ null !== current
+ ? (current.sibling = updatePayload)
+ : (workInProgress.child = updatePayload),
+ (type.last = updatePayload));
+ }
+ if (null !== type.tail)
+ return (
+ (workInProgress = type.tail),
+ (type.rendering = workInProgress),
+ (type.tail = workInProgress.sibling),
+ (type.renderingStartTime = now()),
+ (workInProgress.sibling = null),
+ (current = suspenseStackCursor.current),
+ push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
+ workInProgress
+ );
+ bubbleProperties(workInProgress);
+ return null;
+ case 22:
+ case 23:
+ return (
+ popRenderLanes(),
+ (newProps = null !== workInProgress.memoizedState),
+ null !== current &&
+ (null !== current.memoizedState) !== newProps &&
+ (workInProgress.flags |= 8192),
+ newProps && 0 !== (workInProgress.mode & 1)
+ ? 0 !== (subtreeRenderLanes & 1073741824) &&
+ (bubbleProperties(workInProgress),
+ workInProgress.subtreeFlags & 6 && (workInProgress.flags |= 8192))
+ : bubbleProperties(workInProgress),
+ null
+ );
+ case 24:
+ return null;
+ case 25:
+ return null;
+ }
+ throw Error(
+ "Unknown unit of work tag (" +
+ workInProgress.tag +
+ "). This error is likely caused by a bug in React. Please file an issue."
+ );
+}
+var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
+ didReceiveUpdate = !1;
+function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
+ workInProgress.child =
+ null === current
+ ? mountChildFibers(workInProgress, null, nextChildren, renderLanes)
+ : reconcileChildFibers(
+ workInProgress,
+ current.child,
+ nextChildren,
+ renderLanes
+ );
+}
+function updateForwardRef(
+ current,
workInProgress,
Component,
nextProps,
@@ -4243,7 +4811,7 @@ function updateForwardRef(
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
+ (workInProgress.flags &= -2053),
(current.lanes &= ~renderLanes),
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
@@ -4256,7 +4824,6 @@ function updateMemoComponent(
workInProgress,
Component,
nextProps,
- updateLanes,
renderLanes
) {
if (null === current) {
@@ -4276,7 +4843,6 @@ function updateMemoComponent(
workInProgress,
type,
nextProps,
- updateLanes,
renderLanes
)
);
@@ -4293,14 +4859,13 @@ function updateMemoComponent(
return (workInProgress.child = current);
}
type = current.child;
- if (
- 0 === (updateLanes & renderLanes) &&
- ((updateLanes = type.memoizedProps),
- (Component = Component.compare),
- (Component = null !== Component ? Component : shallowEqual),
- Component(updateLanes, nextProps) && current.ref === workInProgress.ref)
- )
- return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ if (0 === (current.lanes & renderLanes)) {
+ var prevProps = type.memoizedProps;
+ Component = Component.compare;
+ Component = null !== Component ? Component : shallowEqual;
+ if (Component(prevProps, nextProps) && current.ref === workInProgress.ref)
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
+ }
workInProgress.flags |= 1;
current = createWorkInProgress(type, nextProps);
current.ref = workInProgress.ref;
@@ -4312,22 +4877,20 @@ function updateSimpleMemoComponent(
workInProgress,
Component,
nextProps,
- updateLanes,
renderLanes
) {
if (
null !== current &&
shallowEqual(current.memoizedProps, nextProps) &&
current.ref === workInProgress.ref
- ) {
- didReceiveUpdate = !1;
- if (0 === (renderLanes & updateLanes))
+ )
+ if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes)))
+ 0 !== (current.flags & 131072) && (didReceiveUpdate = !0);
+ else
return (
(workInProgress.lanes = current.lanes),
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
- 0 !== (current.flags & 32768) && (didReceiveUpdate = !0);
- }
return updateFunctionComponent(
current,
workInProgress,
@@ -4340,10 +4903,7 @@ 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 ("hidden" === nextProps.mode)
if (0 === (workInProgress.mode & 1))
(workInProgress.memoizedState = { baseLanes: 0, cachePool: null }),
push(subtreeRenderLanesCursor, subtreeRenderLanes),
@@ -4380,13 +4940,13 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) {
reconcileChildren(current, workInProgress, nextChildren, renderLanes);
return workInProgress.child;
}
-function markRef(current, workInProgress) {
+function markRef$1(current, workInProgress) {
var ref = workInProgress.ref;
if (
(null === current && null !== ref) ||
(null !== current && current.ref !== ref)
)
- workInProgress.flags |= 256;
+ workInProgress.flags |= 512;
}
function updateFunctionComponent(
current,
@@ -4411,7 +4971,7 @@ function updateFunctionComponent(
if (null !== current && !didReceiveUpdate)
return (
(workInProgress.updateQueue = current.updateQueue),
- (workInProgress.flags &= -1029),
+ (workInProgress.flags &= -2053),
(current.lanes &= ~renderLanes),
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
);
@@ -4587,7 +5147,7 @@ function updateClassComponent(
"function" === typeof instance.componentDidUpdate &&
(workInProgress.flags |= 4),
"function" === typeof instance.getSnapshotBeforeUpdate &&
- (workInProgress.flags |= 512))
+ (workInProgress.flags |= 1024))
: ("function" !== typeof instance.componentDidUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
@@ -4595,7 +5155,7 @@ function updateClassComponent(
"function" !== typeof instance.getSnapshotBeforeUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
+ (workInProgress.flags |= 1024),
(workInProgress.memoizedProps = nextProps),
(workInProgress.memoizedState = newState)),
(instance.props = nextProps),
@@ -4609,7 +5169,7 @@ function updateClassComponent(
"function" !== typeof instance.getSnapshotBeforeUpdate ||
(oldProps === current.memoizedProps &&
oldState === current.memoizedState) ||
- (workInProgress.flags |= 512),
+ (workInProgress.flags |= 1024),
(nextProps = !1));
}
return finishClassComponent(
@@ -4629,7 +5189,7 @@ function finishClassComponent(
hasContext,
renderLanes
) {
- markRef(current, workInProgress);
+ markRef$1(current, workInProgress);
var didCaptureError = 0 !== (workInProgress.flags & 128);
if (!shouldUpdate && !didCaptureError)
return (
@@ -4677,7 +5237,7 @@ function pushHostRootContext(workInProgress) {
pushTopLevelContextObject(workInProgress, root.context, !1);
pushHostContainer(workInProgress, root.containerInfo);
}
-var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 };
+var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 };
function mountSuspenseOffscreenState(renderLanes) {
return { baseLanes: renderLanes, cachePool: null };
}
@@ -4691,49 +5251,52 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
null !== current && null === current.memoizedState
? !1
: 0 !== (suspenseContext & 2));
- JSCompiler_temp
- ? ((showFallback = !0), (workInProgress.flags &= -129))
- : (null !== current && null === current.memoizedState) ||
- void 0 === nextProps.fallback ||
- !0 === nextProps.unstable_avoidThisFallback ||
- (suspenseContext |= 1);
+ if (JSCompiler_temp) (showFallback = !0), (workInProgress.flags &= -129);
+ else if (null === current || null !== current.memoizedState)
+ suspenseContext |= 1;
push(suspenseStackCursor, suspenseContext & 1);
if (null === current) {
- current = nextProps.children;
- suspenseContext = nextProps.fallback;
+ suspenseContext = nextProps.children;
+ current = nextProps.fallback;
if (showFallback)
return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
- current,
- suspenseContext,
- renderLanes
- )),
- (workInProgress.child.memoizedState = mountSuspenseOffscreenState(
- renderLanes
- )),
- (workInProgress.memoizedState = SUSPENDED_MARKER),
- current
- );
- if ("number" === typeof nextProps.unstable_expectedLoadTime)
- return (
- (current = mountSuspenseFallbackChildren(
- workInProgress,
+ (showFallback = workInProgress.mode),
+ (nextProps = workInProgress.child),
+ (suspenseContext = { mode: "hidden", children: suspenseContext }),
+ 0 === (showFallback & 1) && null !== nextProps
+ ? ((nextProps.childLanes = 0),
+ (nextProps.pendingProps = suspenseContext),
+ workInProgress.mode & 2 &&
+ ((nextProps.actualDuration = 0),
+ (nextProps.actualStartTime = -1),
+ (nextProps.selfBaseDuration = 0),
+ (nextProps.treeBaseDuration = 0)))
+ : (nextProps = createFiberFromOffscreen(
+ suspenseContext,
+ showFallback,
+ 0,
+ null
+ )),
+ (current = createFiberFromFragment(
current,
- suspenseContext,
- renderLanes
+ showFallback,
+ renderLanes,
+ null
)),
+ (nextProps.return = workInProgress),
+ (current.return = workInProgress),
+ (nextProps.sibling = current),
+ (workInProgress.child = nextProps),
(workInProgress.child.memoizedState = mountSuspenseOffscreenState(
renderLanes
)),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- (workInProgress.lanes = 4194304),
current
);
renderLanes = createFiberFromOffscreen(
- { mode: "visible", children: current },
+ { mode: "visible", children: suspenseContext },
workInProgress.mode,
- renderLanes,
+ 0,
null
);
renderLanes.return = workInProgress;
@@ -4742,25 +5305,25 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
if (null !== current.memoizedState) {
if (showFallback)
return (
- (nextProps = updateSuspenseFallbackChildren(
+ (showFallback = updateSuspenseFallbackChildren(
current,
workInProgress,
nextProps.children,
nextProps.fallback,
renderLanes
)),
- (showFallback = workInProgress.child),
+ (nextProps = workInProgress.child),
(suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
+ (nextProps.memoizedState =
null === suspenseContext
? mountSuspenseOffscreenState(renderLanes)
: {
baseLanes: suspenseContext.baseLanes | renderLanes,
cachePool: null
}),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
+ showFallback
);
renderLanes = updateSuspensePrimaryChildren(
current,
@@ -4773,25 +5336,25 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
}
if (showFallback)
return (
- (nextProps = updateSuspenseFallbackChildren(
+ (showFallback = updateSuspenseFallbackChildren(
current,
workInProgress,
nextProps.children,
nextProps.fallback,
renderLanes
)),
- (showFallback = workInProgress.child),
+ (nextProps = workInProgress.child),
(suspenseContext = current.child.memoizedState),
- (showFallback.memoizedState =
+ (nextProps.memoizedState =
null === suspenseContext
? mountSuspenseOffscreenState(renderLanes)
: {
baseLanes: suspenseContext.baseLanes | renderLanes,
cachePool: null
}),
- (showFallback.childLanes = current.childLanes & ~renderLanes),
+ (nextProps.childLanes = current.childLanes & ~renderLanes),
(workInProgress.memoizedState = SUSPENDED_MARKER),
- nextProps
+ showFallback
);
renderLanes = updateSuspensePrimaryChildren(
current,
@@ -4802,41 +5365,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
workInProgress.memoizedState = null;
return renderLanes;
}
-function mountSuspenseFallbackChildren(
- workInProgress,
- primaryChildren,
- fallbackChildren,
- renderLanes
-) {
- var mode = workInProgress.mode,
- progressedPrimaryFragment = workInProgress.child;
- primaryChildren = { mode: "hidden", children: primaryChildren };
- 0 === (mode & 1) && null !== progressedPrimaryFragment
- ? ((progressedPrimaryFragment.childLanes = 0),
- (progressedPrimaryFragment.pendingProps = primaryChildren),
- workInProgress.mode & 2 &&
- ((progressedPrimaryFragment.actualDuration = 0),
- (progressedPrimaryFragment.actualStartTime = -1),
- (progressedPrimaryFragment.selfBaseDuration = 0),
- (progressedPrimaryFragment.treeBaseDuration = 0)))
- : (progressedPrimaryFragment = createFiberFromOffscreen(
- primaryChildren,
- mode,
- 0,
- null
- ));
- fallbackChildren = createFiberFromFragment(
- fallbackChildren,
- mode,
- renderLanes,
- null
- );
- progressedPrimaryFragment.return = workInProgress;
- fallbackChildren.return = workInProgress;
- progressedPrimaryFragment.sibling = fallbackChildren;
- workInProgress.child = progressedPrimaryFragment;
- return fallbackChildren;
-}
function updateSuspensePrimaryChildren(
current,
workInProgress,
@@ -4881,7 +5409,7 @@ function updateSuspenseFallbackChildren(
(primaryChildren.treeBaseDuration = current.treeBaseDuration)),
(workInProgress.deletions = null))
: ((primaryChildren = createWorkInProgress(current, primaryChildProps)),
- (primaryChildren.subtreeFlags = current.subtreeFlags & 1835008));
+ (primaryChildren.subtreeFlags = current.subtreeFlags & 14680064));
null !== currentFallbackChildFragment
? (fallbackChildren = createWorkInProgress(
currentFallbackChildFragment,
@@ -4900,11 +5428,11 @@ function updateSuspenseFallbackChildren(
workInProgress.child = primaryChildren;
return fallbackChildren;
}
-function scheduleWorkOnFiber(fiber, renderLanes) {
+function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) {
fiber.lanes |= renderLanes;
var alternate = fiber.alternate;
null !== alternate && (alternate.lanes |= renderLanes);
- scheduleWorkOnParentPath(fiber.return, renderLanes);
+ scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot);
}
function initSuspenseListRenderState(
workInProgress,
@@ -4943,8 +5471,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) {
a: for (current = workInProgress.child; null !== current; ) {
if (13 === current.tag)
null !== current.memoizedState &&
- scheduleWorkOnFiber(current, renderLanes);
- else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes);
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
+ else if (19 === current.tag)
+ scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress);
else if (null !== current.child) {
current.child.return = current;
current = current.child;
@@ -5024,492 +5553,127 @@ function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
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;
-}
-var appendAllChildren,
- updateHostContainer,
- updateHostComponent$1,
- updateHostText$1;
-appendAllChildren = function(parent, workInProgress) {
- for (var node = workInProgress.child; null !== node; ) {
- if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode);
- else if (4 !== node.tag && null !== node.child) {
- node.child.return = node;
- node = node.child;
- continue;
- }
- if (node === workInProgress) break;
- for (; null === node.sibling; ) {
- if (null === node.return || node.return === workInProgress) return;
- node = node.return;
- }
- node.sibling.return = node.return;
- node = node.sibling;
- }
-};
-updateHostContainer = function() {};
-updateHostComponent$1 = function(current, workInProgress, type, newProps) {
- current.memoizedProps !== newProps &&
- (requiredContext(contextStackCursor$1.current),
- (workInProgress.updateQueue = UPDATE_SIGNAL)) &&
- (workInProgress.flags |= 4);
-};
-updateHostText$1 = function(current, workInProgress, oldText, newText) {
- oldText !== newText && (workInProgress.flags |= 4);
-};
-function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
- switch (renderState.tailMode) {
- case "hidden":
- hasRenderedATailFallback = renderState.tail;
- for (var lastTailNode = null; null !== hasRenderedATailFallback; )
- null !== hasRenderedATailFallback.alternate &&
- (lastTailNode = hasRenderedATailFallback),
- (hasRenderedATailFallback = hasRenderedATailFallback.sibling);
- null === lastTailNode
- ? (renderState.tail = null)
- : (lastTailNode.sibling = null);
- break;
- case "collapsed":
- lastTailNode = renderState.tail;
- for (var lastTailNode$72 = null; null !== lastTailNode; )
- null !== lastTailNode.alternate && (lastTailNode$72 = lastTailNode),
- (lastTailNode = lastTailNode.sibling);
- null === lastTailNode$72
- ? hasRenderedATailFallback || null === renderState.tail
- ? (renderState.tail = null)
- : (renderState.tail.sibling = null)
- : (lastTailNode$72.sibling = null);
- }
-}
-function bubbleProperties(completedWork) {
- var didBailout =
- null !== completedWork.alternate &&
- completedWork.alternate.child === completedWork.child,
- newChildLanes = 0,
- subtreeFlags = 0;
- if (didBailout)
- if (0 !== (completedWork.mode & 2)) {
- for (
- var treeBaseDuration$74 = completedWork.selfBaseDuration,
- child$75 = completedWork.child;
- null !== child$75;
-
- )
- (newChildLanes |= child$75.lanes | child$75.childLanes),
- (subtreeFlags |= child$75.subtreeFlags & 1835008),
- (subtreeFlags |= child$75.flags & 1835008),
- (treeBaseDuration$74 += child$75.treeBaseDuration),
- (child$75 = child$75.sibling);
- completedWork.treeBaseDuration = treeBaseDuration$74;
- } else
- for (
- treeBaseDuration$74 = completedWork.child;
- null !== treeBaseDuration$74;
-
- )
- (newChildLanes |=
- treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes),
- (subtreeFlags |= treeBaseDuration$74.subtreeFlags & 1835008),
- (subtreeFlags |= treeBaseDuration$74.flags & 1835008),
- (treeBaseDuration$74.return = completedWork),
- (treeBaseDuration$74 = treeBaseDuration$74.sibling);
- else if (0 !== (completedWork.mode & 2)) {
- treeBaseDuration$74 = completedWork.actualDuration;
- child$75 = completedWork.selfBaseDuration;
- for (var child = completedWork.child; null !== child; )
- (newChildLanes |= child.lanes | child.childLanes),
- (subtreeFlags |= child.subtreeFlags),
- (subtreeFlags |= child.flags),
- (treeBaseDuration$74 += child.actualDuration),
- (child$75 += child.treeBaseDuration),
- (child = child.sibling);
- completedWork.actualDuration = treeBaseDuration$74;
- completedWork.treeBaseDuration = child$75;
- } else
- for (
- treeBaseDuration$74 = completedWork.child;
- null !== treeBaseDuration$74;
-
- )
- (newChildLanes |=
- treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes),
- (subtreeFlags |= treeBaseDuration$74.subtreeFlags),
- (subtreeFlags |= treeBaseDuration$74.flags),
- (treeBaseDuration$74.return = completedWork),
- (treeBaseDuration$74 = treeBaseDuration$74.sibling);
- completedWork.subtreeFlags |= subtreeFlags;
- completedWork.childLanes = newChildLanes;
- return didBailout;
-}
-function completeWork(current, workInProgress, renderLanes) {
- var newProps = workInProgress.pendingProps;
- switch (workInProgress.tag) {
- case 2:
- case 16:
- case 15:
- case 0:
- case 11:
- case 7:
- case 8:
- case 12:
- case 9:
- case 14:
- return bubbleProperties(workInProgress), null;
- case 1:
- return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
- );
- case 3:
- return (
- (newProps = workInProgress.stateNode),
- popHostContainer(),
- pop(didPerformWorkStackCursor),
- pop(contextStackCursor),
- resetWorkInProgressVersions(),
- newProps.pendingContext &&
- ((newProps.context = newProps.pendingContext),
- (newProps.pendingContext = null)),
- (null !== current && null !== current.child) ||
- newProps.hydrate ||
- (workInProgress.flags |= 512),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
- case 5:
- popHostContext(workInProgress);
- renderLanes = requiredContext(rootInstanceStackCursor.current);
- var type = workInProgress.type;
- if (null !== current && null != workInProgress.stateNode)
- updateHostComponent$1(
- current,
- workInProgress,
- type,
- newProps,
- renderLanes
- ),
- current.ref !== workInProgress.ref && (workInProgress.flags |= 256);
- else {
- if (!newProps) {
- if (null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- bubbleProperties(workInProgress);
- return null;
- }
- requiredContext(contextStackCursor$1.current);
- current = allocateTag();
- type = getViewConfigForType(type);
- var updatePayload = diffProperties(
- null,
- emptyObject,
- newProps,
- type.validAttributes
- );
- ReactNativePrivateInterface.UIManager.createView(
- current,
- type.uiViewClassName,
- renderLanes,
- updatePayload
- );
- renderLanes = new ReactNativeFiberHostComponent(
+ 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,
- type,
- workInProgress
- );
- instanceCache.set(current, workInProgress);
- instanceProps.set(current, newProps);
- appendAllChildren(renderLanes, workInProgress, !1, !1);
- workInProgress.stateNode = renderLanes;
- finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4);
- null !== workInProgress.ref && (workInProgress.flags |= 256);
- }
- bubbleProperties(workInProgress);
- return null;
- case 6:
- if (current && null != workInProgress.stateNode)
- updateHostText$1(
+ current.pendingProps
+ )),
+ (renderLanes.return = workInProgress);
+ renderLanes.sibling = null;
+ }
+ return workInProgress.child;
+}
+function attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+) {
+ 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:
+ var context = workInProgress.type._context,
+ nextValue = workInProgress.memoizedProps.value;
+ push(valueCursor, context._currentValue);
+ context._currentValue = nextValue;
+ break;
+ case 12:
+ 0 !== (renderLanes & workInProgress.childLanes) &&
+ (workInProgress.flags |= 4);
+ context = workInProgress.stateNode;
+ context.effectDuration = 0;
+ context.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);
+ current = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
- current.memoizedProps,
- newProps
- );
- else {
- if ("string" !== typeof newProps && null === workInProgress.stateNode)
- throw Error(
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
- );
- current = requiredContext(rootInstanceStackCursor.current);
- if (!requiredContext(contextStackCursor$1.current).isInAParentText)
- throw Error(
- "Text strings must be rendered within a component."
- );
- renderLanes = allocateTag();
- ReactNativePrivateInterface.UIManager.createView(
- renderLanes,
- "RCTRawText",
- current,
- { text: newProps }
+ renderLanes
);
- instanceCache.set(renderLanes, workInProgress);
- workInProgress.stateNode = renderLanes;
+ return null !== current ? current.sibling : null;
}
- bubbleProperties(workInProgress);
- return null;
- case 13:
- pop(suspenseStackCursor);
- newProps = workInProgress.memoizedState;
- if (0 !== (workInProgress.flags & 128))
- return (
- (workInProgress.lanes = renderLanes),
- 0 !== (workInProgress.mode & 2) &&
- transferActualDuration(workInProgress),
- workInProgress
- );
- newProps = null !== newProps;
- renderLanes = !1;
- null !== current && (renderLanes = null !== current.memoizedState);
- if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1))
- if (
- (null === current &&
- !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) ||
- 0 !== (suspenseStackCursor.current & 1)
- )
- 0 === workInProgressRootExitStatus &&
- (workInProgressRootExitStatus = 3);
- else {
- if (
- 0 === workInProgressRootExitStatus ||
- 3 === workInProgressRootExitStatus
- )
- workInProgressRootExitStatus = 4;
- null === workInProgressRoot ||
- (0 === (workInProgressRootSkippedLanes & 268435455) &&
- 0 === (workInProgressRootUpdatedLanes & 268435455)) ||
- markRootSuspended$1(
- workInProgressRoot,
- workInProgressRootRenderLanes
- );
- }
- if (newProps || renderLanes) workInProgress.flags |= 4;
- bubbleProperties(workInProgress);
- 0 !== (workInProgress.mode & 2) &&
- newProps &&
- ((current = workInProgress.child),
- null !== current &&
- (workInProgress.treeBaseDuration -= current.treeBaseDuration));
- return null;
- case 4:
- return (
- popHostContainer(),
- updateHostContainer(current, workInProgress),
- bubbleProperties(workInProgress),
- null
- );
- case 10:
- return (
- popProvider(workInProgress.type._context),
- bubbleProperties(workInProgress),
- null
- );
- case 17:
- return (
- isContextProvider(workInProgress.type) && popContext(),
- bubbleProperties(workInProgress),
- null
- );
+ push(suspenseStackCursor, suspenseStackCursor.current & 1);
+ break;
case 19:
- pop(suspenseStackCursor);
- type = workInProgress.memoizedState;
- if (null === type) return bubbleProperties(workInProgress), null;
- newProps = 0 !== (workInProgress.flags & 128);
- updatePayload = type.rendering;
- if (null === updatePayload)
- if (newProps) cutOffTailIfNeeded(type, !1);
- else {
- if (
- 0 !== workInProgressRootExitStatus ||
- (null !== current && 0 !== (current.flags & 128))
- )
- for (current = workInProgress.child; null !== current; ) {
- updatePayload = findFirstSuspended(current);
- if (null !== updatePayload) {
- workInProgress.flags |= 128;
- cutOffTailIfNeeded(type, !1);
- current = updatePayload.updateQueue;
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4));
- workInProgress.subtreeFlags = 0;
- current = renderLanes;
- for (newProps = workInProgress.child; null !== newProps; )
- (renderLanes = newProps),
- (updatePayload = current),
- (renderLanes.flags &= 1835010),
- (type = renderLanes.alternate),
- null === type
- ? ((renderLanes.childLanes = 0),
- (renderLanes.lanes = updatePayload),
- (renderLanes.child = null),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.memoizedProps = null),
- (renderLanes.memoizedState = null),
- (renderLanes.updateQueue = null),
- (renderLanes.dependencies = null),
- (renderLanes.stateNode = null),
- (renderLanes.selfBaseDuration = 0),
- (renderLanes.treeBaseDuration = 0))
- : ((renderLanes.childLanes = type.childLanes),
- (renderLanes.lanes = type.lanes),
- (renderLanes.child = type.child),
- (renderLanes.subtreeFlags = 0),
- (renderLanes.deletions = null),
- (renderLanes.memoizedProps = type.memoizedProps),
- (renderLanes.memoizedState = type.memoizedState),
- (renderLanes.updateQueue = type.updateQueue),
- (renderLanes.type = type.type),
- (updatePayload = type.dependencies),
- (renderLanes.dependencies =
- null === updatePayload
- ? null
- : {
- lanes: updatePayload.lanes,
- firstContext: updatePayload.firstContext
- }),
- (renderLanes.selfBaseDuration = type.selfBaseDuration),
- (renderLanes.treeBaseDuration = type.treeBaseDuration)),
- (newProps = newProps.sibling);
- push(
- suspenseStackCursor,
- (suspenseStackCursor.current & 1) | 2
- );
- return workInProgress.child;
- }
- current = current.sibling;
- }
- null !== type.tail &&
- now() > workInProgressRootRenderTargetTime &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
- }
- else {
- if (!newProps)
- if (
- ((current = findFirstSuspended(updatePayload)), null !== current)
- ) {
- if (
- ((workInProgress.flags |= 128),
- (newProps = !0),
- (current = current.updateQueue),
- null !== current &&
- ((workInProgress.updateQueue = current),
- (workInProgress.flags |= 4)),
- cutOffTailIfNeeded(type, !0),
- null === type.tail &&
- "hidden" === type.tailMode &&
- !updatePayload.alternate)
- )
- return bubbleProperties(workInProgress), null;
- } else
- 2 * now() - type.renderingStartTime >
- workInProgressRootRenderTargetTime &&
- 1073741824 !== renderLanes &&
- ((workInProgress.flags |= 128),
- (newProps = !0),
- cutOffTailIfNeeded(type, !1),
- (workInProgress.lanes = 4194304));
- type.isBackwards
- ? ((updatePayload.sibling = workInProgress.child),
- (workInProgress.child = updatePayload))
- : ((current = type.last),
- null !== current
- ? (current.sibling = updatePayload)
- : (workInProgress.child = updatePayload),
- (type.last = updatePayload));
+ context = 0 !== (renderLanes & workInProgress.childLanes);
+ if (0 !== (current.flags & 128)) {
+ if (context)
+ return updateSuspenseListComponent(
+ current,
+ workInProgress,
+ renderLanes
+ );
+ workInProgress.flags |= 128;
}
- if (null !== type.tail)
- return (
- (workInProgress = type.tail),
- (type.rendering = workInProgress),
- (type.tail = workInProgress.sibling),
- (type.renderingStartTime = now()),
- (workInProgress.sibling = null),
- (current = suspenseStackCursor.current),
- push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1),
- workInProgress
- );
- bubbleProperties(workInProgress);
- return null;
+ nextValue = workInProgress.memoizedState;
+ null !== nextValue &&
+ ((nextValue.rendering = null),
+ (nextValue.tail = null),
+ (nextValue.lastEffect = null));
+ push(suspenseStackCursor, suspenseStackCursor.current);
+ if (context) break;
+ else return null;
case 22:
case 23:
return (
- popRenderLanes(),
- (renderLanes = null !== workInProgress.memoizedState),
- null !== current &&
- (null !== current.memoizedState) !== renderLanes &&
- "unstable-defer-without-hiding" !== newProps.mode &&
- (workInProgress.flags |= 4),
- (renderLanes &&
- 0 === (subtreeRenderLanes & 1073741824) &&
- 0 !== (workInProgress.mode & 1)) ||
- bubbleProperties(workInProgress),
- null
+ (workInProgress.lanes = 0),
+ updateOffscreenComponent(current, workInProgress, renderLanes)
);
}
- throw Error(
- "Unknown unit of work tag (" +
- workInProgress.tag +
- "). This error is likely caused by a bug in React. Please file an issue."
- );
+ return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
}
-function unwindWork(workInProgress) {
+function unwindWork(current, workInProgress) {
+ popTreeContext(workInProgress);
switch (workInProgress.tag) {
case 1:
- isContextProvider(workInProgress.type) && popContext();
- var flags = workInProgress.flags;
- return flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128),
- 0 !== (workInProgress.mode & 2) &&
- transferActualDuration(workInProgress),
- workInProgress)
- : null;
+ return (
+ isContextProvider(workInProgress.type) && popContext(),
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128),
+ 0 !== (workInProgress.mode & 2) &&
+ transferActualDuration(workInProgress),
+ workInProgress)
+ : null
+ );
case 3:
- popHostContainer();
- pop(didPerformWorkStackCursor);
- pop(contextStackCursor);
- resetWorkInProgressVersions();
- flags = workInProgress.flags;
- if (0 !== (flags & 128))
- throw Error(
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
- );
- workInProgress.flags = (flags & -16385) | 128;
- return workInProgress;
+ return (
+ popHostContainer(),
+ pop(didPerformWorkStackCursor),
+ pop(contextStackCursor),
+ resetWorkInProgressVersions(),
+ (current = workInProgress.flags),
+ 0 !== (current & 65536) && 0 === (current & 128)
+ ? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
+ : null
+ );
case 5:
return popHostContext(workInProgress), null;
case 13:
return (
pop(suspenseStackCursor),
- (flags = workInProgress.flags),
- flags & 16384
- ? ((workInProgress.flags = (flags & -16385) | 128),
+ (current = workInProgress.flags),
+ current & 65536
+ ? ((workInProgress.flags = (current & -65537) | 128),
0 !== (workInProgress.mode & 2) &&
transferActualDuration(workInProgress),
workInProgress)
@@ -5564,7 +5728,7 @@ function commitBeforeMutationEffects(root, firstChild) {
if (
((root = nextEffect),
(firstChild = root.child),
- 0 !== (root.subtreeFlags & 516) && null !== firstChild)
+ 0 !== (root.subtreeFlags & 1028) && null !== firstChild)
)
(firstChild.return = root), (nextEffect = firstChild);
else
@@ -5572,7 +5736,7 @@ function commitBeforeMutationEffects(root, firstChild) {
root = nextEffect;
try {
var current = root.alternate;
- if (0 !== (root.flags & 512))
+ if (0 !== (root.flags & 1024))
switch (root.tag) {
case 0:
case 11:
@@ -5639,82 +5803,20 @@ function commitHookEffectListUnmount(
} while (effect !== updateQueue);
}
}
-function commitHookEffectListMount(tag, finishedWork) {
+function commitHookEffectListMount(flags, 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$88 = effect.create;
- effect.destroy = create$88();
+ if ((effect.tag & flags) === flags) {
+ var create$83 = effect.create;
+ effect.destroy = create$83();
}
effect = effect.next;
} while (effect !== finishedWork);
}
}
-function hideOrUnhideAllChildren(finishedWork, isHidden) {
- for (var hostSubtreeRoot = null, node = finishedWork; ; ) {
- if (5 === node.tag) {
- if (null === hostSubtreeRoot) {
- hostSubtreeRoot = node;
- 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) {
- if (null === hostSubtreeRoot) throw Error("Not yet implemented.");
- } else if (
- ((22 !== node.tag && 23 !== 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;
- hostSubtreeRoot === node && (hostSubtreeRoot = null);
- node = node.return;
- }
- hostSubtreeRoot === node && (hostSubtreeRoot = null);
- node.sibling.return = node.return;
- node = node.sibling;
- }
-}
function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount)
try {
@@ -5736,12 +5838,18 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
destroy = _effect.destroy;
_effect = _effect.tag;
void 0 !== destroy &&
- 0 !== (_effect & 2) &&
- (current.mode & 2
- ? (startLayoutEffectTimer(),
- safelyCallDestroy(current, nearestMountedAncestor, destroy),
- recordLayoutEffectDuration(current))
- : safelyCallDestroy(current, nearestMountedAncestor, destroy));
+ (0 !== (_effect & 2)
+ ? safelyCallDestroy(current, nearestMountedAncestor, destroy)
+ : 0 !== (_effect & 4) &&
+ (current.mode & 2
+ ? (startLayoutEffectTimer(),
+ safelyCallDestroy(current, nearestMountedAncestor, destroy),
+ recordLayoutEffectDuration(current))
+ : safelyCallDestroy(
+ current,
+ nearestMountedAncestor,
+ destroy
+ )));
effect = effect.next;
} while (effect !== finishedRoot);
}
@@ -5762,12 +5870,8 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
recordLayoutEffectDuration(current);
}
else finishedRoot.componentWillUnmount();
- } catch (unmountError) {
- captureCommitPhaseError(
- current,
- nearestMountedAncestor,
- unmountError
- );
+ } catch (error) {
+ captureCommitPhaseError(current, nearestMountedAncestor, error);
}
break;
case 5:
@@ -5796,6 +5900,25 @@ function detachFiberAfterEffects(fiber) {
function isHostParent(fiber) {
return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag;
}
+function getHostSibling(fiber) {
+ a: for (;;) {
+ for (; null === fiber.sibling; ) {
+ if (null === fiber.return || isHostParent(fiber.return)) return null;
+ fiber = fiber.return;
+ }
+ fiber.sibling.return = fiber.return;
+ for (
+ fiber = fiber.sibling;
+ 5 !== fiber.tag && 6 !== fiber.tag && 18 !== fiber.tag;
+
+ ) {
+ if (fiber.flags & 2) continue a;
+ if (null === fiber.child || 4 === fiber.tag) continue a;
+ else (fiber.child.return = fiber), (fiber = fiber.child);
+ }
+ if (!(fiber.flags & 2)) return fiber.stateNode;
+ }
+}
function commitPlacement(finishedWork) {
a: {
for (var parent = finishedWork.return; null !== parent; ) {
@@ -5807,57 +5930,28 @@ function commitPlacement(finishedWork) {
);
}
var parentFiber = parent;
- parent = parentFiber.stateNode;
switch (parentFiber.tag) {
case 5:
- var isContainer = !1;
+ parent = parentFiber.stateNode;
+ parentFiber.flags & 32 && (parentFiber.flags &= -33);
+ parentFiber = getHostSibling(finishedWork);
+ insertOrAppendPlacementNode(finishedWork, parentFiber, parent);
break;
case 3:
- parent = parent.containerInfo;
- isContainer = !0;
- break;
case 4:
- parent = parent.containerInfo;
- isContainer = !0;
+ parent = parentFiber.stateNode.containerInfo;
+ parentFiber = getHostSibling(finishedWork);
+ insertOrAppendPlacementNodeIntoContainer(
+ finishedWork,
+ parentFiber,
+ parent
+ );
break;
default:
throw Error(
"Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue."
);
}
- parentFiber.flags & 32 && (parentFiber.flags &= -33);
- a: b: for (parentFiber = finishedWork; ; ) {
- for (; null === parentFiber.sibling; ) {
- if (null === parentFiber.return || isHostParent(parentFiber.return)) {
- parentFiber = null;
- break a;
- }
- parentFiber = parentFiber.return;
- }
- parentFiber.sibling.return = parentFiber.return;
- for (
- parentFiber = parentFiber.sibling;
- 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag;
-
- ) {
- if (parentFiber.flags & 2) continue b;
- if (null === parentFiber.child || 4 === parentFiber.tag) continue b;
- else
- (parentFiber.child.return = parentFiber),
- (parentFiber = parentFiber.child);
- }
- if (!(parentFiber.flags & 2)) {
- parentFiber = parentFiber.stateNode;
- break a;
- }
- }
- isContainer
- ? insertOrAppendPlacementNodeIntoContainer(
- finishedWork,
- parentFiber,
- parent
- )
- : insertOrAppendPlacementNode(finishedWork, parentFiber, parent);
}
function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
var tag = node.tag;
@@ -6063,14 +6157,16 @@ function commitWork(current, finishedWork) {
case 11:
case 14:
case 15:
+ commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ commitHookEffectListMount(3, finishedWork);
if (finishedWork.mode & 2)
try {
startLayoutEffectTimer(),
- commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ commitHookEffectListUnmount(5, finishedWork, finishedWork.return);
} finally {
recordLayoutEffectDuration(finishedWork);
}
- else commitHookEffectListUnmount(3, finishedWork, finishedWork.return);
+ else commitHookEffectListUnmount(5, finishedWork, finishedWork.return);
return;
case 1:
return;
@@ -6114,9 +6210,6 @@ function commitWork(current, finishedWork) {
case 12:
return;
case 13:
- null !== finishedWork.memoizedState &&
- ((globalMostRecentFallbackTime = now()),
- hideOrUnhideAllChildren(finishedWork.child, !0));
attachSuspenseRetryListeners(finishedWork);
return;
case 19:
@@ -6124,13 +6217,6 @@ function commitWork(current, finishedWork) {
return;
case 17:
return;
- case 22:
- case 23:
- 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."
@@ -6178,14 +6264,14 @@ function commitMutationEffects(root, firstChild, committedLanes) {
}
}
committedLanes = firstChild.child;
- if (0 !== (firstChild.subtreeFlags & 6454) && null !== committedLanes)
+ if (0 !== (firstChild.subtreeFlags & 12854) && null !== committedLanes)
(committedLanes.return = firstChild), (nextEffect = committedLanes);
else
for (; null !== nextEffect; ) {
firstChild = nextEffect;
try {
var flags = firstChild.flags;
- if (flags & 256) {
+ if (flags & 512) {
var current = firstChild.alternate;
if (null !== current) {
committedLanes = current;
@@ -6202,7 +6288,88 @@ function commitMutationEffects(root, firstChild, committedLanes) {
else currentRef.current = null;
}
}
- switch (flags & 2054) {
+ if (flags & 8192)
+ switch (firstChild.tag) {
+ case 13:
+ if (null !== firstChild.memoizedState) {
+ var current$92 = firstChild.alternate;
+ if (null === current$92 || null === current$92.memoizedState)
+ globalMostRecentFallbackTime = now();
+ }
+ break;
+ case 22:
+ a: {
+ committedLanes = firstChild;
+ var isHidden = null !== firstChild.memoizedState;
+ i = null;
+ for (childToDelete = committedLanes; ; ) {
+ if (5 === childToDelete.tag) {
+ if (null === i) {
+ i = childToDelete;
+ var instance = childToDelete.stateNode;
+ if (isHidden) {
+ var instance$jscomp$0 = instance,
+ viewConfig = instance$jscomp$0.viewConfig;
+ var updatePayload = diffProperties(
+ null,
+ emptyObject,
+ { style: { display: "none" } },
+ viewConfig.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance$jscomp$0._nativeTag,
+ viewConfig.uiViewClassName,
+ updatePayload
+ );
+ } else {
+ var instance$jscomp$1 = childToDelete.stateNode,
+ props = childToDelete.memoizedProps,
+ viewConfig$jscomp$0 = instance$jscomp$1.viewConfig,
+ prevProps = assign({}, props, {
+ style: [props.style, { display: "none" }]
+ });
+ var updatePayload$jscomp$0 = diffProperties(
+ null,
+ prevProps,
+ props,
+ viewConfig$jscomp$0.validAttributes
+ );
+ ReactNativePrivateInterface.UIManager.updateView(
+ instance$jscomp$1._nativeTag,
+ viewConfig$jscomp$0.uiViewClassName,
+ updatePayload$jscomp$0
+ );
+ }
+ }
+ } else if (6 === childToDelete.tag) {
+ if (null === i) throw Error("Not yet implemented.");
+ } else if (
+ ((22 !== childToDelete.tag && 23 !== childToDelete.tag) ||
+ null === childToDelete.memoizedState ||
+ childToDelete === committedLanes) &&
+ null !== childToDelete.child
+ ) {
+ childToDelete.child.return = childToDelete;
+ childToDelete = childToDelete.child;
+ continue;
+ }
+ if (childToDelete === committedLanes) break;
+ for (; null === childToDelete.sibling; ) {
+ if (
+ null === childToDelete.return ||
+ childToDelete.return === committedLanes
+ )
+ break a;
+ i === childToDelete && (i = null);
+ childToDelete = childToDelete.return;
+ }
+ i === childToDelete && (i = null);
+ childToDelete.sibling.return = childToDelete.return;
+ childToDelete = childToDelete.sibling;
+ }
+ }
+ }
+ switch (flags & 4102) {
case 2:
commitPlacement(firstChild);
firstChild.flags &= -3;
@@ -6212,11 +6379,11 @@ function commitMutationEffects(root, firstChild, committedLanes) {
firstChild.flags &= -3;
commitWork(firstChild.alternate, firstChild);
break;
- case 2048:
- firstChild.flags &= -2049;
+ case 4096:
+ firstChild.flags &= -4097;
break;
- case 2052:
- firstChild.flags &= -2049;
+ case 4100:
+ firstChild.flags &= -4097;
commitWork(firstChild.alternate, firstChild);
break;
case 4:
@@ -6243,16 +6410,16 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
if (
((root = nextEffect),
(committedLanes = root.child),
- 0 !== (root.subtreeFlags & 324) && null !== committedLanes)
+ 0 !== (root.subtreeFlags & 8772) && null !== committedLanes)
)
(committedLanes.return = root), (nextEffect = committedLanes);
else
for (root = finishedWork; null !== nextEffect; ) {
committedLanes = nextEffect;
- if (0 !== (committedLanes.flags & 324)) {
+ if (0 !== (committedLanes.flags & 8772)) {
var current = committedLanes.alternate;
try {
- if (0 !== (committedLanes.flags & 68))
+ if (0 !== (committedLanes.flags & 8772))
switch (committedLanes.tag) {
case 0:
case 11:
@@ -6260,11 +6427,11 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
if (committedLanes.mode & 2)
try {
startLayoutEffectTimer(),
- commitHookEffectListMount(3, committedLanes);
+ commitHookEffectListMount(5, committedLanes);
} finally {
recordLayoutEffectDuration(committedLanes);
}
- else commitHookEffectListMount(3, committedLanes);
+ else commitHookEffectListMount(5, committedLanes);
break;
case 1:
var instance = committedLanes.stateNode;
@@ -6310,21 +6477,21 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
commitUpdateQueue(committedLanes, updateQueue, instance);
break;
case 3:
- var updateQueue$90 = committedLanes.updateQueue;
- if (null !== updateQueue$90) {
- var instance$91 = null;
+ var updateQueue$85 = committedLanes.updateQueue;
+ if (null !== updateQueue$85) {
+ var instance$86 = null;
if (null !== committedLanes.child)
switch (committedLanes.child.tag) {
case 5:
- instance$91 = committedLanes.child.stateNode;
+ instance$86 = committedLanes.child.stateNode;
break;
case 1:
- instance$91 = committedLanes.child.stateNode;
+ instance$86 = committedLanes.child.stateNode;
}
commitUpdateQueue(
committedLanes,
- updateQueue$90,
- instance$91
+ updateQueue$85,
+ instance$86
);
}
break;
@@ -6339,7 +6506,7 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
onCommit = _finishedWork$memoize2.onCommit,
onRender = _finishedWork$memoize2.onRender,
effectDuration = committedLanes.stateNode.effectDuration;
- instance$91 = commitTime;
+ instance$86 = commitTime;
current = null === current ? "mount" : "update";
currentUpdateIsNested && (current = "nested-update");
"function" === typeof onRender &&
@@ -6349,14 +6516,14 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
committedLanes.actualDuration,
committedLanes.treeBaseDuration,
committedLanes.actualStartTime,
- instance$91
+ instance$86
);
"function" === typeof onCommit &&
onCommit(
committedLanes.memoizedProps.id,
current,
effectDuration,
- instance$91
+ instance$86
);
enqueuePendingPassiveProfilerEffect(committedLanes);
var parentFiber = committedLanes.return;
@@ -6385,28 +6552,28 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
"This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
);
}
- if (committedLanes.flags & 256) {
- instance$91 = void 0;
+ if (committedLanes.flags & 512) {
+ instance$86 = void 0;
current = committedLanes;
var ref = current.ref;
if (null !== ref) {
var instance$jscomp$0 = current.stateNode;
switch (current.tag) {
case 5:
- instance$91 = instance$jscomp$0;
+ instance$86 = instance$jscomp$0;
break;
default:
- instance$91 = instance$jscomp$0;
+ instance$86 = instance$jscomp$0;
}
if ("function" === typeof ref)
if (current.mode & 2)
try {
- startLayoutEffectTimer(), ref(instance$91);
+ startLayoutEffectTimer(), ref(instance$86);
} finally {
recordLayoutEffectDuration(current);
}
- else ref(instance$91);
- else ref.current = instance$91;
+ else ref(instance$86);
+ else ref.current = instance$86;
}
}
} catch (error) {
@@ -6421,10 +6588,10 @@ function commitLayoutEffects(finishedWork, root, committedLanes) {
nextEffect = null;
break;
}
- instance$91 = committedLanes.sibling;
- if (null !== instance$91) {
- instance$91.return = committedLanes.return;
- nextEffect = instance$91;
+ instance$86 = committedLanes.sibling;
+ if (null !== instance$86) {
+ instance$86.return = committedLanes.return;
+ nextEffect = instance$86;
break;
}
nextEffect = committedLanes.return;
@@ -6444,8 +6611,10 @@ var ceil = Math.ceil,
workInProgressRootExitStatus = 0,
workInProgressRootFatalError = null,
workInProgressRootSkippedLanes = 0,
- workInProgressRootUpdatedLanes = 0,
+ workInProgressRootInterleavedUpdatedLanes = 0,
workInProgressRootPingedLanes = 0,
+ workInProgressRootConcurrentErrors = null,
+ workInProgressRootRecoverableErrors = null,
globalMostRecentFallbackTime = 0,
workInProgressRootRenderTargetTime = Infinity,
hasUncaughtError = !1,
@@ -6460,7 +6629,7 @@ var ceil = Math.ceil,
currentEventTime = -1,
currentEventTransitionLane = 0;
function requestEventTime() {
- return 0 !== (executionContext & 24)
+ return 0 !== (executionContext & 6)
? now()
: -1 !== currentEventTime
? currentEventTime
@@ -6468,9 +6637,9 @@ function requestEventTime() {
}
function requestUpdateLane(fiber) {
if (0 === (fiber.mode & 1)) return 1;
- if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes)
+ if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes)
return workInProgressRootRenderLanes & -workInProgressRootRenderLanes;
- if (0 !== ReactCurrentBatchConfig.transition)
+ if (null !== ReactCurrentBatchConfig.transition)
return (
0 === currentEventTransitionLane &&
((fiber = nextTransitionLane),
@@ -6491,21 +6660,20 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) {
));
var root = markUpdateLaneFromFiberToRoot(fiber, lane);
if (null === root) return null;
- isDevToolsPresent && addFiberToLanesMap(root, fiber, lane);
markRootUpdated(root, lane, eventTime);
- root === workInProgressRoot &&
- (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane),
- 4 === workInProgressRootExitStatus &&
- markRootSuspended$1(root, workInProgressRootRenderLanes));
- 1 === lane
- ? 0 !== (executionContext & 4) && 0 === (executionContext & 24)
- ? performSyncWorkOnRoot(root)
- : (ensureRootIsScheduled(root, eventTime),
+ if (0 === (executionContext & 2) || root !== workInProgressRoot)
+ isDevToolsPresent && addFiberToLanesMap(root, fiber, lane),
+ root === workInProgressRoot &&
+ (0 === (executionContext & 2) &&
+ (workInProgressRootInterleavedUpdatedLanes |= lane),
+ 4 === workInProgressRootExitStatus &&
+ markRootSuspended$1(root, workInProgressRootRenderLanes)),
+ ensureRootIsScheduled(root, eventTime),
+ 1 === lane &&
0 === executionContext &&
- 0 === (fiber.mode & 1) &&
- ((workInProgressRootRenderTargetTime = now() + 500),
- includesLegacySyncCallbacks && flushSyncCallbacks()))
- : ensureRootIsScheduled(root, eventTime);
+ 0 === (fiber.mode & 1) &&
+ ((workInProgressRootRenderTargetTime = now() + 500),
+ includesLegacySyncCallbacks && flushSyncCallbacks());
return root;
}
function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
@@ -6583,7 +6751,7 @@ function ensureRootIsScheduled(root, currentTime) {
default:
existingCallbackNode = NormalPriority;
}
- existingCallbackNode = scheduleCallback(
+ existingCallbackNode = scheduleCallback$1(
existingCallbackNode,
performConcurrentWorkOnRoot.bind(null, root)
);
@@ -6596,7 +6764,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
nestedUpdateScheduled = currentUpdateIsNested = !1;
currentEventTime = -1;
currentEventTransitionLane = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var originalCallbackNode = root.callbackNode;
if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode)
@@ -6606,12 +6774,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
root === workInProgressRoot ? workInProgressRootRenderLanes : 0
);
if (0 === lanes) return null;
- var JSCompiler_inline_result =
- 0 !== (lanes & root.expiredLanes) ? !1 : 0 === (lanes & 30);
- if (JSCompiler_inline_result && !didTimeout) {
+ if (0 !== (lanes & 30) || 0 !== (lanes & root.expiredLanes) || didTimeout)
+ didTimeout = renderRootSync(root, lanes);
+ else {
didTimeout = lanes;
- JSCompiler_inline_result = executionContext;
- executionContext |= 8;
+ var prevExecutionContext = executionContext;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
if (
workInProgressRoot !== root ||
@@ -6637,99 +6805,117 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
while (1);
resetContextDependencies();
ReactCurrentDispatcher$2.current = prevDispatcher;
- executionContext = JSCompiler_inline_result;
+ executionContext = prevExecutionContext;
null !== workInProgress
? (didTimeout = 0)
: ((workInProgressRoot = null),
(workInProgressRootRenderLanes = 0),
(didTimeout = workInProgressRootExitStatus));
- } else didTimeout = renderRootSync(root, lanes);
+ }
if (0 !== didTimeout) {
2 === didTimeout &&
- ((executionContext |= 32),
- root.hydrate && (root.hydrate = !1),
- (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)),
- 0 !== JSCompiler_inline_result &&
- ((lanes = JSCompiler_inline_result),
- (didTimeout = renderRootSync(root, JSCompiler_inline_result))));
+ ((prevExecutionContext = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevExecutionContext &&
+ ((lanes = prevExecutionContext),
+ (didTimeout = recoverFromConcurrentError(root, prevExecutionContext))));
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 2:
- commitRoot(root);
- break;
- case 3:
- markRootSuspended$1(root, lanes);
- if (
- (lanes & 130023424) === lanes &&
- ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
- 10 < didTimeout)
- ) {
- if (0 !== getNextLanes(root, 0)) break;
- JSCompiler_inline_result = root.suspendedLanes;
- if ((JSCompiler_inline_result & lanes) !== lanes) {
- requestEventTime();
- root.pingedLanes |= root.suspendedLanes & JSCompiler_inline_result;
+ if (6 === didTimeout) markRootSuspended$1(root, lanes);
+ else {
+ prevExecutionContext = root.current.alternate;
+ if (
+ 0 === (lanes & 30) &&
+ !isRenderConsistentWithExternalStores(prevExecutionContext) &&
+ ((didTimeout = renderRootSync(root, lanes)),
+ 2 === didTimeout &&
+ ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)),
+ 0 !== prevDispatcher &&
+ ((lanes = prevDispatcher),
+ (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))),
+ 1 === didTimeout)
+ )
+ throw ((originalCallbackNode = workInProgressRootFatalError),
+ prepareFreshStack(root, 0),
+ markRootSuspended$1(root, lanes),
+ ensureRootIsScheduled(root, now()),
+ originalCallbackNode);
+ root.finishedWork = prevExecutionContext;
+ root.finishedLanes = lanes;
+ switch (didTimeout) {
+ case 0:
+ case 1:
+ throw Error("Root did not complete. This is a bug in React.");
+ case 2:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ case 3:
+ markRootSuspended$1(root, lanes);
+ if (
+ (lanes & 130023424) === lanes &&
+ ((didTimeout = globalMostRecentFallbackTime + 500 - now()),
+ 10 < didTimeout)
+ ) {
+ 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, workInProgressRootRecoverableErrors),
+ didTimeout
+ );
break;
}
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- didTimeout
- );
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 4:
- markRootSuspended$1(root, lanes);
- if ((lanes & 4194240) === lanes) break;
- didTimeout = root.eventTimes;
- for (JSCompiler_inline_result = -1; 0 < lanes; )
- (memoizedUpdaters = 31 - clz32(lanes)),
- (prevDispatcher = 1 << memoizedUpdaters),
- (memoizedUpdaters = didTimeout[memoizedUpdaters]),
- memoizedUpdaters > JSCompiler_inline_result &&
- (JSCompiler_inline_result = memoizedUpdaters),
- (lanes &= ~prevDispatcher);
- lanes = JSCompiler_inline_result;
- lanes = now() - lanes;
- lanes =
- (120 > lanes
- ? 120
- : 480 > lanes
- ? 480
- : 1080 > lanes
- ? 1080
- : 1920 > lanes
- ? 1920
- : 3e3 > lanes
- ? 3e3
- : 4320 > lanes
- ? 4320
- : 1960 * ceil(lanes / 1960)) - lanes;
- if (10 < lanes) {
- root.timeoutHandle = scheduleTimeout(
- commitRoot.bind(null, root),
- lanes
- );
+ case 4:
+ markRootSuspended$1(root, lanes);
+ if ((lanes & 4194240) === lanes) break;
+ didTimeout = root.eventTimes;
+ for (prevExecutionContext = -1; 0 < lanes; )
+ (memoizedUpdaters = 31 - clz32(lanes)),
+ (prevDispatcher = 1 << memoizedUpdaters),
+ (memoizedUpdaters = didTimeout[memoizedUpdaters]),
+ memoizedUpdaters > prevExecutionContext &&
+ (prevExecutionContext = memoizedUpdaters),
+ (lanes &= ~prevDispatcher);
+ lanes = prevExecutionContext;
+ lanes = now() - lanes;
+ lanes =
+ (120 > lanes
+ ? 120
+ : 480 > lanes
+ ? 480
+ : 1080 > lanes
+ ? 1080
+ : 1920 > lanes
+ ? 1920
+ : 3e3 > lanes
+ ? 3e3
+ : 4320 > lanes
+ ? 4320
+ : 1960 * ceil(lanes / 1960)) - lanes;
+ if (10 < lanes) {
+ root.timeoutHandle = scheduleTimeout(
+ commitRoot.bind(null, root, workInProgressRootRecoverableErrors),
+ lanes
+ );
+ break;
+ }
+ commitRoot(root, workInProgressRootRecoverableErrors);
break;
- }
- commitRoot(root);
- break;
- case 5:
- commitRoot(root);
- break;
- default:
- throw Error("Unknown root exit status.");
+ case 5:
+ commitRoot(root, workInProgressRootRecoverableErrors);
+ break;
+ default:
+ throw Error("Unknown root exit status.");
+ }
}
}
ensureRootIsScheduled(root, now());
@@ -6737,9 +6923,60 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
? performConcurrentWorkOnRoot.bind(null, root)
: null;
}
+function recoverFromConcurrentError(root, errorRetryLanes) {
+ var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
+ root.current.memoizedState.isDehydrated &&
+ (prepareFreshStack(root, errorRetryLanes).flags |= 256);
+ root = renderRootSync(root, errorRetryLanes);
+ 2 !== root &&
+ ((errorRetryLanes = workInProgressRootRecoverableErrors),
+ (workInProgressRootRecoverableErrors = errorsFromFirstAttempt),
+ null !== errorRetryLanes &&
+ (null === workInProgressRootRecoverableErrors
+ ? (workInProgressRootRecoverableErrors = errorRetryLanes)
+ : workInProgressRootRecoverableErrors.push.apply(
+ workInProgressRootRecoverableErrors,
+ errorRetryLanes
+ )));
+ return root;
+}
+function isRenderConsistentWithExternalStores(finishedWork) {
+ for (var node = finishedWork; ; ) {
+ if (node.flags & 16384) {
+ var updateQueue = node.updateQueue;
+ if (
+ null !== updateQueue &&
+ ((updateQueue = updateQueue.stores), null !== updateQueue)
+ )
+ for (var i = 0; i < updateQueue.length; i++) {
+ var check = updateQueue[i],
+ getSnapshot = check.getSnapshot;
+ check = check.value;
+ try {
+ if (!objectIs(getSnapshot(), check)) return !1;
+ } catch (error) {
+ return !1;
+ }
+ }
+ }
+ updateQueue = node.child;
+ if (node.subtreeFlags & 16384 && null !== updateQueue)
+ (updateQueue.return = node), (node = updateQueue);
+ else {
+ if (node === finishedWork) break;
+ for (; null === node.sibling; ) {
+ if (null === node.return || node.return === finishedWork) return !0;
+ node = node.return;
+ }
+ node.sibling.return = node.return;
+ node = node.sibling;
+ }
+ }
+ return !0;
+}
function markRootSuspended$1(root, suspendedLanes) {
suspendedLanes &= ~workInProgressRootPingedLanes;
- suspendedLanes &= ~workInProgressRootUpdatedLanes;
+ suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes;
root.suspendedLanes |= suspendedLanes;
root.pingedLanes &= ~suspendedLanes;
for (root = root.expirationTimes; 0 < suspendedLanes; ) {
@@ -6752,18 +6989,17 @@ function markRootSuspended$1(root, suspendedLanes) {
function performSyncWorkOnRoot(root) {
currentUpdateIsNested = nestedUpdateScheduled;
nestedUpdateScheduled = !1;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
flushPassiveEffects();
var lanes = getNextLanes(root, 0);
if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null;
var exitStatus = renderRootSync(root, lanes);
if (0 !== root.tag && 2 === exitStatus) {
- executionContext |= 32;
- root.hydrate && (root.hydrate = !1);
var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
0 !== errorRetryLanes &&
- ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes)));
+ ((lanes = errorRetryLanes),
+ (exitStatus = recoverFromConcurrentError(root, errorRetryLanes)));
}
if (1 === exitStatus)
throw ((exitStatus = workInProgressRootFatalError),
@@ -6771,9 +7007,11 @@ function performSyncWorkOnRoot(root) {
markRootSuspended$1(root, lanes),
ensureRootIsScheduled(root, now()),
exitStatus);
+ if (6 === exitStatus)
+ throw Error("Root did not complete. This is a bug in React.");
root.finishedWork = root.current.alternate;
root.finishedLanes = lanes;
- commitRoot(root);
+ commitRoot(root, workInProgressRootRecoverableErrors);
ensureRootIsScheduled(root, now());
return null;
}
@@ -6790,6 +7028,7 @@ function prepareFreshStack(root, lanes) {
if (null !== workInProgress)
for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) {
var interruptedWork = timeoutHandle;
+ popTreeContext(interruptedWork);
switch (interruptedWork.tag) {
case 1:
interruptedWork = interruptedWork.type.childContextTypes;
@@ -6825,30 +7064,32 @@ function prepareFreshStack(root, lanes) {
timeoutHandle = timeoutHandle.return;
}
workInProgressRoot = root;
- workInProgress = createWorkInProgress(root.current, null);
+ workInProgress = root = createWorkInProgress(root.current, null);
workInProgressRootRenderLanes = subtreeRenderLanes = lanes;
workInProgressRootExitStatus = 0;
workInProgressRootFatalError = null;
- workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootPingedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0;
+ workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors = null;
if (null !== interleavedQueues) {
- for (root = 0; root < interleavedQueues.length; root++)
+ for (lanes = 0; lanes < interleavedQueues.length; lanes++)
if (
- ((lanes = interleavedQueues[root]),
- (timeoutHandle = lanes.interleaved),
- null !== timeoutHandle)
+ ((timeoutHandle = interleavedQueues[lanes]),
+ (interruptedWork = timeoutHandle.interleaved),
+ null !== interruptedWork)
) {
- lanes.interleaved = null;
- interruptedWork = timeoutHandle.next;
- var lastPendingUpdate = lanes.pending;
+ timeoutHandle.interleaved = null;
+ var firstInterleavedUpdate = interruptedWork.next,
+ lastPendingUpdate = timeoutHandle.pending;
if (null !== lastPendingUpdate) {
var firstPendingUpdate = lastPendingUpdate.next;
- lastPendingUpdate.next = interruptedWork;
- timeoutHandle.next = firstPendingUpdate;
+ lastPendingUpdate.next = firstInterleavedUpdate;
+ interruptedWork.next = firstPendingUpdate;
}
- lanes.pending = timeoutHandle;
+ timeoutHandle.pending = interruptedWork;
}
interleavedQueues = null;
}
+ return root;
}
function handleError(root$jscomp$0, thrownValue) {
do {
@@ -6886,7 +7127,7 @@ function handleError(root$jscomp$0, thrownValue) {
sourceFiber = erroredWork,
value = thrownValue;
thrownValue = workInProgressRootRenderLanes;
- sourceFiber.flags |= 8192;
+ sourceFiber.flags |= 32768;
isDevToolsPresent && restorePendingUpdaters(root, thrownValue);
if (
null !== value &&
@@ -6894,54 +7135,52 @@ function handleError(root$jscomp$0, thrownValue) {
"function" === typeof value.then
) {
var wakeable = value,
- tag = sourceFiber.tag;
+ sourceFiber$jscomp$0 = sourceFiber,
+ tag = sourceFiber$jscomp$0.tag;
if (
- 0 === (sourceFiber.mode & 1) &&
+ 0 === (sourceFiber$jscomp$0.mode & 1) &&
(0 === tag || 11 === tag || 15 === tag)
) {
- var currentSource = sourceFiber.alternate;
+ var currentSource = sourceFiber$jscomp$0.alternate;
currentSource
- ? ((sourceFiber.updateQueue = currentSource.updateQueue),
- (sourceFiber.memoizedState = currentSource.memoizedState),
- (sourceFiber.lanes = currentSource.lanes))
- : ((sourceFiber.updateQueue = null),
- (sourceFiber.memoizedState = null));
+ ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue),
+ (sourceFiber$jscomp$0.memoizedState =
+ currentSource.memoizedState),
+ (sourceFiber$jscomp$0.lanes = currentSource.lanes))
+ : ((sourceFiber$jscomp$0.updateQueue = null),
+ (sourceFiber$jscomp$0.memoizedState = null));
}
- var hasInvisibleParentBoundary =
- 0 !== (suspenseStackCursor.current & 1),
- workInProgress$34 = returnFiber;
- do {
- var JSCompiler_temp;
- if ((JSCompiler_temp = 13 === workInProgress$34.tag)) {
- var nextState = workInProgress$34.memoizedState;
- if (null !== nextState)
- JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
- else {
- var props = workInProgress$34.memoizedProps;
+ b: {
+ sourceFiber$jscomp$0 = returnFiber;
+ do {
+ var JSCompiler_temp;
+ if ((JSCompiler_temp = 13 === sourceFiber$jscomp$0.tag)) {
+ var nextState = sourceFiber$jscomp$0.memoizedState;
JSCompiler_temp =
- void 0 === props.fallback
- ? !1
- : !0 !== props.unstable_avoidThisFallback
- ? !0
- : hasInvisibleParentBoundary
- ? !1
+ null !== nextState
+ ? null !== nextState.dehydrated
+ ? !0
+ : !1
: !0;
}
- }
- if (JSCompiler_temp) {
- var wakeables = workInProgress$34.updateQueue;
- if (null === wakeables) {
- var updateQueue = new Set();
- updateQueue.add(wakeable);
- workInProgress$34.updateQueue = updateQueue;
- } else wakeables.add(wakeable);
- if (
- 0 === (workInProgress$34.mode & 1) &&
- workInProgress$34 !== returnFiber
- ) {
- workInProgress$34.flags |= 128;
- sourceFiber.flags |= 32768;
- sourceFiber.flags &= -10053;
+ if (JSCompiler_temp) {
+ var suspenseBoundary = sourceFiber$jscomp$0;
+ break b;
+ }
+ sourceFiber$jscomp$0 = sourceFiber$jscomp$0.return;
+ } while (null !== sourceFiber$jscomp$0);
+ suspenseBoundary = null;
+ }
+ if (null !== suspenseBoundary) {
+ suspenseBoundary.flags &= -257;
+ value = suspenseBoundary;
+ sourceFiber$jscomp$0 = thrownValue;
+ if (0 === (value.mode & 1))
+ if (value === returnFiber) value.flags |= 65536;
+ else {
+ value.flags |= 128;
+ sourceFiber.flags |= 131072;
+ sourceFiber.flags &= -52805;
if (1 === sourceFiber.tag)
if (null === sourceFiber.alternate) sourceFiber.tag = 17;
else {
@@ -6950,84 +7189,78 @@ function handleError(root$jscomp$0, thrownValue) {
enqueueUpdate(sourceFiber, update);
}
sourceFiber.lanes |= 1;
- break a;
- }
- value = void 0;
- sourceFiber = thrownValue;
- var pingCache = root.pingCache;
- null === pingCache
- ? ((pingCache = root.pingCache = new PossiblyWeakMap()),
- (value = new Set()),
- pingCache.set(wakeable, value))
- : ((value = pingCache.get(wakeable)),
- void 0 === value &&
- ((value = new Set()), pingCache.set(wakeable, value)));
- if (!value.has(sourceFiber)) {
- value.add(sourceFiber);
- var ping = pingSuspendedRoot.bind(
- null,
- root,
- wakeable,
- sourceFiber
- );
- isDevToolsPresent && restorePendingUpdaters(root, sourceFiber);
- wakeable.then(ping, ping);
}
- workInProgress$34.flags |= 16384;
- workInProgress$34.lanes = thrownValue;
+ else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0);
+ suspenseBoundary.mode & 1 &&
+ attachPingListener(root, wakeable, thrownValue);
+ thrownValue = suspenseBoundary;
+ root = wakeable;
+ var wakeables = thrownValue.updateQueue;
+ if (null === wakeables) {
+ var updateQueue = new Set();
+ updateQueue.add(root);
+ thrownValue.updateQueue = updateQueue;
+ } else wakeables.add(root);
+ break a;
+ } else {
+ if (0 === (thrownValue & 1)) {
+ attachPingListener(root, wakeable, thrownValue);
+ renderDidSuspendDelayIfPossible();
break a;
}
- workInProgress$34 = workInProgress$34.return;
- } while (null !== workInProgress$34);
- value = Error(
- (getComponentNameFromFiber(sourceFiber) || "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."
- );
+ value = Error(
+ "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition."
+ );
+ }
}
- 5 !== workInProgressRootExitStatus &&
+ root = value;
+ 4 !== workInProgressRootExitStatus &&
(workInProgressRootExitStatus = 2);
+ null === workInProgressRootConcurrentErrors
+ ? (workInProgressRootConcurrentErrors = [root])
+ : workInProgressRootConcurrentErrors.push(root);
value = createCapturedValue(value, sourceFiber);
- workInProgress$34 = returnFiber;
+ root = returnFiber;
do {
- switch (workInProgress$34.tag) {
+ switch (root.tag) {
case 3:
- root = value;
- workInProgress$34.flags |= 16384;
+ wakeable = value;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$34.lanes |= thrownValue;
- var update$35 = createRootErrorUpdate(
- workInProgress$34,
+ root.lanes |= thrownValue;
+ var update$jscomp$0 = createRootErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$34, update$35);
+ enqueueCapturedUpdate(root, update$jscomp$0);
break a;
case 1:
- root = value;
- var ctor = workInProgress$34.type,
- instance = workInProgress$34.stateNode;
+ wakeable = value;
+ var ctor = root.type,
+ instance = root.stateNode;
if (
- 0 === (workInProgress$34.flags & 128) &&
+ 0 === (root.flags & 128) &&
("function" === typeof ctor.getDerivedStateFromError ||
(null !== instance &&
"function" === typeof instance.componentDidCatch &&
(null === legacyErrorBoundariesThatAlreadyFailed ||
!legacyErrorBoundariesThatAlreadyFailed.has(instance))))
) {
- workInProgress$34.flags |= 16384;
+ root.flags |= 65536;
thrownValue &= -thrownValue;
- workInProgress$34.lanes |= thrownValue;
- var update$38 = createClassErrorUpdate(
- workInProgress$34,
+ root.lanes |= thrownValue;
+ var update$35 = createClassErrorUpdate(
root,
+ wakeable,
thrownValue
);
- enqueueCapturedUpdate(workInProgress$34, update$38);
+ enqueueCapturedUpdate(root, update$35);
break a;
}
}
- workInProgress$34 = workInProgress$34.return;
- } while (null !== workInProgress$34);
+ root = root.return;
+ } while (null !== root);
}
completeUnitOfWork(erroredWork);
} catch (yetAnotherThrownValue) {
@@ -7045,9 +7278,21 @@ function pushDispatcher() {
ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
}
+function renderDidSuspendDelayIfPossible() {
+ if (
+ 0 === workInProgressRootExitStatus ||
+ 3 === workInProgressRootExitStatus ||
+ 2 === workInProgressRootExitStatus
+ )
+ workInProgressRootExitStatus = 4;
+ null === workInProgressRoot ||
+ (0 === (workInProgressRootSkippedLanes & 268435455) &&
+ 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) ||
+ markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
+}
function renderRootSync(root, lanes) {
var prevExecutionContext = executionContext;
- executionContext |= 8;
+ executionContext |= 2;
var prevDispatcher = pushDispatcher();
if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
if (isDevToolsPresent) {
@@ -7104,7 +7349,7 @@ function completeUnitOfWork(unitOfWork) {
do {
var current = completedWork.alternate;
unitOfWork = completedWork.return;
- if (0 === (completedWork.flags & 8192)) {
+ if (0 === (completedWork.flags & 32768)) {
if (0 === (completedWork.mode & 2))
current = completeWork(current, completedWork, subtreeRenderLanes);
else {
@@ -7119,9 +7364,9 @@ function completeUnitOfWork(unitOfWork) {
return;
}
} else {
- current = unwindWork(completedWork);
+ current = unwindWork(current, completedWork);
if (null !== current) {
- current.flags &= 8191;
+ current.flags &= 32767;
workInProgress = current;
return;
}
@@ -7132,10 +7377,15 @@ function completeUnitOfWork(unitOfWork) {
(current += fiber.actualDuration), (fiber = fiber.sibling);
completedWork.actualDuration = current;
}
- null !== unitOfWork &&
- ((unitOfWork.flags |= 8192),
- (unitOfWork.subtreeFlags = 0),
- (unitOfWork.deletions = null));
+ if (null !== unitOfWork)
+ (unitOfWork.flags |= 32768),
+ (unitOfWork.subtreeFlags = 0),
+ (unitOfWork.deletions = null);
+ else {
+ workInProgressRootExitStatus = 6;
+ workInProgress = null;
+ return;
+ }
}
completedWork = completedWork.sibling;
if (null !== completedWork) {
@@ -7146,23 +7396,23 @@ function completeUnitOfWork(unitOfWork) {
} while (null !== completedWork);
0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5);
}
-function commitRoot(root) {
+function commitRoot(root, recoverableErrors) {
var previousUpdateLanePriority = currentUpdatePriority,
prevTransition = ReactCurrentBatchConfig$2.transition;
try {
- (ReactCurrentBatchConfig$2.transition = 0),
+ (ReactCurrentBatchConfig$2.transition = null),
(currentUpdatePriority = 1),
- commitRootImpl(root, previousUpdateLanePriority);
+ commitRootImpl(root, recoverableErrors, previousUpdateLanePriority);
} finally {
(ReactCurrentBatchConfig$2.transition = prevTransition),
(currentUpdatePriority = previousUpdateLanePriority);
}
return null;
}
-function commitRootImpl(root, renderPriorityLevel) {
+function commitRootImpl(root, recoverableErrors, renderPriorityLevel) {
do flushPassiveEffects();
while (null !== rootWithPendingPassiveEffects);
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Should not already be working.");
var finishedWork = root.finishedWork,
lanes = root.finishedLanes;
@@ -7180,22 +7430,22 @@ function commitRootImpl(root, renderPriorityLevel) {
root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
(workInProgressRootRenderLanes = 0));
- (0 === (finishedWork.subtreeFlags & 1040) &&
- 0 === (finishedWork.flags & 1040)) ||
+ (0 === (finishedWork.subtreeFlags & 2064) &&
+ 0 === (finishedWork.flags & 2064)) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
}));
- remainingLanes = 0 !== (finishedWork.flags & 8054);
- if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) {
+ remainingLanes = 0 !== (finishedWork.flags & 15990);
+ if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) {
remainingLanes = ReactCurrentBatchConfig$2.transition;
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
var previousPriority = currentUpdatePriority;
currentUpdatePriority = 1;
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
ReactCurrentOwner$2.current = null;
commitBeforeMutationEffects(root, finishedWork);
commitTime = now$1();
@@ -7213,24 +7463,31 @@ function commitRootImpl(root, renderPriorityLevel) {
(pendingPassiveEffectsLanes = lanes));
remainingLanes = root.pendingLanes;
0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
- 0 !== (remainingLanes & 1)
- ? ((nestedUpdateScheduled = !0),
- root === rootWithNestedUpdates
- ? nestedUpdateCount++
- : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)))
- : (nestedUpdateCount = 0);
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
isDevToolsPresent && root.memoizedUpdaters.clear();
ensureRootIsScheduled(root, now());
+ if (null !== recoverableErrors)
+ for (
+ renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
+ finishedWork < recoverableErrors.length;
+ finishedWork++
+ )
+ renderPriorityLevel(recoverableErrors[finishedWork]);
if (hasUncaughtError)
throw ((hasUncaughtError = !1),
(root = firstUncaughtError),
(firstUncaughtError = null),
root);
- if (0 !== (executionContext & 4)) return null;
0 !== (pendingPassiveEffectsLanes & 1) &&
0 !== root.tag &&
flushPassiveEffects();
+ remainingLanes = root.pendingLanes;
+ 0 !== (remainingLanes & 1)
+ ? ((nestedUpdateScheduled = !0),
+ root === rootWithNestedUpdates
+ ? nestedUpdateCount++
+ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)))
+ : (nestedUpdateCount = 0);
flushSyncCallbacks();
return null;
}
@@ -7240,7 +7497,7 @@ function flushPassiveEffects() {
prevTransition = ReactCurrentBatchConfig$2.transition,
previousPriority = currentUpdatePriority;
try {
- ReactCurrentBatchConfig$2.transition = 0;
+ ReactCurrentBatchConfig$2.transition = null;
currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority;
if (null === rootWithPendingPassiveEffects)
var JSCompiler_inline_result = !1;
@@ -7248,10 +7505,10 @@ function flushPassiveEffects() {
renderPriority = rootWithPendingPassiveEffects;
rootWithPendingPassiveEffects = null;
pendingPassiveEffectsLanes = 0;
- if (0 !== (executionContext & 24))
+ if (0 !== (executionContext & 6))
throw Error("Cannot flush passive effects while already rendering.");
var prevExecutionContext = executionContext;
- executionContext |= 16;
+ executionContext |= 4;
for (nextEffect = renderPriority.current; null !== nextEffect; ) {
var fiber = nextEffect,
child = fiber.child;
@@ -7269,9 +7526,9 @@ function flushPassiveEffects() {
case 15:
current.mode & 2
? ((passiveEffectStartTime = now$1()),
- commitHookEffectListUnmount(4, current, fiber),
+ commitHookEffectListUnmount(8, current, fiber),
recordPassiveEffectDuration(current))
- : commitHookEffectListUnmount(4, current, fiber);
+ : commitHookEffectListUnmount(8, current, fiber);
}
var child$jscomp$0 = fiber$jscomp$0.child;
if (null !== child$jscomp$0)
@@ -7311,21 +7568,21 @@ function flushPassiveEffects() {
nextEffect = fiber;
}
}
- if (0 !== (fiber.subtreeFlags & 1040) && null !== child)
+ if (0 !== (fiber.subtreeFlags & 2064) && null !== child)
(child.return = fiber), (nextEffect = child);
else
b: for (; null !== nextEffect; ) {
fiber = nextEffect;
- if (0 !== (fiber.flags & 1024))
+ if (0 !== (fiber.flags & 2048))
switch (((i = fiber), i.tag)) {
case 0:
case 11:
case 15:
i.mode & 2
? ((passiveEffectStartTime = now$1()),
- commitHookEffectListUnmount(5, i, i.return),
+ commitHookEffectListUnmount(9, i, i.return),
recordPassiveEffectDuration(i))
- : commitHookEffectListUnmount(5, i, i.return);
+ : commitHookEffectListUnmount(9, i, i.return);
}
var sibling$jscomp$0 = fiber.sibling;
if (null !== sibling$jscomp$0) {
@@ -7340,12 +7597,12 @@ function flushPassiveEffects() {
for (nextEffect = finishedWork; null !== nextEffect; ) {
child = nextEffect;
var firstChild = child.child;
- if (0 !== (child.subtreeFlags & 1040) && null !== firstChild)
+ if (0 !== (child.subtreeFlags & 2064) && null !== firstChild)
(firstChild.return = child), (nextEffect = firstChild);
else
b: for (child = finishedWork; null !== nextEffect; ) {
deletions = nextEffect;
- if (0 !== (deletions.flags & 1024))
+ if (0 !== (deletions.flags & 2048))
try {
switch (((fiberToDelete = deletions), fiberToDelete.tag)) {
case 0:
@@ -7354,11 +7611,11 @@ function flushPassiveEffects() {
if (fiberToDelete.mode & 2) {
passiveEffectStartTime = now$1();
try {
- commitHookEffectListMount(5, fiberToDelete);
+ commitHookEffectListMount(9, fiberToDelete);
} finally {
recordPassiveEffectDuration(fiberToDelete);
}
- } else commitHookEffectListMount(5, fiberToDelete);
+ } else commitHookEffectListMount(9, fiberToDelete);
}
} catch (error) {
captureCommitPhaseError(deletions, deletions.return, error);
@@ -7439,7 +7696,7 @@ function enqueuePendingPassiveProfilerEffect(fiber) {
pendingPassiveProfilerEffects.push(fiber);
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
- scheduleCallback(NormalPriority, function() {
+ scheduleCallback$1(NormalPriority, function() {
flushPassiveEffects();
return null;
}));
@@ -7534,7 +7791,6 @@ function resolveRetryWakeable(boundaryFiber, wakeable) {
}
var beginWork$1;
beginWork$1 = function(current, workInProgress, renderLanes) {
- var updateLanes = workInProgress.lanes;
if (null !== current)
if (
current.memoizedProps !== workInProgress.pendingProps ||
@@ -7542,165 +7798,98 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
)
didReceiveUpdate = !0;
else {
- if (0 === (renderLanes & updateLanes)) {
- 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.type._context;
- var nextValue = workInProgress.memoizedProps.value;
- push(valueCursor, updateLanes._currentValue);
- updateLanes._currentValue = nextValue;
- break;
- case 12:
- 0 !== (renderLanes & workInProgress.childLanes) &&
- (workInProgress.flags |= 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,
- renderLanes
- );
- return null !== workInProgress ? workInProgress.sibling : null;
- }
- push(suspenseStackCursor, suspenseStackCursor.current & 1);
- break;
- case 19:
- updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
- if (0 !== (current.flags & 128)) {
- if (updateLanes)
- return updateSuspenseListComponent(
- current,
- workInProgress,
- renderLanes
- );
- workInProgress.flags |= 128;
- }
- nextValue = workInProgress.memoizedState;
- null !== nextValue &&
- ((nextValue.rendering = null),
- (nextValue.tail = null),
- (nextValue.lastEffect = null));
- push(suspenseStackCursor, suspenseStackCursor.current);
- if (updateLanes) break;
- else return null;
- case 22:
- case 23:
- return (
- (workInProgress.lanes = 0),
- updateOffscreenComponent(current, workInProgress, renderLanes)
- );
- }
- return bailoutOnAlreadyFinishedWork(
- current,
- workInProgress,
- renderLanes
+ if (
+ 0 === (current.lanes & renderLanes) &&
+ 0 === (workInProgress.flags & 128)
+ )
+ return (
+ (didReceiveUpdate = !1),
+ attemptEarlyBailoutIfNoScheduledUpdate(
+ current,
+ workInProgress,
+ renderLanes
+ )
);
- }
- didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1;
+ didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1;
}
else didReceiveUpdate = !1;
workInProgress.lanes = 0;
switch (workInProgress.tag) {
case 2:
- updateLanes = workInProgress.type;
+ var Component = workInProgress.type;
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- nextValue = getMaskedContext(workInProgress, contextStackCursor.current);
+ var context = getMaskedContext(
+ workInProgress,
+ contextStackCursor.current
+ );
prepareToReadContext(workInProgress, renderLanes);
- nextValue = renderWithHooks(
+ context = renderWithHooks(
null,
workInProgress,
- updateLanes,
+ Component,
current,
- nextValue,
+ context,
renderLanes
);
workInProgress.flags |= 1;
if (
- "object" === typeof nextValue &&
- null !== nextValue &&
- "function" === typeof nextValue.render &&
- void 0 === nextValue.$$typeof
+ "object" === typeof context &&
+ null !== context &&
+ "function" === typeof context.render &&
+ void 0 === context.$$typeof
) {
workInProgress.tag = 1;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
- if (isContextProvider(updateLanes)) {
+ if (isContextProvider(Component)) {
var hasContext = !0;
pushContextProvider(workInProgress);
} else hasContext = !1;
workInProgress.memoizedState =
- null !== nextValue.state && void 0 !== nextValue.state
- ? nextValue.state
+ null !== context.state && void 0 !== context.state
+ ? context.state
: null;
initializeUpdateQueue(workInProgress);
- nextValue.updater = classComponentUpdater;
- workInProgress.stateNode = nextValue;
- nextValue._reactInternals = workInProgress;
- mountClassInstance(workInProgress, updateLanes, current, renderLanes);
+ context.updater = classComponentUpdater;
+ workInProgress.stateNode = context;
+ context._reactInternals = workInProgress;
+ mountClassInstance(workInProgress, Component, current, renderLanes);
workInProgress = finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
hasContext,
renderLanes
);
} else
(workInProgress.tag = 0),
- reconcileChildren(null, workInProgress, nextValue, renderLanes),
+ reconcileChildren(null, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child);
return workInProgress;
case 16:
- nextValue = workInProgress.elementType;
+ Component = workInProgress.elementType;
a: {
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2));
current = workInProgress.pendingProps;
- hasContext = nextValue._init;
- nextValue = hasContext(nextValue._payload);
- workInProgress.type = nextValue;
- hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue);
- current = resolveDefaultProps(nextValue, current);
- switch (hasContext) {
+ context = Component._init;
+ Component = context(Component._payload);
+ workInProgress.type = Component;
+ context = workInProgress.tag = resolveLazyComponentTag(Component);
+ current = resolveDefaultProps(Component, current);
+ switch (context) {
case 0:
workInProgress = updateFunctionComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7709,7 +7898,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateClassComponent(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7718,7 +7907,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateForwardRef(
null,
workInProgress,
- nextValue,
+ Component,
current,
renderLanes
);
@@ -7727,79 +7916,75 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress = updateMemoComponent(
null,
workInProgress,
- nextValue,
- resolveDefaultProps(nextValue.type, current),
- updateLanes,
+ Component,
+ resolveDefaultProps(Component.type, current),
renderLanes
);
break a;
}
throw Error(
"Element type is invalid. Received a promise that resolves to: " +
- nextValue +
+ Component +
". Lazy element type must resolve to a class or function."
);
}
return workInProgress;
case 0:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateFunctionComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 1:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateClassComponent(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
case 3:
pushHostRootContext(workInProgress);
- 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."
- );
- nextValue = workInProgress.pendingProps;
- updateLanes = workInProgress.memoizedState.element;
+ if (null === current)
+ throw Error("Should have a current fiber. This is a bug in React.");
+ context = workInProgress.pendingProps;
+ Component = workInProgress.memoizedState.element;
cloneUpdateQueue(current, workInProgress);
- processUpdateQueue(workInProgress, nextValue, null, renderLanes);
- nextValue = workInProgress.memoizedState.element;
- nextValue === updateLanes
+ processUpdateQueue(workInProgress, context, null, renderLanes);
+ context = workInProgress.memoizedState.element;
+ context === Component
? (workInProgress = bailoutOnAlreadyFinishedWork(
current,
workInProgress,
renderLanes
))
- : (reconcileChildren(current, workInProgress, nextValue, renderLanes),
+ : (reconcileChildren(current, workInProgress, context, renderLanes),
(workInProgress = workInProgress.child));
return workInProgress;
case 5:
return (
pushHostContext(workInProgress),
- (updateLanes = workInProgress.pendingProps.children),
- markRef(current, workInProgress),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ (Component = workInProgress.pendingProps.children),
+ markRef$1(current, workInProgress),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 6:
@@ -7812,35 +7997,30 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.stateNode.containerInfo
),
- (updateLanes = workInProgress.pendingProps),
+ (Component = workInProgress.pendingProps),
null === current
? (workInProgress.child = reconcileChildFibers(
workInProgress,
null,
- updateLanes,
+ Component,
renderLanes
))
- : reconcileChildren(
- current,
- workInProgress,
- updateLanes,
- renderLanes
- ),
+ : reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 11:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
updateForwardRef(
current,
workInProgress,
- updateLanes,
- nextValue,
+ Component,
+ context,
renderLanes
)
);
@@ -7867,9 +8047,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
case 12:
return (
(workInProgress.flags |= 4),
- (updateLanes = workInProgress.stateNode),
- (updateLanes.effectDuration = 0),
- (updateLanes.passiveEffectDuration = 0),
+ (Component = workInProgress.stateNode),
+ (Component.effectDuration = 0),
+ (Component.passiveEffectDuration = 0),
reconcileChildren(
current,
workInProgress,
@@ -7880,16 +8060,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
);
case 10:
a: {
- updateLanes = workInProgress.type._context;
- nextValue = workInProgress.pendingProps;
+ Component = workInProgress.type._context;
+ context = workInProgress.pendingProps;
hasContext = workInProgress.memoizedProps;
- var newValue = nextValue.value;
- push(valueCursor, updateLanes._currentValue);
- updateLanes._currentValue = newValue;
+ var newValue = context.value;
+ push(valueCursor, Component._currentValue);
+ Component._currentValue = newValue;
if (null !== hasContext)
if (objectIs(hasContext.value, newValue)) {
if (
- hasContext.children === nextValue.children &&
+ hasContext.children === context.children &&
!didPerformWorkStackCursor.current
) {
workInProgress = bailoutOnAlreadyFinishedWork(
@@ -7914,7 +8094,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
null !== dependency;
) {
- if (dependency.context === updateLanes) {
+ if (dependency.context === Component) {
if (1 === newValue.tag) {
dependency = createUpdate(-1, renderLanes & -renderLanes);
dependency.tag = 2;
@@ -7932,7 +8112,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
newValue.lanes |= renderLanes;
dependency = newValue.alternate;
null !== dependency && (dependency.lanes |= renderLanes);
- scheduleWorkOnParentPath(newValue.return, renderLanes);
+ scheduleContextWorkOnParentPath(
+ newValue.return,
+ renderLanes,
+ workInProgress
+ );
list.lanes |= renderLanes;
break;
}
@@ -7965,7 +8149,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
reconcileChildren(
current,
workInProgress,
- nextValue.children,
+ context.children,
renderLanes
);
workInProgress = workInProgress.child;
@@ -7973,29 +8157,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return workInProgress;
case 9:
return (
- (nextValue = workInProgress.type),
- (updateLanes = workInProgress.pendingProps.children),
+ (context = workInProgress.type),
+ (Component = workInProgress.pendingProps.children),
prepareToReadContext(workInProgress, renderLanes),
- (nextValue = readContext(nextValue)),
- (updateLanes = updateLanes(nextValue)),
+ (context = readContext(context)),
+ (Component = Component(context)),
(workInProgress.flags |= 1),
- reconcileChildren(current, workInProgress, updateLanes, renderLanes),
+ reconcileChildren(current, workInProgress, Component, renderLanes),
workInProgress.child
);
case 14:
return (
- (nextValue = workInProgress.type),
- (hasContext = resolveDefaultProps(
- nextValue,
- workInProgress.pendingProps
- )),
- (hasContext = resolveDefaultProps(nextValue.type, hasContext)),
+ (Component = workInProgress.type),
+ (context = resolveDefaultProps(Component, workInProgress.pendingProps)),
+ (context = resolveDefaultProps(Component.type, context)),
updateMemoComponent(
current,
workInProgress,
- nextValue,
- hasContext,
- updateLanes,
+ Component,
+ context,
renderLanes
)
);
@@ -8005,32 +8185,31 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
workInProgress,
workInProgress.type,
workInProgress.pendingProps,
- updateLanes,
renderLanes
);
case 17:
return (
- (updateLanes = workInProgress.type),
- (nextValue = workInProgress.pendingProps),
- (nextValue =
- workInProgress.elementType === updateLanes
- ? nextValue
- : resolveDefaultProps(updateLanes, nextValue)),
+ (Component = workInProgress.type),
+ (context = workInProgress.pendingProps),
+ (context =
+ workInProgress.elementType === Component
+ ? context
+ : resolveDefaultProps(Component, context)),
null !== current &&
((current.alternate = null),
(workInProgress.alternate = null),
(workInProgress.flags |= 2)),
(workInProgress.tag = 1),
- isContextProvider(updateLanes)
+ isContextProvider(Component)
? ((current = !0), pushContextProvider(workInProgress))
: (current = !1),
prepareToReadContext(workInProgress, renderLanes),
- constructClassInstance(workInProgress, updateLanes, nextValue),
- mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes),
+ constructClassInstance(workInProgress, Component, context),
+ mountClassInstance(workInProgress, Component, context, renderLanes),
finishClassComponent(
null,
workInProgress,
- updateLanes,
+ Component,
!0,
current,
renderLanes
@@ -8040,8 +8219,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) {
return updateSuspenseListComponent(current, workInProgress, renderLanes);
case 22:
return updateOffscreenComponent(current, workInProgress, renderLanes);
- case 23:
- return updateOffscreenComponent(current, workInProgress, renderLanes);
}
throw Error(
"Unknown unit of work tag (" +
@@ -8055,6 +8232,9 @@ function restorePendingUpdaters(root, lanes) {
addFiberToLanesMap(root, schedulingFiber, lanes);
});
}
+function scheduleCallback$1(priorityLevel, callback) {
+ return scheduleCallback(priorityLevel, callback);
+}
function FiberNode(tag, pendingProps, key, mode) {
this.tag = tag;
this.key = key;
@@ -8110,7 +8290,7 @@ function createWorkInProgress(current, pendingProps) {
(workInProgress.deletions = null),
(workInProgress.actualDuration = 0),
(workInProgress.actualStartTime = -1));
- workInProgress.flags = current.flags & 1835008;
+ workInProgress.flags = current.flags & 14680064;
workInProgress.childLanes = current.childLanes;
workInProgress.lanes = current.lanes;
workInProgress.child = current.child;
@@ -8145,10 +8325,6 @@ function createFiberFromTypeAndProps(
a: switch (type) {
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
- case REACT_DEBUG_TRACING_MODE_TYPE:
- fiberTag = 8;
- mode |= 4;
- break;
case REACT_STRICT_MODE_TYPE:
fiberTag = 8;
mode |= 8;
@@ -8177,13 +8353,6 @@ function createFiberFromTypeAndProps(
);
case REACT_OFFSCREEN_TYPE:
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
- case REACT_LEGACY_HIDDEN_TYPE:
- return (
- (type = createFiber(23, pendingProps, key, mode)),
- (type.elementType = REACT_LEGACY_HIDDEN_TYPE),
- (type.lanes = lanes),
- type
- );
default:
if ("object" === typeof type && null !== type)
switch (type.$$typeof) {
@@ -8206,8 +8375,7 @@ function createFiberFromTypeAndProps(
}
throw Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- (null == type ? type : typeof type) +
- "."
+ ((null == type ? type : typeof type) + ".")
);
}
key = createFiber(fiberTag, pendingProps, key, mode);
@@ -8225,6 +8393,7 @@ function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
pendingProps = createFiber(22, pendingProps, key, mode);
pendingProps.elementType = REACT_OFFSCREEN_TYPE;
pendingProps.lanes = lanes;
+ pendingProps.stateNode = {};
return pendingProps;
}
function createFiberFromText(content, mode, lanes) {
@@ -8247,19 +8416,25 @@ function createFiberFromPortal(portal, mode, lanes) {
};
return mode;
}
-function FiberRootNode(containerInfo, tag, hydrate) {
+function FiberRootNode(
+ containerInfo,
+ tag,
+ hydrate,
+ identifierPrefix,
+ onRecoverableError
+) {
this.tag = tag;
this.containerInfo = containerInfo;
this.finishedWork = this.pingCache = this.current = this.pendingChildren = null;
this.timeoutHandle = -1;
- this.pendingContext = this.context = null;
- this.hydrate = hydrate;
- this.callbackNode = null;
+ this.callbackNode = this.pendingContext = this.context = null;
this.callbackPriority = 0;
this.eventTimes = createLaneMap(0);
this.expirationTimes = createLaneMap(-1);
this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0;
this.entanglements = createLaneMap(0);
+ this.identifierPrefix = identifierPrefix;
+ this.onRecoverableError = onRecoverableError;
this.passiveEffectDuration = this.effectDuration = 0;
this.memoizedUpdaters = new Set();
containerInfo = this.pendingUpdatersLaneMap = [];
@@ -8281,9 +8456,9 @@ function findHostInstance(component) {
if (void 0 === fiber) {
if ("function" === typeof component.render)
throw Error("Unable to find node on an unmounted component.");
+ component = Object.keys(component).join(",");
throw Error(
- "Argument appears to not be a ReactComponent. Keys: " +
- Object.keys(component)
+ "Argument appears to not be a ReactComponent. Keys: " + component
);
}
component = findCurrentHostFiber(fiber);
@@ -8365,6 +8540,9 @@ function findNodeHandle(componentOrHandle) {
? componentOrHandle.canonical._nativeTag
: componentOrHandle._nativeTag;
}
+function onRecoverableError(error) {
+ console.error(error);
+}
function unmountComponentAtNode(containerTag) {
var root = roots.get(containerTag);
root &&
@@ -8385,10 +8563,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
- devToolsConfig$jscomp$inline_1013 = {
+ devToolsConfig$jscomp$inline_1003 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
- version: "18.0.0-experimental-568dc3532",
+ version: "18.0.0-experimental-34aa5cfe0-20220329",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@@ -8403,11 +8581,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
-var internals$jscomp$inline_1287 = {
- bundleType: devToolsConfig$jscomp$inline_1013.bundleType,
- version: devToolsConfig$jscomp$inline_1013.version,
- rendererPackageName: devToolsConfig$jscomp$inline_1013.rendererPackageName,
- rendererConfig: devToolsConfig$jscomp$inline_1013.rendererConfig,
+var internals$jscomp$inline_1277 = {
+ bundleType: devToolsConfig$jscomp$inline_1003.bundleType,
+ version: devToolsConfig$jscomp$inline_1003.version,
+ rendererPackageName: devToolsConfig$jscomp$inline_1003.rendererPackageName,
+ rendererConfig: devToolsConfig$jscomp$inline_1003.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@@ -8423,26 +8601,26 @@ var internals$jscomp$inline_1287 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
- devToolsConfig$jscomp$inline_1013.findFiberByHostInstance ||
+ devToolsConfig$jscomp$inline_1003.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
- reconcilerVersion: "18.0.0-experimental-568dc3532"
+ reconcilerVersion: "18.0.0-experimental-34aa5cfe0-20220329"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
- var hook$jscomp$inline_1288 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+ var hook$jscomp$inline_1278 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
- !hook$jscomp$inline_1288.isDisabled &&
- hook$jscomp$inline_1288.supportsFiber
+ !hook$jscomp$inline_1278.isDisabled &&
+ hook$jscomp$inline_1278.supportsFiber
)
try {
- (rendererID = hook$jscomp$inline_1288.inject(
- internals$jscomp$inline_1287
+ (rendererID = hook$jscomp$inline_1278.inject(
+ internals$jscomp$inline_1277
)),
- (injectedHook = hook$jscomp$inline_1288);
+ (injectedHook = hook$jscomp$inline_1278);
} catch (err) {}
}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
@@ -8462,12 +8640,10 @@ exports.createPortal = function(children, containerTag) {
};
exports.dispatchCommand = function(handle, command, args) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.dispatchCommand(
- handle._internalInstanceHandle.stateNode.node,
- command,
- args
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.dispatchCommand(handle.node, command, args))
: ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand(
handle._nativeTag,
command,
@@ -8487,10 +8663,11 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
: componentOrHandle;
};
exports.findNodeHandle = findNodeHandle;
+exports.getInspectorDataForInstance = void 0;
exports.render = function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
- root = new FiberRootNode(containerTag, 0, !1);
+ root = new FiberRootNode(containerTag, 0, !1, "", onRecoverableError);
var JSCompiler_inline_result = 0;
isDevToolsPresent && (JSCompiler_inline_result |= 2);
JSCompiler_inline_result = createFiber(
@@ -8501,7 +8678,12 @@ exports.render = function(element, containerTag, callback) {
);
root.current = JSCompiler_inline_result;
JSCompiler_inline_result.stateNode = root;
- JSCompiler_inline_result.memoizedState = { element: null };
+ JSCompiler_inline_result.memoizedState = {
+ element: null,
+ isDehydrated: !1,
+ cache: null,
+ transitions: null
+ };
initializeUpdateQueue(JSCompiler_inline_result);
roots.set(containerTag, root);
}
@@ -8519,11 +8701,10 @@ exports.render = function(element, containerTag, callback) {
};
exports.sendAccessibilityEvent = function(handle, eventType) {
null != handle._nativeTag &&
- (handle._internalInstanceHandle
- ? nativeFabricUIManager.sendAccessibilityEvent(
- handle._internalInstanceHandle.stateNode.node,
- eventType
- )
+ (null != handle._internalInstanceHandle
+ ? ((handle = handle._internalInstanceHandle.stateNode),
+ null != handle &&
+ nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType))
: ReactNativePrivateInterface.legacySendAccessibilityEvent(
handle._nativeTag,
eventType
@@ -8535,3 +8716,13 @@ exports.unmountComponentAtNodeAndRemoveContainer = function(containerTag) {
ReactNativePrivateInterface.UIManager.removeRootView(containerTag);
};
exports.unstable_batchedUpdates = batchedUpdates;
+
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
+ 'function'
+) {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
+}
+
diff --git a/package.json b/package.json
index 26a81fa9a1857e..a35ea14a21ca6c 100644
--- a/package.json
+++ b/package.json
@@ -94,7 +94,7 @@
"repo-config"
],
"peerDependencies": {
- "react": "17.0.2"
+ "react": "18.0.0"
},
"dependencies": {
"@jest/create-cache-key-function": "^27.0.1",
@@ -124,7 +124,7 @@
"react-refresh": "^0.4.0",
"react-shallow-renderer": "16.14.1",
"regenerator-runtime": "^0.13.2",
- "scheduler": "^0.20.2",
+ "scheduler": "^0.21.0",
"stacktrace-parser": "^0.1.3",
"use-subscription": ">=1.0.0 <1.6.0",
"whatwg-fetch": "^3.0.0",
@@ -133,7 +133,8 @@
},
"devDependencies": {
"flow-bin": "^0.175.1",
- "react": "17.0.2"
+ "react": "18.0.0",
+ "react-test-renderer": "^18.0.0"
},
"beachball": {
"shouldPublish": false
diff --git a/template/package.json b/template/package.json
index bc3ff76f653f62..787908469eb0db 100644
--- a/template/package.json
+++ b/template/package.json
@@ -11,7 +11,7 @@
"lint": "eslint ."
},
"dependencies": {
- "react": "17.0.2",
+ "react": "18.0.0",
"react-native-macos": "1000.0.0"
},
"devDependencies": {
@@ -22,7 +22,7 @@
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.70.1",
- "react-test-renderer": "17.0.2"
+ "react-test-renderer": "18.0.0"
},
"jest": {
"preset": "react-native"
diff --git a/yarn.lock b/yarn.lock
index 1ecaa00547c58d..e5104db354a152 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6735,6 +6735,11 @@ react-is@^16.13.1, react-is@^16.8.4:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
+react-is@^18.0.0:
+ version "18.0.0"
+ resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.0.0.tgz#026f6c4a27dbe33bf4a35655b9e1327c4e55e3f5"
+ integrity sha512-yUcBYdBBbo3QiPsgYDcfQcIkGZHfxOaoE6HLSnr1sPzMhdyxusbfKOSUbSd/ocGi32dxcj366PsTj+5oggeKKw==
+
react-native-codegen@^0.0.17:
version "0.0.17"
resolved "https://registry.yarnpkg.com/react-native-codegen/-/react-native-codegen-0.0.17.tgz#83fb814d94061cbd46667f510d2ddba35ffb50ac"
@@ -6776,6 +6781,15 @@ react-test-renderer@17.0.2:
react-shallow-renderer "^16.13.1"
scheduler "^0.20.2"
+react-test-renderer@^18.0.0:
+ version "18.0.0"
+ resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-18.0.0.tgz#fa403d625ea9478a70ace43db88833f6c3a5bb4c"
+ integrity sha512-SyZTP/FSkwfiKOZuTZiISzsrC8A80KNlQ8PyyoGoOq+VzMAab6Em1POK/CiX3+XyXG6oiJa1C53zYDbdrJu9fw==
+ dependencies:
+ react-is "^18.0.0"
+ react-shallow-renderer "^16.13.1"
+ scheduler "^0.21.0"
+
react@17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
@@ -6784,6 +6798,13 @@ react@17.0.2:
loose-envify "^1.1.0"
object-assign "^4.1.1"
+react@18.0.0:
+ version "18.0.0"
+ resolved "https://registry.yarnpkg.com/react/-/react-18.0.0.tgz#b468736d1f4a5891f38585ba8e8fb29f91c3cb96"
+ integrity sha512-x+VL6wbT4JRVPm7EGxXhZ8w8LTROaxPXOqhlGyVSrv0sB1jkyFGgXxJ8LVoPRLvPR6/CIZGFmfzqUa2NYeMr2A==
+ dependencies:
+ loose-envify "^1.1.0"
+
read-pkg-up@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507"
@@ -7123,6 +7144,13 @@ scheduler@^0.20.2:
loose-envify "^1.1.0"
object-assign "^4.1.1"
+scheduler@^0.21.0:
+ version "0.21.0"
+ resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0.tgz#6fd2532ff5a6d877b6edb12f00d8ab7e8f308820"
+ integrity sha512-1r87x5fz9MXqswA2ERLo0EbOAU74DpIUO090gIasYTqlVoJeMcl+Z1Rg7WHz+qtPujhS/hGIt9kxZOYBV3faRQ==
+ dependencies:
+ loose-envify "^1.1.0"
+
"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
@@ -8153,10 +8181,10 @@ xml@^1.0.1:
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==
-xmlbuilder@^15.1.1:
- version "15.1.1"
- resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-15.1.1.tgz#9dcdce49eea66d8d10b42cae94a79c3c8d0c2ec5"
- integrity sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==
+xmlbuilder@^9.0.7:
+ version "9.0.7"
+ resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
+ integrity sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==
xmlchars@^2.2.0:
version "2.2.0"